:
Technical implementation:
Front-end:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "RuKD. aspx. cs" Inherits = "HuoDGL_DaY_RuKD" %>
<! 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> warehouse receiving ticket printing </title>
<Style>
@ Media print {
. Noprint {
Display: none
}
}
</Style>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: GridView ID = "DaYGridView" runat = "server" AutoGenerateColumns = "False"
Onrowdatabound = "DaYGridView_RowDataBound" BorderWidth = "0" PageSize = "1" BorderStyle = "None" RowStyle-BorderStyle = "None" ShowHeader = "False" GridLines = "None" Width =" 100% ">
<Columns>
<Asp: TemplateField>
<ItemTemplate>
<Table>
<Tr>
<Td> </td>
</Tr>
</Table>
<Table align = "center" width = "100%" cellpadding = "0" cellspacing = "0" border = "0">
<Tr align = "center">
<Td>
<Asp: Image ID = "Image1" runat = "server" ImageUrl = "~ /Images/1.gif" Height = "60px" Width = "100px"/>
</Td>
<Td colspan = "2" align = "center"> <asp: Label ID = "TitleLabel" runat = "server"
Font-Size = "18px" Text = "Sinotrans Jiangsu company Nantong company Guoli warehouse" Font-Bold = "True"/>
<Br/> <center> <asp: Label ID = "Label1" runat = "server" Font-Size = "18px" Text = "commodity warehouse receiving ticket"
Font-Bold = "True"/> </center>
</Td>
<Td> </td>
</Tr>
<Tr>
<Td width = "25%"> goods owner name <asp: textBox ID = "HuoZTextBox" SkinID = "hengx" Width = "160" runat = "server" Text = '<% # Bind ("HuoZ ") %> '> </asp: TextBox> </td>
<Td width = "25%"> Ticket No. <asp: textBox ID = "DanJHMTextBox" SkinID = "hengx" Width = "160" runat = "server" Text = '<% # Bind ("danmtr ") %> '> </asp: TextBox> </td>
<Td width = "25%"> ticket creation date <asp: textBox ID = "ZhiDRQTextBox" Width = "160" SkinID = "hengx" runat = "server" Text = '<% # Bind ("ZhiDRQ ") %> '> </asp: TextBox> </td>
<Td width = "25%"> </td>
</Tr>
<Tr>
<Td> delivery warehouse <asp: textBox ID = "CangKMCTextBox" runat = "server" Width = "160" SkinID = "hengx" Text = '<% # Bind ("CangKMC ") %> '/> </td>
<Td> shipping nature <asp: textBox ID = "SongHXZTextBox" runat = "server" Width = "160" SkinID = "hengx" Text = '<% # Bind ("SongHXZ ") %> '/> </td>
<Td> vehicle ID <asp: TextBox ID = "CheHTextBox" Width = "160" SkinID = "hengx" runat = "server"> </asp: TextBox> </td>
<Td> </td>
</Tr>
<Tr>
<Td> seal number <asp: TextBox ID = "HuoHTextBox" Width = "160" SkinID = "hengx" runat = "server"> </asp: TextBox> </td>
<Td> delivery order No. <asp: textBox ID = "JiaoHDHTextBox" Width = "160" SkinID = "hengx" runat = "server" Text = '<% # Bind ("JiaoHDH ") %> '/> </td>
<Td colspan = "2"> </td>
</Tr>
<Tr>
<Td colspan = "4" align = "center">
<Asp: GridView ID = "MingXGridView" runat = "server" AutoGenerateColumns = "False">
<Columns>
<Asp: BoundField HeaderText = "NO" FooterText = "Remarks">
<ItemStyle HorizontalAlign = "Center"/>
</Asp: BoundField>
<Asp: BoundField HeaderText = "item name">
<ItemStyle HorizontalAlign = "Left"/>
</Asp: BoundField>
<Asp: BoundField DataField = "PinMXH" HeaderText = "model">
<ItemStyle HorizontalAlign = "Left"/>
</Asp: BoundField>
<Asp: BoundField DataField = "GuiG" HeaderText = "type"/>
<Asp: BoundField HeaderText = "unit" FooterText = "Total"/>
<Asp: BoundField DataField = "ShuL" HeaderText = "quantity"/>
<Asp: BoundField HeaderText = "actual number of instances"/>
<Asp: BoundField DataField = "BeiZ" HeaderText = "Remarks"/>
</Columns>
</Asp: GridView>
</Td>
</Tr>
<Tr>
<Td> <asp: Label ID = "BeiZLabel" runat = "server" Text = "standby note" Visible = "false"/> <asp: textBox ID = "BeiZTextBox" SkinID = "hengx" runat = "server" Text = '<% # Bind ("BeiZ ") %> 'visible = "false"/> </td>
<Td> <asp: Label ID = "HeJLabel" runat = "server" Text = "" Visible = "false"/> <asp: textBox ID = "HeJTextBox" SkinID = "hengx" runat = "server" Text = '<% # Bind ("ShuL ") %> 'visible = "false"/> </td>
<Td colspan = "2"> </td>
</Tr>
<Tr>
<Td> operator <asp: TextBox ID = "ZhiDRTextBox" runat = "server" SkinID = "hengx" Text = '<% # Bind ("ZhiDR ") %> '/> </td>
<Td> receiver <asp: TextBox ID = "ShouHRTextBox" SkinID = "hengx" runat = "server"/> </td>
<Td> collaborators <asp: TextBox ID = "XieZRTextBox" SkinID = "hengx" runat = "server"/> </td>
<Td> </td>
</Tr>
<Tr>
<Td colspan = "3"> Description: 1. this warehouse receiving ticket is valid for 7 days from the date of issuance: <br/> & nbsp; & nbsp; 2. white Union Finance inventory Association, green union is the pick-up and return to the single union, blue union is the receipt unit, yellow union is the freight settlement union, red union is the warehouse inventory Union <br/> </td>
<Td align = "right"> Print by <asp: textBox ID = "TextBox1" Width = "110" runat = "server" SkinID = "hengx" Text = '<% # Bind ("DaYR ") %> '/> <br/> Print time <asp: textBox ID = "DaYSJTextBox" Width = "110" SkinID = "hengx" runat = "server" Text = '<% # Bind ("DaYSJ ") %> '> </asp: TextBox>
<Br/> <asp: Label runat = "server" ID = "YeMLabel"/>
</Td>
</Tr>
</Table>
</ItemTemplate>
</Asp: TemplateField>
</Columns>
<PagerStyle CssClass = "noprint"/>
<RowStyle BorderStyle = "None"/>
</Asp: GridView>
</Div>
<P align = "center" class = "noprint">
& Nbsp; <asp: Button ID = "DaYButton" runat = "server" Text = "print" onclick = "DaYButton_Click"/>
<Asp: Button ID = "GuanBButton" runat = "server" onclientclick = "javascript: window. close ();"
Text = "close"/> </p>
</Form>
</Body>
</Html>
Background:
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 Common;
Using System. Collections. Generic;
Public partial class HuoDGL_DaY_RuKD: System. Web. UI. Page
{
SqlGetDataBinder = new SqlGetDataBinder ();
Int PageRows = 0;
Int PageCount = 0;
String BeiZ, ShuL;
Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
If (Request. QueryString ["LiuSDH"]! = Null)
{
ViewState ["LiuSDH"] = Request. QueryString ["LiuSDH"];
ViewState ["UserName"] = Request. QueryString ["username"]. Replace ("td ","");
This. GetDataMessage ();
}
}
}
// Obtain the report data to bind
Protected void GetDataMessage ()
{
If (SqlGetDataBinder. GetDataHasRows ("select DanH from Churchill where LiuSDH = '" + ViewState ["LiuSDH"]. ToString () + "'"))
{
// Obtain the total number of data items
Double count = Convert. toDouble (SqlGetDataBinder. getFirst ("select count (*) from ChuLKDMXB where DanH = '" + ViewState ["LiuSDH"]. toString () + "'"));
PageCount = Convert. ToInt32 (count );
Count = count/8;
Count = Math. Ceiling (count );
List <string> str = null;
Str = SqlGetDataBinder. getStrList ("select ShangJHZXX. shangJMC, DanH, Churchill. beiZ, CangKMC, SongHXZ, RiQ, CaoZR, JiaoHDH from church KD inner join ShangJHZXX on ShangJHZXX. shangJBH = Churchill. huoZBH where LiuSDH = '"+ ViewState [" LiuSDH "]. toString () + "'");
ShuL = SqlGetDataBinder. GetFirst ("select sum (ShuL) from ChuLKDMXB where DanH = '" + ViewState ["LiuSDH"]. ToString () + "'"). ToString ();
DataTable table = new DataTable ();
Table. Columns. Add ("HuoZ", typeof (string); // goods owner
Table. Columns. Add ("ZhiDRQ", typeof (string); // Date of ticket Creation
Table. Columns. Add ("dantings", typeof (string); // Document No.
Table. Columns. Add ("ZhiDR", typeof (string); // single user
Table. Columns. Add ("DaYSJ", typeof (string); // print time
Table. Columns. Add ("Title", typeof (string); // Title
Table. Columns. Add ("ShuL", typeof (string); // quantity
Table. Columns. Add ("BeiZ", typeof (string); // remarks
Table. Columns. Add ("CangKMC", typeof (string); // repository name
Table. Columns. Add ("SongHXZ", typeof (string); // shipping Properties
Table. Columns. Add ("DaYR", typeof (string); // printed
Table. Columns. Add ("JiaoHDH", typeof (string); // delivery order No.
For (double n = 0; n <count; n ++)
{
DataRow row = table. NewRow ();
Row [0] = str [0];
Row [1] = Convert. ToDateTime (str [5]). to1_datestring ();
Row [2] = str [1];
Row [3] = str [6]. ToString ();
Row [4] = DateTime. Now. ToString ("g ");
Row ["BeiZ"] = str [2];
Row ["ShuL"] = ShuL;
Row ["CangKMC"] = str [3];
Row ["SongHXZ"] = str [4];
Row ["DaYR"] = ViewState ["UserName"]. ToString ();
Row ["JiaoHDH"] = str [7];
Table. Rows. Add (row );
}
PageRows = table. Rows. Count;
This. DaYGridView. DataSource = table;
This. DaYGridView. DataBind ();
// No.
Int BianH = 1;
For (int n = 0; n <this. DaYGridView. Rows. Count; n ++)
{
GridView grid = (GridView) this. DaYGridView. Rows [n]. FindControl ("MingXGridView ");
For (int p = 0; p <grid. Rows. Count; p ++)
{
If (grid. Rows [p]. Cells [2]. Text. Replace ("& nbsp;", ""). Trim (). Length> 0)
{
Grid. Rows [p]. Cells [1]. Text = str [0];
}
Grid. Rows [p]. Cells [0]. Text = BianH. ToString ();
BianH ++;
}
}
}
}
Protected void DaYGridView_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
// Current page number
Int count2 = e. Row. RowIndex;
Count2 = count2 * 8;
// Bind detailed information
GridView grid = (GridView) e. Row. FindControl ("MingXGridView ");
If (e. Row. RowIndex = PageRows-1)
{
Grid. ShowFooter = true;
Int p = PageCount % 8;
If (p = 0)
{
P = 8;
}
DataTable table = new DataTable ();
Table. Columns. Add ("PinMXH", typeof (string ));
Table. Columns. Add ("GuiG", typeof (string ));
Table. Columns. Add ("ShuL", typeof (string ));
Table. Columns. Add ("BeiZ", typeof (string ));
Table. Columns. Add ("XuH", typeof (int); // No.
For (int n = 0; n <8-p; n ++)
{
DataRow row = table. NewRow ();
Row [0] = "";
Row [1] = "";
Row [2] = "";
Row [3] = "";
Row [4] = 10000000 + n;
Table. Rows. Add (row );
}
Table. merge (SqlGetDataBinder. getDataTable ("select top 8 PinMXH, GuiG, cast (ShuL as varchar (10) as ShuL, BeiZ, XuH from ChuLKDMXB where DanH = '" + ViewState ["LiuSDH"]. toString () + "'and PinMXH not in (select top" + count2 + "PinMXH from ChuLKDMXB where DanH ='" + ViewState ["LiuSDH"]. toString () + "'order by XuH asc) order by XuH asc "));
Table. DefaultView. Sort = "XuH asc ";
Grid. DataSource = table;
Grid. DataBind ();
Grid. FooterRow. Cells [1]. ColumnSpan = 3;
Grid. FooterRow. Cells [2]. Visible = false;
Grid. FooterRow. Cells [3]. Visible = false;
Grid. FooterRow. Cells [1]. Text = BeiZ;
Grid. FooterRow. Cells [5]. Text = ShuL;
}
Else
{
Grid. dataSource = SqlGetDataBinder. getDataTable ("select top 8 PinMXH, GuiG, ShuL, BeiZ from ChuLKDMXB where DanH = '" + ViewState ["LiuSDH"]. toString () + "'and PinMXH not in (select top" + count2 + "PinMXH from ChuLKDMXB where DanH ='" + ViewState ["LiuSDH"]. toString () + "'order by XuH asc) order by XuH asc ");
Grid. DataBind ();
}
// Set the page number
Int index = e. Row. RowIndex + 1;
(Label) e. Row. FindControl ("YeMLabel"). Text = "" + index. ToString () + "Page, total" + PageRows + "page ";
}
}
Protected void DaYButton_Click (object sender, EventArgs e)
{
RegisterStartupScript ("c", "<script> window. print (); </script> ");
}
}
Note: This article is reprinted to Bai yixuan