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 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
| //以下是导航图标动作————————————————————————————— private void picbox_shouye_MouseHover(object sender, EventArgs e) { if (picbox_shouye.Tag.ToString() == “0”) { picbox_shouye.Image = Image.FromFile(“images/sy_mouse.png”); } } private void picbox_shouye_MouseLeave(object sender, EventArgs e) { if(picbox_shouye.Tag.ToString() == “0”) { picbox_shouye.Image = Image.FromFile(“images/sy.png”); } } private void picbox_shouye_Click(object sender, EventArgs e) { picbox_shouye.Tag = “1”; picbox_shouye.Image = Image.FromFile(“images/sy_select.png”); picbox_yezhu.Tag = “0”; picbox_yezhu.Image = Image.FromFile(“images/yz.png”); picbox_yuangong.Tag = “0”; picbox_yuangong.Image = Image.FromFile(“images/yg.png”); picbox_yewu.Tag = “0”; picbox_yewu.Image = Image.FromFile(“images/yw.png”); picbox_guanyu.Tag = “0”; picbox_guanyu.Image = Image.FromFile(“images/gy.png”); splitcon1.Tag = “sy”; UpdateComboBox(); UpdateTreeview(); treeview_left_AfterSelect(sender, e); } private void picbox_yezhu_MouseHover(object sender, EventArgs e) { if (picbox_yezhu.Tag.ToString() == “0”) { picbox_yezhu.Image = Image.FromFile(“images/yz_mouse.png”); } } private void picbox_yezhu_MouseLeave(object sender, EventArgs e) { if (picbox_yezhu.Tag.ToString() == “0”) { picbox_yezhu.Image = Image.FromFile(“images/yz.png”); } } private void picbox_yezhu_Click(object sender, EventArgs e) { picbox_shouye.Tag = “0”; picbox_shouye.Image = Image.FromFile(“images/sy.png”); picbox_yezhu.Tag = “1”; picbox_yezhu.Image = Image.FromFile(“images/yz_select.png”); picbox_yuangong.Tag = “0”; picbox_yuangong.Image = Image.FromFile(“images/yg.png”); picbox_yewu.Tag = “0”; picbox_yewu.Image = Image.FromFile(“images/yw.png”); picbox_guanyu.Tag = “0”; picbox_guanyu.Image = Image.FromFile(“images/gy.png”); splitcon1.Tag = “yz”; UpdateComboBox(); UpdateTreeview(); treeview_left_AfterSelect(sender, e); } private void picbox_yuangong_MouseHover(object sender, EventArgs e) { if (picbox_yuangong.Tag.ToString() == “0”) { picbox_yuangong.Image = Image.FromFile(“images/yg_mouse.png”); } } private void picbox_yuangong_MouseLeave(object sender, EventArgs e) { if (picbox_yuangong.Tag.ToString() == “0”) { picbox_yuangong.Image = Image.FromFile(“images/yg.png”); } } private void picbox_yuangong_Click(object sender, EventArgs e) { picbox_shouye.Tag = “0”; picbox_shouye.Image = Image.FromFile(“images/sy.png”); picbox_yezhu.Tag = “0”; picbox_yezhu.Image = Image.FromFile(“images/yz.png”); picbox_yuangong.Tag = “1”; picbox_yuangong.Image = Image.FromFile(“images/yg_select.png”); picbox_yewu.Tag = “0”; picbox_yewu.Image = Image.FromFile(“images/yw.png”); picbox_guanyu.Tag = “0”; picbox_guanyu.Image = Image.FromFile(“images/gy.png”); splitcon1.Tag = “yg”; UpdateComboBox(); UpdateTreeview(); treeview_left_AfterSelect(sender, e); } private void picbox_yewu_MouseHover(object sender, EventArgs e) { if (picbox_yewu.Tag.ToString() == “0”) { picbox_yewu.Image = Image.FromFile(“images/yw_mouse.png”); } } private void picbox_yewu_MouseLeave(object sender, EventArgs e) { if (picbox_yewu.Tag.ToString() == “0”) { picbox_yewu.Image = Image.FromFile(“images/yw.png”); } } private void picbox_yewu_Click(object sender, EventArgs e) { picbox_shouye.Tag = “0”; picbox_shouye.Image = Image.FromFile(“images/sy.png”); picbox_yezhu.Tag = “0”; picbox_yezhu.Image = Image.FromFile(“images/yz.png”); picbox_yuangong.Tag = “0”; picbox_yuangong.Image = Image.FromFile(“images/yg.png”); picbox_yewu.Tag = “1”; picbox_yewu.Image = Image.FromFile(“images/yw_select.png”); picbox_guanyu.Tag = “0”; picbox_guanyu.Image = Image.FromFile(“images/gy.png”); splitcon1.Tag = “yw”; UpdateTreeview(); } private void picbox_guanyu_MouseHover(object sender, EventArgs e) { if (picbox_guanyu.Tag.ToString() == “0”) { picbox_guanyu.Image = Image.FromFile(“images/gy_mouse.png”); } } private void picbox_guanyu_MouseLeave(object sender, EventArgs e) { if (picbox_guanyu.Tag.ToString() == “0”) { picbox_guanyu.Image = Image.FromFile(“images/gy.png”); } } private void picbox_guanyu_Click(object sender, EventArgs e) { //picbox_shouye.Tag = “0”; picbox_shouye.Image = Image.FromFile(“images/sy.png”); //picbox_yezhu.Tag = “0”; picbox_yezhu.Image = Image.FromFile(“images/yz.png”); //picbox_yuangong.Tag = “0”; picbox_yuangong.Image = Image.FromFile(“images/yg.png”); //picbox_yewu.Tag = “0”; picbox_yewu.Image = Image.FromFile(“images/yw.png”); //picbox_guanyu.Tag = “1”; picbox_guanyu.Image = Image.FromFile(“images/gy_select.png”); //splitcon1.Tag = “gy”; About aboutme = new About(); //新建关于本软件的窗体类 aboutme.ShowDialog(); //运行新创建的窗体 picbox_guanyu.Image = Image.FromFile(“images/gy.png”); if (picbox_yezhu.Tag.ToString() == “1”) { picbox_yezhu.Image = Image.FromFile(“images/yz_select.png”); } else if (picbox_yuangong.Tag.ToString() == “1”) { picbox_yuangong.Image = Image.FromFile(“images/yg_select.png”); } else if (picbox_yewu.Tag.ToString() == “1”) { picbox_yewu.Image = Image.FromFile(“images/yw_select.png”); } else { picbox_shouye.Image = Image.FromFile(“images/sy_select.png”); } } private int Iskaifashang() { if (treeview_left.SelectedNode == null) //判断是否选中了树节点 { return -1; } int iskaifashang; 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) { iskaifashang = 1; } else { iskaifashang = 0; } return iskaifashang; } public void UpdateComboBox() { combox.Items.Clear(); switch(splitcon1.Tag.ToString()) { case “sy”: combox.Items.Add(“住房编号”); combox.Items.Add(“楼层”); combox.Items.Add(“住房配置”); combox.Items.Add(“业主名称”); combox.Items.Add(“状态”); combox.Items.Add(“所属房产”); combox.Items.Add(“开发商”); combox.SelectedIndex = 0; break; case “yz”: combox.Items.Add(“业主编号”); combox.Items.Add(“姓名”); combox.Items.Add(“性别”); combox.Items.Add(“身份证号”); combox.Items.Add(“权限”); combox.Items.Add(“用户名”); combox.SelectedIndex = 0; break; case “yg”: combox.Items.Add(“员工编号”); combox.Items.Add(“姓名”); combox.Items.Add(“性别”); combox.Items.Add(“部门”); combox.Items.Add(“岗位”); combox.Items.Add(“权限”); combox.Items.Add(“用户名”); combox.SelectedIndex = 0; break; case “yw”: if(treeview_left.SelectedNode == null) { return; } else { switch(treeview_left.SelectedNode.Name) { case “1”: combox.Items.Add(“事务编号”); combox.Items.Add(“事务名称”); combox.Items.Add(“状态”); combox.Items.Add(“负责人”); combox.SelectedIndex = 0; break; case “2”: combox.Items.Add(“申请编号”); combox.Items.Add(“申请名称”); combox.Items.Add(“申请人”); combox.Items.Add(“状态”); combox.Items.Add(“负责人”); combox.SelectedIndex = 0; break; case “3”: combox.Items.Add(“收费编号”); combox.Items.Add(“收费事项”); combox.Items.Add(“状态”); combox.Items.Add(“缴费业主”); combox.Items.Add(“负责人”); combox.SelectedIndex = 0; break; } } break; } } public string givetempsql(string sql) { if (checkbox.Checked) { if(isonce) { isonce = false; needwhere = true; if (splitcon1.Tag.ToString() == “yw”) { if (treeview_left.SelectedNode == null) { MessageBox.Show(“你当前的位置需要选中树节点后查询!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = search.newsql(splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name, needwhere); } } else { sql = search.newsql(splitcon1.Tag.ToString(), “0”); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), “0”, needwhere); } } else { isonce = false; needwhere = false; if (splitcon1.Tag.ToString() == “yw”) { if (treeview_left.SelectedNode == null) { MessageBox.Show(“你当前的位置需要选中树节点后查询!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name, needwhere); } } else { sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), “0”, needwhere); } } } else { if (isonce) { isonce = false; needwhere = true; if (splitcon1.Tag.ToString() == “yw”) { if (treeview_left.SelectedNode == null) { MessageBox.Show(“你当前的位置需要选中树节点后查询!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = search.newsql(splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name, needwhere); } } else { sql = search.newsql(splitcon1.Tag.ToString(), “0”); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), “0”, needwhere); } } else { isonce = false; needwhere = true; if (splitcon1.Tag.ToString() == “yw”) { if (treeview_left.SelectedNode == null) { MessageBox.Show(“你当前的位置需要选中树节点后查询!”, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = search.newsql(splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), treeview_left.SelectedNode.Name, needwhere); } } else { sql = search.newsql(splitcon1.Tag.ToString(), “0”); sql = search.Searchsql(sql, combox.Text, txt_context.Text.Trim(), splitcon1.Tag.ToString(), “0”, needwhere); } } } return sql; } private void txt_context_Enter(object sender, EventArgs e) { txt_context.Tag = txt_context.Text; txt_context.Text = “”; txt_context.ForeColor = Color.Black; } private void txt_context_KeyPress(object sender, KeyPressEventArgs e) { if(e.KeyChar == 13) { picbox_search_Click(sender, e); e.Handled = true; } } private void picbox_search_Click(object sender, EventArgs e) { listview_columns(); tempsql = givetempsql(tempsql); tempint = 0; UpdateListview(tempsql); } private void combox_TextChanged(object sender, EventArgs e) { switch(splitcon1.Tag.ToString()) { case “sy”: switch(combox.Text) { case “住房编号”: txt_context.Text = “请输入住房编号!”; break; case “楼层”: txt_context.Text = “请输入楼层!”; break; case “住房配置”: txt_context.Text = “请输入住房配置!”; break; case “业主名称”: txt_context.Text = “请输入业主名称!”; break; case “状态”: txt_context.Text = “0:未入住 1:已迁入”; break; case “所属房产”: txt_context.Text = “请输入所属房产的名称!”; break; case “开发商”: txt_context.Text = “请输入开发商名称!”; break; } break; case “yz”: switch(combox.Text) { case “业主编号”: txt_context.Text = “请输入业主编号!”; break; case “业主姓名”: txt_context.Text = “请输入业主姓名!”; break; case “性别”: txt_context.Text = “请输入业主性别!”; break; case “身份证号”: txt_context.Text = “请输入身份证号!”; break; case “权限”: txt_context.Text = “0:未审核 1:已审核”; break; case “用户名”: txt_context.Text = “请输入业主用户名!”; break; } break; case “yg”: switch(combox.Text) { case “员工编号”: txt_context.Text = “请输入员工编号!”; break; case “员工姓名”: txt_context.Text = “请输入员工姓名!”; break; case “性别”: txt_context.Text = “男 或 女!”; break; case “部门”: txt_context.Text = “请输入部门名称!”; break; case “岗位”: txt_context.Text = “请输入岗位名称!”; break; case “权限”: txt_context.Text = “0:普通员工 1:管理员 2:超级管理员”; break; case “用户名”: txt_context.Text = “请输入员工用户名!”; break; } break; case “yw”: if(treeview_left.SelectedNode == null) { return; } switch(treeview_left.SelectedNode.Name) { case “1”: switch(combox.Text) { case “事务编号”: txt_context.Text = “请输入事务编号!”; break; case “事务名称”: txt_context.Text = “请输入事项名称!”; break; case “状态”: txt_context.Text = “0:未完成 1:已完成”; break; case “负责人”: txt_context.Text = “请输入员工姓名!”; break; } break; case “2”: switch(combox.Text) { case “申请编号”: txt_context.Text = “请输入申请编号!”; break; case “申请名称”: txt_context.Text = “请输入申请名称!”; break; case “申请人”: txt_context.Text = “请输入业主姓名!”; break; case “状态”: txt_context.Text = “0:未处理 1:已处理: 2:已完成”; break; case “负责人”: break; } break; case “3”: switch(combox.Text) { case “收费编号”: txt_context.Text = “请输入收费编号!”; break; case “收费事项”: txt_context.Text = “请输入收费事项!”; break; case “状态”: txt_context.Text = “0:未缴费 1:已缴费”; break; case “缴费业主”: txt_context.Text = “请输入业主名称!”; break; case “负责人”: txt_context.Text = “请输入员工名称!”; break; } break; } break; } txt_context.ForeColor = Color.Gray; } private void txt_context_Leave(object sender, EventArgs e) { if(txt_context.Text == “”) { txt_context.Text = txt_context.Tag.ToString(); txt_context.ForeColor = Color.Gray; } } //统计代码 public void Tongji() { if(treeview_left.SelectedNode == null) { switch(splitcon1.Tag.ToString()) { case “sy”: DataSet kfsDSet = SQLClass.getDataSet(“select count(id) from kaifashang”, “查询信息表”); DataTable kfsdt = kfsDSet.Tables[“查询信息表”]; DataSet fcDSet = SQLClass.getDataSet(“select count(id) from fangchan”, “查询信息表”); DataTable fcdt = fcDSet.Tables[“查询信息表”]; DataSet zfDSet = SQLClass.getDataSet(“select count(id) from zhufang”, “查询信息表”); DataTable zfdt = zfDSet.Tables[“查询信息表”]; MessageBox.Show(“开发商” + kfsdt.Rows[0][0].ToString() + “家,楼房” + fcdt.Rows[0][0].ToString() + “栋,住房” + zfdt.Rows[0][0].ToString() + “间”, “查询结果”, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case “yz”: DataSet yzDSet = SQLClass.getDataSet(“select count(id),quanxian from yezhu group by quanxian”, “查询信息表”); DataTable yzdt = yzDSet.Tables[“查询信息表”]; int yznum = Convert.ToInt32(yzdt.Rows[0][0].ToString()) + Convert.ToInt32(yzdt.Rows[1][0]); MessageBox.Show(“共计已注册业主” + yznum + “人,已审核” + yzdt.Rows[1][0].ToString() + “人,未审核” + yzdt.Rows[0][0].ToString() + “人”, “查询结果”, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case “yg”: DataSet ygDSet = SQLClass.getDataSet(“select count(id),quanxian from yezhu group by quanxian”, “查询信息表”); DataTable ygdt = ygDSet.Tables[“查询信息表”]; //int ygnum = Convert.ToInt32(ygdt.Rows[0][0].ToString()) + Convert.ToInt32(ygdt.Rows[1][0].ToString()) + Convert.ToInt32(ygdt.Rows[2][0].ToString()); MessageBox.Show(ygdt.Rows.Count.ToString(), “查询结果”, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } else { switch(splitcon1.Tag.ToString()) { case “sy”: break; case “yz”: break; case “yg”: break; case “yw”: break; } } } private void pictureBox1_Click(object sender, EventArgs e) { changeuser = true; this.Close(); } private void picbox_search_MouseHover(object sender, EventArgs e) { picbox_search.Image = Image.FromFile(“images/search_mouse.png”); } private void picbox_search_MouseLeave(object sender, EventArgs e) { picbox_search.Image = Image.FromFile(“images/search.png”); } //public void Chaxun(string sql) //{ // DataSet DSet = SQLClass.getDataSet(sql, “查询信息表”); // DataTable dt = DSet.Tables[“查询信息表”]; // if(dt.Rows.Count > 0) // { // for (int i = 0; i < dt.Rows.Count; i++) // { // } // } //} //以下两个函数是关于导出EXCEL表格的,是通过网上直接找到使用的,尚未理解。 public void ExportToExecl() //导出excel { System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = “xls”; sfd.Filter = “Excel文件(*.xls)|*.xls”; if (sfd.ShowDialog() == DialogResult.OK) { DoExport(this.listview_right, sfd.FileName); } } private void DoExport(ListView listView, string strFileName) { int rowNum = listView.Items.Count; int columnNum = listView.Items[0].SubItems.Count; int rowIndex = 1; int columnIndex = 0; if (rowNum == 0 || string.IsNullOrEmpty(strFileName)) { return; } if (rowNum > 0) { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); if (xlApp == null) { MessageBox.Show(“无法创建excel对象,可能您的系统没有安装excel”); return; } xlApp.DefaultFilePath = “”; xlApp.DisplayAlerts = true; xlApp.SheetsInNewWorkbook = 1; Microsoft.Office.Interop.Excel.Workbook xlBook = xlApp.Workbooks.Add(true); //将ListView的列名导入Excel表第一行 foreach (ColumnHeader dc in listView.Columns) { columnIndex++; xlApp.Cells[rowIndex, columnIndex] = dc.Text; } //将ListView中的数据导入Excel中 for (int i = 0; i < rowNum; i++) { rowIndex++; columnIndex = 0; for (int j = 0; j < columnNum; j++) { columnIndex++; //注意这个在导出的时候加了“\t” 的目的就是避免导出的数据显示为科学计数法。可以放在每行的首尾。 xlApp.Cells[rowIndex, columnIndex] = Convert.ToString(listView.Items[i].SubItems[j].Text) + “\t”; } } //例外需要说明的是用strFileName,Excel.XlFileFormat.xlExcel9795保存方式时 当你的Excel版本不是95、97 而是2003、2007 时导出的时候会报一个错误:异常来自 HRESULT:0x800A03EC。 解决办法就是换成strFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal。 xlBook.SaveAs(strFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); xlApp = null; xlBook = null; MessageBox.Show(“OK”); } } } }
|