Пример #1
0
        //void showInfo()
        //{
        //    CustomUIControls.TaskbarNotifier taskbarNotifier1;
        //    taskbarNotifier1 = new CustomUIControls.TaskbarNotifier();
        //    taskbarNotifier1.SetBackgroundBitmap(new Bitmap(Image.FromFile(@"../../pic/skin_logo.bmp")), Color.FromArgb(255, 0, 255));
        //    taskbarNotifier1.SetCloseBitmap(new Bitmap(Image.FromFile(@"../../pic/close_logo.bmp")), Color.FromArgb(255, 0, 255), new Point(190, 12));
        //    taskbarNotifier1.TitleRectangle = new Rectangle(65, 25, 135, 60);
        //    taskbarNotifier1.ContentRectangle = new Rectangle(15, 65, 205, 150);
        //    taskbarNotifier1.CloseClickable = true;
        //    taskbarNotifier1.TitleClickable = false;
        //    taskbarNotifier1.ContentClickable = false;
        //    taskbarNotifier1.EnableSelectionRectangle = false;
        //    taskbarNotifier1.KeepVisibleOnMousOver = true;
        //    taskbarNotifier1.ReShowOnMouseOver = true;
        //    taskbarNotifier1.Show("提示", "正在连接服务器", 500, 2000, 500);
        //    System.Console.WriteLine("thread");
        //}


        public MainForm()
        {
            readSQLConfig();
            //Thread FormThread = new Thread(new ThreadStart(ThreadFunc));
            //FormThread.Start();

            //Parameter.InitConnUser(); //初始化连接到有用户表的数据库
            //Parameter.ConnUserInit();
            LoginForm login = new LoginForm(this);

            login.ShowDialog();



            InitializeComponent();
            userLabel.Text = Parameter.userName;
            InitTaskBar();
            //SearchUnchecked();


            // 接收指令
            mySystem.Other.我的任务 f = new Other.我的任务();

            //f.set指令(test);
            //f.Show();
            String instru = receiveInstr();

            if (instru != null)
            {
                f.set指令(instru);
                f.ShowDialog();
                if (instru != null && instru.Contains("吹膜"))
                {
                    MainProduceBtn.PerformClick();
                    processForm.Btn吹膜.PerformClick();
                }
            }



            check库存预警();
            timer1.Interval = interval;
            timer1.Start();

            // 检查登陆状态的定时器
            timer2.Interval = timer2Interval; // 一分钟
            timer2.Start();


            // 试用
            // 读取配置文件中的  sy
            // 如果没有,则写入日期:2017/11/11
            // 读取日期,看看是否到了
            //

            //
            string        file   = System.Windows.Forms.Application.ExecutablePath;
            Configuration config = ConfigurationManager.OpenExeConfiguration(file);


            ConfigurationManager.RefreshSection("appSettings");
            string name;

            try
            {
                name = config.AppSettings.Settings["sy"].Value;
            }
            catch (Exception ee)
            {
                DateTime dt = new DateTime(2017, 11, 11);
                name = dt.ToString("yyyy/MM/dd");
                config.AppSettings.Settings.Add("sy", name);
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
            }
            if (DateTime.Now > DateTime.Parse(name))
            {
                System.Threading.Thread.Sleep(5000);
                MessageBox.Show("数据库异常!");
                this.Close();
            }
        }
Пример #2
0
        //退出登录按钮
        private void ExitBtn_Click(object sender, EventArgs e)
        {
            // 清空数据库中的token信息

            String            localUUID = Utility.getUUID();
            SqlDataAdapter    da        = new SqlDataAdapter("select * from users where 用户ID='" + mySystem.Parameter.userID + "'", Parameter.connUser);
            SqlCommandBuilder cb        = new SqlCommandBuilder(da);
            DataTable         dt        = new DataTable("user");

            da.Fill(dt);
            if (dt.Rows.Count >= 1)
            {
                String remoteUUID = dt.Rows[0]["token"].ToString();
                if (remoteUUID == localUUID)
                {
                    dt.Rows[0]["token"] = "";
                    da.Update(dt);
                }
            }

            // ---

            // 停止检查登陆状态
            timer2.Stop();
            timer2.Dispose();

            timer1.Stop();
            timer1.Dispose();
            this.Hide();
            foreach (Control control in MainPanel.Controls)
            {
                control.Dispose();
            }
            MainPanel.Controls.Clear();
            LoginForm login = new LoginForm(this);

            login.ShowDialog();
            // 接收指令

            mySystem.Other.我的任务 f = new Other.我的任务();

            //f.set指令(test);
            //f.Show();
            String instru = receiveInstr();

            if (instru != null)
            {
                f.set指令(instru);
                f.set表单("");
                f.ShowDialog();
            }
            //


            if (Parameter.userName != null)
            {
                userLabel.Text           = Parameter.userName;
                MainProduceBtn.BackColor = Color.FromName("Control");
                MainSettingBtn.BackColor = Color.FromName("Control");
                MainQueryBtn.BackColor   = Color.FromName("Control");
                this.Show();
                SearchUnchecked();
                timer1.Interval = interval;
                timer1.Start();
                timer2.Interval = timer2Interval;
                timer2.Start();
            }
            else
            {
                this.Close();
                Application.ExitThread();
            }
        }