Ejemplo n.º 1
0
        // Create BarCode Service
        private BarCodeService CreateBarCodeService()
        {
            var userId  = User.Identity.GetUserId();
            var service = new BarCodeService(userId);

            return(service);
        }
Ejemplo n.º 2
0
        // Build BarCode Dropdown
        private IOrderedEnumerable <SelectListItem> BuildBarCodeDropdown(int selectedValue)
        {
            var userId         = User.Identity.GetUserId();
            var barCodeService = new BarCodeService(userId);

            var barCodeList       = new SelectList(barCodeService.GetBarCodes(), "BarCodeId", "BarCodeNumber", selectedValue);
            var sortedBarCodeList = barCodeList.OrderBy(o => o.Text);

            return(sortedBarCodeList);
        }
Ejemplo n.º 3
0
        // GET: Customer/Update
        public ActionResult Edit(bool isCust, bool isOrder, int id)
        {
            if (isAdminUser() || isAssociateUser() || (isCustomerUser() && isOrder))
            {
                var service = CreateCustomerService();
                var detail  = service.GetCustById(id);
                var model   =
                    new CustUpdate
                {
                    CustomerId = detail.CustomerId,
                    IsOrder    = isOrder,
                    IsCust     = isCust,
                    //BarCodeNumber = new BarCode(),
                    BarCodeId  = detail.BarCodeId,
                    FirstName  = detail.FirstName,
                    LastName   = detail.LastName,
                    Address    = detail.Address,
                    City       = detail.City,
                    State      = detail.State,
                    ZipCode    = detail.ZipCode,
                    Phone      = detail.Phone,
                    Email      = detail.Email,
                    NumberKids = detail.NumberKids
                };
                var userId         = User.Identity.GetUserId();
                var barCodeService = new BarCodeService(userId);

                // BarCodeId is null here if created by a Customer using Barcode Number of 0
                int barCodeIdParm = 0;
                if (detail.BarCodeId == null)
                {
                    barCodeIdParm       = 0;
                    model.BarCodeNumber = 0;
                }
                else
                {
                    barCodeIdParm = (int)model.BarCodeId;
                    var barCodeDetail = barCodeService.GetBarCodeById(barCodeIdParm);
                    model.BarCodeNumber = barCodeDetail.BarCodeNumber;
                }

                ViewBag.BarCodeId = BuildBarCodeDropdown(barCodeIdParm);

                return(View(model));
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 4
0
        // Get: Customer/Create
        public ActionResult Create(bool isOrder, int barCodeId)
        {
            if (isAdminUser() || isAssociateUser() || (isCustomerUser() && isOrder))
            {
                var userId         = User.Identity.GetUserId();
                var barCodeService = new BarCodeService(userId);

                BarCode barCodeData = new BarCode();
                if (barCodeId != 0)
                {
                    BarCodeDetail barCodeDetail = barCodeService.GetBarCodeById(barCodeId);
                    barCodeData.BarCodeId     = barCodeDetail.BarCodeId;
                    barCodeData.BarCodeNumber = barCodeDetail.BarCodeNumber;
                    // dummy data - don't need:
                    barCodeData.CreateAt = DateTimeOffset.Now;
                    barCodeData.CreateBy = "XX";
                }

                CustCreate model = new CustCreate
                {
                    CustomerId = 0,
                    IsOrder    = isOrder,
                    BarCodeId  = barCodeData.BarCodeId,
                    BarCode    = barCodeData,
                    FirstName  = null,
                    LastName   = null,
                    Address    = null,
                    City       = null,
                    State      = null,
                    ZipCode    = 0,
                    Phone      = null,
                    Email      = null,
                    NumberKids = 0
                };

                ViewBag.BarCodeId = BuildBarCodeDropdown(0);

                return(View(model));
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 5
0
        public ActionResult GetCustBarCode(OrderGetCustBarCode model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.BarCodeNumber > 0)
            {
                var userId         = User.Identity.GetUserId();
                var BarCodeService = new BarCodeService(userId);

                BarCodeDetail newBarCodeDetail = BarCodeService.GetBarCodeByBarCode(model.BarCodeNumber);
                if (newBarCodeDetail == null)
                {
                    ModelState.AddModelError("", $"'{model.BarCodeNumber}' is not a valid Bar Code Number.  Please re-enter or contact a member of the Food Pantry team.");

                    return(View(model));
                }
                ;

                // Verify/Update Customer
                var custService = new CustomerService(userId);

                CustDetail custDetail = custService.GetCustByBarCodeId(newBarCodeDetail.BarCodeId);
                if (custDetail.CustomerId == 0)
                {
                    ModelState.AddModelError("", $"'{model.BarCodeNumber}' is not assigned to a Customer.  Please re-enter or contact a member of the Food Pantry team.");

                    return(View(model));
                }
                return(RedirectToAction(actionName: "Edit", controllerName: "Customer", routeValues: new { isCust = model.IsCust, isOrder = true, id = custDetail.CustomerId }));
            }
            else
            {
                // Create Customer
                return(RedirectToAction(actionName: "Create", controllerName: "Customer", routeValues: new { isOrder = true, barCodeId = 0 }));
            }
        }
Ejemplo n.º 6
0
        private void StartWebService()
        {
            try
            {
                //myServiceObject = ContainerHelper.Container.Resolve<BarCodeService>();
                //host = new ServiceHost(myServiceObject);
                //host.Open();

                rservice = new BarCodeService();
                host     = new ServiceHost(rservice);
                if (host.State == CommunicationState.Opened)
                {
                    return;
                }
                host.Open();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }
Ejemplo n.º 7
0
        public ActionResult Index(int?PageIndex, long?customerID)
        {
            BarCodeModel vm = new BarCodeModel();

            vm.SearchCondition = new BarCodeSearchCondition();
            #region 订单类型
            IEnumerable <WMSConfig> wms = null;
            try
            {
                wms = ApplicationConfigHelper.GetWMS_Config("BarCodeType_" + base.UserInfo.ProjectName);
            }
            catch (Exception)
            {
            }

            if (wms == null)
            {
                wms = ApplicationConfigHelper.GetWMS_Config("BarCodeType");
            }
            List <SelectListItem> st = new List <SelectListItem>();
            foreach (WMSConfig w in wms)
            {
                st.Add(new SelectListItem()
                {
                    Value = w.Name, Text = w.Name
                });
            }
            vm.BarCodeType = st;
            #endregion
            #region 客户
            var CustomerListAll = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Where(t => t.StoreType == 2 || t.StoreType == 3);
            var CustomerListID  = CustomerListAll.Select(t => t.CustomerID);
            var CustomerList    = CustomerListAll.Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });
            ViewBag.CustomerList = CustomerList;
            if (base.UserInfo.UserType == 0)
            {
                vm.SearchCondition.CustomerID = base.UserInfo.CustomerOrShipperID;
            }
            else if (base.UserInfo.UserType == 2)
            {
                if (customerID.HasValue)
                {
                    vm.SearchCondition.CustomerID = customerID;
                }
                else
                {
                    var customerIDs = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Select(c => c.CustomerID);
                    if (customerIDs != null && customerIDs.Count() == 1)
                    {
                        vm.SearchCondition.CustomerID = customerIDs.First();
                    }
                }
            }
            #endregion
            #region 仓库
            IEnumerable <SelectListItem> WarehouseList = null;
            var WarehouseListAll = ApplicationConfigHelper.GetCacheInfo();
            if (vm.SearchCondition.CustomerID == null)
            {
                WarehouseList = WarehouseListAll.Where(c => c.UserID == base.UserInfo.ID && CustomerListID.Contains(c.CustomerID.Value)).Select(t => new { WarehouseID = t.WarehouseID, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseID.ToString(), Text = c.WarehouseName
                });
                StringBuilder sb = new StringBuilder();

                foreach (var i in CustomerListID)
                {
                    sb.Append("" + i + ",");
                }
                if (sb.Length > 1)
                {
                    vm.SearchCondition.CustomerIDs = sb.Remove(sb.Length - 1, 1).ToString();
                }
                else
                {
                    vm.SearchCondition.CustomerIDs = "0";
                }
            }
            else
            {
                WarehouseList = WarehouseListAll.Where(c => (c.CustomerID == vm.SearchCondition.CustomerID && c.UserID == base.UserInfo.ID)).Select(t => new { WarehouseID = t.WarehouseID, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseID.ToString(), Text = c.WarehouseName
                });
            }

            ViewBag.WarehouseList = WarehouseList;
            #endregion
            if (CustomerList.Count() == 1)
            {
                vm.SearchCondition.CustomerID = CustomerList.Select(c => c.Value).FirstOrDefault().ObjectToInt64();
            }
            if (WarehouseList.Count() == 1)
            {
                vm.SearchCondition.WarehouseID = WarehouseList.Select(c => c.Value).FirstOrDefault().ObjectToInt64();
            }


            vm.SearchCondition.StartCreateTime = DateTime.Parse(DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd"));
            vm.SearchCondition.EndCreateTime   = DateTime.Now;
            var response = new BarCodeService().QueryBarCodeList(new GetBarCodeByConditionRequest()
            {
                SearchCondition = null,
                PageIndex       = PageIndex ?? 0,
                PageSize        = UtilConstants.PAGESIZE,
            });
            if (response.IsSuccess)
            {
                vm.BarCodeCollection = response.Result.BarCodeCollection;
                vm.PageIndex         = response.Result.PageIndex;
                vm.PageCount         = response.Result.PageCount;
            }
            return(View(vm));
        }