Example #1
0
 /// <summary>
 /// 准备团购模型
 /// </summary>
 /// <param name="dr">Datareader</param>
 /// <param name="groupBuyList">团购的数据列表</param>
 public static void PrepareGroupBuyModel(OleDbDataReader dr, List <GroupBuyInfo> groupBuyList)
 {
     while (dr.Read())
     {
         GroupBuyInfo groupBuy = new GroupBuyInfo();
         groupBuy.ID          = dr.GetInt32(0);
         groupBuy.Name        = dr[1].ToString();
         groupBuy.Photo       = dr[2].ToString();
         groupBuy.Description = dr[3].ToString();
         groupBuy.ProductID   = dr.GetInt32(4);
         groupBuy.StartDate   = dr.GetDateTime(5);
         groupBuy.EndDate     = dr.GetDateTime(6);
         groupBuy.Price       = dr.GetDecimal(7);
         groupBuy.MinCount    = dr.GetInt32(8);
         groupBuy.MaxCount    = dr.GetInt32(9);
         groupBuy.EachNumber  = dr.GetInt32(10);
         groupBuyList.Add(groupBuy);
     }
 }
Example #2
0
 /// <summary>
 /// 页面加载方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         int id = RequestHelper.GetQueryString <int>("ID");
         userID = Cookies.User.GetUserID(true);
         decimal moneyLeft = UserBLL.ReadUserMore(userID).MoneyLeft;
         if (userID == 0)
         {
             ScriptHelper.Alert("请先登录", "/User/Login.aspx?RedirectUrl=/Plugins/Activity/GroupBuy/GroupBuyAdd.aspx?ID=" + id.ToString());
         }
         groupBuy = GroupBuyBLL.ReadGroupBuy(id);
         if (moneyLeft < groupBuy.Price)
         {
             ScriptHelper.Alert("您账户余额不够该团购活动商品价格,请先充值", "/User/UserRecharge.aspx");
         }
         if (UserGroupBuyBLL.ReadUserGroupBuyByUser(id, userID).ID > 0)
         {
             ScriptHelper.Alert("您已经参加该活动了,请不要重复参加");
         }
         if (groupBuy.StartDate > DateTime.Now)
         {
             ScriptHelper.Alert("该团购活动未开始,不能购买");
         }
         if (groupBuy.EndDate < DateTime.Now)
         {
             ScriptHelper.Alert("该团购活动已经结束,不能购买");
         }
         buyCount            = UserGroupBuyBLL.ReadUserGroupBuyCount(id);
         product             = ProductBLL.ReadProduct(groupBuy.ProductID);
         RegionID.DataSource = RegionBLL.ReadRegionUnlimitClass();
         UserInfo user = UserBLL.ReadUser(userID);
         Consignee.Text   = user.UserName;
         Tel.Text         = user.Tel;
         Mobile.Text      = user.Mobile;
         Address.Text     = user.Address;
         RegionID.ClassID = user.RegionID;
         Head.Title       = "确认商品团购";
     }
 }
Example #3
0
 /// <summary>
 /// 页面加载方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         int groupBuyID = RequestHelper.GetQueryString <int>("ID");
         if (groupBuyID != 0)
         {
             CheckAdminPower("ReadGroupBuy", PowerCheckType.Single);
             GroupBuyInfo groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID);
             Name.Text         = groupBuy.Name;
             Photo.Text        = groupBuy.Photo;
             Description.Value = groupBuy.Description;
             PrdouctID.Items.Add(new ListItem(ProductBLL.ReadProduct(groupBuy.ProductID).Name, groupBuy.ProductID.ToString()));
             StartDate.Text  = groupBuy.StartDate.ToString("yyyy-MM-dd");
             EndDate.Text    = groupBuy.EndDate.ToString("yyyy-MM-dd");
             Price.Text      = groupBuy.Price.ToString();
             MinCount.Text   = groupBuy.MinCount.ToString();
             MaxCount.Text   = groupBuy.MaxCount.ToString();
             EachNumber.Text = groupBuy.EachNumber.ToString();
         }
     }
 }
Example #4
0
        /// <summary>
        /// 读取一条团购数据
        /// </summary>
        /// <param name="id">团购的主键值</param>
        /// <returns>团购数据模型</returns>
        public static GroupBuyInfo ReadGroupBuy(int id)
        {
            string       sql      = "SELECT [ID],[Name],[Photo],[Description],[ProductID],[StartDate],[EndDate],[Price],[MinCount],[MaxCount],[EachNumber] FROM " + GroupBuyAccessHelper.TablePrefix + "GroupBuy WHERE [ID]=" + id.ToString();
            GroupBuyInfo groupBuy = new GroupBuyInfo();

            using (OleDbDataReader dr = GroupBuyAccessHelper.ExecuteReader(sql))
            {
                if (dr.Read())
                {
                    groupBuy.ID          = dr.GetInt32(0);
                    groupBuy.Name        = dr[1].ToString();
                    groupBuy.Photo       = dr[2].ToString();
                    groupBuy.Description = dr[3].ToString();
                    groupBuy.ProductID   = dr.GetInt32(4);
                    groupBuy.StartDate   = dr.GetDateTime(5);
                    groupBuy.EndDate     = dr.GetDateTime(6);
                    groupBuy.Price       = dr.GetDecimal(7);
                    groupBuy.MinCount    = dr.GetInt32(8);
                    groupBuy.MaxCount    = dr.GetInt32(9);
                    groupBuy.EachNumber  = dr.GetInt32(10);
                }
            }
            return(groupBuy);
        }
Example #5
0
        /// <summary>
        /// 全部生成订单按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CreateOrderButton_Click(object sender, EventArgs e)
        {
            int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID");

            groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID);
            ProductInfo             product          = ProductBLL.ReadProduct(groupBuy.ProductID);
            List <UserGroupBuyInfo> userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID);

            foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList)
            {
                if (userGroupBuy.OrderID == 0)
                {
                    decimal totalPrice = groupBuy.Price * userGroupBuy.BuyCount;
                    //添加订单
                    OrderInfo order = new OrderInfo();
                    order.OrderNumber         = ShopCommon.CreateOrderNumber();
                    order.IsActivity          = (int)BoolType.True;
                    order.OrderStatus         = (int)OrderStatus.WaitCheck;
                    order.OrderNote           = "团购活动:" + groupBuy.Name;
                    order.ProductMoney        = totalPrice;
                    order.Balance             = totalPrice;
                    order.FavorableMoney      = 0;
                    order.OtherMoney          = 0;
                    order.CouponMoney         = 0;
                    order.Consignee           = userGroupBuy.Consignee;
                    order.RegionID            = userGroupBuy.RegionID;
                    order.Address             = userGroupBuy.Address;
                    order.ZipCode             = userGroupBuy.ZipCode;
                    order.Tel                 = userGroupBuy.Tel;
                    order.Email               = userGroupBuy.Email;
                    order.Mobile              = userGroupBuy.Mobile;
                    order.ShippingID          = 0;
                    order.ShippingDate        = RequestHelper.DateNow;
                    order.ShippingNumber      = string.Empty;
                    order.ShippingMoney       = 0;
                    order.PayKey              = string.Empty;
                    order.PayName             = string.Empty;
                    order.PayDate             = userGroupBuy.Date;;
                    order.IsRefund            = (int)BoolType.False;
                    order.FavorableActivityID = 0;
                    order.GiftID              = 0;
                    order.InvoiceTitle        = string.Empty;
                    order.InvoiceContent      = string.Empty;
                    order.UserMessage         = string.Empty;
                    order.AddDate             = RequestHelper.DateNow;
                    order.IP       = userGroupBuy.IP;
                    order.UserID   = userGroupBuy.UserID;
                    order.UserName = userGroupBuy.UserName;
                    int orderID = OrderBLL.AddOrder(order);
                    //添加订单详细
                    OrderDetailInfo orderDetail = new OrderDetailInfo();
                    orderDetail.OrderID       = orderID;
                    orderDetail.ProductID     = product.ID;
                    orderDetail.ProductName   = product.Name;
                    orderDetail.ProductWeight = product.Weight;
                    orderDetail.SendPoint     = 0;
                    orderDetail.ProductPrice  = groupBuy.Price;
                    orderDetail.BuyCount      = userGroupBuy.BuyCount;
                    orderDetail.FatherID      = 0;
                    orderDetail.RandNumber    = string.Empty;
                    orderDetail.GiftPackID    = 0;
                    OrderDetailBLL.AddOrderDetail(orderDetail);
                    //更新订单 ID
                    UserGroupBuyBLL.UpdateUserGroupBuy(userGroupBuy.ID, orderID);
                    //更改产品库存订单数量
                    ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
                }
            }
            ScriptHelper.Alert("处理成功", RequestHelper.RawUrl);
        }