Exemple #1
0
 public ActionResult Edit(MemberEditViewModel model)
 {
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             MemberService.Update(model);
             result.Message = "编辑会员信息成功!";
             LogHelper.WriteLog("编辑会员信息成功");
             return RedirectToAction("index");
         }
         catch (Exception ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("编辑会员信息错误", ex);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
     }
     ViewBag.Data_GroupID = Utilities.GetSelectListData(GroupService.GetALL()
           , x => x.ID, x => x.Name, model.GroupID, true);
     ViewBag.Data_DepartmentID = Utilities.GetSelectListData(DepartmentService.GetALL()
         , x => x.ID, x => x.Name, model.DepartmentID, true);
     ViewBag.Data_JobTitleID = Utilities.GetSelectListData(
      JobTitleCateService.GetALL()
     , x => x.ID, x => x.CateName, model.JobTitleID, true);
     return View(model);
 }
Exemple #2
0
        public Member Update(MemberEditViewModel model)
        {
            var entity = Find(model.MemberID);
            db.Attach<Member>(entity);
            entity.Address = model.Address;

            entity.DepartmentID = model.DepartmentID;
            entity.Description = model.Description;
            entity.Email = model.Email;
            entity.GroupID = model.GroupID;
            entity.IsLeader = model.IsLeader;
            entity.AvtarUrl = model.AvtarUrl;
            if (entity.IsLeap)
            {
                entity.BirthDay1 = Utilities.GetLunarStringOnlyMonthDay(model.BirthDay);

            }
            entity.BirthDay = model.BirthDay;
            entity.LastIP = HttpHelper.IP;
            entity.LastTime = DateTime.Now;
            entity.Mobile = model.Mobile;
            entity.Mobile1 = model.Mobile1;
            entity.NickName = model.NickName;
            entity.QQ = model.QQ;
            entity.Sex = model.Sex;
            entity.StudyExp = model.StudyExp;
            entity.IDNumber = model.IDNumber;
            entity.JobExp = model.JobExp;
            entity.FamilySituation = model.FamilySituation;
            entity.JobTitleID = model.JobTitleID;
            db.Commit();
            if (entity.IsLeader)
            {
                var department = DepartmentService.Find(entity.DepartmentID);
                db.Attach<Department>(department);
                department.LeaderID = entity.MemberID;
                db.Commit();
            }
            return entity;
        }
Exemple #3
0
        public ActionResult Edit(int ID)
        {
            ChineseLunisolarCalendar clc = new System.Globalization.ChineseLunisolarCalendar();
            string Luneryear = Utilities.ConvertToChineseYearStyle(clc.GetYear(DateTime.Now));
            var entity = MemberService.Find(ID);
            var model = new MemberEditViewModel()
            {
                Address = entity.Address,
                BirthDay = entity.BirthDay,
                Sex = entity.Sex,
                QQ = entity.QQ,
                DepartmentID = entity.DepartmentID,
                Description = entity.Description,
                Email = entity.Email,
                GroupID = entity.GroupID,
                IsLeader = entity.IsLeader,
                AvtarUrl = entity.AvtarUrl,
                IsLeap = entity.IsLeap,
                Mobile = entity.Mobile,
                Mobile1 = entity.Mobile1,
                NickName = entity.NickName,
                MemberID = entity.MemberID,
                FamilySituation = entity.FamilySituation,
                IDNumber = entity.IDNumber,
                JobExp = entity.JobExp,
                StudyExp = entity.StudyExp,
                JobTitleID = entity.JobTitleID
            };

            ViewBag.Data_GroupID = Utilities.GetSelectListData(GroupService.GetALL()
               , x => x.ID, x => x.Name, model.GroupID, true);
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(DepartmentService.GetALL()
                , x => x.ID, x => x.Name, model.DepartmentID, true);
            ViewBag.Data_JobTitleID = Utilities.GetSelectListData(
               JobTitleCateService.GetALL()
              , x => x.ID, x => x.CateName, model.JobTitleID, true);
            return View(model);
        }