mathieu_cupryk
asked on
URGENT URGENT print question. and will be merge for 1000 points.
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
*****=> Print to printer what ever way.
}
.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Drawing;
using System.Data.Common;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls ;
using Microsoft.Data.Odbc;
namespace MSPOS
{
/// <summary>
/// Summary description for Receipts.
/// </summary>
public class Receipts : System.Web.UI.Page
{
protected System.Web.UI.WebControls. RadioButto nList Group_RadioButtonList;
protected System.Web.UI.WebControls. DataGrid ReceiptsDataGrid;
private DataSet ddlDataSet = new DataSet();
private OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
protected System.Web.UI.WebControls. Button btnRunQuery;
protected System.Web.UI.WebControls. Button Button2;
protected System.Web.UI.WebControls. TextBox txtPayment;
protected System.Web.UI.WebControls. TextBox txtCashier;
private DataSet ddlDataSet1 = new DataSet();
private DataSet ddlDataSet2 = new DataSet();
protected ActiveUp.WebControls.Activ eDateTime ActiveDateTime3;
protected ActiveUp.WebControls.Activ eDateTime ActiveDateTime4;
private DataSet ddlDataSet3 = new DataSet();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
ActiveDateTime3.Date = System.DateTime.Today.Date ;
ActiveDateTime4.Date = System.DateTime.Today.Date ;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Group_RadioButtonList .SelectedI ndexChange d += new System.EventHandler(this.G roup_Radio ButtonList _SelectedI ndexChange d);
this.txtCashier.TextChange d += new System.EventHandler(this.t xtCashier_ TextChange d);
this.btnRunQuery.Click += new System.EventHandler(this.b tnRunQuery _Click);
this.ReceiptsDataGrid.Sele ctedIndexC hanged += new System.EventHandler(this.R eceiptsDat aGrid_Sele ctedIndexC hanged);
this.Load += new System.EventHandler(this.P age_Load);
}
#endregion
private string DecodeReceipt (string szBill)
{
string szNewBill="";
// Create an ASCII encoding.
Encoding ascii = Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(szBill);
foreach (Byte a in encodedBytes)
{
if ( a ==10 || a ==15 ||a==18 ||a ==27)
{}
else if (a == 13)
szNewBill = szNewBill + "\\n";
else
szNewBill = szNewBill +(char) a;
}
return szNewBill;
}
private void txtPayment_TextChanged(obj ect sender, System.EventArgs e)
{
}
private void txtCashier_TextChanged(obj ect sender, System.EventArgs e)
{
}
//************************ ********** ********** ********** ********** *******
// Get RC_PAYMND and populate dataset
public DataSet BindRC_PAYMND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = @"SELECT RC_PAYMNB FROM TBRECEIPTS WHERE RC_PAYMNB='"+searchstring+ "'";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData Set1, "ddlRC_PAYMNB");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet1;
}
//************************ ********** ********** ********** ********** *******
//************************ ********** ********** ********** ********** *******
// Get RC_CASHND and populate dataset
public DataSet BindRC_CASHND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet2
myConnection.Open();
string strSQLDDL = @"SELECT RC_CASHNB FROM TBRECEIPTS WHERE RC_CASHNB='"+searchstring+ "'";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet2.Clear();
myDataAdapter.Fill(ddlData Set2, "ddlRC_CASHNB");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet2;
}
//************************ ********** ********** ********** ********** *******
//************************ ********** ********** ********** ********** *******
// Get RC_CASHND and populate dataset with RC_CASHND and RC_DATE
public DataSet BindRC_DATE()
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet3
myConnection.Open();
string strSQLDDL = @"SELECT RC_DATE FROM TBRECEIPTS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet3.Clear();
myDataAdapter.Fill(ddlData Set3, "ddlRC_DATE");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet3;
}
//************************ ********** ********** ********** ********** *******
public void ReceiptsDataGrid_ItemComma nd(object source, System.Web.UI.WebControls. DataGridCo mmandEvent Args e)
{
ListItemType oType = ((ListItemType)e.Item.Item Type);
if(oType == ListItemType.Item || oType == ListItemType.AlternatingIt em)
{
e.Item.Attributes.Add("onm ouseover", "this.style.backgroundColo r='lightbl ue'");
e.Item.Attributes.Add("onm ouseout", "this.style.backgroundColo r='Beige'" );
}
if(e.CommandName =="View")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
StringBuilder strAlert = new StringBuilder();
strAlert.Append("<script language=javascript> alert('");
strAlert.Append("Receipt: " + parsedreceipt + "\\n");
strAlert.Append("');</scri pt>");
this.RegisterStartupScript ("startup" ,strAlert. ToString() );
}
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
Response.Write("<script language=\"JavaScript\">") ;
Response.Write("</script>" );
}
}
private void Group_RadioButtonList_Sele ctedIndexC hanged(obj ect sender, System.EventArgs e)
{
}
public void btnRunQuery_Click(object sender, System.EventArgs e)
{
string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
string DateString1 = ActiveDateTime3.Date.Day.T oString() + "-" + ActiveDateTime3.Date.Month .ToString( ) + "-" + ActiveDateTime3.Date.Year. ToString() ;
string DateString2 = ActiveDateTime4.Date.Day.T oString() + "-" + ActiveDateTime4.Date.Month .ToString( ) + "-" + ActiveDateTime4.Date.Year. ToString() ;
Response.Write (DateString1 +"<BR>");
Response.Write (DateString2 +"<BR>");
switch (Group_RadioButtonList.Sel ectedIndex )
{
case 0:
select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
break;
case 1:
select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
break;
case 2:
select_statement += " Where RC_DATE<='" + ActiveDateTime4.Date + "' And RC_DATE >= '" + ActiveDateTime3.Date + "'"; //i don't know the type of these fields so this is the reason that i use text property
break;
}
OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = select_statement;
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnecti on);
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData Set1);
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
ReceiptsDataGrid.DataSourc e = ddlDataSet1.Tables[0];
ReceiptsDataGrid.DataBind( );
}
private void ReceiptsDataGrid_SelectedI ndexChange d(object sender, System.EventArgs e)
{
}
}
}
.aspx
<%@ Register TagPrefix="mspos" TagName="footer" Src="~/Engine/Controls/foo ter.ascx" %>
<%@ Register TagPrefix="mspos" TagName="header" Src="Engine/Controls/heade r.ascx" %>
<%@ Register TagPrefix="uc1" TagName="logout" Src="Engine/Controls/logou t.ascx" %>
<%@ Page Language="c#" trace="true" Codebehind="Receipts.aspx. cs" AutoEventWireup="false" Inherits="MSPOS.Receipts" CompilerOptions='/R:"C:\Pr ogram Files\Microsoft.NET\Odbc.N et\Microso ft.data.od bc.dll"'%>
<%@ Register TagPrefix="cc1" Namespace="ActiveUp.WebCon trols" Assembly="ActiveDateTime" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<script language="JavaScript">
</script>
</HEAD>
<body leftMargin="0" background="images/bg.gif" topMargin="0" marginheigh="0" marginwidth="0">
<form id="Form1" action="database.aspx" method="post" runat="server">
<strong>
<P><mspos:header id="Header1" runat="server"></mspos:hea der><BR>
<FONT face="Verdana" size="2"></FONT>
</P>
<P><FONT face="Verdana" size="2"></FONT> </P>
<FONT face="Verdana" size="2">
<P>
<TABLE id="Table2" height="118" cellSpacing="1" cellPadding="1" width="355" border="0">
<TR>
<TD vAlign="top" width="147" colSpan="1" rowSpan="4">
<P><asp:radiobuttonlist id="Group_RadioButtonList" runat="server" BorderWidth="0px" CellSpacing="1" CellPadding="1"
Height="111px" Font-Bold="True" Font-Size="12px" Font-Names="Verdana" Width="35px" BackColor="#FEF9E9">
<asp:ListItem Value="PayNumber">1</asp:L istItem>
<asp:ListItem Value="Cashier">2</asp:Lis tItem>
<asp:ListItem Value="StartDate">3</asp:L istItem>
</asp:radiobuttonlist></P>
</TD>
<TD noWrap colSpan="1" rowSpan="1">Payment Number:</TD>
<TD vAlign="middle" noWrap width="200" colSpan="1" rowSpan="1"><asp:textbox id="txtPayment" runat="server" MaxLength="10"></asp:textb ox></TD>
</TR>
<TR>
<TD width="240">Cashier Number:</TD>
<TD><asp:textbox id="txtCashier" runat="server" MaxLength="8"></asp:textbo x></TD>
</TR>
<TR>
<TD width="240" height="10">Start Date:</TD>
<TD height="10"><cc1:activedat etime id="ActiveDateTime3" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR "></cc1:ac tivedateti me></TD>
</TR>
<TR>
<TD width="240">End Date: &nb sp;
</TD>
<TD><cc1:activedatetime id="ActiveDateTime4" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR "></cc1:ac tivedateti me></TD>
</TR>
<TR>
<TD width="240"></TD>
<TD><asp:button id="btnRunQuery" onclick="btnRunQuery_Click " runat="server" text="Run Query" type="submit"></asp:button ></TD>
</TR>
</TABLE>
</FONT></strong>
<br>
<strong>Results of:</strong>
<asp:datagrid id="ReceiptsDataGrid" runat="server" BorderWidth="3" CellSpacing="1" CellPadding="1"
Height="144px" Width="500px" OnItemCommand="ReceiptsDat aGrid_Item Command" HeaderStyle-Font-Bold="Tru e"
maintainviewstate="false" GridLines="None" BorderStyle="Outset" font-size="XX-Small" font-names="Verdana"
BorderColor="#CCCC99" AutoGenerateColumns="False ">
<AlternatingItemStyle Wrap="False" BackColor="PaleGoldenrod"> </Alternat ingItemSty le>
<ItemStyle Wrap="False" BackColor="Beige"></ItemSt yle>
<HeaderStyle Font-Size="14px" Font-Bold="True" ForeColor="White" BackColor="#954896"></Head erStyle>
<Columns>
<asp:BoundColumn DataField="RC_PAYMNB" HeaderText="Payment Number "></asp:BoundColumn>
<asp:BoundColumn DataField="RC_CASHNB" HeaderText="Cash Number"></asp:BoundColumn>
<asp:BoundColumn DataField="RC_DATE" HeaderText="Date"></asp:Bo undColumn>
<asp:BoundColumn DataField="RC_DATA" Visible="False" HeaderText="Data"></asp:Bo undColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="View" Text="View" Runat="server" ID="Button1"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></P></form>
</body>
</HTML>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
*****=> Print to printer what ever way.
}
.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Drawing;
using System.Data.Common;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls
using Microsoft.Data.Odbc;
namespace MSPOS
{
/// <summary>
/// Summary description for Receipts.
/// </summary>
public class Receipts : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
private DataSet ddlDataSet = new DataSet();
private OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
private DataSet ddlDataSet1 = new DataSet();
private DataSet ddlDataSet2 = new DataSet();
protected ActiveUp.WebControls.Activ
protected ActiveUp.WebControls.Activ
private DataSet ddlDataSet3 = new DataSet();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
ActiveDateTime3.Date = System.DateTime.Today.Date
ActiveDateTime4.Date = System.DateTime.Today.Date
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Group_RadioButtonList
this.txtCashier.TextChange
this.btnRunQuery.Click += new System.EventHandler(this.b
this.ReceiptsDataGrid.Sele
this.Load += new System.EventHandler(this.P
}
#endregion
private string DecodeReceipt (string szBill)
{
string szNewBill="";
// Create an ASCII encoding.
Encoding ascii = Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(szBill);
foreach (Byte a in encodedBytes)
{
if ( a ==10 || a ==15 ||a==18 ||a ==27)
{}
else if (a == 13)
szNewBill = szNewBill + "\\n";
else
szNewBill = szNewBill +(char) a;
}
return szNewBill;
}
private void txtPayment_TextChanged(obj
{
}
private void txtCashier_TextChanged(obj
{
}
//************************
// Get RC_PAYMND and populate dataset
public DataSet BindRC_PAYMND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = @"SELECT RC_PAYMNB FROM TBRECEIPTS WHERE RC_PAYMNB='"+searchstring+
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet1;
}
//************************
//************************
// Get RC_CASHND and populate dataset
public DataSet BindRC_CASHND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet2
myConnection.Open();
string strSQLDDL = @"SELECT RC_CASHNB FROM TBRECEIPTS WHERE RC_CASHNB='"+searchstring+
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet2.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet2;
}
//************************
//************************
// Get RC_CASHND and populate dataset with RC_CASHND and RC_DATE
public DataSet BindRC_DATE()
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet3
myConnection.Open();
string strSQLDDL = @"SELECT RC_DATE FROM TBRECEIPTS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet3.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet3;
}
//************************
public void ReceiptsDataGrid_ItemComma
{
ListItemType oType = ((ListItemType)e.Item.Item
if(oType == ListItemType.Item || oType == ListItemType.AlternatingIt
{
e.Item.Attributes.Add("onm
e.Item.Attributes.Add("onm
}
if(e.CommandName =="View")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
StringBuilder strAlert = new StringBuilder();
strAlert.Append("<script language=javascript> alert('");
strAlert.Append("Receipt: " + parsedreceipt + "\\n");
strAlert.Append("');</scri
this.RegisterStartupScript
}
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
Response.Write("<script language=\"JavaScript\">")
Response.Write("</script>"
}
}
private void Group_RadioButtonList_Sele
{
}
public void btnRunQuery_Click(object sender, System.EventArgs e)
{
string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
string DateString1 = ActiveDateTime3.Date.Day.T
string DateString2 = ActiveDateTime4.Date.Day.T
Response.Write (DateString1 +"<BR>");
Response.Write (DateString2 +"<BR>");
switch (Group_RadioButtonList.Sel
{
case 0:
select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
break;
case 1:
select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
break;
case 2:
select_statement += " Where RC_DATE<='" + ActiveDateTime4.Date + "' And RC_DATE >= '" + ActiveDateTime3.Date + "'"; //i don't know the type of these fields so this is the reason that i use text property
break;
}
OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = select_statement;
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
ReceiptsDataGrid.DataSourc
ReceiptsDataGrid.DataBind(
}
private void ReceiptsDataGrid_SelectedI
{
}
}
}
.aspx
<%@ Register TagPrefix="mspos" TagName="footer" Src="~/Engine/Controls/foo
<%@ Register TagPrefix="mspos" TagName="header" Src="Engine/Controls/heade
<%@ Register TagPrefix="uc1" TagName="logout" Src="Engine/Controls/logou
<%@ Page Language="c#" trace="true" Codebehind="Receipts.aspx.
<%@ Register TagPrefix="cc1" Namespace="ActiveUp.WebCon
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<script language="JavaScript">
</script>
</HEAD>
<body leftMargin="0" background="images/bg.gif"
<form id="Form1" action="database.aspx" method="post" runat="server">
<strong>
<P><mspos:header id="Header1" runat="server"></mspos:hea
<FONT face="Verdana" size="2"></FONT>
</P>
<P><FONT face="Verdana" size="2"></FONT> </P>
<FONT face="Verdana" size="2">
<P>
<TABLE id="Table2" height="118" cellSpacing="1" cellPadding="1" width="355" border="0">
<TR>
<TD vAlign="top" width="147" colSpan="1" rowSpan="4">
<P><asp:radiobuttonlist id="Group_RadioButtonList"
Height="111px" Font-Bold="True" Font-Size="12px" Font-Names="Verdana" Width="35px" BackColor="#FEF9E9">
<asp:ListItem Value="PayNumber">1</asp:L
<asp:ListItem Value="Cashier">2</asp:Lis
<asp:ListItem Value="StartDate">3</asp:L
</asp:radiobuttonlist></P>
</TD>
<TD noWrap colSpan="1" rowSpan="1">Payment Number:</TD>
<TD vAlign="middle" noWrap width="200" colSpan="1" rowSpan="1"><asp:textbox id="txtPayment" runat="server" MaxLength="10"></asp:textb
</TR>
<TR>
<TD width="240">Cashier Number:</TD>
<TD><asp:textbox id="txtCashier" runat="server" MaxLength="8"></asp:textbo
</TR>
<TR>
<TD width="240" height="10">Start Date:</TD>
<TD height="10"><cc1:activedat
Format="DAY;-;MONTH;-;YEAR
</TR>
<TR>
<TD width="240">End Date: &nb
</TD>
<TD><cc1:activedatetime id="ActiveDateTime4" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR
</TR>
<TR>
<TD width="240"></TD>
<TD><asp:button id="btnRunQuery" onclick="btnRunQuery_Click
</TR>
</TABLE>
</FONT></strong>
<br>
<strong>Results of:</strong>
<asp:datagrid id="ReceiptsDataGrid" runat="server" BorderWidth="3" CellSpacing="1" CellPadding="1"
Height="144px" Width="500px" OnItemCommand="ReceiptsDat
maintainviewstate="false" GridLines="None" BorderStyle="Outset" font-size="XX-Small" font-names="Verdana"
BorderColor="#CCCC99" AutoGenerateColumns="False
<AlternatingItemStyle Wrap="False" BackColor="PaleGoldenrod">
<ItemStyle Wrap="False" BackColor="Beige"></ItemSt
<HeaderStyle Font-Size="14px" Font-Bold="True" ForeColor="White" BackColor="#954896"></Head
<Columns>
<asp:BoundColumn DataField="RC_PAYMNB" HeaderText="Payment Number "></asp:BoundColumn>
<asp:BoundColumn DataField="RC_CASHNB" HeaderText="Cash Number"></asp:BoundColumn>
<asp:BoundColumn DataField="RC_DATE" HeaderText="Date"></asp:Bo
<asp:BoundColumn DataField="RC_DATA" Visible="False" HeaderText="Data"></asp:Bo
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="View" Text="View" Runat="server" ID="Button1"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></P></form>
</body>
</HTML>
Do you want it to be printed at the client or the server end? If client, open the decoded receipt document in a browser window and call the Javascript function window.print() in the OnLoad event of the document. If server, take a look at <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconprintsupport.asp>. If you need further help, please be more specific.
ASKER
On the client side
I need a javascript with a the string being passed.
parsedreceipt
It can open up a dialog box. What have u. It just needs to work.
Response.Write("<script language=\"JavaScript\">") ;
**************=>>>>>>>>>>> >>.
Response.Write("</script>" );
I need a javascript with a the string being passed.
parsedreceipt
It can open up a dialog box. What have u. It just needs to work.
Response.Write("<script language=\"JavaScript\">")
**************=>>>>>>>>>>>
Response.Write("</script>"
ASKER
It is a client side script. It is a webform. Do u need more information.
Try redirecting the user to a new aspx page with the following page content:
--
<html>
<body>
<pre>
<%=Server.HtmlEncode(decod edReceiptH ere)%>
</pre>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
--
<html>
<body>
<pre>
<%=Server.HtmlEncode(decod
</pre>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
ASKER
How do I call this:
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
}
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
}
ASKER
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1501: No overload for method 'DecodeReceipt' takes '0' arguments
Source Error:
Line 11: <body leftMargin="0" background="images/bg.gif" topMargin="0" marginheigh="0" marginwidth="0">
Line 12: <pre>
Line 13: <%=Server.HtmlEncode(Decod eReceipt ())%>
Line 14: </pre>
Line 15: <script language="JavaScript">
Compiler Error Message: CS1501: No overload for method 'DecodeReceipt' takes '0' arguments
Source Error:
Line 11: <body leftMargin="0" background="images/bg.gif"
Line 12: <pre>
Line 13: <%=Server.HtmlEncode(Decod
Line 14: </pre>
Line 15: <script language="JavaScript">
The correct approach depends heavily on what you're doing, but the following will work in most cases. It is pretty ugly though :-(
--
if(e.CommandName =="Print")
{
Session["parsedReceipt"] = DecodeReceipt (e.Item.Cells[3].Text);
Response.Redirect("printre ceipt.aspx ");
}
--
And printreceipt.aspx should be something like the following:
--
<%@Page language="C#"%>
<html>
<body>
<html>
<body>
<pre>
<%=Server.HtmlEncode(Sessi on["parsed Receipt"]) %>
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
--
if(e.CommandName =="Print")
{
Session["parsedReceipt"] = DecodeReceipt (e.Item.Cells[3].Text);
Response.Redirect("printre
}
--
And printreceipt.aspx should be something like the following:
--
<%@Page language="C#"%>
<html>
<body>
<html>
<body>
<pre>
<%=Server.HtmlEncode(Sessi
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
ASKER
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.HttpServerUtil ity.HtmlEn code(strin g)' has some invalid arguments
Source Error:
Line 11: <body>
Line 12: <pre>
Line 13: <%=Server.HtmlEncode(Sessi on["parsed Receipt"]) %>
Line 14: </pre>
Line 15: <hr>
Source File: C:\Inetpub\wwwroot\MSPOS\P rintReceip t.aspx Line: 13
Show Detailed Compiler Output:
c:\windows\system32\inetsr v> "c:\windows\microsoft.net\ framework\ v1.1.4322\ csc.exe" /t:library /utf8output /R:"c:\windows\assembly\ga c\system.d rawing\1.0 .5000.0__b 03f5f7f11d 50a3a\syst em.drawing .dll" /R:"c:\windows\assembly\ga c\system.w eb.mobile\ 1.0.5000.0 __b03f5f7f 11d50a3a\s ystem.web. mobile.dll " /R:"c:\windows\assembly\ga c\system.d ata\1.0.50 00.0__b77a 5c561934e0 89\system. data.dll" /R:"c:\windows\assembly\ga c\system.e nterprises ervices\1. 0.5000.0__ b03f5f7f11 d50a3a\sys tem.enterp riseservic es.dll" /R:"c:\windows\microsoft.n et\framewo rk\v1.1.43 22\tempora ry asp.net files\mspos\103692e3\19bdc 9e7\assemb ly\dl2\412 fda75\c0b6 5432_45b5c 401\mspos. dll" /R:"c:\windows\microsoft.n et\framewo rk\v1.1.43 22\tempora ry asp.net files\mspos\103692e3\19bdc 9e7\qgs_ah kr.dll" /R:"c:\windows\microsoft.n et\framewo rk\v1.1.43 22\mscorli b.dll" /R:"c:\windows\assembly\ga c\system.w eb\1.0.500 0.0__b03f5 f7f11d50a3 a\system.w eb.dll" /R:"c:\windows\assembly\ga c\system\1 .0.5000.0_ _b77a5c561 934e089\sy stem.dll" /R:"c:\windows\microsoft.n et\framewo rk\v1.1.43 22\tempora ry asp.net files\mspos\103692e3\19bdc 9e7\assemb ly\dl2\18b 8a94a\4e88 7d3b_0eb5c 401\active datetime.d ll" /R:"c:\windows\assembly\ga c\system.w eb.service s\1.0.5000 .0__b03f5f 7f11d50a3a \system.we b.services .dll" /R:"c:\windows\assembly\ga c\system.x ml\1.0.500 0.0__b77a5 c561934e08 9\system.x ml.dll" /out:"C:\WINDOWS\Microsoft .NET\Frame work\v1.1. 4322\Tempo rary ASP.NET Files\mspos\103692e3\19bdc 9e7\f9cx1y dn.dll" /D:DEBUG /debug+ /optimize- /warnaserror /w:1 "C:\WINDOWS\Microsoft.NET\ Framework\ v1.1.4322\ Temporary ASP.NET Files\mspos\103692e3\19bdc 9e7\f9cx1y dn.0.cs"
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
C:\Inetpub\wwwroot\MSPOS\P rintReceip t.aspx(13, 28): error CS1502: The best overloaded method match for 'System.Web.HttpServerUtil ity.HtmlEn code(strin g)' has some invalid arguments
C:\Inetpub\wwwroot\MSPOS\P rintReceip t.aspx(13, 46): error CS1503: Argument '1': cannot convert from 'object' to 'string'
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.HttpServerUtil
Source Error:
Line 11: <body>
Line 12: <pre>
Line 13: <%=Server.HtmlEncode(Sessi
Line 14: </pre>
Line 15: <hr>
Source File: C:\Inetpub\wwwroot\MSPOS\P
Show Detailed Compiler Output:
c:\windows\system32\inetsr
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
C:\Inetpub\wwwroot\MSPOS\P
C:\Inetpub\wwwroot\MSPOS\P
Oops, sorry :-( I tested the code prior to adding the html encoding and forgot that it requires a strnig instead of an object. Use
<%=Server.HtmlEncode(Sessi on["parsed Receipt"]. ToString() )%>
instead.
Also, in order to avoid spurious runtime errors when users enter the page without a valid receipt, you can also throw in a
<%
if (Session["parsedReceipt"] == null) Response.Redirect("/");
%>
right after the <%@ Page%> directive.
<%=Server.HtmlEncode(Sessi
instead.
Also, in order to avoid spurious runtime errors when users enter the page without a valid receipt, you can also throw in a
<%
if (Session["parsedReceipt"] == null) Response.Redirect("/");
%>
right after the <%@ Page%> directive.
ASKER
The problem is in here:
<body>
<pre>
<%=Server.HtmlEncode(Sessi on["Parsed Receipt"]. ToString() )%>
</pre>
Not parsing. Properly.
<body>
<pre>
<%=Server.HtmlEncode(Sessi
</pre>
Not parsing. Properly.
What do you mean by that? It works fine with me. Please, always post error messages if you say something doesn't work.
ASKER
It's almost there but it is an empty string:
Omg u almost have it.
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
Session["ParsedReceipt"] = parsedreceipt;
Response.Redirect("PrintRe ceipt.aspx ");
}
<html>
<body>
<pre>
<%
if (Session["ParsedReceipt"] == null) Response.Redirect("/");
%>
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
Omg u almost have it.
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
Session["ParsedReceipt"] = parsedreceipt;
Response.Redirect("PrintRe
}
<html>
<body>
<pre>
<%
if (Session["ParsedReceipt"] == null) Response.Redirect("/");
%>
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
Some very minor errors only... The nullity check should be separate from the value printing (and encoding). This should work as your aspx file content:
--
<%@Page language="C#"%>
<% if (Session["parsedReceipt"] == null) Response.Redirect("/"); %>
<html>
<body>
<pre>
<%=Server.HtmlEncode(Sessi on["parsed Receipt"]. ToString() )%>
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
--
<%@Page language="C#"%>
<% if (Session["parsedReceipt"] == null) Response.Redirect("/"); %>
<html>
<body>
<pre>
<%=Server.HtmlEncode(Sessi
</pre>
<hr>
<p><a href="/">Return</a> to the main application.</p>
<script language="JavaScript">
window.print();
</script>
</body>
</html>
ASKER
Ok
T S T T \nIND.SQUARE/EDWARD ST\nVAT REG# 100476 \nBill Payment 2004/07/1 100.00 \nAccount: 91013698-0000 \n Chantal Rigaud \nA/c Balance: 2,566.33 \n \n \nTOTAL 100.00 \n \nTENDERED \n Cash 100.00 \n TOTAL TENDERED 100.00 \n \nCHANGE 0.00 \n
We should fix \n
T S T T \nIND.SQUARE/EDWARD ST\nVAT REG# 100476 \nBill Payment 2004/07/1 100.00 \nAccount: 91013698-0000 \n Chantal Rigaud \nA/c Balance: 2,566.33 \n \n \nTOTAL 100.00 \n \nTENDERED \n Cash 100.00 \n TOTAL TENDERED 100.00 \n \nCHANGE 0.00 \n
We should fix \n
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.