I am creating a GRN application using winforms. I have 2 tables.
Table 1: In hand stock
Table 2: Sales
How can I subtract in hand stock from Quantity after a sale. This is my code for data base inserting. While adding these I want to subtract.
String SQL = "insert into Items_Sold values('"
+ myobj.Invoiceno + "','"
+ myobj.Itemcode + "','"
+ myobj.Category + "','"
+ myobj.Itemname + "','"
+ myobj.Qty + "','"
+ myobj.Unitprice + "',' "
+ myobj.Subtotal + "')";
DBConnection mycon = new DBConnection();
mycon.insertValues(SQL);
I tried
{
string SQL = "Update Stock Set Invoiceno='"
+ textBox_InvoiceNo.Text.Trim() + "', "
+ "Quantity='" + textBox_Qty.Text.Trim() + "',"
DBConnection database = new DBConnection();
int rslt = database.updatetValues(SQL);
if (rslt > 0)
{
MessageBox.Show("Updated");
}
else
{
MessageBox.Show("Faild");
}
}
This is updating my database with new data.