// // GET: /FMM/Supplier/Detail public async Task <ActionResult> Detail(string key) { using (SupplierServiceClient client = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = await client.GetAsync(key); if (result.Code == 0) { SupplierViewModel viewModel = new SupplierViewModel() { Name = result.Data.Name, Code = result.Data.Key, NickName = result.Data.NickName, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Description = result.Data.Description, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
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 async Task <ActionResult> SaveModify(SupplierViewModel model) { using (SupplierServiceClient client = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = await client.GetAsync(model.Code); if (result.Code == 0) { result.Data.Name = model.Name; result.Data.NickName = model.NickName; result.Data.Description = model.Description; 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.Supplier_SaveModify_Success , model.Code); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Save(SupplierViewModel model) { using (SupplierServiceClient client = new SupplierServiceClient()) { Supplier obj = new Supplier() { Key = model.Code, Name = model.Name, NickName = model.NickName, Description = model.Description, 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(FMMResources.StringResource.Supplier_Save_Success , model.Code); } return(Json(rst)); } }
public Supplier GetSupplier(string key) { using (SupplierServiceClient client = new SupplierServiceClient()) { MethodReturnResult <Supplier> rst = client.Get(key); if (rst.Code <= 0) { return(rst.Data); } } return(null); }
public Supplier GetSupplier(string supplierCode) { Supplier s = null; using (SupplierServiceClient client = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = client.Get(supplierCode); if (result.Code <= 0 && result.Data != null) { s = result.Data; } } return(s); }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (SupplierServiceClient client = new SupplierServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.Supplier_Delete_Success , key); } return(Json(result)); } }
public async Task <ActionResult> Query(SupplierQueryViewModel model) { if (ModelState.IsValid) { using (SupplierServiceClient client = new SupplierServiceClient()) { 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.NickName)) { where.AppendFormat(" {0} NickName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.NickName); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Supplier> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
//public ActionResult GetMaterialCode(string q,string orderNumber,string lineStoreName) //{ // string routeOperationName = string.Empty; // using(LineStoreServiceClient client=new LineStoreServiceClient()) // { // MethodReturnResult<LineStore> result = client.Get(lineStoreName); // if (result.Code <= 0 && result.Data != null) // { // routeOperationName = result.Data.RouteOperationName; // } // } // IList<WorkOrderBOM> lstBOM = new List<WorkOrderBOM>(); // using (WorkOrderBOMServiceClient client = new WorkOrderBOMServiceClient()) // { // PagingConfig cfg = new PagingConfig() // { // IsPaging = false, // Where = string.Format(@"MaterialCode LIKE '{0}%' AND Key.OrderNumber='{1}'" // , q // , orderNumber), // OrderBy="Key.ItemNo" // }; // //工作中心为空的可以领到任何线边仓。 // //线边仓对应工序为空的可以领任何料。 // if (!string.IsNullOrEmpty(routeOperationName)) // { // cfg.Where += string.Format(" AND (WorkCenter='' OR WorkCenter IS NULL Or WorkCenter='{0}')", routeOperationName); // } // MethodReturnResult<IList<WorkOrderBOM>> result = client.Get(ref cfg); // if (result.Code <= 0 && result.Data!=null) // { // lstBOM = result.Data; // } // } // return Json(from item in lstBOM // select new // { // @label = string.Format("{0}[{1}]", item.MaterialCode,item.Description), // @value = item.MaterialCode, // @desc=item.Description // }, JsonRequestBehavior.AllowGet); //} public ActionResult GetSupplierName(string q, string materialCode) { IList <Supplier> lstSupplier = new List <Supplier>(); string sWhere = ""; if (materialCode == null || materialCode == "") { sWhere = string.Format(@"Key LIKE '{0}%' AND EXISTS(FROM MaterialReceiptDetail as p WHERE p.SupplierCode = self.Key )" , q , materialCode); } else { sWhere = string.Format(@"Key LIKE '{0}%' AND EXISTS(FROM MaterialReceiptDetail as p WHERE p.SupplierCode = self.Key AND p.MaterialCode = '{1}')" , q , materialCode); } using (SupplierServiceClient client = new SupplierServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = sWhere, 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)); }
// // GET: /FMM/Supplier/ public async Task <ActionResult> Index() { using (SupplierServiceClient client = new SupplierServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <Supplier> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new SupplierQueryViewModel())); }
public void purchaseOrder(PurchaseOrder order) { Product[] books = order.bookArray; foreach (Product book in books) { DateTime time = DateTime.Now; String sqlStr = "INSERT INTO CustomerOrder( CompanyID, productId, productQty, status,orderNo)" + "VALUES(" + 1 + "," + book.id + "," + book.qty + "," + 3 + "," + order.orderNo + ") "; SqlConnection sqlconnection = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(); cmd.CommandText = sqlStr; cmd.Connection = sqlconnection; sqlconnection.Open(); cmd.ExecuteNonQuery(); sqlconnection.Close(); } SupplierServiceClient client = new SupplierServiceClient(); client.purchaseOrderFromCompany(order); }
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 (SupplierServiceClient client = new SupplierServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <Supplier> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public async Task <ActionResult> Save(SupplierToManufacturerViewModel model) { DateTime now = DateTime.Now; MethodReturnResult rst = new MethodReturnResult(); #region 界面录入信息合规性检查 using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> result = client.Get(model.MaterialCode); if (result.Code != 0) { rst.Code = 1001; rst.Message = String.Format("MES中不存在物料编码:{0}", model.MaterialCode); return(Json(rst)); } else { if (model.OrderNumber != "*") { using (WorkOrderServiceClient clientOfWorkOrder = new WorkOrderServiceClient()) { MethodReturnResult <WorkOrder> resultOfOrder = clientOfWorkOrder.Get(model.OrderNumber); if (resultOfOrder.Code != 0) { rst.Code = 1001; rst.Message = String.Format("MES中不存在工单:{0}", model.OrderNumber); return(Json(rst)); } } } } } #endregion using (ERPClient erpClient = new ERPClient()) { MethodReturnResult <DataSet> ds_supplier = erpClient.GetERPSupplier(model.SupplierCode); MethodReturnResult <DataSet> ds_manufacturer = erpClient.GetByCodeERPManufacturer(model.ManufacturerCode); if (ds_supplier == null || ds_supplier.Data.Tables[0].Rows.Count == 0) { rst.Code = 1001; rst.Message = String.Format("ERP中不存在供应商:{0}", model.SupplierCode); return(Json(rst)); } if (ds_manufacturer == null || ds_manufacturer.Data.Tables[0].Rows.Count == 0) { rst.Code = 1001; rst.Message = String.Format("ERP中不存在生产厂商:{0}", model.ManufacturerCode); return(Json(rst)); } //新增转换供应商 using (SupplierServiceClient supplierClient = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = await supplierClient.GetAsync(model.SupplierCode); if (result.Code != 0) { Supplier supplier = new Supplier() { Key = ds_supplier.Data.Tables[0].Rows[0]["CUSCODE"].ToString(), Name = ds_supplier.Data.Tables[0].Rows[0]["CUSNAME"].ToString(), NickName = " ", CreateTime = now, EditTime = now, Creator = User.Identity.Name, Editor = User.Identity.Name, Description = "" }; rst = await supplierClient.AddAsync(supplier); if (rst.Code != 0) { return(Json(rst)); } } } //新增转换生产厂商 using (ManufacturerServiceClient manufacturerClient = new ManufacturerServiceClient()) { MethodReturnResult <Manufacturer> result = await manufacturerClient.GetAsync(model.ManufacturerCode); if (result.Code != 0) { Manufacturer manufacturer = new Manufacturer() { Key = ds_manufacturer.Data.Tables[0].Rows[0]["CSCODE"].ToString(), Name = ds_manufacturer.Data.Tables[0].Rows[0]["CSNAME"].ToString(), NickName = " ", CreateTime = now, EditTime = now, Creator = User.Identity.Name, Editor = User.Identity.Name, Description = "" }; rst = await manufacturerClient.AddAsync(manufacturer); if (rst.Code != 0) { return(Json(rst)); } } } //新增转换规则 using (SupplierToManufacturerServiceClient client = new SupplierToManufacturerServiceClient()) { SupplierToManufacturer obj = new SupplierToManufacturer() { Key = new SupplierToManufacturerKey() { MaterialCode = model.MaterialCode.ToString().Trim().ToUpper(), OrderNumber = model.OrderNumber.ToString().Trim().ToUpper(), SupplierCode = model.SupplierCode.ToString().Trim().ToUpper() }, ManufacturerCode = model.ManufacturerCode.ToString().Trim().ToUpper(), CreateTime = now, EditTime = now, Creator = User.Identity.Name, Editor = User.Identity.Name }; rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(ZPVMResources.StringResource.SupplierToManufacturer_Save_Success); } return(Json(rst)); } } }
public Supplier GetLotBBMaterialSupplier(string lotNumber) { LotBOM lotBOMGlass = null; using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key.LotNumber='{0}' AND MaterialCode like'130308%'", lotNumber) }; MethodReturnResult <IList <LotBOM> > result = client.GetLotBOM(ref cfg); if (result.Code <= 0 && result.Data != null && result.Data.Count > 0) { lotBOMGlass = result.Data[0]; } } Lot Lot = null; using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key.LotNumber='{0}'", lotNumber) }; MethodReturnResult <Lot> result = client.Get(lotNumber); if (result.Code <= 0 && result.Data != null) { Lot = result.Data; } } Supplier sBB = null; using (SupplierServiceClient client = new SupplierServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format(@"EXISTS (FROM LineStoreMaterialDetail as p WHERE p.SupplierCode=self.Key AND p.Key.MaterialLot='{0}' AND p.Key.MaterialCode='{1}' AND p.Key.LineStoreName='{2}' AND p.Key.OrderNumber='{3}')" , lotBOMGlass.Key.MaterialLot , lotBOMGlass.MaterialCode , lotBOMGlass.LineStoreName , Lot.OrderNumber != null ? Lot.OrderNumber : string.Empty ) }; MethodReturnResult <IList <Supplier> > rst = client.Get(ref cfg); if (rst.Code <= 0 && rst.Data.Count > 0) { sBB = rst.Data[0]; } return(sBB); } }
public async Task <ActionResult> Save(MaterialReplaceViewModel model) { DateTime now = DateTime.Now; MethodReturnResult rst = new MethodReturnResult(); #region 界面录入信息合规性检查 using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> result = client.Get(model.ProductCode); if (result.Code != 0) { rst.Code = 1001; rst.Message = String.Format("MES中不存在产品编码:{0}", model.ProductCode); return(Json(rst)); } else { if (result.Data.IsProduct != true) { rst.Code = 1001; rst.Message = String.Format("物料编码[{0}]非产品!", model.ProductCode); return(Json(rst)); } if (model.OrderNumber != "*") { using (WorkOrderServiceClient clientOfWorkOrder = new WorkOrderServiceClient()) { MethodReturnResult <WorkOrder> resultOfOrder = clientOfWorkOrder.Get(model.OrderNumber); if (resultOfOrder.Code != 0) { rst.Code = 1001; rst.Message = String.Format("MES中不存在工单:{0}", model.OrderNumber); return(Json(rst)); } else { if (resultOfOrder.Data.MaterialCode != model.ProductCode) { rst.Code = 1001; rst.Message = String.Format("产品编码{0}与工单{1}不匹配!", model.ProductCode, model.OrderNumber); return(Json(rst)); } } } } } } #endregion using (ERPClient erpClient = new ERPClient()) { MethodReturnResult <DataSet> ds_supplier = erpClient.GetERPSupplier(model.OldMaterialSupplier); MethodReturnResult <DataSet> ds_supplier1 = erpClient.GetERPSupplier(model.NewMaterialSupplier); if (model.OldMaterialSupplier != "*") { if (ds_supplier.Data == null || ds_supplier.Data.Tables[0].Rows.Count == 0) { rst.Code = 1001; rst.Message = String.Format("ERP中不存在供应商:{0}", model.OldMaterialSupplier); return(Json(rst)); } if (ds_supplier.Data != null || ds_supplier.Data.Tables[0].Rows.Count > 0) { //新增替换前供应商 using (SupplierServiceClient supplierClient = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = await supplierClient.GetAsync(model.OldMaterialSupplier); if (result.Code != 0) { Supplier supplier = new Supplier() { Key = ds_supplier.Data.Tables[0].Rows[0]["CUSCODE"].ToString(), Name = ds_supplier.Data.Tables[0].Rows[0]["CUSNAME"].ToString(), NickName = " ", CreateTime = now, EditTime = now, Creator = User.Identity.Name, Editor = User.Identity.Name, Description = "" }; rst = await supplierClient.AddAsync(supplier); if (rst.Code != 0) { return(Json(rst)); } } } } } if (model.NewMaterialSupplier != "000000") { if (ds_supplier1.Data == null || ds_supplier1.Data.Tables[0].Rows.Count == 0) { rst.Code = 1001; rst.Message = String.Format("ERP中不存在供应商:{0}", model.NewMaterialSupplier); return(Json(rst)); } //新增替换后供应商 using (SupplierServiceClient supplierClient1 = new SupplierServiceClient()) { MethodReturnResult <Supplier> result = await supplierClient1.GetAsync(model.NewMaterialSupplier); if (result.Code != 0) { Supplier supplier = new Supplier() { Key = ds_supplier1.Data.Tables[0].Rows[0]["CUSCODE"].ToString(), Name = ds_supplier1.Data.Tables[0].Rows[0]["CUSNAME"].ToString(), NickName = " ", CreateTime = now, EditTime = now, Creator = User.Identity.Name, Editor = User.Identity.Name, Description = "" }; rst = await supplierClient1.AddAsync(supplier); if (rst.Code != 0) { return(Json(rst)); } } } } //新增替换规则 using (MaterialReplaceServiceClient client = new MaterialReplaceServiceClient()) { MaterialReplace obj = new MaterialReplace() { Key = new MaterialReplaceKey() { ProductCode = model.ProductCode.ToString().Trim().ToUpper(), OrderNumber = model.OrderNumber.ToString().Trim().ToUpper(), OldMaterialCode = model.OldMaterialCode.ToString().Trim().ToUpper(), OldMaterialSupplier = model.OldMaterialSupplier.ToString().Trim().ToUpper() }, NewMaterialCode = model.NewMaterialCode.ToString().Trim().ToUpper(), NewMaterialSupplier = model.NewMaterialSupplier.ToString().Trim().ToUpper(), Creator = User.Identity.Name, Editor = User.Identity.Name, CreateTime = DateTime.Now, EditTime = DateTime.Now, Description = model.Description }; rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(ZPVMResources.StringResource.MaterialReplace_Save_Success); } return(Json(rst)); } } }
public SupplierServiceReference.Product[] getAllBooks() { SupplierServiceClient client = new SupplierServiceClient(); return(client.getAllBooks()); }