EDN Admin
Well-known member
hi to all
I have list of names in list view with corresponding unique employee id. The user could select more rows. In each employee id I will find it in database in retrieve all the details information and print it using crystal report. What I want is in each employee
id it will print in separate pages.
Currently using my code, the records of other employee id will append on the current page instead to print in another page with new header and footer.
Any help would greatly appreciated
Thanks in advance
Please see this link of my crystal report designer http://www.shopgruppo.com/dchallenger/crystal-report.jpg
Below code is my form with crystalreportviewer
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub frmIndividualDTRPrint_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load
<span style="color:Blue; Dim frmRefIndividualDTR <span style="color:Blue; As frmIndividualDTR = <span style="color:Blue; DirectCast(frmMain.ActiveMdiChild, frmIndividualDTR)
<span style="color:Blue; Dim dtFromDate <span style="color:Blue; As DateTime = frmRefIndividualDTR.dtpFromDate.Text
<span style="color:Blue; Dim dtToDate <span style="color:Blue; As DateTime = frmRefIndividualDTR.dtpToDate.Text
<span style="color:Blue; Dim myRpt <span style="color:Blue; As <span style="color:Blue; New IndividualDTRReport
<span style="color:Blue; Dim txtHeader <span style="color:Blue; As CrystalDecisions.CrystalReports.Engine.TextObject = myRpt.Section2.ReportObjects(<span style="color:#A31515; "txtHeader")
txtHeader.Text = <span style="color:#A31515; "No Bia Inc. Timecard Report"
<span style="color:Blue; Dim txtDateNow <span style="color:Blue; As CrystalDecisions.CrystalReports.Engine.TextObject = myRpt.Section2.ReportObjects(<span style="color:#A31515; "txtDateNow")
txtDateNow.Text = <span style="color:#A31515; "Period Covered " & Format(dtFromDate, <span style="color:#A31515; "d MMMM yyyy") & <span style="color:#A31515; " - " & Format(dtToDate, <span style="color:#A31515; "d MMMM yyyy")
<span style="color:Blue; Dim row <span style="color:Blue; As DataRow = <span style="color:Blue; Nothing
<span style="color:Blue; Dim DS <span style="color:Blue; As <span style="color:Blue; New DataSet
<span style="color:Green; ADD A TABLE TO THE DATASET
DS.Tables.Add(<span style="color:#A31515; "individual_dtr")
<span style="color:Green; ADD THE COLUMNS TO THE TABLE
<span style="color:Blue; With DS.Tables(0).Columns
.Add(<span style="color:#A31515; "employee_id", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "name", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "position", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "date", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "shift_schedule", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "time_in", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "break_in", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "break_out", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "time_out", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))<br/> .Add(<span style="color:#A31515; "total_work", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))<br/> <span style="color:Blue; End <span style="color:Blue; With
<span style="color:Blue; Dim sSQL <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim i <span style="color:Blue; As <span style="color:Blue; Integer
<span style="color:Green; LOOP THE LISTVIEW AND ADD A ROW TO THE TABLE FOR EACH LISTVIEWITEM
<span style="color:Blue; For i = 0 <span style="color:Blue; To frmRefIndividualDTR.lsvIndividualDTR.SelectedItems.<span style="color:Blue; Count - 1
<span style="color:Blue; Dim current <span style="color:Blue; As DateTime = dtFromDate
<span style="color:Blue; While current <= dtToDate
sSQL = <span style="color:#A31515; "SELECT * FROM ((((pr_employees LEFT OUTER JOIN"
sSQL += <span style="color:#A31515; " pr_employees_other_info ON pr_employees.employee_id = pr_employees_other_info.employee_id)"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_department ON pr_employees_other_info.department_id = pr_department.department_id)"
sSQL += <span style="color:#A31515; " INNER JOIN (SELECT * FROM pr_timecard WHERE (current_date_transaction = #" & Format(current, <span style="color:#A31515; "yyyy/MM/dd") & <span style="color:#A31515; "# AND employee_id = " & frmRefIndividualDTR.lsvIndividualDTR.SelectedItems(i).Text & <span style="color:#A31515; ")) AS Q1 ON (pr_employees.employee_id = Q1.employee_id))"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_shift_scheduled ON pr_employees.shift_id = pr_shift_scheduled.shift_id)"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_timecard_break ON Q1.current_date_transaction = pr_timecard_break.current_date_transaction"
ReadSQL(sSQL)
<span style="color:Blue; If reader.HasRows <span style="color:Blue; Then
reader.Read()
row = DS.Tables(0).NewRow
row(0) = RVI(reader(<span style="color:#A31515; "pr_employees.employee_id"))
row(1) = RVS(reader(<span style="color:#A31515; "last_name")) & <span style="color:#A31515; ", " & RVS(reader(<span style="color:#A31515; "middle_name")) & <span style="color:#A31515; ", " & RVS(reader(<span style="color:#A31515; "first_name"))
row(2) = RVS(reader(<span style="color:#A31515; "position_desired")) & <span style="color:#A31515; " / " & RVS(reader(<span style="color:#A31515; "department_type"))
row(3) = RVS(reader(<span style="color:#A31515; "current_transaction"))
row(4) = RVS(reader(<span style="color:#A31515; "start_time")).Substring(0, 5) & <span style="color:#A31515; "-" & RVS(reader(<span style="color:#A31515; "end_time")).Substring(0, 5)
row(5) = RVS(reader(<span style="color:#A31515; "time_in"))
row(6) = RVS(reader(<span style="color:#A31515; "break_in"))
row(7) = RVS(reader(<span style="color:#A31515; "break_out"))
row(8) = RVS(reader(<span style="color:#A31515; "time_out"))<br/> row(9) = RVS(reader(<span style="color:#A31515; "total_work"))<br/> DS.Tables(0).Rows.Add(row)
<span style="color:Blue; Else
row = DS.Tables(0).NewRow
row(3) = Format(current, <span style="color:#A31515; "d MMMM-ddd")
row(4) = <span style="color:#A31515; ""
row(5) = <span style="color:#A31515; ""
row(6) = <span style="color:#A31515; ""
row(7) = <span style="color:#A31515; ""
row(8) = <span style="color:#A31515; ""<br/> row(9) = <span style="color:#A31515; "" <br/> DS.Tables(0).Rows.Add(row)
<span style="color:Blue; End <span style="color:Blue; If
current = current.AddDays(1)
<span style="color:Blue; End <span style="color:Blue; While
<span style="color:Blue; Next
myRpt.SetDataSource(DS)
CrystalReportViewer1.ReportSource = myRpt
CrystalReportViewer1.Refresh()
<span style="color:Green; DISPOSE OF THE DATASET
DS.Dispose()
DS = <span style="color:Blue; Nothing
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
<br/>
<br/>
View the full article
I have list of names in list view with corresponding unique employee id. The user could select more rows. In each employee id I will find it in database in retrieve all the details information and print it using crystal report. What I want is in each employee
id it will print in separate pages.
Currently using my code, the records of other employee id will append on the current page instead to print in another page with new header and footer.
Any help would greatly appreciated
Thanks in advance
Please see this link of my crystal report designer http://www.shopgruppo.com/dchallenger/crystal-report.jpg
Below code is my form with crystalreportviewer
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub frmIndividualDTRPrint_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load
<span style="color:Blue; Dim frmRefIndividualDTR <span style="color:Blue; As frmIndividualDTR = <span style="color:Blue; DirectCast(frmMain.ActiveMdiChild, frmIndividualDTR)
<span style="color:Blue; Dim dtFromDate <span style="color:Blue; As DateTime = frmRefIndividualDTR.dtpFromDate.Text
<span style="color:Blue; Dim dtToDate <span style="color:Blue; As DateTime = frmRefIndividualDTR.dtpToDate.Text
<span style="color:Blue; Dim myRpt <span style="color:Blue; As <span style="color:Blue; New IndividualDTRReport
<span style="color:Blue; Dim txtHeader <span style="color:Blue; As CrystalDecisions.CrystalReports.Engine.TextObject = myRpt.Section2.ReportObjects(<span style="color:#A31515; "txtHeader")
txtHeader.Text = <span style="color:#A31515; "No Bia Inc. Timecard Report"
<span style="color:Blue; Dim txtDateNow <span style="color:Blue; As CrystalDecisions.CrystalReports.Engine.TextObject = myRpt.Section2.ReportObjects(<span style="color:#A31515; "txtDateNow")
txtDateNow.Text = <span style="color:#A31515; "Period Covered " & Format(dtFromDate, <span style="color:#A31515; "d MMMM yyyy") & <span style="color:#A31515; " - " & Format(dtToDate, <span style="color:#A31515; "d MMMM yyyy")
<span style="color:Blue; Dim row <span style="color:Blue; As DataRow = <span style="color:Blue; Nothing
<span style="color:Blue; Dim DS <span style="color:Blue; As <span style="color:Blue; New DataSet
<span style="color:Green; ADD A TABLE TO THE DATASET
DS.Tables.Add(<span style="color:#A31515; "individual_dtr")
<span style="color:Green; ADD THE COLUMNS TO THE TABLE
<span style="color:Blue; With DS.Tables(0).Columns
.Add(<span style="color:#A31515; "employee_id", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "name", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "position", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "date", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "shift_schedule", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "time_in", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "break_in", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "break_out", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))
.Add(<span style="color:#A31515; "time_out", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))<br/> .Add(<span style="color:#A31515; "total_work", Type.<span style="color:Blue; GetType(<span style="color:#A31515; "System.String"))<br/> <span style="color:Blue; End <span style="color:Blue; With
<span style="color:Blue; Dim sSQL <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim i <span style="color:Blue; As <span style="color:Blue; Integer
<span style="color:Green; LOOP THE LISTVIEW AND ADD A ROW TO THE TABLE FOR EACH LISTVIEWITEM
<span style="color:Blue; For i = 0 <span style="color:Blue; To frmRefIndividualDTR.lsvIndividualDTR.SelectedItems.<span style="color:Blue; Count - 1
<span style="color:Blue; Dim current <span style="color:Blue; As DateTime = dtFromDate
<span style="color:Blue; While current <= dtToDate
sSQL = <span style="color:#A31515; "SELECT * FROM ((((pr_employees LEFT OUTER JOIN"
sSQL += <span style="color:#A31515; " pr_employees_other_info ON pr_employees.employee_id = pr_employees_other_info.employee_id)"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_department ON pr_employees_other_info.department_id = pr_department.department_id)"
sSQL += <span style="color:#A31515; " INNER JOIN (SELECT * FROM pr_timecard WHERE (current_date_transaction = #" & Format(current, <span style="color:#A31515; "yyyy/MM/dd") & <span style="color:#A31515; "# AND employee_id = " & frmRefIndividualDTR.lsvIndividualDTR.SelectedItems(i).Text & <span style="color:#A31515; ")) AS Q1 ON (pr_employees.employee_id = Q1.employee_id))"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_shift_scheduled ON pr_employees.shift_id = pr_shift_scheduled.shift_id)"
sSQL += <span style="color:#A31515; " LEFT OUTER JOIN pr_timecard_break ON Q1.current_date_transaction = pr_timecard_break.current_date_transaction"
ReadSQL(sSQL)
<span style="color:Blue; If reader.HasRows <span style="color:Blue; Then
reader.Read()
row = DS.Tables(0).NewRow
row(0) = RVI(reader(<span style="color:#A31515; "pr_employees.employee_id"))
row(1) = RVS(reader(<span style="color:#A31515; "last_name")) & <span style="color:#A31515; ", " & RVS(reader(<span style="color:#A31515; "middle_name")) & <span style="color:#A31515; ", " & RVS(reader(<span style="color:#A31515; "first_name"))
row(2) = RVS(reader(<span style="color:#A31515; "position_desired")) & <span style="color:#A31515; " / " & RVS(reader(<span style="color:#A31515; "department_type"))
row(3) = RVS(reader(<span style="color:#A31515; "current_transaction"))
row(4) = RVS(reader(<span style="color:#A31515; "start_time")).Substring(0, 5) & <span style="color:#A31515; "-" & RVS(reader(<span style="color:#A31515; "end_time")).Substring(0, 5)
row(5) = RVS(reader(<span style="color:#A31515; "time_in"))
row(6) = RVS(reader(<span style="color:#A31515; "break_in"))
row(7) = RVS(reader(<span style="color:#A31515; "break_out"))
row(8) = RVS(reader(<span style="color:#A31515; "time_out"))<br/> row(9) = RVS(reader(<span style="color:#A31515; "total_work"))<br/> DS.Tables(0).Rows.Add(row)
<span style="color:Blue; Else
row = DS.Tables(0).NewRow
row(3) = Format(current, <span style="color:#A31515; "d MMMM-ddd")
row(4) = <span style="color:#A31515; ""
row(5) = <span style="color:#A31515; ""
row(6) = <span style="color:#A31515; ""
row(7) = <span style="color:#A31515; ""
row(8) = <span style="color:#A31515; ""<br/> row(9) = <span style="color:#A31515; "" <br/> DS.Tables(0).Rows.Add(row)
<span style="color:Blue; End <span style="color:Blue; If
current = current.AddDays(1)
<span style="color:Blue; End <span style="color:Blue; While
<span style="color:Blue; Next
myRpt.SetDataSource(DS)
CrystalReportViewer1.ReportSource = myRpt
CrystalReportViewer1.Refresh()
<span style="color:Green; DISPOSE OF THE DATASET
DS.Dispose()
DS = <span style="color:Blue; Nothing
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
<br/>
<br/>
View the full article