public async Task <ActionResult> QueryQuantity(String MaterialNumber) { double Quantity = 0; MaterialQueryViewModel model = new MaterialQueryViewModel(); if (ModelState.IsValid) { using (LineStoreMaterialServiceClient client = new LineStoreMaterialServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { Where = string.Format(" Key.MaterialLot Like '{0}'" , MaterialNumber) }; MethodReturnResult <IList <LineStoreMaterialDetail> > result = client.GetDetail(ref cfg); if (result.Code <= 0 && result.Data != null && result.Data.Count > 0) { Quantity = result.Data[0].CurrentQty; } else { return; } }); } } return(Json(Quantity)); }
public String GetType(String materialCode) { MaterialQueryViewModel model = new MaterialQueryViewModel(); model.Code = materialCode; StringBuilder where = new StringBuilder(); using (MaterialServiceClient client = new MaterialServiceClient()) { where.AppendFormat(" Key = '{0}'", model.Code); PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Material> > result = client.Get(ref cfg); //List<Material> MaterialList =result.Data.ToList<Material>(); String ProductType = null; if (result.Code == 0) { string barcode = result.Data[0].Key; string qty = result.Data[0].MainRawQtyPerLot.ToString(); ProductType = string.Format("JNM{0}{1}" , barcode.StartsWith("1201") ? "M" : "P" , qty); } return(ProductType); } }
public async Task <ActionResult> Query(MaterialQueryViewModel model) { if (ModelState.IsValid) { using (MaterialServiceClient client = new MaterialServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Code)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Code); } if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Name LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Type LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Type); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Material> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public async Task <ActionResult> Query(MaterialQueryViewModel model) { if (ModelState.IsValid) { using (MaterialServiceClient client = new MaterialServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { //物料代码 if (!string.IsNullOrEmpty(model.Code)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Code); } //名称 if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Name LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } //类型 if (!string.IsNullOrEmpty(model.Type)) { where.AppendFormat(" {0} Type LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Type); } //是否有效条件 if (model.Status != "" && model.Status != null) { where.AppendFormat(" {0} Status = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.Status); } //物料归属类型(物料、产品) if (model.Ascription != "" && model.Ascription != null) { //产品 if (model.Ascription == "P") { where.AppendFormat(" {0} IsProduct = {1}" , where.Length > 0 ? "AND" : string.Empty , "true"); } //材料 if (model.Ascription == "M") { where.AppendFormat(" {0} IsRaw = {1}" , where.Length > 0 ? "AND" : string.Empty , "true"); } } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Material> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }