private void Save_Click(object sender, EventArgs e) { if (OrderOutput.Text == "" || Int32.Parse(OrderOutput.Text) == 0) { MessageBox.Show(" Please field all the fields ", "Invaild Input", MessageBoxButtons.OK); } else { DateTime date = Convert.ToDateTime(OrderDateInput.Text, CultureInfo.InvariantCulture); DateTime duedate = Convert.ToDateTime(dateTimePicker1.Value, CultureInfo.InvariantCulture); string description1 = DescrriptionBox.Text; // str = dataGridView1.Rows[DataGridView.SelectedRows[0].Index].Cells[X].Value.ToString(); OrderFromSupplier OFS = new OrderFromSupplier(Convert.ToInt32(OrderIDInput.Text, CultureInfo.InvariantCulture), date, duedate, Convert.ToDouble(Total_Price, CultureInfo.InvariantCulture), (PaymentMethod)Enum.Parse(typeof(PaymentMethod), PMInput.Text), (OrderStatus)Enum.Parse(typeof(OrderStatus), "UnderTreatment"), Program.seekEmployee(EMP_ID), Program.seekSupplierByName(SupllierInput.Text), description1, true); string data = string.Empty; foreach (DataGridViewRow row in dataGridView1.Rows) { data = Convert.ToString(row.Cells[2].Value); int quantity1 = Convert.ToInt32(row.Cells[3].Value); Product pnew = Program.seekProductByName(data); if (pnew != null) { ProductInOrder NewPIP = new ProductInOrder(pnew, OFS, quantity1, true); } } } foreach (OrderFromSupplier o in Program.ordersFromSuppliers) //check of hahalot - products of every order { o.PrintAll(); } foreach (Product p in Program.products) //check of hahalot - orders of this product { Console.WriteLine("printing ProductInOrder lists of products"); p.printAllSupplierOrdersOfThisProduct(); } this.Close(); Main_Menu New_MM = new Main_Menu(EMP_ID); New_MM.Enabled = true; New_MM.Show(); }
public ProductInOrder(Product productInOrder, OrderFromSupplier orderFromSupplier, int quantity, bool is_new) { this.productInOrder = productInOrder; // הכלה this.orderFromSupplier = orderFromSupplier; //הכלה this.quantity = quantity; this.orderFromSupplier.addProductInOrder(this); this.productInOrder.addSupplierOrdersOfThisProduct(this); if (is_new) { this.createProductsInOrder(); } }
public static void quantityUpdateOfProductInOrder(OrderFromSupplier o, Product p, int newQuantity) { foreach (ProductInOrder pio in o.ProductsInThisOrder) { if ((pio.getOrderFromSupplier().getID() == o.getID()) && (pio.get_ProductInOrder().get_productID() == p.get_productID())) { pio.setQuantity(newQuantity); pio.updateProductsInOrder(); // ######################### to check if the procedure is right } } // prints the lists in this order and in this product to check if productInOrder changed o.PrintAll(); p.printAllSupplierOrdersOfThisProduct(); }
// initalizing orders from sql public static void init_ordersFromSupplier()//מילוי המערך מתוך בסיס הנתונים { SqlCommand c = new SqlCommand(); c.CommandText = "EXECUTE dbo.Get_All_Orders_From_Supplier"; SQL_CON SC = new SQL_CON(); SqlDataReader rdr = SC.execute_query(c); ordersFromSuppliers = new List <OrderFromSupplier>(); while (rdr.Read()) { PaymentMethod pm = (PaymentMethod)Enum.Parse(typeof(PaymentMethod), rdr.GetValue(4).ToString()); OrderStatus os = (OrderStatus)Enum.Parse(typeof(OrderStatus), rdr.GetValue(5).ToString()); OrderFromSupplier ofs = new OrderFromSupplier(int.Parse(rdr.GetValue(0).ToString()), DateTime.Parse(rdr.GetValue(1).ToString()), DateTime.Parse(rdr.GetValue(2).ToString()), double.Parse(rdr.GetValue(3).ToString()), pm, os, seekEmployee(int.Parse(rdr.GetValue(6).ToString())), seekSupplier(int.Parse(rdr.GetValue(7).ToString())), rdr.GetValue(8).ToString(), false); ordersFromSuppliers.Add(ofs); } }
public static void deleteProductInOrder(OrderFromSupplier o, Product p) { ProductInOrder pioToRemove = null; foreach (ProductInOrder pio in o.ProductsInThisOrder) { if ((pio.getOrderFromSupplier().getID() == o.getID()) && (pio.get_ProductInOrder().get_productID() == p.get_productID())) { pioToRemove = pio; } } o.ProductsInThisOrder.Remove(pioToRemove); p.SupplierOrdersOfThisProduct.Remove(pioToRemove); pioToRemove.DeleteProductInOrder(); // prints the lists in this order and in this product to check if deleted them o.PrintAll(); Console.WriteLine("\n"); p.printAllSupplierOrdersOfThisProduct(); }
private void ShowDetails_Click(object sender, EventArgs e) { dataGridView2.Rows.Clear(); dataGridView2.Refresh(); if (dataGridView1.SelectedCells.Count > 0) { int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex; Console.WriteLine("row" + selectedrowindex); OrderFromSupplier OFS = Program.seekOrder_From_Supplier(Convert.ToInt32(dataGridView1.Rows[selectedrowindex].Cells[0].Value)); this.ol = OFS; foreach (ProductInOrder PIO in OFS.ProductsInThisOrder) { dataGridView2.Rows.Add(PIO.get_ProductInOrder().get_productID(), PIO.get_ProductInOrder().get_productName(), PIO.getQuantity(), (PIO.get_ProductInOrder().getSupplierPrice() * PIO.get_ProductInOrder().get_productQuantity())); } } dataGridView2.Visible = true; button3.Visible = true; Quantitybutton.Visible = true; NewQuantity.Visible = true; }