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; } }
void CheckAndDoUpdate() { _model = _bll.GetModel(_bll.GetMaxId() - 1); if (_model == null) { MessageBoxEx.Show("检查更新失败,程序将退出"); Application.Exit(); return; } //执行检查更新操作 if (NeedUpdate()) { Thread.Sleep(2000); //延时两秒,防止进程没有退出 //MessageBoxEx.Show("发现新版本,即将开始更新"); //获取更新文件列表 string[] list = _model.update_files.Split('|'); //显示更新描述 this.Invoke(new Action(() => { labelX1.Text = _model.udapte_details; lbVersion.Text = "V" + _localVersion + " -> V" + _model.version; })); //执行更新 if (!DoUpdate(list)) { MessageBoxEx.Show("更新失败,请联系技术人员!"); //Application.Exit(); return; } XmlHandler.SetPropramVersion((float)_model.version); ConfigurationManager.AppSettings["Version"] = _model.version.ToString(); MessageBoxEx.Show("更新完成."); } else { btnStart_Click(null, null); } }