Exemple #1
0
        public JsonResult UpdateAuditorRelation(int id, FormCollection fcl)
        {
            MStepAuditor sa = new MStepAuditor();

            SomeUtils.SetFieldValueToModel(fcl, sa);

            string result = new ProcessSv().SaveStepAuditor(sa, id);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(new ResultModel()
                {
                    suc = false, msg = result
                }));
            }

            return(Json(new ResultModel()
            {
                suc = true, msg = "保存成功"
            }, "text/html"));
        }
Exemple #2
0
        public string SaveStepAuditor(MStepAuditor sa, int id = 0)
        {
            if (sa.stepValue == null)
            {
                sa.stepValue = db.AuditorsRelation.Max(a => a.step_value) + 1;
            }
            if (db.AuditorsRelation.Where(a => a.auditor_id == sa.auditor && a.step_value == sa.stepValue &&
                                          a.relate_type == sa.relateType && a.relate_value == sa.relateValue).Count() > 0)
            {
                return("对应关系已存在");
            }

            try {
                AuditorsRelation ar;
                if (id == 0)
                {
                    ar = new AuditorsRelation();
                    db.AuditorsRelation.InsertOnSubmit(ar);
                }
                else
                {
                    ar = db.AuditorsRelation.Single(a => a.id == id);
                }
                ar.auditor_id   = sa.auditor;
                ar.step_name    = sa.stepName;
                ar.step_value   = sa.stepValue;
                ar.relate_value = sa.relateValue;
                ar.relate_type  = sa.relateType;

                db.SubmitChanges();
            }
            catch (Exception ex) {
                return(ex.Message);
            }

            return("");
        }