private void BtnSave_Click(object sender, EventArgs e) { StringBuilder param = new StringBuilder(); StringBuilder values = new StringBuilder(); StringBuilder where = new StringBuilder(); param.Append( "gc_item_name," + "gc_item_supp," + "gc_item_brand," + "gc_item_status," + "gc_delivery_date," + "gc_item_cost," + "gc_item_srp," + "gc_item_qty," + "gc_item_code," + "gc_item_type," + "gc_item_desc," + "gc_item_um" ); values.Append( deliveryInfoPage.txtItemName.Text + "," + deliveryInfoPage.cmbSupp.Text + "," + deliveryInfoPage.txtBrand.Text + "," + deliveryInfoPage.cmbItemStatus.Text + "," + deliveryInfoPage.dtDeliveryDate.Value + "," + float.Parse(deliveryInfoPage.txtCost.Text) + "," + float.Parse(deliveryInfoPage.txtSrp.Text) + "," + int.Parse(deliveryInfoPage.txtQty.Text) + "," + deliveryInfoPage.txtItemCode.Text + "," + deliveryInfoPage.cmbItemType.Text + "," + deliveryInfoPage.txtDesc.Text + "," + deliveryInfoPage.txtUm.Text ); where.Append("gc_item_name='" + deliveryInfoPage.itemName + "'"); //where.Append("gc_item_brand='"+deliveryInfoPage.itemBrand+"'"); //where.Append("gc_item_supp='"+deliveryInfoPage.itemSupp+"'"); db.GCUpdateDb("delivery", param, values, where); DataTable dt = db.GCSelectFromDb("delivery", null, null); dgDelivery.DataSource = null; dgDelivery.DataSource = dt; notification = new notification("Changes has been saved.", notification.AlertType.success); notification.ShowDialog(); deliveryInfoPage.Close(); deliveryInfoPage.btnSave.Click -= BtnSave_Click; }
private void btnUpdate_Click(object sender, EventArgs e) { if (txtSuppName.Text != "" && txtContact.Text != "") { StringBuilder param = new StringBuilder(); StringBuilder values = new StringBuilder(); StringBuilder where = new StringBuilder(); param.Append( "gc_supp_name," + "gc_supp_add," + "gc_contact," + "gc_email," + "gc_other_info" ); values.Append( txtSuppName.Text + "," + txtAddress.Text + "," + txtContact.Text + "," + txtEmail.Text + "," + txtOtherInfo.Text ); where.Append("gc_supp_name='" + suppName + "'"); db.GCUpdateDb("suppliers", param, values, where); notification = new notification("Supplier has been updated.", notification.AlertType.success); notification.ShowDialog(); } else { notification = new notification("Error updating, Please check the fields.", notification.AlertType.success); notification.ShowDialog(); } }
private void btnSave_Click(object sender, EventArgs e) { inventoryList invPage = new inventoryList(); StringBuilder where = new StringBuilder(); StringBuilder param = new StringBuilder(); StringBuilder values = new StringBuilder(); param.Append("gc_item_qty,gc_item_srp"); where.Append("gc_item_name='" + itemName + "' AND gc_item_code='" + itemCode + "'"); values.Append( int.Parse(txtQty.Text) + "," + float.Parse(txtItemPrice.Text) ); db.GCUpdateDb("inventory", param, values, where); }
private void BtnUpdate_Click(object sender, EventArgs e) { StringBuilder param = new StringBuilder(); StringBuilder values = new StringBuilder(); StringBuilder where = new StringBuilder(); param.Append("username,password,email,contact,other_info,full_name"); values.Append( editPage.txtUsername.Text + "," + editPage.txtPass.Text + "," + editPage.txtEmail.Text + "," + editPage.txtContact.Text + "," + editPage.txtOtherInfo.Text + "," + editPage.txtFullName.Text ); where.Append("username='******' AND password='******'"); if (editPage.txtFullName.Text != "" && editPage.txtUsername.Text != "" && editPage.txtPass.Text != "") { db.GCUpdateDb("users", param, values, where); DataTable dt = db.GCSelectFromDb("users", null, null); dgUsers.DataSource = null; dgUsers.DataSource = dt; editPage.btnUpdate.Click -= BtnUpdate_Click; notification = new notification("Successfully updated fields.", notification.AlertType.success); notification.ShowDialog(); } else { editPage.btnUpdate.Click -= BtnUpdate_Click; notification = new notification("Error updating. Please check fields.", notification.AlertType.error); notification.ShowDialog(); } editPage.Close(); }
private void BtnAddQty_Click(object sender, EventArgs e) { try { StringBuilder paramInv = new StringBuilder(); StringBuilder whereInv = new StringBuilder(); StringBuilder whereSearch = new StringBuilder(); whereSearch.Append("gc_item_code='" + itemCode + "'"); int resItemCode = db.searchData("stock", null, whereSearch); paramInv.Append("gc_item_qty"); whereInv.Append("gc_item_code='" + itemCode + "'"); DataTable dtInv = db.GCSelectFromDb("inventory", paramInv, whereInv); foreach (DataRow rowInv in dtInv.Rows) { currInventory = int.Parse(rowInv[0].ToString()); } if (currInventory >= int.Parse(invQtyPage.txtQty.Text)) { StringBuilder param = new StringBuilder(); StringBuilder where = new StringBuilder(); param.Append("gc_item_qty"); where.Append("gc_item_code='" + itemCode + "'"); DataTable dt = db.GCSelectFromDb("stock", param, where); foreach (DataRow row in dt.Rows) { currStock = int.Parse(row[0].ToString()); } if (resItemCode == 1) { StringBuilder paramUpdate = new StringBuilder(); StringBuilder valuesUpdate = new StringBuilder(); StringBuilder whereUpdate = new StringBuilder(); whereUpdate.Append("gc_item_code='" + itemCode + "'"); paramUpdate.Append("gc_item_qty"); valuesUpdate.Append(currStock + int.Parse(invQtyPage.txtQty.Text)); db.GCUpdateDb("stock", paramUpdate, valuesUpdate, whereUpdate); notification = new notification("Stock has been updated", notification.AlertType.success); notification.ShowDialog(); invQtyPage.btnAddQty.Click -= BtnAddQty_Click; } else { StringBuilder paramInsert = new StringBuilder(); StringBuilder valuesInsert = new StringBuilder(); paramInsert.Append( "gc_item_name," + "gc_item_qty," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_um," + "gc_item_cost," + "gc_item_srp," + "gc_date_added," + "gc_item_code," + "gc_item_type" ); valuesInsert.Append( itemName + "," + int.Parse(invQtyPage.txtQty.Text) + "," + itemDesc + "," + itemSupp + "," + itemBrand + "," + itemUm + "," + itemCost + "," + itemSrp + "," + DateTime.Today.ToString("MM/dd/yyyy") + "," + itemCode + "," + itemType ); db.GCInsertToDb("stock", paramInsert, valuesInsert); notification = new notification("Item has been added to stock!", notification.AlertType.success); notification.ShowDialog(); invQtyPage.btnAddQty.Click -= BtnAddQty_Click; } updateTrans("stock", itemCode, "in", int.Parse(invQtyPage.txtQty.Text), currStock, itemName); StringBuilder paramUpdateInv = new StringBuilder(); StringBuilder valuesUpdteInv = new StringBuilder(); StringBuilder whereUpdateInv = new StringBuilder(); whereUpdateInv.Append("gc_item_code='" + itemCode + "'"); paramUpdateInv.Append("gc_item_qty"); valuesUpdteInv.Append(currInventory - int.Parse(invQtyPage.txtQty.Text)); db.GCUpdateDb("inventory", paramUpdateInv, valuesUpdteInv, whereUpdateInv); updateTrans("inventory", itemCode, "out", int.Parse(invQtyPage.txtQty.Text), currInventory, itemName); dgStock.DataSource = null; DataTable dtRefresh = db.GCSelectFromDb("inventory", null, null, "ORDER BY id DESC"); dgStock.DataSource = dtRefresh; invQtyPage.btnAddQty.Click -= BtnAddQty_Click; } else { MessageBox.Show("Not enough item on inventory", "Inventory Dont have enought Item", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); invQtyPage.btnAddQty.Click -= BtnAddQty_Click; } } catch (Exception a) { MessageBox.Show(a.Message); invQtyPage.btnAddQty.Click -= BtnAddQty_Click; } invQtyPage.btnAddQty.Click -= BtnAddQty_Click; dgStock.Refresh(); invQtyPage.Close(); }
private void BtnSaveTrans_Click(object sender, EventArgs e) { if (float.Parse(transPage.lblTotal.Text) > float.Parse(transPage.txtCash.Text)) { notification = new notification("Cash is not enough to make transaction.", notification.AlertType.error); notification.ShowDialog(); return; } StringBuilder whereTransUpdate = new StringBuilder(); StringBuilder paramTransUpdate = new StringBuilder(); StringBuilder valuesTransUpdate = new StringBuilder(); foreach (ListViewItem lvi in transPage.lvCart.Items) { StringBuilder whereRes = new StringBuilder(); StringBuilder whereDel = new StringBuilder(); whereRes.Append("gc_item_code='" + lvi.SubItems[1].Text + "' AND gc_unique_id='" + transID + "'"); int result = db.searchData("transact", null, whereRes); if (result == 0) { StringBuilder values = new StringBuilder(); StringBuilder paramUpdate = new StringBuilder(); StringBuilder valuesUpdate = new StringBuilder(); StringBuilder whereUpdate = new StringBuilder(); values.Append( "Sales," + "out," + lvi.SubItems[2].Text + "," + itemQty + "," + DateTime.Now.ToString("MM/dd/yyyy") + "," + transID + "," + lvi.SubItems[1].Text + "," + transPage.txtCustomerName.Text + "," + transPage.txtAddress.Text + "," + lvi.SubItems[5].Text + "," + lvi.SubItems[6].Text + "," + lvi.Text + "," + float.Parse(lvi.SubItems[3].Text) * float.Parse(lvi.SubItems[2].Text) + "," + float.Parse(lvi.SubItems[4].Text) + "," + float.Parse(lvi.SubItems[3].Text) + "," + float.Parse(transPage.txtCash.Text) + "," + (float.Parse(transPage.txtCash.Text) - totalPrice) + "," + float.Parse(lvi.SubItems[4].Text) * float.Parse(lvi.SubItems[2].Text) ); paramUpdate.Append("gc_item_qty"); valuesUpdate.Append(int.Parse(lvi.SubItems[7].Text) - int.Parse(lvi.SubItems[2].Text)); whereUpdate.Append("gc_item_code='" + lvi.SubItems[1].Text + "'"); db.GCUpdateDb("stock", paramUpdate, valuesUpdate, whereUpdate); transaction.insertToTrans(values); } whereDel.Append("gc_unique_id='" + transID + "'"); DataTable dt = db.GCSelectFromDb("transact", null, whereDel); foreach (DataRow row in dt.Rows) { var resItem = transPage.lvCart.FindItemWithText(row[7].ToString(), true, 0); if (resItem == null) { StringBuilder whereDelItem = new StringBuilder(); StringBuilder valueDelItem = new StringBuilder(); StringBuilder paramStockUpdate = new StringBuilder(); StringBuilder valuesStockUpdate = new StringBuilder(); StringBuilder whereStockUpdate = new StringBuilder(); StringBuilder paramStock = new StringBuilder(); StringBuilder whereStock = new StringBuilder(); paramStock.Append("gc_item_qty"); whereStock.Append("gc_item_code='" + row[7].ToString() + "'"); DataTable dtQty = db.GCSelectFromDb("stock", paramStock, whereStock); foreach (DataRow dtQtyRow in dtQty.Rows) { currStockQty = int.Parse(dtQtyRow[0].ToString()); } whereDelItem.Append("gc_item_code,gc_unique_id"); valueDelItem.Append(row[7].ToString() + "," + row[6].ToString()); db.GCDeleteFromDb("transact", valueDelItem, whereDelItem); paramStockUpdate.Append("gc_item_qty"); whereStockUpdate.Append("gc_item_code='" + row[7].ToString() + "'"); valuesStockUpdate.Append(currStockQty + int.Parse(row[3].ToString())); db.GCUpdateDb("stock", paramStockUpdate, valuesStockUpdate, whereStockUpdate); DataTable dtStock = db.GCSelectFromDb("stock", null, null); transPage.dgStock.DataSource = null; transPage.dgStock.DataSource = dtStock; } else if (resItem != null) { StringBuilder wheretSelStock = new StringBuilder(); StringBuilder paramSelStock = new StringBuilder(); paramSelStock.Append("gc_item_qty"); wheretSelStock.Append("gc_item_code='" + lvi.SubItems[1].Text + "' AND gc_unique_id='" + transID + "'"); DataTable dtSelectStock = db.GCSelectFromDb("transact", paramSelStock, wheretSelStock); foreach (DataRow rowQty in dtSelectStock.Rows) { StringBuilder paramUpdateStock = new StringBuilder(); StringBuilder whereUpdateStock = new StringBuilder(); StringBuilder valuesUpdateStock = new StringBuilder(); StringBuilder whereSelItem = new StringBuilder(); StringBuilder paramSelItem = new StringBuilder(); paramSelItem.Append("gc_item_qty"); whereSelItem.Append("gc_item_code='" + lvi.SubItems[1].Text + "'"); DataTable dtSelItem = db.GCSelectFromDb("stock", paramSelItem, whereSelItem); foreach (DataRow rowSelItem in dtSelItem.Rows) { currStock = int.Parse(rowSelItem[0].ToString()); } paramUpdateStock.Append("gc_item_qty"); whereUpdateStock.Append("gc_item_code='" + lvi.SubItems[1].Text + "'"); if (int.Parse(rowQty[0].ToString()) < int.Parse(lvi.SubItems[2].Text)) { addedQty = int.Parse(lvi.SubItems[2].Text) - int.Parse(rowQty[0].ToString()); valuesUpdateStock.Append(currStock - addedQty); db.GCUpdateDb("stock", paramUpdateStock, valuesUpdateStock, whereUpdateStock); } else if (int.Parse(rowQty[0].ToString()) > int.Parse(lvi.SubItems[2].Text)) { addedQty = int.Parse(rowQty[0].ToString()) - int.Parse(lvi.SubItems[2].Text); valuesUpdateStock.Append(currStock + addedQty); db.GCUpdateDb("stock", paramUpdateStock, valuesUpdateStock, whereUpdateStock); } } whereTransUpdate.Append( "gc_from_tbl='sales' " + "AND gc_unique_id='" + transID + "' " + "AND gc_item_code='" + lvi.SubItems[1].Text + "'" ); paramTransUpdate.Append( "gc_item_qty," + "gc_total_price," + "gc_item_cost," + "gc_cust_cash," + "gc_cust_change," + "gc_trans_date," + "gc_cost_total" ); valuesTransUpdate.Append( lvi.SubItems[2].Text + "," + (float.Parse(lvi.SubItems[3].Text) * float.Parse(lvi.SubItems[2].Text)) + "," + float.Parse(lvi.SubItems[4].Text) + "," + float.Parse(transPage.txtCash.Text) + "," + (float.Parse(transPage.txtCash.Text) - float.Parse(transPage.lblTotal.Text)) + "," + DateTime.Now.ToString("MM/dd/yyyy") + "," + float.Parse(lvi.SubItems[2].Text) * float.Parse(lvi.SubItems[4].Text) ); try { transaction.GCUpdateDb("transact", paramTransUpdate, valuesTransUpdate, whereTransUpdate); DataTable dtStock = db.GCSelectFromDb("stock", null, null); transPage.dgStock.DataSource = null; transPage.dgStock.DataSource = dtStock; notification = new notification("Transaction has been updated.", notification.AlertType.success); notification.Show(); } catch (Exception a) { notification = new notification("Transaction error. Please check fields.", notification.AlertType.error); MessageBox.Show(a.Message); notification.Show(); } } } } transPage.dgStock.DataSource = null; DataTable dtTransHist = db.GCSelectFromDb("stock", null, null); transPage.dgStock.DataSource = dtTransHist; transPage.btnSaveTrans.Click -= BtnSaveTrans_Click; }
private void btnSaveTrans_Click(object sender, EventArgs e) { if (SaveMode == true) { if (txtCustomerName.Text == "" && txtAddress.Text == "") { notification = new notification("Error saving. Check fields before saving.", notification.AlertType.error); notification.Show(); return; } string randID = view.Random("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 5); foreach (ListViewItem lvi in lvCart.Items) { StringBuilder values = new StringBuilder(); StringBuilder paramUpdate = new StringBuilder(); StringBuilder valuesUpdate = new StringBuilder(); StringBuilder whereUpdate = new StringBuilder(); values.Append( "Sales," + "out," + lvi.SubItems[2].Text + "," + itemQty + "," + DateTime.Today + "," + randID + "," + lvi.SubItems[1].Text + "," + txtCustomerName.Text + "," + txtAddress.Text + "," + lvi.SubItems[5].Text + "," + lvi.SubItems[6].Text + "," + lvi.Text + "," + float.Parse(lvi.SubItems[3].Text) * float.Parse(lvi.SubItems[2].Text) + "," + float.Parse(lvi.SubItems[4].Text) + "," + float.Parse(lvi.SubItems[3].Text) + "," + float.Parse(txtCash.Text) + "," + (float.Parse(txtCash.Text) - totalPrice) + "," + float.Parse(lvi.SubItems[4].Text) * float.Parse(lvi.SubItems[2].Text) ); paramUpdate.Append("gc_item_qty"); valuesUpdate.Append(int.Parse(lvi.SubItems[7].Text) - int.Parse(lvi.SubItems[2].Text)); whereUpdate.Append("gc_item_code='" + lvi.SubItems[1].Text + "'"); db.GCUpdateDb("stock", paramUpdate, valuesUpdate, whereUpdate); transaction.insertToTrans(values); } dgStock.DataSource = null; DataTable dt = db.GCSelectFromDb("stock", null, null); dgStock.DataSource = dt; foreach (Control ctrl in panel1.Controls) { if (ctrl.GetType() == typeof(TextBox)) { ctrl.Text = ""; } } lvCart.Items.Clear(); DialogResult drPrint = MessageBox.Show("Do you want to print this transaction?", "Print this transaction?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drPrint == DialogResult.Yes) { receiptPage.transID = randID; receiptPage.ShowDialog(); } else { notification = new notification("Transaction has been saved.", notification.AlertType.success); notification.Show(); } } }
private void btnSave_Click(object sender, EventArgs e) { StringBuilder whereItemCode = new StringBuilder(); StringBuilder whereUpdate = new StringBuilder(); StringBuilder paramUpdate = new StringBuilder(); StringBuilder valuesUpdate = new StringBuilder(); StringBuilder whereInvUpdate = new StringBuilder(); StringBuilder paramInvUpdate = new StringBuilder(); StringBuilder valuesInvUpdate = new StringBuilder(); StringBuilder whereStockUpdate = new StringBuilder(); StringBuilder paramStockUpdate = new StringBuilder(); StringBuilder valuesStockUpdate = new StringBuilder(); if (itemCode != "" && itemCode != txtItemCode.Text) { whereItemCode.Append("gc_item_code='" + txtItemCode.Text + "'"); int resItemCode = db.searchData("products", null, whereItemCode); if (resItemCode == 1) { notification = new notification("Item Code already Existing", notification.AlertType.error); notification.ShowDialog(); } else { paramInvUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type" ); valuesInvUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text ); paramStockUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type" ); valuesStockUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text ); paramUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type," + "gc_item_status" ); valuesUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text + "," + "in-active" ); whereInvUpdate.Append("gc_item_code='" + itemCode + "'"); whereStockUpdate.Append("gc_item_code='" + itemCode + "'"); whereUpdate.Append("gc_item_code='" + itemCode + "'"); db.GCUpdateDb("stock", paramStockUpdate, valuesStockUpdate, whereStockUpdate); db.GCUpdateDb("inventory", paramInvUpdate, valuesInvUpdate, whereInvUpdate); db.GCUpdateDb("products", paramUpdate, valuesUpdate, whereUpdate); notification = new notification("Product information updated.", notification.AlertType.success); notification.ShowDialog(); } } else if (itemCode != "" && txtItemName.Text != "") { paramInvUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type" ); valuesInvUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text ); paramStockUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type" ); valuesStockUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text ); paramUpdate.Append( "gc_item_name," + "gc_item_code," + "gc_item_um," + "gc_item_desc," + "gc_item_supp," + "gc_item_brand," + "gc_item_cost," + "gc_item_srp," + "gc_item_type," + "gc_item_status" ); valuesUpdate.Append( txtItemName.Text + "," + txtItemCode.Text + "," + txtUm.Text + "," + txtDesc.Text + "," + cmbSupp.Text + "," + txtBrand.Text + "," + float.Parse(txtCost.Text) + "," + float.Parse(txtSrp.Text) + "," + cmbItemType.Text + "," + "in-active" ); whereInvUpdate.Append("gc_item_code='" + itemCode + "'"); whereStockUpdate.Append("gc_item_code='" + itemCode + "'"); whereUpdate.Append("gc_item_code='" + itemCode + "'"); db.GCUpdateDb("stock", paramStockUpdate, valuesStockUpdate, whereStockUpdate); db.GCUpdateDb("inventory", paramInvUpdate, valuesInvUpdate, whereInvUpdate); db.GCUpdateDb("products", paramUpdate, valuesUpdate, whereUpdate); notification = new notification("Product information updated.", notification.AlertType.success); notification.ShowDialog(); } else { notification = new notification("Error. Please check fields before saving.", notification.AlertType.error); notification.ShowDialog(); } }
private void dgStock_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (e.ColumnIndex == 12) { try { itemName = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString(); itemCode = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString(); qty = int.Parse(senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString()); itemDesc = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString(); itemSupp = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString(); itemBrand = senderGrid.Rows[e.RowIndex].Cells[5].Value.ToString(); itemUm = senderGrid.Rows[e.RowIndex].Cells[6].Value.ToString(); itemCost = float.Parse(senderGrid.Rows[e.RowIndex].Cells[7].Value.ToString()); itemSrp = float.Parse(senderGrid.Rows[e.RowIndex].Cells[8].Value.ToString()); itemType = senderGrid.Rows[e.RowIndex].Cells[10].Value.ToString(); stockAddPage.btnAddQty.Click += BtnAddQty_Click; stockAddPage.ShowDialog(); } catch (Exception a) { MessageBox.Show(a.Message); } } else if (e.ColumnIndex == 11) { StringBuilder whereDel = new StringBuilder(); StringBuilder valuesDel = new StringBuilder(); StringBuilder paramInvUpdate = new StringBuilder(); StringBuilder valuesInvUpdate = new StringBuilder(); StringBuilder whereInvUpdate = new StringBuilder(); StringBuilder paramInvAdd = new StringBuilder(); StringBuilder whereInvAdd = new StringBuilder(); DialogResult delRes = MessageBox.Show("Are you sure you want to delete this stock?", "Delete Supplier?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (delRes == DialogResult.Yes) { paramInvAdd.Append("gc_item_qty"); whereInvAdd.Append("gc_item_code='" + senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString() + "'"); DataTable dtInv = db.GCSelectFromDb("inventory", paramInvAdd, whereInvAdd); foreach (DataRow row in dtInv.Rows) { currInventory = int.Parse(row[0].ToString()); } whereDel.Append("gc_item_code"); valuesDel.Append(senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString()); db.GCDeleteFromDb("stock", valuesDel, whereDel); paramInvUpdate.Append("gc_item_qty"); valuesInvUpdate.Append(currInventory + int.Parse(senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString())); whereInvUpdate.Append("gc_item_code='" + senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString() + "'"); db.GCUpdateDb("inventory", paramInvUpdate, valuesInvUpdate, whereInvUpdate); notification = new notification("Stock has been deleted.", notification.AlertType.success); notification.ShowDialog(); dgStock.DataSource = null; DataTable dtRemove = db.GCSelectFromDb("stock", null, null, "ORDER BY id DESC"); dgStock.DataSource = dtRemove; } } }