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

第二部分的员工主窗体代码,这次的主窗体代码可是足量的啊,老师看到了都吓坏啦,当时,还问这个只是主窗体的代码吗?我说是的。呵呵,其实重复代码很多这里面,而且有些是注释了的代码,但是因为当时可能会用到所以就一直没有删除,知道最后就干脆不删除了,就那么办。这个物业客户关系管理信息系统是我的第一个较为完整的程序吧,虽然花了很多的精力,但是最终还是评优了,而且我的界面做得也不错。当时在网上找的一张图片然后自己用PS处理的。而且根据不同的界面进行了设置,不过大体是一样的。
物业客户管理信息系统(七)之员工主窗体~2

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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//选中——————TreeView
private void treeview_left_AfterSelect(object sender, EventArgs e) //点击treeview所触发的函数
{
isonce = true;
listview_columns();
if (treeview_left.SelectedNode == null) //判断是否选中了树节点
{
switch (splitcon1.Tag.ToString())
{
case “sy”:
tempint = 0;
tempsql = “select * from zhufang”;
iswhere = false;
UpdateListview(tempsql);
break;
case “yz”:
tempint = 0;
tempsql = “select * from yezhu”;
iswhere = false;
UpdateListview(tempsql);
break;
case “yg”:
tempint = 0;
tempsql = “select * from yuangong”;
iswhere = false;
UpdateListview(tempsql);
break;
case “yw”:
break;
}
//return;
}
else
{
SelectNode = treeview_left.SelectedNode; //把当前选中的节点赋值给SelectNode
treeview_left.MouseDown += new MouseEventHandler(treeview_left_MouseDown);
switch (splitcon1.Tag.ToString())
{
case “sy”:
//当鼠标位于控件treeView上并按下鼠标键时,加载treeview_MouseDown的函数
DataSet DSet = SQLClass.getDataSet(“select id from kaifashang where id = ‘” + treeview_left.SelectedNode.Name + “‘ and gongsi = ‘” + treeview_left.SelectedNode.Text + “‘”, “开发商信息表”);
DataTable dt = DSet.Tables[“开发商信息表”];
if (dt.Rows.Count > 0)
{
//treeview_left.Nodes[treeview_left.SelectedNode.Name].Nodes.Clear();
DataSet parentDSet = SQLClass.getDataSet(“select id from fangchan where kaifashangid = ‘” + treeview_left.SelectedNode.Name + “‘”, “楼盘信息表”);
DataTable parentdt = parentDSet.Tables[“楼盘信息表”];
if (parentdt.Rows.Count > 0)
{
tempint = 0;
for (int i = 0; i < parentdt.Rows.Count; i++)
{
if (tempint == 0)
{
tempsql = “select * from zhufang where fangchanid = ‘” + parentdt.Rows[i][0].ToString() + “‘”;
}
else
{
tempsql = tempsql + ” or fangchanid = ‘” + parentdt.Rows[i][0].ToString() + “‘”;
}
iswhere = true;
UpdateListview(“select * from zhufang where fangchanid = ‘” + parentdt.Rows[i][0].ToString() + “‘”);
}
}
}
else
{
DataSet newDSet = SQLClass.getDataSet(“select id from fangchan where jianzu = ‘” + treeview_left.SelectedNode.Text + “‘”, “房产信息表”);
DataTable newdt = newDSet.Tables[“房产信息表”];
if (newdt.Rows.Count > 0)
{
tempint = 0;
for (int i = 0; i < newdt.Rows.Count; i++)
{
if (tempint == 0)
{
tempsql = “select * from zhufang where fangchanid = ‘” + newdt.Rows[i][0].ToString() + “‘”;
}
else
{
tempsql = tempsql + ” or fangchanid = ‘” + newdt.Rows[i][0].ToString() + “‘”;
}
iswhere = true;
UpdateListview(“select * from zhufang where fangchanid = ‘” + newdt.Rows[i][0].ToString() + “‘”);
}
}
}
break;
case “yz”:
tempint = 0;
tempsql = “select * from yezhu where quanxian = ‘” + treeview_left.SelectedNode.Name + “‘”;
iswhere = true;
UpdateListview(tempsql);
break;
case “yg”:
listview_right.Items.Clear();
DataSet gwDSet = SQLClass.getDataSet(“select id from gangwei where gangwei = ‘” + treeview_left.SelectedNode.Text + “‘”, “岗位信息表”);
DataTable gwdt = gwDSet.Tables[“岗位信息表”];
if (gwdt.Rows.Count > 0)
{
tempint = 0;
tempsql = “select * from yuangong where gangweiid = ‘” + treeview_left.SelectedNode.Name + “‘”;
iswhere = true;
UpdateListview(tempsql);
}
else
{
DataSet ygDSet = SQLClass.getDataSet(“select id from gangwei where bumen = ‘” + treeview_left.SelectedNode.Text + “‘”, “部门信息表”);
DataTable ygdt = ygDSet.Tables[“部门信息表”];
if (ygdt.Rows.Count > 0)
{
tempint = 0;
for (int i = 0; i < ygdt.Rows.Count; i++)
{
tempsql = “select * from yuangong where gangweiid = ‘” + ygdt.Rows[i][0] + “‘”;
iswhere = true;
UpdateListview(tempsql);
}
}
}
break;
case “yw”:
switch (treeview_left.SelectedNode.Name)
{
case “1”:
UpdateComboBox();
tempint = 0;
tempsql = “select * from richang”;
iswhere = false;
UpdateListview(tempsql);
break;
case “2”:
UpdateComboBox();
tempint = 0;
tempsql = “select * from fuwu”;
iswhere = false;
UpdateListview(tempsql);
break;
case “3”:
UpdateComboBox();
tempint = 0;
tempsql = “select * from shoufei”;
iswhere = false;
UpdateListview(tempsql);
break;
}
break;
}
}
}
//private void toolStripMenuItem_Click(object sender, EventArgs e)
//{
// MessageBox.Show(“数据库连接失败!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
//}
//鼠标按钮动作—————————–
private void treeview_left_MouseDown(object sender, MouseEventArgs e)
{
this.treeview_left.ContextMenuStrip = conMenuStr_tree_1;
conMenuStr_tree_1.Items.Clear();
//创建一个矩形Rect,对初始化Rect的位置和大小
switch(splitcon1.Tag.ToString())
{
case “sy”:
ToolStripMenuItem addkaifashang = new ToolStripMenuItem(“添加开发商”);
addkaifashang.Click += new EventHandler(添加开发商toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(addkaifashang);
break;
case “yg”:
ToolStripMenuItem addgangwei = new ToolStripMenuItem(“添加岗位”);
addgangwei.Click += new EventHandler(添加岗位toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(addgangwei);
ToolStripMenuItem revisebumen = new ToolStripMenuItem(“修改部门”);
ToolStripMenuItem deletebumen = new ToolStripMenuItem(“删除部门”);
revisebumen.Click += new EventHandler(修改部门toolStripMenuItem_Click);
deletebumen.Click += new EventHandler(删除部门toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(revisebumen);
conMenuStr_tree_1.Items.Add(deletebumen);
break;
}
Rectangle Rect = new Rectangle(SelectNode.Bounds.X, SelectNode.Bounds.Y, SelectNode.Bounds.Width, SelectNode.Bounds.Height);
if (Rect.Contains(e.X, e.Y)) //如果鼠标停留在矩形内
{
//把treeview的右键菜单设置为contextMenuStrip
switch (splitcon1.Tag.ToString())
{
case “sy”:
//ToolStripMenuItem addkaifashang = new ToolStripMenuItem(“添加开发商”);
//addkaifashang.Click += new EventHandler(添加开发商toolStripMenuItem_Click);
//conMenuStr_tree_1.Items.Add(addkaifashang);
DataSet DSet = SQLClass.getDataSet(“select id from kaifashang where id = ‘” + treeview_left.SelectedNode.Name + “‘ and gongsi = ‘” + treeview_left.SelectedNode.Text + “‘”, “开发商信息表”);
DataTable dt = DSet.Tables[“开发商信息表”];
if (dt.Rows.Count > 0)
{
ToolStripMenuItem revisekaifashang = new ToolStripMenuItem(“修改开发商”);
ToolStripMenuItem lookkaifashang = new ToolStripMenuItem(“查看开发商”);
ToolStripMenuItem deletekaifashang = new ToolStripMenuItem(“删除开发商”);
revisekaifashang.Click += new EventHandler(修改开发商toolStripMenuItem_Click);
lookkaifashang.Click += new EventHandler(查看开发商toolStripMenuItem_Click);
deletekaifashang.Click += new EventHandler(删除开发商toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(revisekaifashang);
conMenuStr_tree_1.Items.Add(lookkaifashang);
conMenuStr_tree_1.Items.Add(deletekaifashang);
ToolStripMenuItem addloupan = new ToolStripMenuItem(“添加楼盘”);
addloupan.Click += new EventHandler(添加楼盘toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(addloupan);
}
else
{
ToolStripMenuItem addloupan = new ToolStripMenuItem(“添加楼盘”);
ToolStripMenuItem reviseloupan = new ToolStripMenuItem(“修改楼盘”);
ToolStripMenuItem lookloupan = new ToolStripMenuItem(“查看楼盘”);
ToolStripMenuItem deleteloupan = new ToolStripMenuItem(“删除楼盘”);
addloupan.Click += new EventHandler(添加楼盘toolStripMenuItem_Click);
reviseloupan.Click += new EventHandler(修改楼盘toolStripMenuItem_Click);
lookloupan.Click += new EventHandler(查看楼盘toolStripMenuItem_Click);
deleteloupan.Click += new EventHandler(删除楼盘toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(addloupan);
conMenuStr_tree_1.Items.Add(reviseloupan);
conMenuStr_tree_1.Items.Add(lookloupan);
conMenuStr_tree_1.Items.Add(deleteloupan);
}
break;
case “yz”:
//this.treeview_left.ContextMenuStrip = conMenuStr_yz_1;
break;
case “yg”:
//this.treeview_left.ContextMenuStrip = conMenuStr_yg_1;
DataSet bmDSet = SQLClass.getDataSet(“select bumen from gangwei where bumen = ‘” + treeview_left.SelectedNode.Text + “‘”, “部门信息表”);
DataTable bmdt = bmDSet.Tables[“部门信息表”];
if (bmdt.Rows.Count > 0)
{
}
else
{
ToolStripMenuItem revisegangwei = new ToolStripMenuItem(“修改岗位”);
ToolStripMenuItem deletegangwei = new ToolStripMenuItem(“删除岗位”);
ToolStripMenuItem revisebumen = new ToolStripMenuItem(“修改部门”);
ToolStripMenuItem deletebumen = new ToolStripMenuItem(“删除部门”);
revisegangwei.Click += new EventHandler(修改岗位toolStripMenuItem_Click);
deletegangwei.Click += new EventHandler(删除岗位toolStripMenuItem_Click);
revisebumen.Click += new EventHandler(修改部门toolStripMenuItem_Click);
deletebumen.Click += new EventHandler(删除部门toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(revisegangwei);
conMenuStr_tree_1.Items.Add(deletegangwei);
conMenuStr_tree_1.Items.Add(revisebumen);
conMenuStr_tree_1.Items.Add(deletebumen);
}
break;
case “yw”:
//this.treeview_left.ContextMenuStrip = conMenuStr_yw_1;
break;
}
}
//else
//{
// this.treeview_left.ContextMenuStrip = null; //treeview的右键菜单为空
//}
ToolStripMenuItem refresh = new ToolStripMenuItem(“刷新”);
refresh.Click += new EventHandler(刷新树toolStripMenuItem_Click);
conMenuStr_tree_1.Items.Add(refresh);
}
//treeview节点右键菜单动作
private void 添加开发商toolStripMenuItem_Click(object sender, EventArgs e)
{
Kfs_Form kfs = new Kfs_Form();
kfs.Form_Type = 0;
kfs.Text = “添加开发商”;
kfs.ShowDialog();
if (kfs.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“添加开发商成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 修改开发商toolStripMenuItem_Click(object sender, EventArgs e)
{
Kfs_Form kfs = new Kfs_Form();
kfs.kfsid = treeview_left.SelectedNode.Name;
kfs.Form_Type = 1;
kfs.Text = “修改开发商”;
kfs.ShowDialog();
if (kfs.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“修改添加开发商成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 查看开发商toolStripMenuItem_Click(object sender, EventArgs e)
{
Kfs_Form kfs = new Kfs_Form();
kfs.kfsid = treeview_left.SelectedNode.Name;
kfs.Form_Type = 2;
kfs.Text = “查看开发商”;
kfs.ShowDialog();
}
private void 删除开发商toolStripMenuItem_Click(object sender, EventArgs e)
{
SqlDataReader dr = SQLClass.getcom(“select id from fangchan where kaifashangid = ‘” + treeview_left.SelectedNode.Name + “‘”);
bool ifcom = dr.Read();
if (ifcom)
{
MessageBox.Show(“该开发商下有房产,无法删除!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (DialogResult.OK == MessageBox.Show(“确定删除(” + treeview_left.SelectedNode.Text + “)的所有信息吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
{
//确认删除数据
SQLClass.getsqlcom(“delete from kaifashang where id = ‘” + treeview_left.SelectedNode.Name + “‘ and gongsi = ‘” + treeview_left.SelectedNode.Text + “‘”);
UpdateTreeview();
SQLClass.con_close(); //关闭数据库连接,释放资源
MessageBox.Show(“删除开发商成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void 添加楼盘toolStripMenuItem_Click(object sender, EventArgs e)
{
Fangchan_Form fc = new Fangchan_Form();
fc.Form_Type = 0;
fc.kfsname = treeview_left.SelectedNode.Text;
fc.Text = “添加楼盘”;
fc.ShowDialog();
if (fc.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“添加楼房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 修改楼盘toolStripMenuItem_Click(object sender, EventArgs e)
{
Fangchan_Form fc = new Fangchan_Form();
fc.fcid = treeview_left.SelectedNode.Name;
fc.Form_Type = 1;
fc.Text = “修改楼盘”;
fc.ShowDialog();
if (fc.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“修改楼房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 查看楼盘toolStripMenuItem_Click(object sender, EventArgs e)
{
Fangchan_Form fc = new Fangchan_Form();
fc.fcid = treeview_left.SelectedNode.Name;
fc.Form_Type = 2;
fc.Text = “查看楼盘”;
fc.ShowDialog();
}
private void 删除楼盘toolStripMenuItem_Click(object sender, EventArgs e)
{
SqlDataReader dr = SQLClass.getcom(“select id from zhufang where fangchanid = ‘” + treeview_left.SelectedNode.Name + “‘”);
bool ifcom = dr.Read();
if (ifcom)
{
MessageBox.Show(“该栋建筑还存在住房,请先清空住房后再试!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (DialogResult.OK == MessageBox.Show(“确定删除(” + treeview_left.SelectedNode.Text + “)的所有信息吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
{
//确认删除数据
SQLClass.getsqlcom(“delete from fangchan where id = ‘” + treeview_left.SelectedNode.Name + “‘ and jianzu = ‘” + treeview_left.SelectedNode.Text + “‘”);
UpdateTreeview();
SQLClass.con_close(); //关闭数据库连接,释放资源
MessageBox.Show(“删除楼房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void 添加岗位toolStripMenuItem_Click(object sender, EventArgs e)
{
Gangwei_Form gw = new Gangwei_Form();
gw.Form_Type = 0;
gw.Text = “添加岗位”;
gw.ShowDialog();
if (gw.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“添加岗位成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 修改岗位toolStripMenuItem_Click(object sender, EventArgs e)
{
Gangwei_Form gw = new Gangwei_Form();
gw.gwid = treeview_left.SelectedNode.Name;
gw.bmname = treeview_left.SelectedNode.Parent.Text;
gw.Form_Type = 1;
gw.Text = “添加岗位”;
gw.ShowDialog();
if (gw.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“修改岗位成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void 修改部门toolStripMenuItem_Click(object sender, EventArgs e)
{
Bumen_Form bm = new Bumen_Form();
bm.bmname = treeview_left.SelectedNode.Text;
//bm.Form_Type = 1;
bm.Text = “修改部门”;
bm.ShowDialog();
if (bm.Form_OK == 1)
{
UpdateTreeview(); //更新树节点
MessageBox.Show(“修改部门成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}