Exemple #1
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            ////初始化界面信息
            ////提取用户列表
            //DataSet ds = new DataSet();
            //Dong.BLL.OperInfo mOper = new Dong.BLL.OperInfo();
            //ds = mOper.GetAllList();
            //txtUserName.ValueMember = "Code";
            //txtUserName.DisplayMember = "Code";
            //txtUserName.DataSource = ds.Tables[0];

            ////提取配置信息
            //Dong.BLL.ShopInfo bShop = new Dong.BLL.ShopInfo();
            //Dong.Model.ShopInfo mShop = new Dong.Model.ShopInfo();
            //mShop = bShop.GetModel(1);
            //Dong.Model.GlobalsInfo.shopName = mShop.Name;
            //this.Text = this.Text + " --【" + mShop.Name + "】";

            //Dong.Model.GlobalsInfo.shopAddr = mShop.Addr;

            if (!GlobalUtils.CheckDatabaseConnect())
            {
                MessageBoxEx.Show("连接到数据库服务器失败,请联系技术人员!");
                Application.Exit();
                return;
            }
            _model = _bll.GetModel(_bll.GetMaxId() - 1); //取出来是错的,加了1,这里如果数据库里没有数据,返回的是1,所以还不好判断,就假设数据库一致都有数据吧
            if (_model == null)
            {
                MessageBoxEx.Show("检查更新失败,程序将退出");
                Application.Exit();
                return;
            }
            //执行检查更新操作
            if (NeedUpdate())
            {
                //获取更新文件列表
                string[] list = _model.update_files.Split('|');

                //显示更新描述
                labelX1.Text = _model.udapte_details;

                //执行更新
                MessageBoxEx.Show("发现新版本,即将开始升级");
                Process.Start(GlobalUtils.AppPath + "\\" + "TravelAgency.AutoUpdate.exe");
                Application.Exit();
                return;
            }
        }
Exemple #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;
            }
        }