public void DataBind2(DataView dvAds) { try { HttpCookie cookie = Request.Cookies["BrowserDate"]; Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); if (Session["AD1Count"] == null) Session["AD1Count"] = 0; Session["AD1DV"] = dvAds; DrawAd((int)Session["AD1Count"], dvAds); if (Session["User"] != null) { dat.CountAd(false, dvAds); } //if(Session["User"] != null) // userLit.Text = "<div id=\"userIDDiv\" style=\"display: none;\">" + Session["User"].ToString() + "</div>"; //else // userLit.Text = "<div id=\"userIDDiv\" style=\"display: none;\">No User</div>"; //XmlDataSource xmlAds = new XmlDataSource(); //xmlAds.DataFile = Server.MapPath(".") + "\\UserFiles\\categoies1.xml"; //xmlAds.DataBind(); //RadRotator1.DataSource = xmlAds; //RadRotator1.DataBind(); } catch (Exception ex) { BodyLabel.Text = ex.ToString(); } }
protected void DrawAd(int nextAdIndex, DataView dvAds) { HttpCookie cookie = Request.Cookies["BrowserDate"]; Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); DataView dvAd = dat.GetDataDV("SELECT * FROM Ads WHERE Ad_ID = " + dvAds[nextAdIndex]["Ad_ID"].ToString()); DataView dvUser = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dvAd[0]["User_ID"].ToString()); string templateID = dvAd[0]["Template"].ToString(); string w = "0"; string h = "0"; if (templateID == "1") { Template1Panel.Visible = true; Template2Panel.Visible = false; CustomerImage.AlternateText = dvAds[nextAdIndex]["Header"].ToString(); if (dvAds[nextAdIndex]["FeaturedPicture"].ToString() == "" || dvAds[nextAdIndex]["FeaturedPicture"] == null) { CustomerImage.Visible = false; TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 21); } else { CustomerImage.Visible = true; GetAdSize(out w, out h, dvUser[0]["UserName"].ToString() + "\\" + dvAds[nextAdIndex]["FeaturedPicture"].ToString(), templateID); CustomerImage.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() + "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString(); CustomerImage.Width = int.Parse(w); CustomerImage.Height = int.Parse(h); TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 10); } TitleLabel.Text = dvAds[nextAdIndex]["Header"].ToString(); if (windowT) { TitleLabel.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');"); ReadMoreLink.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');"); A1.HRef = "javascript:CloseWindow('../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad');"; } else { TitleLabel.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad"; ReadMoreLink.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad"; A1.HRef = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad"; } BodyLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["FeaturedSummary"].ToString(), 21); } else { Template1Panel.Visible = false; Template2Panel.Visible = true; Image1.AlternateText = dvAds[nextAdIndex]["Header"].ToString(); if (dvAds[nextAdIndex]["FeaturedPicture"].ToString() == "" || dvAds[nextAdIndex]["FeaturedPicture"] == null) { Image1.Visible = false; } else { GetAdSize(out w, out h, dvUser[0]["UserName"].ToString() + "\\" + dvAds[nextAdIndex]["FeaturedPicture"].ToString(), templateID); Image1.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() + "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString(); Image1.Width = int.Parse(w); Image1.Height = int.Parse(h); } if (windowT) { Image1.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');"); } else { Image1.Attributes.Add("onclick", "window.location = '" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) + "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "'"); } } if (Request.Url.AbsolutePath.ToLower() == "/group.aspx") { dat.CountGroupAds(int.Parse(dvAds[nextAdIndex]["Ad_ID"].ToString())); } else { if (Session["User"] != null) { dat.CountAd(true, dvAds); } else { dat.CountAdAnonymous(true, dvAds); } } }
protected void Timer1_Tick(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["BrowserDate"]; try { Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); if (Session["AD1Count"] == null || Session["AD1DV"] == null) dat.GetAdSet(1, false); DataView dvAds = (DataView)Session["AD1DV"]; int currentAdIndex = int.Parse(Session["AD1Count"].ToString()); if (currentAdIndex < dvAds.Count - 1) { currentAdIndex++; } else { currentAdIndex = 0; } //Draw the next ad DrawAd(currentAdIndex, dvAds); Session["AD1Count"] = currentAdIndex; //Only count the ad when user is logged in. //If user not logged in, can't charge for the ads. if (Session["User"] != null) { dat.CountAd(false, dvAds); } else { dat.CountAdAnonymous(false, dvAds); } } catch (Exception ex) { BodyLabel.Text = ex.ToString(); if (Session["testmessage"] != null) { BodyLabel.Text += Session["testmessage"].ToString(); } } }