p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   Printer settings (http://p2p.wrox.com/showthread.php?t=13856)

rajanikrishna June 7th, 2004 05:02 AM

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.


mega June 10th, 2004 08:53 PM

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

happygv June 10th, 2004 09:01 PM

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
[8]Strive for Perfection[8]

rajanikrishna June 11th, 2004 02:35 AM

Hi happygv,

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



mega June 12th, 2004 07:57 AM

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

hans_napier April 5th, 2006 10:19 AM

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.


mat41 April 5th, 2006 06:15 PM

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

hans_napier April 7th, 2006 03:20 AM

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.

jfergy April 7th, 2006 03:48 AM

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




All times are GMT -4. The time now is 01:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.