Example #1
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        ProductViewList viewlist;

        if (Application[AppKey] == null)
        {
            viewlist = new ProductViewList();
            Application.Add(AppKey, viewlist);
        }
        else
        {
            viewlist = (ProductViewList)Application[AppKey];
            this.BindViewGrid(viewlist.Display());
        }
    }
        protected void grdProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            Models.ProductView view = new Models.ProductView();
            view.ProductID   = grdProducts.SelectedValue.ToString();
            view.ProductName = grdProducts.SelectedRow.Cells[2].Text;
            view.CategoryID  = ddlCategory.SelectedValue.ToString();
            view.ViewCount   = 1;

            Application.Lock();
            ProductViewList viewlist = (ProductViewList)Application[APP_KEY];

            viewlist.Add(view);

            BindViewGrid(viewlist.Display());
        }
Example #3
0
        public IEnumerable <ProductViewList> GetSearchs(string key)
        {
            try
            {
                List <ProductViewList> viewLists = new List <ProductViewList>();

                var _lst = from p in DbContext.Products
                           from c in DbContext.ProductCategorys
                           from v in DbContext.Staffs
                           where p.Staff == v.ID &&
                           p.Category == c.ID &&
                           p.Status == true
                           select new
                {
                    ID       = p.ID,
                    Title    = p.Title,
                    Desc     = p.Desc,
                    Avatar   = p.Avatar,
                    Category = c.Title,
                    Price    = p.Price,
                    Staff    = v.Name,
                    Rate     = p.Rate
                };
                var _temp = _lst.ToList();
                key = key.ToNoSings(true).ToLowerCase();
                if (_lst != null && _lst.Count() > 0 && _temp.Where(x => x.Title.ToNoSings(true).ToLowerCase().Contains(key)).Count() > 0)
                {
                    foreach (var item in _temp.Where(x => x.Title.ToNoSings(true).ToLowerCase().Contains(key)))
                    {
                        ProductViewList viewList = new ProductViewList();
                        viewList.Avatar   = item.Avatar;
                        viewList.Category = item.Category;
                        viewList.Desc     = item.Desc;
                        viewList.ID       = item.ID;
                        viewList.Price    = item.Price;
                        viewList.Title    = item.Title;
                        viewList.Staff    = item.Staff;
                        viewList.Rate     = item.Rate;
                        viewLists.Add(viewList);
                    }
                }
                return(viewLists);
            }
            catch (System.Exception)
            {
                return(null);
            }
        }
Example #4
0
 public IEnumerable <ProductViewList> GetAlls()
 {
     try
     {
         List <ProductViewList> viewLists = new List <ProductViewList>();
         var _lst = from p in DbContext.Products
                    from c in DbContext.ProductCategorys
                    from v in DbContext.Staffs
                    where p.Staff == v.ID &&
                    p.Category == c.ID &&
                    p.Status == true
                    select new
         {
             ID       = p.ID,
             Title    = p.Title,
             Desc     = p.Desc,
             Avatar   = p.Avatar,
             Category = c.Title,
             Price    = p.Price,
             Staff    = v.Name,
             Rate     = p.Rate
         };
         if (_lst != null && _lst.Count() > 0)
         {
             foreach (var item in _lst)
             {
                 ProductViewList viewList = new ProductViewList();
                 viewList.Avatar   = item.Avatar;
                 viewList.Category = item.Category;
                 viewList.Desc     = item.Desc;
                 viewList.ID       = item.ID;
                 viewList.Price    = item.Price;
                 viewList.Title    = item.Title;
                 viewList.Staff    = item.Staff;
                 viewList.Rate     = item.Rate;
                 viewLists.Add(viewList);
             }
         }
         return(viewLists);
     }
     catch (System.Exception)
     {
         return(null);
     }
 }
Example #5
0
 public ProductViewList GetDetail(long id)
 {
     try
     {
         var _item = (from p in DbContext.Products
                      from c in DbContext.ProductCategorys
                      from v in DbContext.Staffs
                      where p.Staff == v.ID &&
                      p.Category == c.ID &&
                      p.ID == id &&
                      p.Status == true
                      select new
         {
             ID = p.ID,
             Title = p.Title,
             Desc = p.Desc,
             Avatar = p.Avatar,
             Category = c.Title,
             Price = p.Price,
             Staff = v.Name,
             StaffID = v.ID,
             Content = p.Content
         }).FirstOrDefault();
         if (_item != null && _item.ID != 0)
         {
             ProductViewList viewList = new ProductViewList();
             viewList.Avatar   = _item.Avatar;
             viewList.Category = _item.Category;
             viewList.Desc     = _item.Desc;
             viewList.ID       = _item.ID;
             viewList.Price    = _item.Price;
             viewList.Title    = _item.Title;
             viewList.Staff    = _item.Staff;
             viewList.StaffID  = _item.StaffID;
             viewList.Content  = _item.Content;
             return(viewList);
         }
         return(null);
     }
     catch (Exception)
     {
         return(null);
     }
 }