/// <summary> /// 搜索 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnserach_Click(object sender, EventArgs e) { if(string.IsNullOrEmpty(tbUserName.Text.Trim())) { //Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"","<script type='text/javascript'>alert('请输入要搜索的用户名');</script>"); Common.JShelper.JSAlert(this.Page, "", "请输入要搜索的用户名!"); tbUserName.Focus(); } else { string str = "UserName like '%" + tbUserName.Text.Trim() + "%'"; LabMS.BLL.UserTable BUT = new LabMS.BLL.UserTable(); DataSet ds = BUT.GetList(str); ds = HandleDataSet(ds); gvRole.DataSource = ds.Tables[0].DefaultView; gvRole.DataBind(); } }
/// <summary> /// 根据RoleId查找出所有拥有该角色的用户 /// </summary> /// <param name="RoleId"></param> /// <returns></returns> public DataSet GetUserInfoByRoleID(int RoleId) { LabMS.BLL.UserRole BUR = new LabMS.BLL.UserRole(); List<LabMS.Model.UserRole> list = new List<LabMS.Model.UserRole>(); string str = "RoleID=" + RoleId; list = BUR.GetModelList(str); LabMS.BLL.UserTable BUserTable = new LabMS.BLL.UserTable(); DataSet ds = new DataSet(); int UserID; string strsql = ""; if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { UserID = int.Parse(list[i].UserID.Value.ToString()); if (i == list.Count - 1) { strsql += " UserID=" + UserID; } else { strsql += " UserID=" + UserID + " or "; } } } else { throw(new Exception("2"));//没有用户拥有该角色 } ds=BUserTable.GetList(strsql); return ds; }