schangxiang@126.com
2025-09-17 f1859bb8b72998c4852aa23a605f6f7628599a2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using FineUIPro;
using FineUIPro.iWareWms;
using iWareCommon.Common.Entity;
using iWareCommon.Common.EnumType;
using iWareDataCore.RBAC.Service;
using iWareExcel.EXCEL.Service;
using iWareWms.Code.Excel.Service;
using System;
using System.Collections.Generic;
 
namespace iWareWms.View.RBAC.User
{
    /// <summary>
    /// 许艺潇
    /// 2018.06
    /// 用户管理操作页面
    /// </summary>
    public partial class User : PageBase
    {
        protected override Grid GetGrid()
        {
            return UserGrid;
        }
 
        protected override DropDownList GetPageSizeDropDownList()
        {
            return ddlPageSize;
        }
 
 
        protected override List<object> GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage)
        {
           
            var users = UserService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "Name", tbName.Text.Trim() }, { "Position", tbPosition.Text.Trim() } },
                Filter = new Dictionary<string, object> { { "Status", ddlStatus.SelectedValue }, { "label", 0 } },
                PageIndex = pageIndex,
                PageSize = pageSize
            }, out msg, out totalNum, out currentPage);
            var res = new List<object>();
 
            users.ForEach(x =>{
                if(x.Id!=1)
                {
                res.Add(x);
                }
            });
            totalNum = (totalNum - 1);
            return res;
        }
 
        protected override void Delete(int id, out string msg)
        {
          
            UserService.GetInstance().Delete(id,out msg);
            WriteLog("用户删除" + msg, "用户管理");
            
        }
 
        protected override void Delete(List<int> ids, out string msg)
        {
            
            UserService.GetInstance().Delete(ids, out msg);
            WriteLog("用户删除" + msg, "用户管理");
        }
 
        protected override void ChangeStatus(List<int> ids, int enable, out string msg)
        {
 
            
            UserService.GetInstance().ChangeStatus(ids, enable, out msg);
            
        }
 
 
        protected override void GridRowCommand(object sender, GridCommandEventArgs e)
        {
            base.GridRowCommand(sender, e);
            if (e.CommandName == "Reset")
            {
 
                string msg;
                
                UserService.GetInstance().ResetPassword(int.Parse(GetGrid().DataKeys[e.RowIndex][0].ToString()), out msg);
 
                if (string.IsNullOrEmpty(msg)) 
                {
                msg="重置密码成功";
                }
                Alert.ShowInTop(msg);
                
                WriteLog("用户重置密码" + msg, "用户管理");
            }
        }
 
 
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                //判断删除复选框是否选择了至少一项纪录
                ResolveDeleteButtonForGrid(Button3, UserGrid);
                
                //判断启用状态复选框是否选择了至少一项纪录
                ResolveEnableStatusButtonForGrid(MenuButton1, UserGrid, true);
                
                //判断禁用状态复选框是否选择了至少一项纪录
                ResolveEnableStatusButtonForGrid(MenuButton2, UserGrid, false);
                
                //查询框中的用户状态
                ddlStatus.Items.Add("全部", "");
                foreach (var status in Enum.GetValues(typeof( EStatus)))
                {
                    ddlStatus.Items.Add(status.ToString(), ((int)status).ToString());
                }    
                Button1.OnClientClick = Window1.GetShowReference("~/View/RBAC/User/UserDetail.aspx", "新增用户");
                Query(1); 
            }
 
        }
 
 
        protected override Window GetWindow()
        {
            return Window2;
        }
 
        protected override void GetPath(object userName)
        {
            string msg;
            var users = UserService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "Name", tbName.Text.Trim() }, { "Position", tbPosition.Text.Trim() } },
                Filter = new Dictionary<string, object> { { "Status", ddlStatus.SelectedValue } },
            }, out msg);
            var datas = new List<object>();
            users.ForEach(x => datas.Add(x));
            var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Name", "用户" } } }, out msg);
            var path = ExcelService.GetInstance().ToExcelByEPPlus(workBooks[0], new Dictionary<string, List<object>> { { "用户", datas } }, out msg);
            Session["ExcelPath"] = path;
        }
 
 
        protected override FineUIPro.Timer GetTimer()
        {
            return timer1;
        }
 
    }
}