protected void btnSend_Click(object sender, EventArgs e)
 {
     CouponItemInfo item = new CouponItemInfo();
     IList<CouponItemInfo> listCouponItem = new List<CouponItemInfo>();
     IList<Member> memdersByNames = new List<Member>();
     if (rdoName.Checked)
     {
         if (!string.IsNullOrEmpty(txtMemberNames.Text.Trim()))
         {
             IList<string> names = new List<string>();
             string[] strArray = txtMemberNames.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 if (IsMembers(strArray[i]))
                 {
                     names.Add(strArray[i]);
                 }
             }
             memdersByNames = SubsitePromoteHelper.GetMemdersByNames(names);
         }
         string claimCode = string.Empty;
         foreach (Member member in memdersByNames)
         {
             claimCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
             item = new CouponItemInfo(couponId, claimCode, new int?(member.UserId), member.Email, DateTime.Now);
             listCouponItem.Add(item);
         }
         if (listCouponItem.Count <= 0)
         {
             ShowMsg("你输入的会员名中没有一个正确的,请输入正确的会员名", false);
             return;
         }
         SubsiteCouponHelper.SendClaimCodes(couponId, listCouponItem);
         txtMemberNames.Text = string.Empty;
         ShowMsg(string.Format("此次发送操作已成功,优惠券发送数量:{0}", listCouponItem.Count), true);
     }
     if (rdoRank.Checked)
     {
         memdersByNames = SubsitePromoteHelper.GetMembersByRank(rankList.SelectedValue);
         string str2 = string.Empty;
         foreach (Member member2 in memdersByNames)
         {
             str2 = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
             item = new CouponItemInfo(couponId, str2, new int?(member2.UserId), member2.Email, DateTime.Now);
             listCouponItem.Add(item);
         }
         if (listCouponItem.Count <= 0)
         {
             ShowMsg("您选择的会员等级下面没有会员", false);
         }
         else
         {
             SubsiteCouponHelper.SendClaimCodes(couponId, listCouponItem);
             txtMemberNames.Text = string.Empty;
             ShowMsg(string.Format("此次发送操作已成功,优惠券发送数量:{0}", listCouponItem.Count), true);
         }
     }
 }
Example #2
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     CouponItemInfo item = new CouponItemInfo();
     IList<CouponItemInfo> listCouponItem = new List<CouponItemInfo>();
     IList<MemberInfo> memdersByOpenIds = new List<MemberInfo>();
     if (this.rdoName.Checked)
     {
         if (!string.IsNullOrEmpty(this.txtMemberNames.Text.Trim()))
         {
             memdersByOpenIds = MemberHelper.GetMemdersByOpenIds("'" + this.txtMemberNames.Text.Trim().Replace("\r\n", "\n").Replace("\n", "','") + "'");
         }
         string claimCode = string.Empty;
         foreach (MemberInfo info2 in memdersByOpenIds)
         {
             claimCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
             item = new CouponItemInfo(this.couponId, claimCode, new int?(info2.UserId), info2.UserName, info2.Email, DateTime.Now);
             listCouponItem.Add(item);
         }
         if (listCouponItem.Count <= 0)
         {
             this.ShowMsg("你输入的OpenId中没有一个正确的,请输入正确的OpenId", false);
             return;
         }
         CouponHelper.SendClaimCodes(this.couponId, listCouponItem);
         this.txtMemberNames.Text = string.Empty;
         this.ShowMsg(string.Format("此次发送操作已成功,优惠券发送数量:{0}", listCouponItem.Count), true);
     }
     if (this.rdoRank.Checked)
     {
         memdersByOpenIds = MemberHelper.GetMembersByRank(this.rankList.SelectedValue);
         string str3 = string.Empty;
         foreach (MemberInfo info3 in memdersByOpenIds)
         {
             str3 = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
             item = new CouponItemInfo(this.couponId, str3, new int?(info3.UserId), info3.UserName, info3.Email, DateTime.Now);
             listCouponItem.Add(item);
         }
         if (listCouponItem.Count <= 0)
         {
             this.ShowMsg("您选择的会员等级下面没有会员", false);
         }
         else
         {
             CouponHelper.SendClaimCodes(this.couponId, listCouponItem);
             this.txtMemberNames.Text = string.Empty;
             this.ShowMsg(string.Format("此次发送操作已成功,优惠券发送数量:{0}", listCouponItem.Count), true);
         }
     }
 }
Example #3
0
 public static CouponItemInfo PopulateCouponItem(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     CouponItemInfo info = new CouponItemInfo();
     info.CouponId = (int) reader["CouponId"];
     info.ClaimCode = (string) reader["ClaimCode"];
     info.GenerateTime = Convert.ToDateTime(reader["GenerateTime"]);
     if (reader["UserId"] != DBNull.Value)
     {
         info.UserId = new int?((int) reader["UserId"]);
     }
     if (reader["EmailAddress"] != DBNull.Value)
     {
         info.EmailAddress = (string) reader["EmailAddress"];
     }
     return info;
 }
Example #4
0
 public abstract bool SendClaimCodes(CouponItemInfo couponItem);
Example #5
0
 public override bool SendClaimCodes(CouponItemInfo couponItem)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_CouponItems(CouponId, ClaimCode,LotNumber, GenerateTime, UserId, EmailAddress) VALUES(@CouponId, @ClaimCode,@LotNumber, @GenerateTime, @UserId, @EmailAddress)");
     database.AddInParameter(sqlStringCommand, "CouponId", DbType.Int32, couponItem.CouponId);
     database.AddInParameter(sqlStringCommand, "ClaimCode", DbType.String, couponItem.ClaimCode);
     database.AddInParameter(sqlStringCommand, "GenerateTime", DbType.DateTime, couponItem.GenerateTime);
     database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32);
     database.AddInParameter(sqlStringCommand, "LotNumber", DbType.Guid, Guid.NewGuid());
     if (couponItem.UserId.HasValue)
     {
         database.SetParameterValue(sqlStringCommand, "UserId", couponItem.UserId.Value);
     }
     else
     {
         database.SetParameterValue(sqlStringCommand, "UserId", DBNull.Value);
     }
     database.AddInParameter(sqlStringCommand, "EmailAddress", DbType.String, couponItem.EmailAddress);
     return (database.ExecuteNonQuery(sqlStringCommand) >= 1);
 }
Example #6
0
 public static bool PointChageCoupon(int couponId, int needPoint, int currentPoint)
 {
     Member user = HiContext.Current.User as Member;
     UserPointInfo point = new UserPointInfo();
     point.OrderId = string.Empty;
     point.UserId = user.UserId;
     point.TradeDate = DateTime.Now;
     point.TradeType = UserPointTradeType.ChangeCoupon;
     point.Increased = null;
     point.Reduced = new int?(needPoint);
     point.Points = currentPoint - needPoint;
     if ((point.Points >= 0) && TradeProvider.Instance().AddMemberPoint(point))
     {
         CouponItemInfo couponItem = new CouponItemInfo();
         couponItem.CouponId = couponId;
         couponItem.UserId = new int?(user.UserId);
         couponItem.EmailAddress = user.Email;
         couponItem.ClaimCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
         couponItem.GenerateTime = DateTime.Now;
         Users.ClearUserCache(user);
         if (TradeProvider.Instance().SendClaimCodes(couponItem))
         {
             return true;
         }
     }
     return false;
 }
Example #7
0
 public bool SendClaimCodes(int couponId, CouponItemInfo couponItem)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_CouponItems(CouponId, ClaimCode,LotNumber, GenerateTime, UserId,UserName,EmailAddress,CouponStatus) VALUES(@CouponId, @ClaimCode,@LotNumber, @GenerateTime, @UserId, @UserName,@EmailAddress,@CouponStatus)");
     this.database.AddInParameter(sqlStringCommand, "CouponId", DbType.Int32, couponId);
     this.database.AddInParameter(sqlStringCommand, "ClaimCode", DbType.String, couponItem.ClaimCode);
     this.database.AddInParameter(sqlStringCommand, "GenerateTime", DbType.DateTime, couponItem.GenerateTime);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32);
     this.database.AddInParameter(sqlStringCommand, "UserName", DbType.String);
     this.database.AddInParameter(sqlStringCommand, "LotNumber", DbType.Guid, Guid.NewGuid());
     if (couponItem.UserId.HasValue)
     {
         this.database.SetParameterValue(sqlStringCommand, "UserId", couponItem.UserId.Value);
     }
     else
     {
         this.database.SetParameterValue(sqlStringCommand, "UserId", DBNull.Value);
     }
     if (!string.IsNullOrEmpty(couponItem.UserName))
     {
         this.database.SetParameterValue(sqlStringCommand, "UserName", couponItem.UserName);
     }
     else
     {
         this.database.SetParameterValue(sqlStringCommand, "UserName", DBNull.Value);
     }
     this.database.AddInParameter(sqlStringCommand, "EmailAddress", DbType.String, couponItem.EmailAddress);
     this.database.AddInParameter(sqlStringCommand, "CouponStatus", DbType.String, 0);
     return (this.database.ExecuteNonQuery(sqlStringCommand) >= 1);
 }