Exemple #1
0
        private void btn_AddNewItem_Click(object sender, EventArgs e)
        {
            var form2 = new Add_Drug();

            form2.ShowDialog();
            form2.Dispose();
        }
Exemple #2
0
 private void Dgv_Product_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (Dgv_Product.Rows.Count > 0)
         {
             string itemcode = Dgv_Product.CurrentRow.Cells["id"].Value.ToString();
             if (Dgv_Product.CurrentCell.OwningColumn.Name == "ColEdit")
             {
                 DataTable dtb = this.cntrl.Get_itemDetails(itemcode);
                 if (dtb.Rows.Count > 0)
                 {
                     var form2 = new Add_Drug(dtb);
                     form2.ShowDialog();
                     form2.Dispose();
                 }
             }
             else if (Dgv_Product.CurrentCell.OwningColumn.Name == "ColDelete")
             {
                 int          i   = 0;
                 DialogResult res = MessageBox.Show("Are you sure you want to delete..?", "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                 if (res == DialogResult.Yes)
                 {
                     int       index = Dgv_Product.CurrentRow.Index;
                     DataTable dt    = this.cntrl.get_stock(itemcode);
                     if (dt.Rows[0][0].ToString() != "")
                     {
                         if (Convert.ToDecimal(dt.Rows[0][0].ToString()) > 0)
                         {
                             MessageBox.Show("Item have stock", "Can't Delete..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                             return;
                         }
                         else
                         {
                         }
                     }
                     else
                     {
                         i = this.cntrl.delete(itemcode);
                         if (i > 0)
                         {
                             Dgv_Product.Rows.RemoveAt(index);
                             DataTable dtb = this.cntrl.Fill_Grid();
                             Fill_Grid(dtb);
                         }
                     }
                 }
             }
         }
     }
 }