View Single Post
  #6 (permalink)  
Old April 5th, 2006, 10:19 AM
hans_napier hans_napier is offline
Registered User
 
Join Date: Apr 2006
Location: Segamat, Johor, Malaysia.
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.

Reply With Quote