⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.cs

📁 尚都shangdu新闻后台管理程序,可做各种网站新闻发布
💻 CS
字号:
using System;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Data;
using System.Runtime;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// functions 的摘要说明
/// </summary>
public class functions
{
	public functions()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}


    public string gettag(string PageStr)
    {
        string TempStr;
        int PageLen;
        string tem;
        int CurrentTag, StartTag, EndTag;
        string[] ParameterArray;

        CurrentTag = 0;
        StartTag = 0;
        PageLen = PageStr.Length;

        CurrentTag = PageStr.IndexOf("{$(");
        if (CurrentTag > -1)
        {
            StartTag = CurrentTag;
            EndTag = PageStr.IndexOf(")$}", StartTag);
            TempStr = PageStr.Substring(StartTag + 3, EndTag - StartTag - 3 );

            ParameterArray = TempStr.Split(',');

            tem = news_list(ParameterArray);

            PageStr = PageStr.Substring(0, StartTag) + tem +PageStr.Substring(EndTag + 3);
        }
        return PageStr;
    }

    static public string Left(string str, int L)
    {
        string tmpStr;
        tmpStr = str;
        if (str.Length > L)
        {

            tmpStr = str.Substring(0, L) + "...";
        }
        return tmpStr;
    }


    public string news_list(string[] p)
    {
        try
        {
            string templage = "<table>";
            if (p[3].ToString() == "news")
            {
                SqlConnection con = db.CreateConnection();
                con.Open();
                string strsql;
                string color;
                strsql = "select top " + p[0].ToString() + " title,bh,color,url from news where bigclassname='" + p[1].ToString() + "' order by bh desc";
                SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
                DataSet ds = new DataSet();
                ad.Fill(ds, "aa");
                
                string place;
                for (int i = 0; i < Convert.ToInt16(p[0]); i++)
                {
                    if (ds.Tables["aa"].Rows[i]["color"].ToString() == "" || ds.Tables["aa"].Rows[i]["color"].ToString() == "无" || ds.Tables["aa"].Rows[i]["color"].ToString() == "black")
                    {
                        color = "#333333";
                    }
                    else
                    {
                        color = ds.Tables["aa"].Rows[i]["color"].ToString();
                    }
                    if (ds.Tables["aa"].Rows[i]["url"].ToString() != "")
                    {
                        place = ds.Tables["aa"].Rows[i]["url"].ToString();
                    }
                    else
                    {
                        place = "/articls/" + p[1].ToString() + "/" + ds.Tables["aa"].Rows[i]["bh"].ToString() + ".aspx";
                    }
                    templage = templage + "<tr><td><a href=\"" + place + "\" target=\"_blank\"><span style=\"color:"+color+"\">" + Left(ds.Tables["aa"].Rows[i]["title"].ToString(), Convert.ToInt16(p[2])) + "</span></a></td></tr>";
                }
                templage = templage + "</table>";
                
            }

            if (p[3].ToString() == "shops")
            {
                SqlConnection con = db.CreateConnection();
                con.Open();
                string strsql;
                strsql = "select top " + p[0].ToString() + " shop_name,bh from shops where bigclassname='" + p[1].ToString() + "' order by bh desc";
                SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
                DataSet ds = new DataSet();
                ad.Fill(ds, "aa");
                string place;
                for (int i = 0; i < Convert.ToInt16(p[0]); i++)
                {
                    place = "/shops/" + p[1].ToString() + "/" + ds.Tables["aa"].Rows[i]["bh"].ToString() + ".aspx";
                    templage = templage + "<tr><td><a href=\"" + place + "\" target=\"_blank\">" + Left(ds.Tables["aa"].Rows[i]["shop_name"].ToString(), Convert.ToInt16(p[2])) + "</a></td></tr>";
                }
                templage = templage + "</table>";
               
            }

            if (p[3].ToString() == "downloads")
            {
                SqlConnection con = db.CreateConnection();
                con.Open();
                string strsql;
                strsql = "select top " + p[0].ToString() + " name,bh from downloads where bigclassname='" + p[1].ToString() + "' order by bh desc";
                SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
                DataSet ds = new DataSet();
                ad.Fill(ds, "aa");
                string place;
                for (int i = 0; i < Convert.ToInt16(p[0]); i++)
                {
                    place = "/downloads/" + p[1].ToString() + "/" + ds.Tables["aa"].Rows[i]["bh"].ToString() + ".aspx";
                    templage = templage + "<tr><td><a href=\"" + place + "\" target=\"_blank\">" + Left(ds.Tables["aa"].Rows[i]["name"].ToString(), Convert.ToInt16(p[2])) + "</a></td></tr>";
                }
                templage = templage + "</table>";
                
            }

            if (p[3].ToString() == "mynew")
            {
                SqlConnection con = db.CreateConnection();
                con.Open();
                string strsql;
                strsql = "select top " + p[0].ToString() + " title,bh,color,bigclassname from news  order by bh desc";
                SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
                DataSet ds = new DataSet();
                ad.Fill(ds, "aa");
                string place;
                for (int i = 0; i < Convert.ToInt16(p[0]); i++)
                {
                    place = "/articls/" + ds.Tables["aa"].Rows[i]["bigclassname"].ToString() + "/" + ds.Tables["aa"].Rows[i]["bh"].ToString() + ".aspx";
                    templage = templage + "<tr><td><a href=\"" + place + "\" target=\"_blank\"><span style=\"color:#333333\">" + Left(ds.Tables["aa"].Rows[i]["title"].ToString(), Convert.ToInt16(p[2])) + "</span></a></td></tr>";
                }
                templage = templage + "</table>";
                
            }
            return templage;
        }
        catch
        {
            string templage;
            templage = "template error";
            return templage;
        }
       
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -