FrmCusSelect.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.Dresses.DressManagement
  11. {
  12. public partial class FrmCusSelect : LYFZ.Software.UI.Dresses.DressManagement.FrmCusSelect
  13. {
  14. public FrmCusSelect()
  15. {
  16. this.Shown+=FrmCusSelect_Shown;
  17. this.txtkeyword.KeyDown += txtkeyword_KeyDown;
  18. this.btnSlect.Click += btnSlect_Click;
  19. this.btnOK.Click += btnOK_Click;
  20. this.btnclose.Click += btnclose_Click;
  21. this.listViewData.ColumnClick += listViewData_ColumnClick;
  22. this.listViewData.MouseDoubleClick += listViewData_MouseDoubleClick;
  23. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  24. }
  25. /// <summary>
  26. /// 客户编号
  27. /// </summary>
  28. public string StrClientNumber;
  29. /// <summary>
  30. /// 相片集合
  31. /// </summary>
  32. ImageList mlistImage = new ImageList();
  33. /// <summary>
  34. /// 用于排序的类
  35. /// </summary>
  36. LYFZ.ComponentLibrary.ListViewColumnSorter lvwColumnSorter;
  37. /// <summary>
  38. /// 窗体加载事件
  39. /// </summary>
  40. /// <param name="sender"></param>
  41. /// <param name="e"></param>
  42. void FrmCusSelect_Shown(object sender, EventArgs e)
  43. {
  44. this.listViewData.View = View.Details;
  45. this.listViewData.GridLines = true;
  46. string[] StrColumns = "客户姓名,客户电话,客户性别,客户生日,客户婚期,客户QQ,客户微信,客户地址".Split(',');
  47. for (int i = 0; i < StrColumns.Length; i++)
  48. {
  49. ColumnHeader ch = new ColumnHeader();
  50. ch.Text = StrColumns[i].Trim();
  51. ch.TextAlign = HorizontalAlignment.Left;
  52. switch (StrColumns[i].Trim())
  53. {
  54. case "客户生日":
  55. case "客户婚期":
  56. ch.Width = 120;
  57. break;
  58. default: ch.Width = 100; break;
  59. }
  60. this.listViewData.Columns.Add(ch);
  61. }
  62. this.mlistImage.ImageSize = new Size(1, 27);
  63. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  64. this.listViewData.SmallImageList = mlistImage;
  65. this.lvwColumnSorter = new ComponentLibrary.ListViewColumnSorter();
  66. this.listViewData.ListViewItemSorter = this.lvwColumnSorter;
  67. this.PublicFunctionRows();
  68. }
  69. /// <summary>
  70. /// 回车查询
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. void txtkeyword_KeyDown(object sender, KeyEventArgs e)
  75. {
  76. if (e.KeyCode == Keys.Enter)
  77. { this.PublicFunctionRows(); }
  78. }
  79. /// <summary>
  80. /// 查询
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="e"></param>
  84. void btnSlect_Click(object sender, EventArgs e)
  85. { this.PublicFunctionRows(); }
  86. /// <summary>
  87. /// 确定
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. void btnOK_Click(object sender, EventArgs e)
  92. {
  93. if (this.listViewData.SelectedItems.Count == 0)
  94. { MessageBoxCustom.Show("请选中你要的客户!"); return; }
  95. this.StrClientNumber = this.listViewData.SelectedItems[0].Tag.ToString().Trim();
  96. this.Close();
  97. }
  98. /// <summary>
  99. /// 关闭
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. void btnclose_Click(object sender, EventArgs e)
  104. { this.Close(); }
  105. /// <summary>
  106. /// 点击排序
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. void listViewData_ColumnClick(object sender, ColumnClickEventArgs e)
  111. {
  112. // 检查点击的列是不是现在的排序列.
  113. if (e.Column == lvwColumnSorter.SortColumn)
  114. {
  115. // 重新设置此列的排序方法.
  116. if (lvwColumnSorter.Order == SortOrder.Ascending)
  117. { lvwColumnSorter.Order = SortOrder.Descending; }
  118. else
  119. { lvwColumnSorter.Order = SortOrder.Ascending; }
  120. }
  121. else
  122. {
  123. // 设置排序列,默认为正向排序
  124. lvwColumnSorter.SortColumn = e.Column;
  125. lvwColumnSorter.Order = SortOrder.Ascending;
  126. }
  127. // 用新的排序方法对ListView排序
  128. this.listViewData.Sort();
  129. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
  130. }
  131. /// <summary>
  132. /// 双击选中
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. void listViewData_MouseDoubleClick(object sender, MouseEventArgs e)
  137. {
  138. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  139. { this.btnOK_Click(this, null); }
  140. }
  141. /// <summary>
  142. /// 创建行
  143. /// </summary>
  144. void PublicFunctionRows()
  145. {
  146. this.ucPagerEx1.PageCurrent = 1;
  147. this.ucPagerEx1.PageSize = 100;
  148. this.ucPagerEx1.Bind();
  149. }
  150. /// <summary>
  151. /// 画分页
  152. /// </summary>
  153. /// <param name="e"></param>
  154. /// <returns></returns>
  155. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  156. {
  157. this.listViewData.Items.Clear();
  158. string StrWhere = "Cus_Type!='儿童'";
  159. DataTable dt = new DataTable();
  160. if (!string.IsNullOrEmpty(this.txtkeyword.Text))
  161. { StrWhere += " and (Cus_Name like '%" + this.txtkeyword.Text + "%' or Cus_Telephone like '%" + this.txtkeyword.Text + "%' or Cus_NamePinyin like '" + this.txtkeyword.Text + "')"; }
  162. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  163. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  164. {
  165. pageData.TableName = "tb_ErpCustomer";
  166. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  167. pageData.PageSize = this.ucPagerEx1.PageSize;
  168. pageData.QueryCondition = StrWhere.ToString();
  169. pageData.QueryFieldName = "Cus_CustomerNumber,Cus_Name,Cus_Telephone,Cus_Sex,Cus_Birthday,Cus_BirthdayLunar,Cus_DayForMarriage,Cus_DayForMarriageLunar,Cus_QQ,Cus_MicroSignal,Cus_Address";
  170. pageData.OrderStr = "ID desc";
  171. pageData.OrderType = 1;
  172. DataSet da = pageData.QueryDataTable();
  173. dt = da.Tables[0];
  174. if (dt.Rows.Count > 0)
  175. {
  176. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  177. {
  178. #region
  179. for (int t = 0; t < dt.Rows.Count; t++)
  180. {
  181. ListViewItem lvItem = new ListViewItem();
  182. lvItem.Tag = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
  183. lvItem.Text = dt.Rows[t]["Cus_Name"].ToString().Trim();
  184. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  185. ListSubItem.Name = "客户电话";
  186. ListSubItem.Text = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  187. lvItem.SubItems.Add(ListSubItem);
  188. ListSubItem = new ListViewItem.ListViewSubItem();
  189. ListSubItem.Name = "客户性别";
  190. ListSubItem.Text = dt.Rows[t]["Cus_Sex"].ToString().Trim() == "0" ? "男" : "女";
  191. lvItem.SubItems.Add(ListSubItem);
  192. ListSubItem = new ListViewItem.ListViewSubItem();
  193. ListSubItem.Name = "客户生日";
  194. string StrBirthday = "";
  195. if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_Birthday"].ToString().Trim()))
  196. {
  197. StrBirthday = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
  198. if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  199. { StrBirthday += "_农历"; }
  200. }
  201. ListSubItem.Text = StrBirthday;
  202. lvItem.SubItems.Add(ListSubItem);
  203. ListSubItem = new ListViewItem.ListViewSubItem();
  204. ListSubItem.Name = "客户婚期";
  205. string StrDayForMarriage = "";
  206. if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_DayForMarriage"].ToString().Trim()))
  207. {
  208. StrDayForMarriage = dt.Rows[t]["Cus_DayForMarriage"].ToString().Trim();
  209. if (dt.Rows[t]["Cus_DayForMarriageLunar"].ToString().Trim() == "1")
  210. { StrDayForMarriage += "_农历"; }
  211. }
  212. ListSubItem.Text = StrDayForMarriage;
  213. lvItem.SubItems.Add(ListSubItem);
  214. ListSubItem = new ListViewItem.ListViewSubItem();
  215. ListSubItem.Name = "客户QQ";
  216. ListSubItem.Text = dt.Rows[t]["Cus_QQ"].ToString().Trim();
  217. lvItem.SubItems.Add(ListSubItem);
  218. ListSubItem = new ListViewItem.ListViewSubItem();
  219. ListSubItem.Name = "客户微信";
  220. ListSubItem.Text = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
  221. lvItem.SubItems.Add(ListSubItem);
  222. ListSubItem = new ListViewItem.ListViewSubItem();
  223. ListSubItem.Name = "客户地址";
  224. ListSubItem.Text = dt.Rows[t]["Cus_Address"].ToString().Trim();
  225. lvItem.SubItems.Add(ListSubItem);
  226. if ((this.listViewData.Items.Count % 2) > 0)
  227. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  228. else
  229. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  230. this.listViewData.Items.Add(lvItem);
  231. }
  232. #endregion
  233. }));
  234. }
  235. });
  236. try
  237. { this.ucPagerEx1.TbDataSource = dt; }
  238. catch
  239. { }
  240. return pageData.TotalCount;
  241. }
  242. }
  243. }