public Login() { //MessageBox.Show(Application.StartupPath); InitializeComponent(); this.InitForm(); SMethod.InitBackForeColor(this); label_title.Text += string.Format("({0})", ApplicationUpdate.GetCurrentVersion()); Task.Run(() => { ApplicationUpdate.Init(); this.BeginInvoke_CheckHandle(() => { button_login.Enabled = true; label_ServerVersion.Text = ApplicationUpdate.CheckForUpdate_Result ? "当前有可用更新" : "当前无可用更新"; label_ServerVersion.ForeColor = ApplicationUpdate.CheckForUpdate_Result ? SParms.AlarmColor : SParms.NomalColor; label_ServerVersion.Visible = true; }); }); //if ( string.IsNullOrWhiteSpace( ApplicationUpdate.ServerVewsion)) //{ // label_ServerVersion.Text = "服务器上的最新版本为:" + ApplicationUpdate.ServerVewsion; //} //else //{ //} }
public void TryLogin() { bool mysuperid = tb_user.Text == "331"; //匹配岗位的超级权限 bool mysuperid_configwindow = tb_user.Text == "332"; //不匹配岗位的超级权限,且还能弹出窗口选择相应的岗位 bool bingding_id = tb_user.Text == "999"; //人工绑定岗位专用ID if (!mysuperid_configwindow && !IsGetConfig) //获取程序配置信息 { button1_Click(null, null); if (!IsGetConfig) { return; } } if (!mysuperid && !mysuperid_configwindow && !bingding_id && (tb_user.Text == "" || tb_password.Text == "")) { MessageBox.Show("用户名和密码均不能为空", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string loginResult = SQL.Login(tb_user.Text, tb_password.Text, out string err); if (mysuperid_configwindow) { GWSelect gwselect = new GWSelect(); gwselect.Init(AppConfig.PCIP); if (gwselect.ShowDialog() == DialogResult.Yes) { SQL.GetConfig(new List <string> { gwselect.SelectPCIP }, out err); AppConfig.GetDynmaicConfigImm(); } else { return; } } if (mysuperid || mysuperid_configwindow || (bingding_id && AppConfig.GXType_Enum == AppConfig.GXType_EnumType.绑定) || (!string.IsNullOrEmpty(loginResult) && loginResult.Substring(0, 1) == "1")) { AppConfig.Init(); //登陆前的ClickOnce自动更新判定 if (ApplicationUpdate.CheckForUpdate(AppConfig.ALLOWLOWVERSION)) { //if (MessageBox.Show(string.Format("使用该版本登陆将自动更新\r\n最新版:{0}\r\n当前版本:{1}\r\n最低允许版本:{2}\r\n你确定要这么做吗?更新无法回退!", ApplicationUpdate.ServerVewsion, ApplicationUpdate.GetCurrentVersion(), AppConfig.ALLOWLOWVERSION), "警告", MessageBoxButtons.YesNo) if (MessageBox.Show(string.Format("使用该版本登陆将自动更新\r\n当前版本:{0}\r\n最低允许版本:{1}\r\n你确定要这么做吗?更新无法回退!", ApplicationUpdate.GetCurrentVersion(), AppConfig.ALLOWLOWVERSION), "警告", MessageBoxButtons.YesNo) == DialogResult.Yes) { ApplicationUpdate.Update(); } } switch (AppConfig.GXType_Enum) { case AppConfig.GXType_EnumType.未定义: default: MessageBox.Show("你的工序类型不正确,请联系管理员", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; case AppConfig.GXType_EnumType.人工: case AppConfig.GXType_EnumType.扭力: case AppConfig.GXType_EnumType.干检: case AppConfig.GXType_EnumType.绑定: SParms.User = tb_user.Text; this.Visible = false; Main main = new Main(mysuperid || mysuperid_configwindow); main.ShowDialog(); break; } this.Close(); } else { MessageBox.Show(loginResult.Substring(1), "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); //tb_user.Text = ""; tb_password.Text = ""; tb_password.Focus(); return; } }