private void btnCreate_Click(object sender, EventArgs e) { if (ProductsReceivedTable.Rows.Count != 0) { //if (GeneralMethods.CreateNewReceieveOrder()) //{ GeneralMethods.CreateReceiveOrder(UserID); ROID = GeneralMethods.GetReceiveOrderID(); //GeneralMethods.CreatePurchaseOrder(); foreach (DataRow row in ProductsReceivedTable.Rows) { int pid = (Convert.ToInt32(row["ID"])); int quantity = (Convert.ToInt32(row[2])); float amount = (Convert.ToSingle(row[3])); GeneralMethods.CreateReceiveOrderTransaction(ROID, UserID, pid, quantity, amount); float Price = amount / quantity; int Profit = GeneralMethods.GetProfitRate(pid); float SellingPrice = ((Price / 100) * Profit) + Price; int OldQuantity = GeneralMethods.GetQuantity(pid); GeneralMethods.UpdateProductQuantityAndPrice(pid, (quantity + OldQuantity), Price, SellingPrice); //if ((GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity) > 0) //{ // GeneralMethods.CreatePurchaseOrderAfterReceive(GeneralMethods.GetProductVendor(pid), pid, (GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity)); //} } //DataTable LastPurchaseOrder = new DataTable(); //DataTable NewPurchaseOrder = new DataTable(); //LastPurchaseOrder = GeneralMethods.GetPurchaseOrderTransactionTable((GeneralMethods.GetPurchaseOrderID() - 1)); //NewPurchaseOrder = GeneralMethods.GetPurchaseOrderTransactionTable(GeneralMethods.GetPurchaseOrderID()); //foreach (DataRow row in LastPurchaseOrder.Rows) //{ // bool Present = false; // int VendorID = 0; // int Quantity = 0; // int pid = Convert.ToInt32(row["pid"]); // foreach (DataRow NewRow in NewPurchaseOrder.Rows) // { // int npid = Convert.ToInt32(NewRow["pid"]); // if (npid == pid) // { // Present = true; // break; // } // VendorID = Convert.ToInt32(row["vid"]); // Quantity = Convert.ToInt32(row["potquantity"]); // if (!Present) // { // GeneralMethods.CreatePurchaseOrderAfterReceive(VendorID, pid, Quantity); // } // } //} GeneralMethods.CreatePurchaseOrderMethod(); MessageBox.Show("Receive Order Successfully Created!", "Success!"); //} } else { MessageBox.Show("Please select some items first!", "Error!"); } }