Пример #1
0
        public void OrderCheckout()
        {
            SqlTransaction trans = null;

            try
            {
                trans = SqlHelper.BeginTransaction(Config.ConnectionString);
                this.OrderStatusIDE = OrderStatusE.Submitted;
                this.Save(trans);

                UserVoucher UserVoucher = new UserVoucher(this.Cxt, 0);
                UserVoucher.UserID  = this.UserID;
                UserVoucher.OrderID = this.OrderID;
                UserVoucher.Save(UserVoucher, trans);

                SqlHelper.CommitTransaction(trans);

                OrderDetail OrderDetail = OrderDetail.GetOrderDetail(this.Cxt, this.OrderID);
                this.OrderDetail = OrderDetail;
                this.UserVoucher = UserVoucher;
                MailVerifyResult mvr = EmailTemplate.Send(this.Cxt, EmailTemplateE.FiniVoucher, this);

                if (mvr == MailVerifyResult.Ok)
                {
                }
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);

                throw ex;
            }
        }
Пример #2
0
 public void Save(UserVoucher UserVoucher, SqlTransaction trans)
 {
     UserVoucher.ExpiryDate       = DateTime.Now.AddYears(+1);
     UserVoucher.BuyDate          = DateTime.Now;
     UserVoucher.VoucherNo        = Guid.NewGuid().ToString();
     UserVoucher.VoucherStatusIDE = UserVoucher.VoucherStatusE.Buy;
     UserVoucher.Save(trans);
 }
Пример #3
0
        public static UserVoucher GetUserVoucher(Cxt cxt, string voucherNo)
        {
            UserVoucher userVoucher = null;
            DataTable   dt          = BaseCollection.ExecuteSql(InfiChess.UserVoucher, "SELECT * FROM UserVoucher where VoucherNo = @p1", voucherNo);

            if (dt.Rows.Count > 0)
            {
                userVoucher = new UserVoucher(cxt, dt.Rows[0]);
            }
            return(userVoucher);
        }
Пример #4
0
        public static UserVoucher CheckoutAccount(Cxt cxt, string voucherNo)
        {
            SqlTransaction trans       = null;
            UserVoucher    UserVoucher = null;

            try
            {
                UserVoucher = UserVoucher.GetUserVoucher(cxt, voucherNo);

                if (UserVoucher != null)
                {
                    User User = new User(cxt, UserVoucher.UserID);

                    OrderDetail OrderDetail = new OrderDetail(cxt, UserVoucher.OrderID);

                    trans = SqlHelper.BeginTransaction(Config.ConnectionString);

                    if (UserVoucher.VoucherStatusIDE != VoucherStatusE.Used)
                    {
                        UserVoucher.ActivationDate   = DateTime.Now;
                        UserVoucher.VoucherStatusIDE = VoucherStatusE.Used;
                        UserVoucher.Save(trans);


                        User.Fini += OrderDetail.Quantity;
                        User.UpdateFini(trans, User.Fini, User.UserID);


                        SqlHelper.CommitTransaction(trans);
                        UserVoucher.isUsed = false;
                    }
                    else
                    {
                        UserVoucher.isUsed = true;
                    }
                }
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);

                throw ex;
            }
            return(UserVoucher);
        }