<%@ Register TagPrefix="Title" TagName="TitleShow" Src="/aspnetdata/Title.ascx" %>
<%@Page Debug=True %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web" %>
<html>
<head>
	<script language="C#" runat="server">
	SqlConnection Source;
	string d="SELECT Staff.*, MonthPay.* FROM MonthPay INNER JOIN Staff ON MonthPay.SID = Staff.SID Order by Staff.SID";
	void Page_load(object sender,EventArgs e){
		Source = (SqlConnection)Session["NowEmpSQL"];
		if(IsPostBack==false){
			bindNew(true);
			}
	}
	void bindNew(Boolean tag){//结合至DataGrid
		if(tag==true){
			DataSet DS = new DataSet();
			SqlDataAdapter NComm = new SqlDataAdapter(d, Source);
			NComm.Fill(DS, "staffPay");
			Session["NowDS"]=DS;//声明为Session
			staffPay.DataSource=DS.Tables["staffPay"].DefaultView;
			staffPay.DataBind();
		}
		else{
			DataSet DS=(DataSet)Session["NowDS"];
			DataView dv=DS.Tables["staffPay"].DefaultView;
			staffPay.DataSource=dv;
			staffPay.DataBind();
		}
	}
	void ChangePage(object sender,DataGridPageChangedEventArgs e){
		staffPay.CurrentPageIndex = e.NewPageIndex;
		bindNew(false);
	}
	</script>
</head>
<body background="/aspnetdata/images/winback.gif">
<Title:TitleShow id="BookT" Runat="server" />
<form runat="server" >
      <ASP:DataGrid id="staffPay" runat="server"
        BorderColor="black"
        BorderWidth="1"
        GridLines="Both"
        CellPadding="3"
        CellSpacing="0"
        Font-Name="Verdana"
        Font-Size="9pt"
        HeaderStyle-BackColor="LightYellow"
	HeaderStyle-HorizontalAlign="Center"
	AutoGenerateColumns="FALSE"
	SelectedItemStyle-BackColor="#FFFFC0"
        AllowPaging="True"
        PagerStyle-Mode="NextPrev"
        pagesize="6"
        OnPageIndexChanged="ChangePage"
>
      <Columns>
	<asp:BoundColumn HeaderText="StaffID" DataField="SID" ItemStyle-Wrap="false"  />
	<asp:BoundColumn HeaderText="Name" DataField="cname" />
	<asp:BoundColumn HeaderText="PID" DataField="pid" />
	<asp:BoundColumn HeaderText="YearMonth" DataField="YearMonth" />
	<asp:BoundColumn HeaderText="应发工资" DataField="PayTotalDe" DataFormatString="{0:n}"/>
        <asp:BoundColumn HeaderText="扣款合计" DataFormatString="{0:n}" DataField="MinusTotal" ItemStyle-HorizontalAlign="right"/>
        <asp:BoundColumn HeaderText="福利金" DataFormatString="{0:n}" DataField="WellFare" ItemStyle-HorizontalAlign="right"/>
	<asp:TemplateColumn HeaderText="Pay" >
		<ItemTemplate>
			<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "Pay","{0:c}") %> id="Pay"/>
		</ItemTemplate>
	</asp:TemplateColumn>
	</Columns>
</ASP:DataGrid>
</form>