예제 #1
0
        private void btnSend_Click(object sender, System.EventArgs e)
        {
            VoucherInfo     voucherInfo = VoucherHelper.GetVoucher(voucherId);
            DateTime        deadline    = DateTime.Now.AddDays(voucherInfo.Validity);
            VoucherItemInfo item        = new VoucherItemInfo();

            System.Collections.Generic.IList <VoucherItemInfo> list  = new System.Collections.Generic.List <VoucherItemInfo>();
            System.Collections.Generic.IList <Member>          list2 = new System.Collections.Generic.List <Member>();
            if (this.rdoName.Checked)
            {
                if (!string.IsNullOrEmpty(this.txtMemberNames.Text.Trim()))
                {
                    System.Collections.Generic.IList <string> list3 = new System.Collections.Generic.List <string>();
                    string   text  = this.txtMemberNames.Text.Trim().Replace("\r\n", "\n");
                    string[] array = text.Replace("\n", "*").Split(new char[]
                    {
                        '*'
                    });
                    for (int i = 0; i < array.Length; i++)
                    {
                        list3.Add(array[i]);
                    }
                    list2 = PromoteHelper.GetMemdersByNames(list3);
                }
                string claimCode = string.Empty;
                string password  = string.Empty;
                foreach (Member current in list2)
                {
                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                    password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    item      = new VoucherItemInfo(this.voucherId, claimCode, password, new int?(current.UserId), current.Username, current.Email, System.DateTime.Now, deadline);
                    list.Add(item);
                }
                if (list.Count <= 0)
                {
                    this.ShowMsg("你输入的会员名中没有一个正确的,请输入正确的会员名", false);
                    return;
                }
                VoucherHelper.SendClaimCodes(list);
                this.txtMemberNames.Text = string.Empty;
                this.ShowMsg(string.Format("此次发送操作已成功,现金券发送数量:{0}", list.Count), true);
            }
            if (this.rdoRank.Checked)
            {
                StringBuilder strcondition = new StringBuilder();
                strcondition.Append("1=1");
                if (this.rankList.SelectedValue > 0)
                {
                    strcondition.AppendFormat(" and GradeId={0} ", this.rankList.SelectedValue);
                }

                if (this.registerFromDate.SelectedDate.HasValue && this.registerToDate.SelectedDate.HasValue)
                {
                    strcondition.AppendFormat(" and CreateDate>='{0}' and CreateDate<='{1}' ", this.registerFromDate.SelectedDate.Value, this.registerToDate.SelectedDate.Value);
                }

                if (this.ddlReggion.GetSelectedRegionId().HasValue)
                {
                    strcondition.AppendFormat(" and TopRegionId={0} ", this.ddlReggion.GetSelectedRegionId().Value);
                }


                list2 = PromoteHelper.GetMembersByCondition(strcondition.ToString());
                string claimCode2 = string.Empty;
                string password2  = string.Empty;
                foreach (Member current2 in list2)
                {
                    claimCode2 = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    claimCode2 = Sign(claimCode2, "UTF-8").Substring(8, 16);
                    password2  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    item       = new VoucherItemInfo(this.voucherId, claimCode2, password2, new int?(current2.UserId), current2.Username, current2.Email, System.DateTime.Now, deadline);
                    list.Add(item);
                }
                if (list.Count <= 0)
                {
                    this.ShowMsg("您选择的条件下面没有符合条件的会员", false);
                    return;
                }
                VoucherHelper.SendClaimCodes(list);
                this.txtMemberNames.Text = string.Empty;
                this.ShowMsg(string.Format("此次发送操作已成功,现金券发送数量:{0}", list.Count), true);
            }
        }