Thinker

Personal e-notepad


    08.09.2011 Thursday

    Aueeins
    Aueeins
    水面上的小草

    帖子数 : 173
    积分 : 3539
    威望 : 0
    注册日期 : 2011-09-08
    地点 : SG

    08.09.2011 Thursday  Empty 08.09.2011 Thursday

    Post by Aueeins on 08/09/11, 09:21 am

    有关Print的程序设计



    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

    Try
    Dim strReport As String = ""
    strReport = "\22Payroll03.RPT"

    ' Initialize Table Logon Info for crystal report
    If cls00Common.Report_Init(vpReportDocument, strReport) = False Then Exit Sub '初始化vpReportDocument

    Dim vOptDateJoinFrom As Integer, vOptDateJoinTo As Integer, _
    vOptDateLeftFrom As Integer, vOptDateLeftTo As Integer

    If IsDate(maskDateJoinfrom.Text) Then
    vOptDateJoinFrom = 1
    Else
    vOptDateJoinFrom = 0
    maskDateJoinfrom.Text = "01/01/1990"
    End If

    If IsDate(maskDateJoinTo.Text) Then
    vOptDateJoinTo = 1
    Else
    vOptDateJoinTo = 0
    maskDateJoinTo.Text = "31/12/2099"
    End If

    If IsDate(maskDateLeftFrom.Text) Then
    vOptDateLeftFrom = 1
    Else
    vOptDateLeftFrom = 0
    maskDateLeftFrom.Text = "01/01/1990"
    End If

    If IsDate(maskDateLeftTo.Text) Then
    vOptDateLeftTo = 1
    Else
    vOptDateLeftTo = 0
    maskDateLeftTo.Text = "31/12/2099"
    End If

    '以上用来传进Default日期

    vpReportDocument.SetParameterValue("pDepartment", txtDepartment.Text)

    vpReportDocument.SetParameterValue("pDateJoinFrom", CDate(maskDateJoinfrom.Text))
    vpReportDocument.SetParameterValue("vOptDateJoinFrom", vOptDateJoinFrom)
    vpReportDocument.SetParameterValue("pDateJoinTo", CDate(maskDateJoinTo.Text))
    vpReportDocument.SetParameterValue("vOptDateJoinTo", vOptDateJoinTo)
    vpReportDocument.SetParameterValue("pDateLeftFrom", CDate(maskDateLeftFrom.Text))
    vpReportDocument.SetParameterValue("vOptDateLeftFrom", vOptDateLeftFrom)
    vpReportDocument.SetParameterValue("pDateLeftTo", CDate(maskDateLeftTo.Text))
    vpReportDocument.SetParameterValue("vOptDateLeftTo", vOptDateLeftTo)
    vpReportDocument.SetParameterValue("pPermanent", chkPermanent.Checked)
    vpReportDocument.SetParameterValue("pContract", chkContract.Checked)
    vpReportDocument.SetParameterValue("pTemp", chkTemp.Checked)
    vpReportDocument.SetParameterValue("pNotApplicable", chkNotApplicable.Checked)
    vpReportDocument.SetParameterValue("pExistOnly", chkExistOnly.Checked)
    '这里是Set ParameterValue

    Dim i As Integer, strSortFields As String = ""
    For i = 0 To lstRight.Items.Count - 1
    If strSortFields <> "" Then
    strSortFields = strSortFields & " & "
    End If

    Select Case UCase(lstRight.Items(i))
    Case "STAFF ID"
    strSortFields = strSortFields & "{m03staff.StaffId}"
    Case "STAFF NAME"
    strSortFields = strSortFields & "{m03staff.Name}"
    Case "TIME CARD"
    strSortFields = strSortFields & "{m03staff.TimeCardNo}"
    Case "PAYROLL ID"
    strSortFields = strSortFields & "{m03staff.PayrollID}"
    End Select
    Next i

    '用For Loop,多次判断并保存键入的String


    If strSortFields <> "" Then
    vpReportDocument.DataDefinition.FormulaFields("fSorting1").Text = strSortFields
    'vpReportDocument.DataDefinition.SortFields(0).SortDirection = _
    'CrystalDecisions.Shared.SortDirection.DescendingOrder
    End If

    Dim strSortBy As String = ""
    If lstRight.Items.Count > 0 Then
    strSortBy = "Sort By: "
    '即将放进fSelection的strSortBy显示给用户看到,排列的详细信息

    For i = 0 To lstRight.Items.Count - 1
    strSortBy = strSortBy & lstRight.Items(i) & " "
    Next i
    End If
    vpReportDocument.SetParameterValue("pSortBy", strSortBy)

    Me.Hide()
    Dim Printing As New F00REPORT
    Printing.crvReport.ReportSource = vpReportDocument ' Set the Crystal Report -> Report Source
    Printing.Text = UCase(Me.Text)
    Printing.ShowDialog() ' Print report in Crystal Report Viewer
    vpReportDocument.Close()
    Application.DoEvents()

    Me.Close()
    Me.Dispose()
    Catch ex As Exception
    MsgBox("<f22Report03.btnPrint_Click> " & ex.Message)
    End Try
    End Sub

      Current date/time is 05/06/20, 08:49 pm