public bool DelPosition(List <MODEL.T_MemberInformation> memList, int roleId) { MODEL.T_RoleAct roleAct; int count = 0; foreach (MODEL.T_MemberInformation mem in memList) { //开始录入 roleAct = new MODEL.T_RoleAct(); roleAct.RoleId = roleId; roleAct.RoleActor = mem.StuNum; roleAct.IsDel = false; if (OperateContext.Current.BLLSession.IRoleActBLL.Del(roleAct) > 0) { count++; } } if (count > 0) { return(true); } else { return(false); } }
/// <summary> /// 管理员修改方法,可以修改所有信息 /// </summary> /// <param name="member"></param> /// <returns></returns> public ActionResult AdminEdit(MODEL.T_MemberInformation member) { int oldRoleId = 0; try { oldRoleId = Convert.ToInt32(Request.Form["oldRoleId"]); //查看角色属性 int roleId = 0; OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u => u.RoleId == oldRoleId && u.RoleActor == member.StuNum); object o = Request.Form["role"]; if (Request.Form["role"] != null) { roleId = Convert.ToInt32(Request.Form["role"]); MODEL.T_RoleAct roleAct = new MODEL.T_RoleAct(); roleAct.RoleId = roleId; roleAct.RoleActor = member.StuNum; OperateContext.Current.BLLSession.IRoleActBLL.Add(roleAct); } } catch { } //得到修改SecretShow属性 int ShowFPhone = 2; int ShowAddress = 2; int ShowPhone = 2; int IsShow; ShowAddress = Convert.ToInt32(Request.Form["ShowAddress"]);//设置部分信息是否可以看到 ShowFPhone = Convert.ToInt32(Request.Form["ShowFPhone"]); ShowPhone = Convert.ToInt32(Request.Form["ShowPhone"]); IsShow = 4 * ShowFPhone + 2 * ShowAddress + ShowPhone;//得到信息公开数据 member.SecretShow = IsShow; if (ModelState.IsValid) { //EF修改主键一定要加 string[] proNames = new string[] { "StuNum", "StuName", "Gender", "QQNum", "Email", "Birthday", "Class", "Major", "Counselor", "HeadTeacher", "UndergraduateTutor", "TelephoneNumber", "HomPhoneNumber", "FamilyAddress", "Department", "TechnicalLevel", "StudyGuideNumber", "Sign", "OtheInfor", "SecretShow" }; int IsSuccess = OperateContext.Current.BLLSession.IMemberInformationBLL.Modify(member, proNames); if (IsSuccess > 0) { return(Content("<script>alert('修改成功');window.location='/PersonalManger/CheckMember/PersonPage?StuNum=" + member.StuNum + "'</script>")); } else { return(Content("<script>alert('修改失败');window.location='/PersonalManger/CheckMember/PageEdit?StuNum=" + member.StuNum + "'</script>")); } } else { return(Content("<script>alert('修改失败');window.location='/PersonalManger/CheckMember/PageEdit?StuNum=" + member.StuNum + "'</script>")); } }
/// <summary> /// 管理员修改方法,可以修改所有信息 /// </summary> /// <param name="member"></param> /// <returns></returns> public ActionResult AdminEdit(MODEL.T_MemberInformation member) { int oldRoleId = 0; try { oldRoleId=Convert.ToInt32(Request.Form["oldRoleId"]); //查看角色属性 int roleId = 0; OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u => u.RoleId == oldRoleId && u.RoleActor == member.StuNum); object o = Request.Form["role"]; if (Request.Form["role"] != null) { roleId = Convert.ToInt32(Request.Form["role"]); MODEL.T_RoleAct roleAct = new MODEL.T_RoleAct(); roleAct.RoleId = roleId; roleAct.RoleActor = member.StuNum; OperateContext.Current.BLLSession.IRoleActBLL.Add(roleAct); } } catch { } //得到修改SecretShow属性 int ShowFPhone = 2; int ShowAddress = 2; int ShowPhone = 2; int IsShow; ShowAddress = Convert.ToInt32(Request.Form["ShowAddress"]);//设置部分信息是否可以看到 ShowFPhone = Convert.ToInt32(Request.Form["ShowFPhone"]); ShowPhone = Convert.ToInt32(Request.Form["ShowPhone"]); IsShow = 4 * ShowFPhone + 2 * ShowAddress + ShowPhone;//得到信息公开数据 member.SecretShow = IsShow; if (ModelState.IsValid) { //EF修改主键一定要加 string[] proNames = new string[] {"StuNum","StuName", "Gender", "QQNum","Email","Birthday" , "Class", "Major","Counselor","HeadTeacher", "UndergraduateTutor", "TelephoneNumber", "HomPhoneNumber", "FamilyAddress", "Department", "TechnicalLevel", "StudyGuideNumber", "Sign", "OtheInfor", "SecretShow"}; int IsSuccess= OperateContext.Current.BLLSession.IMemberInformationBLL.Modify(member, proNames); if (IsSuccess > 0) return Content("<script>alert('修改成功');window.location='/PersonalManger/CheckMember/PersonPage?StuNum=" + member.StuNum + "'</script>"); else { return Content("<script>alert('修改失败');window.location='/PersonalManger/CheckMember/PageEdit?StuNum=" + member.StuNum + "'</script>"); } } else { return Content("<script>alert('修改失败');window.location='/PersonalManger/CheckMember/PageEdit?StuNum=" + member.StuNum + "'</script>"); } }
/// <summary> /// 登陆成功进入主页 /// </summary> /// <returns></returns> public ActionResult MainPage() { ViewBag.name = OperateContext.Current.Usr.StuName; //在这个地方进行人员角色的更新 string dtone; string dttwo; string dtthree; string dtfour; DateTime dt = DateTime.Now; if (dt.Month == 7) { dtone = dt.Year.ToString(); dttwo = (dt.Year - 1).ToString(); dtthree = (dt.Year - 2).ToString(); dtfour = (dt.Year - 3).ToString(); //1.将所有退役人员设置为毕业人员 List <MODEL.T_RoleAct> rolelist = new List <MODEL.T_RoleAct>(); rolelist = OperateContext.Current.BLLSession.IRoleActBLL.GetListBy(u => u.RoleId == 10012).ToList(); OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u => u.RoleId == 10012); foreach (MODEL.T_RoleAct ra in rolelist) { ra.RoleId = 10011; OperateContext.Current.BLLSession.IRoleActBLL.Add(ra); } //2.所有大四成员角色设置为退役人员 List <string> numlist = new List <string>(); numlist = OperateContext.Current.BLLSession.IRoleActBLL.GetListBy(u => u.RoleActor.Contains(dtfour)).Select(p => p.RoleActor).ToList(); OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u => u.RoleActor.Contains(dtfour)); MODEL.T_RoleAct ro; foreach (string stunum in numlist) { ro = new MODEL.T_RoleAct(); ro.RoleId = 10012; ro.RoleActor = stunum; ro.IsDel = false; OperateContext.Current.BLLSession.IRoleActBLL.Add(ro); } } return(View()); }
public ActionResult MainPage() { ViewBag.name = OperateContext.Current.Usr.StuName; //在这个地方进行人员角色的更新 string dtone; string dttwo; string dtthree; string dtfour; DateTime dt = DateTime.Now; if (dt.Month == 7) { dtone = dt.Year.ToString(); dttwo = (dt.Year - 1).ToString(); dtthree = (dt.Year - 2).ToString(); dtfour = (dt.Year - 3).ToString(); //1.将所有退役人员设置为毕业人员 List<MODEL.T_RoleAct> rolelist=new List<MODEL.T_RoleAct>(); rolelist=OperateContext.Current.BLLSession.IRoleActBLL.GetListBy(u=>u.RoleId==10012).ToList(); OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u=>u.RoleId==10012); foreach(MODEL.T_RoleAct ra in rolelist){ ra.RoleId=10011; OperateContext.Current.BLLSession.IRoleActBLL.Add(ra); } //2.所有大四成员角色设置为退役人员 List<string> numlist=new List<string>(); numlist=OperateContext.Current.BLLSession.IRoleActBLL.GetListBy(u=>u.RoleActor.Contains(dtfour)).Select(p=>p.RoleActor).ToList(); OperateContext.Current.BLLSession.IRoleActBLL.DelBy(u=>u.RoleActor.Contains(dtfour)); MODEL.T_RoleAct ro; foreach(string stunum in numlist) { ro=new MODEL.T_RoleAct(); ro.RoleId=10012; ro.RoleActor=stunum; ro.IsDel=false; OperateContext.Current.BLLSession.IRoleActBLL.Add(ro); } } return View(); }
public ActionResult BatchAdd(HttpPostedFileBase filebase) { HttpPostedFileBase file = Request.Files["files"]; string FileName; string savePath; if (file == null || file.ContentLength <= 0) { ViewBag.error = "文件不能为空"; return Redirect("/PersonalManger/CheckMember/AddStu"); } else { string filename = Path.GetFileName(file.FileName); int filesize = file.ContentLength;//获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(filename);//获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(filename);//获取无扩展文件名 int MaxSize = 8000 * 1024;//定义上传文件的最大空间大小为8M string FileType = ".xls,.xlsx";//定义上传文件的类型字符串 FileName = NoFileName+ fileEx; if (!FileType.Contains(fileEx)) { ViewBag.error = "文件类型不对,只能导入xls和xlsx格式的文件"; return Redirect("/PersonalManger/CheckMember/AddStu"); } if (filesize >= MaxSize) { ViewBag.error = "上传文件超过8M,请小于8M"; return Redirect("/PersonalManger/CheckMember/AddStu"); } string path = AppDomain.CurrentDomain.BaseDirectory + "Excel\\"; savePath = Path.Combine(path, FileName); file.SaveAs(savePath); } FileStream fs = new FileStream(savePath,FileMode.Open, FileAccess.ReadWrite, FileShare.None);//创建文件流 DataTable dt = new XlsStreamToDT(fs, 15).Xls2DT(); using (var scope = new TransactionScope()) { MODEL.T_MemberInformation member; for (int i = 1; i <dt.Rows.Count; i++) { member = new MODEL.T_MemberInformation(); member.StuNum = dt.Rows[i][0].ToString();//获取学号 member.StuName = dt.Rows[i][1].ToString();//获取姓名 member.LoginPwd = dt.Rows[i][2].ToString();//获取初始密码 member.QQNum = "1"; member.Email = "*****@*****.**"; member.PhotoPath = "../../HeadImg/final.png"; member.JoinTime = DateTime.Now; member.Department = 10007; member.TechnicalLevel = 10003; member.IsAdmin = false; member.IsDelete = false; member.SecretShow = 7; OperateContext.Current.BLLSession.IMemberInformationBLL.Add(member); MODEL.T_OgnizationAct OrganizationAct = new MODEL.T_OgnizationAct() { OrganizationId =10004 , RoleActor =member.StuNum,IsDel = false }; OperateContext.Current.BLLSession.IOgnizationActBLL.Add(OrganizationAct); //对每一个新成员赋予实习生的角色 MODEL.T_RoleAct ra = new MODEL.T_RoleAct(); ra.RoleId = 10009; ra.RoleActor = member.StuNum; ra.IsDel = false; OperateContext.Current.BLLSession.IRoleActBLL.Add(ra); } scope.Complete(); } //删除掉存储在网站目录下的文件 //事实上,调用File.Delete并没有删除文件,它只是让操作系统认为文件不存在, //文件在磁盘上的空间被标记成空的,以便用于再次使用。但是文件的数据没有被移除,您可以非常容易恢复。 //被删除的文件直到相应的空间被重写才会真消失,这也许要很长时间。 if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } return Content("<script>alert('批量新增成功!');window.location='/PersonalManger/CheckMember/Index';</script>"); }
public bool DelPosition(List<MODEL.T_MemberInformation> memList, int roleId) { MODEL.T_RoleAct roleAct; int count = 0; foreach (MODEL.T_MemberInformation mem in memList) { //开始删除数据 roleAct = new MODEL.T_RoleAct(); roleAct.RoleId = roleId; roleAct.RoleActor = mem.StuNum; roleAct.IsDel = false; if (OperateContext.Current.BLLSession.IRoleActBLL.Del(roleAct) > 0) { count++; } } if (count > 0) return true; else return false; }
public ActionResult BatchAdd(HttpPostedFileBase filebase) { HttpPostedFileBase file = Request.Files["files"]; string FileName; string savePath; if (file == null || file.ContentLength <= 0) { return(Content("<script>alert('文件不能为空!');window.location='/PersonalManger/CheckMember/AddStu';</script>")); } else { string filename = Path.GetFileName(file.FileName); int filesize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = Path.GetExtension(filename); //获取上传文件的扩展名 string NoFileName = Path.GetFileNameWithoutExtension(filename); //获取无扩展文件名 int MaxSize = 8000 * 1024; //定义上传文件的最大空间大小为8M string FileType = ".xls,.xlsx"; //定义上传文件的类型字符串 FileName = NoFileName + fileEx; if (!FileType.Contains(fileEx)) { return(Content("<script>alert('文件类型不对,只能导入xls和xlsx格式的文件!');window.location='/PersonalManger/CheckMember/AddStu';</script>")); } if (filesize >= MaxSize) { return(Content("<script>alert('上传文件超过8M,请小于8M!');window.location='/PersonalManger/CheckMember/AddStu';</script>")); } string path = AppDomain.CurrentDomain.BaseDirectory + "Excel\\"; savePath = Path.Combine(path, FileName); file.SaveAs(savePath); } FileStream fs = new FileStream(savePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None);//创建文件流 DataTable dt = new XlsStreamToDT(fs, 15).Xls2DT(); using (var scope = new TransactionScope()) { MODEL.T_MemberInformation member; for (int i = 1; i < dt.Rows.Count; i++) { member = new MODEL.T_MemberInformation(); member.StuNum = dt.Rows[i][0].ToString(); //获取学号 member.StuName = dt.Rows[i][1].ToString(); //获取姓名 member.LoginPwd = dt.Rows[i][2].ToString(); //获取初始密码 member.QQNum = "1"; member.Email = "*****@*****.**"; member.PhotoPath = "../../HeadImg/final.png"; member.JoinTime = DateTime.Now; member.Department = 10007; member.TechnicalLevel = 10003; member.IsAdmin = false; member.IsDelete = false; member.SecretShow = 7; OperateContext.Current.BLLSession.IMemberInformationBLL.Add(member); MODEL.T_OgnizationAct OrganizationAct = new MODEL.T_OgnizationAct() { OrganizationId = 10004, RoleActor = member.StuNum, IsDel = false }; OperateContext.Current.BLLSession.IOgnizationActBLL.Add(OrganizationAct); //对每一个新成员赋予实习生的角色 MODEL.T_RoleAct ra = new MODEL.T_RoleAct(); ra.RoleId = 10009; ra.RoleActor = member.StuNum; ra.IsDel = false; OperateContext.Current.BLLSession.IRoleActBLL.Add(ra); } scope.Complete(); } //删除掉存储在网站目录下的文件 //事实上,调用File.Delete并没有删除文件,它只是让操作系统认为文件不存在, //文件在磁盘上的空间被标记成空的,以便用于再次使用。但是文件的数据没有被移除,您可以非常容易恢复。 //被删除的文件直到相应的空间被重写才会真消失,这也许要很长时间。 if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } return(Content("<script>alert('批量新增成功!');window.location='/PersonalManger/CheckMember/Index';</script>")); }