BackCashCardCashSuperSmallForm.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.SuperSmallForm
  10. {
  11. public partial class BackCashCardCashSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.BackCashCardCashSuperSmallForm
  12. {
  13. static LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
  14. public BackCashCardCashSuperSmallForm()
  15. {
  16. }
  17. LYFZ.BLL.BLL_ErpMemberCard mcbll = new LYFZ.BLL.BLL_ErpMemberCard();
  18. LYFZ.BLL.BLL_ErpMemberCardBackCash mcbcbll = new BLL.BLL_ErpMemberCardBackCash();
  19. LYFZ.BLL.BLL_ErpMemberCardBackCashTakeCash mctcbll = new BLL.BLL_ErpMemberCardBackCashTakeCash();
  20. /// <summary>
  21. /// 会员卡编号
  22. /// </summary>
  23. public string StrNumber;
  24. /// <summary>
  25. /// 会员卡号
  26. /// </summary>
  27. public string CradNumber;
  28. /// <summary>
  29. /// 持卡人
  30. /// </summary>
  31. public string CradName;
  32. /// <summary>
  33. /// 可取现金
  34. /// </summary>
  35. public string AdvisableCash;
  36. /// <summary>
  37. /// 是否保存
  38. /// </summary>
  39. public bool IsSaveed = false;
  40. public decimal Mcbc_AlreadyWithdrawCash;
  41. LYFZ.Model.Model_ErpMemberCardBackCash model = null;
  42. /// <summary>
  43. /// 窗体加载事件
  44. /// </summary>
  45. /// <param name="sender"></param>
  46. /// <param name="e"></param>
  47. protected override void BackCashCardCashSuperSmallForm_Shown(object sender, EventArgs e)
  48. {
  49. this.txtCardNumber.Text = this.CradNumber;
  50. this.txtHolder.Text = this.CradName;
  51. model = mcbcbll.GetModel("Mcbc_Number", this.StrNumber);
  52. if (model.ID <= 0)
  53. { MessageBoxCustom.Show("没有可提示金额"); this.Close(); }
  54. this.txtPackagesAmoun.Text = model.Mcbc_PackagesMoney.ToString().Trim();
  55. this.txtHaveReturnedAmoun.Text = (model.Mcbc_AlreadyCashBack - model.Mcbc_AlreadyWithdrawCash).ToString();
  56. }
  57. /// <summary>
  58. /// 回车键
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. protected override void txtCashAmount_KeyDown(object sender, KeyEventArgs e)
  63. {
  64. if (e.KeyCode == Keys.Enter)
  65. { this.btnSave_Click(this, null); }
  66. }
  67. /// <summary>
  68. /// 双击已返金额
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. protected override void txtHaveReturnedAmoun_MouseDoubleClick(object sender, MouseEventArgs e)
  73. {
  74. this.txtCashAmount.Text = this.txtHaveReturnedAmoun.Text;
  75. }
  76. /// <summary>
  77. /// 金额输入限制
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. protected override void txtCashAmount_KeyPress(object sender, KeyPressEventArgs e)
  82. {
  83. if (Convert.ToString(e.KeyChar) == ".")
  84. {
  85. if (this.txtCashAmount.Text.Trim().IndexOf('.') != -1)
  86. { e.Handled = true; }
  87. }
  88. else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  89. { e.Handled = true; }
  90. }
  91. /// <summary>
  92. /// 保存
  93. /// </summary>
  94. /// <param name="sender"></param>
  95. /// <param name="e"></param>
  96. protected override void btnSave_Click(object sender, EventArgs e)
  97. {
  98. if (this.txtCashAmount.Text.Trim() == "")
  99. { MessageBoxCustom.Show("请输入提现金额!"); return; }
  100. if (Convert.ToDecimal(this.txtCashAmount.Text) > Convert.ToDecimal(this.txtHaveReturnedAmoun.Text))
  101. { MessageBoxCustom.Show("提现金额不能大于已返金额!"); return; }
  102. LYFZ.Model.Model_ErpMemberCard tblmodel = mcbll.GetModel("Mc_Number", this.StrNumber);
  103. if (tblmodel.Mc_TraderPassword.Trim() != "")
  104. {
  105. LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.EnterPasswordSuperSmallForm Efrm = new SuperSmallForm.EnterPasswordSuperSmallForm();
  106. Efrm.Text = "请输入密码";
  107. Efrm.ShowDialog();
  108. if (Efrm.Pwd != "")
  109. {
  110. if (tblmodel.Mc_TraderPassword.Trim() != LYFZ.Command.Command_MD5.md5(Efrm.Pwd))
  111. { MessageBoxCustom.Show("密码错误"); return; }
  112. }
  113. else
  114. { return; }
  115. }
  116. DateTime strTime = SDateTime.Now;
  117. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  118. decimal deAoumnt = Convert.ToDecimal(this.txtCashAmount.Text);
  119. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  120. model.Mcbc_AlreadyWithdrawCash = model.Mcbc_AlreadyWithdrawCash + deAoumnt;
  121. model.Mcbc_UpdateDateTime = strTime;
  122. model.Mcbc_UpdateName = strUserID;
  123. clist.Add(mcbcbll.GetUpdateCommandInfo(model));
  124. LYFZ.Model.Model_ErpMemberCardBackCashTakeCash modeltc = new Model.Model_ErpMemberCardBackCashTakeCash();
  125. modeltc.Mctc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  126. modeltc.Mctc_Number = this.StrNumber;
  127. modeltc.Mctc_PackagesMoney = this.model.Mcbc_PackagesMoney;
  128. modeltc.Mctc_CashAmount = deAoumnt;
  129. modeltc.Mctc_CashAmountAudit = "";
  130. modeltc.Mctc_CashAmountAuditName = "";
  131. modeltc.Mctc_CashAmountAuditRemark = "";
  132. modeltc.Mctc_UpdateDateTime = strTime;
  133. modeltc.Mctc_UpdateName = strUserID;
  134. clist.Add(mctcbll.GetAddCommandInfo(modeltc));
  135. if (clist.Count > 0)
  136. {
  137. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  138. { MessageBoxCustom.Show("提现失败"); return; }
  139. this.IsSaveed = true;
  140. //XXX 为客户姓名;XXN 为会员卡号;TEXT 为提现内容(如:本次提现金额和剩余未提现金额); XXT 为提现时间
  141. System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
  142. {
  143. Model.SMSParameters sparameters = new Model.SMSParameters();
  144. sparameters.CurrentSpendingMemberID = tblmodel.Mc_CustomerNumber;
  145. sparameters.CardNumber = tblmodel.Mc_CradNumber;
  146. sparameters.TEXT = "返现卡提现金额为:" + deAoumnt;
  147. sparameters.XXT = strTime;
  148. try
  149. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.会员返现卡提现后X分钟, sparameters); }
  150. catch { }
  151. }));
  152. t.Start();
  153. MessageBoxCustom.Show("提现成功");
  154. this.Close();
  155. }
  156. }
  157. /// <summary>
  158. /// 取消
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. protected override void btnCancel_Click(object sender, EventArgs e)
  163. {
  164. this.Close();
  165. }
  166. }
  167. }