예제 #1
0
        public async Task <ActionResult> Save(EfficiencyConfigurationViewModel model)
        {
            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                EfficiencyConfiguration obj = new EfficiencyConfiguration()
                {
                    Key = new EfficiencyConfigurationKey()
                    {
                        Code  = model.Code.ToUpper(),
                        Group = model.Group.ToUpper()
                    },
                    Code         = model.EffiCode,
                    Name         = model.EffiName,
                    Lower        = model.Lower,
                    Upper        = model.Upper,
                    Description  = model.Description,
                    Color        = model.Color,
                    Grade        = model.Grade,
                    MaterialCode = model.MaterialCode,
                    IsUsed       = model.IsUsed,
                    Editor       = User.Identity.Name,
                    EditTime     = DateTime.Now,
                    CreateTime   = DateTime.Now,
                    Creator      = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(ZPVCResources.StringResource.EfficiencyConfiguration_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
예제 #2
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
            });
        }
예제 #3
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));
            }
        }
예제 #4
0
        //
        // GET: /ZPVC/EfficiencyConfiguration/Modify
        public async Task <ActionResult> Modify(string group, string code)
        {
            EfficiencyConfigurationViewModel viewModel = new EfficiencyConfigurationViewModel();

            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                MethodReturnResult <EfficiencyConfiguration> result = await client.GetAsync(new EfficiencyConfigurationKey()
                {
                    Code  = code,
                    Group = group
                });

                if (result.Code == 0)
                {
                    viewModel = new EfficiencyConfigurationViewModel()
                    {
                        Code         = result.Data.Key.Code,
                        Group        = result.Data.Key.Group,
                        Description  = result.Data.Description,
                        EffiCode     = result.Data.Code,
                        EffiName     = result.Data.Name,
                        Lower        = result.Data.Lower,
                        Upper        = result.Data.Upper,
                        Color        = result.Data.Color,
                        Grade        = result.Data.Grade,
                        MaterialCode = result.Data.MaterialCode,
                        IsUsed       = result.Data.IsUsed,
                        CreateTime   = result.Data.CreateTime,
                        Creator      = result.Data.Creator,
                        Editor       = result.Data.Editor,
                        EditTime     = result.Data.EditTime
                    };
                    return(PartialView("_ModifyPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_ModifyPartial"));
        }
예제 #5
0
        public async Task <ActionResult> Delete(string group, string code)
        {
            MethodReturnResult         result = new MethodReturnResult();
            EfficiencyConfigurationKey key    = new EfficiencyConfigurationKey()
            {
                Code  = code,
                Group = group
            };

            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                result = await client.DeleteAsync(key);

                if (result.Code == 0)
                {
                    result.Message = string.Format(ZPVCResources.StringResource.EfficiencyConfiguration_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }
예제 #6
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()));
        }
예제 #7
0
        public async Task <ActionResult> SaveModify(EfficiencyConfigurationViewModel model)
        {
            using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient())
            {
                EfficiencyConfigurationKey key = new EfficiencyConfigurationKey()
                {
                    Code  = model.Code,
                    Group = model.Group
                };
                MethodReturnResult <EfficiencyConfiguration> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    result.Data.Lower        = model.Lower;
                    result.Data.Upper        = model.Upper;
                    result.Data.Code         = model.EffiCode;
                    result.Data.Name         = model.EffiName;
                    result.Data.Color        = model.Color;
                    result.Data.Grade        = model.Grade;
                    result.Data.MaterialCode = model.MaterialCode;
                    result.Data.Description  = model.Description;
                    result.Data.IsUsed       = model.IsUsed;
                    result.Data.Editor       = User.Identity.Name;
                    result.Data.EditTime     = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(ZPVCResources.StringResource.EfficiencyConfiguration_SaveModify_Success
                                                    , key);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
예제 #8
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));
        }