using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Text;
using System.IO;
public partial class JCD : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
labpage.Text = "1";
}
protected void select_Click(object sender, EventArgs e)
{
PageRepeater();
}
private void PageRepeater()
{
string querysql = "";
string sqlInfoCount = "";
string timeone = Request.Form["optionDate"].ToString();
string timetwo = Request.Form["ToDate"].ToString();
if (timeone != "" && timetwo == "")
{
string onetime = timeone + " 00:00:00";
string twotime = timeone + " 23:59:59";
querysql = @"select * from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
sqlInfoCount = @"select count(*) from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
}
if (timeone == "" && timetwo != "")
{
string onetime = timetwo + " 00:00:00";
string twotime = timetwo + " 23:59:59";
querysql = @"select * from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
sqlInfoCount = @"select count(*) from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
}
if (timeone != "" && timetwo != "")
{
string onetime = timeone + " 00:00:00";
string twotime = timetwo + " 23:59:59";
querysql = @"select * from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
sqlInfoCount = @"select count(*) from JCD_VIEW where sSignDateTime>='" + onetime + "' and sSignDateTime<='" + twotime + "'";
}
if (timeone == "" && timetwo == "")
{
querysql = @"select * from JCD_VIEW where 1=1";
sqlInfoCount = @"select count(*) from JCD_VIEW where 1=1";
}
if (sequenceid.Text != "")
{
querysql += @"and sequenceid like '%" + sequenceid.Text.Trim() + "%'";
sqlInfoCount += @"and sequenceid like '%" + sequenceid.Text.Trim() + "%'";
}
if (sname.Text != "")
{
querysql += @"and sname like '%" + sname.Text.Trim() + "%'";
sqlInfoCount += @"and sname like '%" + sname.Text.Trim() + "%'";
}
if (gonghao.Text != "")
{
querysql += @"and gonghao like '%" + gonghao.Text.Trim() + "%'";
sqlInfoCount += @"and gonghao like '%" + gonghao.Text.Trim() + "%'";
}
//sqlHelper自定义的数据库连接类
sqlHelper help = new sqlHelper();
DataSet myset = help.ExecuteDataSetSql(querysql);
Repeater1.DataSource = myset;
Repeater1.DataBind();
DataSet ds = help.ExecuteDataSetSql(sqlInfoCount);
zhong.Text = ds.Tables[0].Rows[0][0].ToString();
PagedDataSource pds = new PagedDataSource();
pds.DataSource = myset.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
pds.CurrentPageIndex = Convert.ToInt32(this.labpage.Text) - 1;
Repeater2.DataSource = pds;
countpage.Text = pds.PageCount.ToString();
labpage.Text = (pds.CurrentPageIndex + 1).ToString();
this.firstpage.Enabled = true;
this.pritpage.Enabled = true;
this.nextpage.Enabled = true;
this.lastpage.Enabled = true;
if (pds.CurrentPageIndex < 1)
{
this.firstpage.Enabled = false;
this.pritpage.Enabled = false;
}
if (pds.CurrentPageIndex == pds.PageCount - 1)
{
this.nextpage.Enabled = false;
this.lastpage.Enabled = false;
}
Repeater2.DataBind();
}
protected void firstpage_Click(object sender, EventArgs e)
{
this.labpage.Text = "1";
this.PageRepeater();
}
protected void pritpage_Click(object sender, EventArgs e)
{
this.labpage.Text = Convert.ToString(Convert.ToInt32(labpage.Text) - 1);
this.PageRepeater();
}
protected void nextpage_Click(object sender, EventArgs e)
{
this.labpage.Text = Convert.ToString(Convert.ToInt32(labpage.Text) + 1);
this.PageRepeater();
}
protected void lastpage_Click(object sender, EventArgs e)
{
this.labpage.Text = this.countpage.Text;
this.PageRepeater();
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JCD.aspx.cs" Inherits="JCD" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>獎懲單查詢頁</title>
<link href="css/birthday.css" rel="stylesheet" type="text/css" />
<script src="js/birthday.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="流水號:"></asp:Label>
<asp:TextBox ID="sequenceid" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="姓 名:"></asp:Label>
<asp:TextBox ID="sname" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="工 號:"></asp:Label>
<asp:TextBox ID="gonghao" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label4" runat="server" Text="簽核日期:"></asp:Label>
<input name="optionDate" οnfοcus="show_cele_date(optionDate,'','',optionDate)" class="input" /> <asp:Label ID="Label5" runat="server" Text="至"></asp:Label>
<input name="ToDate" οnfοcus="show_cele_date(ToDate,'','',ToDate)" class="input" />
<asp:Button ID="select" runat="server" Text="查詢" οnclick="select_Click" />
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="1" cellspacing="1" style="background-color: #99CCFF; font-size:12px; width:1000px;">
<tr>
<td align="center" style=" width:6.00%;">流水號
</td>
<td align="center" style=" width:6.00%;">姓名
</td>
<td align="center" style=" width:6.00%;">工號
</td>
<td align="center" style=" width:7.00%;">課別
</td>
<td align="center" style=" width:5.00%;">職務
</td>
<td align="center" style=" width:15.00%;">獎懲內容
</td>
<td align="center" style=" width:10.00%;">獎懲類型
</td>
<td align="center" style=" width:5.00%;">金額
</td>
<td align="center" style=" width:10.00%;">描述
</td>
<td align="center" style=" width:2.00%;">章
</td>
<td align="center" style=" width:2.00%;">節
</td>
<td align="center" style=" width:2.00%;">條
</td>
<td align="center" style=" width:5.00%;">簽核人
</td>
</td>
<td align="center" style=" width:10.00%;">簽核時間
</td>
</td>
<td align="center" style=" width:9.00%;">簽核內容
</td>
</tr>
</table>
</HeaderTemplate>
</asp:Repeater>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<table border="1" cellpadding="1" cellspacing="1" style=" font-size:12px; width:1000px;">
<tr>
<td align="center" style="width:6.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("SequenceID")%>
</td>
<td align="center" style="width:6.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Sname")%>
</td>
<td align="center" style=" width:6.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Gonghao")%>
</td>
<td align="center" style="width:7.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Kebie")%>
</td>
<td align="center" style="width:5.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Zhiwu")%>
</td>
<td align="center" style="width:15.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Contents")%>
</td>
<td align="center" style="width:10.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("type2")%>
</td>
<td align="center" style="width:5.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Jiner")%>
</td>
<td align="center" style="width:10.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Mx")%>
</td>
<td align="center" style="width:2.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Zhang")%>
</td>
<td align="center" style="width:2.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Jie")%>
</td>
<td align="center" style="width:2.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("Tiao")%>
</td>
<td align="center" style="width:5.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("sSignerName")%>
</td>
</td>
<td align="center" style="width:10.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("sSignDateTime")%>
</td>
</td>
<td align="center" style="width:9.00%;word-wrap:break-word;word-break:break-all;"> <%# Eval("sComment")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<table border="1" style="font-size:12px; width:1000px; text-align:center">
<tr>
<td>
<asp:LinkButton ID="firstpage" runat="server" οnclick="firstpage_Click">首頁</asp:LinkButton>
<asp:LinkButton ID="pritpage" runat="server" οnclick="pritpage_Click">上一頁</asp:LinkButton>
<asp:LinkButton ID="nextpage" runat="server" οnclick="nextpage_Click">下一頁</asp:LinkButton>
<asp:LinkButton ID="lastpage" runat="server" οnclick="lastpage_Click">尾頁</asp:LinkButton>
第<asp:Label ID="labpage" runat="server" Text="Label"></asp:Label>
頁/共<asp:Label ID="countpage" runat="server" Text="Label"></asp:Label>
頁 共<asp:Label ID="zhong" runat="server" Text="Label"></asp:Label>条记录</td></tr>
</table>
</div>
</form>
</body>
</html>