Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            anm_Utility ut = new anm_Utility();
            if (Request.QueryString["category"] != null)
            {
                h2archive.Text = h2archive.Text + " " + ut.GetCategory(Request.QueryString["category"]);
            }
            else if (Request.QueryString["news"] != null)
            {
                category       = ut.GetCategoryFromNews(Request.QueryString["news"]);
                h2archive.Text = h2archive.Text + " " + ut.GetCategory(category);
            }
            string menu         = "";
            int    nart         = 0;
            int    InitialYear  = Convert.ToInt32(ut.GetSetting("Year"));
            int    InitialMonth = Convert.ToInt32(ut.GetSetting("Month"));
            string viewart      = ut.GetSetting("ViewNarticles");
            if (ut.GetSetting("ArchiveMenu") == "True")
            {
                PnlArchiveMenu.Visible = true;
                if (ut.GetSetting("ArchiveType") == "2")
                {
                    ddlarchive.Visible = true;
                    ddlarchive.Items.Add(new ListItem(GetGlobalResourceObject("language", "SelectMonth").ToString()));

                    if (Request.QueryString["category"] != null || Request.QueryString["news"] != null)
                    {
                        int cat = 0;
                        if (Request.QueryString["category"] != null)
                        {
                            cat = Convert.ToInt32(Request.QueryString["category"].ToString());
                        }
                        else
                        {
                            cat = Convert.ToInt32(ut.GetCategoryFromNews(Request.QueryString["news"].ToString()));
                        }
                        int currentYear = Convert.ToInt32(DateTime.Now.Year.ToString());
                        int currentMonth = Convert.ToInt32(DateTime.Now.Month.ToString());
                        int i, j;
                        if (currentYear == InitialYear)
                        {
                            for (i = currentMonth; i >= InitialMonth; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear, cat);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear + "-" + cat));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear + "-" + cat));
                                }
                            }
                        }
                        else
                        {
                            for (i = currentMonth; i > 0; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear, cat);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear + "-" + cat));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear + "-" + cat));
                                }
                            }
                        }
                        for (j = currentYear - 1; j >= InitialYear; j--)
                        {
                            if (j == InitialYear)
                            {
                                for (i = 12; i >= InitialMonth; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j, cat);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j + "-" + cat));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j + "-" + cat));
                                    }
                                }
                            }
                            else
                            {
                                for (i = 12; i > 0; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j, cat);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j + "-" + cat));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j + "-" + cat));
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        int currentYear = Convert.ToInt32(DateTime.Now.Year.ToString());
                        int currentMonth = Convert.ToInt32(DateTime.Now.Month.ToString());
                        int i, j;
                        if (currentYear == InitialYear)
                        {
                            for (i = currentMonth; i >= InitialMonth; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear));
                                }
                            }
                        }
                        else
                        {
                            for (i = currentMonth; i > 0; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear));
                                }
                            }
                        }
                        for (j = currentYear - 1; j >= InitialYear; j--)
                        {
                            if (j == InitialYear)
                            {
                                for (i = 12; i >= InitialMonth; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j));
                                    }
                                }
                            }
                            else
                            {
                                for (i = 12; i > 0; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Response.Write(menu);
        }
    }
Ejemplo n.º 2
0
    protected string ViewSideMenu()
    {
        anm_Utility ut       = new anm_Utility();
        string      category = "";

        if (Request.QueryString["news"] != null)
        {
            category = ut.GetCategoryFromNews(Request.QueryString["news"]);
        }
        if (Request.QueryString["category"] != null)
        {
            category = Request.QueryString["category"];
        }
        if (category == "")
        {
            string menu = "";
            if (ut.GetSetting("SideMenu") == "True")
            {
                menu = ut.GetSideMenu();
            }
            return(menu);
        }
        else
        {
            string   apath      = anm_Utility.GetWebAppRoot();
            string   idfather   = ut.GetIdFather(category);
            String[] categories = new String[20];
            string   res        = "";
            int      i          = 1;
            categories[0] = category;
            while (!idfather.Equals("0"))
            {
                categories[i] = idfather;
                idfather      = ut.GetIdFather(idfather);
                i++;
            }
            for (int j = 0; categories[j] != null; j++)
            {
                string cat = ut.GetCategory(categories[j]);
                string url = ut.GetCategoryUrl(categories[j]);
                if (url == "" || url == null)
                {
                    res = "<li><a href='" + apath + "/subscribe/" + categories[j] + ".aspx'><img src='" + apath + "/images/rssicon.gif' alt='rss' style='border: none;' /></a> <strong><a href='" + apath + "/category" + categories[j] + ".aspx'>" + cat + "</a></strong></li>" + res;
                }
                else
                {
                    res = "<li>&nbsp;&nbsp;&nbsp; <strong><a href='" + url + "'>" + cat + "</a></strong></li>" + res;
                }
            }
            string        linksons     = "";
            string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
            SqlConnection myConnection = new SqlConnection(strConn);
            SqlCommand    myCommand    = new SqlCommand("anm_getSonCategories", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@idcategory", SqlDbType.NVarChar).Value = category;
            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            while (reader.Read())
            {
                string url = reader["url"].ToString();
                string idc = reader["idcategory"].ToString();
                string cat = reader["category"].ToString();
                if (url == "" || url == null)
                {
                    linksons += "<li class='menulinksons'><a href='" + apath + "/subscribe/" + idc + ".aspx'><img src='" + apath + "/images/rssicon.gif' alt='rss' style='border: none;' /></a> <strong><a href='" + apath + "/category" + idc + ".aspx'>" + cat + "</a></strong></li>";
                }
                else
                {
                    linksons += "<li class='menulinksons'>&nbsp;&nbsp;&nbsp; <strong><a href='" + url + "'>" + cat + "</a></strong></li>";
                }
            }
            myConnection.Close();
            if (linksons != "")
            {
                //res += "<ul class='menulinksons'>" + linksons + "</ul>";
                res += linksons;
            }

            if (ut.GetSetting("SideMenu") == "True")
            {
                return("<h2>" + HttpContext.GetGlobalResourceObject("language", "Menu") + "</h2><div class='sp'><ul>" + res + "</ul></div>");
            }
            else
            {
                return("");
            }
        }
    }