private void loginClick(object sender, RoutedEventArgs e) { dmSql login = new dmSql(); //int result=login.Login(userName.Text.Trim(),passWord.Password.Trim()); int result = 1; if (result == 1) { MonitoringInterface w1 = new MonitoringInterface(); System.Windows.Application.Current.MainWindow = w1; this.Close(); w1.Show(); /*if (extendScrean.IsChecked == true)//判断是否启动扩展屏 * { * try * { * MonitoringInterface w1 = new MonitoringInterface(); * System.Windows.Application.Current.MainWindow = w1; * this.Close(); * w1.Show(); * } * catch (Exception ex) * { * System.Windows.MessageBox.Show("未检测到扩展屏,请确定扩展屏正常连接,再进行勾选。");//显示异常信息 * } * } * else * { * MonitoringInterface w1 = new MonitoringInterface(); * System.Windows.Application.Current.MainWindow = w1; * this.Close(); * w1.Show(); * }*/ } else { if (userName.Text == "" || passWord.Password == "") { System.Windows.MessageBox.Show("登录名或者密码为空,请输入。"); } else { System.Windows.MessageBox.Show("登录名或者密码有误,请确认后输入。"); } } }
private void LoginClick(object sender, RoutedEventArgs e)//登录按钮 { //userName.Text = "1"; //password.Password = "******"; try { userInfor = loginData.Login(userName.Text.Trim(), password.Password.Trim()); } catch { MessageBoxX.Show("警告", "数据库连接失败!"); System.Windows.Application.Current.Shutdown(); Environment.Exit(0);//强制退出 GC.Collect(); } //roleContrl需要数据库查询赋值 if (userInfor != null) { roleContrl = str[userInfor.RoleID];//用以权限赋值 opeation.UserID = userInfor.ID; opeation.OptionName = "登录"; opeation.LogType = 1; opeation.Result = "成功"; opeation.UserName = userInfor.Name; opeation.IP = deviceIP; opeation.OptionTime = GetTime(GetTimeStamp().ToString()); OperationLogData.WriteOperationLog(opeation); if (!String.IsNullOrWhiteSpace(userName.Text) && IsUserNameNew(userName.Text))//更新用户名的配置文件 { if (userCount < maxCount) { sc.write_string("userName", "count" + userCount.ToString(), userName.Text); userCount += 1; sc.write_double("userCount", "max", userCount); } else { for (int i = 0; i < maxCount - 1; i++) { sc.write_string("userName", "count" + i.ToString(), sc.read_string("userName", "count" + (i + 1).ToString())); } sc.write_string("userName", "count" + (userCount - 1).ToString(), userName.Text); } } if ((bool)rememberPassword.IsChecked && !String.IsNullOrWhiteSpace(password.Password))//更新密码的配置文件 { sc.write_string("password", "user_" + userName.Text, password.Password); } sc.write_bool("isRememberPassword", "value", (bool)rememberPassword.IsChecked);//更新是否记住密码 if (extendScrean.IsChecked == true) //判断是否启动扩展屏 { MonitoringInterface q = new MonitoringInterface(); System.Windows.Application.Current.MainWindow = q; this.Close(); q.Show(); try { MainWindow.opeation.OptionName = "双屏显示"; //日志入库 MainWindow.opeation.LogType = 2; MainWindow.opeation.OptionTime = GetTime(GetTimeStampS().ToString()); MainWindow.OperationLogData.WriteOperationLog(MainWindow.opeation); if (!MainWindow.doubleScreen) { MainWindow.doubles = new DoubleScreen(); MainWindow.doubles.Closed += doubleScreenClosed; System.Windows.Application.Current.MainWindow = MainWindow.doubles; MainWindow.doubles.Show(); MainWindow.doubleScreen = true; MonitoringX.MonitoringXObj.doubleScreen(); //修改主界面 } } catch (Exception eex) { MessageBoxX.Show("异常信息", "未检测到扩展屏。"); //显示异常信息 MainWindow.doubleScreen = false; } } else { MonitoringInterface q = new MonitoringInterface(); System.Windows.Application.Current.MainWindow = q; this.Close(); q.Show(); }; } else { if (String.IsNullOrWhiteSpace(userName.Text) || String.IsNullOrWhiteSpace(password.Password)) { MessageBoxX.Show("警告", "登录名或者密码为空。"); } else { MessageBoxX.Show("警告", "登录名或者密码有误.。"); } }; }