private void savebutton_Click(object sender, EventArgs e) { Store aStore = new Store(); StoreDAO aStoreDao = new StoreDAO(); aStore = aStoreDao.GetStoreByItemId(ItemId); Transaction1 aTransaction1 = new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = transactiontypelebel.Text; aTransaction1.Amount = Convert.ToDouble(quantitytextBox.Text)*aStore.UnitPrice; aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aTransaction1.CauseOrPurpose = purposeTextBox.Text.Trim(); aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text); if (aStore.Quantity >= 0) { aStoreDao.InsertTransaction(aTransaction1,CategoryId); string sr = aStoreDao.UpdateStore(aStore); MessageBox.Show(sr); if (sr == "Insert Sucessfully") { this.Close(); } } else MessageBox.Show("Not Enough quantity"); }
private void savebutton_Click(object sender, System.EventArgs e) { Store aStore=new Store(); StoreDAO aStoreDao=new StoreDAO(); aStore = aStoreDao.GetStoreByItemId(ItemId); Transaction1 aTransaction1=new Transaction1(); aTransaction1.ItemName = aStore.ItemName; aTransaction1.TransactionType = "Purchase"; aTransaction1.SupplierName = supplierNamecomboBox.Text; aTransaction1.Amount = Convert.ToDouble(amounttextBox.Text); aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text); aTransaction1.ItemUnit = aStore.Unit; aStoreDao.InsertTransaction(aTransaction1,CategoryId); double newstore = aStore.Amount + Convert.ToDouble(amounttextBox.Text); double newquantity = aStore.Quantity + Convert.ToDouble(quantitytextBox.Text); double unitprice = 0; if (newquantity != 0) { unitprice = (newstore / newquantity); } else unitprice = 0; aStore.UnitPrice = unitprice; aStore.Quantity = newquantity; string sr = aStoreDao.UpdateStore(aStore); MessageBox.Show(sr); if(sr=="Insert Sucessfully") { this.Close(); } }