Example #1
0
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     if (dtgv_DSQD.CurrentRow != null)
     {
         if (MessageBox.Show("Bạn thực sự muốn xoá quyết định này?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 oQuyetDinh.Ma_Quyet_Dinh = dtgv_DSQD.CurrentRow.Cells[0].Value.ToString();
                 if (oQuyetDinh.Delete())
                 {
                     MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 RefreshDataSource();
             }
             catch (Exception)
             {
                 MessageBox.Show("Xóa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Example #2
0
        private void btn_DeleteQD_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn thực sự muốn xoá quyết định này?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    if (dtPhuCap.Rows.Count > 0 || thongTinQuyetDinh1.txt_MaQD.Text != "")
                    {
                        List <string> ma_nv = new List <string>();

                        foreach (DataRow dr in dtPhuCap.Rows)
                        {
                            ma_nv.Add(dr["ma_nv"].ToString());
                        }

                        oQuyetDinh.Ma_Quyet_Dinh = thongTinQuyetDinh1.txt_MaQD.Text;

                        if (oQuyetDinh.Delete(ma_nv.ToArray()))
                        {
                            MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Xóa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Không thể thực hiện thao tác xóa quyết định.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Xóa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }