예제 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtMatKhauCu.Text.Trim() != DangNhap_DAL.Pass)
     {
         MessageBox.Show("Sai mật khẩu");
         txtMatKhauCu.Text = string.Empty;
         txtMatKhauCu.Focus();
         return;
     }
     else
     {
         if (txtMatKhauMoi.Text == txtXacNhanMK.Text)
         {
             QL_NGUOIDUNG p = new QL_NGUOIDUNG();
             p.TENDANGNHAP = DangNhap_DAL.UserName;
             p.MATKHAU     = txtMatKhauMoi.Text.Trim();
             if (dmk.ThayDoiMK(p))
             {
                 MessageBox.Show("Cập nhật thông tin thành công");
                 this.Close();
                 return;
             }
             else
             {
                 MessageBox.Show("Cập nhật thông tin thất bại");
                 return;
             }
         }
         else
         {
             MessageBox.Show("Xác nhận mật khẩu không trùng khớp");
             return;
         }
     }
 }
예제 #2
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtTenTaiKhoan.Text == string.Empty)
     {
         MessageBox.Show("Bạn chưa nhập tên tài khoản");
         txtTenTaiKhoan.Focus();
         return;
     }
     if (txtMatKhau.Text == string.Empty)
     {
         MessageBox.Show("Bạn chưa nhập mật khẩu");
         txtMatKhau.Focus();
         return;
     }
     else
     {
         QL_NGUOIDUNG user = new QL_NGUOIDUNG();
         user.TENDANGNHAP = txtTenTaiKhoan.Text.Trim();
         user.MATKHAU     = txtMatKhau.Text.Trim();
         if (qlnd.ThemNguoiDung(user))
         {
             QL_PHANQUYEN pq = new QL_PHANQUYEN();
             pq.TENDANGNHAP = user.TENDANGNHAP;
             if (radiobtAdmin.Checked == true)
             {
                 pq.MANHOM = "ad";
             }
             else
             {
                 pq.MANHOM = "nv";
             }
             if (qlnd.PhanQuyenUser(pq))
             {
                 MessageBox.Show("Bạn đã thêm người dùng " + user.TENDANGNHAP);
                 txtTenTaiKhoan.Text = string.Empty;
                 txtMatKhau.Text     = string.Empty;
                 txtTenTaiKhoan.Focus();
             }
             else
             {
                 MessageBox.Show("Thêm thất bại");
             }
         }
         else
         {
             MessageBox.Show("Đã có tài khoản");
         }
     }
 }