Ejemplo n.º 1
0
        public ActionResult Add(PlanDelayView model)
        {
            ResultView <int> view = new ResultView <int>();

            //表单校验
            if (string.IsNullOrEmpty(model.ProjectName))
            {
                view.Flag    = false;
                view.Message = "请选择延期申请所属项目!";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.PlanName))
            {
                view.Flag    = false;
                view.Message = "请选择延期工程节点!";
                return(Json(view));
            }

            ////施工单位
            //string builder = Request.Form["Builder"];
            //if (string.IsNullOrWhiteSpace(builder))
            //{
            //    view.Flag = false;
            //    view.Message = "请填写相关责任单位情况!";
            //    return Json(view);
            //}
            //model.PlanDelayCompanys = JsonConvert.DeserializeObject<List<Epm_PlanDelayCompany>>(builder);

            var companyIds   = Request.Form["CompanyId"];
            var companyNames = Request.Form["CompanyName"];

            for (int i = 0; i < companyIds.Split('、').Length; i++)
            {
                var planDelayview = new Epm_PlanDelayCompany();
                planDelayview.ProjectId   = model.ProjectId;
                planDelayview.ProjectName = model.ProjectName;
                planDelayview.CompanyId   = Convert.ToInt64(companyIds.Split('、')[i]);
                planDelayview.CompanyName = companyNames.Split('、')[i];
                planDelayview.DelayDay    = model.DelayDay;
                planDelayview.State       = model.State;
                planDelayview.DelayId     = model.Id;
                model.PlanDelayCompanys.Add(planDelayview);
            }
            if (model.PlanDelayCompanys == null || !model.PlanDelayCompanys.Any())
            {
                view.Flag    = false;
                view.Message = "请填写相关责任单位情况!";
                return(Json(view));
            }

            Result <bool> result = new Result <bool>();

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.AddPlanDelay(model);
            }
            return(Json(result.ToResultView()));
        }