示例#1
0
        //
        // GET: /FMM/Manufacturer/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (ManufacturerServiceClient client = new ManufacturerServiceClient())
            {
                MethodReturnResult <Manufacturer> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    ManufacturerViewModel viewModel = new ManufacturerViewModel()
                    {
                        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"));
        }
示例#2
0
        public async Task <ActionResult> SaveModify(ManufacturerViewModel model)
        {
            using (ManufacturerServiceClient client = new ManufacturerServiceClient())
            {
                MethodReturnResult <Manufacturer> 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.Manufacturer_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
        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));
                }
            }
        }