PaymentQueryMemberCard.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.MembershipManage.SuperSmallForm
  10. {
  11. public partial class PaymentQueryMemberCard : LYFZ.Software.UI.MembershipManage.SuperSmallForm.PaymentQueryMemberCard
  12. {
  13. public PaymentQueryMemberCard()
  14. {
  15. this.btnQuery.Click += btnQuery_Click;
  16. this.cmbQueryText.KeyDown += cmbQueryText_KeyDown;
  17. this.btnOK.Click += btnOK_Click;
  18. this.dgvData.MouseDoubleClick += dgvData_MouseDoubleClick;
  19. }
  20. /// <summary>
  21. /// 是否保存
  22. /// </summary>
  23. public bool IsSaveed = false;
  24. /// <summary>
  25. /// 会员值
  26. /// </summary>
  27. public string StrMemberText = "";
  28. /// <summary>
  29. /// 员工编号
  30. /// </summary>
  31. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  32. /// <summary>
  33. /// 查询
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="e"></param>
  37. void btnQuery_Click(object sender, EventArgs e)
  38. {
  39. this.PublicFunctionRows();
  40. }
  41. /// <summary>
  42. /// 回车
  43. /// </summary>
  44. /// <param name="sender"></param>
  45. /// <param name="e"></param>
  46. void cmbQueryText_KeyDown(object sender, KeyEventArgs e)
  47. {
  48. if (e.KeyCode == Keys.Enter)
  49. { this.btnQuery_Click(this, null); }
  50. }
  51. /// <summary>
  52. /// 按此会员
  53. /// </summary>
  54. /// <param name="sender"></param>
  55. /// <param name="e"></param>
  56. void btnOK_Click(object sender, EventArgs e)
  57. {
  58. if (this.dgvData.Rows.Count > 0)
  59. {
  60. if(this.dgvData.SelectedRows.Count>0)
  61. {
  62. this.IsSaveed = true;
  63. this.StrMemberText = this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim();
  64. this.Close();
  65. }
  66. }
  67. }
  68. /// <summary>
  69. /// 双击事件
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. void dgvData_MouseDoubleClick(object sender, MouseEventArgs e)
  74. {
  75. if (this.dgvData.Rows.Count > 0)
  76. {
  77. if (e.X >= 0 && e.Y >= 0)
  78. {
  79. this.IsSaveed = true;
  80. this.StrMemberText = this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim();
  81. this.Close();
  82. }
  83. }
  84. }
  85. DataTable newTable = new DataTable();
  86. /// <summary>
  87. /// 创建行
  88. /// </summary>
  89. void PublicFunctionRows()
  90. {
  91. Dictionary<string, string> dictColumns = new Dictionary<string, string>();
  92. string[] StrColumns = "Mc_Number,会员卡号,持卡人,性别,电话,积分,金额".Split(',');
  93. for (int i = 0; i < StrColumns.Length; i++)
  94. { dictColumns.Add(StrColumns[i].Trim(), "100"); }
  95. this.dgvData.dictShowColumName = dictColumns;
  96. string StrWhere = "";
  97. string StrText = this.cmbQueryText.Text.Trim();
  98. if (LYFZ.Command.Command_Validate.IsChinese(StrText))
  99. { StrWhere += " And (Cus_Name like '%" + StrText + "%' or Mc_SecondQueryName like '%" + StrText + "%')"; }
  100. else if (LYFZ.Command.Command_Validate.IsNumber(StrText))
  101. {
  102. if (StrText.Length == 11)
  103. { StrWhere += " And (Cus_Telephone = '" + StrText + "'or Mc_CradNumber = '" + StrText + "')"; }
  104. else
  105. { StrWhere += " And (Cus_Telephone like '%" + StrText + "%' or Mc_CradNumber like '%" + StrText + "%')"; }
  106. }
  107. else if (LYFZ.Command.Command_Validate.IsEnglish(StrText))
  108. { StrWhere += " And (dbo.fn_ChineseToSpell(Cus_Name) like '%" + StrText + "%' or dbo.fn_ChineseToSpell(Mc_SecondQueryName) like '%" + StrText + "%')"; }
  109. else if (LYFZ.Command.Command_Validate.IsOrderNumber(StrText))
  110. { StrWhere += " And Mc_CradNumber like '%" + StrText + "%'"; }
  111. if (StrWhere.Trim().Length > 0)
  112. {
  113. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  114. {
  115. this.newTable = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrWhere, -1);
  116. });
  117. if (this.newTable.Rows.Count > 0)
  118. { this.PublicFunctionRows(this.newTable.Select()); }
  119. else
  120. { this.dgvData.DataColumns(this.dgvData.dgvCurrentColumnOriginalSet, strHideField: this.dgvData.dgvFixedHideColumn); }
  121. }
  122. }
  123. /// <summary>
  124. /// 处理数据
  125. /// </summary>
  126. /// <param name="dtRows"></param>
  127. void PublicFunctionRows(DataRow[] dtRows)
  128. {
  129. this.dgvData.DataColumns(this.newTable.Columns, strHideField: "Mc_Number");
  130. this.dgvData.FillLastColumn();
  131. DataGridViewRow dgvr = null;
  132. DataGridViewCell cell = null;
  133. for (int i = 0; i < dtRows.Length; i++)
  134. {
  135. dgvr = new DataGridViewRow();
  136. for (int j = 0; j < this.newTable.Columns.Count; j++)
  137. {
  138. cell = new DataGridViewTextBoxCell();
  139. cell.Value = dtRows[i][this.newTable.Columns[j].ColumnName.Trim()].ToString().Trim();
  140. dgvr.Cells.Add(cell);
  141. }
  142. if (this.newTable.Columns.Contains("欠款") && Convert.ToDecimal(dtRows[i]["欠款"]) > 0)
  143. { dgvr.DefaultCellStyle.ForeColor = Color.Red; }
  144. this.dgvData.Rows.Add(dgvr);
  145. }
  146. this.dgvData.Columns["持卡人"].Frozen = true;
  147. this.dgvData.Columns["持卡人"].Width = 120;
  148. if (this.dgvData.Columns.Contains("办卡日期"))
  149. { this.dgvData.Columns["办卡日期"].Width = 120; }
  150. this.dgvData.ClearSelection();
  151. }
  152. }
  153. }