Exemplo n.º 1
0
        private void BindData(int pagerIndex, int pageSize = 10)
        {
            Ye_User user = (Ye_User)Session["YeUser"];

            using (var entities = new YellEatEntities())
            {
                var query =
                    from collect in entities.Ye_UserCollection
                    join shop in entities.Ye_Shop
                    on collect.ShopID equals shop.ShopID
                    join g in
                    (from order in entities.Ye_Order
                     where order.UserID == YeUser.UserID
                     group order by order.ShopID)
                    on collect.ShopID equals g.Key
                    into temp
                    from g in temp.DefaultIfEmpty()
                    where collect.IsCollecting && collect.ShopID == shop.ShopID && collect.UserID == user.UserID
                    select new
                {
                    shop.ShopID,
                    shop.ShopName,
                    shop.Clicks,
                    shop.DeliveryTime,
                    EatCount = g.Count(),
                    shop.Rank
                };
                rptShopList.DataSource = query.OrderBy(s => s.EatCount).Skip(pagerIndex * pageSize).Take(pageSize).ToArray();
                rptShopList.DataBind();
            }
        }
Exemplo n.º 2
0
        //protected void btnSendSMS_OnClick(object sender, EventArgs e)
        //{

        //}
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            var user = new Ye_User()
            {
                Address       = tbxAddress.Text.Trim(),
                UserName      = tbxName.Text.Trim(),
                Zip           = tbxZip.Text.Trim(),
                AptSuite      = tbxAptSuite.Text.Trim(),
                Mobile        = tbxPhone.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPassword.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册!
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                if (Request.Cookies["location"] == null)
                {
                    var cookie = new HttpCookie("location", user.Address);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Response.Cookies["location"].Value = user.Address;
                }
                if (Request.Cookies["username"] == null)
                {
                    var cookie = new HttpCookie("username", user.UserName);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Request.Cookies["username"].Value = user.UserName;
                }
                WebUtil.AlertAndRedirect("Register successfully", "Home.aspx");
            }
            else
            {
                WebUtil.Alert("Failed to register.");
            }
        }
Exemplo n.º 3
0
 //protected void btnSendSMS_OnClick(object sender, EventArgs e)
 //{
 //}
 protected void btnRegister_OnClick(object sender, EventArgs e)
 {
     var user = new Ye_User()
     {
         Address = tbxAddress.Text.Trim(),
         UserName = tbxName.Text.Trim(),
         Zip =  tbxZip.Text.Trim(),
         AptSuite = tbxAptSuite.Text.Trim(),
         Mobile = tbxPhone.Text.Trim(),
         Password = DESUtil.Encrypt(tbxPassword.Text.Trim()),
         Email = tbxEmail.Text.Trim(),
         FaceBookID = "",
         QQ = "",
         WxID = "",
         Status = 0,
         LastLoginTime = DateTime.Now,
         RegisterTime = DateTime.Now
     };
     if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
     {
         WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册!
         return;
     }
     if (UserBll.AddUser(user))
     {
         Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
         if (Request.Cookies["location"] == null)
         {
             var cookie = new HttpCookie("location", user.Address);
             cookie.Expires = DateTime.MaxValue;
             Response.Cookies.Add(cookie);
         }
         else
         {
             Response.Cookies["location"].Value = user.Address;
         }
         if (Request.Cookies["username"] == null)
         {
             var cookie = new HttpCookie("username", user.UserName);
             cookie.Expires = DateTime.MaxValue;
             Response.Cookies.Add(cookie);
         }
         else
         {
             Request.Cookies["username"].Value = user.UserName;
         }
         WebUtil.AlertAndRedirect("Register successfully","Home.aspx");
     }
     else
     {
         WebUtil.Alert("Failed to register.");
     }
 }
Exemplo n.º 4
0
        protected void imgBtn_OnClick(object sender, ImageClickEventArgs e)
        {
            var user = new Ye_User()
            {
                Address  = tbxAddress.Text.Trim(),
                UserName = tbxFirstName.Text.Trim() + " " + tbxLastName.Text.Trim(),
                //Zip =  tbxZip.Text.Trim(),
                //Aptsuite = tbxAptSuite.Text.Trim(),
                Mobile        = tbxMobile.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPwd1.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                Zip           = "",
                AptSuite      = "",
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("当前用户已经存在!请使用其他用户名注册!");
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                Response.Redirect("Home.aspx");
            }
            else
            {
                WebUtil.Alert("注册失败!");
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool AddUser(Ye_User user)
 {
     _entities.Ye_User.Add(user);
     return _entities.SaveChanges() > 0;
 }
Exemplo n.º 6
0
        protected void DataControl()
        {
            int userId;
            if (string.IsNullOrEmpty(Request.QueryString["UserId"]) || !int.TryParse(Request.QueryString["UserId"], out userId))
            {
                return;
            }
            using (YellEatEntities ef = new YellEatEntities())
            {

                user = ef.Ye_User.FirstOrDefault(o => o.UserID == userId);
                if (user == null)
                {
                    return;
                }
                //var query=from order in ef.Ye_Order
                //          join shop in ef.Ye_Shop on order.ShopID equals shop.ShopID
                //          join p in (
                //               from detail in ef.Ye_OrderDetail
                //               join product in ef.Ye_Product on detail.ProductID equals product.ProductID
                //              group new{detail,product} by detail.OrderID
                //              ) on order.OrderID equals
                var queryOrder = ef.Ye_Order.Where(o => o.UserID == user.UserID).Join(ef.Ye_OrderDetail, o => o.OrderID, p => p.OrderID,
                       (o, p) => new
                       {
                           ShopId = o.ShopID,
                           OrderSN = o.OrderSN,
                           OrderCreateTime = o.OrderCreateTime,
                           TotalPrice = o.TotalPrice,
                           ReceiverMobile = o.ReceiverMobile,
                           ReceiveAddress = o.ReceiveAddress,
                           UnitCouponCost = o.UnitCouponCost,
                           Tax = o.Tax,
                           OrderStatus = o.OrderStatus,
                           ProductID = p.ProductID,
                           Quantity = p.Quantity,
                           UnitCost = p.UnitCost,
                       })
                       .Join(ef.Ye_Shop, o => o.ShopId, p => p.ShopID,
                       (o, p) => new
                       {
                           ShopId = o.ShopId,
                           OrderSN = o.OrderSN,
                           OrderCreateTime = o.OrderCreateTime,
                           TotalPrice = o.TotalPrice,
                           ReceiverMobile = o.ReceiverMobile,
                           ReceiveAddress = o.ReceiveAddress,
                           UnitCouponCost = o.UnitCouponCost,
                           Tax = o.Tax,
                           OrderStatus = o.OrderStatus,
                           ProductID = o.ProductID,
                           Quantity = o.Quantity,
                           UnitCost = o.UnitCost,
                           ShopName = p.ShopName
                       });
                pagerOrder.PageSize = pageSize;
                pagerOrder.DataItemCount = ef.Ye_Order.Where(o => o.UserID == user.UserID).Count();
                repOrder.DataSource = queryOrder.OrderByDescending(o => o.OrderCreateTime).Skip(pagerOrder.PageSize * pagerOrder.CurrentPagerIndex).Take(pagerOrder.PageSize).ToList();
                repOrder.DataBind();
                pagerOrder.SetPagerControlState();

                pagerCollection.PageSize = pageSize;
                pagerCollection.DataItemCount = ef.Ye_UserCollection.Where(o => o.UserID == user.UserID).Count();
                repCollection.DataSource = ef.Ye_UserCollection.Where(o => o.UserID == user.UserID)
                    .Join(ef.Ye_Shop, o => o.ShopID, p => p.ShopID, (o, p) => new
                    {
                        ShopId = o.ShopID,
                        ShopName = p.ShopName,
                        EatCount = ef.Ye_Order.Where(q => q.UserID == o.UserID && q.ShopID == o.ShopID).Count(),
                        UserCollectionID=o.UserCollectionID
                    }).OrderByDescending(o => o.UserCollectionID).Skip(pagerCollection.PageSize * pagerCollection.CurrentPagerIndex).Take(pagerCollection.PageSize).ToList();

                //repCollection.DataSource = queryCoolection;
                repCollection.DataBind();
                pagerCollection.SetPagerControlState();

            }
        }
Exemplo n.º 7
0
        protected void DataControl()
        {
            int userId;

            if (string.IsNullOrEmpty(Request.QueryString["UserId"]) || !int.TryParse(Request.QueryString["UserId"], out userId))
            {
                return;
            }
            using (YellEatEntities ef = new YellEatEntities())
            {
                user = ef.Ye_User.FirstOrDefault(o => o.UserID == userId);
                if (user == null)
                {
                    return;
                }
                //var query=from order in ef.Ye_Order
                //          join shop in ef.Ye_Shop on order.ShopID equals shop.ShopID
                //          join p in (
                //               from detail in ef.Ye_OrderDetail
                //               join product in ef.Ye_Product on detail.ProductID equals product.ProductID
                //              group new{detail,product} by detail.OrderID
                //              ) on order.OrderID equals
                var queryOrder = ef.Ye_Order.Where(o => o.UserID == user.UserID).Join(ef.Ye_OrderDetail, o => o.OrderID, p => p.OrderID,
                                                                                      (o, p) => new
                {
                    ShopId          = o.ShopID,
                    OrderSN         = o.OrderSN,
                    OrderCreateTime = o.OrderCreateTime,
                    TotalPrice      = o.TotalPrice,
                    ReceiverMobile  = o.ReceiverMobile,
                    ReceiveAddress  = o.ReceiveAddress,
                    UnitCouponCost  = o.UnitCouponCost,
                    Tax             = o.Tax,
                    OrderStatus     = o.OrderStatus,
                    ProductID       = p.ProductID,
                    Quantity        = p.Quantity,
                    UnitCost        = p.UnitCost,
                })
                                 .Join(ef.Ye_Shop, o => o.ShopId, p => p.ShopID,
                                       (o, p) => new
                {
                    ShopId          = o.ShopId,
                    OrderSN         = o.OrderSN,
                    OrderCreateTime = o.OrderCreateTime,
                    TotalPrice      = o.TotalPrice,
                    ReceiverMobile  = o.ReceiverMobile,
                    ReceiveAddress  = o.ReceiveAddress,
                    UnitCouponCost  = o.UnitCouponCost,
                    Tax             = o.Tax,
                    OrderStatus     = o.OrderStatus,
                    ProductID       = o.ProductID,
                    Quantity        = o.Quantity,
                    UnitCost        = o.UnitCost,
                    ShopName        = p.ShopName
                });
                pagerOrder.PageSize      = pageSize;
                pagerOrder.DataItemCount = ef.Ye_Order.Where(o => o.UserID == user.UserID).Count();
                repOrder.DataSource      = queryOrder.OrderByDescending(o => o.OrderCreateTime).Skip(pagerOrder.PageSize * pagerOrder.CurrentPagerIndex).Take(pagerOrder.PageSize).ToList();
                repOrder.DataBind();
                pagerOrder.SetPagerControlState();

                pagerCollection.PageSize      = pageSize;
                pagerCollection.DataItemCount = ef.Ye_UserCollection.Where(o => o.UserID == user.UserID).Count();
                repCollection.DataSource      = ef.Ye_UserCollection.Where(o => o.UserID == user.UserID)
                                                .Join(ef.Ye_Shop, o => o.ShopID, p => p.ShopID, (o, p) => new
                {
                    ShopId           = o.ShopID,
                    ShopName         = p.ShopName,
                    EatCount         = ef.Ye_Order.Where(q => q.UserID == o.UserID && q.ShopID == o.ShopID).Count(),
                    UserCollectionID = o.UserCollectionID
                }).OrderByDescending(o => o.UserCollectionID).Skip(pagerCollection.PageSize * pagerCollection.CurrentPagerIndex).Take(pagerCollection.PageSize).ToList();

                //repCollection.DataSource = queryCoolection;
                repCollection.DataBind();
                pagerCollection.SetPagerControlState();
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool AddUser(Ye_User user)
 {
     _entities.Ye_User.Add(user);
     return(_entities.SaveChanges() > 0);
 }