public UserEmployeeDetailModel GetEmployeeDetailByEmployeeNumber(int employeeNumber) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail dbDetail = (from detail in context.UserEmployeeDetails where detail.EmployeeNumber == employeeNumber select detail).FirstOrDefault(); UserEmployeeDetailModel empDetail = new UserEmployeeDetailModel(); empDetail.Id = dbDetail.Id; empDetail.EmployeeNumber = dbDetail.EmployeeNumber; empDetail.Name = dbDetail.Name; empDetail.Email = dbDetail.Email; empDetail.Phone = dbDetail.Phone; return empDetail; }
public Boolean DeleteUserAccount(UserEmployeeModel userEmployeeModel, UserEmployeeDetailModel userEmployeeDetailModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail dbDetail = (from detail in context.UserEmployeeDetails where detail.EmployeeNumber == userEmployeeDetailModel.EmployeeNumber select detail).FirstOrDefault(); context.DeleteObject(dbDetail); context.SaveChanges(); UserEmployee dbUser = (from user in context.UserEmployees where user.EmployeeNumber == userEmployeeModel.EmployeeNumber select user).FirstOrDefault(); context.DeleteObject(dbUser); context.SaveChanges(); return true; }
private UserEmployeeDetail ConvertToDBDetail(UserEmployeeDetailModel userEmployeeDetailModel) { if (userEmployeeDetailModel == null) return null; DAL.UserEmployeeDetail userEmployeeDetail = new DAL.UserEmployeeDetail(); userEmployeeDetail.EmployeeNumber = userEmployeeDetailModel.EmployeeNumber; userEmployeeDetail.Name = userEmployeeDetailModel.Name; userEmployeeDetail.Email = userEmployeeDetailModel.Email; userEmployeeDetail.Phone = userEmployeeDetailModel.Phone; return userEmployeeDetail; }
public Boolean UpdateUserDetailAccount(UserEmployeeDetailModel userEmployeeDetail) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail empDetal = (from d in context.UserEmployeeDetails where d.Id == userEmployeeDetail.Id select d).FirstOrDefault(); empDetal.EmployeeNumber = userEmployeeDetail.EmployeeNumber; empDetal.Name = userEmployeeDetail.Name; empDetal.Email = userEmployeeDetail.Email; empDetal.Phone = userEmployeeDetail.Phone; context.SaveChanges(); return true; }
public ActionResult doCreateUser() { BLLUserAccount bllUserAccount = new BLLUserAccount(); UserEmployeeModel userEmployeeModel = new UserEmployeeModel(); UserEmployeeDetailModel userEmployeeDetailModel = new UserEmployeeDetailModel(); userEmployeeModel.EmployeeNumber = bllUserAccount.GetMaxEmployeeNumber() + 1; userEmployeeModel.Password = "******"; userEmployeeModel.DepartmentId = Convert.ToInt32(Request.Form["dept_name"]); userEmployeeModel.IsManager = (Convert.ToInt32(Request.Form["isManager"]) == 0 ? false : true); userEmployeeModel.IsChecker = (Convert.ToInt32(Request.Form["isChecker"]) == 0 ? false : true); userEmployeeModel.IsAvailable = (Convert.ToInt32(Request.Form["isAvailable"]) == 0 ? false : true); userEmployeeModel.Name = Request.Form["name"]; userEmployeeModel.Email = Request.Form["email"]; userEmployeeModel.Phone = Request.Form["phone"]; if (userEmployeeModel.Email == null || !isEmail(userEmployeeModel.Email)) { TempData["employeeNumberErrorMsg"] = "请输入正确的邮箱地址!"; return RedirectToAction("CreateUser", "Employee"); } if (userEmployeeModel.Phone == null ||!isPhone(userEmployeeModel.Phone)) { TempData["phoneErrorMsg"] = "请输入正确的手机号!"; return RedirectToAction("CreateUser", "Employee"); } Boolean result = bllUserAccount.CreateUserAccount(userEmployeeModel); if (result == true) { ViewData["successMsg"] = "添加成功"; return RedirectToAction("Index", "Employee"); } else { ViewData["errorMsg"] = "添加失败"; return RedirectToAction("Index", "Employee"); } }
public Boolean DeleteUserAccount(UserEmployeeModel userEmployeeModel, UserEmployeeDetailModel userEmployeeDetailModel) { userDAL.DeleteUserAccount(userEmployeeModel, userEmployeeDetailModel); return true; }
public Boolean UpdateUserDetailAccount(UserEmployeeDetailModel empDetailModel) { return userDAL.UpdateUserDetailAccount(empDetailModel); }
public ActionResult doProfile() { UserEmployeeDetailModel empDetailModel = new UserEmployeeDetailModel { Id = Convert.ToInt32(Request.Form["empDetailId"]), EmployeeNumber = Convert.ToInt32(User.Identity.Name), Name = Request.Form["name"], Email = Request.Form["email"], Phone = Request.Form["phone"] }; //非空验证 if (empDetailModel.Name == "" || empDetailModel.Email == "" || empDetailModel.Phone == "") { TempData["errorMsg"] = "请填写所有的字段。"; } else if (new BLLUserAccount().UpdateUserDetailAccount(empDetailModel)) { TempData["successMsg"] = "保存成功。"; } else { TempData["errorMsg"] = "保存失败。"; } return RedirectToAction("Profile", "User"); }