123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
- {
- public partial class PaymentQueryMemberCard : LYFZ.Software.UI.MembershipManage.SuperSmallForm.PaymentQueryMemberCard
- {
- public PaymentQueryMemberCard()
- {
- this.btnQuery.Click += btnQuery_Click;
- this.cmbQueryText.KeyDown += cmbQueryText_KeyDown;
- this.btnOK.Click += btnOK_Click;
- this.dgvData.MouseDoubleClick += dgvData_MouseDoubleClick;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 会员值
- /// </summary>
- public string StrMemberText = "";
- /// <summary>
- /// 员工编号
- /// </summary>
- string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 回车
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbQueryText_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.btnQuery_Click(this, null); }
- }
- /// <summary>
- /// 按此会员
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnOK_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if(this.dgvData.SelectedRows.Count>0)
- {
- this.IsSaveed = true;
- this.StrMemberText = this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim();
- this.Close();
- }
- }
- }
- /// <summary>
- /// 双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (e.X >= 0 && e.Y >= 0)
- {
- this.IsSaveed = true;
- this.StrMemberText = this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim();
- this.Close();
- }
- }
- }
- DataTable newTable = new DataTable();
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
- Dictionary<string, string> dictColumns = new Dictionary<string, string>();
- string[] StrColumns = "Mc_Number,会员卡号,持卡人,性别,电话,积分,金额".Split(',');
- for (int i = 0; i < StrColumns.Length; i++)
- { dictColumns.Add(StrColumns[i].Trim(), "100"); }
- this.dgvData.dictShowColumName = dictColumns;
- string StrWhere = "";
- string StrText = this.cmbQueryText.Text.Trim();
- if (LYFZ.Command.Command_Validate.IsChinese(StrText))
- { StrWhere += " And (Cus_Name like '%" + StrText + "%' or Mc_SecondQueryName like '%" + StrText + "%')"; }
- else if (LYFZ.Command.Command_Validate.IsNumber(StrText))
- {
- if (StrText.Length == 11)
- { StrWhere += " And (Cus_Telephone = '" + StrText + "'or Mc_CradNumber = '" + StrText + "')"; }
- else
- { StrWhere += " And (Cus_Telephone like '%" + StrText + "%' or Mc_CradNumber like '%" + StrText + "%')"; }
- }
- else if (LYFZ.Command.Command_Validate.IsEnglish(StrText))
- { StrWhere += " And (dbo.fn_ChineseToSpell(Cus_Name) like '%" + StrText + "%' or dbo.fn_ChineseToSpell(Mc_SecondQueryName) like '%" + StrText + "%')"; }
- else if (LYFZ.Command.Command_Validate.IsOrderNumber(StrText))
- { StrWhere += " And Mc_CradNumber like '%" + StrText + "%'"; }
- if (StrWhere.Trim().Length > 0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- this.newTable = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrWhere, -1);
- });
- if (this.newTable.Rows.Count > 0)
- { this.PublicFunctionRows(this.newTable.Select()); }
- else
- { this.dgvData.DataColumns(this.dgvData.dgvCurrentColumnOriginalSet, strHideField: this.dgvData.dgvFixedHideColumn); }
- }
- }
- /// <summary>
- /// 处理数据
- /// </summary>
- /// <param name="dtRows"></param>
- void PublicFunctionRows(DataRow[] dtRows)
- {
- this.dgvData.DataColumns(this.newTable.Columns, strHideField: "Mc_Number");
- this.dgvData.FillLastColumn();
- DataGridViewRow dgvr = null;
- DataGridViewCell cell = null;
- for (int i = 0; i < dtRows.Length; i++)
- {
- dgvr = new DataGridViewRow();
- for (int j = 0; j < this.newTable.Columns.Count; j++)
- {
- cell = new DataGridViewTextBoxCell();
- cell.Value = dtRows[i][this.newTable.Columns[j].ColumnName.Trim()].ToString().Trim();
- dgvr.Cells.Add(cell);
- }
- if (this.newTable.Columns.Contains("欠款") && Convert.ToDecimal(dtRows[i]["欠款"]) > 0)
- { dgvr.DefaultCellStyle.ForeColor = Color.Red; }
- this.dgvData.Rows.Add(dgvr);
- }
- this.dgvData.Columns["持卡人"].Frozen = true;
- this.dgvData.Columns["持卡人"].Width = 120;
- if (this.dgvData.Columns.Contains("办卡日期"))
- { this.dgvData.Columns["办卡日期"].Width = 120; }
- this.dgvData.ClearSelection();
- }
- }
- }
|