123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- 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.Helper;
- using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
- namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
- {
- public partial class RedeemPointsSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.RedeemPointsSuperSmallForm
- {
- public RedeemPointsSuperSmallForm()
- {
- }
- LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
- LYFZ.BLL.BLL_ErpMemberCardPoints mcpbll = new LYFZ.BLL.BLL_ErpMemberCardPoints();
- LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcolgbll = new BLL.BLL_ErpMemberCardPointsLOG();
- /// <summary>
- /// 会员卡编号
- /// </summary>
- public string StrNumber;
- /// <summary>
- /// 会员卡号
- /// </summary>
- public string CradNumber;
- /// <summary>
- /// 持卡人
- /// </summary>
- public string CradName;
- /// <summary>
- /// 可取积分
- /// </summary>
- public string AdvisablePoints;
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void RedeemPointsSuperSmallForm_Load(object sender, EventArgs e)
- {
- txtHolders.Text = CradName;
- txtUsablePoints.Text = AdvisablePoints;
- txtCradNumber.Text = CradNumber;
- if (this.Text == "赠送积分")
- {
- labelEx4.Text = "赠送说明:";//
- labelEx5.Text = "赠送积分:";
- }
- }
- /// <summary>
- /// 关闭窗体后发生事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void RedeemPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
- frm1.RefreshParentForm = IsSaveed;
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- if (this.txtUsePoints.Text.Trim() == "")
- { MessageBoxCustom.Show("请输入你要赠送的积分数量"); return; }
- if (LYFZ.Command.Command_Validate.IsNumber(this.txtUsePoints.Text.Trim()) == false)
- { MessageBoxCustom.Show("积分格式输入错误,积分数量以整数为单位计算"); return; }
- if (this.txtUsePoints.Text.Trim().IndexOf('.') != -1)
- { MessageBoxCustom.Show("积分以整数单位计算,你输入的为小数,则自动四会五入为整数"); }
- string Magess = "";
- DateTime StrTime = SDateTime.Now;
- string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- List<CommandInfo> clist = new List<CommandInfo>();
- LYFZ.Model.Model_ErpMemberCardPointsLOG MPLog = new Model.Model_ErpMemberCardPointsLOG();
- LYFZ.Model.Model_ErpMemberCardPoints MCrad = mcpbll.GetModel("Mcps_Number", this.StrNumber);
- bool IsID = true;
- string StrMagess = "";
- if (this.Text == "赠送积分")
- {
- StrMagess = "赠送积分";
- if (txtRedeemGoods.Text.Trim() == "")
- { MessageBoxCustom.Show("赠送积分,请在赠送说明中输入赠送原由"); return; }
- if (MCrad.ID <= 0)
- { IsID = false; MPLog.MPlg_OriginalPoints = 0; MCrad.Mcps_Number = this.StrNumber; }
- else { MPLog.MPlg_OriginalPoints = MCrad.Mcps_AvailablePoints; }
- MCrad.Mcps_TotalPoints = MCrad.Mcps_TotalPoints + Convert.ToInt32(this.txtUsePoints.Text.Trim());
- MCrad.Mcps_AvailablePoints = MCrad.Mcps_AvailablePoints + Convert.ToInt32(this.txtUsePoints.Text.Trim());
- MCrad.Mcps_UpdateDateTime = StrTime;
- MCrad.Mcps_UpdateName = StrUserName;
- string StrGradeName = LYFZ.BLL.OrderPayment_Member.GetMemberUpgradeData(this.StrNumber, Convert.ToInt32(this.txtUsePoints.Text.Trim()));
- if (StrGradeName != "")
- {
- LYFZ.Model.Model_ErpMemberCard mdlCard = mcbll.GetModel("Mc_Number", this.StrNumber);
- mdlCard.Mc_CardType = StrGradeName;
- clist.Add(mcbll.GetUpdateCommandInfo(mdlCard));
- }
- MPLog.MPlg_Type = "2";
- MPLog.MPlg_Remark = "本次" + this.txtRedeemGoods.Text.Trim() + "赠送积分" + this.txtUsePoints.Text.Trim();
- Magess = "赠送积分成功";
- }
- else
- {
- StrMagess = "兑换物品";
- if (MCrad.ID <= 0)
- { IsID = false; MPLog.MPlg_OriginalPoints = 0; }
- else { MPLog.MPlg_OriginalPoints = MCrad.Mcps_AvailablePoints; }
- if ((MCrad.Mcps_AvailablePoints - Convert.ToInt32(txtUsePoints.Text.Trim())) < 0)
- { MessageBoxCustom.Show("你的可用积分不足,兑换失败"); return; }
- if (txtRedeemGoods.Text.Trim() == "")
- { MessageBoxCustom.Show("请输入要兑换的物品"); return; }
- MCrad.Mcps_AvailablePoints = MCrad.Mcps_AvailablePoints - Convert.ToInt32(this.txtUsePoints.Text.Trim());
- MCrad.Mcps_UpdateDateTime = StrTime;
- MCrad.Mcps_UpdateName = StrUserName;
- MPLog.MPlg_Type = "0";
- MPLog.MPlg_Remark = "本次兑换物品" + this.txtRedeemGoods.Text.Trim() + "使用积分" + this.txtUsePoints.Text.Trim();
- Magess = "物品兑换成功";
- }
- MPLog.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
- MPLog.MPlg_Number = this.StrNumber;
- MPLog.MPlg_OrderNumber = "";
- MPLog.MPlg_ExistingPoints = MCrad.Mcps_AvailablePoints;
- MPLog.MPlg_UsePoints = Convert.ToInt32(this.txtUsePoints.Text.Trim());
- MPLog.MPlg_RedeemArticle = this.txtRedeemGoods.Text.Trim();
- MPLog.MPlg_CreateDatetime = StrTime;
- MPLog.MPlg_CreateName = StrUserName;
- if (IsID)
- { clist.Add(mcpbll.GetUpdateCommandInfo(MCrad)); }
- else { clist.Add(mcpbll.GetAddCommandInfo(MCrad)); }
- clist.Add(mcolgbll.GetAddCommandInfo(MPLog));
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("确定要" + StrMagess + "吗", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- IsSaveed = true;
- LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
- string StrContentText = "";
- if (this.Text == "赠送积分")
- {
- StrContentText = "本次" + this.txtRedeemGoods.Text.Trim() + ",获得赠送积分(" + MPLog.MPlg_UsePoints + ")分,当前可用积分(" + MCrad.Mcps_AvailablePoints + ")分。";
- // LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS("", modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
- //2017-03-24 刘工修改
- LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(modelCard.Mc_CustomerNumber, modelCard.Mc_CradNumber, "", MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
- }
- else
- {
- StrContentText = "本次兑换物品" + this.txtRedeemGoods.Text.Trim() + "使用积分(" + MPLog.MPlg_UsePoints + ")分,当前可用积分(" + MCrad.Mcps_AvailablePoints + ")分。";
- LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(modelCard.Mc_CustomerNumber, modelCard.Mc_CradNumber, "", MCrad.Mcps_AvailablePoints, GetReferralPoints: 0, StrContentText: StrContentText);
- }
- //System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
- //{
- // LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
- // Model.SMSParameters sparameters = new Model.SMSParameters();
- // LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
- // sparameters.CurrentSpendingMemberID = modelCard.Mc_CustomerNumber;
- // sparameters.AvailablePoints = MCrad.Mcps_AvailablePoints;
- // try
- // { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分接近X的百分之80时, sparameters); }
- // catch { }
- // try
- // { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分达到或超过X分时, sparameters); }
- // catch { }
- //}));
- //t.Start();
- MessageBoxCustom.Show(Magess);
- this.Close();
- }
- else
- { MessageBoxCustom.Show("操作失败"); }
- }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnCancel_Click(object sender, EventArgs e)
- { this.Close(); }
- }
- }
|