protected void btnSend_Click(object sender, EventArgs e) { pnlMessage.Visible = true; try { if (!RadCaptcha1.IsValid) { msgBox.Text = "کد امنیتی اشتباه است"; msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; return; } SitesDataContext dc = new SitesDataContext(); string Title = txtTitle.Text; string Description = txtDescription.Text; string SenderEmail = txtEmail.Text; string SenderName = txtSenderName.Text; string CatID = hfCatID.Value; string Url = txtUrl.Text.Replace("http://", ""); if (CatID == "") { lblMessage.Text = "لطفا گروه سایت را انتخاب کنید"; return; } AllSites PreSite = dc.AllSites.SingleOrDefault(p => p.Url.Equals(Url)); if (PreSite != null) { lblMessage.Text = "این سایت قبلا وارد شده است"; return; } AllSites NewSite = new AllSites(); NewSite.SiteName = Title; NewSite.Description = Description; NewSite.Cat = Convert.ToInt32(CatID); NewSite.ID = GenNewID(); NewSite.Active = 0; NewSite.VisitCount = 0; NewSite.Rating = 0; NewSite.ViewerCount = 0; NewSite.SumAll = 0; NewSite.SenderName = SenderName; NewSite.SenderEmail = SenderEmail; NewSite.Url = Url; dc.AllSites.InsertOnSubmit(NewSite); dc.SubmitChanges(); lblMessage.Text = "درخواست شما برای افزودن سایت جدید ثبت شد. پس از تایید مدیر سایت ، لینک درخواستی شما ظاهر میشود."; btnSend.Visible = false; } catch { lblMessage.Text = "خطا در ثبت سایت"; } }
protected void HandleDataList(object source, DataListCommandEventArgs e) { if (e.CommandName == "ShowSubCats") { LinkButton btnCat = (LinkButton)e.Item.FindControl("btnCat"); string CatID = Convert.ToString(btnCat.Attributes["CatID"]); SitesDataContext dc = new SitesDataContext(); dlSiteCats.DataSource = dc.SiteCatNames.Where(p => p.Parent.Equals(CatID)); dlSiteCats.DataBind(); hfCatID.Value = CatID; btnTopCat.Visible = true; lblSelGroupLabel.Visible = true; lblSelectedGroup.Text = dc.SiteCatNames.SingleOrDefault(p => p.ID.Equals(CatID)).Name; } }
protected void HandleRepeater(object source, RepeaterCommandEventArgs e) { LinkButton btnEditLink = (LinkButton)e.Item.FindControl("btnEditLink"); string SiteID = Convert.ToString(btnEditLink.Attributes["SiteID"]); SitesDataContext dc = new SitesDataContext(); AllSites CurSite = dc.AllSites.SingleOrDefault(p => p.ID.Equals(SiteID)); if (CurSite != null) { txtTitle.Text = CurSite.SiteName; txtDescription.Text = CurSite.Description; pnlEditLink.CssClass = "EditLinkArea"; //string JSCommand = "pageScroll();"; //ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), "AdjustScript", JSCommand, true); hfSiteID.Value = SiteID; } }
protected void Page_Load(object sender, EventArgs e) { return; SitesDataContext dc = new SitesDataContext(); int SkipCount = 0; int PageNo = 1; int PageCount; string CatID = Request["CatID"]; strPageNo = Request["PageNo"]; string ConcatUrl = "&CatID=" + CatID; try { PageNo = Convert.ToInt32(strPageNo); } catch { } if (PageNo == 0) { PageNo = 1; } SkipCount = 20 * (PageNo - 1); if (!Page.IsPostBack) { txtKeyword.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; "); IQueryable <SiteCatNames> ItemList; if (CatID == null || CatID == "" || CatID == "0") { ItemList = dc.SiteCatNames.Where(p => p.Parent.Equals(0)); btnTopCat.Visible = false; } else { ItemList = dc.SiteCatNames.Where(p => p.Parent.Equals(CatID)); btnTopCat.Visible = true; } dlSiteCats.DataSource = ItemList; dlSiteCats.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { return; string SiteID = Request["SiteID"]; if (SiteID != null) { SitesDataContext dc = new SitesDataContext(); AllSites CurSite = dc.AllSites.SingleOrDefault(p => p.ID.Equals(SiteID)); if (CurSite != null) { CurSite.VisitCount++; dc.SubmitChanges(); Response.Redirect("http://" + CurSite.Url); } } }
protected void btnTopCat_Click(object sender, EventArgs e) { string CatID = hfCatID.Value; SitesDataContext dc = new SitesDataContext(); SiteCatNames CurParentCat = dc.SiteCatNames.SingleOrDefault(p => p.ID.Equals(CatID)); if (CurParentCat != null) { dlSiteCats.DataSource = dc.SiteCatNames.Where(p => p.Parent.Equals(CurParentCat.Parent)); dlSiteCats.DataBind(); hfCatID.Value = CurParentCat.Parent.ToString(); if (CurParentCat.Parent.ToString() == "0") { btnTopCat.Visible = false; lblSelGroupLabel.Visible = false; } else { btnTopCat.Visible = true; lblSelGroupLabel.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { return; if (!Page.IsPostBack) { SitesDataContext dc = new SitesDataContext(); int SkipCount = 0; int PageNo = 1; int PageCount; strPageNo = Request["PageNo"]; Keyword = Request["Keyword"]; string ConcatUrl = "&Keyword=" + Keyword; PageNo = Convert.ToInt32(strPageNo); if (PageNo == 0) { PageNo = 1; } SkipCount = 20 * (PageNo - 1); txtKeyword.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; "); dlSites.DataSource = dc.SiteCatNames.Where(p => p.Parent.Equals(0)); dlSites.DataBind(); if (Keyword != null && Keyword != "") { IQueryable <AllSites> ItemList; int PageSize = 20; rptItems.DataSource = dc.AllSites.Where(p => p.Active.Equals(1) && (p.SiteName.Contains(Keyword) || p.Description.Contains(Keyword) || p.Url.Contains(Keyword))).OrderBy(p => p.ViewerCount).Skip(SkipCount).Take(PageSize); rptItems.DataBind(); int ResultCount = dc.AllSites.Where(p => p.Active.Equals(1) && (p.SiteName.Contains(Keyword) || p.Description.Contains(Keyword) || p.Url.Contains(Keyword))).Count(); PageCount = ResultCount / PageSize; if (ResultCount % PageSize > 0) { PageCount++; } pgrToolbar.PageNo = PageNo; pgrToolbar.PageCount = PageCount; pgrToolbar.ConcatUrl = ConcatUrl; pgrToolbar.PageBind(); if (ResultCount > 0) { lblHeader.Text = " جستجو در سایتهای ایرانی "; Page.Title = " سایتهای ایرانی::نتایج جستجو برای " + Keyword + " صفحه " + Tools.ConvertToUnicode(PageNo); string Message = ""; if (ResultCount >= 500) { Message = " بیش از " + Tools.ConvertToUnicode(ResultCount) + " نتیجه برای <b>" + Keyword + "</b> پیدا شد"; } else { Message = Tools.ConvertToUnicode(ResultCount) + " نتیجه برای <b>" + Keyword + "</b> پیدا شد"; } msgText.Text = Message; msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.OK; } } else { msgText.Text = "کلمه جستجو خالی است"; msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; } } }
protected void Page_Load(object sender, EventArgs e) { try { return; SitesDataContext dc = new SitesDataContext(); int SkipCount = 0; int PageNo = 1; int PageCount; string CatID = Request["CatID"]; strPageNo = Request["PageNo"]; string ConcatUrl = "&CatID=" + CatID; try { PageNo = Convert.ToInt32(strPageNo); } catch { } if (PageNo == 0) { PageNo = 1; } SkipCount = 20 * (PageNo - 1); if (!Page.IsPostBack) { txtKeyword.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; "); IQueryable <SiteCatNames> ItemList; if (CatID == null || CatID == "") { ItemList = dc.SiteCatNames.Where(p => p.Parent.Equals(0)); } else { ItemList = dc.SiteCatNames.Where(p => p.Parent.Equals(CatID)); } dlSites.DataSource = ItemList; dlSites.DataBind(); if (dlSites.Items.Count == 0) { lblNoSubCat.Visible = true; } if (CatID != null) { int PageSize = 20; rptItems.DataSource = dc.AllSites.Where(p => p.Cat.Equals(CatID) && p.Active.Equals(1)).OrderBy(p => p.ViewerCount).Skip(SkipCount).Take(PageSize); rptItems.DataBind(); int ResultCount = dc.AllSites.Where(p => p.Cat.Equals(CatID) && p.Active.Equals(1)).Count(); PageCount = ResultCount / PageSize; if (ResultCount % PageSize > 0) { PageCount++; } pgrToolbar.PageNo = PageNo; pgrToolbar.PageCount = PageCount; pgrToolbar.ConcatUrl = ConcatUrl; pgrToolbar.PageBind(); string CatName = dc.SiteCatNames.SingleOrDefault(p => p.ID.Equals(CatID)).Name; if (rptItems.Items.Count > 0) { lblHeader.Text = " فهرست سایتهای گروه " + CatName; Page.Title = " سایتهای ایرانی :: فهرست سایتهای گروه " + CatName + " صفحه " + Tools.ConvertToUnicode(PageNo); } } else { hplNav.Visible = false; } } } catch (Exception err) { string MailBody = "Page: " + Request.FilePath + " Exception: " + err.Message; Tools tools = new Tools(); bool SendResult = tools.SendEmail(MailBody, "پارست ::Error ", "*****@*****.**", "", "", ""); } }