Ejemplo n.º 1
0
        private void TreeBind()
        {
            var manager    = context.dt_manager.FirstOrDefault(w => w.id == GetAdminInfo().id);
            var department = context.li_departments.FirstOrDefault(w => w.id == manager.department_id);

            BLL.department bll = new BLL.department();
            var            dt  = new DataTable();

            if (department == null)
            {
                dt = bll.GetList(0);
            }
            else if (department.parent_id == 0)
            {
                dt = bll.GetListByOkParentId(department.id, 0);
            }
            else
            {
                dt = bll.GetListByOkId(department.id, 0);
            }

            this.ddlDepartments.Items.Clear();
            this.ddlDepartments.Items.Add(new ListItem("不限", ""));
            foreach (DataRow dr in dt.Rows)
            {
                string Id         = dr["id"].ToString();
                int    ClassLayer = int.Parse(dr["class_layer"].ToString());
                string Title      = dr["department_name"].ToString().Trim();

                if (ClassLayer == 1)
                {
                    this.ddlDepartments.Items.Add(new ListItem(Title, Id));
                }
                else
                {
                    Title = "├ " + Title;
                    Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title;
                    this.ddlDepartments.Items.Add(new ListItem(Title, Id));
                }
                var g =
                    context.li_user_group_departments.Where(w => w.department_id == Convert.ToInt32(Id))
                    .Select(s => s.user_group_id)
                    .ToList();
                if (groupIdList.Count == 0)
                {
                    groupIdList = g;
                }
                else
                {
                    groupIdList = groupIdList.Concat(g).ToList();
                }

                departmentIdList.Add(int.Parse(Id));
            }
        }
Ejemplo n.º 2
0
        private void RptBind()
        {
            //BLL.manager bll = new BLL.manager();
            //this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            //this.rptList.DataBind();

            IQueryable <dt_manager> query = context.dt_manager;

            BLL.department departmentbll = new BLL.department();

            if (string.IsNullOrWhiteSpace(ddlDepartments.SelectedValue)) // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
            {
                var manager = context.dt_manager.Single(m => m.id == GetAdminInfo().id);
                if (manager.department_id > 0)
                {
                    query = query.Where(w => idstrList.Contains(w.id));
                }
            }
            else // 选了下属,看下属的组权限,无选的话不能看全部
            {
                var department = context.li_departments.FirstOrDefault(w => w.id == Convert.ToInt32(ddlDepartments.SelectedValue));
                if (department.class_layer == 1)
                {
                    DataTable dt = departmentbll.GetListByOkParentId(department.id, 0);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string Id = dr["id"].ToString();
                        var    g  = context.dt_manager.Where(w => w.department_id == Convert.ToInt32(Id))
                                    .Select(s => s.id)
                                    .ToList();
                        if (manageridstrList.Count == 0)
                        {
                            manageridstrList = g;
                        }
                        else
                        {
                            manageridstrList = manageridstrList.Concat(g).ToList();
                        }
                    }
                    query = query.Where(w => manageridstrList.Contains(w.id)); // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
                }
                else                                                           // 选了下属,看下属的组权限,无选的话不能看全部
                {
                    var canAccessGroups = context.dt_manager.Where(w => w.department_id == Convert.ToInt32(ddlDepartments.SelectedValue)).Select(s => s.id).ToArray();
                    query = query.Where(w => canAccessGroups.Contains(w.id));
                }
            }

            if (!string.IsNullOrWhiteSpace(txtKeywords.Text))
            {
                query = query.Where(w => (w.user_name.Contains(txtKeywords.Text) || w.real_name.Contains(txtKeywords.Text) || w.email.Contains(txtKeywords.Text)));
            }

            totalCount = query.Count();

            rptList.DataSource = query
                                 .OrderBy(u => u.add_time)
                                 .ThenByDescending(u => u.id)
                                 .Skip(pageSize * (page - 1))
                                 .Take(pageSize)
                                 .ToList();

            rptList.DataBind();

            //绑定页码
            txtPageNum.Text = pageSize.ToString();
            var pageUrl = Utils.CombUrlTxt("manager_list.aspx", "keywords={0}&page={1}&department_id={2}", txtKeywords.Text, "__id__", ddlDepartments.SelectedValue);

            PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8);
        }
Ejemplo n.º 3
0
        private void RptBind()
        {
            Agp2pDataContext context = new Agp2pDataContext();

            BLL.department bll     = new BLL.department();
            var            options = new DataLoadOptions();

            options.LoadWith <dt_user_groups>(g => g.dt_users);
            options.LoadWith <dt_users>(u => u.li_wallets);
            context.LoadOptions = options;

            IQueryable <dt_user_groups> query = context.dt_user_groups;

            //if (string.IsNullOrWhiteSpace(ddlSubordinates.SelectedValue)) // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
            //{
            //    var subordinatesId = context.dt_manager.Single(m => m.id == GetAdminInfo().id).dt_manager2.Select(s => s.id).ToArray();

            //    var canAccessGroups =
            //        context.li_user_group_access_keys.Where(
            //            k => k.owner_manager == GetAdminInfo().id || subordinatesId.Contains(k.owner_manager))
            //            .Select(k => k.user_group).Distinct()
            //            .ToArray();
            //    query = query.Where(w => !canAccessGroups.Any() || canAccessGroups.Contains(w.id));
            //}
            //else // 选了下属,看下属的组权限,无选的话不能看全部
            //{
            //    var canAccessGroups = context.li_user_group_access_keys.Where(k => k.owner_manager == Convert.ToInt32(ddlSubordinates.SelectedValue)).Select(k => k.user_group).ToArray();
            //    query = query.Where(w => canAccessGroups.Contains(w.id));
            //}

            if (string.IsNullOrWhiteSpace(ddlDepartments.SelectedValue)) // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
            {
                var manager = context.dt_manager.Single(m => m.id == GetAdminInfo().id);
                if (manager.department_id > 0)
                {
                    query = query.Where(w => idstrList.Contains(w.id));
                }
            }
            else // 选了下属,看下属的组权限,无选的话不能看全部
            {
                var department = context.li_departments.FirstOrDefault(w => w.id == Convert.ToInt32(ddlDepartments.SelectedValue));
                if (department.class_layer == 1)
                {
                    DataTable dt = bll.GetListByOkParentId(department.id, 0);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string Id = dr["id"].ToString();
                        var    g  = context.li_user_group_departments.Where(w => w.department_id == Convert.ToInt32(Id))
                                    .Select(s => s.user_group_id)
                                    .ToList();
                        if (departmentIdList.Count == 0)
                        {
                            departmentIdList = g;
                        }
                        else
                        {
                            departmentIdList = departmentIdList.Concat(g).ToList();
                        }
                    }
                    query = query.Where(w => departmentIdList.Contains(w.id)); // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
                }
                else                                                           // 选了下属,看下属的组权限,无选的话不能看全部
                {
                    var canAccessGroups = context.li_user_group_departments.Where(w => w.department_id == Convert.ToInt32(ddlDepartments.SelectedValue)).Select(s => s.user_group_id).ToArray();
                    query = query.Where(w => canAccessGroups.Contains(w.id));
                }
            }
            query = query.Where(w => w.title.Contains(txtKeywords.Text));

            var groups = query.OrderBy(g => g.grade).AsEnumerable().Select(g => new GroupDetails
            {
                id              = g.id,
                is_default      = g.is_default,
                GroupName       = g.title,
                Servers         = QueryServers(g),
                UserCount       = QueryGroupUserCount(g),
                DepartmentName  = QueryDepartmentName(g),
                IdleMoney       = QueryGroupUserWalletSum(g, w => w.idle_money),
                LockedMoney     = QueryGroupUserWalletSum(g, w => w.locked_money),
                InvestingMoney  = QueryGroupUserWalletSum(g, w => w.investing_money),
                UnpaidPrincipal = QueryGroupUserWalletSum(g, w => w.total_investment - w.investing_money),
                TotalInvestment = QueryGroupUserWalletSum(g, w => w.total_investment),
                ProfitingMoney  = QueryGroupUserWalletSum(g, w => w.profiting_money),
                PaidMoney       = QueryGroupUserWalletSum(g, w => w.total_profit),
                TotalProfit     = QueryGroupUserWalletSum(g, w => w.total_profit + w.profiting_money),
                TotalCharge     = QueryGroupUserWalletSum(g, w => w.total_charge),
                TotalWithdraw   = QueryGroupUserWalletSum(g, w => w.total_withdraw)
            }).ToLazyList();

            rptList.DataSource = groups.Concat(Enumerable.Range(0, 1).Select(i => new GroupDetails
            {
                GroupName  = "总计",
                is_default = 1, // hide operation
                UserCount  = groups.Sum(g => g.UserCount),
                //DepartmentName = groups.Select(g => g.DepartmentName).ToString(),
                IdleMoney       = groups.Sum(w => w.IdleMoney),
                LockedMoney     = groups.Sum(w => w.LockedMoney),
                InvestingMoney  = groups.Sum(w => w.InvestingMoney),
                UnpaidPrincipal = groups.Sum(w => w.TotalInvestment - w.InvestingMoney),
                TotalInvestment = groups.Sum(w => w.TotalInvestment),
                ProfitingMoney  = groups.Sum(w => w.ProfitingMoney),
                PaidMoney       = groups.Sum(w => w.TotalProfit),
                TotalProfit     = groups.Sum(w => w.TotalProfit + w.ProfitingMoney),
                TotalCharge     = groups.Sum(w => w.TotalCharge),
                TotalWithdraw   = groups.Sum(w => w.TotalWithdraw)
            }));

            rptList.DataBind();
        }
Ejemplo n.º 4
0
        private void LoadManagerDDL(string department_id)
        {
            department_id = department_id == "" ? ddlDepartments.SelectedValue : department_id;
            List <dt_manager> managers = null;

            ListItem[] managerListItems;

            BLL.department bll = new BLL.department();

            if (string.IsNullOrWhiteSpace(department_id)) // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
            {
                var manager = context.dt_manager.Single(m => m.id == GetAdminInfo().id);
                if (manager.department_id > 0)
                {
                    managers = context.dt_manager.Where(w => departmentIdList.Contains(Convert.ToInt32(w.department_id))).ToList();
                }
                else
                {
                    managers = context.dt_manager.ToList();
                }
            }
            else // 选了下属,看下属的组权限,无选的话不能看全部
            {
                var department = context.li_departments.FirstOrDefault(w => w.id == Convert.ToInt32(department_id));
                if (department.class_layer == 1)
                {
                    DataTable dt = bll.GetListByOkParentId(department.id, 0);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string Id = dr["id"].ToString();
                        var    g  = context.li_user_group_departments.Where(w => w.department_id == Convert.ToInt32(Id))
                                    .Select(s => s.department_id)
                                    .ToList();
                        if (departmentIdList2.Count == 0)
                        {
                            departmentIdList2 = g;
                        }
                        else
                        {
                            departmentIdList2 = departmentIdList2.Concat(g).ToList();
                        }
                    }
                    managers = context.dt_manager.Where(w => departmentIdList2.Contains(Convert.ToInt32(w.department_id))).ToList();
                }
                else   // 选了下属,看下属的组权限,无选的话不能看全部
                {
                    managers = context.dt_manager.Where(w => w.department_id == Convert.ToInt32(department_id)).ToList();
                }
            }

            managerListItems = managers.Select(m =>
                                               new ListItem(
                                                   string.IsNullOrWhiteSpace(m.real_name)
                                  ? m.user_name
                                  : string.Format("{0}({1})", m.user_name, m.real_name), m.id.ToString())).ToArray();

            ddlManager.Items.Clear();
            if (managerListItems.Length == 0)
            {
                ddlManager.Items.Add(new ListItem("暂无管理员", ""));
            }
            ddlManager.Items.AddRange(managerListItems);
            if (!string.IsNullOrWhiteSpace(manager_id))
            {
                ddlManager.SelectedValue = manager_id;
            }
        }
Ejemplo n.º 5
0
        private void ShowInfo(string department_id, string manager_id)
        {
            department_id = department_id == "" ? ddlDepartments.SelectedValue : department_id;
            //if (department_id == "")
            //{
            //    ddlManager.Enabled = false;
            //}
            ddlDepartments.SelectedValue = department_id;

            IQueryable <dt_user_groups> userGroups = context.dt_user_groups;

            BLL.department bll = new BLL.department();

            if (string.IsNullOrWhiteSpace(ddlDepartments.SelectedValue)) // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
            {
                var manager = context.dt_manager.Single(m => m.id == GetAdminInfo().id);
                if (manager.department_id > 0)
                {
                    userGroups = userGroups.Where(w => groupIdList.Contains(w.id));
                }
            }
            else // 选了下属,看下属的组权限,无选的话不能看全部
            {
                var department = context.li_departments.FirstOrDefault(w => w.id == Convert.ToInt32(department_id));
                if (department.class_layer == 1)
                {
                    DataTable dt = bll.GetListByOkParentId(department.id, 0);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string Id = dr["id"].ToString();
                        var    g  = context.li_user_group_departments.Where(w => w.department_id == Convert.ToInt32(Id))
                                    .Select(s => s.user_group_id)
                                    .ToList();
                        if (departmentIdList3.Count == 0)
                        {
                            departmentIdList3 = g;
                        }
                        else
                        {
                            departmentIdList3 = departmentIdList3.Concat(g).ToList();
                        }
                    }
                    userGroups = userGroups.Where(w => departmentIdList3.Contains(w.id));
                    // 不限:查自己的组权限 + 下属的组权限,都无选权限的话能看全部
                }
                else // 选了下属,看下属的组权限,无选的话不能看全部
                {
                    var userGroupLists =
                        context.li_user_group_departments.Where(k => k.department_id == Convert.ToInt32(department_id))
                        .Select(s => s.user_group_id)
                        .ToList();
                    userGroups = userGroups.Where(w => userGroupLists.Contains(w.id));
                }
            }


            //var isClassLayer = context.li_departments.FirstOrDefault(f => f.id == Convert.ToInt32(department_id));
            //if (isClassLayer.class_layer == 1)
            //{
            //    userGroups = context.dt_user_groups.Where(w => groupIdList.Contains(w.id)).ToList();
            //}
            //else
            //{
            //    var userGroupLists = context.li_user_group_departments.Where(k => k.department_id == Convert.ToInt32(department_id)).Select(s => s.user_group_id).ToList();
            //    userGroups = context.dt_user_groups.Where(w => userGroupLists.Contains(w.id)).ToList();
            //}

            var listItems = userGroups.Select(g => new ListItem(g.title, g.id.ToString())).ToArray();
            Dictionary <string, li_user_group_access_keys> selectedGroups = null;

            if (!string.IsNullOrWhiteSpace(ddlManager.SelectedValue))
            {
                selectedGroups = context.li_user_group_access_keys.Where(k => k.owner_manager == Convert.ToInt32(ddlManager.SelectedValue)).ToDictionary(g => g.user_group.ToString());
                if (selectedGroups.Count > 0)
                {
                    listItems.Where(l => selectedGroups.Keys.Contains(l.Value)).ForEach(l => { l.Selected = true; });
                }
                else
                {
                    listItems.Where(l => !selectedGroups.Keys.Contains(l.Value)).ForEach(l => { l.Selected = true; });
                }
            }
            else
            {
                listItems.ForEach(l => l.Selected = true);
            }


            cblUserGroup.Items.Clear();
            if (listItems.Length == 0)
            {
                cblUserGroup.Items.Add(new ListItem("暂无用户分组", ""));
            }
            cblUserGroup.Items.AddRange(listItems);
        }