MemberCardDeleteSmallForm.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. namespace LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm
  10. {
  11. public partial class MemberCardDeleteSmallForm : LYFZ.Software.UI.MembershipManage.SetSmallForm.MemberCardDeleteSmallForm
  12. {
  13. public MemberCardDeleteSmallForm()
  14. {
  15. this.Load += MemberCardDeleteSmallForm_Load;
  16. this.txtQuery.KeyDown += txtQuery_KeyDown;
  17. this.btnQuery.Click += btnQuery_Click;
  18. this.btnDelete.Click += btnDelete_Click;
  19. }
  20. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  21. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  22. LYFZ.BLL.BLL_ErpMemberCardAmountCashStatus mcacsbll = new BLL.BLL_ErpMemberCardAmountCashStatus();
  23. LYFZ.BLL.BLL_ErpMemberCardAmountChangeLOG mcscLog = new BLL.BLL_ErpMemberCardAmountChangeLOG();
  24. LYFZ.BLL.BLL_ErpMemberCardBackCash mcbsbll = new BLL.BLL_ErpMemberCardBackCash();
  25. LYFZ.BLL.BLL_ErpMemberCardBackCashSet mcbcsetbll = new BLL.BLL_ErpMemberCardBackCashSet();
  26. LYFZ.BLL.BLL_ErpMemberCardBackCashTakeCash mcbctcbll = new BLL.BLL_ErpMemberCardBackCashTakeCash();
  27. LYFZ.BLL.BLL_ErpMemberCardDiscount mcdtbll = new BLL.BLL_ErpMemberCardDiscount();
  28. LYFZ.BLL.BLL_ErpMemberCardInterfaceManagement mcimbll = new BLL.BLL_ErpMemberCardInterfaceManagement();
  29. LYFZ.BLL.BLL_ErpMemberCardOperateLOG mcoLogbll = new BLL.BLL_ErpMemberCardOperateLOG();
  30. LYFZ.BLL.BLL_ErpMemberCardPayment mcptbll = new BLL.BLL_ErpMemberCardPayment();
  31. LYFZ.BLL.BLL_ErpMemberCardPaymentContentDetail mcpcdbll = new BLL.BLL_ErpMemberCardPaymentContentDetail();
  32. LYFZ.BLL.BLL_ErpMemberCardPhotographerMain mcpmbll = new BLL.BLL_ErpMemberCardPhotographerMain();
  33. LYFZ.BLL.BLL_ErpMemberCardPhotographerVice mcpvbll = new BLL.BLL_ErpMemberCardPhotographerVice();
  34. LYFZ.BLL.BLL_ErpMemberCardPoints mcpointsbll = new BLL.BLL_ErpMemberCardPoints();
  35. LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcpointsLog = new BLL.BLL_ErpMemberCardPointsLOG();
  36. LYFZ.BLL.BLL_ErpMemberCardRechargeRecord mcrrbll = new BLL.BLL_ErpMemberCardRechargeRecord();
  37. LYFZ.BLL.BLL_ErpMemberCardServiceContentUseLog mcscuLog = new BLL.BLL_ErpMemberCardServiceContentUseLog();
  38. LYFZ.BLL.BLL_ErpMemberCardViceCard mcvbll = new BLL.BLL_ErpMemberCardViceCard();
  39. LYFZ.BLL.BLL_ErpMemberCardValidity mcvybll = new BLL.BLL_ErpMemberCardValidity();
  40. LYFZ.BLL.BLL_ErpMemberCardTakeCash mctcbll = new LYFZ.BLL.BLL_ErpMemberCardTakeCash();
  41. LYFZ.BLL.BLL_ErpSystemLogs syslog = new BLL.BLL_ErpSystemLogs();
  42. /// <summary>
  43. /// 窗体加载事件
  44. /// </summary>
  45. /// <param name="sender"></param>
  46. /// <param name="e"></param>
  47. void MemberCardDeleteSmallForm_Load(object sender, EventArgs e)
  48. {
  49. this.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  50. this.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  51. this.dgvData.DataColumns("会员卡号,姓名,性别,电话,类型,状态,等级,积分,金额,折扣,套系金额,已返金额,已取出金额,办卡日期,备注");
  52. this.dgvData.FillLastColumn();
  53. }
  54. /// <summary>
  55. /// 回车查询
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. void txtQuery_KeyDown(object sender, KeyEventArgs e)
  60. {
  61. if (e.KeyCode == Keys.Enter)
  62. { this.PublicFunctionRows(); }
  63. }
  64. /// <summary>
  65. /// 查询
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. void btnQuery_Click(object sender, EventArgs e)
  70. { this.PublicFunctionRows(); }
  71. /// <summary>
  72. /// 删除
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. void btnDelete_Click(object sender, EventArgs e)
  77. {
  78. if (this.dgvData.Rows.Count > 0)
  79. {
  80. if (this.dgvData.CurrentCell.ColumnIndex >= 0 && this.dgvData.CurrentRow.Index >= 0)
  81. {
  82. if (MessageBoxCustom.Show("您选择的会员卡号为:" + this.dgvData.CurrentRow.Cells["会员卡号"].Value.ToString().Trim() + ",持卡人为:" + this.dgvData.CurrentRow.Cells["姓名"].Value.ToString().Trim() + ";\r\n删除后则无法恢复!您确定要删除此会员帐户吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  83. {
  84. string StrMcNumber = this.dgvData.CurrentRow.Cells["Mc_Number"].Value.ToString().Trim();
  85. LYFZ.Model.Model_ErpMemberCard modelMc = mcbll.GetModel("Mc_Number", StrMcNumber);
  86. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  87. clist.Add(mcacsbll.GetDeleteCommandInfo(whereStr: "Mcacr_Number = '" + StrMcNumber + "'"));
  88. clist.Add(mcscLog.GetDeleteCommandInfo(whereStr: "Mcacl_Number = '" + StrMcNumber + "'"));
  89. clist.Add(mcbsbll.GetDeleteCommandInfo(whereStr: "Mcbc_Number = '" + StrMcNumber + "'"));
  90. clist.Add(mcbcsetbll.GetDeleteCommandInfo(whereStr: "Mcb_Number = '" + StrMcNumber + "'"));
  91. clist.Add(mcbctcbll.GetDeleteCommandInfo(whereStr: "Mctc_Number = '" + StrMcNumber + "'"));
  92. clist.Add(mcdtbll.GetDeleteCommandInfo(whereStr: "Mcdt_Number = '" + StrMcNumber + "'"));
  93. clist.Add(mcimbll.GetDeleteCommandInfo(whereStr: "Mcim_Number = '" + StrMcNumber + "'"));
  94. clist.Add(mcoLogbll.GetDeleteCommandInfo(whereStr: "mcol_Number = '" + StrMcNumber + "'"));
  95. LYFZ.Model.Model_ErpMemberCardPayment model = mcptbll.GetModel("Mcpt_Number", StrMcNumber);
  96. clist.Add(mcptbll.GetDeleteCommandInfo("ID", "=", model.ID));
  97. clist.Add(mcpcdbll.GetDeleteCommandInfo(whereStr: "Mcpcd_PaymentNumber = '" + model.Mcpt_PaymentNumber + "'"));
  98. clist.Add(mcpmbll.GetDeleteCommandInfo(whereStr: "Mcpm_Number = '" + StrMcNumber + "'"));
  99. clist.Add(mcpvbll.GetDeleteCommandInfo(whereStr: "Mcpv_Number = '" + StrMcNumber + "'"));
  100. clist.Add(mcpointsbll.GetDeleteCommandInfo(whereStr: "Mcps_Number = '" + StrMcNumber + "'"));
  101. clist.Add(mcpointsLog.GetDeleteCommandInfo(whereStr: "MPlg_Number = '" + StrMcNumber + "'"));
  102. clist.Add(mcrrbll.GetDeleteCommandInfo(whereStr: "Mcrr_Number = '" + StrMcNumber + "'"));
  103. clist.Add(mcscuLog.GetDeleteCommandInfo(whereStr: "Mcsl_Number = '" + StrMcNumber + "'"));
  104. clist.Add(mcvbll.GetDeleteCommandInfo(whereStr: "Mvc_Number = '" + StrMcNumber + "'"));
  105. clist.Add(mcbll.GetDeleteCommandInfo("ID", "=", Convert.ToInt32(this.dgvData.CurrentRow.Cells["Mc_ID"].Value)));
  106. clist.Add(mcvybll.GetDeleteCommandInfo("Mcvy_Number","=",StrMcNumber));
  107. clist.Add(mctcbll.GetDeleteCommandInfo("Mctkc_Number", "=", StrMcNumber));
  108. string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  109. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  110. string StrUserIP = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.User_IP;
  111. string StrContent = "[删除会员] 会员卡编号:"+modelMc.Mc_Number+", 会员卡号:" + this.dgvData.CurrentRow.Cells["会员卡号"].Value + ",客户:" + this.dgvData.CurrentRow.Cells["姓名"].Value + " " + this.dgvData.CurrentRow.Cells["电话"].Value + ",等级:" + this.dgvData.CurrentRow.Cells["等级"].Value + ",状态:" + this.dgvData.CurrentRow.Cells["状态"].Value + ",可用金额:" + this.dgvData.CurrentRow.Cells["金额"].Value + ",可用积分:" + this.dgvData.CurrentRow.Cells["积分"].Value + ",折扣:" + this.dgvData.CurrentRow.Cells["折扣"].Value + ",返现套系金额:" + this.dgvData.CurrentRow.Cells["套系金额"].Value + ",已返金额:" + this.dgvData.CurrentRow.Cells["已返金额"].Value + ",已取金额:" + this.dgvData.CurrentRow.Cells["已取出金额"].Value;
  112. clist.Add(new LYFZ.BLL.BLL_ErpSystemLogs().GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除会员, StrContent, strUserID, StrUserName, StrUserIP)));
  113. clist.Add(new BLL.BLL_ErpACVBSYS().GetAddCommandInfo(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetModelLog(LYFZ.EnumPublic.SystemLogsType.删除会员.ToString(), StrContent)));
  114. if (clist.Count > 0)
  115. {
  116. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  117. { MessageBoxCustom.Show("删除失败!"); return; }
  118. try
  119. {
  120. //更新客户组成员表
  121. DataTable tbl = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerID = '" + modelMc.Mc_CustomerNumber + "'", ShowColumnName: "GM_CustomerGroupID").Tables[0];
  122. if (tbl.Rows.Count > 0)
  123. {
  124. try
  125. {
  126. System.Threading.ThreadPool.QueueUserWorkItem(delegate
  127. {
  128. for (int i = 0; i < tbl.Rows.Count; i++)
  129. {
  130. LYFZ.DAL.DAL_ErpCustomer.UpdateAggregationCustomer(tbl.Rows[i]["GM_CustomerGroupID"].ToString().Trim());
  131. }
  132. });
  133. }
  134. catch { }
  135. }
  136. }
  137. catch { }
  138. this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
  139. if (modelMc.Mc_Status == "1")
  140. { LYFZ.BLL.OrderPayment_Member.MemberLogout(modelMc.Mc_CustomerNumber, modelMc.Mc_CradNumber); }
  141. MessageBoxCustom.Show("删除成功!");
  142. }
  143. }
  144. }
  145. else
  146. { MessageBoxCustom.Show("请选择您要删除的会员卡"); return; }
  147. }
  148. }
  149. /// <summary>
  150. /// 数据处理
  151. /// </summary>
  152. void PublicFunctionRows()
  153. {
  154. if (this.txtQuery.Text.Trim() == "")
  155. { MessageBoxCustom.Show("请输入你要查询的会员卡卡号"); return; }
  156. string StrWhere = " 会员卡号 != '' and (会员卡号 like '" + this.txtQuery.Text.Trim() + "%' or 姓名 like '" + this.txtQuery.Text.Trim() + "%' or 电话 like '%" + this.txtQuery.Text.Trim() + "%' or dbo.fn_ChineseToSpell(姓名) like '" + this.txtQuery.Text.Trim() + "%') ";
  157. DataTable tbl = orbll.GetView_Custom("BView_MemberMain_GoldMember", StrWhere: StrWhere, ShowColumnName: "Mc_ID,Mc_Number,会员卡号,姓名,性别,电话,类型,( case when Mc_Status = '0' then '已注销' else '正在使用' end) as 状态,等级,积分,金额,折扣,套系金额,已返金额,已取出金额,办卡日期,备注").Tables[0];
  158. if (tbl.Rows.Count > 0)
  159. {
  160. this.dgvData.DataSource(tbl, strHideField: "Mc_ID,Mc_Number");
  161. }
  162. else
  163. { MessageBoxCustom.Show("根据你输入的查询条件未找到任何相关信息!"); this.dgvData.Rows.Clear(); return; }
  164. }
  165. }
  166. }