Exemplo n.º 1
0
        private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            ICopyRight copyRight = new RegisterCopyRight();

            copyRight.UpdateUserInfo();
            Application.Exit();
        }
Exemplo n.º 2
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            ICopyRight copyRightChecker = new RegisterCopyRight();

            if (!copyRightChecker.CheckAvailable())
            {
                MessageBoxEx.Show("试用期限已到,请联系管理人员!");
                Application.Exit();
                return;
            }

            //chkRememberPswd.CheckValueChanged+=chkRememberPswd_CheckValueChanged;
            txtUserName.SelectedValueChanged += txtUserName_SelectedValueChanged;

            //  读取配置文件寻找记住的用户名和密码
            FileStream fs = new FileStream(_userDataFile, FileMode.OpenOrCreate);

            if (fs.Length > 0)
            {
                BinaryFormatter bf = new BinaryFormatter();
                _users = bf.Deserialize(fs) as List <User>;
                if (_users == null)
                {
                    return;
                }

                foreach (User user in _users)
                {
                    this.txtUserName.Items.Add(user.Username);
                }

                for (int i = 0; i < _users.Count; i++)
                {
                    if (this.txtUserName.Text != "")
                    {
                        foreach (var user in _users)
                        {
                            if (user.Username == this.txtUserName.Text.Trim())
                            {
                                this.txtPswd.Text            = user.Password;
                                this.chkRememberPswd.Checked = true; //这里虽然默认选中了,但是后面其实会触发user_name selectedvaluechanged事件就无所谓了
                            }
                        }
                    }
                }
            }
            fs.Close();
            //  用户名默认选中第一个
            if (this.txtUserName.Items.Count > 0)
            {
                this.txtUserName.SelectedIndex = this.txtUserName.Items.Count - 1;
            }
            //item = (List<User>)bUser.GetAll();
            //item =
            //this.UserName.DataSource = item;
            //this.UserName.DisplayMember = "Username";

            if (!GlobalUtils.CheckDatabaseConnect())
            {
                MessageBoxEx.Show("连接到数据库服务器失败,请联系技术人员!");
                Application.Exit();
                return;
            }

            SteelManagement.BLL.ProgramUpdate bllProgramUpdate = new SteelManagement.BLL.ProgramUpdate();
            var latest = bllProgramUpdate.GetLatestModel();


            if (latest == null)
            {
                MessageBoxEx.Show("检查更新失败,程序将退出");
                Application.Exit();
                return;
            }
            //执行检查更新操作
            if (NeedUpdate(latest.Version))
            {
                //执行更新
                MessageBoxEx.Show("发现新版本,即将开始升级");
                Process.Start(GlobalUtils.AppPath + "\\" + "SteelManagement.AutoUpdate.exe");
                Application.Exit();
                return;
            }
        }