ManyFormSearch.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using DataUpload.Model;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using RDIFramework.Utilities;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Configuration;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Net;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Windows.Forms;
  17. namespace DataUpload
  18. {
  19. public partial class ManyFormSearch : Form
  20. {
  21. public string dbMeter = ConfigurationManager.AppSettings["DBMeter"];
  22. IDbProvider dbHelper
  23. {
  24. get
  25. {
  26. var DbDefine = DbFactoryProvider.GetProvider(CurrentDbType.Access, dbMeter);
  27. return DbDefine;
  28. }
  29. }
  30. public delegate void SetListViewData(string sql, string type, string start, string end);
  31. public event SetListViewData FillListView;
  32. private string areaId = null;
  33. public ManyFormSearch()
  34. {
  35. InitializeComponent();
  36. }
  37. private void lBox_area_SelectedValueChanged(object sender, EventArgs e)
  38. {
  39. txt_area.Text = "";
  40. areaId = "";
  41. List<String> list = new List<String>();
  42. List<String> areaList = new List<String>();
  43. if (lBox_area.SelectedValue != null && lBox_area.SelectedValue.ToString() != "1")
  44. {
  45. for (int i = 0; i < lBox_area.SelectedItems.Count; i++)
  46. {
  47. DataRowView rowView = lBox_area.SelectedItems[i] as DataRowView;
  48. areaList.Add(rowView["小区名称"].ToString());
  49. list.Add(rowView["AreaID"].ToString());
  50. }
  51. areaId = String.Join(",", list.ToArray());
  52. txt_area.Text = String.Join(",", areaList.ToArray());
  53. }
  54. }
  55. private void FormSearch_Load(object sender, EventArgs e)
  56. {
  57. var sql = "Select * From Bsc_AreaInfo";
  58. DataTable dt = dbHelper.Fill(sql);
  59. lBox_area.ValueMember = "AreaID";
  60. lBox_area.DisplayMember = "小区名称";
  61. lBox_area.DataSource = dt;
  62. lBox_area.SelectedIndex = 0;
  63. lBox_area.SelectedItems.Clear();
  64. }
  65. private void btnOK_Click(object sender, EventArgs e)
  66. {
  67. this.btnOK.Enabled = false;
  68. var sql = "Select * From View_MeterList Where 1=1 and userNo is not null and userNo <> ''and 表地址 is not null and 表地址 <> '' ";
  69. //小区
  70. if (!string.IsNullOrEmpty(txt_area.Text))
  71. {
  72. sql += " and AreaNo in (" + areaId + ")";
  73. }
  74. string type = "1";
  75. sql += " Order by 小区名称,Right('0000' + [楼宇编号], 4),Right('0000' + [单元编号], 4),Right('0000' + [门牌编号], 4),UserNo,MeterID";
  76. string start, end;
  77. if (FillListView != null)
  78. {
  79. MyParam myParam = new MyParam()
  80. {
  81. SQL = sql,
  82. Type = type
  83. };
  84. this.Close();
  85. //new Thread(new ParameterizedThreadStart(LoadData)).Start(myParam);
  86. FillListView(myParam.SQL, myParam.Type, myParam.Start, myParam.End);
  87. }
  88. }
  89. private void LoadData(object obj)
  90. {
  91. MyParam p = obj as MyParam;
  92. FillListView(p.SQL, p.Type, p.Start, p.End);
  93. }
  94. private void btnCancel_Click(object sender, EventArgs e)
  95. {
  96. this.Close();
  97. }
  98. private class MyParam
  99. {
  100. public string SQL { get; set; }
  101. public string Type { get; set; }
  102. public string Start { get; set; }
  103. public string End { get; set; }
  104. }
  105. private void txt_area_TextChanged(object sender, EventArgs e)
  106. {
  107. }
  108. private void lBox_area_SelectedIndexChanged(object sender, EventArgs e)
  109. {
  110. }
  111. private void groupBox2_Enter(object sender, EventArgs e)
  112. {
  113. }
  114. }
  115. }