public ActionResult UserEdit(int id) { var user = from Users in db.Users join Managers in db.Managers on Users.PersonId equals Managers.id select new Managerlist { ManagerId = Managers.id, UserId = Users.id, ManagerNum = Managers.ManagerNum, ManagerName = Managers.ManagerName, Gender = Managers.Gender, Mobile = Managers.Mobile, Password = Users.Password, StartDate = Users.StartDate, Role = Users.Role, PersonId = Users.PersonId, Birthday = Managers.Birthday, HireDate = Managers.HireDate, ManagerType = Managers.ManagerType, HeadImage = Managers.HeadImage, Comments = Managers.Comments, }; var a = user.Where(x => x.ManagerId == id).FirstOrDefault(); Managerlist userone = new Managerlist(); userone.ManagerId = a.ManagerId; userone.UserId = a.ManagerId; userone.ManagerNum = a.ManagerNum; userone.ManagerName = a.ManagerName; userone.Gender = a.Gender; userone.Mobile = a.Mobile; userone.Password = a.Password; userone.StartDate = a.StartDate; userone.Role = a.Role; userone.PersonId = a.PersonId; userone.Birthday = a.Birthday; userone.HireDate = a.HireDate; userone.ManagerType = a.ManagerType; userone.HeadImage = a.HeadImage; userone.Comments = a.Comments; if (a.Birthday != null) { ViewData["Birthday"] = Convert.ToDateTime(a.Birthday).ToString("yyyy-MM-dd"); } else { ViewData["Birthday"] = null; } if (a.HireDate != null) { ViewData["HireDate"] = Convert.ToDateTime(a.HireDate).ToString("yyyy-MM-dd"); } else { ViewData["HireDate"] = null; } return(View(userone)); }
public ActionResult UserDetail(int id) { var user = from Users in db.Users join Managers in db.Managers on Users.PersonId equals Managers.id select new Managerlist { ManagerId = Managers.id, UserId = Users.id, ManagerNum = Managers.ManagerNum, ManagerName = Managers.ManagerName, Gender = Managers.Gender, Mobile = Managers.Mobile, Password = Users.Password, StartDate = Users.StartDate, Role = Users.Role, PersonId = Users.PersonId, Birthday = Managers.Birthday, HireDate = Managers.HireDate, ManagerType = Managers.ManagerType, HeadImage = Managers.HeadImage, Comments = Managers.Comments, }; var a = user.Where(x => x.ManagerId == id).FirstOrDefault(); Managerlist userone = new Managerlist(); userone.ManagerId = a.ManagerId; userone.UserId = a.ManagerId; userone.ManagerNum = a.ManagerNum; userone.ManagerName = a.ManagerName; if (a.Gender == "0") { userone.Gender = "男"; } if (a.Gender == "1") { userone.Gender = "女"; } userone.Mobile = a.Mobile; userone.Password = a.Password; userone.StartDate = a.StartDate; userone.Role = a.Role; userone.PersonId = a.PersonId; userone.Birthday = a.Birthday; userone.HireDate = a.HireDate; if (a.ManagerType == "M") { userone.ManagerType = "项目经理"; } if (a.ManagerType == "C") { userone.ManagerType = "客户经理"; } userone.HeadImage = a.HeadImage; userone.Comments = a.Comments; return(View(userone)); }