提交 | 用户 | 时间
|
e46d3b
|
1 |
using System; |
懒 |
2 |
using System.Collections.Generic; |
|
3 |
using System.ComponentModel; |
|
4 |
using System.Data; |
|
5 |
using System.Data.SqlClient; |
|
6 |
using System.Drawing; |
|
7 |
using System.Linq; |
|
8 |
using System.Text; |
|
9 |
using System.Windows.Forms; |
|
10 |
using WeifenLuo.WinFormsUI.Docking; |
|
11 |
using YX.BLL; |
|
12 |
using YX.Entity; |
|
13 |
namespace YX |
|
14 |
{ |
|
15 |
public partial class FrmUserInfo : WindowParent |
|
16 |
{ |
|
17 |
SystemOrganization_Bll organization_bll = new SystemOrganization_Bll(); |
|
18 |
// SystemUserInfo_Dal user_dal = new SystemUserInfo_Dal(); |
|
19 |
SystemUserInfo_Bll user_bll = new SystemUserInfo_Bll(); |
|
20 |
SystemMenu_Bll menu_bll = new SystemMenu_Bll(); |
|
21 |
public FrmUserInfo(string ParentId) |
|
22 |
{ |
|
23 |
InitializeComponent(); |
|
24 |
SetButton(ParentId, this.toolStrip1);//设置按钮权限 |
|
25 |
} |
|
26 |
|
|
27 |
private void FrmUserInfo_Load(object sender, EventArgs e) |
|
28 |
{ |
|
29 |
GetComboxList(); |
|
30 |
BindTreeView(organization_bll.GetOrganizations()); |
|
31 |
if (treeView1.Nodes.Count > 0)//展开一级节点 |
|
32 |
{ |
|
33 |
treeView1.Nodes[0].Expand(); |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
private void GetComboxList() |
|
38 |
{ |
|
39 |
DataTable dt = new DataTable(); |
|
40 |
DataColumn Name = new DataColumn("Name"); |
|
41 |
DataColumn Value = new DataColumn("Value"); |
|
42 |
dt.Columns.Add(Name); |
|
43 |
dt.Columns.Add(Value); |
|
44 |
|
|
45 |
DataRow dr1 = dt.NewRow(); |
|
46 |
dr1["Name"] = "工号"; |
|
47 |
dr1["Value"] = "User_Code"; |
|
48 |
|
|
49 |
DataRow dr2 = dt.NewRow(); |
|
50 |
dr2["Name"] = "账户"; |
|
51 |
dr2["Value"] = "User_Account"; |
|
52 |
|
|
53 |
DataRow dr3 = dt.NewRow(); |
|
54 |
dr3["Name"] = "姓名"; |
|
55 |
dr3["Value"] = "User_Name"; |
|
56 |
dt.Rows.Add(dr1); |
|
57 |
dt.Rows.Add(dr2); |
|
58 |
dt.Rows.Add(dr3); |
|
59 |
this.com_Searchwhere.ComboBox.DisplayMember = "Name"; |
|
60 |
this.com_Searchwhere.ComboBox.ValueMember = "Value"; |
|
61 |
|
|
62 |
this.com_Searchwhere.ComboBox.DataSource = dt; |
|
63 |
} |
|
64 |
private void BindTreeView(List<Base_Organization> list) |
|
65 |
{ |
|
66 |
try |
|
67 |
{ |
|
68 |
treeView1.Nodes.Clear(); |
|
69 |
list = organization_bll.GetOrganizations(); |
|
70 |
var parents = list.Where(o => o.ParentId == "0"); |
|
71 |
foreach (var item in parents) |
|
72 |
{ |
|
73 |
TreeNode tn = new TreeNode(); |
|
74 |
tn.Text = item.Organization_Name; |
|
75 |
tn.Tag = item.Organization_ID; |
|
76 |
tn.ImageIndex = 0; |
|
77 |
FillTree(tn, list); |
|
78 |
treeView1.Nodes.Add(tn); |
|
79 |
} |
|
80 |
} |
|
81 |
catch (Exception ex) |
|
82 |
{ |
|
83 |
System_Bll.WriteLogToDB(new Entity.Base_Log |
|
84 |
{ |
|
85 |
CreateUserID = FrmLogin.LoginUserID, |
|
86 |
CreateUserName = FrmLogin.loginUserName, |
|
87 |
LocalIP = FrmLogin.LocalIP, |
|
88 |
LogMessage = ex.Message, |
|
89 |
Type = "系统错误!", |
|
90 |
ClassName = typeof(FrmUserInfo).ToString() |
|
91 |
}); |
|
92 |
MessageBox.Show(ex.Message); |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
private void FillTree(TreeNode node, List<Base_Organization> list) |
|
97 |
{ |
|
98 |
|
|
99 |
var childs = list.Where(o => o.ParentId == node.Tag.ToString()); |
|
100 |
if (childs.Count() > 0) |
|
101 |
{ |
|
102 |
foreach (var item in childs) |
|
103 |
{ |
|
104 |
TreeNode tnn = new TreeNode(); |
|
105 |
tnn.Text = item.Organization_Name; |
|
106 |
tnn.Tag = item.Organization_ID; |
|
107 |
tnn.ImageIndex = 0; |
|
108 |
if (item.ParentId == node.Tag.ToString()) |
|
109 |
{ |
|
110 |
FillTree(tnn, list); |
|
111 |
} |
|
112 |
node.Nodes.Add(tnn); |
|
113 |
} |
|
114 |
|
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) |
|
119 |
{ |
|
120 |
string Organization_ID = e.Node.Tag.ToString(); |
|
121 |
StringBuilder SqlWhere = new StringBuilder(); |
|
122 |
IList<SqlParameter> IList_param = new List<SqlParameter>(); |
|
123 |
if (!string.IsNullOrEmpty(Organization_ID)) |
|
124 |
{ |
|
125 |
SqlWhere.Append(" AND S.Organization_ID =@Organization_ID"); |
|
126 |
IList_param.Add(new SqlParameter("@Organization_ID", Organization_ID )); |
|
127 |
} |
|
128 |
this.dataGridView1.DataSource = user_bll.GetUserInfoByOrganization_Id(SqlWhere, IList_param); |
|
129 |
|
|
130 |
} |
|
131 |
|
|
132 |
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) |
|
133 |
{ |
|
134 |
if (this.dataGridView1.Rows.Count != 0) |
|
135 |
{ |
|
136 |
for (int i = 0; i < this.dataGridView1.Rows.Count; ) |
|
137 |
{ |
|
138 |
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.BlanchedAlmond; |
|
139 |
i += 2; |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
private void btn_select_Click(object sender, EventArgs e) |
|
145 |
{ |
|
146 |
StringBuilder SqlWhere = new StringBuilder(); |
|
147 |
IList<SqlParameter> IList_param = new List<SqlParameter>(); |
|
148 |
if (!string.IsNullOrEmpty(txt_Search.Text)) |
|
149 |
{ |
|
150 |
SqlWhere.Append(" and U." + com_Searchwhere.ComboBox.SelectedValue.ToString()+ " like @obj "); |
|
151 |
IList_param.Add(new SqlParameter("@obj", '%' + txt_Search.Text.Trim() + '%')); |
|
152 |
} |
|
153 |
if (!string.IsNullOrEmpty(treeView1.SelectedNode.Tag.ToString())) |
|
154 |
{ |
|
155 |
SqlWhere.Append(" AND S.Organization_ID =@Organization_ID"); |
|
156 |
IList_param.Add(new SqlParameter("@Organization_ID", treeView1.SelectedNode.Tag.ToString())); |
|
157 |
} |
|
158 |
this.dataGridView1.DataSource= user_bll.GetUserInfoByOrganization_Id(SqlWhere, IList_param); |
|
159 |
} |
|
160 |
|
|
161 |
private void btn_Add_Click(object sender, EventArgs e) |
|
162 |
{ |
|
163 |
FrmUserInfoEdit edit = new FrmUserInfoEdit(this); |
|
164 |
edit.ShowDialog(); |
|
165 |
} |
|
166 |
|
|
167 |
private void btn_edit_Click(object sender, EventArgs e) |
|
168 |
{ |
|
169 |
if (dataGridView1.DataSource == null) |
|
170 |
{ |
|
171 |
MessageBox.Show("请选择要编辑的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
172 |
} |
|
173 |
else |
|
174 |
{ |
|
175 |
DataGridViewRow dr = dataGridView1.SelectedRows[0]; |
|
176 |
|
|
177 |
if (dr != null) |
|
178 |
{ |
|
179 |
FrmUserInfoEdit edit = new FrmUserInfoEdit(this,ref dr); |
|
180 |
edit.ShowDialog(); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
private void btn_delete_Click(object sender, EventArgs e) |
|
187 |
{ |
|
188 |
|
|
189 |
try |
|
190 |
{ |
|
191 |
DataGridViewRow dr = dataGridView1.SelectedRows[0]; |
|
192 |
if (dr != null) |
|
193 |
{ |
|
194 |
//int result = bll.DeleteSysMenu(dr.Cells["Menu_Id"].Value.ToString()); |
|
195 |
// if (result == 1) |
|
196 |
// { |
|
197 |
MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
198 |
// this.dataGridView1.DataSource = dal.GetSysMenuChilds(this.listView1.SelectedItems[0].Tag.ToString()); |
|
199 |
// } |
|
200 |
//else |
|
201 |
// { |
|
202 |
MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
203 |
// } |
|
204 |
} |
|
205 |
} |
|
206 |
catch (Exception ex) |
|
207 |
{ |
|
208 |
System_Bll.WriteLogToDB(new Entity.Base_Log |
|
209 |
{ |
|
210 |
CreateUserID = FrmLogin.LoginUserID, |
|
211 |
CreateUserName = FrmLogin.loginUserName, |
|
212 |
LocalIP = FrmLogin.LocalIP, |
|
213 |
LogMessage = ex.Message, |
|
214 |
Type = "系统错误!", |
|
215 |
ClassName = typeof(FrmUserInfo).ToString() |
|
216 |
}); |
|
217 |
MessageBox.Show(ex.Message); |
|
218 |
} |
|
219 |
} |
|
220 |
|
|
221 |
private void btn_refresh_Click(object sender, EventArgs e) |
|
222 |
{ |
|
223 |
if (treeView1.SelectedNode != null) |
|
224 |
{ |
|
225 |
string Organization_ID = treeView1.SelectedNode.Tag.ToString(); |
|
226 |
StringBuilder SqlWhere = new StringBuilder(); |
|
227 |
IList<SqlParameter> IList_param = new List<SqlParameter>(); |
|
228 |
if (!string.IsNullOrEmpty(Organization_ID)) |
|
229 |
{ |
|
230 |
SqlWhere.Append(" AND S.Organization_ID =@Organization_ID"); |
|
231 |
IList_param.Add(new SqlParameter("@Organization_ID", Organization_ID)); |
|
232 |
} |
|
233 |
this.dataGridView1.DataSource = user_bll.GetUserInfoByOrganization_Id(SqlWhere, IList_param); |
|
234 |
} |
|
235 |
|
|
236 |
} |
|
237 |
|
|
238 |
private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e) |
|
239 |
{ |
|
240 |
BindTreeView(organization_bll.GetOrganizations()); |
|
241 |
if (treeView1.Nodes.Count > 0)//展开一级节点 |
|
242 |
{ |
|
243 |
treeView1.Nodes[0].Expand(); |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
} |