Ejemplo n.º 1
0
 private void btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (TaiKhoan_BUS.TimTk_TheoTen(txtTaiKhoan.Text.Trim()) == null)
     {
         XtraMessageBox.Show("Bạn chưa chọn dòng cần xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DialogResult thongbao = XtraMessageBox.Show("Bạn có chắc muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (thongbao == DialogResult.No)
         {
             XtraMessageBox.Show("Bạn đã hủy thao tác xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         if (thongbao == DialogResult.Yes)
         {
             TaiKhoan_DTO TK = new TaiKhoan_DTO();
             TK.ID = int.Parse(nmID.Text);
             if (TaiKhoan_BUS.XoaTaiKhoan(nmID.Text))
             {
                 frmTaiKhoan_Load(sender, e);
                 XtraMessageBox.Show("Bạn đã xóa thành công tài khoản ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
Ejemplo n.º 2
0
 //Button Xóa
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (drNhanVien == null)
     {
         MessageBox.Show("Chọn nhân viên muốn xóa");
         return;
     }
     else if (MessageBox.Show("Bạn có chắc chắn muốn xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         NhanVien_DTO nhanVien = new NhanVien_DTO();
         nhanVien.MaNhanVien = drNhanVien.Cells[0].Value.ToString();
         if (danhSachNhanVien == null)
         {
             gunaDataGridView1.DataSource = null;
         }
         //Xóa nhân viên và tài khoản của nhân viên đó
         TaiKhoan_DTO tk = new TaiKhoan_DTO();
         tk.Tentk = nhanVien.MaNhanVien;
         if (NhanVien_BUS.XoaNhanVien(nhanVien) || TaiKhoan_BUS.XoaTaiKhoan(tk))
         {
             drNhanVien          = null;
             txtHoTen.Text       = "";
             txtSoDienThoai.Text = "";
             txtChucVu.Text      = "";
             txtBacLuong.Text    = "";
             rtxtDiaChi.Text     = "";
             LoadNhanVien();
             MessageBox.Show("Xóa thành công");
             return;
         }
         MessageBox.Show("Xóa thất bại");
     }
 }