Ejemplo n.º 1
0
        public static void CapNhatTaiKhoan(DANGNHAP_DTO TaiKhoan)
        {
            SqlConnection cnn = sqlConectionData.KetNoi();
            SqlCommand    cmd = new SqlCommand("CapNhatTaiKhoan", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@LoaiTaiKhoan", SqlDbType.Int).Value         = TaiKhoan.LoaiDangNhap;
            cmd.Parameters.Add("@TenDangNhap", SqlDbType.NVarChar, 50).Value = TaiKhoan.TenDangNhap;
            cmd.Parameters.Add("@Pass", SqlDbType.NVarChar, 50).Value        = TaiKhoan.MatKhau;
            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Ejemplo n.º 2
0
 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)
     { }
 }
Ejemplo n.º 3
0
 public static void CapNhatTaiKhoan(DANGNHAP_DTO TaiKhoan)
 {
     DANGNHAP_DAO.CapNhatTaiKhoan(TaiKhoan);
 }
Ejemplo n.º 4
0
 private void rd_them_Click(object sender, EventArgs e)
 {
     try
     {
         if (Check() == 0)//nếu không có lỗi
         {
             //thêm hàng vào csdl
             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;
             }
             string       matkhau  = md5(txt_matkhau.Text);
             DANGNHAP_DTO TaiKhoan = new DANGNHAP_DTO(loai, txt_ten.Text, matkhau);
             DANGNHAP_BUS.ThemTaiKhoan(TaiKhoan);
             ThemHang(dgv_taikhoan.Rows.Count, cb_loai.Text, txt_ten.Text, matkhau);
             timer1.Start();
             timer1.Enabled         = true;
             lbl_thongbao.ForeColor = Color.Red;
             lbl_thongbao.Text      = "Thêm thành công!";
             timer1_Tick(sender, e);
             XoaTrangO();//xóa hết các ô dữ liệu
         }
         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();
         }
         else
         if (Check() == 3)            //ngày khám nhỏ hơn ngày sinh
         {
             DevComponents.DotNetBar.MessageBoxEx.Show("Bị trùng tên đăng nhập, xin hãy kiểm tra lại!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_ten.Focus();
         }
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 5
0
 public static void ThemTaiKhoan(DANGNHAP_DTO TaiKhoan)
 {
     DANGNHAP_DAO.ThemTaiKhoan(TaiKhoan);
 }