public async Task <ActionResult> SaveModify(MaterialAttributeViewModel model) { using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { MethodReturnResult <MaterialAttribute> result = await client.GetAsync(new MaterialAttributeKey() { MaterialCode = model.MaterialCode, AttributeName = model.AttributeName }); if (result.Code == 0) { result.Data.Value = model.Value; 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(FMMResources.StringResource.MaterialAttribute_SaveModify_Success , result.Data.Key); } return(Json(rst)); } return(Json(result)); } }
// // GET: /FMM/MaterialAttribute/Detail public async Task <ActionResult> Detail(string materialCode, string attributeName) { using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { MethodReturnResult <MaterialAttribute> result = await client.GetAsync(new MaterialAttributeKey() { MaterialCode = materialCode, AttributeName = attributeName }); if (result.Code == 0) { MaterialAttributeViewModel viewModel = new MaterialAttributeViewModel() { MaterialCode = result.Data.Key.MaterialCode, AttributeName = result.Data.Key.AttributeName, Value = result.Data.Value, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
public async Task <ActionResult> Save(MaterialAttributeViewModel model) { using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { MaterialAttribute obj = new MaterialAttribute() { Key = new MaterialAttributeKey() { MaterialCode = model.MaterialCode, AttributeName = model.AttributeName }, Value = model.Value, Editor = User.Identity.Name, EditTime = DateTime.Now, }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.MaterialAttribute_Save_Success , obj.Key); } return(Json(rst)); } }
public string GetProductType(string materialCode, string orderNumber, string powersetCode, int itemNo, Lot lot) { string productType = string.Empty; Material material = null; string wop = ""; wop = GetPowersetName(lot.Key, powersetCode, itemNo); using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> result = client.Get(materialCode); MethodReturnResult <MaterialAttribute> resultOfMaterialAttr = new MethodReturnResult <MaterialAttribute>(); MaterialAttributeServiceClient clientOfMattr = new MaterialAttributeServiceClient(); if (result.Code == 0) { material = result.Data; if (wop != "") { int indexOfType = material.Name.IndexOf('-'); if (indexOfType >= 0) { productType = material.Name.Substring(0, indexOfType) + "-" + wop.Substring(0, 3); } else { productType = material.Name.Substring(0, 6) + "-" + wop.Substring(0, 3); } if (material.Name.Contains("PV")) { MaterialAttributeKey materialAttributeKey = new MaterialAttributeKey() { MaterialCode = material.Key, AttributeName = "ProductType" }; resultOfMaterialAttr = clientOfMattr.Get(materialAttributeKey); if (resultOfMaterialAttr.Data != null) { string valueOf = resultOfMaterialAttr.Data.Value.Trim(); int indexOfType1 = valueOf.IndexOf('*'); productType = string.Format("{0}{1}-{2}{3}" , valueOf.Substring(0, indexOfType1) , wop.Substring(0, 3) , material.MainRawQtyPerLot , valueOf.Substring(valueOf.Length - 3)); } else { productType = ""; } } } } } return(productType); }
public async Task <ActionResult> Delete(string materialCode, string attributeName) { MethodReturnResult result = new MethodReturnResult(); using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { result = await client.DeleteAsync(new MaterialAttributeKey() { MaterialCode = materialCode, AttributeName = attributeName }); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.MaterialAttribute_Delete_Success , attributeName); } return(Json(result)); } }
public async Task <ActionResult> Query(MaterialAttributeQueryViewModel model) { if (ModelState.IsValid) { using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { where.AppendFormat(" {0} Key.MaterialCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.MaterialCode); if (!string.IsNullOrEmpty(model.AttributeName)) { where.AppendFormat(" {0} Key.AttributeName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.AttributeName); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <MaterialAttribute> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /FMM/MaterialAttribute/ public async Task <ActionResult> Index(string materialCode) { using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> result = await client.GetAsync(materialCode ?? string.Empty); if (result.Code > 0 || result.Data == null) { return(RedirectToAction("Index", "Material")); } ViewBag.Material = result.Data; } using (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key.MaterialCode,Key.AttributeName", Where = string.Format(" Key.MaterialCode = '{0}'" , materialCode) }; MethodReturnResult <IList <MaterialAttribute> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new MaterialAttributeQueryViewModel() { MaterialCode = materialCode })); }
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 (MaterialAttributeServiceClient client = new MaterialAttributeServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <MaterialAttribute> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public ActionResult Save(LotMateSeModel model) { MethodReturnResult result = new MethodReturnResult(); int count = 0; try { string lotNumber = model.LotNumber.ToUpper(); result = GetLot(lotNumber); if (result.Code > 0) { return(Json(result)); } //取得批次信息 MethodReturnResult <Lot> rst = result as MethodReturnResult <Lot>; Lot obj = rst.Data; MaterialAttributeServiceClient clientOfMattr = new MaterialAttributeServiceClient(); MaterialAttributeKey materialAttributeKey = new MaterialAttributeKey() { MaterialCode = obj.MaterialCode, AttributeName = "MapBitCount" }; MethodReturnResult <MaterialAttribute> materialAttributeOfMap = clientOfMattr.Get(materialAttributeKey); if (materialAttributeOfMap.Code == 0 && materialAttributeOfMap.Data != null) { count = Convert.ToInt32(materialAttributeOfMap.Data.Value); } if (count != 0 && model.SEModulesNo.Length != count) { result.Code = 1000; result.Message = string.Format("组件批次{0}优化器序列号{1}长度不符合长度限制{2}", model.LotNumber, model.SEModulesNo, count); return(Json(result)); } else if (count != 0 && model.SEModulesNo.Length == count) { if (model.SEModulesNo.Length == 8) { int seModulesNo = 0; bool isNum = int.TryParse(model.SEModulesNo, out seModulesNo); if (isNum) { obj.Attr3 = model.SEModulesNo; } else { result.Code = 1000; result.Message = string.Format("组件批次{0}优化器序列号{1}不合法", model.LotNumber, model.SEModulesNo); return(Json(result)); } } else { obj.Attr3 = model.SEModulesNo; } } else { obj.Attr3 = model.SEModulesNo; } using (LotCreateServiceClient client = new LotCreateServiceClient()) { result = client.UpdateLotSEModules(obj); if (result.Code == 0) { result.Message = string.Format("组件批次{0}优化器序列号{1}匹配成功", model.LotNumber, model.SEModulesNo); } } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }