123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709 |
- 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;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- 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("升级失败!"); }
- }
- }
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- Hashtable htData = new Hashtable();
- /// <summary>
- /// 是否为首次运行
- /// </summary>
- bool IsFirstRun = true;
- /// <summary>
- /// 员工编号
- /// </summary>
- string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- /// <summary>
- /// 回车查找
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbQueryText_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.btnQuery_Click(null, null); }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnQuery_Click(object sender, EventArgs e)
- {
- this.htData.Clear();
- //this.PublicFunctionRows();
- ucPagerEx1.PageCurrent = 1;
- ucPagerEx1.Bind();
- }
- /// <summary>
- /// 高级查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 付款
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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() + "未有欠款!"); }
- }
- }
- /// <summary>
- /// 开新卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 会员卡管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("请选择要操作的会员号");
- }
- /// <summary>
- /// 新摄会管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("请选择要操作的会员号");
- }
- /// <summary>
- /// 发短信
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("请选中您要发送短信的会员"); }
- }
- }
- }
- /// <summary>
- /// 导入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 主卡列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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); }
- }
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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); }
- }
- }
- /// <summary>
- /// 右键菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);//弹出操作菜单
- }
- }
- }
- }
- /// <summary>
- /// 右键菜单选择项事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- }
- /// <summary>
- /// 欠款选项
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkArrears_Click(object sender, EventArgs e)
- {
- ucPagerEx1.PageCurrent = 1;
- ucPagerEx1.Bind();
- //this.PublicFunctionRows();
- }
- /// <summary>
- /// 注销选项
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cbkManageCancellationCard_Click(object sender, EventArgs e)
- {
- ucPagerEx1.PageCurrent = 1;
- ucPagerEx1.Bind();
- //this.PublicFunctionRows();
- }
- /// <summary>
- /// 点击列标头排序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 当前点击的字段
- /// </summary>
- string StrCurrentClickField = "";
- /// <summary>
- /// 排序字段
- /// </summary>
- string StrSortField = "Mc_ID DESC";
- /// <summary>
- /// 排序顺序
- /// </summary>
- string StrSortOrder = "DESC";
- DataTable newTable = new DataTable();
- /// <summary>
- /// 创建行
- /// </summary>
- 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<string, string> dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(this.StrUserID, StrGuidName, this.dgvData.dgvCurrentColumnOriginalSet);
- Dictionary<string, string> tempDictColumns = new Dictionary<string, string>();
- 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;
- }
- /// <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;
- }
- 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();
- }
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- 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;
- }
- }
- }
|