Esempio n. 1
0
        public IEnumerable <SelectListItem> GetGroupList()
        {
            IList <EfficiencyConfiguration> lstValues = new List <EfficiencyConfiguration>();

            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("IsUsed=1"),
                    OrderBy  = "Key.Group"
                };

                MethodReturnResult <IList <EfficiencyConfiguration> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstValues = result.Data;
                }
            }

            var lnq = (from item in lstValues
                       select item.Key.Group).Distinct();

            return(from item in lnq
                   select new SelectListItem()
            {
                Text = item,
                Value = item
            });
        }
Esempio n. 2
0
        public ActionResult GetCode(string q, string group, string lineCode, bool isChange)
        {
            string packageNo = string.Empty;

            //生成包装号。
            if (isChange)
            {
                string line = string.Empty;
                using (ProductionLineServiceClient client = new ProductionLineServiceClient())
                {
                    MethodReturnResult <ProductionLine> result = client.Get(lineCode);
                    if (result.Code <= 0)
                    {
                        line = result.Data.Attr1;
                    }
                }
                if (!string.IsNullOrEmpty(line))
                {
                    string prefix = string.Format("C{0:yyMMdd}{1}", DateTime.Now, line);
                    int    itemNo = 0;
                    using (PackageInfoServiceClient client = new PackageInfoServiceClient())
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = 0,
                            PageSize = 1,
                            Where    = string.Format("Key LIKE '{0}%'"
                                                     , prefix),
                            OrderBy = "Key Desc"
                        };
                        MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg);
                        if (result.Code <= 0 && result.Data.Count > 0)
                        {
                            string maxPackageNo = result.Data[0].Key.Replace(prefix, "");
                            int.TryParse(maxPackageNo, out itemNo);
                        }
                        itemNo++;
                    }
                    packageNo = prefix + itemNo.ToString("0000");
                }
            }
            //获取配置信息。
            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.Code LIKE '{0}%' AND Key.Group='{1}'"
                                             , q
                                             , group)
                };
                MethodReturnResult <IList <EfficiencyConfiguration> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    return(Json(from item in result.Data
                                select new
                    {
                        @label = item.Key.Code,
                        @value = item.Key.Code,
                        @Name = item.Name,
                        @Lower = item.Lower,
                        @Upper = item.Upper,
                        @Grade = item.Grade,
                        @Color = item.Color,
                        @PackageNo = packageNo,
                        @MaterialCode = item.MaterialCode ?? string.Empty
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <EfficiencyConfiguration> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial", new EfficiencyConfigurationViewModel()));
        }
Esempio n. 4
0
        public async Task <ActionResult> Query(EfficiencyConfigurationQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Group))
                            {
                                where.AppendFormat(" {0} Key.Group LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Group);
                            }
                            if (!string.IsNullOrEmpty(model.Code))
                            {
                                where.AppendFormat(" {0} Key.Code LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Code);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <EfficiencyConfiguration> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", new EfficiencyConfigurationViewModel()));
            }
            else
            {
                return(View("Index", model));
            }
        }