RedeemPointsSuperSmallForm.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.Helper;
  11. using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
  12. namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
  13. {
  14. public partial class RedeemPointsSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.RedeemPointsSuperSmallForm
  15. {
  16. public RedeemPointsSuperSmallForm()
  17. {
  18. }
  19. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  20. LYFZ.BLL.BLL_ErpMemberCardPoints mcpbll = new LYFZ.BLL.BLL_ErpMemberCardPoints();
  21. LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcolgbll = new BLL.BLL_ErpMemberCardPointsLOG();
  22. /// <summary>
  23. /// 会员卡编号
  24. /// </summary>
  25. public string StrNumber;
  26. /// <summary>
  27. /// 会员卡号
  28. /// </summary>
  29. public string CradNumber;
  30. /// <summary>
  31. /// 持卡人
  32. /// </summary>
  33. public string CradName;
  34. /// <summary>
  35. /// 可取积分
  36. /// </summary>
  37. public string AdvisablePoints;
  38. /// <summary>
  39. /// 是否保存
  40. /// </summary>
  41. public bool IsSaveed = false;
  42. /// <summary>
  43. /// 窗体加载事件
  44. /// </summary>
  45. /// <param name="sender"></param>
  46. /// <param name="e"></param>
  47. protected override void RedeemPointsSuperSmallForm_Load(object sender, EventArgs e)
  48. {
  49. txtHolders.Text = CradName;
  50. txtUsablePoints.Text = AdvisablePoints;
  51. txtCradNumber.Text = CradNumber;
  52. if (this.Text == "赠送积分")
  53. {
  54. labelEx4.Text = "赠送说明:";//
  55. labelEx5.Text = "赠送积分:";
  56. }
  57. }
  58. /// <summary>
  59. /// 关闭窗体后发生事件
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. protected override void RedeemPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
  64. {
  65. GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
  66. frm1.RefreshParentForm = IsSaveed;
  67. }
  68. /// <summary>
  69. /// 保存
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. protected override void btnSave_Click(object sender, EventArgs e)
  74. {
  75. if (this.txtUsePoints.Text.Trim() == "")
  76. { MessageBoxCustom.Show("请输入你要赠送的积分数量"); return; }
  77. if (LYFZ.Command.Command_Validate.IsNumber(this.txtUsePoints.Text.Trim()) == false)
  78. { MessageBoxCustom.Show("积分格式输入错误,积分数量以整数为单位计算"); return; }
  79. if (this.txtUsePoints.Text.Trim().IndexOf('.') != -1)
  80. { MessageBoxCustom.Show("积分以整数单位计算,你输入的为小数,则自动四会五入为整数"); }
  81. string Magess = "";
  82. DateTime StrTime = SDateTime.Now;
  83. string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  84. List<CommandInfo> clist = new List<CommandInfo>();
  85. LYFZ.Model.Model_ErpMemberCardPointsLOG MPLog = new Model.Model_ErpMemberCardPointsLOG();
  86. LYFZ.Model.Model_ErpMemberCardPoints MCrad = mcpbll.GetModel("Mcps_Number", this.StrNumber);
  87. bool IsID = true;
  88. string StrMagess = "";
  89. if (this.Text == "赠送积分")
  90. {
  91. StrMagess = "赠送积分";
  92. if (txtRedeemGoods.Text.Trim() == "")
  93. { MessageBoxCustom.Show("赠送积分,请在赠送说明中输入赠送原由"); return; }
  94. if (MCrad.ID <= 0)
  95. { IsID = false; MPLog.MPlg_OriginalPoints = 0; MCrad.Mcps_Number = this.StrNumber; }
  96. else { MPLog.MPlg_OriginalPoints = MCrad.Mcps_AvailablePoints; }
  97. MCrad.Mcps_TotalPoints = MCrad.Mcps_TotalPoints + Convert.ToInt32(this.txtUsePoints.Text.Trim());
  98. MCrad.Mcps_AvailablePoints = MCrad.Mcps_AvailablePoints + Convert.ToInt32(this.txtUsePoints.Text.Trim());
  99. MCrad.Mcps_UpdateDateTime = StrTime;
  100. MCrad.Mcps_UpdateName = StrUserName;
  101. string StrGradeName = LYFZ.BLL.OrderPayment_Member.GetMemberUpgradeData(this.StrNumber, Convert.ToInt32(this.txtUsePoints.Text.Trim()));
  102. if (StrGradeName != "")
  103. {
  104. LYFZ.Model.Model_ErpMemberCard mdlCard = mcbll.GetModel("Mc_Number", this.StrNumber);
  105. mdlCard.Mc_CardType = StrGradeName;
  106. clist.Add(mcbll.GetUpdateCommandInfo(mdlCard));
  107. }
  108. MPLog.MPlg_Type = "2";
  109. MPLog.MPlg_Remark = "本次" + this.txtRedeemGoods.Text.Trim() + "赠送积分" + this.txtUsePoints.Text.Trim();
  110. Magess = "赠送积分成功";
  111. }
  112. else
  113. {
  114. StrMagess = "兑换物品";
  115. if (MCrad.ID <= 0)
  116. { IsID = false; MPLog.MPlg_OriginalPoints = 0; }
  117. else { MPLog.MPlg_OriginalPoints = MCrad.Mcps_AvailablePoints; }
  118. if ((MCrad.Mcps_AvailablePoints - Convert.ToInt32(txtUsePoints.Text.Trim())) < 0)
  119. { MessageBoxCustom.Show("你的可用积分不足,兑换失败"); return; }
  120. if (txtRedeemGoods.Text.Trim() == "")
  121. { MessageBoxCustom.Show("请输入要兑换的物品"); return; }
  122. MCrad.Mcps_AvailablePoints = MCrad.Mcps_AvailablePoints - Convert.ToInt32(this.txtUsePoints.Text.Trim());
  123. MCrad.Mcps_UpdateDateTime = StrTime;
  124. MCrad.Mcps_UpdateName = StrUserName;
  125. MPLog.MPlg_Type = "0";
  126. MPLog.MPlg_Remark = "本次兑换物品" + this.txtRedeemGoods.Text.Trim() + "使用积分" + this.txtUsePoints.Text.Trim();
  127. Magess = "物品兑换成功";
  128. }
  129. MPLog.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
  130. MPLog.MPlg_Number = this.StrNumber;
  131. MPLog.MPlg_OrderNumber = "";
  132. MPLog.MPlg_ExistingPoints = MCrad.Mcps_AvailablePoints;
  133. MPLog.MPlg_UsePoints = Convert.ToInt32(this.txtUsePoints.Text.Trim());
  134. MPLog.MPlg_RedeemArticle = this.txtRedeemGoods.Text.Trim();
  135. MPLog.MPlg_CreateDatetime = StrTime;
  136. MPLog.MPlg_CreateName = StrUserName;
  137. if (IsID)
  138. { clist.Add(mcpbll.GetUpdateCommandInfo(MCrad)); }
  139. else { clist.Add(mcpbll.GetAddCommandInfo(MCrad)); }
  140. clist.Add(mcolgbll.GetAddCommandInfo(MPLog));
  141. if (clist.Count > 0)
  142. {
  143. if (MessageBoxCustom.Show("确定要" + StrMagess + "吗", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  144. { return; }
  145. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  146. {
  147. IsSaveed = true;
  148. LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
  149. string StrContentText = "";
  150. if (this.Text == "赠送积分")
  151. {
  152. StrContentText = "本次" + this.txtRedeemGoods.Text.Trim() + ",获得赠送积分(" + MPLog.MPlg_UsePoints + ")分,当前可用积分(" + MCrad.Mcps_AvailablePoints + ")分。";
  153. // LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS("", modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
  154. //2017-03-24 刘工修改
  155. LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(modelCard.Mc_CustomerNumber, modelCard.Mc_CradNumber, "", MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
  156. }
  157. else
  158. {
  159. StrContentText = "本次兑换物品" + this.txtRedeemGoods.Text.Trim() + "使用积分(" + MPLog.MPlg_UsePoints + ")分,当前可用积分(" + MCrad.Mcps_AvailablePoints + ")分。";
  160. LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(modelCard.Mc_CustomerNumber, modelCard.Mc_CradNumber, "", MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
  161. }
  162. //System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
  163. //{
  164. // LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
  165. // Model.SMSParameters sparameters = new Model.SMSParameters();
  166. // LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
  167. // sparameters.CurrentSpendingMemberID = modelCard.Mc_CustomerNumber;
  168. // sparameters.AvailablePoints = MCrad.Mcps_AvailablePoints;
  169. // try
  170. // { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分接近X的百分之80时, sparameters); }
  171. // catch { }
  172. // try
  173. // { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分达到或超过X分时, sparameters); }
  174. // catch { }
  175. //}));
  176. //t.Start();
  177. MessageBoxCustom.Show(Magess);
  178. this.Close();
  179. }
  180. else
  181. { MessageBoxCustom.Show("操作失败"); }
  182. }
  183. }
  184. /// <summary>
  185. /// 取消
  186. /// </summary>
  187. /// <param name="sender"></param>
  188. /// <param name="e"></param>
  189. protected override void btnCancel_Click(object sender, EventArgs e)
  190. { this.Close(); }
  191. }
  192. }