Exemplo n.º 1
0
 public bool CreatePeople(STCheckPeopleSaveModel model, out string erroMsg)
 {
     using (var db = dbFactory.Open())
     {
         using (var dbTrans = db.OpenTransaction())
         {
             try
             {
                 erroMsg = string.Empty;
                 var peopleId = db.Insert(model.People, true);
                 for (int i = 0; i < model.PeoAward.Count; i++)
                 {
                     model.PeoAward[i].PeopleId = (int)peopleId;
                     db.Insert(model.PeoAward[i], true);
                 }
                 for (int i = 0; i < model.PeoChange.Count; i++)
                 {
                     model.PeoChange[i].PeopleId = (int)peopleId;
                     db.Insert(model.PeoChange[i], true);
                 }
                 for (int i = 0; i < model.PeoPunish.Count; i++)
                 {
                     model.PeoPunish[i].PeopleId = (int)peopleId;
                     db.Insert(model.PeoPunish[i], true);
                 }
                 for (int i = 0; i < model.PeoEducation.Count; i++)
                 {
                     model.PeoEducation[i].PeopleId = (int)peopleId;
                     db.Insert(model.PeoEducation[i], true);
                 }
                 dbTrans.Commit();
                 return(true);
             }
             catch (Exception ex)
             {
                 dbTrans.Rollback();
                 erroMsg = ex.Message;
                 return(false);
             }
         }
     }
 }
        public ActionResult Edit(STCheckPeopleSaveViewModel model)
        {
            ControllerResult result = ControllerResult.SuccResult;

            result.IsSucc = true;
            STCheckPeopleSaveModel editModel = new STCheckPeopleSaveModel();

            try
            {
                DateTime?postnumstartdate = null;
                DateTime?postnumenddate   = null;
                CommonUtils.GetLayuiDateRange(model.Postnumdate, out postnumstartdate, out postnumenddate);
                model.postnumstartdate = postnumstartdate;
                model.postnumenddate   = postnumenddate;
                editModel.People       = new t_bp_People_ST()
                {
                    PostDate         = model.PostDate,
                    Id               = model.Id,
                    Name             = model.Name,
                    Customid         = model.Customid,
                    Sex              = model.Sex,
                    Birthday         = model.Birthday,
                    SelfNum          = model.SelfNum,
                    PostNum          = model.PostNum,
                    ishaspostnum     = model.ishaspostnum,
                    postnumstartdate = model.postnumstartdate,
                    postnumenddate   = model.postnumenddate,
                    School           = model.School,
                    Education        = model.Education,
                    Title            = model.Title,
                    Professional     = model.Professional,
                    Tel              = model.Tel,
                    zw               = model.zw,
                    Email            = model.Email,
                    SBNum            = model.SBNum,
                    isjs             = model.isjs,
                    ismanager        = model.ismanager,
                    issy             = model.issy,
                    PostType         = model.PostType,
                    postDelayReg     = model.postDelayReg,
                    selfnumPath      = model.selfnumPath,
                    educationpath    = model.educationpath,
                    PhotoPath        = model.PhotoPath,
                    PostPath         = model.PostPath,
                    sbnumpath        = model.sbnumpath
                };
                editModel.PeoAward     = new List <t_bp_PeoAwards_ST>();
                editModel.PeoChange    = new List <t_bp_PeoChange_ST>();
                editModel.PeoPunish    = new List <t_bp_PeoPunish_ST>();
                editModel.PeoEducation = new List <t_bp_PeoEducation_ST>();
                if (model.peoAward != null)
                {
                    foreach (var item in model.peoAward)
                    {
                        item.PeopleId = model.Id;
                        editModel.PeoAward.Add(item);
                    }
                }
                if (model.peoPunish != null)
                {
                    foreach (var item in model.peoPunish)
                    {
                        item.PeopleId = model.Id;
                        editModel.PeoPunish.Add(item);
                    }
                }
                if (model.peoEducation != null)
                {
                    foreach (var item in model.peoEducation)
                    {
                        item.PeopleId = model.Id;
                        editModel.PeoEducation.Add(item);
                    }
                }
                if (model.peoChange != null)
                {
                    foreach (var item in model.peoChange)
                    {
                        item.PeopleId = model.Id;
                        editModel.PeoChange.Add(item);
                    }
                }
                string erroMsg = string.Empty;
                if (!sTCheckPeopleService.EditPeople(editModel, out erroMsg))
                {
                    result         = ControllerResult.FailResult;
                    result.ErroMsg = erroMsg;
                    result.IsSucc  = false;
                }
                else
                {
                    LogUserAction("进行了商砼人员信息修改操作,id为{0}".Fmt(model.Id));
                }
            }
            catch (Exception ex)
            {
                result         = ControllerResult.FailResult;
                result.ErroMsg = ex.Message;
                result.IsSucc  = false;
            }
            return(Content(result.ToJson()));
        }
Exemplo n.º 3
0
        public bool EditPeople(STCheckPeopleSaveModel model, out string erroMsg)
        {
            using (var db = dbFactory.Open())
            {
                using (var dbTrans = db.OpenTransaction())
                {
                    try
                    {
                        erroMsg = string.Empty;
                        db.UpdateOnly(model.People, r => new
                        {
                            r.Name,
                            r.Customid,
                            r.Sex,
                            r.Birthday,
                            r.SelfNum,
                            r.PostNum,
                            r.ishaspostnum,
                            r.postnumstartdate,
                            r.postnumenddate,
                            r.School,
                            r.Education,
                            r.Title,
                            r.Professional,
                            r.Tel,
                            r.zw,
                            r.Email,
                            r.SBNum,
                            r.isjs,
                            r.ismanager,
                            r.issy,
                            r.PostType,
                            r.postDelayReg,
                            r.selfnumPath,
                            r.educationpath,
                            r.PhotoPath,
                            r.PostPath,
                            r.sbnumpath
                        }, r => r.Id == model.People.Id);
                        db.Delete <t_bp_PeoAwards_ST>(r => r.PeopleId == model.People.Id);
                        for (int i = 0; i < model.PeoAward.Count; i++)
                        {
                            model.PeoAward[i].Id = 0;
                            db.Insert(model.PeoAward[i], true);
                        }

                        db.Delete <t_bp_PeoChange_ST>(r => r.PeopleId == model.People.Id);

                        for (int i = 0; i < model.PeoChange.Count; i++)
                        {
                            model.PeoChange[i].Id = 0;
                            db.Insert(model.PeoChange[i], true);
                        }
                        db.Delete <t_bp_PeoPunish_ST>(r => r.PeopleId == model.People.Id);
                        for (int i = 0; i < model.PeoPunish.Count; i++)
                        {
                            model.PeoPunish[i].Id = 0;
                            db.Insert(model.PeoPunish[i], true);
                        }

                        db.Delete <t_bp_PeoEducation_ST>(r => r.PeopleId == model.People.Id);
                        for (int i = 0; i < model.PeoEducation.Count; i++)
                        {
                            model.PeoEducation[i].Id = 0;
                            db.Insert(model.PeoEducation[i], true);
                        }
                        dbTrans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        dbTrans.Rollback();
                        erroMsg = ex.Message;
                        return(false);
                    }
                }
            }
        }
        public ActionResult Create(STCheckPeopleSaveViewModel model)
        {
            ControllerResult result = ControllerResult.SuccResult;

            result.IsSucc = true;
            STCheckPeopleSaveModel createModel = new STCheckPeopleSaveModel();

            try
            {
                if (repCustom.GetByCondition(r => r.Id == model.Customid).Count == 0)
                {
                    result         = ControllerResult.FailResult;
                    result.ErroMsg = "新增失败,该机构系统中不存在!";
                    return(Content(result.ToJson()));
                }

                DateTime?postnumstartdate = null;
                DateTime?postnumenddate   = null;
                CommonUtils.GetLayuiDateRange(model.Postnumdate, out postnumstartdate, out postnumenddate);
                model.postnumstartdate = postnumstartdate;
                model.postnumenddate   = postnumenddate;
                createModel.People     = new t_bp_People_ST()
                {
                    Approvalstatus   = "0",
                    Name             = model.Name,
                    Customid         = model.Customid,
                    Sex              = model.Sex,
                    PostDate         = model.PostDate,
                    Birthday         = model.Birthday,
                    SelfNum          = model.SelfNum,
                    PostNum          = model.PostNum,
                    ishaspostnum     = model.ishaspostnum,
                    postnumstartdate = model.postnumstartdate,
                    postnumenddate   = model.postnumenddate,
                    School           = model.School,
                    Education        = model.Education,
                    Title            = model.Title,
                    Professional     = model.Professional,
                    Tel              = model.Tel,
                    zw            = model.zw,
                    Email         = model.Email,
                    SBNum         = model.SBNum,
                    isjs          = model.isjs,
                    ismanager     = model.ismanager,
                    issy          = model.issy,
                    PostType      = model.PostType,
                    postDelayReg  = model.postDelayReg,
                    selfnumPath   = model.selfnumPath,
                    educationpath = model.educationpath,
                    PhotoPath     = model.PhotoPath,
                    PostPath      = model.PostPath,
                    sbnumpath     = model.sbnumpath
                };
                createModel.PeoAward     = new List <t_bp_PeoAwards_ST>();
                createModel.PeoChange    = new List <t_bp_PeoChange_ST>();
                createModel.PeoPunish    = new List <t_bp_PeoPunish_ST>();
                createModel.PeoEducation = new List <t_bp_PeoEducation_ST>();

                if (model.peoAward != null)
                {
                    foreach (var item in model.peoAward)
                    {
                        createModel.PeoAward.Add(item);
                    }
                }
                if (model.peoPunish != null)
                {
                    foreach (var item in model.peoPunish)
                    {
                        createModel.PeoPunish.Add(item);
                    }
                }
                if (model.peoEducation != null)
                {
                    foreach (var item in model.peoEducation)
                    {
                        createModel.PeoEducation.Add(item);
                    }
                }
                if (model.peoChange != null)
                {
                    foreach (var item in model.peoChange)
                    {
                        createModel.PeoChange.Add(item);
                    }
                }
                string erroMsg = string.Empty;
                if (!sTCheckPeopleService.CreatePeople(createModel, out erroMsg))
                {
                    result         = ControllerResult.FailResult;
                    result.ErroMsg = erroMsg;
                    result.IsSucc  = false;
                }
                else
                {
                    LogUserAction("进行了商砼人员信息新增操作,姓名为{0},身份证号为{1}".Fmt(model.Name, model.SelfNum));
                }
            }
            catch (Exception ex)
            {
                result         = ControllerResult.FailResult;
                result.ErroMsg = ex.Message;
                result.IsSucc  = false;
            }
            return(Content(result.ToJson()));
        }