3층 + 저장 프로세스 구현 페이지 예시 코드

7753 단어
프런트 디자인:
 
  




<br/><script src="js/Jquery1.7.js" type="text/javascript"/> <br/><script type="text/javascript"> <br>$(function () { <br>$('#txtPagination').focus(function () { <br>$(this).val(""); <br>}) <br>}) <br></script> <br/> <br/> <br/><form id="form1" runat="server"> <br/><div> <br/><gridview id="GridView1" runat="server" autogeneratecolumns="False">Height="336px" Width="685px"> <br/><columns> <br/><boundfield datafield="Id" headertext=" "/> <br/><boundfield datafield="NewsTitle" headertext=" "/> <br/><boundfield datafield="NewsContent" headertext=" "/> <br/><boundfield datafield="CreateTime">DataFormatString="{0:yyyy-MM-dd hh:mm:ss}" HeaderText=" " /> <br/></boundfield></columns> <br/></gridview> <br/><linkbutton id="btnFirst" runat="server" onclick="btnFirst_Click"> </linkbutton> <br/><linkbutton>ID="btnPre" runat="server" onclick="btnPre_Click"> </linkbutton> <br/><linkbutton id="btnNext">runat="server" onclick="btnNext_Click"> </linkbutton> <br/><linkbutton id="btnLast" runat="server" onclick="btnLast_Click"> </linkbutton><textbox>ID="txtPagination" runat="server"></textbox> <br/><linkbutton id="btnSkip" runat="server" onclick="btnSkip_Click">GO</linkbutton> <br/></div> <br/></form> <br/> <br/> <br/> </code></pre> <br/> <br/> <pre><code> <br/>create proc usp_role_GetDateByPageIndex <br/>@pageSize int, <br/>@pageIndex int <br/>as <br/>begin <br/>select * from <br/>( <br/>select *,ROW_NUMBER() over(order by role_id) as rownumber from role) as tbl <br/>where tbl.rownumber between (@pageSize*(@pageIndex-1)+1) and @pageIndex*@pageSize <br/>end <br/>exec usp_role_GetDateByPageIndex 5,3 <br/> </code></pre> <br/> BLL,DAL,DataAccess,MODEL <br/> DAL : <br/> <pre><code> <br/>// , <br/>public DataTable GetListDataTable(int PageSize, int PageIndex) <br/>{ <br/>SqlParameter[] parameters = { <br/>new SqlParameter("@PageSize", SqlDbType.Int), <br/>new SqlParameter("@PageIndex", SqlDbType.Int) <br/>}; <br/>parameters[0].Value = PageSize; <br/>parameters[1].Value = PageIndex; <br/>return DbHelperSQL.RunProcedureDataTable("usp_role_GetDateByPageIndex", parameters); <br/>} <br/> BLL GetListDataTable: <br/>public DataTable GetListDataTable(int pagesize, int pageindex) <br/>{ <br/>return dal.GetListDataTable(pagesize, pageindex); <br/>} <br/> DbHelper RunProcedureDataTable : <br/>public static DataTable RunProcedureDataTable(string stroreProcName, IDataParameter[] parameters) <br/>{ <br/>using (SqlConnection connection = new SqlConnection(connectionString)) <br/>{ <br/>DataTable dt = new DataTable(); <br/>connection.Open(); <br/>SqlDataAdapter sqlDA = new SqlDataAdapter(); <br/>sqlDA.SelectCommand = BuildQueryCommand(connection, stroreProcName, parameters); <br/>sqlDA.Fill(dt); <br/>connection.Close(); <br/>return dt; <br/>} <br/>} <br/> </code></pre> <br/> : <br/> <pre><code> <br/>using System; <br/>using System.Collections.Generic; <br/>using System.Linq; <br/>using System.Web; <br/>using System.Web.UI; <br/>using System.Web.UI.WebControls; <br/>using System.Data; <br/>namespace <br/>{ <br/>public partial class paging : System.Web.UI.Page <br/>{ <br/>int pagesize = 10; <br/>int pageindex = 1; <br/>protected void Page_Load(object sender, EventArgs e) <br/>{ <br/>if (!IsPostBack) <br/>{ <br/>ViewState["pageindex"] = 1; <br/>LadaData(); <br/>GetListPageindex(); <br/>} <br/>} <br/>private void GetListPageindex() <br/>{ <br/>BLL.T_News1 bnews = new BLL.T_News1(); <br/>int totalcount = bnews.GetRecordCount(""); <br/>if (totalcount % pagesize == 0) <br/>{ <br/>ViewState["lastpageindex"] = totalcount / pagesize; <br/>} <br/>else <br/>{ <br/>ViewState["lastpageindex"] = totalcount / pagesize + 1; <br/>} <br/>} <br/>private void LadaData() <br/>{ <br/>BLL.T_News1 bnews = new BLL.T_News1(); <br/>DataTable dt = bnews.GetListDataTable(pagesize, Convert.ToInt32(ViewState["pageindex"])); <br/>this.GridView1.DataSource = dt; <br/>this.GridView1.DataBind(); <br/>} <br/>// <br/>protected void btnFirst_Click(object sender, EventArgs e) <br/>{ <br/>ViewState["pageindex"] = 1; <br/>LadaData(); <br/>} <br/>// <br/>protected void btnPre_Click(object sender, EventArgs e) <br/>{ <br/>int pageindex = Convert.ToInt32(ViewState["pageindex"]); <br/>if (pagesize>1) <br/>{ <br/>pageindex--; <br/>ViewState["pageindex"] = pageindex; <br/>LadaData(); <br/>} <br/>} <br/>// <br/>protected void btnNext_Click(object sender, EventArgs e) <br/>{ <br/>int pageindex = Convert.ToInt32(ViewState["pageindex"]); <br/>if (pageindex<convert.toint32>{ <br/>pageindex++; <br/>ViewState["pageindex"] = pageindex; <br/>LadaData(); <br/>} <br/>} <br/>// <br/>protected void btnLast_Click(object sender, EventArgs e) <br/>{ <br/>ViewState["pageindex"] = ViewState["lastpageindex"]; <br/>LadaData(); <br/>} <br/>// <br/>protected void btnSkip_Click(object sender, EventArgs e) <br/>{ <br/>int result; <br/>if (int.TryParse(txtPagination.Text, out result) == true) <br/>{ <br/>ViewState["pageindex"] = txtPagination.Text.Trim(); <br/>LadaData(); <br/>} <br/>else <br/>{ <br/>txtPagination.Text = " "; <br/>} <br/>} <br/>} <br/>} <br/> </convert.toint32></code></pre> <div class="clearfix"> <span id="art_bot" class="jbTestPos"/> </div> </div> </div> </div>

좋은 웹페이지 즐겨찾기