private void btnCreate_Click(object sender, EventArgs e) { if (CartTable.Rows.Count != 0) { GeneralMethods.CreateSalesOrder(CustID); SOID = GeneralMethods.GetSalesOrderID(); int Sum = 0; foreach (DataRow row in CartTable.Rows) { int pid = (Convert.ToInt32(row["ID"])); int quantity = (Convert.ToInt32(row[2])); float amount = (Convert.ToSingle(row[3])); int OldQuantity = GeneralMethods.GetQuantity(pid); Sum += (int)amount; GeneralMethods.CreateSalesOrderTransaction(SOID, pid, quantity, amount); float Price = amount / quantity; int Profit = GeneralMethods.GetProfitRate(pid); float SellingPrice = ((Price / 100) * Profit) + Price; GeneralMethods.UpdateProductQuantityOnSale(pid, (OldQuantity - quantity)); GeneralMethods.CreatePurchaseOrderMethod(); //if ((GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity) > 0) //{ // GeneralMethods.CreatePurchaseOrderAfterReceive(GeneralMethods.GetProductVendor(pid), pid, (GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity)); //} //GeneralMethods.CreatePurchaseOrderMethod(); } MessageBox.Show("Your total bill:\t" + Sum + "\nThank You For Shopping!", "Success!"); } else { MessageBox.Show("Please add some items to cart first!", "Error!"); } }
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!"); } }