Exemplo n.º 1
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            Store aStore=new Store();
            StoreDAO aStoreDao=new StoreDAO();
            aStore = aStoreDao.GetOtherStoreByItemId(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.InsertOtherTransaction(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.UpdateOtherStore(aStore);
            MessageBox.Show(sr);
            if(sr=="Insert Sucessfully")
            {
                this.Close();
            }
        }
Exemplo n.º 2
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            Store aStore = new Store();
            StoreDAO aStoreDao = new StoreDAO();
            aStore = aStoreDao.GetOtherStoreByItemId(ItemId);
            Transaction1 aTransaction1 = new Transaction1();
            aTransaction1.ItemName = aStore.ItemName;
            aTransaction1.TransactionType = othertransactiontypelebel.Text;
            aTransaction1.Amount = Convert.ToDouble(quantitytextBox.Text) * aStore.UnitPrice;
            aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.ItemUnit = aStore.Unit;
            aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.CauseOrPurpose = purposeTextBox.Text.Trim();
            if (aStore.Quantity >= 0)
            {

                aStoreDao.InsertOtherTransaction(aTransaction1,CategoryId);

                string sr = aStoreDao.UpdateOtherStore(aStore);
                MessageBox.Show(sr);
                if (sr == "Insert Sucessfully")
                {
                    this.Close();
                }
            }
            else MessageBox.Show("Not Enough quantity");
        }