Esempio n. 1
0
        /// <summary>
        /// 读取一条用户团购数据
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <returns>用户团购用户团购数据模型</returns>
        public static UserGroupBuyInfo ReadUserGroupBuyByUser(int groupBuyID, int userID)
        {
            string           sql          = "SELECT [ID],[GroupBuyID],[Date],[IP],[BuyCount],[OrderID],[UserID],[UserName],[Consignee],[RegionID],[Address],[ZipCode],[Tel],[Email],[Mobile] FROM " + GroupBuyAccessHelper.TablePrefix + "UserGroupBuy WHERE [GroupBuyID]=" + groupBuyID.ToString() + " AND [UserID]=" + userID.ToString();
            UserGroupBuyInfo userGroupBuy = new UserGroupBuyInfo();

            using (OleDbDataReader dr = GroupBuyAccessHelper.ExecuteReader(sql))
            {
                if (dr.Read())
                {
                    userGroupBuy.ID         = dr.GetInt32(0);
                    userGroupBuy.GroupBuyID = dr.GetInt32(1);
                    userGroupBuy.Date       = dr.GetDateTime(2);
                    userGroupBuy.IP         = dr[3].ToString();
                    userGroupBuy.BuyCount   = dr.GetInt32(4);
                    userGroupBuy.OrderID    = dr.GetInt32(5);
                    userGroupBuy.UserID     = dr.GetInt32(6);
                    userGroupBuy.UserName   = dr[7].ToString();
                    userGroupBuy.Consignee  = dr[8].ToString();
                    userGroupBuy.RegionID   = dr[9].ToString();
                    userGroupBuy.Address    = dr[10].ToString();
                    userGroupBuy.ZipCode    = dr[11].ToString();
                    userGroupBuy.Tel        = dr[12].ToString();
                    userGroupBuy.Email      = dr[13].ToString();
                    userGroupBuy.Mobile     = dr[14].ToString();
                }
            }
            return(userGroupBuy);
        }
Esempio n. 2
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //读取用户信息
            userID = Cookies.User.GetUserID(true);
            string userName  = Cookies.User.GetUserName(false);
            string userEmail = CookiesHelper.ReadCookieValue("UserEmail");
            //添加团购记录
            int id = RequestHelper.GetQueryString <int>("ID");

            groupBuy = GroupBuyBLL.ReadGroupBuy(id);
            UserGroupBuyInfo userGroupBuy = new UserGroupBuyInfo();

            userGroupBuy.GroupBuyID = id;
            userGroupBuy.Date       = RequestHelper.DateNow;
            userGroupBuy.IP         = ClientHelper.IP;
            userGroupBuy.BuyCount   = RequestHelper.GetForm <int>("BuyCount");
            userGroupBuy.OrderID    = 0;
            userGroupBuy.UserID     = userID;
            userGroupBuy.UserName   = userName;
            userGroupBuy.Consignee  = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));
            userGroupBuy.RegionID   = RegionID.ClassID;
            userGroupBuy.Address    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));
            userGroupBuy.ZipCode    = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));
            userGroupBuy.Tel        = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            userGroupBuy.Email      = userEmail;
            userGroupBuy.Mobile     = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));
            UserGroupBuyBLL.AddUserGroupBuy(userGroupBuy);
            UserAccountRecordBLL.AddUserAccountRecord(-groupBuy.Price * userGroupBuy.BuyCount, 0, "参加团购活动:" + groupBuy.Name, userID, userName);
            ScriptHelper.Alert("购买成功!", "GroupBuyDetail.aspx?ID=" + userGroupBuy.GroupBuyID);
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条用户团购数据
        /// </summary>
        /// <param name="userGroupBuy">用户团购模型变量</param>
        public static int AddUserGroupBuy(UserGroupBuyInfo userGroupBuy)
        {
            string sql = "INSERT INTO " + GroupBuyAccessHelper.TablePrefix + "UserGroupBuy([GroupBuyID],[Date],[IP],[BuyCount],[OrderID],[UserID],[UserName],[Consignee],[RegionID],[Address],[ZipCode],[Tel],[Email],[Mobile]) VALUES (@groupBuyID,@date,@iP,@buyCount,@orderID,@userID,@userName,@consignee,@regionID,@address,@zipCode,@tel,@email,@mobile)";

            OleDbParameter[] parameters =
            {
                new OleDbParameter("@groupBuyID", OleDbType.Integer),
                new OleDbParameter("@date",       OleDbType.VarWChar),
                new OleDbParameter("@iP",         OleDbType.VarWChar),
                new OleDbParameter("@buyCount",   OleDbType.Integer),
                new OleDbParameter("@orderID",    OleDbType.Integer),
                new OleDbParameter("@userID",     OleDbType.Integer),
                new OleDbParameter("@userName",   OleDbType.VarWChar),
                new OleDbParameter("@consignee",  OleDbType.VarWChar),
                new OleDbParameter("@regionID",   OleDbType.VarWChar),
                new OleDbParameter("@address",    OleDbType.VarWChar),
                new OleDbParameter("@zipCode",    OleDbType.VarWChar),
                new OleDbParameter("@tel",        OleDbType.VarWChar),
                new OleDbParameter("@email",      OleDbType.VarWChar),
                new OleDbParameter("@mobile",     OleDbType.VarWChar)
            };
            parameters[0].Value  = userGroupBuy.GroupBuyID;
            parameters[1].Value  = userGroupBuy.Date;
            parameters[2].Value  = userGroupBuy.IP;
            parameters[3].Value  = userGroupBuy.BuyCount;
            parameters[4].Value  = userGroupBuy.OrderID;
            parameters[5].Value  = userGroupBuy.UserID;
            parameters[6].Value  = userGroupBuy.UserName;
            parameters[7].Value  = userGroupBuy.Consignee;
            parameters[8].Value  = userGroupBuy.RegionID;
            parameters[9].Value  = userGroupBuy.Address;
            parameters[10].Value = userGroupBuy.ZipCode;
            parameters[11].Value = userGroupBuy.Tel;
            parameters[12].Value = userGroupBuy.Email;
            parameters[13].Value = userGroupBuy.Mobile;
            GroupBuyAccessHelper.ExecuteNonQuery(sql, parameters);
            Object id = GroupBuyAccessHelper.ExecuteScalar("SELECT MAX([ID]) FROM " + GroupBuyAccessHelper.TablePrefix + "UserGroupBuy");

            return(Convert.ToInt32(id));
        }
Esempio n. 4
0
 /// <summary>
 /// 准备用户团购模型
 /// </summary>
 /// <param name="dr">Datareader</param>
 /// <param name="userGroupBuyList">用户团购的数据列表</param>
 public static void PrepareUserGroupBuyModel(OleDbDataReader dr, List <UserGroupBuyInfo> userGroupBuyList)
 {
     while (dr.Read())
     {
         UserGroupBuyInfo userGroupBuy = new UserGroupBuyInfo();
         userGroupBuy.ID         = dr.GetInt32(0);
         userGroupBuy.GroupBuyID = dr.GetInt32(1);
         userGroupBuy.Date       = dr.GetDateTime(2);
         userGroupBuy.IP         = dr[3].ToString();
         userGroupBuy.BuyCount   = dr.GetInt32(4);
         userGroupBuy.OrderID    = dr.GetInt32(5);
         userGroupBuy.UserID     = dr.GetInt32(6);
         userGroupBuy.UserName   = dr[7].ToString();
         userGroupBuy.Consignee  = dr[8].ToString();
         userGroupBuy.RegionID   = dr[9].ToString();
         userGroupBuy.Address    = dr[10].ToString();
         userGroupBuy.ZipCode    = dr[11].ToString();
         userGroupBuy.Tel        = dr[12].ToString();
         userGroupBuy.Email      = dr[13].ToString();
         userGroupBuy.Mobile     = dr[14].ToString();
         userGroupBuyList.Add(userGroupBuy);
     }
 }