Subject: Printer settings
Posted By: rajanikrishna Post Date: 6/7/2004 5:02:26 AM
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.

Reply By: mega Reply Date: 6/10/2004 8:53:58 PM
Why not just insert breaks like VbCrLf or VbTab between queries?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsconstring.asp

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
Reply By: happygv Reply Date: 6/10/2004 9:01:18 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
Strive for Perfection
Reply By: rajanikrishna Reply Date: 6/11/2004 2:35:00 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.


Reply By: mega Reply Date: 6/12/2004 7:57:42 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:
So that i can save my stationary.

What do you mean?

 - mega
Reply By: hans_napier Reply Date: 4/5/2006 10:19:49 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.EmpPosition,employee.EmpWorkSite,payslip.PayslipId,payslip.NormalOvertime,payslip.NormalSaturday,payslip.PublicHoliday,payslip.ShiftAllowance,payslip.AttendanceAllowance,payslip.40MinAllowance,payslip.Levi,payslip.Penalty,payslip.Advance,payslip.ChequeNo,payslip.TotalSalary,DATE_FORMAT(payslip.PaymentDate,'%d %M %Y'),payslip.EPF,payslip.Socso,payslip.CommissionBonus,payslip.Claims,payslip.PhoneUsed,payslip.MealAllowance,payslip.Basicsalary,payslip.NormalDay,payslip.TransAllowance,payslip.LeaderAllowance,payslip.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.

Reply By: mat41 Reply Date: 4/5/2006 6:15:16 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
Reply By: hans_napier Reply Date: 4/7/2006 3:20:01 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.

Reply By: jfergy Reply Date: 4/7/2006 3:48:04 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



Go to topic 4973

Return to index page 321
Return to index page 320
Return to index page 319
Return to index page 318
Return to index page 317
Return to index page 316
Return to index page 315
Return to index page 314
Return to index page 313
Return to index page 312