示例#1
0
        public ORDERS cancelOrders(int orderNumber)
        {
            ORDERS orders = ORDERS_DB.GetORDERS(orderNumber);

            orders.Fk_Id_Order_Status = 9;

            DELIVERY_DB dm       = new DELIVERY_DB(Configuration);
            DELIVERY    delivery = dm.GetDELIVERY(orders.Fk_Id_Delivery);

            delivery.Fk_Id_Delivery_Status = 9;
            dm.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery);

            return(ORDERS_DB.UpdateORDERS_Fk_Id_Order_Status(orders));
        }
示例#2
0
        public ORDERS cancelOrders(string [] stab)
        {
            ORDERS orders = ORDERS_DB.GetORDERS(stab);

            orders.Fk_Id_Order_Status = 16;

            DELIVERY_DB dm       = new DELIVERY_DB(Configuration);
            DELIVERY    delivery = dm.GetDELIVERY(orders.Fk_Id_Delivery);

            delivery.Fk_Id_Delivery_Status = 16;
            dm.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery);

            return(ORDERS_DB.UpdateORDERS_Fk_Id_Order_Status(orders));
        }
示例#3
0
        public DELIVERY archiveDelivery(int deliveryNumber)
        {
            DELIVERY delivery = DELIVERY_DB.GetDELIVERY(deliveryNumber);

            DELIVERY_DB.UpdateDELIVERY_Finish_Time(delivery);

            delivery.Fk_Id_Delivery_Status = 15;
            ORDERS_DB om     = new ORDERS_DB(Configuration);
            ORDERS    orders = om.GetORDERS(DELIVERY_DB.GetORDERSid(deliveryNumber));

            orders.Fk_Id_Order_Status = 7;

            om.UpdateORDERS_Fk_Id_Order_Status(orders);

            return(DELIVERY_DB.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery));
        }
示例#4
0
        public ORDERS addNewBills(int orderNumber)
        {
            BILLS_Manager bm     = new BILLS_Manager(Configuration);
            ORDERS        orders = ORDERS_DB.GetORDERS(orderNumber);

            orders.Fk_Id_Bills        = bm.createNewBills(orderNumber);
            orders.Fk_Id_Order_Status = 2;

            DELIVERY_DB dm       = new DELIVERY_DB(Configuration);
            DELIVERY    delivery = dm.GetDELIVERY(orders.Fk_Id_Delivery);

            delivery.Fk_Id_Delivery_Status = 2;
            dm.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery);
            ORDERS_DB.UpdateORDERS_Fk_Id_Bills(orders);
            return(ORDERS_DB.UpdateORDERS_Fk_Id_Order_Status(orders));
        }
        public int createNewBills(int orderNumber)
        {
            ORDERS_DISHES_DB odm = new ORDERS_DISHES_DB(Configuration);
            ORDERS_DB        om  = new ORDERS_DB(Configuration);

            SERVICE_CLASS_DB scm = new SERVICE_CLASS_DB(Configuration);
            DELIVERY_DB      dm  = new DELIVERY_DB(Configuration);

            ORDERS orders = om.GetORDERS(orderNumber);

            BILLS bills = new BILLS();

            bills.Amount = odm.GetAmount(orders) + scm.GetAmount(dm.GetDELIVERY(orders.Fk_Id_Delivery));
            bills        = BILLS_DB.AddBILLS(bills);
            return(bills.Id);
        }
示例#6
0
        public ORDERS confirmOrders(int orderNumber)
        {
            ORDERS orders = ORDERS_DB.GetORDERS(orderNumber);

            orders.Fk_Id_Order_Status = 4;

            BILLS_DB bm    = new BILLS_DB(Configuration);
            BILLS    bills = bm.GetBILLS(orders.Fk_Id_Bills);

            bm.UpdateBILLS_Payment_Date(bills);

            DELIVERY_DB dm       = new DELIVERY_DB(Configuration);
            DELIVERY    delivery = dm.GetDELIVERY(orders.Fk_Id_Delivery);

            delivery.Fk_Id_Delivery_Status = 4;
            dm.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery);

            return(ORDERS_DB.UpdateORDERS_Fk_Id_Order_Status(orders));
        }
示例#7
0
        public double GetAmount(ORDERS orders)
        {
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string query = "SELECT SUM(Quantity*Price) AS PRICE " +
                                   "FROM ORDERS_DISHES od, DISHES d " +
                                   "WHERE od.Fk_Id_Dishes = d.Id " +
                                   "AND od.Fk_Id_Orders = @orderNumber; ";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@orderNumber", orders.Id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            if (dr["PRICE"] != DBNull.Value)
                            {
                                return((double)dr["PRICE"]);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(0.0);
        }
示例#8
0
        public ORDERS GetORDERS(int Id)
        {
            ORDERS orders           = null;
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM ORDERS WHERE Id = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", Id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            orders = new ORDERS();

                            if (dr["Id"] != DBNull.Value)
                            {
                                orders.Id = (int)dr["Id"];
                            }

                            if (dr["Created_At"] != DBNull.Value)
                            {
                                orders.Created_At = (DateTime)dr["Created_At"];
                            }

                            if (dr["Fk_Id_Bills"] != DBNull.Value)
                            {
                                orders.Fk_Id_Bills = (int)dr["Fk_Id_Bills"];
                            }

                            if (dr["Fk_Id_Delivery"] != DBNull.Value)
                            {
                                orders.Fk_Id_Delivery = (int)dr["Fk_Id_Delivery"];
                            }

                            if (dr["Fk_Id_Customers"] != DBNull.Value)
                            {
                                orders.Fk_Id_Customers = (int)dr["Fk_Id_Customers"];
                            }

                            if (dr["Fk_Id_Order_Status"] != DBNull.Value)
                            {
                                orders.Fk_Id_Order_Status = (int)dr["Fk_Id_Order_Status"];
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orders);
        }
示例#9
0
        public List <ORDERS> GetORDERSForCustomer(int customerNumber)
        {
            List <ORDERS> orders           = null;
            string        connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT ORDERS.Id, ORDERS.Created_At, Fk_Id_Bills, Fk_Id_Delivery, ORDERS.Fk_Id_Customers, Fk_Id_Order_Status FROM ORDERS, DELIVERY WHERE Fk_Id_Delivery = DELIVERY.Id AND Fk_Id_Customers = @Fk_Id_Customers AND Fk_Id_Order_Status = 4 AND Fk_Id_Delivery_Time > (SELECT MIN(Id) FROM DELIVERY_TIME WHERE DATEDIFF(minute, CAST( CONVERT(TIME(7),GETDATE()) as datetime ), CAST( Time_Zone as datetime )) > 179);";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@Fk_Id_Customers", customerNumber);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (orders == null)
                            {
                                orders = new List <ORDERS>();
                            }

                            ORDERS order = new ORDERS();

                            if (dr["Id"] != DBNull.Value)
                            {
                                order.Id = (int)dr["Id"];
                            }

                            if (dr["Created_At"] != DBNull.Value)
                            {
                                order.Created_At = (DateTime)dr["Created_At"];
                            }

                            if (dr["Fk_Id_Bills"] != DBNull.Value)
                            {
                                order.Fk_Id_Bills = (int)dr["Fk_Id_Bills"];
                            }

                            if (dr["Fk_Id_Delivery"] != DBNull.Value)
                            {
                                order.Fk_Id_Delivery = (int)dr["Fk_Id_Delivery"];
                            }

                            if (dr["Fk_Id_Customers"] != DBNull.Value)
                            {
                                order.Fk_Id_Customers = (int)dr["Fk_Id_Customers"];
                            }

                            if (dr["Fk_Id_Order_Status"] != DBNull.Value)
                            {
                                order.Fk_Id_Order_Status = (int)dr["Fk_Id_Order_Status"];
                            }

                            orders.Add(order);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orders);
        }
示例#10
0
        public ORDERS GetORDERS(string[] stab)
        {
            ORDERS orders           = null;
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string query = "SELECT o.Id, o.Created_At, o.Fk_Id_Bills, o.Fk_Id_Delivery, o.Fk_Id_Customers, o.Fk_Id_Order_Status " +
                                   "FROM ORDERS o, CUSTOMERS c " +
                                   "WHERE o.Fk_Id_Customers = c.Id " +
                                   "AND c.FirstName = @FirstName " +
                                   "AND c.LastName = @LastName " +
                                   "AND o.Id = @Id";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@Id", Convert.ToInt32(stab[0]));
                    cmd.Parameters.AddWithValue("@FirstName", stab[1]);
                    cmd.Parameters.AddWithValue("@LastName", stab[2]);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            orders = new ORDERS();

                            if (dr["Id"] != DBNull.Value)
                            {
                                orders.Id = (int)dr["Id"];
                            }

                            if (dr["Created_At"] != DBNull.Value)
                            {
                                orders.Created_At = (DateTime)dr["Created_At"];
                            }

                            if (dr["Fk_Id_Bills"] != DBNull.Value)
                            {
                                orders.Fk_Id_Bills = (int)dr["Fk_Id_Bills"];
                            }

                            if (dr["Fk_Id_Delivery"] != DBNull.Value)
                            {
                                orders.Fk_Id_Delivery = (int)dr["Fk_Id_Delivery"];
                            }

                            if (dr["Fk_Id_Customers"] != DBNull.Value)
                            {
                                orders.Fk_Id_Customers = (int)dr["Fk_Id_Customers"];
                            }

                            if (dr["Fk_Id_Order_Status"] != DBNull.Value)
                            {
                                orders.Fk_Id_Order_Status = (int)dr["Fk_Id_Order_Status"];
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orders);
        }