GoldCardMemberFormMain.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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. using System.Collections;
  10. using LYFZ.UCPager;
  11. using System.Dynamic;
  12. namespace LYFZ.Software.MainBusiness.MembershipManage
  13. {
  14. public partial class GoldCardMemberFormMain : LYFZ.Software.UI.MembershipManage.GoldCardMemberFormMain
  15. {
  16. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  17. LYFZ.BLL.BLL_ErpMemberCardPaymentOrder mcpobll = new BLL.BLL_ErpMemberCardPaymentOrder();
  18. public GoldCardMemberFormMain()
  19. {
  20. this.Load += GoldCardMemberFormMain_Load;
  21. this.chkArrears.Click += chkArrears_Click;
  22. this.cbkManageCancellationCard.Click += cbkManageCancellationCard_Click;
  23. this.btnSuperiorQuery.Click += btnSuperiorQuery_Click;
  24. this.btnPayment.Click += btnPayment_Click;
  25. this.dgvData.CellMouseDown += dgvData_CellMouseDown;
  26. this.dgvData.ColumnHeaderMouseClick += dgvData_ColumnHeaderMouseClick;
  27. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  28. //this.cmbtreevStoreName.ComboBoxTree_NodeMouseClick += CmbtreevStoreName_ComboBoxTree_NodeMouseClick;
  29. }
  30. //private void CmbtreevStoreName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  31. //{
  32. // throw new NotImplementedException();
  33. //}
  34. private int ucPagerEx1_EventPaging(EventPagingArg e)
  35. {
  36. this.ucPagerEx1.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
  37. PublicFunctionRows();
  38. return ucPagerEx1.NMax;
  39. }
  40. /// <summary>
  41. /// 窗体加载事件
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. void GoldCardMemberFormMain_Load(object sender, EventArgs e)
  46. {
  47. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrKeyCode: "qt001");
  48. 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 应付";
  49. // StrColumnName += ", (select top 1 Mcpt_CreateDatetime from tb_ErpMemberCardAmountChangeLOG where mcpt_Number = tb_ErpMemberCardPaymentOrder.Mcpo_Number order by Mcpt_CreateDatetime desc ) as 最后使用时间 ";
  50. 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];
  51. if (dt.Rows.Count > 0)
  52. {
  53. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  54. for (int i = 0; i < dt.Rows.Count; i++)
  55. {
  56. LYFZ.Model.Model_ErpMemberCardPaymentOrder modelMcpo = new Model.Model_ErpMemberCardPaymentOrder();
  57. modelMcpo.Mcpo_Number = dt.Rows[i]["Mcpt_Number"].ToString().Trim();
  58. modelMcpo.Mcpo_OrderNumber = dt.Rows[i]["Mcpt_PaymentNumber"].ToString().Trim();
  59. modelMcpo.Mcpo_OrderAmount = Convert.ToDecimal(dt.Rows[i]["应付"]) + Convert.ToDecimal(dt.Rows[i]["Mcpt_DiscountAmount"]);
  60. modelMcpo.Mcpo_OrderType = dt.Rows[i]["Mcpt_PaymentType"].ToString().Trim();
  61. modelMcpo.Mcpo_OrderDiscount = Convert.ToDecimal(dt.Rows[i]["Mcpt_Discount"]);
  62. modelMcpo.Mcpo_OrderPerson = dt.Rows[i]["Mcpt_OrderPerson"].ToString().Trim();
  63. modelMcpo.Mcpo_PackageClass = dt.Rows[i]["Mcpt_PackageClass"].ToString().Trim();
  64. modelMcpo.Mcpo_PackagePrice = Convert.ToDecimal(dt.Rows[i]["Mcpt_PackagePrice"]);
  65. modelMcpo.Mcpo_CreateDatetime = Convert.ToDateTime(dt.Rows[i]["Mcpt_CreateDatetime"]);
  66. modelMcpo.Mcpo_CreateName = dt.Rows[i]["Mcpt_CreateName"].ToString().Trim();
  67. clist.Add(mcpobll.GetAddCommandInfo(modelMcpo));
  68. }
  69. if (clist.Count > 0)
  70. {
  71. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  72. { MessageBoxCustom.Show("升级失败!"); }
  73. }
  74. }
  75. }
  76. /// <summary>
  77. /// 查询列表
  78. /// </summary>
  79. Hashtable htData = new Hashtable();
  80. /// <summary>
  81. /// 是否为首次运行
  82. /// </summary>
  83. bool IsFirstRun = true;
  84. /// <summary>
  85. /// 员工编号
  86. /// </summary>
  87. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  88. /// <summary>
  89. /// 窗体加载事件
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. protected override void GoldCardMemberFormMain_Shown(object sender, EventArgs e)
  94. {
  95. this.btnOpenNewCard.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Member_OpenCard);
  96. this.btnSendSMS.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.SMSSend);
  97. this.btnImport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.DataImport);
  98. this.btnExporting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.DataExport);
  99. //this.PublicFunctionRows();
  100. ucPagerEx1.PageCurrent = 1;
  101. ucPagerEx1.Bind();
  102. this.IsFirstRun = false;
  103. this.GoldCardMemberFormMain_Resize(null, null);
  104. }
  105. /// <summary>
  106. /// 回车查找
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. protected override void cmbQueryText_KeyDown(object sender, KeyEventArgs e)
  111. {
  112. if (e.KeyCode == Keys.Enter)
  113. { this.btnQuery_Click(null, null); }
  114. }
  115. /// <summary>
  116. /// 查询
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. protected override void btnQuery_Click(object sender, EventArgs e)
  121. {
  122. this.htData.Clear();
  123. //this.PublicFunctionRows();
  124. ucPagerEx1.PageCurrent = 1;
  125. ucPagerEx1.Bind();
  126. }
  127. /// <summary>
  128. /// 高级查询
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. void btnSuperiorQuery_Click(object sender, EventArgs e)
  133. {
  134. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.SuperiorQuerySmallForm frm = new SetSmallForm.SuperiorQuerySmallForm();
  135. frm.ShowDialog();
  136. if (frm.IsSaveed)
  137. {
  138. this.htData = frm.htData;
  139. //this.PublicFunctionRows();
  140. ucPagerEx1.PageCurrent = 1;
  141. ucPagerEx1.Bind();
  142. }
  143. }
  144. /// <summary>
  145. /// 付款
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. void btnPayment_Click(object sender, EventArgs e)
  150. {
  151. if (this.dgvData.Rows.Count > 0 && this.dgvData.SelectedRows.Count > 0)
  152. {
  153. //if (Convert.ToDecimal(this.dgvData.SelectedRows[0].Cells["欠款"].Value) > 0)
  154. {
  155. LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberServiceCardArrearsSuperSmallForm frm = new SuperSmallForm.MemberServiceCardArrearsSuperSmallForm();
  156. frm.StrMemberNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
  157. frm.ShowDialog();
  158. if (frm.IsSaveed)
  159. {
  160. //this.PublicFunctionRows();
  161. ucPagerEx1.PageCurrent = 1;
  162. ucPagerEx1.Bind();
  163. }
  164. }
  165. //else
  166. //{ MessageBoxCustom.Show("会员" + this.dgvData.SelectedRows[0].Cells["会员卡号"].Value.ToString().Trim() + "未有欠款!"); }
  167. }
  168. }
  169. /// <summary>
  170. /// 开新卡
  171. /// </summary>
  172. /// <param name="sender"></param>
  173. /// <param name="e"></param>
  174. protected override void btnOpenNewCard_Click(object sender, EventArgs e)
  175. {
  176. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.AddGoldCardMemberSmallForm frm = new SetSmallForm.AddGoldCardMemberSmallForm();
  177. frm.ShowDialog();
  178. if (frm.IsSaveed)
  179. {
  180. //this.PublicFunctionRows();
  181. ucPagerEx1.PageCurrent = 1;
  182. ucPagerEx1.Bind();
  183. }
  184. }
  185. /// <summary>
  186. /// 会员卡管理
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. protected override void btnCardManage_Click(object sender, EventArgs e)
  191. {
  192. if (this.dgvData.Rows.Count > 0)
  193. {
  194. if (this.dgvData.SelectedRows.Count > 0)
  195. {
  196. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.GoldManagementSmallForm frm = new SetSmallForm.GoldManagementSmallForm();
  197. frm.StrNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
  198. frm.CancellationCard = this.cbkManageCancellationCard.Checked;
  199. frm.ShowDialog();
  200. if (frm.IsSaveed)
  201. {
  202. //this.PublicFunctionRows();
  203. ucPagerEx1.PageCurrent = 1;
  204. ucPagerEx1.Bind();
  205. }
  206. return;
  207. }
  208. }
  209. MessageBoxCustom.Show("请选择要操作的会员号");
  210. }
  211. /// <summary>
  212. /// 新摄会管理
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. protected override void btnPhotographerManagement_Click(object sender, EventArgs e)
  217. {
  218. if (this.dgvData.Rows.Count > 0)
  219. {
  220. if (this.dgvData.SelectedRows.Count > 0)
  221. {
  222. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MyPhotographerConferenceSmallForm frm = new SetSmallForm.MyPhotographerConferenceSmallForm();
  223. frm.StrNumber = this.dgvData.SelectedRows[0].Cells["Mc_Number"].Value.ToString().Trim();
  224. frm.ShowDialog();
  225. //if (frm.IsSaveed)
  226. //{ PublicFunctionRows(); }
  227. return;
  228. }
  229. }
  230. MessageBoxCustom.Show("请选择要操作的会员号");
  231. }
  232. /// <summary>
  233. /// 发短信
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. protected override void btnSendSMS_Click(object sender, EventArgs e)
  238. {
  239. if (this.dgvData.Rows.Count > 0)
  240. {
  241. if (this.dgvData.SelectedRows.Count > 0)
  242. {
  243. string StrMc_Telephone = "";
  244. string strtmp = "";
  245. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  246. {
  247. if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim()))
  248. { StrMc_Telephone += this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim() + ","; }
  249. else
  250. { strtmp = this.dgvData.SelectedRows[i].Cells["电话"].Value.ToString().Trim() + ","; }
  251. }
  252. if (strtmp != "")
  253. { MessageBoxCustom.Show("号码" + strtmp.TrimEnd(',') + "不是正确的电话号码"); }
  254. if (StrMc_Telephone != "")
  255. {
  256. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms SendSMS = new SMSManagement.SmsSend.FrmSendSms();
  257. SendSMS.Phone = StrMc_Telephone.TrimEnd(',');
  258. SendSMS.Show();
  259. }
  260. else { MessageBoxCustom.Show("请选中您要发送短信的会员"); }
  261. }
  262. }
  263. }
  264. /// <summary>
  265. /// 导入
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. protected override void btnImport_Click(object sender, EventArgs e)
  270. {
  271. Point p = this.Parent.PointToScreen(new Point(0, 0));
  272. p.Y += 2;
  273. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MemberImportExcel frm = new SetSmallForm.MemberImportExcel();
  274. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  275. frm.Location = p;
  276. frm.Size = new Size(this.Width - 4, this.Height - 5);
  277. frm.ShowDialog();
  278. if (frm.IsSaveed)
  279. {
  280. //this.PublicFunctionRows();
  281. ucPagerEx1.PageCurrent = 1;
  282. ucPagerEx1.Bind();
  283. }
  284. }
  285. /// <summary>
  286. /// 导出
  287. /// </summary>
  288. /// <param name="sender"></param>
  289. /// <param name="e"></param>
  290. protected override void btnExporting_Click(object sender, EventArgs e)
  291. {
  292. #if IGNORE // 只能导出当前列表的数据, 不能按要求导出;
  293. this.dgvData.ExportDataTable(StrFileName: "会员卡");
  294. #else
  295. // 保存对话框;
  296. SaveFileDialog saveFile = new SaveFileDialog();
  297. saveFile.FileName = "会员资料";
  298. saveFile.Title = "导出数据报表文件";
  299. saveFile.Filter = "EXECL文件(*.xls) |*.xls |文本文件(*.txt) |*.txt |所有文件(*.*) |*.*";
  300. saveFile.FilterIndex = 1;
  301. DialogResult drst = saveFile.ShowDialog();
  302. if (drst == DialogResult.No || drst == DialogResult.Cancel || drst == DialogResult.No || drst == DialogResult.Abort)
  303. return;
  304. bool IsExport = false;
  305. // 获取查询出来的DataTable;
  306. DataTable table = null;
  307. string StrQueryCondition = this.GetWhereStr();
  308. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  309. {
  310. table = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrQueryCondition, -1);
  311. });
  312. if (table.Rows.Count == 0)
  313. {
  314. MessageBoxCustom.Show("没有数据可导出");
  315. return;
  316. }
  317. // 移除多余的列;
  318. table.Columns.Remove("Mc_Number");
  319. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  320. {
  321. try
  322. {
  323. if (LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), table, null, backgroundWorker))
  324. {
  325. MessageBoxCustom.Show("数据导出成功!");
  326. }
  327. else
  328. {
  329. MessageBoxCustom.Show("数据导出失败!");
  330. }
  331. }
  332. catch (Exception ex)
  333. {
  334. MessageBoxCustom.Show(String.Format("导出数据出错:{0}", ex.Message));
  335. }
  336. });
  337. //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
  338. //{
  339. // if (table.Rows.Count > 0)
  340. // {
  341. // try
  342. // {
  343. // //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
  344. // //{
  345. // // IsExport = LYFZ.Command.Command_ExportExcel.DataTable2Sheet(saveFile.FileName.Trim(), table, "Sheet1", IsCoveredExistingFile: true);
  346. // //}));
  347. // IsExport = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), table, null, backgroundWorker);
  348. // }
  349. // catch
  350. // { }
  351. // if (IsExport)
  352. // MessageBoxCustom.Show("导出成功!");
  353. // else
  354. // MessageBoxCustom.Show("导出失败!");
  355. // }
  356. //}));
  357. #endif
  358. }
  359. /// <summary>
  360. /// 关闭
  361. /// </summary>
  362. /// <param name="sender"></param>
  363. /// <param name="e"></param>
  364. protected override void btnClose_Click(object sender, EventArgs e)
  365. { this.Close(); }
  366. /// <summary>
  367. /// 主卡列表双击事件
  368. /// </summary>
  369. /// <param name="sender"></param>
  370. /// <param name="e"></param>
  371. protected override void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  372. {
  373. if (this.dgvData.Rows.Count > 0)
  374. {
  375. if (e.ColumnIndex != -1 && e.RowIndex != -1)
  376. { this.btnCardManage_Click(this, null); }
  377. }
  378. }
  379. /// <summary>
  380. /// 窗体大小发生变化
  381. /// </summary>
  382. /// <param name="sender"></param>
  383. /// <param name="e"></param>
  384. protected override void GoldCardMemberFormMain_Resize(object sender, EventArgs e)
  385. {
  386. if (!this.IsFirstRun)
  387. {
  388. int ControlsWidth = 0;
  389. int ForCount = 0;
  390. for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
  391. {
  392. if (this.flowLayoutPanel1.Controls[i].Visible)
  393. {
  394. ForCount++;
  395. ControlsWidth += this.flowLayoutPanel1.Controls[i].Width;
  396. }
  397. }
  398. ControlsWidth += ForCount * 6 + this.btnClose.Width / 2;
  399. int strWidth = this.Width;
  400. if (strWidth > ControlsWidth)
  401. { this.flowLayoutPanel1.Size = new Size(this.panelEx2.Width - 10, 40); }
  402. else
  403. { this.flowLayoutPanel1.Size = new Size(this.panelEx2.Width - 10, 70); }
  404. }
  405. }
  406. /// <summary>
  407. /// 右键菜单
  408. /// </summary>
  409. /// <param name="sender"></param>
  410. /// <param name="e"></param>
  411. void dgvData_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
  412. {
  413. if (e.Button == MouseButtons.Right)
  414. {
  415. if (e.RowIndex == -1)
  416. {
  417. this.dgvData.conMenu.Items.Clear();
  418. ToolStripMenuItem item = new ToolStripMenuItem();
  419. item.Text = "设置标题";
  420. item.Tag = "SetColumnShow";
  421. item.Name = "SetColumnShow";
  422. this.dgvData.conMenu.Items.Add(item);
  423. // this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
  424. this.dgvData.conMenu.ItemClicked -= dgvData_DataGridViewConMenu_ItemClicked;
  425. this.dgvData.conMenu.ItemClicked += dgvData_DataGridViewConMenu_ItemClicked;
  426. // this.dgvData.conMenu.Show();
  427. if (!this.dgvData.conMenu.Visible)
  428. {
  429. this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
  430. }
  431. }
  432. }
  433. }
  434. /// <summary>
  435. /// 右键菜单选择项事件
  436. /// </summary>
  437. /// <param name="sender"></param>
  438. /// <param name="e"></param>
  439. void dgvData_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  440. {
  441. ToolStripItem item = e.ClickedItem;
  442. if (item.Name.Trim() == "SetColumnShow")
  443. {
  444. if (LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ShowDataGridViewSetColumn(this.dgvData))
  445. {
  446. //this.PublicFunctionRows();
  447. ucPagerEx1.PageCurrent = 1;
  448. ucPagerEx1.Bind();
  449. }
  450. }
  451. }
  452. /// <summary>
  453. /// 欠款选项
  454. /// </summary>
  455. /// <param name="sender"></param>
  456. /// <param name="e"></param>
  457. void chkArrears_Click(object sender, EventArgs e)
  458. {
  459. ucPagerEx1.PageCurrent = 1;
  460. ucPagerEx1.Bind();
  461. //this.PublicFunctionRows();
  462. }
  463. /// <summary>
  464. /// 注销选项
  465. /// </summary>
  466. /// <param name="sender"></param>
  467. /// <param name="e"></param>
  468. void cbkManageCancellationCard_Click(object sender, EventArgs e)
  469. {
  470. ucPagerEx1.PageCurrent = 1;
  471. ucPagerEx1.Bind();
  472. //this.PublicFunctionRows();
  473. }
  474. /// <summary>
  475. /// 点击列标头排序
  476. /// </summary>
  477. /// <param name="sender"></param>
  478. /// <param name="e"></param>
  479. void dgvData_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  480. {
  481. if (e.Button == MouseButtons.Left)
  482. {
  483. string StrColumnName = this.dgvData.Columns[e.ColumnIndex].Name.Trim();
  484. if (StrColumnName == this.StrCurrentClickField || string.IsNullOrEmpty(this.StrCurrentClickField))
  485. {
  486. if (this.StrSortOrder == "ASC")
  487. { this.StrSortOrder = "DESC"; }
  488. else
  489. { this.StrSortOrder = "ASC"; }
  490. }
  491. else
  492. { this.StrSortOrder = "DESC"; }
  493. this.StrSortField = StrColumnName + " " + this.StrSortOrder + "";
  494. this.StrCurrentClickField = StrColumnName;
  495. DataRow[] dtRows = this.newTable.Select("1 = 1", StrColumnName + " " + StrSortOrder);
  496. this.PublicFunctionRows(dtRows);
  497. }
  498. }
  499. /// <summary>
  500. /// 当前点击的字段
  501. /// </summary>
  502. string StrCurrentClickField = "";
  503. /// <summary>
  504. /// 排序字段
  505. /// </summary>
  506. string StrSortField = "Mc_ID DESC";
  507. /// <summary>
  508. /// 排序顺序
  509. /// </summary>
  510. string StrSortOrder = "DESC";
  511. DataTable newTable = new DataTable();
  512. /// <summary>
  513. /// 创建行
  514. /// </summary>
  515. void PublicFunctionRows()
  516. {
  517. this.dgvData.dgvCurrentColumnOriginalSet = "Mc_Number,会员卡号,持卡人,性别,电话,类型,等级,总积分,当前积分,储值欠款,服务卡欠款,总充值金额,金额,折扣,套系金额,已返金额,已取出金额,返现副卡,积分副卡,服务次数,备注,客户生日,办卡日期,卡未使用天数";
  518. string StrGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0032.ToString().Trim();
  519. this.dgvData.dgvFixedHideColumn = "Mc_Number";
  520. this.dgvData.dgvGuidName = StrGuidName;
  521. this.dgvData.dgvUserEmployeeID = this.StrUserID;
  522. Dictionary<string, string> dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(this.StrUserID, StrGuidName, this.dgvData.dgvCurrentColumnOriginalSet);
  523. Dictionary<string, string> tempDictColumns = new Dictionary<string, string>();
  524. foreach (string key in dictColumns.Keys)
  525. {
  526. if(key=="积分")
  527. {
  528. tempDictColumns.Add("当前积分", dictColumns[key]);
  529. }
  530. else
  531. {
  532. tempDictColumns.Add(key, dictColumns[key]);
  533. }
  534. }
  535. dictColumns = tempDictColumns;
  536. this.dgvData.dictShowColumName = dictColumns;
  537. string StrQueryCondition = this.GetWhereStr();
  538. dynamic dyObj = new ExpandoObject();
  539. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  540. {
  541. //this.newTable = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMember(this.dgvData, StrQueryCondition, 1000);
  542. dyObj = LYFZ.ComponentLibrary.DataGridOrderView.GetData_MemberMainGoldMemberNew(this.dgvData, StrQueryCondition,
  543. ucPagerEx1.PageCurrent, ucPagerEx1.PageSize);
  544. this.newTable = dyObj.DataTable;
  545. });
  546. BindPageData(ucPagerEx1.PageCurrent, dyObj.PageSize, dyObj.TotalCount);
  547. if (this.newTable.Rows.Count > 0)
  548. {
  549. this.PublicFunctionRows(this.newTable.Select());
  550. }
  551. else
  552. {
  553. this.dgvData.DataColumns(this.dgvData.dgvCurrentColumnOriginalSet, strHideField: this.dgvData.dgvFixedHideColumn);
  554. }
  555. }
  556. public void BindPageData(int pageIndx, int pageSize, int totalCount)
  557. {
  558. ucPagerEx1.NMax = totalCount;
  559. ucPagerEx1.CurrentPageCount = (pageSize);
  560. ucPagerEx1.PageCurrent = pageIndx;
  561. }
  562. /// <summary>
  563. /// 处理数据
  564. /// </summary>
  565. /// <param name="dtRows"></param>
  566. void PublicFunctionRows(DataRow[] dtRows)
  567. {
  568. this.dgvData.DataColumns(this.newTable.Columns, strHideField: "Mc_Number");
  569. this.dgvData.FillLastColumn();
  570. DataGridViewRow dgvr = null;
  571. DataGridViewCell cell = null;
  572. for (int i = 0; i < dtRows.Length; i++)
  573. {
  574. dgvr = new DataGridViewRow();
  575. for (int j = 0; j < this.newTable.Columns.Count; j++)
  576. {
  577. cell = new DataGridViewTextBoxCell();
  578. cell.Value = dtRows[i][this.newTable.Columns[j].ColumnName.Trim()].ToString().Trim();
  579. dgvr.Cells.Add(cell);
  580. }
  581. if (this.newTable.Columns.Contains("储值欠款") && Convert.ToDecimal(dtRows[i]["储值欠款"]) > 0)
  582. {
  583. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  584. }
  585. if (this.newTable.Columns.Contains("服务卡欠款") && Convert.ToDecimal(dtRows[i]["服务卡欠款"]) > 0)
  586. {
  587. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  588. }
  589. this.dgvData.Rows.Add(dgvr);
  590. }
  591. this.dgvData.Columns["持卡人"].Frozen = true;
  592. this.dgvData.Columns["持卡人"].Width = 120;
  593. if (this.dgvData.Columns.Contains("办卡日期"))
  594. { this.dgvData.Columns["办卡日期"].Width = 120; }
  595. this.dgvData.ClearSelection();
  596. }
  597. /// <summary>
  598. /// 获取查询条件
  599. /// </summary>
  600. /// <returns></returns>
  601. string GetWhereStr()
  602. {
  603. string StrWhere = "";
  604. string StrText = this.cmbQueryText.Text.Trim();
  605. string StrStoreNameWhere = DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Mc_DividedShop", ConnectWord: " and ");
  606. if (LYFZ.Command.Command_Validate.IsChinese(StrText))
  607. { StrWhere += " And (Cus_Name like '%" + StrText + "%' or Mc_SecondQueryName like '%" + StrText + "%')"; }
  608. else if (LYFZ.Command.Command_Validate.IsNumber(StrText))
  609. {
  610. if (StrText.Length == 11)
  611. { StrWhere += " And (Cus_Telephone = '" + StrText + "'or Mc_CradNumber = '" + StrText + "')"; }
  612. else
  613. { StrWhere += " And (Cus_Telephone like '%" + StrText + "%' or Mc_CradNumber like '%" + StrText + "%')"; }
  614. }
  615. else if (LYFZ.Command.Command_Validate.IsEnglish(StrText))
  616. { StrWhere += " And (dbo.fn_ChineseToSpell(Cus_Name) like '%" + StrText + "%' or dbo.fn_ChineseToSpell(Mc_SecondQueryName) like '%" + StrText + "%')"; }
  617. else if (LYFZ.Command.Command_Validate.IsOrderNumber(StrText))
  618. { StrWhere += " And Mc_CradNumber like '%" + StrText + "%'"; }
  619. if (this.cbkManageCancellationCard.Checked)
  620. { StrWhere += " and Mc_Status = '0'"; }
  621. else
  622. { StrWhere += " and Mc_Status = '1'"; }
  623. if (this.chkArrears.Checked)
  624. { StrWhere += " and (isnull(欠款,0) > 0 or isnull(Mcrd_ArrearsAmount,0)>0 )"; }
  625. if (htData != null && htData.Count > 0)
  626. {
  627. if (htData.ContainsKey("AvailableAmountStart") && htData.ContainsKey("AvailableAmountEnd"))
  628. {
  629. if (htData["AvailableAmountStart"].ToString().Trim().Length > 0 && htData["AvailableAmountEnd"].ToString().Trim().Length > 0)
  630. { StrWhere += " and (Mc_Money between " + htData["AvailableAmountStart"].ToString().Trim() + " and " + htData["AvailableAmountEnd"].ToString().Trim() + ")"; }
  631. else if (htData["AvailableAmountStart"].ToString().Trim().Length > 0 && htData["AvailableAmountEnd"].ToString().Trim().Length <= 0)
  632. { StrWhere += " and Mc_Money = " + htData["AvailableAmountStart"].ToString().Trim() + ""; }
  633. else if (htData["AvailableAmountStart"].ToString().Trim().Length <= 0 && htData["AvailableAmountEnd"].ToString().Trim().Length > 0)
  634. { StrWhere += " and Mc_Money = " + htData["AvailableAmountEnd"].ToString().Trim() + ""; }
  635. }
  636. if (htData.ContainsKey("AvailablePointsStart") && htData.ContainsKey("AvailablePointsEnd"))
  637. {
  638. if (htData["AvailablePointsStart"].ToString().Trim().Length > 0 && htData["AvailablePointsEnd"].ToString().Trim().Length > 0)
  639. { StrWhere += " and (isnull(Mcps_AvailablePoints,0) between " + htData["AvailablePointsStart"].ToString().Trim() + " and " + htData["AvailablePointsEnd"].ToString().Trim() + ")"; }
  640. else if (htData["AvailablePointsStart"].ToString().Trim().Length > 0 && htData["AvailablePointsEnd"].ToString().Trim().Length <= 0)
  641. { StrWhere += " and isnull(Mcps_AvailablePoints,0) = " + htData["AvailablePointsStart"].ToString().Trim() + ""; }
  642. else if (htData["AvailablePointsStart"].ToString().Trim().Length <= 0 && htData["AvailablePointsEnd"].ToString().Trim().Length > 0)
  643. { StrWhere += " and isnull(Mcps_AvailablePoints,0) = " + htData["AvailablePointsEnd"].ToString().Trim() + ""; }
  644. }
  645. if (htData.ContainsKey("SeriesAmountStart") && htData.ContainsKey("SeriesAmountEnd"))
  646. {
  647. if (htData["SeriesAmountStart"].ToString().Trim().Length > 0 && htData["SeriesAmountEnd"].ToString().Trim().Length > 0)
  648. { StrWhere += " and (isnull(Mcbc_PackagesMoney,0) between " + htData["SeriesAmountStart"].ToString().Trim() + " and " + htData["SeriesAmountEnd"].ToString().Trim() + ")"; }
  649. else if (htData["SeriesAmountStart"].ToString().Trim().Length > 0 && htData["SeriesAmountEnd"].ToString().Trim().Length <= 0)
  650. { StrWhere += " and isnull(Mcbc_PackagesMoney,0) = " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
  651. else if (htData["SeriesAmountStart"].ToString().Trim().Length <= 0 && htData["SeriesAmountEnd"].ToString().Trim().Length > 0)
  652. { StrWhere += " and isnull(Mcbc_PackagesMoney,0) = " + htData["SeriesAmountEnd"].ToString().Trim() + ""; }
  653. }
  654. if (htData.ContainsKey("ServiceStartNumber") && htData.ContainsKey("ServiceEndNumber"))
  655. {
  656. if (htData["ServiceStartNumber"].ToString().Trim().Length > 0 && htData["ServiceEndNumber"].ToString().Trim().Length > 0)
  657. { StrWhere += " and (isnull(Mcse_ServiceCount,0) between " + htData["ServiceStartNumber"].ToString().Trim() + " and " + htData["ServiceEndNumber"].ToString().Trim() + ")"; }
  658. else if (htData["ServiceStartNumber"].ToString().Trim().Length > 0 && htData["ServiceEndNumber"].ToString().Trim().Length <= 0)
  659. { StrWhere += " and isnull(Mcse_ServiceCount,0) = " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
  660. else if (htData["ServiceStartNumber"].ToString().Trim().Length <= 0 && htData["ServiceEndNumber"].ToString().Trim().Length > 0)
  661. { StrWhere += " and isnull(Mcse_ServiceCount,0) = " + htData["ServiceEndNumber"].ToString().Trim() + ""; }
  662. }
  663. if (htData.ContainsKey("StartTotalMoney") && htData.ContainsKey("EndTotalMoney"))
  664. {
  665. if (htData["StartTotalMoney"].ToString().Trim().Length > 0 && htData["EndTotalMoney"].ToString().Trim().Length > 0)
  666. { StrWhere += " and (isnull(Mc_TotalMoney,0) between " + htData["StartTotalMoney"].ToString().Trim() + " and " + htData["EndTotalMoney"].ToString().Trim() + ")"; }
  667. else if (htData["StartTotalMoney"].ToString().Trim().Length > 0 && htData["EndTotalMoney"].ToString().Trim().Length <= 0)
  668. { StrWhere += " and isnull(Mc_TotalMoney,0) >= " + htData["SeriesAmountStart"].ToString().Trim() + ""; }
  669. else if (htData["StartTotalMoney"].ToString().Trim().Length <= 0 && htData["EndTotalMoney"].ToString().Trim().Length > 0)
  670. { StrWhere += " and isnull(Mc_TotalMoney,0) <= " + htData["EndTotalMoney"].ToString().Trim() + ""; }
  671. }
  672. if (htData.ContainsKey("ClientBirthdayStart") && htData.ContainsKey("ClientBirthdayEnd"))
  673. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("dbo.Fun_GetGregorianCalendarNowYearBirthday(Cus_Birthday,Cus_BirthdayLunar)", htData["ClientBirthdayStart"].ToString().Trim(), htData["ClientBirthdayEnd"].ToString().Trim()); }
  674. if (htData.ContainsKey("OpenCardStart") && htData.ContainsKey("OpenCardEnd"))
  675. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Mc_CreateDatetime", htData["OpenCardStart"].ToString().Trim(), htData["OpenCardEnd"].ToString().Trim()); }
  676. }
  677. #if IGNORE // 导出时,需要用;
  678. this.htData.Clear();
  679. #endif
  680. if(!string.IsNullOrEmpty(StrStoreNameWhere))
  681. {
  682. StrWhere = StrWhere + StrStoreNameWhere;
  683. }
  684. return StrWhere;
  685. }
  686. }
  687. }