Exemplo n.º 1
0
 private void btnInformation_Click(object sender, EventArgs e)
 {
     if (ob_FrmInfoAdmin == null || ob_FrmInfoAdmin.IsDisposed)
     {
         ob_FrmInfoAdmin = new FrmInfoAdmin();
         ob_FrmInfoAdmin.Show();
     }
     else
     {
         ob_FrmInfoAdmin.Activate();
     }
 }
Exemplo n.º 2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("用户名不能为空!", "错误");
             txtUserName.Focus();
             return;
         }
         else if (txtUserPassword.Text.Trim() == "")
         {
             MessageBox.Show("密码不能为空!", "错误");
             txtUserPassword.Focus();
             return;
         }
         this.Text = "正在验证...";
         this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
         string psw = CPublic.GetMd5Str(txtUserPassword.Text.Trim());
         string sqlStr = "select userPassword, userPurview, firstLogin from tbl_User where userName='******'";
         CDataBase.conn.ConnectionString = CDataBase.connStr;
         CDataBase.conn.Open();
         SqlCommand cmd = new SqlCommand(sqlStr, CDataBase.conn);
         SqlDataReader sdr = cmd.ExecuteReader();
         if (!sdr.Read())
         {
             MessageBox.Show("用户名错误,请重新输入!", "错误");
             this.Cursor = System.Windows.Forms.Cursors.Arrow;
             this.Text = "登录";
             txtUserName.Text = "";
             txtUserPassword.Text = "";
             txtUserName.Focus();
         }
         else if (sdr["userPassword"].ToString().Trim() == psw.Trim())
         {
             CPublic.userInfo[0] = txtUserName.Text.Trim();
             CPublic.userInfo[1] = psw.Trim();
             CPublic.userInfo[2] = sdr["userPurview"].ToString().Trim();
             CPublic.userInfo[3] = sdr["firstLogin"].ToString().Trim();
             this.Cursor = System.Windows.Forms.Cursors.Arrow;
             this.Text = "登录";
             if (CPublic.userInfo[2] == "顾客")
             {
                 FrmCustomerMain ob_FrmCustomerMain = new FrmCustomerMain();
                 ob_FrmCustomerMain.Show();
             }
             else
             {
                 FrmAdminMain ob_FrmAdminMain = new FrmAdminMain();
                 ob_FrmAdminMain.Show();
             }
             this.Hide();
             CDataBase.conn.Close();
             if (CPublic.userInfo[3] == "是")
             {
                 if(CPublic.userInfo[2]=="普通管理员")
                 {
                     MessageBox.Show("未设置个人信息,请先设置,否则一旦忘记密码,将无法找回!",
                                                  "严重警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     FrmInfoAdmin ob_FrmInformation = new FrmInfoAdmin();
                     ob_FrmInformation.Show();
                 }
                 else if(CPublic.userInfo[2]=="顾客")
                 {
                     MessageBox.Show("未设置个人信息,请先设置,否则一旦忘记密码,将无法找回!",
                                                     "严重警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     FrmInfoCustomer ob_FrmInformation = new FrmInfoCustomer();
                     ob_FrmInformation.Show();
                 }
             }
         }
         else
         {
             MessageBox.Show("密码错误,请重新输入!", "错误");
             this.Cursor = System.Windows.Forms.Cursors.Arrow;
             this.Text = "登录";
             txtUserPassword.Text = "";
             txtUserPassword.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "登录异常");
         this.Cursor = System.Windows.Forms.Cursors.Arrow;
         this.Text = "登录";
         txtUserName.Text = "";
         txtUserPassword.Text = "";
         txtUserName.Focus();
     }
     finally
     {
         CDataBase.conn.Close();
     }
 }
Exemplo n.º 3
0
 private void btnInformation_Click(object sender, EventArgs e)
 {
     if (ob_FrmInfoAdmin == null || ob_FrmInfoAdmin.IsDisposed)
     {
         ob_FrmInfoAdmin = new FrmInfoAdmin();
         ob_FrmInfoAdmin.Show();
     }
     else
     {
         ob_FrmInfoAdmin.Activate();
     }
 }
Exemplo n.º 4
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("用户名不能为空!", "错误");
             txtUserName.Focus();
             return;
         }
         else if (txtUserPassword.Text.Trim() == "")
         {
             MessageBox.Show("密码不能为空!", "错误");
             txtUserPassword.Focus();
             return;
         }
         this.Text   = "正在验证...";
         this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
         string psw    = CPublic.GetMd5Str(txtUserPassword.Text.Trim());
         string sqlStr = "select userPassword, userPurview, firstLogin from tbl_User where userName='******'";
         CDataBase.conn.ConnectionString = CDataBase.connStr;
         CDataBase.conn.Open();
         SqlCommand    cmd = new SqlCommand(sqlStr, CDataBase.conn);
         SqlDataReader sdr = cmd.ExecuteReader();
         if (!sdr.Read())
         {
             MessageBox.Show("用户名错误,请重新输入!", "错误");
             this.Cursor          = System.Windows.Forms.Cursors.Arrow;
             this.Text            = "登录";
             txtUserName.Text     = "";
             txtUserPassword.Text = "";
             txtUserName.Focus();
         }
         else if (sdr["userPassword"].ToString().Trim() == psw.Trim())
         {
             CPublic.userInfo[0] = txtUserName.Text.Trim();
             CPublic.userInfo[1] = psw.Trim();
             CPublic.userInfo[2] = sdr["userPurview"].ToString().Trim();
             CPublic.userInfo[3] = sdr["firstLogin"].ToString().Trim();
             this.Cursor         = System.Windows.Forms.Cursors.Arrow;
             this.Text           = "登录";
             if (CPublic.userInfo[2] == "顾客")
             {
                 FrmCustomerMain ob_FrmCustomerMain = new FrmCustomerMain();
                 ob_FrmCustomerMain.Show();
             }
             else
             {
                 FrmAdminMain ob_FrmAdminMain = new FrmAdminMain();
                 ob_FrmAdminMain.Show();
             }
             this.Hide();
             CDataBase.conn.Close();
             if (CPublic.userInfo[3] == "是")
             {
                 if (CPublic.userInfo[2] == "普通管理员")
                 {
                     MessageBox.Show("未设置个人信息,请先设置,否则一旦忘记密码,将无法找回!",
                                     "严重警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     FrmInfoAdmin ob_FrmInformation = new FrmInfoAdmin();
                     ob_FrmInformation.Show();
                 }
                 else if (CPublic.userInfo[2] == "顾客")
                 {
                     MessageBox.Show("未设置个人信息,请先设置,否则一旦忘记密码,将无法找回!",
                                     "严重警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     FrmInfoCustomer ob_FrmInformation = new FrmInfoCustomer();
                     ob_FrmInformation.Show();
                 }
             }
         }
         else
         {
             MessageBox.Show("密码错误,请重新输入!", "错误");
             this.Cursor          = System.Windows.Forms.Cursors.Arrow;
             this.Text            = "登录";
             txtUserPassword.Text = "";
             txtUserPassword.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "登录异常");
         this.Cursor          = System.Windows.Forms.Cursors.Arrow;
         this.Text            = "登录";
         txtUserName.Text     = "";
         txtUserPassword.Text = "";
         txtUserName.Focus();
     }
     finally
     {
         CDataBase.conn.Close();
     }
 }