我正在制作一个项目,我正在为学生,办公室和帐户生成收据。目前我根据单选按钮的选择一次显示这三个副本但我希望这三个收据显示在同一页面,以便它们可以打印在一张A4尺寸的纸张上。我附上我的aspx,cs代码以及我正在使用的截图以及我想要的内容。
aspx代码
<asp:RadioButtonList ID="rblreceipt" runat="server" Visible="false" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="rblreceipt_OnSelectedIndexChanged">
<asp:ListItem>Student copy</asp:ListItem>
<asp:ListItem>Office copy</asp:ListItem>
<asp:ListItem>Accounts copy</asp:ListItem>
</asp:RadioButtonList>
<asp:Panel ID="pnlreceipt" runat="server">
<div id="divprint">
<div id="divpnlreceipt" runat="server" visible="false">
<table class="outertable">
<tr>
<td>
<asp:Image ID="imglogo" runat="server" ImageUrl="~/Images/scholar-logo.png" CssClass="logo"/>
<asp:Label ID="lblreceiptcopy" runat="server" Text="Label" CssClass="receiptcopyheading"></asp:Label>
</td>
</tr>
<tr>
<td>
<table class="innertablereceipt">
<tr>
<td colspan="4"><span class="innerheading">ME-LUNCH RECEIPT</span></td>
</tr>
<tr>
<td>
Receipt No:<asp:Label ID="lblreceiptno" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td>
Adm. No:<asp:Label ID="lbladmno" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td class="col3">
Code No:<asp:Label ID="lblcodeno" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td>
Date:<asp:Label ID="lbldate" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr>
<td>
Name:<asp:Label ID="lblname" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td>
Class:<asp:Label ID="lblclass" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td colspan="2">
For the month of:<asp:Label ID="lblmonth" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr>
<td>
Father's Name:<asp:Label ID="lblfathername" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td>
School:<asp:Label ID="lblschool" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td colspan="2">
Branch:<asp:Label ID="lblbranch" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr>
<td>
Address:<asp:Label ID="lbladdress" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="height:4px;">
<td colspan="4">................................................................................................................................................................................................</td>
</tr>
<tr style="border-bottom:1px dotted black;">
<td colspan="2">
Particulars
</td>
<td>
Amount
</td>
</tr>
<tr style="height:4px;">
<td colspan="4">................................................................................................................................................................................................</td>
</tr>
<tr style="border-bottom:1px dotted black;height:40px">
<td colspan="2">
Me-Lunch Charges
</td>
<td colspan="2">
<asp:Label ID="lblamount" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr style="height:4px;">
<td colspan="4">................................................................................................................................................................................................</td>
</tr>
<tr>
<td colspan="3"></td>
<td>
Total amount:<asp:Label ID="lbltotalamount" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr>
<td>
Cash/cheque No:<asp:Label ID="lblpaymenttype" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td colspan="3">
Bank Name:<asp:Label ID="lblbankname" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
</tr>
<tr>
<td>(In words):</td>
<td colspan="2" class="txtunderline">
<asp:Label ID="lblamountwords" runat="server" Text="" CssClass="lblreceipt"></asp:Label>
</td>
<td></td>
</tr>
<tr>
<td colspan="3">
*Cheque subject to realisation
</td>
<td>Cashier Signature</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
<div id="divstudent" runat="server" class="studentreceipt" visible="false"></div>
c#code
public void filldata()
{
sql ="select s.admissionnumber,s.studentname,g.forename,g.relationshipcode,c.classname,concat(a.address,',',a.town,',',a.state,',',a.country) as address,e.amount "
+"from tblstudent s left join tblguardian g on s.studentcode=g.studentcode "
+"left join tblclass c on c.classcode=s.classcode "
+"left join tblcontactaddress ca on ca.usercode=g.guardiancode "
+"left join tbladdress a on ca.addressid=a.addressid "
+"left join tblmiddaymeal_entry e on e.studentcode=s.studentcode "
+"where s.studentcode='"+drpstudent.SelectedItem.Value+"' and c.classcode='"+drpclass.SelectedItem.Value+"'";
ds = obj.openDataset(sql,Session["schoolcode"].ToString());
lblfathername.Text = "";
for (int i = 0; i < ds.Tables[0].Rows.Count;i++)
{
if (ds.Tables[0].Rows[0]["relationshipcode"].ToString()=="14")
{
lblfathername.Text = ds.Tables[0].Rows[i]["forename"].ToString();
}
}
string sqlrecepit = "SELECT * FROM tblmiddaymeal_receipt order by receiptno desc";
DataSet dsreceipt = new DataSet();
dsreceipt = obj.openDataset(sqlrecepit,Session["schoolcode"].ToString());
string sqlschool = "select * from tblschool where schoolcode='"+Session["schoolcode"].ToString()+"'";
DataSet dsSchool = new DataSet();
dsSchool = obj.openDataset(sqlschool,Session["schoolcode"].ToString());
if (dsreceipt.Tables[0].Rows.Count == 0)
{
lblreceiptno.Text = "10000";
}
else
{
lblreceiptno.Text = (Convert.ToInt32(dsreceipt.Tables[0].Rows[0]["receiptno"]) + 1).ToString();
}
lblreceiptcopy.Text = "Student Copy";
lbladmno.Text = ds.Tables[0].Rows[0]["admissionnumber"].ToString();
lblcodeno.Text = "";
lbldate.Text = "<b>"+DateTime.Now.ToString("dd/MM/yyyy")+"</b>";
lblname.Text = ds.Tables[0].Rows[0]["studentname"].ToString();
lblclass.Text = ds.Tables[0].Rows[0]["classname"].ToString();
lblmonth.Text = drpmonth.SelectedItem.Text;
lblschool.Text = dsSchool.Tables[0].Rows[0]["schoolname"].ToString();
lblbranch.Text = "S.S.B";
if (ds.Tables[0].Rows[0]["amount"].ToString().Length == 0)
{
lblamount.Text = "";
lbltotalamount.Text = "";
lblamountwords.Text = "";
}
else
{
lblamount.Text = ds.Tables[0].Rows[0]["amount"].ToString();
lbltotalamount.Text = "<b>" + ds.Tables[0].Rows[0]["amount"].ToString() + "</b>";
lblamountwords.Text = " " + "<b>" + NumberToWords(Convert.ToInt32(ds.Tables[0].Rows[0]["amount"])) + " only" + " </b>";
}
lblpaymenttype.Text = drppayment.SelectedItem.Text;
if(drppayment.SelectedIndex==2)
{
lblbankname.Text = txtbankname.Text;
}
string sqlcheck = "select * from tblmiddaymeal_receipt r where r.studentcode='"+drpstudent.SelectedItem.Value+"' and formonthof='"+drpmonth.SelectedItem.Text+"'";
DataSet dscheck = new DataSet();
dscheck = obj.openDataset(sqlcheck,Session["schoolcode"].ToString());
if(dscheck.Tables[0].Rows.Count!=0)
{
string sqlinsert = "update tblmiddaymeal_receipt set date='" + DateTime.Now.ToString("dd/MM/yyyy") + "',forMonthOf='" + drpmonth.SelectedItem.Text + "', "
+ "branch='" + lblbranch.Text + "',amount='" + lblamount.Text + "',paymenttype='" + lblpaymenttype.Text + "',bankname='" + lblbankname.Text + "' "
+ "where receiptno='" + dscheck.Tables[0].Rows[0]["receiptno"].ToString() + "'";
obj.executeQuery(sqlinsert, Session["schoolcode"].ToString());
}
else
{
string sqlinsert = "insert into tblmiddaymeal_receipt(receiptno,studentcode,date,forMonthOf,branch,amount,paymenttype,bankname) "
+ "values('" + lblreceiptno.Text + "','" + drpstudent.SelectedItem.Value + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','" + drpmonth.SelectedItem.Text + "','" + lblbranch.Text + "','" + lblamount.Text + "','" + lblpaymenttype.Text + "','" + lblbankname.Text + "')";
obj.executeQuery(sqlinsert, Session["schoolcode"].ToString());
}
}
public void generatereceipt()
{
divstudent.Controls.Add(pnlreceipt);
divpnlreceipt.Visible = true;
divstudent.Visible = true;
//divoffice.Visible = true;
//divaccounts.Visible = true;
}
protected void btnsubmit_OnClick(object sender, ImageClickEventArgs e)
{
btnprint.Visible = true;
filldata();
generatereceipt();
rblreceipt.SelectedIndex = 0;
rblreceipt.Visible = true;
}
我页面的截图
我希望输出