public DELIVERY updateServiceClass(int deliveryNumber, int serviceClassId) { DELIVERY delivery = DELIVERY_DB.GetDELIVERY(deliveryNumber); delivery.Fk_Id_Service_Class = serviceClassId; return(DELIVERY_DB.UpdateDELIVERY_Fk_Id_Service_Class(delivery)); }
public DELIVERY updateDeliveryTime(int deliveryNumber, int deliveryTimeId) { DELIVERY delivery = DELIVERY_DB.GetDELIVERY(deliveryNumber); delivery.Fk_Id_Delivery_Time = deliveryTimeId; return(DELIVERY_DB.UpdateDELIVERY_Fk_Id_Delivery_Time(delivery)); }
public DELIVERY assignCourier(int deliveryNumber, int restaurantNumber) { DELIVERY_COURIER_Manager dcm = new DELIVERY_COURIER_Manager(Configuration); DELIVERY delivery = DELIVERY_DB.GetDELIVERY(deliveryNumber); DELIVERY_DB.UpdateDELIVERY_Start_Time(delivery); delivery.Fk_Id_Delivery_Courier = dcm.getAvailableCourier(restaurantNumber, deliveryNumber); return(DELIVERY_DB.UpdateDELIVERY_Fk_Id_Delivery_Courier(delivery)); }
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)); }
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)); }
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)); }
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); }
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)); }
public List <DELIVERY> displayDelivery(int courierNumber) { return(DELIVERY_DB.GetDELIVERYforCourier(courierNumber)); }
public int createNewDelivery() { return(DELIVERY_DB.AddDELIVERY()); }
public DELIVERY_Manager(IConfiguration configuration) { DELIVERY_DB = new DELIVERY_DB(configuration); Configuration = configuration; }
public DELIVERY_COURIER GetFreeDELIVERY_COURIER(int restaurantsId, int deliveryId) { int dtm1, delivery_time, dtp1, maxdt, citiesId; DELIVERY_DB ddb = new DELIVERY_DB(Config); delivery_time = ddb.GetDELIVERY(deliveryId).Fk_Id_Delivery_Time; DELIVERY_TIME_DB dtdb = new DELIVERY_TIME_DB(Config); maxdt = dtdb.GetMaximumDeliveryTimeId(); if (delivery_time == 0) { dtm1 = delivery_time; } else { dtm1 = delivery_time - 1; } if (delivery_time == maxdt) { dtp1 = delivery_time; } else { dtp1 = delivery_time + 1; } RESTAURANTS_DB rdb = new RESTAURANTS_DB(Config); citiesId = rdb.GetCITIES(restaurantsId); DELIVERY_COURIER delivery_courier = null; string connectionString = Config.GetConnectionString("DefaultConnection"); try { using (SqlConnection cn = new SqlConnection(connectionString)) { string query = "SELECT TOP (1) * " + "FROM DELIVERY_COURIER WHERE Fk_Id_Cities = @restaurantCitiesId " + "AND Id NOT IN(SELECT DELIVERY_COURIER.Id " + "FROM DELIVERY, DELIVERY_COURIER, STATUS " + "WHERE DELIVERY.Fk_Id_Delivery_Courier = DELIVERY_COURIER.Id " + "AND DELIVERY.Fk_Id_Delivery_Status = STATUS.Id " + "AND DELIVERY.Fk_Id_Delivery_Time IN(@dtidm1, @dtid, @dtidp1) " + "AND STATUS.Designation = 'Pending' " + "GROUP BY DELIVERY_COURIER.Id " + "HAVING COUNT(DELIVERY.Id) > 4);"; SqlCommand cmd = new SqlCommand(query, cn); cmd.Parameters.AddWithValue("@restaurantCitiesId", citiesId); cmd.Parameters.AddWithValue("@dtidm1", dtm1); cmd.Parameters.AddWithValue("@dtid", delivery_time); cmd.Parameters.AddWithValue("@dtidp1", dtp1); cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { delivery_courier = new DELIVERY_COURIER(); if (dr["Id"] != DBNull.Value) { delivery_courier.Id = (int)dr["Id"]; } if (dr["FirstName"] != DBNull.Value) { delivery_courier.FirstName = (string)dr["FirstName"]; } if (dr["LastName"] != DBNull.Value) { delivery_courier.LastName = (string)dr["LastName"]; } if (dr["Phone_Number"] != DBNull.Value) { delivery_courier.Phone_Number = (string)dr["Phone_Number"]; } if (dr["Address"] != DBNull.Value) { delivery_courier.Address = (string)dr["Address"]; } if (dr["Login"] != DBNull.Value) { delivery_courier.Login = (string)dr["Login"]; } if (dr["Password"] != DBNull.Value) { delivery_courier.Password = (string)dr["Password"]; } if (dr["Created_At"] != DBNull.Value) { delivery_courier.Created_At = (DateTime)dr["Created_At"]; } if (dr["Fk_Id_Cities"] != DBNull.Value) { delivery_courier.Fk_Id_Cities = (int)dr["Fk_Id_Cities"]; } } } } } catch (Exception e) { throw e; } return(delivery_courier); }