Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Producty_type pt = new Producty_type();
            Product p = new Product();
            ViewItems vi = new ViewItems();
            pt.loadProductType(cboType.Text);
            int temp = pt.getIdproductType();

            vi.loadViewItems(txtProduct.Text);
            double temp2 = vi.ItemId;

            p.setProductType(temp);
            p.setDescription(txtDescription.Text);
            p.setQty(Convert.ToDouble(txtQuantity.Text));
            p.setAmount(Convert.ToDouble(txtAmount.Text));
            p.setItemId(temp2);
            p.setOutBy(GLOBAL_VARS.ActiveUser.Username);

            if (this.active_product_id != 0)
            {
                p.setIdproducts(active_product_id);
                p.edit();
            }
            else {
                p.Save();
            }

             //DB2 Transaction goes here...
            if (cboType.Text == "Egg") {
                TransactionForDB2 tdb2 = new TransactionForDB2();
                //for StockInTransaction Class
                tdb2.St.FromSupplier = 6;
                tdb2.St.Remarks = "Stockin from Poultry";
                tdb2.St.TotalNoOfItems = 1;
                tdb2.St.TotalQty = Convert.ToDouble(txtQuantity.Text);
                tdb2.St.PreparedBy = GLOBAL_VARS.ActiveUser.Username;
                tdb2.St.ApprovedBy = GLOBAL_VARS.ActiveUser.Username;
                tdb2.St.ReceivedBy = GLOBAL_VARS.ActiveUser.Username;
                //for StockIn Class
                tdb2.S.ItemId = IdOfSelectedItem;
                tdb2.S.QtyIn = Convert.ToDouble(txtQuantity.Text);
                tdb2.addToCollectionOfS(tdb2.S);
                //for Quick report
                tdb2.Q.ItemCode = txtProduct.Text;
                tdb2.Q.ItemQty = Convert.ToDouble(txtQuantity.Text);
                tdb2.Q.ItemQtyStanding = ((Convert.ToDouble(f.getAttribute("db2", "items", "item_qty", "item_code", txtProduct.Text))) + tdb2.Q.ItemQty);
                tdb2.Q.TransactionType = "stock_in";

                tdb2.ExecuteDB2Transaction();
            }
             //end of DB2 Transaction

            vp.loadListviewItem();
        }