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;
using System.Collections;
using LYFZ.UCPager;
using System.Dynamic;
namespace LYFZ.Software.MainBusiness.MembershipManage
{
public partial class GoldCardMemberFormMain : LYFZ.Software.UI.MembershipManage.GoldCardMemberFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpMemberCardPaymentOrder mcpobll = new BLL.BLL_ErpMemberCardPaymentOrder();
public GoldCardMemberFormMain()
{
this.Load += GoldCardMemberFormMain_Load;
this.chkArrears.Click += chkArrears_Click;
this.cbkManageCancellationCard.Click += cbkManageCancellationCard_Click;
this.btnSuperiorQuery.Click += btnSuperiorQuery_Click;
this.btnPayment.Click += btnPayment_Click;
this.dgvData.CellMouseDown += dgvData_CellMouseDown;
this.dgvData.ColumnHeaderMouseClick += dgvData_ColumnHeaderMouseClick;
this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
//this.cmbtreevStoreName.ComboBoxTree_NodeMouseClick += CmbtreevStoreName_ComboBoxTree_NodeMouseClick;
}
//private void CmbtreevStoreName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
//{
// throw new NotImplementedException();
//}
private int ucPagerEx1_EventPaging(EventPagingArg e)
{
this.ucPagerEx1.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
PublicFunctionRows();
return ucPagerEx1.NMax;
}
///
/// 窗体加载事件
///
///
///
void GoldCardMemberFormMain_Load(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrKeyCode: "qt001");
string StrColumnName = "Mcpt_Number,Mcpt_PaymentNumber,Mcpt_PaymentType,Mcpt_Discount,Mcpt_DiscountAmount,Mcpt_OrderPerson,Mcpt_PackageClass,Mcpt_PackagePrice,Mcpt_CreateDatetime,Mcpt_CreateName,isnull((case when Mcpt_PackagePrice > 0 then Mcpt_PackagePrice else (select sum(Mcpcd_SalePrice) from tb_ErpMemberCardPaymentContentDetail where Mcpcd_PaymentNumber = Mcpt_PaymentNumber) end),0) AS 应付";
// StrColumnName += ", (select top 1 Mcpt_CreateDatetime from tb_ErpMemberCardAmountChangeLOG where mcpt_Number = tb_ErpMemberCardPaymentOrder.Mcpo_Number order by Mcpt_CreateDatetime desc ) as 最后使用时间 ";
DataTable dt = orbll.GetView_Custom("tb_ErpMemberCardPayment Left Join tb_ErpMemberCardPaymentOrder on Mcpo_OrderNumber = Mcpt_PaymentNumber", StrWhere: "Mcpo_OrderNumber is null", ShowColumnName: StrColumnName).Tables[0];
if (dt.Rows.Count > 0)
{
List clist = new List();
for (int i = 0; i < dt.Rows.Count; i++)
{
LYFZ.Model.Model_ErpMemberCardPaymentOrder modelMcpo = new Model.Model_ErpMemberCardPaymentOrder();
modelMcpo.Mcpo_Number = dt.Rows[i]["Mcpt_Number"].ToString().Trim();
modelMcpo.Mcpo_OrderNumber = dt.Rows[i]["Mcpt_PaymentNumber"].ToString().Trim();
modelMcpo.Mcpo_OrderAmount = Convert.ToDecimal(dt.Rows[i]["应付"]) + Convert.ToDecimal(dt.Rows[i]["Mcpt_DiscountAmount"]);
modelMcpo.Mcpo_OrderType = dt.Rows[i]["Mcpt_PaymentType"].ToString().Trim();
modelMcpo.Mcpo_OrderDiscount = Convert.ToDecimal(dt.Rows[i]["Mcpt_Discount"]);
modelMcpo.Mcpo_OrderPerson = dt.Rows[i]["Mcpt_OrderPerson"].ToString().Trim();
modelMcpo.Mcpo_PackageClass = dt.Rows[i]["Mcpt_PackageClass"].ToString().Trim();
modelMcpo.Mcpo_PackagePrice = Convert.ToDecimal(dt.Rows[i]["Mcpt_PackagePrice"]);
modelMcpo.Mcpo_CreateDatetime = Convert.ToDateTime(dt.Rows[i]["Mcpt_CreateDatetime"]);
modelMcpo.Mcpo_CreateName = dt.Rows[i]["Mcpt_CreateName"].ToString().Trim();
clist.Add(mcpobll.GetAddCommandInfo(modelMcpo));
}
if (clist.Count > 0)
{
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
{ MessageBoxCustom.Show("升级失败!"); }
}
}
}
///
/// 查询列表
///
Hashtable htData = new Hashtable();
///
/// 是否为首次运行
///
bool IsFirstRun = true;
///
/// 员工编号
///
string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 窗体加载事件
///
///
///
protected override void GoldCardMemberFormMain_Shown(object sender, EventArgs e)
{
this.btnOpenNewCard.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Member_OpenCard);
this.btnSendSMS.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.SMSSend);
this.btnImport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.DataImport);
this.btnExporting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.DataExport);
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
this.IsFirstRun = false;
this.GoldCardMemberFormMain_Resize(null, null);
}
///
/// 回车查找
///
///
///
protected override void cmbQueryText_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{ this.btnQuery_Click(null, null); }
}
///
/// 查询
///
///
///
protected override void btnQuery_Click(object sender, EventArgs e)
{
this.htData.Clear();
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
///
/// 高级查询
///
///
///
void btnSuperiorQuery_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.SuperiorQuerySmallForm frm = new SetSmallForm.SuperiorQuerySmallForm();
frm.ShowDialog();
if (frm.IsSaveed)
{
this.htData = frm.htData;
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
}
///
/// 付款
///
///
///
void btnPayment_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0 && this.dgvData.SelectedRows.Count > 0)
{
//if (Convert.ToDecimal(this.dgvData.SelectedRows[0].Cells["欠款"].Value) > 0)
{
LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberServiceCardArrearsSuperSmallForm frm = new SuperSmallForm.MemberServiceCardArrearsSuperSmallForm();
frm.StrMemberNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
frm.ShowDialog();
if (frm.IsSaveed)
{
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
}
//else
//{ MessageBoxCustom.Show("会员" + this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim() + "未有欠款!"); }
}
}
///
/// 开新卡
///
///
///
protected override void btnOpenNewCard_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.AddGoldCardMemberSmallForm frm = new SetSmallForm.AddGoldCardMemberSmallForm();
frm.ShowDialog();
if (frm.IsSaveed)
{
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
}
///
/// 会员卡管理
///
///
///
protected override void btnCardManage_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
if (this.dgvData.SelectedRows.Count > 0)
{
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.GoldManagementSmallForm frm = new SetSmallForm.GoldManagementSmallForm();
frm.StrNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
frm.CancellationCard = this.cbkManageCancellationCard.Checked;
frm.ShowDialog();
if (frm.IsSaveed)
{
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
return;
}
}
MessageBoxCustom.Show("请选择要操作的会员号");
}
///
/// 新摄会管理
///
///
///
protected override void btnPhotographerManagement_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
if (this.dgvData.SelectedRows.Count > 0)
{
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MyPhotographerConferenceSmallForm frm = new SetSmallForm.MyPhotographerConferenceSmallForm();
frm.StrNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
frm.ShowDialog();
//if (frm.IsSaveed)
//{ PublicFunctionRows(); }
return;
}
}
MessageBoxCustom.Show("请选择要操作的会员号");
}
///
/// 发短信
///
///
///
protected override void btnSendSMS_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
if (this.dgvData.SelectedRows.Count > 0)
{
string StrMc_Telephone = "";
string strtmp = "";
for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
{
if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim()))
{ StrMc_Telephone += this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim() + ","; }
else
{ strtmp = this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim() + ","; }
}
if (strtmp != "")
{ MessageBoxCustom.Show("号码" + strtmp.TrimEnd(',') + "不是正确的电话号码"); }
if (StrMc_Telephone != "")
{
LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms SendSMS = new SMSManagement.SmsSend.FrmSendSms();
SendSMS.Phone = StrMc_Telephone.TrimEnd(',');
SendSMS.Show();
}
else { MessageBoxCustom.Show("请选中您要发送短信的会员"); }
}
}
}
///
/// 导入
///
///
///
protected override void btnImport_Click(object sender, EventArgs e)
{
Point p = this.Parent.PointToScreen(new Point(0, 0));
p.Y += 2;
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MemberImportExcel frm = new SetSmallForm.MemberImportExcel();
frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
frm.Location = p;
frm.Size = new Size(this.Width - 4, this.Height - 5);
frm.ShowDialog();
if (frm.IsSaveed)
{
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
}
///
/// 导出
///
///
///
protected override void btnExporting_Click(object sender, EventArgs e)
{
#if IGNORE // 只能导出当前列表的数据, 不能按要求导出;
this.dgvData.ExportDataTable(StrFileName: "会员卡");
#else
// 保存对话框;
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.FileName = "会员资料";
saveFile.Title = "导出数据报表文件";
saveFile.Filter = "EXECL文件(*.xls) |*.xls |文本文件(*.txt) |*.txt |所有文件(*.*) |*.*";
saveFile.FilterIndex = 1;
DialogResult drst = saveFile.ShowDialog();
if (drst == DialogResult.No || drst == DialogResult.Cancel || drst == DialogResult.No || drst == DialogResult.Abort)
return;
bool IsExport = false;
// 获取查询出来的DataTable;
DataTable table = null;
string StrQueryCondition = this.GetWhereStr();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
{
table = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrQueryCondition, -1);
});
if (table.Rows.Count == 0)
{
MessageBoxCustom.Show("没有数据可导出");
return;
}
// 移除多余的列;
table.Columns.Remove("Mc_Number");
LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
try
{
if (LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), table, null, backgroundWorker))
{
MessageBoxCustom.Show("数据导出成功!");
}
else
{
MessageBoxCustom.Show("数据导出失败!");
}
}
catch (Exception ex)
{
MessageBoxCustom.Show(String.Format("导出数据出错:{0}", ex.Message));
}
});
//this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
//{
// if (table.Rows.Count > 0)
// {
// try
// {
// //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
// //{
// // IsExport = LYFZ.Command.Command_ExportExcel.DataTable2Sheet(saveFile.FileName.Trim(), table, "Sheet1", IsCoveredExistingFile: true);
// //}));
// IsExport = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), table, null, backgroundWorker);
// }
// catch
// { }
// if (IsExport)
// MessageBoxCustom.Show("导出成功!");
// else
// MessageBoxCustom.Show("导出失败!");
// }
//}));
#endif
}
///
/// 关闭
///
///
///
protected override void btnClose_Click(object sender, EventArgs e)
{ this.Close(); }
///
/// 主卡列表双击事件
///
///
///
protected override void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
if (e.ColumnIndex != -1 && e.RowIndex != -1)
{ this.btnCardManage_Click(this, null); }
}
}
///
/// 窗体大小发生变化
///
///
///
protected override void GoldCardMemberFormMain_Resize(object sender, EventArgs e)
{
if (!this.IsFirstRun)
{
int ControlsWidth = 0;
int ForCount = 0;
for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
{
if (this.flowLayoutPanel1.Controls[i].Visible)
{
ForCount++;
ControlsWidth += this.flowLayoutPanel1.Controls[i].Width;
}
}
ControlsWidth += ForCount * 6 + this.btnClose.Width / 2;
int strWidth = this.Width;
if (strWidth > ControlsWidth)
{ this.flowLayoutPanel1.Size = new Size(this.panelEx2.Width - 10, 40); }
else
{ this.flowLayoutPanel1.Size = new Size(this.panelEx2.Width - 10, 70); }
}
}
///
/// 右键菜单
///
///
///
void dgvData_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (e.RowIndex == -1)
{
this.dgvData.conMenu.Items.Clear();
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "设置标题";
item.Tag = "SetColumnShow";
item.Name = "SetColumnShow";
this.dgvData.conMenu.Items.Add(item);
// this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
this.dgvData.conMenu.ItemClicked -= dgvData_DataGridViewConMenu_ItemClicked;
this.dgvData.conMenu.ItemClicked += dgvData_DataGridViewConMenu_ItemClicked;
// this.dgvData.conMenu.Show();
if (!this.dgvData.conMenu.Visible)
{
this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
}
}
}
}
///
/// 右键菜单选择项事件
///
///
///
void dgvData_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
ToolStripItem item = e.ClickedItem;
if (item.Name.Trim() == "SetColumnShow")
{
if (LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ShowDataGridViewSetColumn(this.dgvData))
{
//this.PublicFunctionRows();
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
}
}
}
///
/// 欠款选项
///
///
///
void chkArrears_Click(object sender, EventArgs e)
{
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
//this.PublicFunctionRows();
}
///
/// 注销选项
///
///
///
void cbkManageCancellationCard_Click(object sender, EventArgs e)
{
ucPagerEx1.PageCurrent = 1;
ucPagerEx1.Bind();
//this.PublicFunctionRows();
}
///
/// 点击列标头排序
///
///
///
void dgvData_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
string StrColumnName = this.dgvData.Columns[e.ColumnIndex].Name.Trim();
if (StrColumnName == this.StrCurrentClickField || string.IsNullOrEmpty(this.StrCurrentClickField))
{
if (this.StrSortOrder == "ASC")
{ this.StrSortOrder = "DESC"; }
else
{ this.StrSortOrder = "ASC"; }
}
else
{ this.StrSortOrder = "DESC"; }
this.StrSortField = StrColumnName + " " + this.StrSortOrder + "";
this.StrCurrentClickField = StrColumnName;
DataRow[] dtRows = this.newTable.Select("1 = 1", StrColumnName + " " + StrSortOrder);
this.PublicFunctionRows(dtRows);
}
}
///
/// 当前点击的字段
///
string StrCurrentClickField = "";
///
/// 排序字段
///
string StrSortField = "Mc_ID DESC";
///
/// 排序顺序
///
string StrSortOrder = "DESC";
DataTable newTable = new DataTable();
///
/// 创建行
///
void PublicFunctionRows()
{
this.dgvData.dgvCurrentColumnOriginalSet = "Mc_Number,会员卡号,持卡人,性别,电话,类型,等级,总积分,当前积分,储值欠款,服务卡欠款,总充值金额,金额,折扣,套系金额,已返金额,已取出金额,返现副卡,积分副卡,服务次数,备注,客户生日,办卡日期,卡未使用天数";
string StrGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0032.ToString().Trim();
this.dgvData.dgvFixedHideColumn = "Mc_Number";
this.dgvData.dgvGuidName = StrGuidName;
this.dgvData.dgvUserEmployeeID = this.StrUserID;
Dictionary dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(this.StrUserID, StrGuidName, this.dgvData.dgvCurrentColumnOriginalSet);
Dictionary tempDictColumns = new Dictionary();
foreach (string key in dictColumns.Keys)
{
if(key=="积分")
{
tempDictColumns.Add("当前积分", dictColumns[key]);
}
else
{
tempDictColumns.Add(key, dictColumns[key]);
}
}
dictColumns = tempDictColumns;
this.dgvData.dictShowColumName = dictColumns;
string StrQueryCondition = this.GetWhereStr();
dynamic dyObj = new ExpandoObject();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
//this.newTable = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrQueryCondition, 1000);
dyObj = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMemberNew(this.dgvData, StrQueryCondition,
ucPagerEx1.PageCurrent, ucPagerEx1.PageSize);
this.newTable = dyObj.DataTable;
});
BindPageData(ucPagerEx1.PageCurrent, dyObj.PageSize, dyObj.TotalCount);
if (this.newTable.Rows.Count > 0)
{
this.PublicFunctionRows(this.newTable.Select());
}
else
{
this.dgvData.DataColumns(this.dgvData.dgvCurrentColumnOriginalSet, strHideField: this.dgvData.dgvFixedHideColumn);
}
}
public void BindPageData(int pageIndx, int pageSize, int totalCount)
{
ucPagerEx1.NMax = totalCount;
ucPagerEx1.CurrentPageCount = (pageSize);
ucPagerEx1.PageCurrent = pageIndx;
}
///
/// 处理数据
///
///
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;
}
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();
}
///
/// 获取查询条件
///
///
string GetWhereStr()
{
string StrWhere = "";
string StrText = this.cmbQueryText.Text.Trim();
string StrStoreNameWhere = DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Mc_DividedShop", ConnectWord: " and ");
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 (this.cbkManageCancellationCard.Checked)
{ StrWhere += " and Mc_Status = '0'"; }
else
{ StrWhere += " and Mc_Status = '1'"; }
if (this.chkArrears.Checked)
{ StrWhere += " and (isnull(欠款,0) > 0 or isnull(Mcrd_ArrearsAmount,0)>0 )"; }
if (htData != null && htData.Count > 0)
{
if (htData.ContainsKey("AvailableAmountStart") && htData.ContainsKey("AvailableAmountEnd"))
{
if (htData["AvailableAmountStart"].ToString().Trim().Length > 0 && htData["AvailableAmountEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and (Mc_Money between " + htData["AvailableAmountStart"].ToString().Trim() + " and " + htData["AvailableAmountEnd"].ToString().Trim() + ")"; }
else if (htData["AvailableAmountStart"].ToString().Trim().Length > 0 && htData["AvailableAmountEnd"].ToString().Trim().Length <= 0)
{ StrWhere += " and Mc_Money = " + htData["AvailableAmountStart"].ToString().Trim() + ""; }
else if (htData["AvailableAmountStart"].ToString().Trim().Length <= 0 && htData["AvailableAmountEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and Mc_Money = " + htData["AvailableAmountEnd"].ToString().Trim() + ""; }
}
if (htData.ContainsKey("AvailablePointsStart") && htData.ContainsKey("AvailablePointsEnd"))
{
if (htData["AvailablePointsStart"].ToString().Trim().Length > 0 && htData["AvailablePointsEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and (isnull(Mcps_AvailablePoints,0) between " + htData["AvailablePointsStart"].ToString().Trim() + " and " + htData["AvailablePointsEnd"].ToString().Trim() + ")"; }
else if (htData["AvailablePointsStart"].ToString().Trim().Length > 0 && htData["AvailablePointsEnd"].ToString().Trim().Length <= 0)
{ StrWhere += " and isnull(Mcps_AvailablePoints,0) = " + htData["AvailablePointsStart"].ToString().Trim() + ""; }
else if (htData["AvailablePointsStart"].ToString().Trim().Length <= 0 && htData["AvailablePointsEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and isnull(Mcps_AvailablePoints,0) = " + htData["AvailablePointsEnd"].ToString().Trim() + ""; }
}
if (htData.ContainsKey("SeriesAmountStart") && htData.ContainsKey("SeriesAmountEnd"))
{
if (htData["SeriesAmountStart"].ToString().Trim().Length > 0 && htData["SeriesAmountEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and (isnull(Mcbc_PackagesMoney,0) between " + htData["SeriesAmountStart"].ToString().Trim() + " and " + htData["SeriesAmountEnd"].ToString().Trim() + ")"; }
else if (htData["SeriesAmountStart"].ToString().Trim().Length > 0 && htData["SeriesAmountEnd"].ToString().Trim().Length <= 0)
{ StrWhere += " and isnull(Mcbc_PackagesMoney,0) = " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
else if (htData["SeriesAmountStart"].ToString().Trim().Length <= 0 && htData["SeriesAmountEnd"].ToString().Trim().Length > 0)
{ StrWhere += " and isnull(Mcbc_PackagesMoney,0) = " + htData["SeriesAmountEnd"].ToString().Trim() + ""; }
}
if (htData.ContainsKey("ServiceStartNumber") && htData.ContainsKey("ServiceEndNumber"))
{
if (htData["ServiceStartNumber"].ToString().Trim().Length > 0 && htData["ServiceEndNumber"].ToString().Trim().Length > 0)
{ StrWhere += " and (isnull(Mcse_ServiceCount,0) between " + htData["ServiceStartNumber"].ToString().Trim() + " and " + htData["ServiceEndNumber"].ToString().Trim() + ")"; }
else if (htData["ServiceStartNumber"].ToString().Trim().Length > 0 && htData["ServiceEndNumber"].ToString().Trim().Length <= 0)
{ StrWhere += " and isnull(Mcse_ServiceCount,0) = " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
else if (htData["ServiceStartNumber"].ToString().Trim().Length <= 0 && htData["ServiceEndNumber"].ToString().Trim().Length > 0)
{ StrWhere += " and isnull(Mcse_ServiceCount,0) = " + htData["ServiceEndNumber"].ToString().Trim() + ""; }
}
if (htData.ContainsKey("StartTotalMoney") && htData.ContainsKey("EndTotalMoney"))
{
if (htData["StartTotalMoney"].ToString().Trim().Length > 0 && htData["EndTotalMoney"].ToString().Trim().Length > 0)
{ StrWhere += " and (isnull(Mc_TotalMoney,0) between " + htData["StartTotalMoney"].ToString().Trim() + " and " + htData["EndTotalMoney"].ToString().Trim() + ")"; }
else if (htData["StartTotalMoney"].ToString().Trim().Length > 0 && htData["EndTotalMoney"].ToString().Trim().Length <= 0)
{ StrWhere += " and isnull(Mc_TotalMoney,0) >= " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
else if (htData["StartTotalMoney"].ToString().Trim().Length <= 0 && htData["EndTotalMoney"].ToString().Trim().Length > 0)
{ StrWhere += " and isnull(Mc_TotalMoney,0) <= " + htData["EndTotalMoney"].ToString().Trim() + ""; }
}
if (htData.ContainsKey("ClientBirthdayStart") && htData.ContainsKey("ClientBirthdayEnd"))
{ StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("dbo.Fun_GetGregorianCalendarNowYearBirthday(Cus_Birthday,Cus_BirthdayLunar)", htData["ClientBirthdayStart"].ToString().Trim(), htData["ClientBirthdayEnd"].ToString().Trim()); }
if (htData.ContainsKey("OpenCardStart") && htData.ContainsKey("OpenCardEnd"))
{ StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Mc_CreateDatetime", htData["OpenCardStart"].ToString().Trim(), htData["OpenCardEnd"].ToString().Trim()); }
}
#if IGNORE // 导出时,需要用;
this.htData.Clear();
#endif
if(!string.IsNullOrEmpty(StrStoreNameWhere))
{
StrWhere = StrWhere + StrStoreNameWhere;
}
return StrWhere;
}
}
}