private void btnExe_Click(object sender, EventArgs e) { try { switch (cbxAction.SelectedIndex) { case 0: if (txtQuantity.Value == 0) { MessageBox.Show("Your quanity must be bigger than 0", "ERROR!"); txtQuantity.Focus(); txtQuantity.Select(0, 1); } else { string iditem = txtIditem.Text; iditem = iditem.ToUpper().ToString(); DataTable dtdetail = receiptBLL.addreceiptdetail(iditem, itemBLL.getname(), Convert.ToInt16(txtQuantity.Value), itemBLL.getprice()); dgvReceiptDetail.DataSource = dtdetail; txtTotal.Text = receiptBLL.getreceiptgrantotal().ToString(); startadd(); } break; case 1: if (dgvReceiptDetail.CurrentCell != null) { if (txtQuantity.Value == 0) { MessageBox.Show("Your quanity must be bigger than 0", "ERROR!"); txtQuantity.Focus(); txtQuantity.Select(0, 1); } else { string iditem = txtIditem.Text; iditem = iditem.ToUpper().ToString(); int rownum = dgvReceiptDetail.CurrentCell.RowIndex; int quantity = (int)txtQuantity.Value; itemBLL.verifyitem(iditem); DataTable dtdetail = receiptBLL.mofidyreceiptdetail(rownum, quantity, itemBLL.getprice()); dgvReceiptDetail.DataSource = dtdetail; txtTotal.Text = receiptBLL.getreceiptgrantotal().ToString(); } } else { MessageBox.Show("There is no detail to modify!", "ERROR"); } break; case 2: if (dgvReceiptDetail.CurrentCell != null) { int rownum = dgvReceiptDetail.CurrentCell.RowIndex; DataTable dtdetail = receiptBLL.deletereceiptdetail(rownum); dgvReceiptDetail.DataSource = dtdetail; txtTotal.Text = receiptBLL.getreceiptgrantotal().ToString(); } else { MessageBox.Show("There is no detail to delete!", "ERROR"); } break; } } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR"); } }