private void ShowDepartments() { List <int> depts; if ("" == hidDepartment.Value) { depts = DepartmentInstance.GetAllDepartments(); } else { depts = DepartmentInstance.GetSubdepartments(ParseInt(hidDepartment.Value)); } var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); var list = DepartmentInstance.FindPageList <TB_Department>(pageIndex, PageSize, out totalRecords, f => f.Delete == false && (f.Name.IndexOf(txtName.Value.Trim()) >= 0) && depts.Contains(f.id), "Parent,Name"); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"10\">No records, You can change the condition and try again or " + " <a href=\"./department_add.aspx\">ADD</a> new one.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; foreach (var obj in list) { cnt++; var users = AccountInstance.FindList(f => f.Department == obj.id).Count(); var upper = 0 == obj.Parent ? null : DepartmentInstance.Find(f => f.id == obj.Parent); var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString())); html += "<tr>" + "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" + "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" + "<td><a href=\"./department_add.aspx?key=" + id + "\" >" + obj.Name + "</a></td>" + "<td>" + obj.Phone + "</td>" + "<td>" + obj.Fax + "</td>" + "<td>" + (obj.IsDefault == true ? "Yes" : "-") + "</td>" + "<td><a href=\"#d" + (null == upper ? "" : upper.id.ToString()) + "\" >" + (null == upper ? "" : upper.Name) + "</a></td>" + "<td>" + (0 == users ? "0" : ("<a href=\"./account_list.aspx?key=" + Utility.UrlEncode(Utility.Encrypt("d," + obj.id.ToString())) + "\" >" + users + "</a>")) + "</td>" + "<td>" + obj.Room + "</td>" + "<td>" + obj.Address + "</td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./department_list.aspx", divPagging); } }
private void ShowAccountList() { // 部门id列表 var depts = "" != hidDepartment.Value ? (DepartmentInstance.GetSubdepartments(ParseInt(hidDepartment.Value))) : (DepartmentInstance.GetAllDepartments()); // 角色列表 List <int> roles; if ("" != hidRole.Value) { roles = new List <int>(); roles.Add(ParseInt(hidRole.Value)); } else { roles = RoleInstance.GetAllRole(); } var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); var list = AccountInstance.FindPageList <TB_Account>(pageIndex, PageSize, out totalRecords, f => (f.Name.IndexOf(txtName.Value.Trim()) >= 0) && (roles.Contains(f.Role.Value) || f.Role == (int?)null) && (depts.Contains(f.Department.Value) || f.Department == (int?)null) && f.Delete == false, "Name"); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"12\">No records, You can change the condition and try again or " + " <a href=\"./account_add.aspx\">ADD</a> new one.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; foreach (var obj in list) { cnt++; var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString())); html += "<tr " + (obj.Locked == true ? "style=\"color: red;\"" : "") + ">" + "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" + "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" + "<td style=\"width: 60px;\"><a href=\"./account_add.aspx?key=" + id + "\" >" + obj.Name + "</a></td>" + "<td style=\"width: 60px;\">" + obj.Code + "</td>" + "<td style=\"width: 80px;\">" + obj.RegisterTime.Value.ToString("yyyy-MM-dd") + "</td>" + "<td style=\"width: 50px;\">" + (obj.Locked == true ? "Locked" : "Normal") + "</td>" + "<td>" + ("<a href=\"#d" + (null == obj.Department ? "" : obj.Department.ToString()) + "\" >" + (null == obj.Department ? "-" : obj.TB_Department.Name) + "</a>") + "</td>" + "<td>" + ("<a href=\"#r" + (null == obj.Role ? "" : obj.Role.ToString()) + "\" >" + (null == obj.Role ? "-" : obj.TB_Role.Name) + "</a>") + "</td>" + "<td>" + obj.LoginTimes.ToString() + "</td>" + "<td>" + (null == obj.LastLoginTime ? "never" : obj.LastLoginTime.Value.ToString("yyyy-MM-dd HH:mm:ss")) + "</td>" + "<td>" + obj.LastLoginIp + "</td>" + "<td></td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./account_list.aspx", divPagging); } }