Example #1
0
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     if (!ChkOCDBLink(DBAccessProc.Common.DBConnectionString))
     {
         MessageBox.Show("数据库连接失败,请检查网络或配置");
         return;
     }
     try
     {
         if (txtExaminerId.Text.Trim() == "")
         {
             MessageBox.Show("请输入考试员/操作员编号!");
             return;
         }
         if (txtPassword.Password.Trim() == "")
         {
             MessageBox.Show("请输入密码!");
             return;
         }
         DBAccessHelper.GetExaminer(txtExaminerId.Text.Trim().ToUpper(), txtPassword.Password.Trim(), dsrsrc.trainMangeDataSet);
         if (dsrsrc.trainMangeDataSet.TraManagerDataTable.Rows.Count == 0)
         {
             MessageBox.Show("登录失败!考试员/操作员编号和密码不匹配,请重试。");
             txtExaminerId.Text   = "";
             txtPassword.Password = "";
         }
         else
         {
             MainWindow mainWindow = new MainWindow();
             mainWindow.Show();
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("登录失败!原因:" + ex.Message + ",位置:" + ex.StackTrace);
         Environment.Exit(0);
     }
     //string strPwd = DateTime.Today.ToString("yyyyMMdd");
     //if (pswBoxLogin.Password.Trim() == strPwd)
     //{
     //	MainWindow mainWindow = new MainWindow();
     //	mainWindow.Show();
     //	this.Close();
     //}
     //else
     //{
     //	MessageBox.Show("密码错误!");
     //	this.pswBoxLogin.Clear();
     //	this.pswBoxLogin.Focus();
     //}
 }