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.StatisticsForm { public partial class MemberExpiresRemindForm : LYFZ.Software.UI.MembershipManage.StatisticsForm.MemberExpiresRemindForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure(); public MemberExpiresRemindForm() { this.Load += MemberExpiresRemindForm_Load; this.Shown += MemberExpiresRemindForm_Shown; this.btnQuery.Click += btnQuery_Click; this.btnSet.Click += btnSet_Click; this.btnClose.Click += btnClose_Click; this.txtDay.KeyPress += txtDay_KeyPress; this.chkPoints.Click += chkPoints_Click; this.chkStoredValue.Click += chkStoredValue_Click; this.chkBackCash.Click += chkBackCash_Click; this.chkService.Click += chkService_Click; this.chkPhotographer.Click += chkPhotographer_Click; } DataTable dtSet = new DataTable(); /// /// 窗体加载事件 /// /// /// void MemberExpiresRemindForm_Load(object sender, EventArgs e) { this.PublicFunctionRows(); } /// /// 窗体加载事件 /// /// /// void MemberExpiresRemindForm_Shown(object sender, EventArgs e) { this.PublicFunctionRows(); this.GetCongfig(); } /// /// 查询 /// /// /// void btnQuery_Click(object sender, EventArgs e) { this.PublicFunctionRows(); } /// /// 设置 /// /// /// void btnSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.MembershipManage.StatisticsForm.MemberExpiresRemindSetForm frm = new MemberExpiresRemindSetForm(); frm.ShowDialog(); if (frm.IsSaveed) { this.dtSet = new Json.JsontoDataTable().toObject(frm.StrJosnData); this.PublicFunctionRows(); this.GetCongfig(); } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 输入限制 /// /// /// void txtDay_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } } /// /// 积分选择 /// /// /// void chkPoints_Click(object sender, EventArgs e) { this.chkPoints.Checked = true; this.chkStoredValue.Checked = false; this.chkBackCash.Checked = false; this.chkService.Checked = false; this.chkPhotographer.Checked = false; this.PublicFunctionRows(); this.GetCongfig(); } /// /// 领会选择 /// /// /// void chkStoredValue_Click(object sender, EventArgs e) { this.chkPoints.Checked = false; this.chkStoredValue.Checked = true; this.chkBackCash.Checked = false; this.chkService.Checked = false; this.chkPhotographer.Checked = false; this.PublicFunctionRows(); this.GetCongfig(); } /// /// 返现选择 /// /// /// void chkBackCash_Click(object sender, EventArgs e) { this.chkPoints.Checked = false; this.chkStoredValue.Checked = false; this.chkBackCash.Checked = true; this.chkService.Checked = false; this.chkPhotographer.Checked = false; this.PublicFunctionRows(); this.GetCongfig(); } /// /// 服务选择 /// /// /// void chkService_Click(object sender, EventArgs e) { this.chkPoints.Checked = false; this.chkStoredValue.Checked = false; this.chkBackCash.Checked = false; this.chkService.Checked = true; this.chkPhotographer.Checked = false; this.PublicFunctionRows(); this.GetCongfig(); } /// /// 新摄会选择 /// /// /// void chkPhotographer_Click(object sender, EventArgs e) { this.chkPoints.Checked = false; this.chkStoredValue.Checked = false; this.chkBackCash.Checked = false; this.chkService.Checked = false; this.chkPhotographer.Checked = true; this.PublicFunctionRows(); this.GetCongfig(); } /// /// 获取配置文件数据 /// void GetCongfig() { if (this.dtSet.Rows.Count <= 0) { DataTable dt = sgbll.GetList("Sconfig_Code in ('MemberExpiresSet')").Tables[0]; if (dt.Rows.Count > 0) { this.dtSet = new Json.JsontoDataTable().toObject(dt.Rows[0]["Sconfig_Value"].ToString().Trim()); } } if (this.dtSet.Rows.Count > 0) { if (this.chkPoints.Checked) { DataRow[] dtRow = this.dtSet.Select("StrName='Points'"); if (dtRow.Length > 0) { this.txtDay.Text = dtRow[0]["StrValue"].ToString().Trim(); } } else if (this.chkStoredValue.Checked) { DataRow[] dtRow = this.dtSet.Select("StrName='StoredValue'"); if (dtRow.Length > 0) { this.txtDay.Text = dtRow[0]["StrValue"].ToString().Trim(); } } else if (this.chkBackCash.Checked) { DataRow[] dtRow = this.dtSet.Select("StrName='BackCash'"); if (dtRow.Length > 0) { this.txtDay.Text = dtRow[0]["StrValue"].ToString().Trim(); } } else if (this.chkService.Checked) { DataRow[] dtRow = this.dtSet.Select("StrName='Service'"); if (dtRow.Length > 0) { this.txtDay.Text = dtRow[0]["StrValue"].ToString().Trim(); } } else if (this.chkPhotographer.Checked) { DataRow[] dtRow = this.dtSet.Select("StrName='Photographer'"); if (dtRow.Length > 0) { this.txtDay.Text = dtRow[0]["StrValue"].ToString().Trim(); } } } } /// /// 创建行数据 /// void PublicFunctionRows() { this.dgvData.Rows.Clear(); string StrWhere = ""; if (this.chkPoints.Checked) { StrWhere = " And Mcvy_Type = 2"; } else if (this.chkStoredValue.Checked) { StrWhere = " And Mcvy_Type = 1"; } else if (this.chkBackCash.Checked) { StrWhere = " And Mcvy_Type = 3"; } else if (this.chkService.Checked) { StrWhere = " And Mcvy_Type = 4"; } else if (this.chkPhotographer.Checked) { StrWhere = " And Mcvy_Type = 5"; } string StrTableName = "with t as " + "(" + "SELECT tb_ErpMemberCardValidity.ID," + "Mcvy_Number AS 会员编号," + "Mc_CradNumber AS 会员卡号," + "(Cus_Name+'/'+Mc_SecondQueryName) AS 姓名," + "Cus_Telephone AS 电话," + "case Mcvy_Type when 1 then '储值卡' " + "when 2 then '积分卡' " + "when 3 then '返现卡' " + "when 4 then '服务卡' " + "when 5 then '新摄会卡' end AS 类型," + "Mcvy_ValidityTime AS 到期时间," + "DATEDIFF(day, GETDATE(), Mcvy_ValidityTime) AS 几天未完 " + "from tb_ErpMemberCardValidity " + "Left Join tb_ErpMemberCard on Mc_Number = Mcvy_Number " + "Left Join tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber " + "where Mcvy_ValidityTime is not null" + StrWhere + ")" + "select * from t where 几天未完 <= " + this.txtDay.Text.Trim() + " order by 几天未完"; DataTable dt = orbll.GetView_Custom(StrTableName).Tables[0]; this.dgvData.DataSource(dt, strHideField: "ID"); } } }