FrmCustomerSelete.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder
  10. {
  11. public partial class FrmCustomerSelete : LYFZ.Software.UI.FinancialManagement.TwoSalesOrder.FrmCustomerSelete
  12. {
  13. public FrmCustomerSelete()
  14. {
  15. this.Shown += FrmCustomerSelete_Shown;
  16. this.txtkeyword.KeyDown += txtkeyword_KeyDown;
  17. this.btnQuery.Click += btnQuery_Click;
  18. this.dgvData.MouseDoubleClick += dgvData_MouseDoubleClick;
  19. this.btnOk.Click += btnOk_Click;
  20. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  21. }
  22. /// <summary>
  23. /// 选择的客户编号
  24. /// </summary>
  25. public string StrClientNumber;
  26. /// <summary>
  27. /// 窗体加载事件
  28. /// </summary>
  29. /// <param name="sender"></param>
  30. /// <param name="e"></param>
  31. void FrmCustomerSelete_Shown(object sender, EventArgs e)
  32. {
  33. this.dgvData.DataColumns("客户编号,客户姓名,客户性别,客户电话,客户地址", strHideField: "客户编号");
  34. this.PublicFunctionRows();
  35. }
  36. /// <summary>
  37. /// 关键字回车查询
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. void txtkeyword_KeyDown(object sender, KeyEventArgs e)
  42. {
  43. if (e.KeyCode == Keys.Enter)
  44. { this.PublicFunctionRows(); }
  45. }
  46. /// <summary>
  47. /// 查询
  48. /// </summary>
  49. /// <param name="sender"></param>
  50. /// <param name="e"></param>
  51. void btnQuery_Click(object sender, EventArgs e)
  52. { this.PublicFunctionRows(); }
  53. /// <summary>
  54. /// 双击选择
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. void dgvData_MouseDoubleClick(object sender, EventArgs e)
  59. {
  60. if (this.dgvData.Rows.Count > 0)
  61. { this.btnOk_Click(this, null); }
  62. }
  63. /// <summary>
  64. /// 确定选择
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. void btnOk_Click(object sender, EventArgs e)
  69. {
  70. if (this.dgvData.SelectedRows.Count == 0)
  71. { MessageBoxCustom.Show("请选择你要客户!"); return; }
  72. this.StrClientNumber = this.dgvData.CurrentRow.Cells["客户编号"].Value.ToString();
  73. this.Close();
  74. }
  75. /// <summary>
  76. /// 绑定数据
  77. /// </summary>
  78. void PublicFunctionRows()
  79. {
  80. this.ucPagerEx1.PageCurrent = 1;
  81. this.ucPagerEx1.PageSize = 100;
  82. this.ucPagerEx1.Bind();
  83. }
  84. /// <summary>
  85. /// 画分页
  86. /// </summary>
  87. /// <param name="e"></param>
  88. /// <returns></returns>
  89. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  90. {
  91. this.dgvData.Rows.Clear();
  92. string Strkeyword = txtkeyword.Text.Trim();
  93. DataTable dt = new DataTable();
  94. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  95. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  96. pageData.PageSize = this.ucPagerEx1.PageSize;
  97. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  98. {
  99. string StrWhere = "Cus_Type != '儿童'";
  100. if (!string.IsNullOrEmpty(txtkeyword.Text))
  101. { StrWhere += " And (Cus_Name like '%" + Strkeyword + "%' or Cus_Telephone like '%" + Strkeyword + "%' or Cus_NamePinyin like '%" + Strkeyword + "%' )"; }
  102. pageData.QueryCondition = StrWhere;
  103. pageData.TableName = "tb_ErpCustomer";
  104. pageData.QueryFieldName = " Cus_CustomerNumber,Cus_Name,Cus_Sex,Cus_Telephone,Cus_Address";
  105. pageData.OrderStr = " Cus_Name Asc";
  106. pageData.OrderType = 1;
  107. dt = pageData.QueryDataTable().Tables[0];
  108. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  109. {
  110. for (int t = 0; t < dt.Rows.Count; t++)
  111. {
  112. DataGridViewRow dgvr = new DataGridViewRow();
  113. DataGridViewCell cell = null;
  114. cell = new DataGridViewTextBoxCell();
  115. cell.Value = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim(); ;
  116. dgvr.Cells.Add(cell);
  117. cell = new DataGridViewTextBoxCell();
  118. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim(); ;
  119. dgvr.Cells.Add(cell);
  120. cell = new DataGridViewTextBoxCell();
  121. cell.Value = Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]) ? "女" : "男";
  122. dgvr.Cells.Add(cell);
  123. cell = new DataGridViewTextBoxCell();
  124. cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  125. dgvr.Cells.Add(cell);
  126. cell = new DataGridViewTextBoxCell();
  127. cell.Value = dt.Rows[t]["Cus_Address"].ToString().Trim();
  128. dgvr.Cells.Add(cell);
  129. this.dgvData.Rows.Add(dgvr);
  130. }
  131. }));
  132. });
  133. try
  134. { this.ucPagerEx1.TbDataSource = dt; }
  135. catch
  136. { }
  137. this.dgvData.ClearSelection();
  138. this.dgvData.FillLastColumn();
  139. return pageData.TotalCount;
  140. }
  141. }
  142. }