コード例 #1
0
 private void rd_capnhat_Click(object sender, EventArgs e)
 {
     if (txt_cu.Text == "" || txt_moi.Text == "" || txt_remoi.Text == "")
     {
         DevComponents.DotNetBar.MessageBoxEx.Show("Chưa nhập đủ dữ liệu kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         if (txt_cu.Text == "")
         {
             txt_cu.Focus();
         }
         else
         if (txt_moi.Text == "")
         {
             txt_moi.Focus();
         }
         else
         if (txt_remoi.Text == "")
         {
             txt_remoi.Focus();
         }
     }
     else
     {
         if (DANGNHAP_BUS.TrangThai(ten, md5(txt_cu.Text)) == 0)
         {
             DevComponents.DotNetBar.MessageBoxEx.Show("Mật khẩu hiện tại không đúng, kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_cu.Focus();
         }
         else
         {
             if (txt_moi.Text != txt_remoi.Text)
             {
                 DevComponents.DotNetBar.MessageBoxEx.Show("Mật khẩu mới và mật khẩu nhập lại không khớp!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txt_remoi.Focus();
             }
             else
             {
                 DANGNHAP_BUS.CapNhatMatKhau(ten, md5(txt_moi.Text));
                 this.Close();
             }
         }
     }
 }
コード例 #2
0
ファイル: TaiKhoan.cs プロジェクト: ThanhTiem/QL_PhongMachTu
 private void rd_capnhat_ItemClick(object sender, EventArgs e)
 {
     try
     {
         if (dgv_taikhoan.CurrentCell.Selected == true)
         {
             if (sender.ToString() == "Cả hai")
             {
                 if (Check() == 3)//không có lỗi
                 {
                     //chắc chắn muốn thay đổi thông tin bệnh nhân đã chọn
                     if (DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn cập nhật tài khoản không?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
                     {
                         string matkhau;
                         //cập nhật thông tin vừa nhập
                         int    now         = dgv_taikhoan.CurrentCell.RowIndex;                     //lấy số thứ tự hiện tại trên datagridview
                         int    k           = int.Parse(dgv_taikhoan.Rows[now].Cells[0].Value.ToString());
                         string TenTaiKhoan = DANGNHAP_BUS.LoadTaiKhoan().Rows[k - 1][1].ToString(); //lấy mã bệnh nhân
                         //cập nhật thông tin vài database
                         if (cb_loai.Text == "Admin")
                         {
                             loai = 1;
                         }
                         else
                         if (cb_loai.Text == "Bác Sĩ")
                         {
                             loai = 2;
                         }
                         else
                         if (cb_loai.Text == "Nhân viên")
                         {
                             loai = 3;
                         }
                         matkhau = md5(txt_matkhau.Text);
                         DANGNHAP_DTO TaiKhoan = new DANGNHAP_DTO(loai, TenTaiKhoan, matkhau);
                         DANGNHAP_BUS.CapNhatTaiKhoan(TaiKhoan);
                         //cập nhật thông tin lại database
                         dgv_taikhoan.Rows[now].Cells[1].Value = cb_loai.Text;
                         dgv_taikhoan.Rows[now].Cells[2].Value = txt_ten.Text;
                         dgv_taikhoan.Rows[now].Cells[3].Value = txt_matkhau.Text;
                         timer1.Start();
                         timer1.Enabled         = true;
                         lbl_thongbao.ForeColor = Color.Red;
                         lbl_thongbao.Text      = "Cập nhật thành công!";
                         timer1_Tick(sender, e);
                         dgv_taikhoan.CurrentCell.Selected = false;
                         XoaTrangO();//xóa hết thông tin trên các  textbox
                     }
                 }
                 else
                 if (Check() == 1)    //nếu còn ô trống
                 {
                     DevComponents.DotNetBar.MessageBoxEx.Show("Bạn chưa nhập đầy đủ dữ liệu, xin hãy kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     if (cb_loai.Text == "")
                     {
                         cb_loai.Focus();
                     }
                     if (txt_ten.Text == "")
                     {
                         txt_ten.Focus();
                     }
                     else
                     {
                         txt_matkhau.Focus();
                     }
                 }
                 else
                 if (Check() == 2)        //có số trong tên
                 {
                     DevComponents.DotNetBar.MessageBoxEx.Show("Không có loại tài khoản vừa nhập, xin hãy kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     cb_loai.Focus();
                 }
             }
             if (sender.ToString() == "Loại")
             {
                 if (cb_loai.Text != "" && cb_loai.AutoCompleteCustomSource.IndexOf(cb_loai.Text) != -1)
                 {
                     if (DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn cập nhật loại của tài khoản này không?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
                     {
                         //cập nhật thông tin vừa nhập
                         int    now         = dgv_taikhoan.CurrentCell.RowIndex;                     //lấy số thứ tự hiện tại trên datagridview
                         int    k           = int.Parse(dgv_taikhoan.Rows[now].Cells[0].Value.ToString());
                         string TenTaiKhoan = DANGNHAP_BUS.LoadTaiKhoan().Rows[k - 1][1].ToString(); //lấy mã bệnh nhân
                         //cập nhật thông tin vài database
                         if (cb_loai.Text == "Admin")
                         {
                             loai = 1;
                         }
                         else
                         if (cb_loai.Text == "Bác Sĩ")
                         {
                             loai = 2;
                         }
                         else
                         if (cb_loai.Text == "Nhân viên")
                         {
                             loai = 3;
                         }
                         DANGNHAP_BUS.CapNhatLoai(TenTaiKhoan, loai);
                         //cập nhật thông tin lại database
                         dgv_taikhoan.Rows[now].Cells[1].Value = cb_loai.Text;
                         dgv_taikhoan.Rows[now].Cells[2].Value = txt_ten.Text;
                         timer1.Start();
                         timer1.Enabled         = true;
                         lbl_thongbao.ForeColor = Color.Red;
                         lbl_thongbao.Text      = "Cập nhật thành công!";
                         timer1_Tick(sender, e);
                         dgv_taikhoan.CurrentCell.Selected = false;
                         XoaTrangO();//xóa hết thông tin trên các  textbox
                     }
                 }
                 else
                 if (cb_loai.Text == "")
                 {
                     DevComponents.DotNetBar.MessageBoxEx.Show("Chưa nhập loại tài khoản!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     cb_loai.Focus();
                 }
                 else
                 {
                     DevComponents.DotNetBar.MessageBoxEx.Show("Loại tài khoẳn vừa nhập không có trong danh sách, xin kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     cb_loai.Focus();
                 }
             }
             else
             if (sender.ToString() == "Mật khẩu")
             {
                 if (txt_matkhau.Text != "")
                 {
                     if (DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn cập nhật mật khẩu của tài khoản này không?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
                     {
                         //cập nhật thông tin vừa nhập
                         int    now         = dgv_taikhoan.CurrentCell.RowIndex;                     //lấy số thứ tự hiện tại trên datagridview
                         int    k           = int.Parse(dgv_taikhoan.Rows[now].Cells[0].Value.ToString());
                         string TenTaiKhoan = DANGNHAP_BUS.LoadTaiKhoan().Rows[k - 1][1].ToString(); //lấy mã bệnh nhân
                                                                                                     //cập nhật thông tin vài database
                         string matkhau;
                         matkhau = md5(txt_matkhau.Text);
                         DANGNHAP_BUS.CapNhatMatKhau(TenTaiKhoan, matkhau);
                         //cập nhật thông tin lại database
                         dgv_taikhoan.Rows[now].Cells[3].Value = matkhau;
                         dgv_taikhoan.Rows[now].Cells[2].Value = txt_ten.Text;
                         timer1.Start();
                         timer1.Enabled         = true;
                         lbl_thongbao.ForeColor = Color.Red;
                         lbl_thongbao.Text      = "Cập nhật thành công!";
                         timer1_Tick(sender, e);
                         dgv_taikhoan.CurrentCell.Selected = false;
                         XoaTrangO();//xóa hết thông tin trên các  textbox
                     }
                 }
                 else
                 if (txt_matkhau.Text == "")
                 {
                     DevComponents.DotNetBar.MessageBoxEx.Show("Chưa nhập mật khẩu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     cb_loai.Focus();
                 }
             }
         }
         else
         {
             DevComponents.DotNetBar.MessageBoxEx.Show("Chưa chọn tài khoản cần cập nhật!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     { }
 }