FrmSelectCustomer.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.PieceCommissionRecords
  10. {
  11. public partial class FrmSelectCustomer : LYFZ.Software.UI.FinancialManagement.PieceCommissionRecords.FrmSelectCustomer
  12. {
  13. public string Ord_Type;
  14. public string Ord_Number;
  15. public string Ord_OrdersPerson;
  16. public string Ord_CustomerName1;
  17. public string Ord_SeriesName;
  18. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  19. public FrmSelectCustomer()
  20. {
  21. this.Shown += FrmSelectCustomer_Shown;
  22. this.btnOk.Click += btnOk_Click;
  23. this.btnSlect.Click += btnSlect_Click;
  24. this.dgvData.DoubleClick += dgvData_DoubleClick;
  25. this.txtQueryText.KeyDown += txtQueryText_KeyDown;
  26. //this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  27. }
  28. /// <summary>
  29. /// 窗体加载事件
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. void FrmSelectCustomer_Shown(object sender, EventArgs e)
  34. { this.PublicFunctionRows(); }
  35. /// <summary>
  36. /// 获取数据
  37. /// </summary>
  38. void PublicFunctionRows()
  39. {
  40. string StrWhere1 = "";
  41. string StrWhere2 = "";
  42. int inTop = 20;
  43. if (this.txtQueryText.Text.Trim().Length > 0)
  44. {
  45. inTop = 100;
  46. StrWhere1 = "And (Cus_Name like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Telephone like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Name_py like '%" + this.txtQueryText.Text.Trim() + "%' or Ord_SinceOrderNumber = '" + this.txtQueryText.Text.Trim() + "')";
  47. StrWhere2 = "And (Cus_Name like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Telephone like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_NamePinyin like '%" + this.txtQueryText.Text.Trim() + "%' or Tsorder_Number = '" + this.txtQueryText.Text.Trim() + "')";
  48. }
  49. DataTable dtTable = new DataTable();
  50. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  51. {
  52. string StrTableName = "with t AS " +
  53. "(" +
  54. "select tb_ErpOrder.ID,Ord_Number AS 订单编号,Ord_SinceOrderNumber AS 订单号,dbo.fn_CheckOrderType(Ord_Type) AS 订单类型,Cus_Name AS 客户姓名,Cus_Telephone AS 客户电话,接单人,Ord_SeriesName AS 套系名称,Ord_SeriesPrice AS 套系价格,1 AS 数量 " +
  55. "from tb_ErpOrder " +
  56. "Left Join dbo.CView_OrderPerson on OrdPe_OrderNumber = Ord_Number " +
  57. "Left Join tempTB_AggregationCustomer on Ord_Number=GP_OrderNumber " +
  58. "where Cus_Name is not null " + StrWhere1 + " " +
  59. "UNION ALL " +
  60. "select tb_ErpTwoSalesOrder.ID,Tsorder_Number AS 订单编号,Tsorder_Number AS 订单号,'散客消费' AS 订单类型,Cus_Name AS 客户姓名,Cus_Telephone AS 客户电话,Tsorder_OpenSingle AS 接单人,Tsorder_Name AS 套系名称,Tsorder_Money AS 套系价格,Tsorder_Quantity AS 数量 " +
  61. "from tb_ErpTwoSalesOrder " +
  62. "Left Join tb_ErpCustomer on Cus_CustomerNumber = Tsorder_CustomerNumber " +
  63. "Where Cus_Name is not null " + StrWhere2 +
  64. ")" +
  65. "select top " + inTop + " * from t Order By ID DESC";
  66. dtTable = orbll.GetView_Custom(StrTableName).Tables[0];
  67. //刘工临时修复 散客消费订单的订接单人显示错误问题
  68. foreach (DataRow row in dtTable.Rows)
  69. {
  70. if (row["订单类型"].ToString() == "散客消费")
  71. {
  72. row["接单人"] = LYFZ.DAL.DAL_ErpUser.GetUserIDToUserName(row["接单人"].ToString());
  73. }
  74. }
  75. });
  76. this.dgvData.DataSource(dtTable, strHideField: "ID,订单编号");
  77. //foreach (DataGridViewRow row in this.dgvData.Rows)
  78. //{
  79. // row.Cells["接单人"].Value="AK";
  80. //}
  81. }
  82. /// <summary>
  83. /// 查询
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. void btnSlect_Click(object sender, EventArgs e)
  88. { this.PublicFunctionRows(); }
  89. /// <summary>
  90. /// 回车查询
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. void txtQueryText_KeyDown(object sender, KeyEventArgs e)
  95. {
  96. if (e.KeyCode == Keys.Enter)
  97. { this.PublicFunctionRows(); }
  98. }
  99. /// <summary>
  100. /// 确定
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. void btnOk_Click(object sender, EventArgs e)
  105. {
  106. if (this.dgvData.SelectedRows.Count == 0)
  107. { MessageBoxCustom.Show("请选中你要的客户!"); return; }
  108. if (this.dgvData.CurrentRow.Cells["订单类型"].Value.ToString().Trim() == "散客消费")
  109. { this.Ord_Type = "散客消费"; }
  110. else
  111. { this.Ord_Type = this.dgvData.CurrentRow.Cells["订单类型"].Value.ToString().Trim(); }
  112. this.Ord_Number = this.dgvData.CurrentRow.Cells["订单编号"].Value.ToString().Trim();
  113. this.Ord_OrdersPerson = this.dgvData.CurrentRow.Cells["接单人"].Value.ToString().Trim();
  114. this.Ord_CustomerName1 = this.dgvData.CurrentRow.Cells["客户姓名"].Value.ToString().Trim();
  115. this.Ord_SeriesName = this.dgvData.CurrentRow.Cells["套系名称"].Value.ToString().Trim();
  116. this.Close();
  117. }
  118. /// <summary>
  119. /// 双击确定
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. void dgvData_DoubleClick(object sender, EventArgs e)
  124. { this.btnOk_Click(this, null); }
  125. }
  126. }