資源簡介
幫同學(xué)做的一個(gè)小型新聞系統(tǒng),做的不見得好,但是關(guān)鍵是過了,呵呵.系統(tǒng)采用c#+sql2005,使用了一個(gè)數(shù)據(jù)庫操作類,實(shí)現(xiàn)一些基本的系統(tǒng)功能,修改下就可以使用了.
代碼片段和文件信息
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;
public?partial?class?_Default?:?System.Web.UI.Page
{
????Database?Db?=?new?Database();//引用數(shù)據(jù)庫通用操作類
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
????????string?strSQL?=?@“Select?*?from?NewView?where?Class_id=18??and?isdel=0?order?by?id?desc“;?//查詢語句
????????DataSet?Ds1?=??Db.GetDataSet(strSQL);//使用數(shù)據(jù)庫通用操作類獲取DataSet//使用數(shù)據(jù)庫通用操作類獲取DataSet
??????????PagedDataSource?Pds?=?new?PagedDataSource();//對(duì)數(shù)據(jù)源進(jìn)行分頁操作
????????Pds.DataSource?=?Ds1.Tables[0].DefaultView;
????????Pds.AllowPaging?=?true;
????????Pds.PageSize?=?8;
????????Repeater1.DataSource?=?Pds;//設(shè)置數(shù)據(jù)源
????????Repeater1.DataBind();//綁定數(shù)據(jù)源
????????Rep2();
????????Rep3();
????????Rep4();
????????Rep5();
????????R();
????}
????public?void?Rep2()
????{
????????string?strSQL2?=?@“Select?*?from?NewView?where?Class_id=13?and?isdel=0?order?by?id?desc“;
????????DataSet?Ds2?=?Db.GetDataSet(strSQL2);
??????????PagedDataSource?Pds?=?new?PagedDataSource();//對(duì)數(shù)據(jù)源進(jìn)行分頁操作
????????Pds.DataSource?=?Ds2.Tables[0].DefaultView;
????????Pds.AllowPaging?=?true;
????????Pds.PageSize?=?8;
????????Repeater2.DataSource?=?Pds;//設(shè)置數(shù)據(jù)源
????????Repeater2.DataBind();//綁定數(shù)據(jù)源
????}
????public?void?Rep3()
????{
????????string?strSQL3?=?@“Select?*?from?NewView?where?Class_id=12?and?isdel=0?order?by?id?desc“;
????????DataSet?Ds3?=?Db.GetDataSet(strSQL3);
??????????PagedDataSource?Pds?=?new?PagedDataSource();//對(duì)數(shù)據(jù)源進(jìn)行分頁操作
????????Pds.DataSource?=?Ds3.Tables[0].DefaultView;
????????Pds.AllowPaging?=?true;
????????Pds.PageSize?=?8;
????????Repeater3.DataSource?=?Pds;//設(shè)置數(shù)據(jù)源
????????Repeater3.DataBind();//綁定數(shù)據(jù)源
????}
????public?void?Rep4()
????{
????????string?strSQL4?=?@“Select?*?from?NewView?where?Class_id=11?and?isdel=0?order?by?id?desc“;
????????DataSet?Ds4?=?Db.GetDataSet(strSQL4);
??????????PagedDataSource?Pds?=?new?PagedDataSource();//對(duì)數(shù)據(jù)源進(jìn)行分頁操作
????????Pds.DataSource?=?Ds4.Tables[0].DefaultView;
????????Pds.AllowPaging?=?true;
????????Pds.PageSize?=?5;
????????Repeater4.DataSource?=?Pds;//設(shè)置數(shù)據(jù)源
????????Repeater4.DataBind();//綁定數(shù)據(jù)源
????}
????public?void?Rep5()
????{
????????string?strSQL5?=?@“Select?*?from?linkAddress?where?isdel=0?order?by?id?desc“;
????????DataSet?Ds5?=?Db.GetDataSet(strSQL5);
??????????PagedDataSource?Pds?=?new?PagedDataSource();//對(duì)數(shù)據(jù)源進(jìn)行分頁操作
????????Pds.DataSource?=?Ds5.Tables[0].DefaultView;
????????Pds.AllowPaging?=?true;
????????Pds.PageSize?=?4;
????????Repeater5.DataSource?=?Pds;//設(shè)置數(shù)據(jù)源
????????Repeater5.DataBind();//綁定數(shù)據(jù)源
????}
????public?void?R()
????{
????????string?strSQL?=?@“Select?*?from?NewView?order?by?id?desc“;
評(píng)論
共有 條評(píng)論