private void Pay_Click(object sender, EventArgs e) { if (TotalPrice.Text == "" || Int32.Parse(TotalPrice.Text) == 0) { MessageBox.Show(" You must enter at least one pruduct to complete the sale ", "Invaild Input", MessageBoxButtons.OK); } else if (CustomerID.Text == "" || CheckCustomerID() == false) { MessageBox.Show("Please enter valid Customer ID ", "Invaild Input", MessageBoxButtons.OK); } else { DialogResult dialogResult = MessageBox.Show("Do you want to finish the purchase?", "Finish the Purchase", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { CalculateFinalPrice(); MessageBox.Show(" Thank you, the total amount is : " + Total_Price, "Invaild Input", MessageBoxButtons.OK); DateTime date = Convert.ToDateTime(DateTime.Now, CultureInfo.InvariantCulture); Purchase pfc = new Purchase(Convert.ToInt32(PurchaseID.Text, CultureInfo.InvariantCulture), Convert.ToDouble(Total_Price, CultureInfo.InvariantCulture), Program.seekEmployee(EMP_ID), Program.seekCustomer(Convert.ToInt32(CustomerID.Text, CultureInfo.InvariantCulture)), date, (PaymentMethod)Enum.Parse(typeof(PaymentMethod), PMInput.Text), Program.seekPromoCode(PromotionCode.Text), true); string data2 = string.Empty; foreach (DataGridViewRow row in dataGridView1.Rows) { data2 = Convert.ToString(row.Cells[1].Value); int quantity1 = Convert.ToInt32(row.Cells[2].Value); Product pnew = Program.seekProductByName(data2); if (pnew != null) { ProductInPurchases NewPIP = new ProductInPurchases(pfc, pnew, quantity1, true); pnew.setProductQuantity(pnew.get_productQuantity() - quantity1); // change to new quantity attribute pnew.update_product(); // update sql messageBoxForInventoryAlert(); } } } else if (dialogResult == DialogResult.No) { } foreach (Purchase p in Program.purchases) //check of hahalot - products of every Purchase { p.PrintAll(); } foreach (Product p in Program.products) //check of hahalot - Purchase of everyProduct { Console.WriteLine("printing ProductIn lists of products"); p.printAllProductsInPurchases(); } } }
public static void init_Product_In_Purchases()//init data from sql { SqlCommand c = new SqlCommand(); c.CommandText = "EXECUTE dbo.Get_All_Products_In_Purchases"; SQL_CON SC = new SQL_CON(); SqlDataReader rdr = SC.execute_query(c); productsInPurchase = new List <ProductInPurchases>(); while (rdr.Read()) { ProductInPurchases proipur = new ProductInPurchases(seekPurchases(int.Parse(rdr.GetValue(0).ToString())), seekProduct(rdr.GetValue(1).ToString()), int.Parse(rdr.GetValue(2).ToString()), false); productsInPurchase.Add(proipur); } }
public void addProductsInPurchase(ProductInPurchases pip1) { this.Products_In_Purchase.Add(pip1); }
} // updating priority public void addProductsInPurchase(ProductInPurchases pip1) { this.purchasesOfThisProduct.Add(pip1); }