public static List <Order_Details_DATA> Select_ALL_Order_Details()
        {
            List <Order_Details_DATA> Order_Details = new List <Order_Details_DATA>();

            DataTable table = DBL.get_DATA("ORDERS_DETAIAS_select_All");

            foreach (DataRow item in table.Rows)
            {
                Order_Details_DATA Order_Detail = new Order_Details_DATA();
                Order_Detail.Id          = Convert.ToInt16(item["ID_ORDERS_DETAIAS"]);
                Order_Detail.Quantity    = Convert.ToInt16(item["QUANTITY"]);
                Order_Detail.Total_price = Convert.ToDouble(item["TOTAL_PRICE"]);
                Order_Detail.Total_price_after_discount = Convert.ToDouble(item["TOTAL_PRICE_with_discount"]);
                Order_Detail.Discount = Convert.ToDouble(item["DISCOUNT"]);
                Orders_DATA   order   = new Orders_DATA();
                Products_DATA product = new Products_DATA();
                Order_Detail.Order   = order;
                Order_Detail.Product = product;
                order.Id             = Convert.ToInt16(item["ID_ORDER"]);
                order = Orders_DAL.Select_Item_Orders(order.Id);
                Order_Detail.Order = order;

                product.Id = Convert.ToInt16(item["ID_PRODUCT"]);
                Order_Detail.Product.Id = product.Id;
                Order_Details.Add(Order_Detail);
            }

            return(Order_Details);
        }
        public static List <Order_Details_DATA> Select_ALL_Order_Details_By_Order_Id(int Order_Id)
        {
            List <Order_Details_DATA> Order_Details = new List <Order_Details_DATA>();
            Order_Details_DATA        Order_Detail  = new Order_Details_DATA();
            DataTable table = DBL.get_DATA("ORDERS_DETAIAS_select_All");

            foreach (DataRow item in table.Rows)
            {
                Order_Detail.Id       = Convert.ToInt16(item["ID_ORDERS_DETAIAS"]);
                Order_Detail.Quantity = Convert.ToInt16(item["QUANTITY"]);
                Orders_DATA Order = new Orders_DATA();


                Order.Id = Convert.ToInt16(item["ID_ORDER"]);

                Products_DATA Product = new Products_DATA();
                Product.Id = Convert.ToInt16(item["ID_PRODUCT"]);

                Order_Detail.Order   = Order;
                Order_Detail.Product = Product;
                Order_Details.Add(Order_Detail);
            }
            Order_Details = Order_Details.Where(x => x.Order.Id == Order_Id).ToList();
            return(Order_Details);
        }
        public static void Delete_Orders(Orders_DATA Orders)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("ID_ORDER", Orders.Id));

            DBL.execute_query("ORDERS_delete", parameters);
        }
        public static void Insert_Orders(Orders_DATA Orders)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("DATE_ORDERS", Orders.Order_date));


            parameters.Add(new SqlParameter("ID_CUSTOMER", Orders.Customer.ID));
            parameters.Add(new SqlParameter("ID_User", Orders.User_id));
            parameters.Add(new SqlParameter("Total_paied", Orders.Total_paied));
            DBL.execute_query("ORDERS_insert", parameters);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            Orders_DATA order = new Orders_DATA();

            order.User_id    = user_name.Id;
            order.Order_date = Convert.ToDateTime(dateTimePicker1.Text);
            Customer_DATA customer = new Customer_DATA();

            customer.ID       = Convert.ToInt16(id.Text);
            order.Customer    = customer;
            order.Total_paied = Convert.ToDouble(total_value.Text);
            Orders_BLL.Insert_Orders(order);

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                Products_DATA product = new Products_DATA();
                product.Id = Convert.ToInt16(row.Cells[0].Value);
                Orders_DATA orders = new Orders_DATA();
                orders = Orders_BLL.Select_ALL_Orders().Last();
                Order_Details_DATA order_details = new Order_Details_DATA();
                order_details.Quantity    = Convert.ToInt16(row.Cells[3].Value);
                order_details.Total_price = Convert.ToDouble(row.Cells[4].Value);
                order_details.Discount    = Convert.ToDouble(row.Cells[5].Value);
                order_details.Total_price_after_discount = Convert.ToDouble(row.Cells[6].Value);
                order_details.Order   = orders;
                order_details.Product = product;
                Order_Details_BLL.Insert_Order_Details(order_details);
            }


            id.Text                  = "";
            name.Text                = "";
            lastname.Text            = "";
            phone.Text               = "";
            email.Text               = "";
            textBox2.Text            = "";
            product_id.Text          = "";
            product_name.Text        = "";
            product_price.Text       = "";
            product_quantety.Text    = "";
            product_total_price.Text = "";
            product_discount.Text    = "";
            product_total.Text       = "";
            total_value.Text         = "";
            pictureBox1.Image        = null;
            button2.Enabled          = true;
            button3.Enabled          = false;
            table.Clear();
            dataGridView1.DataSource = table;
        }
        public static List <Orders_DATA> Select_ALL_Orders_By_Categories_Id(int Categories_Id)
        {
            List <Orders_DATA> Orders = new List <Orders_DATA>();
            Orders_DATA        Order  = new Orders_DATA();
            DataTable          table  = DBL.get_DATA("ORDERS_select_All");

            foreach (DataRow item in table.Rows)
            {
                Order.Id          = Convert.ToInt16(item["ID_ORDER"]);
                Order.Order_date  = (DateTime)item["DATE_ORDERS"];
                Order.Customer.ID = Convert.ToInt16(item["ID_CUSTOMER"]);
                Order.Total_paied = Convert.ToDouble(item["Total_paied"]);
                Orders.Add(Order);
            }

            return(Orders);
        }
        public static Orders_DATA Select_Item_Orders(int Id)
        {
            Orders_DATA         Orders     = new Orders_DATA();
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("ID_ORDER", Id));

            Orders.Id         = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[0]);
            Orders.Order_date = (DateTime)DBL.get_DATA_row("ORDERS_select", parameters)[1];
            Customer_DATA customer = new Customer_DATA();

            customer.ID = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[2]);

            Orders.Customer    = customer;
            Orders.User_id     = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[3]);
            Orders.Total_paied = Convert.ToDouble(DBL.get_DATA_row("ORDERS_select", parameters)[4]);
            Orders.Customer    = new Customer_DATA();
            return(Orders);
        }
        public static void Insert_Order_Details(Order_Details_DATA Order_Details)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("QUANTITY", Order_Details.Quantity));
            Orders_DATA oreder = new Orders_DATA();

            parameters.Add(new SqlParameter("ID_ORDER", Order_Details.Order.Id));

            parameters.Add(new SqlParameter("ID_PRODUCT", Order_Details.Product.Id));
            parameters.Add(new SqlParameter("PRICE", Order_Details.Product.Price));
            parameters.Add(new SqlParameter("DISCOUNT", Order_Details.Discount));
            parameters.Add(new SqlParameter("TOTAL_PRICE", Order_Details.Total_price));
            parameters.Add(new SqlParameter("TOTAL_PRICE_with_discount", Order_Details.Total_price_after_discount));



            DBL.execute_query("ORDERS_DETAIAS_insert", parameters);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bill_2      bill  = new bill_2();
            Orders_DATA Order = new Orders_DATA();

            Order.Id = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[0].Value);
            //Order.Order_date = DateTime.ParseExact(dataGridView1.SelectedRows[0].Cells[1].Value.ToString(), "dd/MM/yyyy", null);
            Customer_DATA Customer = new Customer_DATA();

            Customer.ID = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[2].Value);

            Customer.First_Name = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();

            Customer.Last_Name = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
            Order.User_id      = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[5].Value);
            Order.Total_paied  = Convert.ToDouble(dataGridView1.SelectedRows[0].Cells[6].Value);

            bill.Order          = Order;
            bill.Order.Customer = Customer;

            bill.Show();
        }
Exemple #10
0
 public static void Delete_Orders(Orders_DATA Orders)
 {
     Orders_DAL.Delete_Orders(Orders);
 }
Exemple #11
0
 public static void Upaate_Orders(Orders_DATA Orders)
 {
     Orders_DAL.Upaate_Orders(Orders);
 }
Exemple #12
0
 public static void Insert_Orders(Orders_DATA Orders)
 {
     Orders_DAL.Insert_Orders(Orders);
 }
Exemple #13
0
 public static Orders_DATA Select_Item_Categories(Orders_DATA Orders)
 {
     return(Orders_DAL.Select_Item_Orders(Orders.Id));
 }