Exemple #1
0
        public void InitializeCategory(int PageNo, int GroupNo, bool bindingPagingIsRequired)
        {
            List <CategoryClass> category = new List <CategoryClass>();
            int totalRows = 0;
            int PageSize  = 10;

            int.TryParse(ConfigurationManager.AppSettings["PageSize"], out PageSize);

            if (Pages != "")
            {
                category             = CategoryClass.Categories(Search, Pages, PageNo, PageSize, out totalRows);
                litSearchResult.Text = "(" + totalRows + ") Games Available in <b style=\"color:LimeGreen;\">\"" + Pages + "\"</b>";
                if (PageNowClick)
                {
                    lbNext.CommandArgument     = "1";
                    lbPrevious.CommandArgument = "1";
                    PageNowClick = false;
                }
            }
            else if (Search != "")
            {
                category             = CategoryClass.Categories(Search, Pages, PageNo, PageSize, out totalRows);
                litSearchResult.Text = "(" + totalRows + ") Games Found for <b style=\"color:Red;\">\"" + Search + "\"</b>";
            }
            else
            {
                category             = CategoryClass.Categories(Search, Pages, PageNo, PageSize, out totalRows);
                litSearchResult.Text = "";
            }
            //Binding Paging
            if (bindingPagingIsRequired)
            {
                BindPaging(totalRows, GroupNo);
                foreach (RepeaterItem cc in rptrPaging.Controls)
                {
                    HtmlControl lisControl = (HtmlControl)cc.FindControl("li_paging");
                    lisControl.Attributes["class"] = "page-item active";
                    break;
                }
            }
            rptrCategory.DataSource = category.ToList();
            rptrCategory.DataBind();
        }
Exemple #2
0
        //Related Games
        protected void rptrCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CategoryClass category      = (CategoryClass)e.Item.DataItem;
            ImageButton   categoryImage = ((ImageButton)e.Item.FindControl("ImgSmallImage"));

            if (category.Small_Image != null)
            {
                categoryImage.ImageUrl = "data:Image/jpg;base64," + Convert.ToBase64String(category.Small_Image);
            }
            categoryImage.PostBackUrl = "~/Description.aspx?Game_ID=" + category.Game_ID;
            LinkButton lbGameHeading = ((LinkButton)e.Item.FindControl("lbGameName"));

            lbGameHeading.Text        = category.Game_Full_Name;
            lbGameHeading.PostBackUrl = "~/Description.aspx?Game_ID=" + category.Game_ID;
            ((Literal)e.Item.FindControl("litUploadDate")).Text     = CalculatedDuration(category.Upload_Date);
            ((Literal)e.Item.FindControl("litPrimaryComment")).Text = category.Primary_Comment;
            Repeater rptr = ((Repeater)e.Item.FindControl("rptrType"));

            rptr.DataSource = category.Game_Type.Split(",".ToCharArray().First());
            rptr.DataBind();
        }
 public static List<CategoryClass> Categories(string Search, string Page, int PageNo, int PageSize, out int TotalRows)
 {
   int totolrows = 0;
   List<CategoryClass> cats = new List<CategoryClass>();
   string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
   using (SqlConnection con = new SqlConnection(cs))
   {
     SqlCommand cmd = new SqlCommand("Sp_Vw_Category", con);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@Search", Search);
     cmd.Parameters.AddWithValue("@Page", Page);
     cmd.Parameters.AddWithValue("@PageNo", PageNo);
     cmd.Parameters.AddWithValue("@PageSize", PageSize);
     SqlDataAdapter sda = new SqlDataAdapter(cmd);
     DataSet ds = new DataSet();
     sda.Fill(ds);
     con.Open();
     SqlDataReader rdr = cmd.ExecuteReader();
     while (rdr.Read())
     {
       CategoryClass cc = new CategoryClass()
       {
         Game_ID = Convert.ToInt32(rdr["Game_ID"]),
         Game_Full_Name = rdr["Game_Full_Name"].ToString(),
         Game_Short_Name = rdr["Game_Short_Name"].ToString(),
         Upload_Date = Convert.ToDateTime(rdr["Upload_Date"]),
         Game_Type = rdr["Game_Type"].ToString(),
         Primary_Comment = rdr["Primary_Comment"].ToString(),
       };
       if(rdr["Small_Image"].ToString().Length > 0)
       {
         cc.Small_Image = (byte[])rdr["Small_Image"];
       }
       cats.Add(cc);
     }
     totolrows = (int)ds.Tables[1].Rows[0].ItemArray[0];
   }
   TotalRows = totolrows;
   return cats;
 }