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
| private void 删除部门toolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK == MessageBox.Show(“确定删除(” + treeview_left.SelectedNode.Text + “)的所有信息吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { DataSet gwDSet = SQLClass.getDataSet(“select id from gangwei where bumen = ‘” + treeview_left.SelectedNode.Text + “‘”, “岗位信息表”); DataTable gwdt = gwDSet.Tables[“岗位信息表”]; if(gwdt.Rows.Count > 0) { for (int i = 0; i < gwdt.Rows.Count; i++) { DataSet DSet = SQLClass.getDataSet(“select id from yuangong where gangweiid = ‘” + gwdt.Rows[i][0].ToString() + “‘”, “员工信息表”); DataTable dt = DSet.Tables[“员工信息表”]; if (dt.Rows.Count > 0) { MessageBox.Show(“该节点中有员工,不能删除(” + treeview_left.SelectedNode.Text + “)的所有信息。”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { } } } else { } //确认删除数据 SQLClass.getsqlcom(“delete from gangwei where bumen = ‘” + treeview_left.SelectedNode.Text + “‘”); UpdateTreeview(); SQLClass.con_close(); //关闭数据库连接,释放资源 MessageBox.Show(“删除岗位成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void 删除岗位toolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK == MessageBox.Show(“确定删除(” + treeview_left.SelectedNode.Text + “)的所有信息吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { DataSet DSet = SQLClass.getDataSet(“select id from yuangong where gangweiid = ‘” + treeview_left.SelectedNode.Name + “‘”, “员工信息表”); DataTable dt = DSet.Tables[“员工信息表”]; if (dt.Rows.Count > 0) { MessageBox.Show(“该节点中有员工,不能删除(” + treeview_left.SelectedNode.Text + “)的所有信息。”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { //确认删除数据 SQLClass.getsqlcom(“delete from gangwei where id = ‘” + treeview_left.SelectedNode.Name + “‘ and gangwei = ‘” + treeview_left.SelectedNode.Text + “‘”); UpdateTreeview(); SQLClass.con_close(); //关闭数据库连接,释放资源 MessageBox.Show(“删除岗位成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } private void 刷新树toolStripMenuItem_Click(object sender, EventArgs e) { UpdateTreeview(); treeview_left_AfterSelect(sender, e); } private void 刷新列toolStripMenuItem_Click(object sender, EventArgs e) { treeview_left_AfterSelect(sender, e); } private void listview_right_MouseDown(object sender, MouseEventArgs e) { this.listview_right.ContextMenuStrip = conMenuStr_list_1; conMenuStr_list_1.Items.Clear(); switch (splitcon1.Tag.ToString()) { case “sy”: ToolStripMenuItem addzhufang = new ToolStripMenuItem(“添加住房”); addzhufang.Click += new EventHandler(添加住房toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addzhufang); break; case “yz”: ToolStripMenuItem addyezhu = new ToolStripMenuItem(“添加业主”); addyezhu.Click += new EventHandler(添加业主toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addyezhu); break; case “yg”: ToolStripMenuItem addyuangong = new ToolStripMenuItem(“添加员工”); addyuangong.Click += new EventHandler(添加员工toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addyuangong); break; case “yw”: if (treeview_left.SelectedNode == null) //判断是否选中了树节点 { return; } switch (treeview_left.SelectedNode.Name) { case “1”: ToolStripMenuItem addrichang = new ToolStripMenuItem(“添加日常”); addrichang.Click += new EventHandler(添加日常toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addrichang); break; case “2”: ToolStripMenuItem addshenqing = new ToolStripMenuItem(“添加申请”); addshenqing.Click += new EventHandler(添加申请toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addshenqing); break; case “3”: ToolStripMenuItem addshoufei = new ToolStripMenuItem(“添加收费”); addshoufei.Click += new EventHandler(添加收费toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addshoufei); break; } break; } if (listview_right.SelectedItems.Count <= 0 || listview_right.SelectedItems[0].SubItems[1].Text == “”) { } else { switch (splitcon1.Tag.ToString()) { case “sy”: ToolStripMenuItem revisezhufang = new ToolStripMenuItem(“修改住房”); ToolStripMenuItem deletezhufang = new ToolStripMenuItem(“删除住房”); ToolStripMenuItem inzhufang = new ToolStripMenuItem(“业主入住”); ToolStripMenuItem outzhufang = new ToolStripMenuItem(“业主迁出”); ToolStripMenuItem rezhufang = new ToolStripMenuItem(“退款迁出”); revisezhufang.Click += new EventHandler(修改住房toolStripMenuItem_Click); deletezhufang.Click += new EventHandler(删除住房toolStripMenuItem_Click); inzhufang.Click += new EventHandler(业主入住toolStripMenuItem_Click); outzhufang.Click += new EventHandler(业主迁出toolStripMenuItem_Click); rezhufang.Click += new EventHandler(退款迁出toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(revisezhufang); conMenuStr_list_1.Items.Add(deletezhufang); conMenuStr_list_1.Items.Add(inzhufang); conMenuStr_list_1.Items.Add(outzhufang); conMenuStr_list_1.Items.Add(rezhufang); break; case “yz”: ToolStripMenuItem reviseyezhu = new ToolStripMenuItem(“修改业主”); ToolStripMenuItem deleteyezhu = new ToolStripMenuItem(“删除业主”); ToolStripMenuItem passyezhu = new ToolStripMenuItem(“审核通过”); ToolStripMenuItem cancelyezhu = new ToolStripMenuItem(“取消审核”); reviseyezhu.Click += new EventHandler(修改业主toolStripMenuItem_Click); deleteyezhu.Click += new EventHandler(删除业主toolStripMenuItem_Click); passyezhu.Click += new EventHandler(审核通过toolStripMenuItem_Click); cancelyezhu.Click += new EventHandler(取消审核toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(reviseyezhu); conMenuStr_list_1.Items.Add(deleteyezhu); conMenuStr_list_1.Items.Add(passyezhu); conMenuStr_list_1.Items.Add(cancelyezhu); ToolStripMenuItem addshoufei = new ToolStripMenuItem(“添加收费”); addshoufei.Click += new EventHandler(添加收费toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(addshoufei); break; case “yg”: ToolStripMenuItem reviseyuangong = new ToolStripMenuItem(“修改员工”); ToolStripMenuItem deleteyuangong = new ToolStripMenuItem(“删除员工”); reviseyuangong.Click += new EventHandler(修改员工toolStripMenuItem_Click); deleteyuangong.Click += new EventHandler(删除员工toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(reviseyuangong); conMenuStr_list_1.Items.Add(deleteyuangong); if(glyqx == 2) { ToolStripMenuItem sheyuangong = new ToolStripMenuItem(“设为管理员”); ToolStripMenuItem quyuangong = new ToolStripMenuItem(“设为普通员工”); sheyuangong.Click += new EventHandler(设为管理员toolStripMenuItem_Click); quyuangong.Click += new EventHandler(设为普通员工toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(sheyuangong); conMenuStr_list_1.Items.Add(quyuangong); } break; case “yw”: if (treeview_left.SelectedNode == null) //判断是否选中了树节点 { return; } switch (treeview_left.SelectedNode.Name) { case “1”: ToolStripMenuItem reviserichang = new ToolStripMenuItem(“修改日常”); ToolStripMenuItem deleterichang = new ToolStripMenuItem(“删除日常”); ToolStripMenuItem overrichang = new ToolStripMenuItem(“设为已完成”); ToolStripMenuItem cancelrichang = new ToolStripMenuItem(“设为未完成”); reviserichang.Click += new EventHandler(修改日常toolStripMenuItem_Click); deleterichang.Click += new EventHandler(删除日常toolStripMenuItem_Click); overrichang.Click += new EventHandler(设为已完成toolStripMenuItem_Click); cancelrichang.Click += new EventHandler(设为未完成toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(reviserichang); conMenuStr_list_1.Items.Add(deleterichang); conMenuStr_list_1.Items.Add(overrichang); conMenuStr_list_1.Items.Add(cancelrichang); break; case “2”: ToolStripMenuItem reviseshenqing = new ToolStripMenuItem(“修改申请”); ToolStripMenuItem deleteshenqing = new ToolStripMenuItem(“删除申请”); ToolStripMenuItem acceptshenqing = new ToolStripMenuItem(“受理申请”); ToolStripMenuItem cancelacceptshenqing = new ToolStripMenuItem(“取消受理”); ToolStripMenuItem overshenqing = new ToolStripMenuItem(“完成申请”); ToolStripMenuItem cancelovershenqing = new ToolStripMenuItem(“取消完成”); reviseshenqing.Click += new EventHandler(修改申请toolStripMenuItem_Click); deleteshenqing.Click += new EventHandler(删除申请toolStripMenuItem_Click); acceptshenqing.Click += new EventHandler(受理申请toolStripMenuItem_Click); cancelacceptshenqing.Click += new EventHandler(取消受理toolStripMenuItem_Click); overshenqing.Click += new EventHandler(完成申请toolStripMenuItem_Click); cancelovershenqing.Click += new EventHandler(取消完成toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(reviseshenqing); conMenuStr_list_1.Items.Add(deleteshenqing); conMenuStr_list_1.Items.Add(acceptshenqing); conMenuStr_list_1.Items.Add(cancelacceptshenqing); conMenuStr_list_1.Items.Add(overshenqing); conMenuStr_list_1.Items.Add(cancelovershenqing); break; case “3”: ToolStripMenuItem reviseshoufei = new ToolStripMenuItem(“修改收费”); ToolStripMenuItem deleteshoufei = new ToolStripMenuItem(“删除收费常”); reviseshoufei.Click += new EventHandler(修改收费toolStripMenuItem_Click); deleteshoufei.Click += new EventHandler(删除收费toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(reviseshoufei); conMenuStr_list_1.Items.Add(deleteshoufei); ToolStripMenuItem yishoufei = new ToolStripMenuItem(“设为已缴费”); ToolStripMenuItem weishoufei = new ToolStripMenuItem(“设为未缴费”); yishoufei.Click += new EventHandler(设为已缴费toolStripMenuItem_Click); weishoufei.Click += new EventHandler(设为未缴费toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(yishoufei); conMenuStr_list_1.Items.Add(weishoufei); break; } break; } } ToolStripMenuItem daochuexcel = new ToolStripMenuItem(“导出Excel”); daochuexcel.Click += new EventHandler(导出ExceltoolStripMenuItem_Click); conMenuStr_list_1.Items.Add(daochuexcel); ToolStripMenuItem refresh = new ToolStripMenuItem(“刷新”); refresh.Click += new EventHandler(刷新列toolStripMenuItem_Click); conMenuStr_list_1.Items.Add(refresh); } //listview列表右键菜单 private void 导出ExceltoolStripMenuItem_Click(object sender, EventArgs e) { if(listview_right.Items.Count <= 0) { MessageBox.Show(“列表为空,不能导出!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ExportToExecl(); } } private void 添加住房toolStripMenuItem_Click(object sender, EventArgs e) { SqlDataReader DR = SQLClass.getcom(“select id from fangchan”); bool ifcom = DR.Read(); if(!ifcom) { MessageBox.Show(“你还没有添加房产不能进行该操作!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Zhufang_Form zf = new Zhufang_Form(); zf.Form_Type = 0; if(treeview_left.SelectedNode == null) { zf.fcname = null; } else { zf.fcname = treeview_left.SelectedNode.Text; } zf.Text = “添加住房”; zf.ShowDialog(); if (zf.Form_OK == 1) { treeview_left_AfterSelect(sender, e); //treeview_left_AfterSelect(sender, e); MessageBox.Show(“添加住房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void 修改住房toolStripMenuItem_Click(object sender, EventArgs e) { if(listview_right.SelectedItems[0].SubItems[5].Text == “已入住”) { if (DialogResult.OK == MessageBox.Show(“住房处于入住状态,修改可能会出现错误,确定要继续吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { } else { MessageBox.Show(“操作已取消!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { } Zhufang_Form zf = new Zhufang_Form(); if (treeview_left.SelectedNode == null) { zf.fcname = null; } else { zf.fcname = treeview_left.SelectedNode.Text; } zf.zfid = listview_right.SelectedItems[0].SubItems[1].Text; zf.Form_Type = 1; zf.Text = “修改住房”; zf.ShowDialog(); if (zf.Form_OK == 1) { treeview_left_AfterSelect(sender, e); MessageBox.Show(“修改住房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void 删除住房toolStripMenuItem_Click(object sender, EventArgs e) { if(listview_right.SelectedItems[0].SubItems[5].Text == “已入住”) { MessageBox.Show(“已有业主入住,无法删除!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (DialogResult.OK == MessageBox.Show(“确定删除(” + treeview_left.SelectedNode.Text + “的” + listview_right.SelectedItems[0].SubItems[1].Text + “号住房)的所有信息吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { //确认删除数据 SQLClass.getsqlcom(“delete from zhufang where id = ‘” + listview_right.SelectedItems[0].SubItems[1].Text + “‘”); treeview_left_AfterSelect(sender, e); SQLClass.con_close(); //关闭数据库连接,释放资源 MessageBox.Show(“删除住房成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } private void 业主入住toolStripMenuItem_Click(object sender, EventArgs e) { Zhufang_Form zf = new Zhufang_Form(); if (treeview_left.SelectedNode == null) { zf.fcname = null; } else { zf.fcname = treeview_left.SelectedNode.Text; } if(listview_right.SelectedItems[0].SubItems[5].Text == “已入住”) { MessageBox.Show(“已有用户入住,未迁出之前不得再入住!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { zf.zfid = listview_right.SelectedItems[0].SubItems[1].Text; zf.Form_Type = 3; zf.Text = “业主入住”; zf.ShowDialog(); if (zf.Form_OK == 1) { treeview_left_AfterSelect(sender, e); MessageBox.Show(“设置入住成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } private void 业主迁出toolStripMenuItem_Click(object sender, EventArgs e) { if (listview_right.SelectedItems[0].SubItems[5].Text == “已入住”) { if (DialogResult.OK == MessageBox.Show(“确定设置(” + treeview_left.SelectedNode.Text + “的” + listview_right.SelectedItems[0].SubItems[1].Text + “号住房)的业主迁出吗?”, “询问”, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { SQLClass.getsqlcom(“update zhufang set yezhuid = ”,zhuangtai = ‘0’ where id = ‘” + listview_right.SelectedItems[0].SubItems[1].Text + “‘”); treeview_left_AfterSelect(sender, e); MessageBox.Show(“设置迁出成功!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(“暂无用户入住,无需迁出!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
|