Exemplo n.º 1
0
        public ActionResult CheckReviseEditParam(int sid)
        {
            var db   = new Context();
            var seam = db.Seams
                       .Include(x => x.Procedure)
                       .Include(x => x.InitialParams)
                       .Include(x => x.RevisedParams)
                       .SingleOrDefault(x => x.Id == sid);

            if (seam == null)
            {
                return(PartialView("_ReviseEditParam"));
            }

            ViewBag.WeldMethod = seam.Procedure.WeldMethod;

            if (!seam.InitialParams.Any())
            {
                return(PartialView("_ReviseEditParam"));
            }

            var model = new EditParamModel();

            var paramDict = seam.InitialParams.ToDictionary(param => param.Enum, param => param.Value);

            foreach (var prop in model.GetType().GetProperties())
            {
                if (!(prop.Name.Contains("原因") || prop.Name.Contains("原因序号")))
                {
                    prop.SetValue(model, paramDict.GetValue(prop.Name.ToEnum <WeldParam>()), null);
                }
            }

            return(PartialView("_ReviseEditParam", model));
        }
Exemplo n.º 2
0
        public ActionResult ReviseEditParam(int sid, EditParamModel model)
        {
            var db   = new Context();
            var seam = db.Seams
                       .Include(x => x.Procedure)
                       .Include(x => x.InitialParams)
                       .SingleOrDefault(x => x.Id == sid);

            if (seam == null)
            {
                return(PartialView("_EditParam"));
            }

            if (!seam.InitialParams.Any())
            {
                seam.InitialParams.AddRange(GlobalData.InitialMethodParams(seam.Procedure.WeldMethod));
            }

            var props = model.GetType().GetProperty("原因");

            seam.Reason = (string)props.GetValue(model, null);

            var propsNo = model.GetType().GetProperty("原因序号");

            seam.ReasonNo = (string)propsNo.GetValue(model, null);

            foreach (var param in seam.InitialParams)
            {
                var t = model.GetType();
                if (seam.Procedure.WeldMethod == WeldMethod.高频钎焊)
                {
                    if (param.Enum == WeldParam.填充材料牌号)
                    {
                        param.Enum = WeldParam.钎料牌号;
                    }
                    if (param.Enum == WeldParam.填充材料规格)
                    {
                        param.Enum = WeldParam.钎料规格;
                    }
                }
                if (seam.Procedure.WeldMethod == WeldMethod.氩弧焊)
                {
                    if (param.Enum == WeldParam.钎料牌号)
                    {
                        param.Enum = WeldParam.填充材料牌号;
                    }
                    if (param.Enum == WeldParam.钎料规格)
                    {
                        param.Enum = WeldParam.填充材料规格;
                    }
                }
                var prop = t.GetProperty(param.Enum.ToString());

                param.Value = (string)prop.GetValue(model, null);
            }
            // seam.Reason=model.
            db.SaveChanges();
            return(Json(new { succeed = true }));
        }
Exemplo n.º 3
0
        public ActionResult ReviseModifyParam(int sid, EditParamModel model)
        {
            var db   = new Context();
            var seam = db.Seams
                       .Include(x => x.Procedure)
                       .Include(x => x.InitialParams)
                       .Include(x => x.RevisedParams)
                       .SingleOrDefault(x => x.Id == sid);

            if (seam == null)
            {
                return(PartialView("_ReviseModifyParam"));
            }

            if (!seam.InitialParams.Any())
            {
                return(Json(new { error = "没有初始值" }));
            }

            if (!seam.RevisedParams.Any())
            {
                seam.RevisedParams.AddRange(seam.InitialParams.Select(x =>
                                                                      new SeamParam2 {
                    Enum = x.Enum, Value = x.Value
                }));
            }

            foreach (var param in seam.RevisedParams)
            {
                var t    = model.GetType();
                var prop = t.GetProperty(param.Enum.ToString());
                param.Value = (string)prop.GetValue(model, null);
            }
            var props = model.GetType().GetProperty("原因");

            seam.Reason = (string)props.GetValue(model, null);

            var propsNo = model.GetType().GetProperty("原因序号");

            seam.ReasonNo = (string)propsNo.GetValue(model, null);

            db.SaveChanges();
            return(Json(new { succeed = true }));
        }