//the UI layer
Using System;
using System.Collections.Generic;
using System.Linq;
Using System. The Web;
Using System. Web. UI.
Using System. Web. UI. WebControls;
Using System. The Data;
Using System. The Data. SqlClient.
The using Entity;
Using the Business;
The namespace orange star design
{
Public partial class Display_Goods: System. Web. UI. Page
{
The static DataTable DT.
Protected void Page_Load (object sender, EventArgs e)
{
If (Session (" users ")==null)
{
Response. Write (" & lt; script> Alert (" please log in first!) ; . The parent window. The location. Herf='Login. Aspx' & lt;/script>" );
return;
}
//else
//{
//Entity. Users u=(Entity. Users) Session (" Users ");
//u.U serName=Business. AdminBusiness. GetUserNamebyID (u). The ToString ();
//this. Label1. Text="welcome administrator" + u.U serName + "come back!" ;
//}
if (! IsPostBack)
{
DT=Business. AdminBusiness. SelectViewGoods ();
View state [" pageindex "]=0;
Enclosing LoadDataList (DT);
}
}
Private PagedDataSource DataListPaging DataTable (dt)
{
DataView dv=dt. DefaultView;
PagedDataSource PDS=new PagedDataSource ();
PDS. The DataSource=dv;
PDS. AllowPaging=true;
PDS. PageSize=2;
PDS. CurrentPageIndex=the Convert. ToInt32 (view state [r]. "pageindex" ToString ());
View state (" pagecount "]=PDS. Pagecount;
If (PDS. IsFirstPage)
{
This. Lbtn_pre. Enabled=false;
}
The else
{
This. Lbtn_pre. Enabled=true;
}
If (PDS. IsLastPage)
{
This. Lbtn_next. Enabled=false;
}
The else
{
This. Lbtn_next. Enabled=true;
}
Return a PDS.
}
Private void LoadDataList DataTable (dt)
{
Enclosing dl_goods. The DataSource=this. DataListPaging (dt);
This. Dl_goods. DataBind ();
}
Protected void lbtn_Click (object sender, EventArgs e)
{
LinkButton LBTN=sender as LinkButton;
String cmda=lbtn.Com mandArgument;
Int pageindex=the Convert. ToInt32 (view state [r]. "pageindex" ToString ());
If (cmda=="pre")
{
Pageindex=pageindex - 1;
}
The else
{
Pageindex=pageindex + 1;
}
View state [" pageindex "]=pageindex;
Enclosing LoadDataList (DT);
This. Tbx_pageindex. Text=(pageindex + 1). The ToString ();
}
Protected void btn_jump_Click (object sender, EventArgs e)
{
Int pagenum=the Convert. ToInt32 (this) tbx_pageindex) Text. The Trim ());
Int pageindex pagenum=1;
Int pagecount=the Convert. ToInt32 (view state (" pagecount "]);
If (pageindex & lt; 0)
{
Response. Write (" & lt; script> Alert (' pages must be greater than zero! Will return to home page! ') & lt;/script>" );
Pageindex=0;
}
If (pageindex & gt;=pagecount)
{
Response. Write (" & lt; script> Alert (' shall not exceed total pages! Will arrive in the last page! ') & lt;/script>" );
Pageindex pagenum=1;
}
View state [" pageindex "]=pageindex;
Enclosing LoadDataList (DT);
This. Tbx_pageindex. Text=(pageindex + 1). The ToString ();
}
Protected void btn_search_Click (object sender, EventArgs e)
{
String gname=this. Tbx_gname. Text. The Trim ();
If (gname=="% %")
{
Response. Write (" & lt; script> Alert (' commodity name cannot be empty! ') & lt;/script>" );
return;
}
The Entity. The Goods g=new Goods ();
Gname g.G oodsName="%" + + "%";
DT=Business. AdminBusiness. SelectViewGoodsbyGoodsName (g);
Enclosing dl_goods. The DataSource=this. DataListPaging (DT);
This. Dl_goods. DataBind ();
}
Protected void ImageButton1_Click1 (object sender, ImageClickEventArgs e)
{
ImageButton Ibtn=(ImageButton) sender;
String gid=Ibtn.Com mandArgument;
The Response. Redirect (" ~/Detail. Aspx? Gid="+ gid);
}
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//DAL layer
Using System;
using System.Collections.Generic;
using System.Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. The Data;
Using System. The Data. SqlClient.
Using System. The Configuration;
The namespace DataAccess
{
Public static class DA
{
The static SqlConnection myconn;
The static SqlCommand SCD.
The static SqlDataAdapter sda.
The static DA ()
{
Myconn=new SqlConnection ();
Myconn. The ConnectionString=ConfigurationManager. ConnectionStrings [r]. "CxConn" ConnectionString;
SCD=new SqlCommand ();
SCD. Connection=myconn;
Sda=new SqlDataAdapter ();
}
# region to perform the query SQL commands, SQL presence of parameters can be
///& lt; Summary>
///execute the query SQL commands, SQL presence of parameters can be
///& lt;/summary>
///& lt; Param name="cmdtext & gt;" SQL command text & lt;/param>
///& lt; Param name="cmdtype & gt;" The command type & lt;/param>
///& lt; Param name="names" & gt; The parameter name list & lt;/param>
///& lt; Param name="values" & gt; Parameter names corresponding parameter values list & lt;/param>
///& lt; Returns> The int type, said the number of rows affected & lt;/returns>
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull