private void buttonEqual_Click(object sender, EventArgs e) { //switch (d) //{ // case "+": a = b + double.Parse(textBox1.Text); break; // case "-": a = b - double.Parse(textBox1.Text); break; // case "*": a = b * double.Parse(textBox1.Text); break; // case "/": a = b / double.Parse(textBox1.Text); break; //} //textBox1.Text = a + ""; CalHelper calHelper = new CalHelper(); para2 = double.Parse(textBox1.Text); switch (sign) { case "+": textBox1.Text = "" + calHelper.Add(para1, para2); break; case "-": textBox1.Text = "" + calHelper.Subtract(para1, para2); break; case "*": textBox1.Text = "" + calHelper.Multiply(para1, para2); break; case "/": textBox1.Text = "" + calHelper.Divide(para1, para2); break; } c = true; textBox1.Focus(); }
public void StartInit() { log = new Logger(Path.Combine(Directory.GetCurrentDirectory(), "Log")); /// <summary> /// 登录实例 /// </summary> LoginForm _LoginForm = null; /// <summary> /// 获取调用实例 /// </summary> CaijiCommHelper _CaijiCommHelper = null; /// <summary> /// 试验初始化配置信息 /// </summary> SXCJModule _Module = null; try { _Module = CalHelper.LoadModule(); _CaijiCommHelper = new CaijiCommHelper(log, _Module); _LoginForm = new LoginForm(log, _CaijiCommHelper, _Module); ReLogin: if (DialogResult.OK == _LoginForm.ShowDialog()) { if (_LoginForm.IsUpdate && !IsRuningProcess("JZUpgradeAgent")) { JZUpgrade.UpdateAlert ua = new JZUpgrade.UpdateAlert(2); if (ua.ShowDialog() != DialogResult.OK) { goto ReLogin; } ProcessStartInfo Info = new ProcessStartInfo(); Info.CreateNoWindow = false; Info.UseShellExecute = true; Info.FileName = Path.Combine(Application.StartupPath, "JZUpgrade.exe"); Info.Arguments = "\"5\""; Process.Start(Info); _LoginForm.Enabled = false; _LoginForm.lblUpdateStatus.Text = "正在更新..."; goto ReLogin; } #region 用户登录 if (_LoginForm.bNetWorkIsConnected) { #region 在线登陆 ShowForm(); SetText("用户登录中......."); try { string msg = _CaijiCommHelper.Login(_LoginForm.cmbUserName.Text, _LoginForm.txtUserPwd.Text, _Module.SpecialSetting.MachineCode, true); if (msg.ToLower().Trim() != "true") { CloseFrom(); if (MessageBox.Show(msg, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { goto ReLogin; } else { Application.Exit(); return; } } else { #region 网络登录成功 _LoginForm.timerUpdate.Stop(); #region 步本地用户 SetText("同步本地用户......."); _CaijiCommHelper.SysUserInfo(Yqun.Common.ContextCache.ApplicationContext.Current.UserName, Yqun.Common.ContextCache.ApplicationContext.Current.Password, Yqun.Common.ContextCache.ApplicationContext.Current.UserCode, Yqun.Common.ContextCache.ApplicationContext.Current.InTestRoom.Code); #endregion #region 步本地模板 SetText("初始化用户配置信息......."); SetText("同步本地模板......."); _CaijiCommHelper.UpdateLocalModelInfo(_Module.SpecialSetting.TestRoomCode); #endregion if (!Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator) { #region 步本地配置信息 try { SetText("检查本地配置信息状态......."); switch (_CaijiCommHelper.GetClientConfigStatus(_Module.SpecialSetting.MachineCode)) { case -1: SetText("本地配置信息状态检查失败,请联系管理员......."); break; case 0: //SetText("同步本地配置信息......."); //_CaijiCommHelper.UploadClientConfig(_Module.SpecialSetting.TestRoomCode, _Module.SpecialSetting.MachineCode, Newtonsoft.Json.JsonConvert.SerializeObject(_Module.SpecialSetting)); MessageBox.Show("本地设备信息未在服务上注册,请联系管理员!", "本地配置提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); CloseFrom(); goto ReLogin; case 1: SetText("同步本地配置信息......."); _CaijiCommHelper.UpDateClientConfig(_Module.SpecialSetting.MachineCode, Newtonsoft.Json.JsonConvert.SerializeObject(_Module.SpecialSetting)); break; case 2: SetText("同步本地配置信息......."); _CaijiCommHelper.GetClientConfig(ref _Module, _Module.SpecialSetting.MachineCode); break; } SetText("同步本地配置信息完成......."); } catch (Exception exSysConfig) { log.WriteLog(exSysConfig.Message + System.Environment.NewLine + exSysConfig.TargetSite, true, true); } #endregion } #region 本地数据 if (!Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator) { SetText("上传本地数据中......."); if (_CaijiCommHelper.UpdateLocalDateToServer()) { SetText("上传本地数据成功......."); } else { SetText("上传本地数据失败,下次启动将继续上传......."); } } #endregion #region 记录历史登陆 _LoginForm.MemberUser(); #endregion #endregion } } catch (Exception ex) { MessageBox.Show("网络连接失败!已经转至本地服务登录!" + ex.Message, "登录提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); Yqun.Common.ContextCache.ApplicationContext.Current.ISLocalService = true; } #endregion } else { #region 本地用户登录 ShowForm(); SetText("用户登录中......."); SetText("读取本地登录用户信息......."); DataTable _DataTable = new DataTable(); _DataTable = _CaijiCommHelper.GetUserInfo(_LoginForm.cmbUserName.Text, _LoginForm.txtUserPwd.Text); if (_DataTable != null && _DataTable.Rows.Count > 0) { Yqun.Common.ContextCache.ApplicationContext.Current.UserName = _LoginForm.cmbUserName.Text; Yqun.Common.ContextCache.ApplicationContext.Current.Password = _LoginForm.txtUserPwd.Text; Yqun.Common.ContextCache.ApplicationContext.Current.UserCode = _DataTable.Rows[0]["UserCode"].ToString(); Yqun.Common.ContextCache.ApplicationContext.Current.InTestRoom.Code = _DataTable.Rows[0]["UserTestCode"].ToString(); Yqun.Common.ContextCache.ApplicationContext.Current.ISLocalService = true; _Module = CalHelper.LoadModule(); } else { if (MessageBox.Show("用户名或密码错误,请查证后在登录!", "登录错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { goto ReLogin; } else { Application.Exit(); return; } } #endregion } #region 释放资源 if (_SplashScreen != null) { CloseFrom(); } #endregion #endregion Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(log, _Module, _CaijiCommHelper)); } } catch (Exception ex) { log.WriteLog(ex.StackTrace, true, false); } }