//********************************* CUSTOMERS ***********************************************//
        public static IEnumerable<SelectListItem> GetCustomerDropDownList()
        {
            var db = new IstokDoorsDBContext();

            var customerList = db.Customers.ToList();
            var dropDownCustomerList = new List<SelectListItem>();

            foreach (var customer in customerList)
            {
                var customerId = customer.CustomerId;
                string customerName = customer.CompanyName;

                if (String.IsNullOrEmpty(customerName))
                {
                    customerName = string.Format("{0} {1}", customer.ContactFirstName, customer.ContactLastName);
                }

                dropDownCustomerList.Add(new SelectListItem
                {
                    Text = customerName,
                    Value = customerId.ToString(CultureInfo.InvariantCulture)
                });
            }

            return dropDownCustomerList;
        }
        public static void SendSmsToAllInvolved(int orderId, string action)
        {
            IstokDoorsDBContext db = new IstokDoorsDBContext();

            var employeesToInform = db.Employees.Where(i => i.IsSmsInformed == true).ToList();

            string messageText;

            if (action == "ship")
            {
                messageText = " Заказ " + orderId + " oтправлен! Проверьте Журнал Учёта Складских Запасов для дополнительной информации.";
            }
            else
            {
                messageText = " Заказ " + orderId + " oтменён! Проверьте Журнал Учёта Складских Запасов для дополнительной информации.";
            }

            var twilio = new TwilioRestClient(TwilioSender.AccountSid, TwilioSender.AuthToken);

            if (employeesToInform != null)
            {
                foreach (var employee in employeesToInform)
                {
                    var message = twilio.SendMessage(TwilioSender.PhoneNumber, employee.PhoneNumber1, messageText, "");
                }

            }
        }
        public static void AddOrderItems(OrderHeader orderHeader, int lastOrderId)
        {
            IstokDoorsDBContext db = new IstokDoorsDBContext();

            foreach (var item in orderHeader.OrderItems)
            {
                db.usp_CreateOrderItem(lastOrderId, item.DoorId, item.Quantity, item.Discount);

            }

            db.SaveChanges();
        }
        public static void EditOrderHeaderData(OrderHeader orderHeader)
        {
            IstokDoorsDBContext db = new IstokDoorsDBContext();

            var dbOrderHeader = db.OrderHeaders.Find(orderHeader.OrderId);

            dbOrderHeader.Memo = orderHeader.Memo;
            dbOrderHeader.PaymentTermId = orderHeader.PaymentTermId;
            dbOrderHeader.IsPaid = orderHeader.IsPaid;
            dbOrderHeader.PaymentReferece = orderHeader.PaymentReferece;

            db.SaveChanges();
        }
        public static void AddOrderHeaderData(OrderHeader orderHeader)
        {
            IstokDoorsDBContext db = new IstokDoorsDBContext();

            OrderHeader myOrderHeader = new OrderHeader();

            myOrderHeader.PaymentTermId = orderHeader.PaymentTermId;
            myOrderHeader.CustomerId = orderHeader.CustomerId;
            myOrderHeader.Memo = orderHeader.Memo;

            db.OrderHeaders.Add(myOrderHeader);
            db.SaveChanges();
        }
        //***********************       FACTORIES ********************************//
        public static IEnumerable<SelectListItem> GetDropDownListFactories()
        {
            var db = new IstokDoorsDBContext();

            var facotries = db.Factories.ToList();

            var dropDownListFactories = (from t in facotries
                let factroyId = t.FactoryId
                let doorData = t.FactoryName
                select new SelectListItem
                {
                    Text = doorData,
                    Value = factroyId.ToString(CultureInfo.InvariantCulture),
                }).ToList().OrderBy(x => x.Text);

            return dropDownListFactories;
        }
        //**************************************** DOORS ************************************************//
        public static IEnumerable<SelectListItem> GetDoorDropDownList()
        {
            //var doorsDropDownList = new List<SelectListItem>();
            var db = new IstokDoorsDBContext();
            var doors = db.Doors.ToList();
            var doorsDropDownList = (from t in doors
                let doorId = t.DoorId
                let doorData = string.Format("{0} {1} {2}", t.Model, t.CanvasSize, t.Color)

               select new SelectListItem
                {
                    Text = doorData,
                    Value = doorId.ToString(CultureInfo.InvariantCulture),
                }).ToList().OrderBy(x=>x.Text);

            return doorsDropDownList;
        }
        //*********************** VALUES FOR PRODUCTION JOURNAL'S "IS MANUFACTURED" DDL
        public static void GetValuesForPrdJrnlIsManufacturedDDL(IEnumerable<ProductionJournal> orders)
        {
            var db = new IstokDoorsDBContext();

            foreach (var item in orders)
            {
                var dropDownListItems = new List<SelectListItem>();
                for (int i = item.IsManufacturedForBatch; i < item.ToBeManufacturedForBatch + 1; i++)
                {
                    dropDownListItems.Add(new SelectListItem
                    {
                        Text = i.ToString(CultureInfo.InvariantCulture),
                        Value = i.ToString(CultureInfo.InvariantCulture),
                    });
                }

                var selectedItem = dropDownListItems.First(x => x.Value == item.IsManufacturedForBatch.ToString());
                selectedItem.Selected = true;

                item.DropDownListItems = dropDownListItems;

            }

            db.SaveChanges();
        }
        //*********************** VALUES FOR PLANNING JOURNAL'S "ALLOCATE FROM INVENTORY" DDL ************//
        public static void GetValuesForPlnJrnlLAllocateFromInvtrDDL(IEnumerable<PlanningJournal> orders)
        {
            var db = new IstokDoorsDBContext();

            foreach (var item in orders)
            {
                var dropDownListItems = new List<SelectListItem>();
                for (int i = 0; i < item.AllocValueForDDList + 1; i++)
                {
                    dropDownListItems.Add(new SelectListItem
                    {
                        Text = i.ToString(CultureInfo.InvariantCulture),
                        Value = i.ToString(CultureInfo.InvariantCulture),
                    });
                }

                var selectedItem = dropDownListItems.First(x => x.Value == item.AllocateFromInventory.ToString());
                selectedItem.Selected = true;

                item.DropDownListItems = dropDownListItems;
            }

            db.SaveChanges();
        }
Esempio n. 10
0
        //************************************* PAYMENT TERMS ********************************************//
        public static IEnumerable<SelectListItem> GetPaymentTermsDropDownList()
        {
            var db = new IstokDoorsDBContext();

            var paymentTermsList = db.PaymentTerms.ToList();

            var dropDownPaymentTermList = new List<SelectListItem>();

            foreach (var paymentTerm in paymentTermsList)
            {
                var paymentTermId = paymentTerm.PaymentTermId;
                var paymentTermName = paymentTerm.PaymentTermName;

                dropDownPaymentTermList.Add(new SelectListItem
                {
                    Text = paymentTermName,
                    Value = paymentTermId.ToString(CultureInfo.InvariantCulture)
                });

            }

            return dropDownPaymentTermList;
        }