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(); /// /// 会员卡编号 /// public string StrNumber; /// /// 会员卡号 /// public string CradNumber; /// /// 持卡人 /// public string CradName; /// /// 可取积分 /// public string AdvisablePoints; /// /// 是否保存 /// public bool IsSaveed = false; /// /// 窗体加载事件 /// /// /// 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 = "赠送积分:"; } } /// /// 关闭窗体后发生事件 /// /// /// protected override void RedeemPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e) { GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner; frm1.RefreshParentForm = IsSaveed; } /// /// 保存 /// /// /// 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 clist = new List(); 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("操作失败"); } } } /// /// 取消 /// /// /// protected override void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }