public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string psw = context.Request.Params["Password"].ToString(); string usercode = context.Request.Params["UserCode"].ToString(); string usertype = context.Request.Params["UserType"].ToString(); string returnvalue=""; if (usertype == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); List<LabMS.Model.UserTable> userTableModelList = new List<LabMS.Model.UserTable>(); userTableModelList = userTable.GetModelList("Password='******' and PCode='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } else if (usertype == "student") { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); List<LabMS.Model.Student> userTableModelList = new List<LabMS.Model.Student>(); userTableModelList = userTable.GetModelList("Student_Pass='******' and Student_Code='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } if (usertype == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); List<LabMS.Model.Teacher> userTableModelList = new List<LabMS.Model.Teacher>(); userTableModelList = userTable.GetModelList("Password='******' and Teacher_Code='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } context.Response.Write(returnvalue); }
/// <summary> /// 根据UserID找出已经赋给此用户的角色信息 /// </summary> /// <param name="UserID"></param> /// <returns></returns> public List<LabMS.Model.RoleTable> GetUserRoleByUserID(int UserID) { LabMS.BLL.UserRole BUR = new LabMS.BLL.UserRole(); List<LabMS.Model.UserRole> listMUR = new List<LabMS.Model.UserRole>(); #region 用户是否存在 string str1 = "UserID="+UserID; LabMS.BLL.UserTable BUT = new LabMS.BLL.UserTable(); List<LabMS.Model.UserTable> list = new List<LabMS.Model.UserTable>(); list = BUT.GetModelList(str1); if (list.Count == 0) { throw(new Exception("1"));//用户不存在 } #endregion #region 用户是否有角色 string str = "UserID="+UserID; listMUR=BUR.GetModelList(str);//在UserRole表中找出RoleID if (listMUR.Count == 0) { throw(new Exception("2"));//用户没有对应角色 } #endregion LabMS.BLL.RoleTable BRT = new LabMS.BLL.RoleTable(); List<LabMS.Model.RoleTable> listMRT = new List<LabMS.Model.RoleTable>(); int RoleID; string sqlstr = ""; for (int i = 0; i < listMUR.Count; i++) { RoleID =int.Parse(listMUR[i].RoleID.Value.ToString()); if (i == listMUR.Count - 1) { sqlstr += " RoleId=" + RoleID; } else { sqlstr += " RoleId="+RoleID+" or "; } } listMRT = BRT.GetModelList(sqlstr); return listMRT; }
public bool IsExistUserName(string UserName) { string str = "UserName='******'"; int count; bool success = false; LabMS.BLL.UserTable BUT = new LabMS.BLL.UserTable(); count=BUT.GetModelList(str).Count; if (count > 0) { //已经存在 success = false; } else { //不存在,可以注册 success = true; } return success; }
private bool IsUserNameAndPassword() { if (UserType == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); List<LabMS.Model.UserTable> userTableModelList = new List<LabMS.Model.UserTable>(); userTableModelList = userTable.GetModelList("Password='******' and PCode='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } else if (UserType == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); List<LabMS.Model.Teacher> userTableModelList = new List<LabMS.Model.Teacher>(); userTableModelList = userTable.GetModelList("Password='******' and Teacher_Code='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } else { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); List<LabMS.Model.Student> userTableModelList = new List<LabMS.Model.Student>(); userTableModelList = userTable.GetModelList("Student_Pass='******' and Student_Code='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } }
/// <summary> /// 根据用户ID获得用户列表信息 /// </summary> /// <param name="Userid"></param> /// <returns></returns> public List<LabMS.Model.UserTable> GetUserTableByUserID(int Userid) { LabMS.BLL.UserTable But = new LabMS.BLL.UserTable(); return But.GetModelList("UserID="+Userid); }