Пример #1
0
 void RefresOrder(Order_Del newOrder, Order_Del oldOrder)
 {
     if (!oldOrder.Bouquet_ID.Equals(newOrder.Bouquet_ID))
     {
         oldOrder.Bouquet_ID = newOrder.Bouquet_ID;
     }
     if (!oldOrder.Date_Delived.Equals(newOrder.Date_Delived))
     {
         oldOrder.Date_Delived = newOrder.Date_Delived;
     }
 }
Пример #2
0
        void Equals(string zipOrdera, Order_Del orderDel, string[] zipForDriver, string ComboDriver)
        {
            foreach (var dr1 in zipForDriver)
            {
                if (dr1.Equals(zipOrdera))
                {
                    orderDel.Driver_ID    = Convert.ToInt32(ComboDriver);
                    orderDel.Order_Status = "InTransite";

                    break;
                }
            }
            try { db.SaveChanges(); } catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #3
0
        public bool SaveOrder(CallCenter model)
        {
            bool result = false;
            //create address

            Address address = new Address()
            {
                Address_City              = model.Address_City,
                Address_ZIPCODE           = model.Address_ZIPCODE,
                Address_Numder_Appartment = model.Address_Numder_Appartment,
                Address_Country           = model.Address_Country,
                Address_line1             = model.Address_line1,
                Address_line2             = model.Address_line2,
                Address_Name_Street       = model.Address_Name_Street,
                Address_Number_Street     = model.Address_Number_Street,
                Address_State             = model.Address_State,
            };

            db.Addresses.Add(address);
            //create customer
            Cust2 cust2 = new Cust2()
            {
                Lname   = model.Client.Lname,
                Fname   = model.Client.Fname,
                Address = address,
                Email   = model.Client.Email,
                Phone   = model.Client.Phone,
                Gender  = model.Gender
            };

            db.Cust2.Add(cust2);

            //create order
            int id = 0;

            int.TryParse(model.ComboBouqets, out id);
            int quantities = 0;

            int.TryParse(model.ComboQuantities, out quantities);
            decimal summ = 0;

            decimal.TryParse(model.Sum, out summ);

            Order_Del order = new Order_Del()
            {
                Bouquet_ID       = id,
                Florist_ID       = 25,
                Cust2            = cust2,
                Driver_ID        = 1000,
                Order_Date       = DateTime.Today,
                Bouquet_Quontity = quantities,
                Date_Delived     = DateDelivery,
                Total_Price      = summ,
                Size_Bouquets    = model.ComboSizes,
                Order_Status     = "Payed"
            };

            db.Order_Del.Add(order);
            try
            {
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(result);
            }
        }
Пример #4
0
        /// <summary>
        /// Редактирование старой заявки
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool EditOldOrder(CallCenter model)
        {
            bool result = false;
            //
            var oldOrderFromDB = db.Order_Del.FirstOrDefault(d => d.Order_ID == model.Order_ID);
            var oldAddress     = oldOrderFromDB.Cust2.Address;
            var oldCustomer    = oldOrderFromDB.Cust2;

            Address address = new Address()
            {
                Address_City              = model.Address_City,
                Address_ZIPCODE           = model.Address_ZIPCODE,
                Address_Numder_Appartment = model.Address_Numder_Appartment,
                Address_Country           = model.Address_Country,
                Address_line1             = model.Address_line1,
                Address_line2             = model.Address_line2,
                Address_Name_Street       = model.Address_Name_Street,
                Address_Number_Street     = model.Address_Number_Street,
                Address_State             = model.Address_State,
            };

            RefreshAddress(address, oldAddress);
            //create customer
            Cust2 cust2 = new Cust2()
            {
                Lname  = model.Client.Lname,
                Fname  = model.Client.Fname,
                Email  = model.Client.Email,
                Phone  = model.Client.Phone,
                Gender = model.Gender
            };

            RefreshCustomer(cust2, oldCustomer);
            //create order
            int id = 0;

            int.TryParse(model.ComboBouqets, out id);
            int quantities = 0;

            int.TryParse(model.ComboQuantities, out quantities);
            decimal summ = 0;

            decimal.TryParse(model.Sum, out summ);

            Order_Del order = new Order_Del()
            {
                Bouquet_ID       = id,
                Bouquet_Quontity = quantities,
                Date_Delived     = DateDelivery,
                Total_Price      = summ,
                Size_Bouquets    = model.ComboSizes,
            };

            RefresOrder(order, oldOrderFromDB);

            try
            {
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(result);
            }
        }