Пример #1
0
        private void LoadCombos()
        {
            List <SelectListItem> seekTypes = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Value = "NAME", Text = "Name"
                },
                new SelectListItem()
                {
                    Value = "CODE", Text = "Code"
                },
                new SelectListItem()
                {
                    Value = "BARCODE", Text = "Barcode"
                }
            };

            ViewData["SeekType"] = new SelectList(seekTypes, "Value", "Text");
            var docTypes = Enum.GetValues(typeof(RecurringDocTypeEnum))
                           .Cast <RecurringDocTypeEnum>()
                           .Select(c => new SelectListItem()
            {
                Value = c.ToString(),
                Text  = c.GetDescription()
            }).ToList();

            ViewData["DocType"]            = new SelectList(docTypes, "Value", "Text");
            ViewData["RecurringFrequency"] = FiltersHelper.GetRecurringFrequencyList();
            ViewData["CompanyId"]          = new SelectList(_context.Companies.OrderBy(p => p.Code).AsNoTracking(), "Id", "Code");
            ViewData["PaymentMethodId"]    = new SelectList(_context.PaymentMethods.OrderBy(p => p.Name).AsNoTracking(), "Id", "Name");
            IQueryable transactorList;
            IQueryable docTypeList;

            if (CreateFromType == RecurringDocTypeEnum.BuyType)
            {
                transactorList = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.SUPPLIER").OrderBy(s => s.Name).AsNoTracking();
                docTypeList    = _context.BuyDocSeriesDefs.OrderBy(p => p.Name).AsNoTracking();
            }
            else
            {
                transactorList = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.CUSTOMER" || s.TransactorType.Code == "SYS.DEPARTMENT").OrderBy(s => s.Name).AsNoTracking();
                docTypeList    = _context.SellDocSeriesDefs.OrderBy(p => p.Name).AsNoTracking();
            }

            ViewData["TransactorId"] = new SelectList(transactorList, "Id", "Name");
            ViewData["DocSeriesId"]  = new SelectList(docTypeList, "Id", "Name");
        }
Пример #2
0
        private void LoadCombos()
        {
            List <SelectListItem> seekTypes = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Value = "NAME", Text = "Name"
                },
                new SelectListItem()
                {
                    Value = "CODE", Text = "Code"
                },
                new SelectListItem()
                {
                    Value = "BARCODE", Text = "Barcode"
                }
            };

            ViewData["SeekType"] = new SelectList(seekTypes, "Value", "Text");
            var docTypes = Enum.GetValues(typeof(RecurringDocTypeEnum))
                           .Cast <RecurringDocTypeEnum>()
                           .Select(c => new SelectListItem()
            {
                Value = c.ToString(),
                Text  = c.GetDescription()
            }).ToList();

            ViewData["DocType"]            = new SelectList(docTypes, "Value", "Text");
            ViewData["RecurringFrequency"] = FiltersHelper.GetRecurringFrequencyList();
            ViewData["CompanyId"]          = new SelectList(_context.Companies.OrderBy(p => p.Code).AsNoTracking(), "Id", "Code");
            ViewData["PaymentMethodId"]    = new SelectList(_context.PaymentMethods.OrderBy(p => p.Name).AsNoTracking(), "Id", "Name");
            IQueryable transactorList;
            IQueryable docTypeList;

            switch (ItemVm.RecurringDocType)
            {
            case RecurringDocTypeEnum.BuyType:
                transactorList           = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.SUPPLIER").OrderBy(s => s.Name).AsNoTracking();
                docTypeList              = _context.BuyDocSeriesDefs.OrderBy(p => p.Name).AsNoTracking();
                ViewData["TransactorId"] = new SelectList(transactorList, "Id", "Name");
                ViewData["DocSeriesId"]  = new SelectList(docTypeList, "Id", "Name");
                break;

            case RecurringDocTypeEnum.SellType:
                transactorList           = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.CUSTOMER" || s.TransactorType.Code == "SYS.DEPARTMENT").OrderBy(s => s.Name).AsNoTracking();
                docTypeList              = _context.SellDocSeriesDefs.OrderBy(p => p.Name).AsNoTracking();
                ViewData["TransactorId"] = new SelectList(transactorList, "Id", "Name");
                ViewData["DocSeriesId"]  = new SelectList(docTypeList, "Id", "Name");
                break;

            default:
                break;
            }


            var buyDocSeriesListJs = _context.BuyDocSeriesDefs.OrderBy(p => p.Name)
                                     .Select(p => new SelectListItem()
            {
                Text  = p.Name,
                Value = p.Id.ToString()
            }).ToList();
            var sellDocSeriesListJs = _context.SellDocSeriesDefs.OrderBy(p => p.Name)
                                      .Select(p => new SelectListItem()
            {
                Text  = p.Name,
                Value = p.Id.ToString()
            }).ToList();
            var supplierListJs = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.SUPPLIER").OrderBy(s => s.Name)
                                 .Select(p => new SelectListItem()
            {
                Text  = p.Name,
                Value = p.Id.ToString()
            }).ToList();
            var customerListJs = _context.Transactors.Where(s => s.TransactorType.Code == "SYS.CUSTOMER" || s.TransactorType.Code == "SYS.DEPARTMENT").OrderBy(s => s.Name)
                                 .Select(p => new SelectListItem()
            {
                Text  = p.Name,
                Value = p.Id.ToString()
            }).ToList();

            ViewData["BuyDocSeriesListJs"]  = buyDocSeriesListJs;
            ViewData["SellDocSeriesListJs"] = sellDocSeriesListJs;
            ViewData["SupplierListJs"]      = supplierListJs;
            ViewData["CustomerListJs"]      = customerListJs;
        }