Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtMKCu.Text != "" && txtMKMoi1.Text != "" && txtMKMoi2.Text != "")
     {
         if (txtMKMoi1.Text != txtMKMoi2.Text)
         {
             MetroFramework.MetroMessageBox.Show(this, "Nhập mật khẩu không trùng nhau. \nMời nhập lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtMKCu.Text   = "";
             txtMKMoi1.Text = "";
             txtMKMoi2.Text = "";
             txtMKCu.Focus();
         }
         else
         {
             if (txtMKCu.Text == user.MatKhau)
             {
                 BUS_OBJ.doiMK(user.TenDangNhap, txtMKMoi1.Text);
                 MetroFramework.MetroMessageBox.Show(this, "Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 user.MatKhau = txtMKMoi1.Text;
                 this.Close();
             }
             else
             {
                 MetroFramework.MetroMessageBox.Show(this, "Sai mật khẩu cũ. \nMời nhập lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtMKCu.Text = "";
             }
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Vui lòng điền đầy đủ thông tin.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         if (txtMKMoi2.Text == "")
         {
             txtMKMoi2.Focus();
         }
         if (txtMKMoi1.Text == "")
         {
             txtMKMoi1.Focus();
         }
         if (txtMKCu.Text == "")
         {
             txtMKCu.Focus();
         }
     }
 }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtTenDN.Text != "" && txtMaResetMK.Text != "")
     {
         if (txtMaResetMK.Text == "123")
         {
             try
             {
                 BUS_OBJ.taoMoiTKNV(txtTenDN.Text, "1");
                 MetroFramework.MetroMessageBox.Show(this, "Tên đăng nhập không tồn tại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtTenDN.Focus();
             }
             catch (Exception)
             {
                 MetroFramework.MetroMessageBox.Show(this, "Đặt lại mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 BUS_OBJ.doiMK(txtTenDN.Text, "1");
                 this.Close();
             }
             finally
             {
                 //if (conn.State == ConnectionState.Open) conn.Close();
             }
         }
         else
         {
             MetroFramework.MetroMessageBox.Show(this, "Mã đặt lại mật khẩu không đúng.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             if (txtMaResetMK.Text == "")
             {
                 txtMaResetMK.Focus();
             }
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Vui lòng điền đầy đủ thông tin.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         if (txtTenDN.Text == "")
         {
             txtTenDN.Focus();
         }
     }
 }