Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 05:02 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default Printer settings

Hello friends,

  I am developing payroll application. Each emp payslip contains 20 lines. I am generating payslip one by one for each emp. After printing one payslip i want to stop the printer(break) and continue the same page with another emp payslip. Like that i want to print 3 slips on each page. How can i stop the printer after each slip is printed.

Thanx in advance.

 
Old June 10th, 2004, 08:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Why not just insert breaks like VbCrLf or VbTab between queries?
http://msdn.microsoft.com/library/de...sconstring.asp
Code:
For i = 1 To objRS.Count 'For as many payslips you got
  If i Mod 3 = 0 Then ' print for every 3
    Response.Write("<script> & _ 'Not sure this will work...
                      window.print() & _
                    </script>")
    Response.Flush 'write to the client
  Else
    Response.Write(objRS("PaySlip") & VbTab) 'your payslips
    objRS.MoveNext
  End If
Next
Something like that..

 - mega
 
Old June 10th, 2004, 09:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Mega,

As far as I understand, the original post seems to want for a PAUSE of printer, once after each slip is printed, (so that he may re-align the paper or tear it off) which means he wanted to control the printer from his code. Doesn't look like this would be of any help to him.

_________________________
-Vijay G
Strive for Perfection
 
Old June 11th, 2004, 02:35 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi happygv,

  U are correct. Exactly i want that to pause the printer after printing each slip. So that i can save my stationary.


 
Old June 12th, 2004, 07:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

That depends on the printer. I don't see how you would do that on a private home printer. Maybe you could do it on a pro work printer. Does the printer have some sort API?
 
Quote:
quote:So that i can save my stationary.

What do you mean?

 - mega
 
Old April 5th, 2006, 10:19 AM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hans_napier
Default

Hi! I'd seen all the post concerning the this matter but doesn't help me solve my problems. I also had almost the same problems, printing for pay roll. I'm trying to use the page-break but don't seem to work.

The scenario are like this.
I'm displaying multiple records from the database(MySQL) into the page. bind the records to label for each records using data reader using loop so that it can display all the records. I'd programmaticly create all the label. the output are not the problems but when I tried to print it, some of the records are in another page. so i think if i put a page-break at the end of each record then i could solve the problems, but it doesn't.

i even try to use the css in my coding.tried everything...(put it at the HTML view.)

here are a part of my codes;

------------------------------------------------

public void ViewPaySlip()
{
    bangkai = Session["pdate"].ToString();

    OdbcCon.Open();

    select = "select DISTINCT employee.EmpName,employee.EmpNRIC,employee.EmpPosi tion,employee.EmpWorkSite,payslip.PayslipId,paysli p.NormalOvertime,payslip.NormalSaturday,payslip.Pu blicHoliday,payslip.ShiftAllowance,payslip.Attenda nceAllowance,payslip.40MinAllowance,payslip.Levi,p ayslip.Penalty,payslip.Advance,payslip.ChequeNo,pa yslip.TotalSalary,DATE_FORMAT(payslip.PaymentDate, '%d %M %Y'),payslip.EPF,payslip.Socso,payslip.CommissionB onus,payslip.Claims,payslip.PhoneUsed,payslip.Meal Allowance,payslip.Basicsalary,payslip.NormalDay,pa yslip.TransAllowance,payslip.LeaderAllowance,paysl ip.HotAllowance,payslip.Absent FROM employee,payslip WHERE employee.EmpNo=payslip.EmpNo AND DATE_FORMAT(payslip.PaymentDate, '%m%Y')='"+bangkai+"' ORDER BY employee.EmpWorkSite,employee.EmpName";
    OdbcCommand OdbcComViewPaySlip = new OdbcCommand(select,OdbcCon);
    OdbcDataReader OdbcDrPaySlip = OdbcComViewPaySlip.ExecuteReader();
    while (OdbcDrPaySlip.Read())
    {
        Label lblCompName = new Label();
        Label lblCompRegNo = new Label();
        Label lblPageBreak = new Label();

        Label lblNama = new Label();
        Label lblNRIC = new Label();
        Label lblProjek = new Label();
// Label lblPayslipId = new Label();
        Label lblNormOT = new Label();
        Label lblNormSat = new Label();


        Label lblViewNama = new Label();
        Label lblViewNRIC = new Label();
        Label lblViewProjek = new Label();
// Label lblViewPayslipId = new Label();
        Label lblViewNormOT = new Label();
        Label lblViewNormSat = new Label();
        .
        .
        .
            .
// lblPayslipId.Text ="Pay Slip No. : ";

        lblCompName.Text ="Saleh Ab. Malek Sdn. Bhd. ";

        lblCompRegNo.Text =" (Co.No : 564770-x)";

        lblNama.Text ="Name : ";
        lblProjek.Text ="Site : ";
        lblNRIC.Text ="NRIC / Passport No. : ";
        lblTarikh.Text ="Date : ";

        lblNormOT.Text ="Normal Overtime : ";
        lblNormSat.Text ="Normal Saturday : ";
        .
                .
                .
                .
        lblViewNama.Text = OdbcDrPaySlip.GetString(0).ToString();
        lblViewNRIC.Text = OdbcDrPaySlip.GetString(1).ToString();
        release = OdbcDrPaySlip.GetString(2).ToString();

        lblViewProjek.Text = OdbcDrPaySlip.GetString(3).ToString();
// lblViewPayslipId.Text = OdbcDrPaySlip.GetString(4).ToString();
        lblViewNormOT.Text = OdbcDrPaySlip.GetString(5).ToString();
        lblViewNormSat.Text = OdbcDrPaySlip.GetString(6).ToString();
        .
                .
                .
                .
        pbreak="<p style=\"PAGE-BREAK-AFTER: always\">--</p>";
        if(release=="Cleaner")
        {

            PanelViewEmp.Controls.Add(lblCompName);
            lblCompName.Font.Bold = true;
            lblCompName.Font.Size = 11;

            PanelViewEmp.Controls.Add(lblCompRegNo);
            lblCompRegNo.Font.Size = 9;

            PanelViewEmp.Controls.Add(new LiteralControl("<br>"));
// -------------------------------1st Row-------------------------------
                        .
            .
                        .
                        .
// -------------------------------17th Row-------------------------------

            PanelViewEmp.Controls.Add(new LiteralControl("------------------------------------------------------------------------------------------------"));
            PanelViewEmp.Controls.Add(new LiteralControl("<br>"));
// -------------------------------18th Row-------------------------------

            PanelViewEmp.Controls.Add(lblSalarySum);
            lblSalarySum.Font.Size = 9;
            lblSalarySum.Style.Add("POSITION","absolute");
            lblSalarySum.Style.Add("LEFT", "300px");

            PanelViewEmp.Controls.Add(lblViewSalarySum);
            lblViewSalarySum.Font.Bold = true;
            lblViewSalarySum.Font.Size = 9;
            lblViewSalarySum.Width = 82;
            lblViewSalarySum.Style.Add("POSITION","absolute");
            lblViewSalarySum.Style.Add("LEFT", "420px");
            lblViewSalarySum.Style.Add("TEXT-ALIGN", "right");
            PanelViewEmp.Controls.Add(new LiteralControl("<br>"));
// -------------------------------19th Row-------------------------------

            PanelViewEmp.Controls.Add(new LiteralControl("------------------------------------------------------------------------------------------------"));
            PanelViewEmp.Controls.Add(new LiteralControl("<P>------------------------------------------------------------------------------------------------</P>"));
// Response.Write(PanelViewEmp.Controls.Add(new LiteralControl("<P>------------------------------------------------------------------------------------------------</P>")));
            PanelViewEmp.Controls.Add(new LiteralControl("<br>"));
            PanelViewEmp.Controls.Add(new LiteralControl("<p id=\"opara\" style=\"PAGE-BREAK-AFTER: always\" runat=\"server\">"));
// Response.Write("<P><B>Hello</B></P>");
// Response.Write("<p>Start the next page</p>");
// PanelViewEmp.Controls.Add(new LiteralControl("<br clear=all style='mso-special-character:line-break;page-break-before:always'>"));
// PanelViewEmp.Controls.Add(new LiteralControl("<br clear=all style='page-break-before:always'>"));
// PanelViewEmp.Controls.Add(new LiteralControl("<br><br><br>"));
// -------------------------------20th Row-------------------------------

// PanelViewEmp.Controls.Add(new LiteralControl("<br><br><br>"));
                }

-----------------------------------------

if you can give me any idea how to solve this then it would be a great help to me.

 
Old April 5th, 2006, 06:15 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

hans_napier
;;;I'm trying to use the page-break but don't seem to work
This method does. Put this in your style sheet:

br.newpage{page-break-before:always;}

Now on any page you want to force a new page for printing:

<BR class="newpage">

Additionaly if you want to hide something (a print icon or on screen instructions you do not wish to appear on your hard copy) Use the following style:

@media print{
    .NoPrint{
        display: none;
    }
}

And use it like so:

<td valign="top" class="NoPrint">Stuff you dont wnat printed</td>



Wind is your friend
Matt
 
Old April 7th, 2006, 03:20 AM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hans_napier
Default

Thank you mat41. I will try the code you gave.

ok! i'd done it. it's working perfectly.

instead of putting the control to the panel control. i put it directly on the page using :

this.controls.add(thecontrolthatwecreate)
 if using
panel.conrols.add() then i can't use the code that you gave.
thanks alots.
 
Old April 7th, 2006, 03:48 AM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about trin to pause the query for a specified time period? Or better yet give the screen an action popup that says ok and goes to the next one?
http://www.aspfaq.com/show.asp?id=2141







Similar Threads
Thread Thread Starter Forum Replies Last Post
printer settings at client side ramesh.b ASP.NET 2.0 Professional 0 March 7th, 2006 09:00 AM
Programmatically Change Printer Settings vempativenu Beginning VB 6 0 September 2nd, 2004 06:29 AM
Printer Settings melvik C# 0 May 25th, 2004 02:11 AM
how to save & restore default printer settings? Tiffany Pro VB 6 1 April 7th, 2004 06:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.