| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 | using CCWin;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using WCS_Client.Utility;namespace WCS_Client.From{    public partial class FromMain : Form    {        System.Timers.Timer _timer;        public FromMain()        {            InitializeComponent();            InitFrm();        }        private void InitFrm()        {            #region 初始化任务栏            string sX = "";            try            {                DateTime D = CurrentHelper.User.Use_LoginTime;                switch (D.DayOfWeek)                {                    case DayOfWeek.Sunday:                        sX = "日";                        break;                    case DayOfWeek.Monday:                        sX = "一";                        break;                    case DayOfWeek.Tuesday:                        sX = "二";                        break;                    case DayOfWeek.Wednesday:                        sX = "三";                        break;                    case DayOfWeek.Thursday:                        sX = "四";                        break;                    case DayOfWeek.Friday:                        sX = "五";                        break;                    case DayOfWeek.Saturday:                        sX = "六";                        break;                }            }            catch            {            }            toolStripStatusLabel1.Text = string.Format("【{0}】【{1}】【{2}】【星期{3}】", CurrentHelper.User.Use_Name, CurrentHelper.User.Use_RoleName, CurrentHelper.User.Use_LoginTime, sX);            toolStripStatusLabel2.Text = "苏州博众精工科技有限公司版权所有";            this.MainMenuStrip = skinMenuStrip1;            #endregion        }        private void tsmtUser_Click(object sender, EventArgs e)        {            if (CurrentHelper.User.Use_RoleName == "系统管理员")            {                FromUser fu = FromUser.ChildFromInstanc;                if (fu != null)                {                    fu.ShowIcon = false;                    fu.MdiParent = this;                    fu.Show();//显示子窗体                }            }            else            {                MessageBox.Show("普通管理员无权限打开该页面。");            }        }        private void tsmt_Calc_Click(object sender, EventArgs e)        {            #region [ 启动计算器 ]            System.Diagnostics.Process Proc;            try            {                // 启动计算器                Proc = new System.Diagnostics.Process();                Proc.StartInfo.FileName = "calc.exe";                Proc.StartInfo.UseShellExecute = false;                Proc.StartInfo.RedirectStandardInput = true;                Proc.StartInfo.RedirectStandardOutput = true;                Proc.Start();            }            catch            {                Proc = null;            }            #endregion        }        #region [ API: 记事本 ]        /// <summary>        /// 传递消息给记事本        /// </summary>        /// <param name="hWnd"></param>        /// <param name="Msg"></param>        /// <param name="wParam"></param>        /// <param name="lParam"></param>        /// <returns></returns>        [DllImport("User32.DLL")]        public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);        /// <summary>        /// 查找句柄        /// </summary>        /// <param name="hwndParent"></param>        /// <param name="hwndChildAfter"></param>        /// <param name="lpszClass"></param>        /// <param name="lpszWindow"></param>        /// <returns></returns>        [DllImport("User32.DLL")]        public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);        /// <summary>        /// 记事本需要的常量        /// </summary>        public const uint WM_SETTEXT = 0x000C;        #endregion        private void tsmt_Book_Click(object sender, EventArgs e)        {            #region [ 启动记事本 ]            System.Diagnostics.Process Proc;            try            {                // 启动记事本                Proc = new System.Diagnostics.Process();                Proc.StartInfo.FileName = "notepad.exe";                Proc.StartInfo.UseShellExecute = false;                Proc.StartInfo.RedirectStandardInput = true;                Proc.StartInfo.RedirectStandardOutput = true;                Proc.Start();            }            catch            {                Proc = null;            }            #endregion            #region [ 传递数据给记事本 ]            if (Proc != null)            {                // 调用 API, 传递数据                while (Proc.MainWindowHandle == IntPtr.Zero)                {                    Proc.Refresh();                }                IntPtr vHandle = FindWindowEx(Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);                // 传递数据给记事本                SendMessage(vHandle, WM_SETTEXT, 0, "");            }            #endregion        }        private void tsmt_SysReset_Click(object sender, EventArgs e)        {            Application.Restart();        }        private void tsmt_SysExit_Click(object sender, EventArgs e)        {            Application.Exit();        }        private void skinMenuStrip1_ItemAdded(object sender, ToolStripItemEventArgs e)        {            //若需要保留还原及最小化按钮,条件仅需e.Item.Text.Length == 0            if (e.Item.Text.Length == 0 || e.Item.Text == "还原(&R)" || e.Item.Text == "最小化(&N)")            {                e.Item.Visible = false;            }        }        private void tsmt_task_Click(object sender, EventArgs e)        {            Form_Task fu = Form_Task.ChildFromInstanc;            if (fu != null)            {                fu.ShowIcon = false;                fu.MdiParent = this;                fu.Show();//显示子窗体            }        }        private void tsmt_TaskDis_Click(object sender, EventArgs e)        {            Form_TaskDis fu = Form_TaskDis.ChildFromInstanc;            if (fu != null)            {                fu.ShowIcon = false;                fu.MdiParent = this;                fu.Show();//显示子窗体            }        }        private void tsmaterInMontior_Click(object sender, EventArgs e)        {            Form_Monitior fu = Form_Monitior.ChildFromInstanc;            if (fu != null)            {                //fu.ShowIcon = false;                //fu.MdiParent = this;                fu.Show();//显示子窗体            }        }        private void tsmtQueryLog_Click(object sender, EventArgs e)        {            System.Diagnostics.Process.Start(@"D:\项目\科勒\Code\WCS\BZ_WCS\WCSService\App_Log");        }        private void tsmtSystemSet_Click(object sender, EventArgs e)        {            if (CurrentHelper.User.Use_RoleName == "系统管理员")            {                Form_SystemSet systemSet = Form_SystemSet.ChildFromInstanc;                if (systemSet != null)                {                    systemSet.ShowIcon = false;                    systemSet.MdiParent = this;                    systemSet.Show();                }            }            else            {                MessageBox.Show("普通管理员无权限打开该页面。");            }        }        private void tsmtSrmDataQuery_Click(object sender, EventArgs e)        {            Form_SrmData sd = Form_SrmData.ChildFromInstanc;            if (sd != null)            {                sd.ShowIcon = false;                sd.MdiParent = this;                sd.Show();//显示子窗体            }        }        private void tsmiEquLockQuery_Click(object sender, EventArgs e)        {            if (CurrentHelper.User.Use_RoleName == "系统管理员")            {                Form_EquLockQuery systemSet = Form_EquLockQuery.ChildFromInstanc;                if (systemSet != null)                {                    systemSet.ShowIcon = false;                    systemSet.MdiParent = this;                    systemSet.Show();                }            }            else            {                MessageBox.Show("普通管理员无权限打开该页面。");            }        }        private void FromMain_Load(object sender, EventArgs e)        {            _timer = new System.Timers.Timer(5000);            _timer.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;            _timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);            _timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;        }        private void theout(object sender, EventArgs e)        {            CommHelper.ClearMemory();        }        private void 立体库料箱物流设备监控ToolStripMenuItem_Click(object sender, EventArgs e)        {            Form_Monitior_Box fu = Form_Monitior_Box.ChildFromInstanc;            if (fu != null)            {                //fu.ShowIcon = false;                //fu.MdiParent = this;                fu.Show();//显示子窗体            }        }        static DataTable dt = null;        private static DataTable Dt        {            get            {                if (dt == null)                {                    dt = new DataTable();                    dt.Columns.Add("USER_NO");                }                return dt;            }        }        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)        {            DataRow row = Dt.NewRow();            row["USER_NO"] = CurrentHelper.User.USER_NO;            var editpwd = new FormEditPwd(row);            editpwd.ShowDialog();        }        private void 历史报警记录查询ToolStripMenuItem_Click(object sender, EventArgs e)        {            var alaramrecord = FrmALARAMRECORD.ChildFromInstanc;            if (alaramrecord != null)            {                alaramrecord.ShowIcon = false;                alaramrecord.MdiParent = this;                alaramrecord.Show();//显示子窗体            }        }        //private void tsmtTwo_Click(object sender, EventArgs e)        //{        //    Form_materInMontior fu = Form_materInMontior.ChildFromInstanc;        //    if (fu != null)        //    {        //        //fu.ShowIcon = false;        //        //fu.MdiParent = this;        //        fu.Show();//显示子窗体        //    }        //}    }}
 |