using System; using System.Data; 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; using System.Data.SqlClient; using System.Text.RegularExpressions; using WebApp.Components; using System.Text; using basic; using System.IO; public partial class Download : System.Web.UI.Page { public MyClass mc = new MyClass(); public int intClassID; public string strParentColumnName = null; public string strParentColumnSubName = null; public string strColumnName = null; public string strColumnSubName = null; public string strPath = null; int intRowCount;//用来记录总记录数 public BasicPage bp = new BasicPage(); public SystemTools systemtools = new SystemTools(); public string yangban; protected void Page_Load(object sender, EventArgs e) { intClassID = basic.Tools.RequestClass.GetQueryInt("ClassID", 0); page = basic.Tools.RequestClass.GetQueryInt("page", 1); //调用类 Common common = new Common(); #region 显示栏目名称 //显示栏目名称 ClientColumnName clientcolumnname = new ClientColumnName(); clientcolumnname = common.showColumnName(intClassID); strColumnName = clientcolumnname.ColumnName; strColumnSubName = clientcolumnname.ColumnSubName; #endregion #region 显示父级栏目名称 //显示父级栏目名称 ClientParentColumnName clientparentcolumnname = new ClientParentColumnName(); clientparentcolumnname = common.showParentColumnName(intClassID); strParentColumnName = clientparentcolumnname.ParentColumnName; strParentColumnSubName = clientparentcolumnname.ParentColumnSubName; #endregion //读取整站SEO的设置信息 ClientSEO clientseo = common.showSEO(); this.Title = strColumnName + "-" + mc.ShowWebsiteKeyById(1, "CompanyName"); description.Attributes["content"] = clientseo.WebDescription; keywords.Attributes["content"] = strColumnName + "," + mc.ShowWebsiteKeyById(1, "CompanyName"); //读取某个栏目的SEO设置信息 ClientColumnSEO clientcolumnseo = common.showColumnSEO(intClassID); if (clientcolumnseo.ColumnTitle.Length > 0) { this.Title = clientcolumnseo.ColumnTitle; } if (clientcolumnseo.ColumnDescription.Length > 0) { description.Attributes["content"] = clientcolumnseo.ColumnDescription; } if (clientcolumnseo.ColumnKeywords.Length > 0) { keywords.Attributes["content"] = clientcolumnseo.ColumnKeywords; } if (!Page.IsPostBack) { strsql = ComSQL(intClassID); orderby = "Paixu desc,Istop desc,CONVERT(varchar(100),Putdate,23) desc,id desc"; RptBind(strsql, orderby); } DownLoadZidingyi.Visible = false; DownLoadMoban.Visible = false; yangban = mc.ShowColumnKeyById(intClassID, "Sample"); if (yangban == "" || yangban == "99") { DownLoadZidingyi.Visible = true; } else { DownLoadMoban.Visible = true; GetMobanhtml(); } } #region 分页 绑定数据 public string strsql, orderby; public DataSet dsNews = new DataSet(); public int intNews; public int intTotalCount = 1; public int intUnm = 0;//共多少条记录 public int page = 1;//第几页 public int Num;//前多少页 public int pageNum = 10;//每页的页数 private void RptBind(string _strWhere, string _orderby) { Num = (page - 1) * pageNum; showpageNum();//总数 intTotalCount = ShowintTotalCount(intUnm, pageNum); StringBuilder strSql1 = new StringBuilder(); strSql1.Append("select top " + pageNum + " id,title,url,putdate,Istop,fujian from News "); strSql1.Append(" where "); strSql1.Append(_strWhere); strSql1.Append(" and Id not in "); strSql1.Append(" ( "); strSql1.Append(" select top " + Num + " id from News "); strSql1.Append(" where "); strSql1.Append(_strWhere); strSql1.Append(" order by "); strSql1.Append(_orderby); strSql1.Append(" ) "); strSql1.Append(" order by "); strSql1.Append(_orderby); dsNews = bp.SelectDataBase("News", strSql1.ToString()); intNews = dsNews.Tables[0].Rows.Count; this.DataList2.DataSource = dsNews; this.DataList2.DataBind(); } //总条数 protected void showpageNum() { SqlDataReader myread = bp.getRead("select count(id) as CountId from News where " + strsql); if (myread.Read()) { intUnm = Convert.ToInt32(myread["CountId"].ToString()); } myread.Close(); } //计算一共多少页 public int ShowintTotalCount(int Total, int PageSize) { if (Total % PageSize == 0) { return Total / PageSize; } else { return Total / PageSize + 1; } } //sql组合 public string ComSQL(int classid) { StringBuilder strSql = new StringBuilder(); strSql.Append(" Id >0 and StaticPage<>2"); if (classid > 0) strSql.Append(" and ClassId=" + classid); return strSql.ToString(); } #endregion protected string ChangeGif(string data) { DateTime t1 = DateTime.Now; DateTime t2 = Convert.ToDateTime(data); TimeSpan ts = t1 - t2; int d = ts.Days; string strGif = null; if (d <= 2) { strGif = ""; } return strGif; } public string CheckUrl(string url, string id) { if (!string.IsNullOrEmpty(url) && url.Contains("http")) { return url + "\" target=\"_blank"; } return "Check/Doc.aspx?ID=" + id; } public string PrintFileVersionInfo(string path) { string asd = "0.00kb"; if (path != "upload/fujian.jpg") { string path1 = System.Web.HttpContext.Current.Server.MapPath(path); if (!Directory.Exists(path1)) { long ss = new FileInfo(path1).Length; asd = Math.Round((double.Parse(ss.ToString()) / 1024), 2).ToString("0.00") + "kb"; } else { asd = "0.00MB"; } } return asd; } public string strhtml = ""; public void GetMobanhtml() { if (yangban == "1") { strhtml += "
"; strhtml += ""; strhtml += "
"; } else if (yangban == "2") { strhtml += "
"; strhtml += ""; strhtml += "
"; } } }