Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 显示指定部门的所有用户列表
        /// </summary>
        /// <param name="node"></param>
        /// <param name="parent"></param>
        protected void ShowDepartmentUsersInTreeView(TreeNode node, int parent)
        {
            var users = AccountInstance.FindList(f => f.Department == parent).OrderBy(o => o.Name);

            foreach (var user in users)
            {
                node.ChildNodes.Add(new TreeNode
                {
                    Text         = user.Name,
                    ShowCheckBox = true,
                    SelectAction = TreeNodeSelectAction.Expand,
                    NavigateUrl  = "#" + user.id
                });
            }
        }
Esempio n. 3
0
        private void ShowRoles()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = RoleInstance.FindPageList <TB_Role>(pageIndex, PageSize, out totalRecords,
                                                                   p => p.Delete == false && p.Name.IndexOf(txtName.Value.Trim()) >= 0, "Name");
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);
            //list = list.OrderBy(o => o.IsAdministrator).ThenBy(t => t.IsDefault).ThenBy(t => t.AddTime);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"8\">No records, you can change condition and try again, or " +
                       " <a href=\"./role_add.aspx\">Add</a> some new role.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    var users = AccountInstance.FindList(f => f.Role == obj.id).Count();
                    var id    = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            // 系统默认角色无法删除
                            "<td style=\"width: 40px; text-align: center;\">" + (obj.IsDefault.Value ? "" :
                                                                                 ("<input type=\"checkbox\" id=\"cb_" + id + "\" />")) + "</td>" +
                            "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" +
                            "<td><a href=\"./role_add.aspx?key=" + id + "\" title=\"click to edit\">" + ("" == obj.Name ? "-" : obj.Name) + "</a></td>" +
                            "<td>" + (obj.IsDefault.Value ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsAdministrator.Value ? "Yes" : "-") + "</td>" +
                            "<td>" + (users > 0 ? ("<a href=\"./account_list.aspx?key=" +
                                                   Utility.UrlEncode(Utility.Encrypt("r," + obj.id.ToString())) + "\" >" + users.ToString() + "</a>") : users.ToString()) + "</td>" +
                            "<td><a href=\"./role_authority.aspx?key=" + id + "\">Edit</a></td>" +
                            "<td>" + obj.Description + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./role_list.aspx", divPagging);
            }
        }
Esempio n. 4
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                if ("" != hidID.Value)
                {
                    var ids  = GetIdList(hidID.Value.Split(new char[] { ',' }));
                    var list = AccountInstance.FindList(f => ids.Contains(f.id) && f.Delete == false);
                    foreach (var account in list)
                    {
                        account.Delete = true;
                        Update(account);

                        SaveHistory(new TB_AccountHistory
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("DeleteAccount")).id,
                            ObjectA  = "[id=" + account.id + "] " + account.Name
                        });
                    }
                    ShowNotification("./account_list.aspx", "Success: You have delete " + ids.Count() + " account(s).");
                }
            }
        }