public async Task <ActionResult> SaveModify(EfficiencyViewModel model) { using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { EfficiencyKey key = new EfficiencyKey() { Code = model.Code, Group = model.Group }; MethodReturnResult <Efficiency> result = await client.GetAsync(key); if (result.Code == 0) { result.Data.Lower = model.Lower; result.Data.Upper = model.Upper; result.Data.Name = model.Name; 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(ZPVMResources.StringResource.Efficiency_SaveModify_Success , model.Code); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Save(EfficiencyViewModel model) { using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { Efficiency obj = new Efficiency() { Key = new EfficiencyKey() { Code = model.Code.ToUpper(), Group = model.Group.ToUpper() }, Name = model.Name, Lower = model.Lower, Upper = model.Upper, Description = model.Description, 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(ZPVMResources.StringResource.Efficiency_Save_Success , obj.Key); } return(Json(rst)); } }
//public ActionResult GetSupplierName(string q) //{ // IList<Supplier> lstSupplier = new List<Supplier>(); // using (SupplierServiceClient client = new SupplierServiceClient()) // { // PagingConfig cfg = new PagingConfig() // { // IsPaging = false, // Where = string.Format(@"Key LIKE '{0}%'" // , q), // OrderBy = "Key" // }; // MethodReturnResult<IList<Supplier>> result = client.Get(ref cfg); // if (result.Code <= 0 && result.Data != null) // { // lstSupplier = result.Data; // } // } // return Json(from item in lstSupplier // select new // { // @label = item.Key + "-" + item.Name, // @value = item.Key, // @SupplierName = item.Name // }, JsonRequestBehavior.AllowGet); //} public ActionResult GetEfficiency(string q) { IList <Efficiency> lst = new List <Efficiency>(); using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format(@"Name LIKE '{0}%' and IsUsed = 1" , q), OrderBy = "Name" }; MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg); if (result.Code <= 0 && result.Data != null) { lst = result.Data; } } var lnq = from item in lst select item.Name; return(Json(from item in lnq.Distinct <string>() select new { @label = item, @value = item }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Query(EfficiencyQueryViewModel model) { if (ModelState.IsValid) { using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { 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 <Efficiency> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public async Task <ActionResult> Delete(string group, string code) { MethodReturnResult result = new MethodReturnResult(); EfficiencyKey key = new EfficiencyKey() { Code = code, Group = group }; using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(ZPVMResources.StringResource.Efficiency_Delete_Success , key); } return(Json(result)); } }
// // GET: /ZPVM/Efficiency/ public async Task <ActionResult> Index() { using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new EfficiencyQueryViewModel())); }
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 (EfficiencyServiceClient client = new EfficiencyServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /ZPVM/Efficiency/Modify public async Task <ActionResult> Modify(string group, string code) { EfficiencyViewModel viewModel = new EfficiencyViewModel(); using (EfficiencyServiceClient client = new EfficiencyServiceClient()) { MethodReturnResult <Efficiency> result = await client.GetAsync(new EfficiencyKey() { Code = code, Group = group }); if (result.Code == 0) { viewModel = new EfficiencyViewModel() { Code = result.Data.Key.Code, Group = result.Data.Key.Group, Description = result.Data.Description, Name = result.Data.Name, Lower = result.Data.Lower, Upper = result.Data.Upper, 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")); }