物业客户管理信息系统(七)之员工主窗体~1

该部分主要是主窗体代码的部分,因为我写的物业客户关系管理信息系统的主窗体的代码有点长,所以这里要分成多篇文章来进行发布。之前在写代码的时候过于匆忙,两个星期内完成的系统,而且还要设计界面等等的工作,于是编写的代码有点乱,而且代码没有写上注释,可能看起来有点不方便。其实刚开始的时候我的设想是每句重要的语句都加上注释的,但是写代码的时候实在没有心情搭理注释了,而且这两个星期的管理信息系统课程设计真的是满满的时间都在编程,而且在答辩的那天草草收尾了,也根本没有时间进行注释之类的事情了。
 物业客户管理信息系统(七)之员工主窗体~1

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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WYMIS
{
public partial class Main_Yuangong_Form : Form
{
SQL_Class SQLClass = new SQL_Class(); //创建一个SQL_Class对象SQLClass,用以调用SQL_Class类中的函数
TreeNode SelectNode = new TreeNode(); //创建一个TreeNode对象SelectNode,用以存储被选中的树节点
Zhuangtai_Class Zhuangtai = new Zhuangtai_Class();
Search_Class search = new Search_Class();
public static int tempint;
public static string tempsql;
public static bool iswhere;
public static bool isonce = true;
public static bool needwhere = true;
public bool changeuser;
//管理员信息变量————————–
public int glyid; //管理员ID
public string glyxm; //管理员姓名
public string glyxb; //管理员性别
public string glybm; //管理员部门
public string glygw; //管理员岗位
public string glylx; //管理员联系方式
public string glydz; //管理员住址
public string glyyhm; //管理员用户名
public int glyqx; //管理员权限
public Main_Yuangong_Form()
{
InitializeComponent();
}
[DllImport(“user32.dll”)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wparam, int lparam);
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)//按下的是鼠标左键
{
Capture = false;//释放鼠标使能够手动操作
SendMessage(Handle, 0x00A1, 2, 0);//拖动窗体
}
}
//以下为重点代码——————————————————————–
public void listview_columns() //列表的列项添加
{
listview_right.Columns.Clear();
listview_right.Items.Clear();
//if (treeview_left.SelectedNode == null) //判断是否选中了树节点
//{
// return;
//}
switch(splitcon1.Tag.ToString())
{
case “sy”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “住房编号”, 70);
listview_right.Columns.Add(“2”, “楼层”, 50);
listview_right.Columns.Add(“3”, “住房配置”, 100);
listview_right.Columns.Add(“4”, “业主名称”, 100);
listview_right.Columns.Add(“5”,“状态”,50);
listview_right.Columns.Add(“6”,“所属房产”,100);
listview_right.Columns.Add(“7”, “费用”, 100);
break;
case “yz”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “业主编号”, 70);
listview_right.Columns.Add(“2”, “姓名”, 100);
listview_right.Columns.Add(“3”, “性别”, 50);
listview_right.Columns.Add(“4”, “联系方式”, 100);
listview_right.Columns.Add(“5”, “住址”,150);
listview_right.Columns.Add(“6”, “身份证号”,100);
listview_right.Columns.Add(“7”, “权限”, 50);
listview_right.Columns.Add(“9”, “费用”, 50);
listview_right.Columns.Add(“8”, “用户名”, 70);
break;
case “yg”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “员工编号”, 70);
listview_right.Columns.Add(“2”, “姓名”, 100);
listview_right.Columns.Add(“3”, “性别”, 50);
listview_right.Columns.Add(“4”, “岗位”,100);
listview_right.Columns.Add(“5”, “联系方式”,100);
listview_right.Columns.Add(“6”, “地址”, 150);
listview_right.Columns.Add(“7”, “权限”, 80);
listview_right.Columns.Add(“8”, “用户名”, 50);
break;
case “yw”:
if(treeview_left.SelectedNode == null)
{
return;
}
switch (treeview_left.SelectedNode.Name)
{
case “1”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “事务编号”, 100);
listview_right.Columns.Add(“2”, “事务名称”, 100);
listview_right.Columns.Add(“3”, “任务时间”, 80);
listview_right.Columns.Add(“4”, “状态”, 50);
listview_right.Columns.Add(“5”, “负责人”,70);
listview_right.Columns.Add(“6”, “备注”,100);
break;
case “2”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “申请编号”, 100);
listview_right.Columns.Add(“2”, “申请名称”, 100);
listview_right.Columns.Add(“3”, “申请人”, 100);
listview_right.Columns.Add(“4”, “申请时间”, 80);
listview_right.Columns.Add(“5”, “状态”, 50);
listview_right.Columns.Add(“6”, “受理时间”, 80);
listview_right.Columns.Add(“7”, “负责人”,100);
listview_right.Columns.Add(“8”, “完成时间”,80);
listview_right.Columns.Add(“9”, “费用”, 50);
break;
case “3”:
listview_right.Columns.Add(“0”, “序号”, 50);
listview_right.Columns.Add(“1”, “收费编号”, 70);
listview_right.Columns.Add(“2”, “收费事项”, 100);
listview_right.Columns.Add(“3”, “金额”, 50);
listview_right.Columns.Add(“4”, “类型”,70);
listview_right.Columns.Add(“5”, “缴费时间”,80);
listview_right.Columns.Add(“6”, “缴费业主”, 100);
listview_right.Columns.Add(“7”, “负责人”, 100);
listview_right.Columns.Add(“8”, “备注”, 100);
break;
}
break;
}
}
private void Main_Yuangong_Form_Load(object sender, EventArgs e) //加载窗体函数
{
lab_title.Text = this.Text + ” – “ + lab_title.Text;
lab_glyxm.Text += glyxm;
lab_glyxb.Text += glyxb;
lab_glygw.Text = glybm + ” “ + glygw;
lab_glylx.Text += glylx;
lab_glydz.Text += glydz;
lab_glyyhm.Text += glyyhm;
//设置加载窗体时首页图片的选中
//picbox_shouye.Image = Image.FromFile(“images/sy_select.png”);
//picbox_shouye.Tag = “1”;
//UpdateTreeview();
//this.listview_right.ContextMenuStrip = conMenuStr_list_1;
picbox_shouye_Click(sender, e);
}
//更新树节点——————————————
private void UpdateTreeview() //加载treeview根节点下面的子节点
{
isonce = true;
treeview_left.Nodes.Clear();
listview_columns();
switch(splitcon1.Tag.ToString())
{
case “sy”:
DataSet TreeSet = SQLClass.getDataSet(“select id,gongsi from kaifashang”, “房产开发商”);
DataTable treedt = TreeSet.Tables[“房产开发商”]; //创建一个DataTable对象
if (treedt.Rows.Count > 0)
{
for (int i = 0; i < treedt.Rows.Count; i++)
{
//创建一个TreeNode对象,并对node的属性进行赋值
TreeNode node = new TreeNode(treedt.Rows[i][1].ToString(), 1, 2);
node.Name = treedt.Rows[i][0].ToString();
treeview_left.Nodes.Add(node); //把node添加到根节点上
DataSet sonTreeSet = SQLClass.getDataSet(“Select id,jianzu from fangchan where kaifashangid = ‘” + treedt.Rows[i][0] + “‘”, “楼盘信息表”);
DataTable sontreedt = sonTreeSet.Tables[“楼盘信息表”];
if (sontreedt.Rows.Count > 0)
{
for (int j = 0; j < sontreedt.Rows.Count; j++)
{
TreeNode sonnode = new TreeNode(sontreedt.Rows[j][1].ToString(), 1, 2);
sonnode.Name = sontreedt.Rows[j][0].ToString();
treeview_left.Nodes[i].Nodes.Add(sonnode);
}
}
}
}
break;
case “yz”:
for (int i = 0; i < 2; i++)
{
string sort = Zhuangtai.YezhuQuanxian(i.ToString());
TreeNode node = new TreeNode(sort, 1, 2);
node.Name = i.ToString();
treeview_left.Nodes.Add(node);
}
break;
case “yg”: //当面板为员工时
DataSet ygDSet = SQLClass.getDataSet(“select bumen from gangwei group by bumen”,“部门信息表”);
DataTable ygdt = ygDSet.Tables[“部门信息表”];
if (ygdt.Rows.Count > 0)
{
for (int i = 0; i < ygdt.Rows.Count; i++)
{
TreeNode ygnode = new TreeNode(ygdt.Rows[i][0].ToString(), 1, 2);
ygnode.Name = i.ToString();
treeview_left.Nodes.Add(ygnode); //把node添加到根节点上
DataSet gwDSet = SQLClass.getDataSet(“select id,gangwei from gangwei where bumen = ‘” + ygdt.Rows[i][0].ToString() + “‘”, “岗位信息表”);
DataTable gwdt = gwDSet.Tables[“岗位信息表”];
if(gwdt.Rows.Count > 0)
{
for (int j = 0; j < gwdt.Rows.Count; j++)
{
TreeNode gwnode = new TreeNode(gwdt.Rows[j][1].ToString(), 1, 2);
gwnode.Name = gwdt.Rows[j][0].ToString();
treeview_left.Nodes[i].Nodes.Add(gwnode); //把node添加到根节点上
}
}
}
}
break;
case “yw”:
for (int i = 0; i < 3; i++)
{
string sort = Zhuangtai.Yewu((i + 1).ToString());
TreeNode node = new TreeNode(sort, 1, 2);
node.Name = (i + 1).ToString();
treeview_left.Nodes.Add(node);
}
break;
}
}
//更新列表————————–
private void UpdateListview(string sql) //加载listview中的数据,其中sql参数表示传递的SQL的语句
{
DataSet DSet = SQLClass.getDataSet(sql, “数据库信息表”);
DataTable dt = DSet.Tables[“数据库信息表”]; //创建一个DataTable对象
switch (splitcon1.Tag.ToString())
{
case “sy”:
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string zhuangtai = Zhuangtai.Zhufang(dt.Rows[i][4].ToString());
string yezhu;
if (dt.Rows[i][3].ToString() != “”)
{
yezhu = Zhuangtai.YezhuName(dt.Rows[i][3].ToString(), true);
}
else
{
yezhu = “”;
}
string fcname = Zhuangtai.FangchanName(dt.Rows[i][5].ToString(), true);
//定义一个string数组item,按listview中列的顺序存放数据
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString(), yezhu, zhuangtai, fcname, dt.Rows[i][6].ToString() + “元” };
//创建一个ListView对象newitem,并对newitem的属性进行赋值
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem); //把newitem添加到listview中
}
}
break;
case “yz”:
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string yzquanxian = Zhuangtai.YezhuQuanxian(dt.Rows[i][6].ToString());
//定义一个string数组item,按listview中列的顺序存放数据
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString(), dt.Rows[i][5].ToString(), yzquanxian, dt.Rows[i][9].ToString() + “元”, dt.Rows[i][7].ToString() };
//创建一个ListView对象newitem,并对newitem的属性进行赋值
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem); //把newitem添加到listview中
}
}
break;
case “yg”:
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string ygquanxian = Zhuangtai.YuangongQuanxian(dt.Rows[i][6].ToString());
string yggw = Zhuangtai.GangweiName(dt.Rows[i][3].ToString(), true);
//定义一个string数组item,按listview中列的顺序存放数据
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString(), yggw, dt.Rows[i][4].ToString(), dt.Rows[i][5].ToString(), ygquanxian, dt.Rows[i][7].ToString() };
//创建一个ListView对象newitem,并对newitem的属性进行赋值
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem); //把newitem添加到listview中
}
}
break;
case “yw”:
if (dt.Rows.Count > 0)
{
switch (treeview_left.SelectedNode.Name)
{
case “1”:
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string rczhuangtai = Zhuangtai.Richang(dt.Rows[i][3].ToString());
string ygxm = Zhuangtai.YuangongName(dt.Rows[i][4].ToString(), true);
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString(), rczhuangtai, ygxm, dt.Rows[i][5].ToString() };
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem);
}
break;
case “2”:
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string ywzhuangtai = Zhuangtai.Fuwu(dt.Rows[i][4].ToString());
string yzxm = Zhuangtai.YezhuName(dt.Rows[i][2].ToString(),true);
string ygxm = Zhuangtai.YuangongName(dt.Rows[i][6].ToString(),true);
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), yzxm, dt.Rows[i][3].ToString(), ywzhuangtai, dt.Rows[i][5].ToString(), ygxm, dt.Rows[i][7].ToString(), dt.Rows[i][8].ToString() + “元” };
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem);
}
break;
case “3”:
for (int i = 0; i < dt.Rows.Count; i++)
{
tempint++;
string leixing = Zhuangtai.Shoufei_leixing(dt.Rows[i][3].ToString());
string yz = Zhuangtai.YezhuName(dt.Rows[i][5].ToString(), true);
string yg = Zhuangtai.YuangongName(dt.Rows[i][6].ToString(),true);
string[] item = { tempint.ToString(), dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString() + “元”, leixing, dt.Rows[i][4].ToString(), yz, yg, dt.Rows[i][7].ToString() };
ListViewItem newitem = new ListViewItem(item);
newitem.ImageIndex = 9; //设置数据行的图标
listview_right.Items.Add(newitem);
}
break;
}
}
break;
}
}