/// <summary> /// 导师DDL /// </summary> /// <param name="dropDownList"></param> public static void TeacherDLL(DropDownList dropDownList, string major_id = null) { dropDownList.Items.Clear(); var bll = new BLL.t_teacher(); var model = major_id == null?bll.GetModelList("teacher_stat=0 AND teacher_type=0") : bll.GetModelList("teacher_stat=0 AND teacher_type=0 AND teacher_major_id='" + major_id + "'"); foreach (var item in model) { dropDownList.Items.Add(new ListItem(item.teacher_name, item.teacher_gh)); } }
protected void Page_Load(object sender, EventArgs e) { var msg = new BLL.Message(); if (Session["login_name"] == null) { Response.Write("请先<a href='/'>登录</a>"); Response.End(); } if (Request["pwd"] != null) { if (Request["pwd"].Length < 6) { msg.Msg = "密码长度必须大于等于6个字符!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } try { string pwd = BLL.Utils.HashPasswd(Request["pwd"]); // 预先加密 switch (Session["type"].ToString()) { case "admin": var bll_admin = new BLL.t_admin(); var admin = bll_admin.GetModel(Session["login_name"].ToString()); admin.pwd = pwd; msg.Msg = (bll_admin.Update(admin)) ? "修改密码成功!" : "发生错误!"; break; case "student": var bll_student = new BLL.t_student(); var student = bll_student.GetModel(Session["login_name"].ToString()); student.student_pwd = pwd; msg.Msg = (bll_student.Update(student)) ? "修改密码成功!" : "发生错误!"; break; case "teacher": var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(Session["login_name"].ToString()); teacher.teacher_pwd = pwd; msg.Msg = (bll_teacher.Update(teacher)) ? "修改密码成功!" : "发生错误!"; break; case "mteacher": goto case "teacher"; //直接调用teacher块 } if (msg.Msg.Equals("修改密码成功!")) { /// 写入日志 BLL.Utils.Log(this, "修改密码"); // 注销登录 Session.Clear(); msg.Body = "/"; } } finally { Response.Write(BLL.Utils.toJson(msg)); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["login_name"] != null && Request["pwd"] != null && Request["type"] != null) { var msg = new BLL.Message(); /// 验证输入长度 if (Request["login_name"].Length < 3 || Request["pwd"].Length < 6 || Request["login_name"].Length > 32 || Request["pwd"].Length > 16) { msg.Msg = "数据输入有误!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } /// 构建日志Model Model.t_log log = new Model.t_log { log_ip = Request.UserHostAddress, user_name = Request["login_name"], }; try { string url = null; var login_name = Request["login_name"]; var pwd = Request["pwd"]; var type = Request["type"]; /// 登录验证 if (BLL.Utils.Login(login_name, pwd, type)) { // 登录成功 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = null; // 显示名称(姓名) Session["role"] = 0; // 为了方便母版页判断权限和修改菜单,特设此变量,值越小权限越低:1学生,2导师,3教研室主任,4教务管理员 /// 获取附加信息 var bll_major = new BLL.t_major(); // 专业 switch (type) { #region 教务管理员登录 case "admin": Session["role"] = 4; var bll_admin = new BLL.t_admin(); var admin = bll_admin.GetModel(login_name); Session["user_name"] = admin.user_name; url = "/admin/"; break; #endregion 教务管理员登录 #region 教务室主任登录 case "mteacher": Session["role"] = 3; var bll_mteacher = new BLL.t_teacher(); var mteacher = bll_mteacher.GetModel(login_name); /// 获取专业信息 Session["major_id"] = mteacher.teacher_major_id; /// 获取系别信息 Session["dept_id"] = mteacher.teacher_dept_id; Session["user_name"] = mteacher.teacher_name; url = "/admin/"; break; #endregion 教务室主任登录 #region 导师登录 case "teacher": Session["role"] = 2; var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(login_name); /// 获取专业信息 Session["major_id"] = teacher.teacher_major_id; /// 获取系别信息 Session["dept_id"] = teacher.teacher_dept_id; Session["user_name"] = teacher.teacher_name; url = "/topic/"; break; #endregion 导师登录 #region 学生登录 case "student": //学生 Session["role"] = 1; var bll_student = new BLL.t_student(); var student = bll_student.GetModel(login_name); Session["user_name"] = student.student_name; Session["class_id"] = student.student_class_id; /// 获取班级信息 var bll_class = new BLL.t_class(); var myclass = bll_class.GetModel(student.student_class_id); /// 获取专业信息 var major = bll_major.GetModel(myclass.class_major_id); Session["major_id"] = major.major_id; /// 获取系别信息 Session["dept_id"] = major.major_dept_id; url = "/select/list.aspx"; break; #endregion 学生登录 } msg.Msg = log.log_info = "登录成功!"; } else { // 登录失败 log.log_info = msg.Msg = "用户名或密码错误!"; } if (url != null) { msg.Body = (url); } } catch { msg.Msg = "发生错误!"; } var bll_log = new BLL.t_log(); bll_log.Add(log); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } else { BLL.Utils.ShowMessage(this, "输入有误!"); } }
/// <summary> /// 登录 /// </summary> /// <param name="login_name">登录名</param> /// <param name="pwd">密码</param> /// <param name="type">类型:student,admin,mteacher,teacher /// 默认student</param> /// <returns></returns> public static bool Login(string login_name, string pwd, string type = "student") { switch (type) { #region 学生登录 case "student": //学生 var bll_student = new BLL.t_student(); var student = bll_student.GetModel(login_name); if (student == null || (!student.student_stat.Equals(0))) { return(false); } if (!chkPasswd(pwd, student.student_pwd)) { return(false); } break; #endregion 学生登录 #region 教务管理员登录 case "admin": var bll_admin = new BLL.t_admin(); var admin = bll_admin.GetModel(login_name); if (admin == null || (!admin.user_stat.Equals(0))) { return(false); } if (!chkPasswd(pwd, admin.pwd)) { return(false); } break; #endregion 教务管理员登录 #region 教务室主任登录 case "mteacher": var bll_mteacher = new BLL.t_teacher(); var mteacher = bll_mteacher.GetModel(login_name); if (mteacher == null || (!mteacher.teacher_stat.Equals(0))) { return(false); } if (!mteacher.teacher_type.Equals(1)) { return(false); } if (!chkPasswd(pwd, mteacher.teacher_pwd)) { return(false); } break; #endregion 教务室主任登录 #region 导师登录 case "teacher": var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(login_name); if (teacher == null || (!teacher.teacher_stat.Equals(0))) { return(false); } if (!teacher.teacher_type.Equals(0)) { return(false); } if (!chkPasswd(pwd, teacher.teacher_pwd)) { return(false); } break; #endregion 导师登录 } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (Request["type"] != null) { var msg = new BLL.Message(); try { string type = Request["type"].ToLower(); /// 判断是获取还是设置 if (type.Equals("update")) { /// 设置 string my_q = Request["my_q"].ToString(); string my_a = Request["my_a"].ToString(); switch (Session["type"].ToString()) { case "student": var bll_student = new BLL.t_student(); var student = bll_student.GetModel(Session["login_name"].ToString()); student.student_pwd_a = my_a; student.student_pwd_q = my_q; msg.Msg = (bll_student.Update(student)) ? "修改密保成功!" : "修改密保失败!"; break; case "teacher": var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(Session["login_name"].ToString()); teacher.teacher_pwd_q = my_q; teacher.teacher_pwd_a = my_a; msg.Msg = (bll_teacher.Update(teacher)) ? "修改密保成功!" : "修改密保失败!"; break; } } else { switch (Session["type"].ToString()) { case "student": var bll_student = new BLL.t_student(); var student = bll_student.GetModel(Session["login_name"].ToString()); msg.Body = student; msg.Code = 1; //标注学生 break; case "teacher": var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(Session["login_name"].ToString()); msg.Body = teacher; msg.Code = 2; //标注教师 break; } } } finally { /// 写入日志 BLL.Utils.Log(this, "修改密保问题"); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["login_name"] != null && Request["type"] != null) { var msg = new BLL.Message(); try { /// 设置重试次数上限 if (Session["try"] == null) { Session["try"] = 0; } else { Session["try"] = int.Parse(Session["try"].ToString()) + 1; } if (Session["try"].Equals(10)) { msg.Msg = "重试次数已超过10次,系统拒绝操作!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } string type = Request["type"].ToLower(); string login_name = Request["login_name"]; string my_a = Request["a"] == null ? null : Request["a"]; switch (type) { case "student": var bll_student = new BLL.t_student(); var model = bll_student.GetModel(login_name); if (model == null) { msg.Msg = "该学生不存在!"; } else if (!model.student_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else if (model.student_pwd_q == null || model.student_pwd_q.Length < 1) { msg.Msg = "未设置密保问题,无法通过密保重置密码!"; } else { msg.Body = model.student_pwd_q; } if (my_a != null && model.student_pwd_a.Equals(my_a)) { /// 登录系统 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = model.student_name; // 显示名称(姓名) msg.Body = "/ChagePassword.aspx"; } else if (my_a != null && (!model.student_pwd_a.Equals(my_a))) { msg.Msg = "密保答案错误!"; msg.Body = null; } break; case "teacher": var bll_teachert = new BLL.t_teacher(); var model2 = bll_teachert.GetModel(login_name); if (model2 == null) { msg.Msg = "该导师不存在!"; } else if (!model2.teacher_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else if (!model2.teacher_type.Equals(0)) { msg.Msg = "教研室主任请联系教务管理员重置密码!"; } else if (model2.teacher_pwd_q == null || model2.teacher_pwd_q.Length < 1) { msg.Msg = "未设置密保问题,无法通过密保重置密码!"; } else { msg.Body = model2.teacher_pwd_q; } if (my_a != null && model2.teacher_pwd_a.Equals(my_a)) { /// 登录系统 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = model2.teacher_name; // 显示名称(姓名) msg.Body = "/ChagePassword.aspx"; } else if (my_a != null && (!model2.teacher_pwd_a.Equals(my_a))) { msg.Msg = "密保答案错误!"; msg.Body = null; } break; } } finally { /// 写入日志 var log = new Model.t_log { log_info = "通过密保问题重置密码", log_ip = Request.UserHostAddress, user_name = Request["login_name"], }; BLL.Utils.Log(log); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { var msg = new BLL.Message(); if (!Session["type"].Equals("admin")) { BLL.Utils.ShowMessage(this, "该功能仅教务管理员可用!"); Response.End(); } /// 校验角色 if (Request["login_name"] != null && Request["type"] != null) { try { string type = Request["type"].ToLower(); string login_name = Request["login_name"]; string pwd = null; if (Request["pwd"] != null) { if (Request["pwd"].Length < 6 || Request["pwd"].Length > 32) { msg.Msg = "密码长度必须大于5个字符小于32个字符!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } else { pwd = BLL.Utils.HashPasswd(Request["pwd"]); // 预先加密 } } switch (type) { case "student": var bll_student = new BLL.t_student(); var model = bll_student.GetModel(login_name); if (model == null) { msg.Msg = "该学生不存在!"; } else if (!model.student_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else { msg.Code = 1; } if (pwd != null) { model.student_pwd = pwd; msg.Msg = (bll_student.Update(model)) ? "修改密码成功!" : "修改密码失败!"; } break; case "teacher": var bll_teachert = new BLL.t_teacher(); var model2 = bll_teachert.GetModel(login_name); if (model2 == null) { msg.Msg = "该导师或教研室主任不存在!"; } else if (!model2.teacher_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else { msg.Code = 1; } if (pwd != null) { model2.teacher_pwd = pwd; msg.Msg = (bll_teachert.Update(model2)) ? "修改密码成功!" : "修改密码失败!"; } break; } } finally { /// 写入日志 BLL.Utils.Log(this, "重置密码:" + Request["login_name"]); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } } }