//
        // GET: /ZPVM/WorkOrderControlObject/
        public async Task <ActionResult> Index(string OrderNumber, string MaterialCode)
        {
            if (string.IsNullOrEmpty(OrderNumber) || string.IsNullOrEmpty(MaterialCode))
            {
                return(RedirectToAction("Index", "WorkOrderRule"));
            }

            using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
            {
                MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey()
                {
                    OrderNumber  = OrderNumber,
                    MaterialCode = MaterialCode
                });

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "WorkOrderRule"));
                }
                ViewBag.Rule = result.Data;
            }

            using (WorkOrderControlObjectServiceClient client = new WorkOrderControlObjectServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.OrderNumber = '{0}' AND Key.MaterialCode='{1}'"
                                              , OrderNumber
                                              , MaterialCode),
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <WorkOrderControlObject> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new WorkOrderControlObjectQueryViewModel()
            {
                OrderNumber = OrderNumber, MaterialCode = MaterialCode
            }));
        }
Пример #2
0
        //
        // GET: /ZPVM/WorkOrderRule/Detail
        public async Task <ActionResult> Detail(string orderNumber, string materialCode)
        {
            using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
            {
                MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey()
                {
                    OrderNumber  = orderNumber,
                    MaterialCode = materialCode
                });

                if (result.Code == 0)
                {
                    WorkOrderRuleViewModel viewModel = new WorkOrderRuleViewModel()
                    {
                        OrderNumber      = result.Data.Key.OrderNumber,
                        MaterialCode     = result.Data.Key.MaterialCode,
                        CalibrationType  = result.Data.CalibrationType,
                        CalibrationCycle = result.Data.CalibrationCycle,
                        PowerDegree      = result.Data.PowerDegree,
                        MinPower         = result.Data.MinPower,
                        MaxPower         = result.Data.MaxPower,
                        FixCycle         = result.Data.FixCycle,
                        FullPackageQty   = result.Data.FullPackageQty,
                        Description      = result.Data.Description,
                        RuleCode         = result.Data.RuleCode,
                        RuleName         = result.Data.RuleName,
                        CreateTime       = result.Data.CreateTime,
                        Creator          = result.Data.Creator,
                        Editor           = result.Data.Editor,
                        EditTime         = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial", new WorkOrderRuleViewModel()
            {
                OrderNumber = orderNumber,
                MaterialCode = materialCode
            }));
        }
Пример #3
0
        public async Task <ActionResult> SaveModify(WorkOrderRuleViewModel model)
        {
            using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
            {
                MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey()
                {
                    OrderNumber  = model.OrderNumber,
                    MaterialCode = model.MaterialCode
                });

                if (result.Code == 0)
                {
                    result.Data.RuleName         = model.RuleName;
                    result.Data.RuleCode         = model.RuleCode;
                    result.Data.PowerDegree      = model.PowerDegree;
                    result.Data.MinPower         = model.MinPower;
                    result.Data.MaxPower         = model.MaxPower;
                    result.Data.FixCycle         = model.FixCycle;
                    result.Data.FullPackageQty   = model.FullPackageQty.Value;
                    result.Data.CalibrationCycle = model.CalibrationCycle;
                    result.Data.CalibrationType  = model.CalibrationType;
                    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.WorkOrderRule_SaveModify_Success
                                                    , result.Data.Key);
                    }
                    return(Json(rst));
                }
                else
                {
                    return(await Save(model));
                }
            }
        }