Esempio n. 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (dgvData.Rows.Count < 1 || dgvData.CurrentCellAddress.Y < 0)
            {
                return;
            }
            if (MessageBox.Show("Xác nhận?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            try
            {
                int i  = dgvData.CurrentRow.Index;
                int ID = Convert.ToInt32(dgvData.Rows[i].Cells["ColID"].Value.ToString());

                long re = bus.Delete(ID);

                if (re > 0)
                {
                    LoadData();
                    MessageBox.Show("Thành công.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Đơn vị tính đã được sử dụng", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Không thành công!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public bool DonViTinh_Delete(int mansp)
 {
     try
     {
         return(DonViTinh_bus.Delete(mansp));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (XtraMessageBox.Show("Bạn có muốn xóa đơn vị tính này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             bus.Delete(Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[3]).ToString()));
             XtraMessageBox.Show("Đã xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             HienThi();
             KhoaDieuKhien();
         }
         catch
         {
         }
     }
 }