private void saveStock_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtStPrice.Text) || string.IsNullOrWhiteSpace(txtTrnsID.Text)) { MessageBox.Show("The cart is Empty!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult res = MessageBox.Show("Are you sure, You want to save this cart?", "Confirm to Save!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { string itemList = ""; foreach (DataGridViewRow r in dtInventory.Rows) { ////////////////////Generating the ID//////////////////// string genInvID; string InvID = r.Cells[0].Value.ToString(); if (r.Cells[0].Value.ToString() == "New Arrival") { config.singleResult("SELECT concat(STRT,END) FROM genid WHERE ID = 1"); genInvID = config.dt.Rows[0].Field <string>(0); config.update_Autonumber("Inventory"); } else { genInvID = InvID; } //////////////////////Sql for saving////////////////////// sql = "SELECT * FROM inventory WHERE inventoryID='" + r.Cells[0].Value + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "UPDATE inventory SET Qty = '" + r.Cells[2].Value + "' WHERE inventoryID ='" + r.Cells[0].Value + "'"; config.Execute_Query(sql); } else { sql = "INSERT INTO `inventory` ( `inventoryID`, `itemID`, `Qty`)" + " VALUES ('" + genInvID + "','" + r.Cells[1].Value + "','" + r.Cells[2].Value + "')"; config.Execute_Query(sql); } ///////////////////Item List/////////////////////////////// itemList = itemList + r.Cells[1].Value + "(" + r.Cells[3].Value + "), "; } itemList = itemList.Substring(0, (itemList.Length - 2)); sql = "INSERT INTO `transactions` (`transID`, `user`, `transType`, `transDate`, `items`, `stockPrice`)" + " VALUES ('" + txtTrnsID.Text + "','" + Login.user + "','Stock-IN','" + txtDate.Text + "','" + itemList + "','" + txtStPrice.Text + "')"; config.Execute_Query(sql); config.update_Autonumber("Transaction"); ClearAll(); } } }
private void btnSave_Click(object sender, EventArgs e) { foreach (Control obj in pnl_productManager.Controls) { if (obj is TextBox) { if (obj.Text == "") { MessageBox.Show("Action connot be perform. All fields are required to be fill up.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } sql = "SELECT ITEMID FROM items WHERE ITEMID='" + itemID.Text + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "UPDATE items SET qty =qty + '" + quantity.Text + "' WHERE ITEMID ='" + itemID.Text + "'"; config.Execute_Query(sql); } else { sql = "insert into items (ITEMID,`NAME`, `DESCRIPTION`, `TYPE`, `PRICE`, `QTY`,UNIT)" + "VALUES ('" + itemID.Text + "','" + name.Text + "','" + description.Text + "','" + type.Text + "','" + price.Text + "','" + quantity.Text + "','" + units.Text + "' )"; config.Execute_CUD(sql, "No data saved.", "Data has been saved in the database."); config.update_Autonumber(type.Text); } btnNew_Click(sender, e); }
private void btnsave_Click(object sender, EventArgs e) { foreach (Control obj in pnl_stockmaster.Controls) { if (obj is TextBox) { if (obj.Text == "") { MessageBox.Show("Action connot be perform. All fields are required to be fill up.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } sql = "INSERT INTO `tblstock_in_out` (`ITEMID`, `QTY`,`TRANSACTIONDATE`, `TOTALPRICE`, `REMARKS`)" + " VALUES ('" + txtitemid.Text + "','" + txtqty.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + txtprice.Text + "','StockIn')"; config.Execute_Query(sql); sql = "SELECT ITEMID FROM tblitems WHERE ITEMID='" + txtitemid.Text + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "UPDATE tblitems SET qty =qty + '" + txtqty.Text + "' WHERE ITEMID ='" + txtitemid.Text + "'"; config.Execute_Query(sql); } else { sql = "insert into tblitems (ITEMID,`NAME`, `DESCRIPTION`, `TYPE`, `PRICE`, `QTY`,UNIT)" + "VALUES ('" + txtitemid.Text + "','" + txtname.Text + "','" + txtdescription.Text + "','" + cbotype.Text + "','" + txtprice.Text + "','" + txtqty.Text + "','" + cbounit.Text + "' )"; config.Execute_CUD(sql, "No data saved.", "Data has been saved in the database."); config.update_Autonumber(cbotype.Text); } btnnew_Click(sender, e); }
private void btnsave_Click(object sender, EventArgs e) { foreach (Control obj in pnl_stockmaster.Controls) { if (obj is TextBox) { if (obj.Text == "") { MessageBox.Show("No se puede realizar ninguna acción. Todos los campos deben completarse.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } sql = "INSERT INTO `tblstock_in_out` (`ITEMID`, `QTY`,`TRANSACTIONDATE`, `TOTALPRICE`, `REMARKS`)" + " VALUES ('" + txtitemid.Text + "','" + txtqty.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + txtprice.Text + "','StockIn')"; config.Execute_Query(sql); sql = "SELECT ITEMID FROM tblitems WHERE ITEMID='" + txtitemid.Text + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "UPDATE tblitems SET qty =qty + '" + txtqty.Text + "' WHERE ITEMID ='" + txtitemid.Text + "'"; config.Execute_Query(sql); } else { sql = "insert into tblitems (ITEMID,`NAME`, `DESCRIPTION`, `TYPE`, `PRICE`, `QTY`,UNIT)" + "VALUES ('" + txtitemid.Text + "','" + txtname.Text + "','" + txtdescription.Text + "','" + cbotype.Text + "','" + txtprice.Text + "','" + txtqty.Text + "','" + cbounit.Text + "' )"; config.Execute_CUD(sql, "No hay datos guardados.", "Los datos se han guardado en la base de datos."); config.update_Autonumber(cbotype.Text); } btnnew_Click(sender, e); }