Exemple #1
0
        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();
        }
Exemple #2
0
        public static void init_ProductsInOrder()//מילוי המערך מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.Get_All_Products_In_Supplier_Order";
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);

            productsInOrder = new List <ProductInOrder>();

            while (rdr.Read())
            {
                ProductInOrder pio = new ProductInOrder(seekProduct(rdr.GetValue(1).ToString()), seekOrder_From_Supplier(int.Parse(rdr.GetValue(0).ToString())), int.Parse(rdr.GetValue(2).ToString()), false);
                productsInOrder.Add(pio);
            }
        }
Exemple #3
0
        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();
        }
 public void addProductInOrder(ProductInOrder pio1)
 {
     this.ProductsInThisOrder.Add(pio1);
 }
Exemple #5
0
 public void addSupplierOrdersOfThisProduct(ProductInOrder pio1)
 {
     this.SupplierOrdersOfThisProduct.Add(pio1);
 }