public async void InsertBooking()
        {
            Voucher voucher = new Voucher();

            voucher.VoucherDate = System.DateTime.Now;
            ICollection <VoucherInfo> lstVoucherInfo = new List <VoucherInfo>();

            CurrentAmount.VoucherId = voucher.Id;
            lstVoucherInfo.Add(CurrentAmount);

            VoucherInfo voucherInfoCash = new VoucherInfo();

            voucherInfoCash.VoucherId = voucher.Id;
            voucherInfoCash.Amount    = CurrentAmount.Amount;
            voucherInfoCash.IsCredit  = false;

            lstVoucherInfo.Add(voucherInfoCash);
            //InsertBooking ib = new InsertBooking();
            //ib.CashAmount = CurrentAmount;
            //ib.EnquiryId = CurrentEnquiry.Id;
            //Voucher v = new Voucher();
            //v.VoucherDate = System.DateTime.Now;
            //ib.Voucher = v;

            CurrentEnquiry.Voucher              = voucher;
            CurrentEnquiry.VoucherId            = voucher.Id;
            CurrentEnquiry.Voucher.VoucherInfos = lstVoucherInfo;
            await _repository.Insert(CurrentEnquiry);
        }
Exemple #2
0
        private void ProcessorUseVoucherByCode(System.Web.HttpContext context)
        {
            decimal     orderAmount = decimal.Parse(context.Request["CartTotal"]);
            string      claimCode   = context.Request["VoucherCode"];
            string      Password    = context.Request["VoucherPassword"];
            VoucherInfo voucherInfo = ShoppingProcessor.UseVoucher(orderAmount, claimCode, Password);

            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            if (voucherInfo != null)
            {
                stringBuilder.Append("{");
                stringBuilder.Append("\"Status\":\"OK\",");
                stringBuilder.AppendFormat("\"VoucherName\":\"{0}\",", voucherInfo.Name);
                stringBuilder.AppendFormat("\"DiscountValue\":\"{0}\"", Globals.FormatMoney(voucherInfo.DiscountValue));
                stringBuilder.Append("}");
            }
            else
            {
                stringBuilder.Append("{");
                stringBuilder.Append("\"Status\":\"ERROR\"");
                stringBuilder.Append("}");
            }
            context.Response.ContentType = "application/json";
            context.Response.Write(stringBuilder);
        }
 void Init()
 {
     InsertCommand.IsEnabled = true;
     CurrentCustomer         = new Customer();
     CurrentCustomer.Contact = new Contact();
     CurrentAmount           = new VoucherInfo();
     Amounts = new ObservableCollection <VoucherInfo>();
 }
Exemple #4
0
        public static VoucherInfo SelectVoucher(int countryId, int voucherId)
        {
            CheckConnectionStringThrow();

            #region SQL

            const string SQL = @"select v_number, v_date_voucher, br_id, br_name, br_add_1, br_add_2, br_add_3, br_add_4, br_add_5, v_final_country, ho_vat_number, 
                                    br_DEMAT_export_number, v_title, v_firstname, v_lastname, v_passport_no, v_refund_str, v_refund_in_refund_currency                                 
                                 from Voucher (nolock)
                                 inner join Branch (nolock) on br_id = v_br_id and br_iso_id = v_iso_id
                                 inner join HeadOffice (nolock) on ho_id = br_ho_id and ho_iso_id = br_iso_id
                                 where v_iso_id = @iso and v_number = @number";

            #endregion //SQL

            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();

                using (var comm = new SqlCommand(SQL, conn))
                {
                    comm.Parameters.AddWithValue("@iso", countryId);
                    comm.Parameters.AddWithValue("@number", voucherId);

                    using (var reader = comm.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        if (!reader.Read())
                        {
                            throw new ApplicationException(
                                      string.Format("Cannot find voucher IsoId: {0} VoucherId: {1}", countryId, voucherId));
                        }

                        var result = new VoucherInfo
                        {
                            v_number                    = reader.Get <int>("v_number"),
                            v_date_voucher              = reader.Get <DateTime>("v_date_voucher"),
                            br_id                       = reader.Get <int>("br_id"),
                            br_name                     = reader.GetString("br_name"),
                            br_add_1                    = reader.GetString("br_add_1"),
                            br_add_2                    = reader.GetString("br_add_2"),
                            br_add_3                    = reader.GetString("br_add_3"),
                            br_add_4                    = reader.GetString("br_add_4"),
                            br_add_5                    = reader.GetString("br_add_5"),
                            br_DEMAT_export_number      = reader.GetNull <long>("br_DEMAT_export_number").GetValueOrDefault(),
                            ho_vat_number               = reader.GetString("ho_vat_number"),
                            v_final_country             = reader.GetString("v_final_country"),
                            v_title                     = reader.GetString("v_title"),
                            v_firstname                 = reader.GetString("v_firstname"),
                            v_lastname                  = reader.GetString("v_lastname"),
                            v_passport_no               = reader.GetString("v_passport_no"),
                            v_refund_str                = reader.GetString("v_refund_str"),
                            v_refund_in_refund_currency = reader.GetNull <decimal>("v_refund_in_refund_currency"),
                        };
                        return(result);
                    }
                }
            }
        }
Exemple #5
0
        private void ReceiveVouchers(System.Web.HttpContext context)
        {
            string text = "";

            if (context.Request["voucherid"] != null)
            {
                text = context.Request["voucherid"].ToString();
            }
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.message = "你还未登陆,请登陆";
                return;
            }
            int voucherid = 0;

            if (!int.TryParse(text, out voucherid))
            {
                this.message = "该链接无效";
                return;
            }

            VoucherInfo voucherInfo = VoucherHelper.GetVoucher(voucherid);

            if (voucherInfo == null || voucherInfo.SendType != 3 || voucherInfo.StartTime.Date > DateTime.Now.Date || voucherInfo.ClosingTime < DateTime.Now.Date)
            {
                this.message = "该链接无效";
                return;
            }

            int count = VoucherHelper.GetCountVoucherItem(voucherid, member.UserId);

            if (count == 0)
            {
                string claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                string          password        = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                DateTime        deadline        = DateTime.Now.AddDays(voucherInfo.Validity);
                VoucherItemInfo voucherItemInfo = new VoucherItemInfo(voucherid, claimCode, password, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, deadline);

                IList <VoucherItemInfo> voucherItemList = new List <VoucherItemInfo>();
                voucherItemList.Add(voucherItemInfo);
                if (VoucherHelper.SendClaimCodes(voucherItemList))
                {
                    this.message = "你已成功领取该优惠券";
                }

                else
                {
                    this.message = "操作失败";
                }
            }
            else
            {
                this.message = "您已经领过该优惠券";
            }
        }
Exemple #6
0
        VoucherInfo CreateVoucherInfo(ApiPocketVoucherViewModel inVoucherInfo)
        {
            var result = new VoucherInfo();

            result.DiscountCode          = inVoucherInfo.DiscountCode;
            result.NumberOfUsesRemaining = inVoucherInfo.NumberOfUsesRemaining;
            result.VoucherName           = inVoucherInfo.VoucherName;
            return(result);
        }
Exemple #7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!int.TryParse(this.Page.Request.QueryString["voucherId"], out this.voucherId))
            {
                base.GotoResourceNotFound();
                return;
            }
            this.btnAddVouchers.Click += new System.EventHandler(this.btnAddVouchers_Click);

            //如果是编辑现金券
            if ((!this.Page.IsPostBack))
            {
                if (this.voucherId > 0)
                {
                    VoucherInfo voucher = VoucherHelper.GetVoucher(this.voucherId);
                    if (voucher == null)
                    {
                        base.GotoResourceNotFound();
                        return;
                    }
                    if (voucher.ClosingTime.CompareTo(System.DateTime.Now) < 0)
                    {
                        this.ShowMsg("该现金券已经结束!", false);
                        return;
                    }
                    Globals.EntityCoding(voucher, false);
                    //this.lblEditCouponId.Text = coupon.CouponId.ToString();
                    this.btnAddVouchers.Text = "修改";
                    this.txtVoucherName.Text = voucher.Name;
                    this.txtValidity.Text    = voucher.Validity.ToString();
                    if (voucher.Amount.HasValue)
                    {
                        this.txtAmount.Text = string.Format("{0:F2}", voucher.Amount);
                    }
                    this.txtDiscountValue.Text          = voucher.DiscountValue.ToString("F2");
                    this.calendarEndDate.SelectedDate   = new System.DateTime?(voucher.ClosingTime);
                    this.calendarStartDate.SelectedDate = new System.DateTime?(voucher.StartTime);

                    switch (voucher.SendType)
                    {
                    case 0: rdoManually.Checked = true; break;

                    case 1: rdoOverMoney.Checked = true; this.txtOverMoney.Text = voucher.SendTypeItem; break;

                    case 2: rdoRegist.Checked = true; break;

                    case 3: rdoLq.Checked = true; break;
                    }
                }

                else
                {
                    rdoManually.Checked = true;
                }
            }
        }
        public string CloseSubscription(string id, double amount)
        {
            try
            {
                ChitSubscriber chitSubscriber = FindBySubscriptionId(id);
                Voucher        voucher        = new Voucher
                {
                    VoucherDate = new DateTime(),
                };

                var bookId = bookService.FindByName(ChitDueService.VOUCHER_TYPE_NAME).Id;

                VoucherInfo[] voucherInfos = new VoucherInfo[2];
                voucherInfos[0] = new VoucherInfo()
                {
                    bookId    = bookId,
                    IsCredit  = false,
                    VoucherId = voucher.Id,
                    Amount    = amount,
                };
                voucherInfos[1] = new VoucherInfo()
                {
                    bookId    = bookId,
                    IsCredit  = true,
                    VoucherId = voucher.Id,
                    Amount    = amount
                };
                voucher.VoucherTypeId = _voucherTypeService
                                        .FindByName(VoucherTypeMasterEnum.Sales.ToString()).Id;
                voucher.VoucherTypeMaster      = null;
                chitSubscriber.ClosedVoucherId = voucher.Id;
                Repository.Update(chitSubscriber);
                UnitOfWork.GetRepository <VoucherInfo>().Add(voucherInfos);
                UnitOfWork.GetRepository <Voucher>().Add(voucher);

                UnitOfWork.SaveChanges();
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
            return(null);
        }
        public EnquiryBookingViewModel(Enquiry enq)
        {
            CurrentEnquiry = enq;

            WireCommands();

            _repository = Startup.Instance.provider.GetService <IBookingService>();
            //_repository = new addon365.WebClient.Service.WebService.BookingService();
            if (enq.Voucher == null)
            {
                CurrentAmount = new VoucherInfo();
            }
            else

            {
                Mode          = ScreenOpenMode.Edit;
                CurrentAmount = enq.Voucher.VoucherInfos.Where(x => x.FieldInfo == FieldInfo.CashAmount.ToString()).Single();
            }
        }
        public void AddVoucher(VoucherInfo voucher)
        {
            if (connection.State != ConnectionState.Open)
            {
                ConnectToSQLDatabase();
            }
            cmd.CommandText = string.Format("insert Voucher(Code,Expiry,Decrease,NumberInit,NumberRemain) values(@Code,@Expiry,@Value,@NumberInit,@NumberRemain)");
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue(string.Format("@Code"), voucher.Code);
            cmd.Parameters.AddWithValue(string.Format("@Expiry"), voucher.ExpiryDate);
            cmd.Parameters.AddWithValue(string.Format("@Value"), voucher.Value);
            cmd.Parameters.AddWithValue(string.Format("@NumberInit"), voucher.NumberInit);
            cmd.Parameters.AddWithValue(string.Format("@NumberRemain"), voucher.NumberRemain);
            cmd.ExecuteNonQuery();

            /*if ( cmd.ExecuteNonQuery() != 1)
             * {
             *  MessageBox.Show("Lỗi khi thêm voucher vào database");
             * }*/
        }
        private void InitilizeForNew()
        {
            CurrentPurchase = new Purchase();
            CurrentItem     = new PurchaseItem();
            _Items          = new ObservableCollection <PurchaseItem>();

            InvoiceAmount           = new VoucherInfo();
            InvoiceAmount.FieldInfo = FieldInfo.InvoiceAmount.ToString();
            InvoiceAmount.bookId    = MasterData.PurchaseBook.Id;

            CashAmount           = new VoucherInfo();
            CashAmount.FieldInfo = FieldInfo.CashAmount.ToString();
            CashAmount.bookId    = MasterData.CashBook.Id;

            GstAmount           = new VoucherInfo();
            GstAmount.FieldInfo = FieldInfo.GstAmount.ToString();
            GstAmount.bookId    = MasterData.GstBook.Id;

            AddPropertyCommand.IsEnabled = true;
        }
        public BindingList <VoucherInfo> GetVouchers()
        {
            var Vouchers = new BindingList <VoucherInfo>();

            if (connection.State != ConnectionState.Open)
            {
                ConnectToSQLDatabase();
            }
            cmd.CommandText = string.Format("select * from Voucher");
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    VoucherInfo item = new VoucherInfo();
                    item.Code         = (string)reader["Code"];
                    item.ExpiryDate   = (DateTime)reader["Expiry"];
                    item.NumberInit   = (int)reader["NumberInit"];
                    item.NumberRemain = (int)reader["NumberRemain"];
                    item.Value        = (int)reader["Decrease"];
                    Vouchers.Add(item);
                }
            }
            return(Vouchers);
        }
Exemple #13
0
 void SummaryInfo()
 {
     summary     = cv.Info(listLocationJO);
     label1.Text = $"No. of Account Title : {summary.TotalAccountTitle}\nTotal Debit : {summary.TotalDebit:c2}\nTotal Credit : {summary.TotalCredit:c2}\nBalance : {summary.Balance:c2}\nNo. of Location J.O. : {summary.TotalLocationJO}";
 }
Exemple #14
0
        /// <summary>
        /// 添加按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddVouchers_Click(object sender, System.EventArgs e)
        {
            string  text     = string.Empty;
            string  arg_0B_0 = string.Empty;
            decimal?amount;
            decimal discountValue;

            if (!this.ValidateValues(out amount, out discountValue))
            {
                return;
            }
            if (!this.calendarStartDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择开始日期!", false);
                return;
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择结束日期!", false);
                return;
            }
            if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
            {
                this.ShowMsg("开始日期不能晚于结束日期!", false);
                return;
            }

            string strValidity = this.txtValidity.Text;

            if (!Regex.IsMatch(strValidity, @"^[1-9][0-9]*$"))
            {
                this.ShowMsg(" 有效期只能是数字,必须大于等于O!", false);
                return;
            }

            string strOverMoney = txtOverMoney.Text;

            if (this.rdoOverMoney.Checked && !Regex.IsMatch(strOverMoney, @"^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$"))
            {
                this.ShowMsg(" 满足金额必须为正数,且最多只能有两位小数", false);
                return;
            }


            VoucherInfo voucherInfo = new VoucherInfo();

            voucherInfo.Name          = this.txtVoucherName.Text;
            voucherInfo.ClosingTime   = this.calendarEndDate.SelectedDate.Value.AddDays(1).AddSeconds(-1);
            voucherInfo.StartTime     = this.calendarStartDate.SelectedDate.Value;
            voucherInfo.Amount        = amount;
            voucherInfo.DiscountValue = discountValue;

            #region 发送方式
            int    SendType     = 0;
            string stroverMoney = string.Empty;
            if (this.rdoManually.Checked)
            {
                SendType = int.Parse(this.rdoManually.Value);
            }

            else if (this.rdoOverMoney.Checked)
            {
                SendType     = int.Parse(this.rdoOverMoney.Value);
                stroverMoney = txtOverMoney.Text.ToString();
            }

            else if (this.rdoRegist.Checked)
            {
                SendType = int.Parse(this.rdoRegist.Value);
            }

            else if (this.rdoLq.Checked)
            {
                SendType = int.Parse(this.rdoLq.Value);
            }


            #endregion

            voucherInfo.SendType     = SendType;
            voucherInfo.SendTypeItem = stroverMoney;
            voucherInfo.Validity     = int.Parse(this.txtValidity.Text);

            #region 字段限制验证,通过数据注解验证的方式
            ValidationResults validationResults = Validation.Validate <VoucherInfo>(voucherInfo, new string[]
            {
                "Voucher"
            });
            if (!validationResults.IsValid)
            {
                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ValidationResult current = enumerator.Current;
                        text += Formatter.FormatErrorMessage(current.Message);
                        this.ShowMsg(text, false);
                        return;
                    }
                }
            }
            #endregion

            string empty = string.Empty;
            if (this.voucherId == 0)  //创建现金券
            {
                VoucherActionStatus voucherActionStatus = VoucherHelper.CreateVoucher(voucherInfo, 0, out empty, 1);
                if (voucherActionStatus == VoucherActionStatus.UnknowError)
                {
                    this.ShowMsg("未知错误", false);
                }
                else
                {
                    if (voucherActionStatus == VoucherActionStatus.DuplicateName)
                    {
                        this.ShowMsg("已经存在相同的现金券名称", false);
                        return;
                    }
                    if (voucherActionStatus == VoucherActionStatus.CreateClaimCodeError)
                    {
                        this.ShowMsg("生成现金券号码错误", false);
                        return;
                    }
                    this.ShowMsg("添加现金券成功", true);
                    this.RestCoupon();
                    return;
                }
            }

            else  //修改现金券
            {
                voucherInfo.VoucherId = this.voucherId;
                VoucherActionStatus voucherActionStatus = VoucherHelper.UpdateVoucher(voucherInfo);
                if (voucherActionStatus == VoucherActionStatus.Success)
                {
                    this.RestCoupon();
                    this.ShowMsg("成功修改了现金券信息", true);
                }
                else
                {
                    if (voucherActionStatus == VoucherActionStatus.DuplicateName)
                    {
                        this.ShowMsg("修改现金券信息错误,已经具有此现金券名称", false);
                        return;
                    }
                    this.ShowMsg("未知错误", false);
                    this.RestCoupon();
                    return;
                }
            }
        }
Exemple #15
0
        MemberInfo createMemberInfo(ApiMemberViewModel inMember)
        {
            var result = new MemberInfo();

            //::::::::::::::::::::::::::::::::::::
            result.UniqueId    = Convert.ToString(inMember.UniqueId);
            result.MemberType  = Convert.ToInt32(inMember.MemberType);
            result.Email       = inMember.Email;
            result.Address1    = inMember.AddressLine1;
            result.Address2    = inMember.AddressLine2;
            result.Mobile      = inMember.Mobile;
            result.PhoneNumber = inMember.Phone;
            result.City        = inMember.CityName;
            result.Country     = inMember.CountryName;
            result.DateOfBirth = inMember.Birthday;
            result.FirstName   = inMember.FirstName;
            result.LastName    = inMember.LastName;
            result.State       = inMember.StateName;
            result.Title       = inMember.Title;
            result.ZipCode     = inMember.PostalCode;
            DateTime lastModified = inMember.LastModified;

            if (inMember.MembershipProfiles != null)
            {
                var membershipProfile = inMember.MembershipProfiles.SingleOrDefault();
                if (membershipProfile != null)
                {
                    result.BirthdayBenefitDate = membershipProfile.LastBirthdayBenefitDate;
                    result.HomeSiteId          = membershipProfile.HomeSiteCode;
                    result.LastVisitDate       = membershipProfile.LastTransactionDate;
                    result.TierId                   = membershipProfile.TierLevelId.HasValue ? membershipProfile.TierLevelId.Value : 0;
                    result.YearStartDate            = membershipProfile.YearStartDate;
                    result.CardNumber               = membershipProfile.CardNumber;
                    result.MemberCardCode           = membershipProfile.CardCode;
                    result.MembershipNumber         = membershipProfile.MembershipNumber;
                    result.PointRule                = membershipProfile.PointRule;
                    result.PreviousYearPoint        = membershipProfile.PreviousYearPoint;
                    result.CurrentYearPoint         = membershipProfile.CurrentYearPoint;
                    result.AvailableBirthDayPoint   = membershipProfile.AvailableBirthDayPoint;
                    result.AvailableFirstVisitPoint = membershipProfile.AvailableFirstVisitPoint;
                    result.EarnedPoints             = membershipProfile.EarnedPoints;
                    result.LoadedPoints             = membershipProfile.LoadedPoints;
                    result.IsFirstVisitRewarded     = membershipProfile.IsFirstVisitRewarded;
                    if (membershipProfile.LastModified > lastModified)
                    {
                        lastModified = membershipProfile.LastModified;
                    }
                    result.MemberVouchers = new List <VoucherInfo>();
                    if (membershipProfile.Vouchers != null)
                    {
                        foreach (var voucher in membershipProfile.Vouchers)
                        {
                            var memberVoucher = new VoucherInfo()
                            {
                                DiscountCode          = voucher.DiscountCode,
                                VoucherName           = voucher.Name,
                                NumberOfUsesRemaining = voucher.NumberOfUsesAllowed.HasValue ? voucher.NumberOfUsesAllowed.Value : 0
                            };
                            result.MemberVouchers.Add(memberVoucher);
                        }
                    }
                }
            }
            result.LastModified = lastModified.ToLocalTime();
            result.Activated    = true;
            return(result);
        }
Exemple #16
0
 public static string GetOperatorId(this VoucherInfo i, Dictionary <int, CurrentUser> dict)
 {
     return(dict.ContainsKey(i.OperatorId) ? dict[i.OperatorId].UserName : i.OperatorId.ToString());
 }
Exemple #17
0
 private LoyaltyVoucherResponse CreateVoucherResponse(bool inSuccesful, string inMessage, string inDescription, LoyaltyResponseCode inResponseCode, VoucherInfo inVoucherInfo)
 {
     return(new LoyaltyVoucherResponse(inSuccesful, inMessage, inDescription, inResponseCode, inVoucherInfo));
 }
Exemple #18
0
 public static VoucherActionStatus UpdateVoucher(VoucherInfo voucher)
 {
     Globals.EntityCoding(voucher, true);
     return(new VoucherDao().UpdateVoucher(voucher));
 }
Exemple #19
0
        protected void btnExport_Click(object sender, System.EventArgs e)
        {
            //默认为复杂密码
            int pwdtype = 1;

            if (!string.IsNullOrEmpty(hiddenPwdtype.Value))
            {
                pwdtype = int.Parse(hiddenPwdtype.Value);
            }

            int num;

            if (!int.TryParse(this.tbvoucherNum.Text, out num))
            {
                this.ShowMsg("导出数量必须为正数", false);
                return;
            }
            if (num <= 0)
            {
                this.ShowMsg("导出数量必须为正数", false);
                return;
            }
            int voucherId;

            if (!int.TryParse(this.txtvoucherid.Value, out voucherId))
            {
                this.ShowMsg("参数错误", false);
                return;
            }
            VoucherInfo         voucher             = VoucherHelper.GetVoucher(voucherId);
            string              empty               = string.Empty;
            VoucherActionStatus voucherActionStatus = VoucherHelper.CreateVoucher(voucher, num, out empty, pwdtype);

            if (voucherActionStatus == VoucherActionStatus.UnknowError)
            {
                this.ShowMsg("未知错误", false);
                return;
            }
            if (voucherActionStatus == VoucherActionStatus.CreateClaimCodeError)
            {
                this.ShowMsg("生成现金券号码错误", false);
                return;
            }
            if (voucherActionStatus == VoucherActionStatus.CreateClaimCodeSuccess && !string.IsNullOrEmpty(empty))
            {
                System.Collections.Generic.IList <VoucherItemInfo> voucherItemInfos = VoucherHelper.GetVoucherItemInfos(empty);
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
                stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">");
                stringBuilder.AppendLine("<td>现金券号码</td>");
                stringBuilder.AppendLine("<td>现金券密码</td>");
                stringBuilder.AppendLine("<td>现金券金额</td>");
                stringBuilder.AppendLine("<td>过期时间</td>");
                stringBuilder.AppendLine("</tr>");
                foreach (VoucherItemInfo current in voucherItemInfos)
                {
                    stringBuilder.AppendLine("<tr>");
                    stringBuilder.AppendLine("<td>" + current.ClaimCode + "</td>");
                    stringBuilder.AppendLine("<td>" + current.Password + "</td>");
                    stringBuilder.AppendLine("<td>" + voucher.DiscountValue + "</td>");
                    stringBuilder.AppendLine("<td>" + current.Deadline + "</td>");
                    stringBuilder.AppendLine("</tr>");
                }
                stringBuilder.AppendLine("</table>");
                this.Page.Response.Clear();
                this.Page.Response.Buffer  = false;
                this.Page.Response.Charset = "GB2312";
                this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=VoucherInfo_" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
                this.Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                this.Page.Response.ContentType     = "application/ms-excel";
                this.Page.EnableViewState          = false;
                this.Page.Response.Write(stringBuilder.ToString());
                hiddenPwdtype.Value = "";
                this.Page.Response.End();
            }
        }
        public ChitSubriberDue Save(ChitSubscribeDomain domain)
        {
            ChitSubscriber  chitSubscriber  = null;
            ChitSubriberDue chitSubriberDue = new ChitSubriberDue()
            {
                DueNo   = GenerateDueId(),
                Voucher = new Voucher()
                {
                    VoucherDate   = DateTime.Now,
                    VoucherTypeId = voucherService.FindByName(VOUCHER_TYPE_NAME).Id,
                }
            };

            if (domain.SubscribeId == Guid.Empty)
            {
                Guid customerId = Guid.Empty;
                if (domain.CustomerId == Guid.Empty)
                {
                    var customer = new Customer()
                    {
                        Contact = new Contact()
                        {
                            FirstName    = domain.CustomerName,
                            Address      = domain.Address,
                            MobileNumber = domain.MobileNumber
                        }
                    };
                    UnitOfWork.GetRepository <Customer>().Add(customer);
                    customerId = customer.Id;
                }
                else
                {
                    customerId = domain.CustomerId;
                }
                chitSubscriber = new ChitSubscriber()
                {
                    ChitSchemeId = domain.ChitSchemeId,
                    CustomerId   = customerId,
                    JoinedDate   = DateTime.Now,
                    SubscribeId  = GenerateSubscribeId()
                };


                chitSubriberDue.ChitSubscriber = chitSubscriber;
            }
            else
            {
                chitSubriberDue.ChitSubscriberId = domain.SubscribeId;
            }

            VoucherInfo[] voucherInfos = new VoucherInfo[2];
            voucherInfos[0] = new VoucherInfo()
            {
                bookId    = bookService.FindByName(VOUCHER_TYPE_NAME).Id,
                IsCredit  = true,
                VoucherId = chitSubriberDue.Voucher.Id,
                Amount    = domain.Amount,
                FieldInfo = domain.FieldInfo
            };
            voucherInfos[1] = new VoucherInfo()
            {
                bookId    = bookService.FindByName(VOUCHER_TYPE_NAME).Id,
                IsCredit  = false,
                VoucherId = chitSubriberDue.Voucher.Id,
                Amount    = domain.Amount,
                FieldInfo = domain.FieldInfo
            };
            Repository.Add(chitSubriberDue);
            UnitOfWork.GetRepository <VoucherInfo>().Add(voucherInfos);
            UnitOfWork.SaveChanges();
            return(chitSubriberDue);
        }
Exemple #21
0
 //Voucher Response
 protected LoyaltyVoucherResponse CreateVoucherResponseNoError(VoucherInfo inVoucherInfo)
 {
     return(CreateVoucherResponse(true, "", "", LoyaltyResponseCode.Successful, inVoucherInfo));
 }
Exemple #22
0
 protected LoyaltyVoucherResponse CreateVoucherResponseError(string inMessage, string inDescription, LoyaltyResponseCode inResponseCode, VoucherInfo inVoucherInfo)
 {
     return(CreateVoucherResponse(false, inMessage, inDescription, inResponseCode, inVoucherInfo));
 }
        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);
            }
        }
Exemple #24
0
 /// <summary>
 /// 添加现金券
 /// </summary>
 /// <param name="coupon"></param>
 /// <param name="count"></param>
 /// <param name="lotNumber"></param>
 /// <returns></returns>
 public static VoucherActionStatus CreateVoucher(VoucherInfo voucher, int count, out string lotNumber, int pwdType)
 {
     Globals.EntityCoding(voucher, true);
     return(new VoucherDao().CreateVoucher(voucher, count, out lotNumber, pwdType));
 }