/// <summary> /// 根据角色名称查找角色的ID /// </summary> /// <param name="RoleName"></param> /// <returns></returns> public static int Find(String RoleName) { #region 输入合法性检测 if (string.IsNullOrEmpty(RoleName)) { return(0); } #endregion #region 把得到数据组装成类的实例 DataTable dt = DAL.Role.QueryOne(RoleName); if (dt.Rows.Count > 0) { Models.DB.Role role = new Models.DB.Role(); role.ID = Convert.ToInt32(dt.Rows[0]["ID"]); role.Name = dt.Rows[0]["Name"].ToString(); role.RoleValue = dt.Rows[0]["RoleValue"].ToString(); role.Enable = Convert.ToBoolean(dt.Rows[0]["Enable"]); role.RoleModelID = Convert.ToInt32(dt.Rows[0]["RoleModelID"]); return(role.ID); } #endregion return(0); }
private void accessControl() { if (Session["user"] == null || Session["role"] == null) { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } String UserID = Session["user"].ToString(); String RoleID = Session["role"].ToString(); LoginRole = BLL.Role.SelectRoleOne(Convert.ToInt32(RoleID)); LoginAdmin = BLL.AdminModel.SelectAdminModelByUserID(UserID); }
/// <summary> /// 根据ID获取一条信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public static Models.DB.Role SelectRoleOne(int ID) { Models.DB.Role Role = new Models.DB.Role(); System.Data.DataTable dt = DAL.Select.GetOne("Tb_Role", ID); if (dt.Rows.Count > 0) { Role.ID = Convert.ToInt32(dt.Rows[0]["ID"]); Role.Name = dt.Rows[0]["Name"].ToString(); Role.RoleValue = dt.Rows[0]["RoleValue"].ToString(); Role.Enable = Convert.ToBoolean(dt.Rows[0]["Enable"]); Role.RoleModelID = Convert.ToInt32(dt.Rows[0]["RoleModelID"]); } return(Role); }
private void accessControl() { if (Session["user"] == null || Session["role"] == null) { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } String UserID = Session["user"].ToString(); String RoleID = Session["role"].ToString(); LoginRole = BLL.Role.SelectRoleOne(Convert.ToInt32(RoleID)); /***********非管理员角色跳出*************/ if (!(LoginRole.Name == "ScauAdmin" || LoginRole.Name == "CollegeAdmin")) { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } }
private void accessControl() { if (Session["user"] == null || Session["role"] == null) { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } UserID = Session["user"].ToString(); RoleID = Session["role"].ToString(); LoginRole = BLL.Role.SelectRoleOne(Convert.ToInt32(RoleID)); /**********非评委角色跳出********************/ if (LoginRole.Name != "Student") { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } }
protected void Page_Load(object sender, EventArgs e) { accessControl(); if (Request["edit"] == null) { Response.Redirect("Default.aspx"); return; } try { int Id = Convert.ToInt32(Request["edit"]); Admin = BLL.AdminModel.SelectAdminModelOne(Id); user = BLL.User.SelectUserOne(Admin.UserId); Role = BLL.Role.SelectRoleOne(user.RoleId); initRoles(); } catch { Response.Redirect("Default.aspx"); } }
/// <summary> /// 根据模型Id,获取记录 /// </summary> /// <param name="RoleModelID"></param> /// <returns></returns> public static List <Models.DB.Role> SelectRole(int RoleModelID) { List <Models.DB.Role> Roles = new List <Models.DB.Role>(); Models.DB.Role Role = new Models.DB.Role(); Role.RoleModelID = RoleModelID; System.Data.DataTable dt = DAL.Select.GetList(Role, "RoleModelID"); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Role = new Models.DB.Role(); Role.ID = Convert.ToInt32(dt.Rows[i]["ID"]); Role.Name = dt.Rows[i]["Name"].ToString(); Role.RoleValue = dt.Rows[i]["RoleValue"].ToString(); Role.Enable = Convert.ToBoolean(dt.Rows[i]["Enable"]); Role.RoleModelID = Convert.ToInt32(dt.Rows[i]["RoleModelID"]); Roles.Add(Role); } } return(Roles); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string dowhat = context.Request["dowhat"]; if (dowhat == null) { dowhat = ""; } #region 登录 if (dowhat == "login") { string UserName = context.Request["UserName"]; string Password = context.Request["Password"]; Password = Utility.Tool.MD5(Password); Models.DB.User user = BLL.User.Find(UserName, Password); if (user.Enable == false) { context.Response.Write("EnableFalse"); context.Response.End(); return; } if (user != null) { context.Session["user"] = user.ID; context.Session["role"] = user.RoleId; Models.DB.Role role = BLL.Role.SelectRoleOne(user.RoleId); if (role != null) { context.Response.Write(role.Name); context.Response.End(); return; } else { context.Response.Write("faild"); context.Response.End(); return; } // context.Response.Write("success"); } else { context.Response.Write("faild"); } context.Response.End(); return; } #endregion #region 注册 if (dowhat == "register") { String UserName = context.Request["UserName"]; String Password = context.Request["Password"]; Password = Utility.Tool.MD5(Password); String StudentID = context.Request["StudentID"]; String Name = context.Request["Name"]; String Sex = context.Request["Sex"]; String InTimeYear = context.Request["InTimeYear"]; String School = context.Request["School"]; String College = context.Request["College"]; String Major = context.Request["Major"]; String Mail = context.Request["Mail"]; int RoleID = BLL.Role.Find("Student"); if (RoleID == 0) { return; } if (BLL.User.Find(UserName) != null) { context.Response.Write("USEREXIST"); context.Response.End(); return; } if (BLL.StudentInfoModel.FindByString(StudentID, "StudentID").Count > 0) { context.Response.Write("STUDENTEXIST"); context.Response.End(); return; } int UserID = BLL.User.CreateUser(UserName, Password, RoleID, "False"); if (UserID > 0) { if (BLL.Create.CreateStudentModelInfo(StudentID, Name, Sex, Major, InTimeYear, School, College, Mail, UserID) > 0) { context.Response.Write("success"); } else { BLL.Delete.Word("Tb_User", UserID.ToString()); context.Response.Write("faild"); } } else { context.Response.Write("faild"); } context.Response.End(); return; } #endregion }