home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
rptDailySchedule.aspx.vb
< prev
next >
Wrap
Text File
|
2010-09-11
|
14KB
|
275 lines
Imports System.Data
Imports System.Data.OleDb
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports System.Web.UI
Public Class rptDailySchedule
Inherits AspNetMaker7_tfpssnet
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
'Groups for header elements
Private m_objPageHeader As Group = New Group
'Groups for footer elements
Private m_objPageFooter As Group = New Group
'Page Dimensions of pages
Private Shared s_objPageDimensions As PageDimensions = New PageDimensions(PageSize.Letter, PageOrientation.Portrait, 54.0F)
'Current page that elements are being added to
Private m_objCurrentPage As ceTe.DynamicPDF.Page
'Top Y coordinate for the body of the report
Private m_fltBodyTop As Single = 80
'Bottom Y coordinate for the body of the report
Private m_fltBodyBottom As Single = s_objPageDimensions.Body.Bottom - s_objPageDimensions.Body.Top
'Current Y coordinate where elements are being added
Private m_fltCurrentY As Single
'Used to control the alternating background
Private m_blnAlternateBG As Boolean
Private sStartDate As String, sEndDate As String, tmpCount As Long, SortOption As Long, sEmployeeID As Long
Private sEmployeeName As String, tmpLastDate As String, tmpLastEvent As Long = 999999999
Private tmpEventTotalMinutes As Long, tmpDayTotalMinutes As Long, tmpEmpCount As Long
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sStartDate = Session("tmpStartDate")
sEndDate = Session("tmpEndDate")
'Create a document and set it's properties
Dim objDocument As Document = New Document
objDocument.Creator = "rptDailySchedule.aspx"
objDocument.Author = "Tony L. Clayton"
objDocument.Title = "PSS Daily Schedule Report"
objDocument.InitialPageZoom = PageZoom.FitWidth
'Adds elements to the header groups
SetPageHeader()
SetPageFooter()
'Establises connection to the database
Dim objconnection As OleDbConnection = GetOpenDBConn()
Dim objData As OleDbDataReader = GetData(objconnection)
'Builds the report
BuildDocument(objDocument, objData)
'Cleans up database connections
objData.Close()
objconnection.Close()
'Outputs the SimpleReport to the current web page
objDocument.DrawToWeb("rptDailySchedule.pdf")
Response.End()
End Sub
Private Sub SetPageHeader()
'Adds elements to the header group
With m_objPageHeader
.Add(New Image(Server.MapPath("images\logo.png"), 0, 0, 0.7F))
.Add(New Image(Server.MapPath("images\logo.png"), 405, 0, 0.7F))
.Add(New Label("P R O D U C T I O N S E R V I C E S S C H E D U L I N G S Y S T E M", 0, 0, 504, 10, Font.HelveticaBold, 8, TextAlign.Center))
.Add(New Label("Daily Schedule Report", 0, 12, 504, 16, Font.HelveticaBold, 16, TextAlign.Center))
.Add(New Label("As of " & ew_FormatDateTime(Now(), vbLongDate), 0, 30, 504, 9, Font.HelveticaBold, 9, TextAlign.Center))
.Add(New Label("From " & ew_FormatDateTime(sStartDate, vbShortDate) & " through " & ew_FormatDateTime(sEndDate, vbShortDate), 0, 40, 504, 9, Font.HelveticaBold, 9, TextAlign.Left))
.Add(New Label("Event Name", 5, 58, 120, 9, Font.TimesBold, 9))
.Add(New Label("Part Name", 120, 58, 120, 9, Font.TimesBold, 9))
.Add(New Label("Actual", 375, 58, 120, 9, Font.TimesBold, 9))
.Add(New Label("Actual", 425, 58, 120, 9, Font.TimesBold, 9))
.Add(New Label("Employee Name", 20, 68, 100, 9, Font.TimesBold, 9))
.Add(New Label("Position", 125, 68, 120, 9, Font.TimesBold, 9))
.Add(New Label("Location", 200, 60, 120, 9, Font.TimesBold, 9))
.Add(New Label("Start", 378, 68, 120, 9, Font.TimesBold, 9))
.Add(New Label("End", 430, 68, 120, 9, Font.TimesBold, 9))
.Add(New Label("Total", 480, 68, 120, 9, Font.TimesBold, 9))
m_objPageHeader.Add(New Line(0, 80, 504, 80))
End With
End Sub
Private Sub SetPageFooter()
'Adds elements to the footer group
Dim objLabel As PageNumberingLabel = New PageNumberingLabel("Page %%CP%% of %%TP%%", 0, 692, 504, 8, Font.HelveticaBold, 8, TextAlign.Right)
'objLabel.HasPageNumbering = True
m_objPageFooter.Add(objLabel)
End Sub
Private Sub AddNewPage(ByVal document As Document)
'Adds a new page to the document
m_objCurrentPage = New ceTe.DynamicPDF.Page(s_objPageDimensions)
m_objCurrentPage.Elements.Add(m_objPageHeader)
m_objCurrentPage.Elements.Add(m_objPageFooter)
'Uncomment the line below to add a layout grid to the each page
'm_objCurrentPage.Elements.Add(New LayoutGrid)
m_fltCurrentY = m_fltBodyTop
m_blnAlternateBG = False
document.Pages.Add(m_objCurrentPage)
End Sub
Private Sub BuildDocument(ByVal document As Document, ByVal data As OleDbDataReader)
'Builds the PDF document with data from the DataReader
AddNewPage(document)
While data.Read()
'Add current record to the document
AddRecord(document, data)
End While
PrintTotals(document)
End Sub
Private Sub AddRecord(ByVal document As Document, ByVal data As OleDbDataReader)
Dim intReqHeight As Integer, tmpTime As Long, tmpHours As String, tmpMinutes As String
intReqHeight = 9
'Adds a new page to the document if needed
If m_fltCurrentY > m_fltBodyBottom - 20 Then AddNewPage(document)
If tmpLastEvent <> data("evtID") Or data("schDate") <> tmpLastDate Then
If tmpLastEvent <> 999999999 Then
' m_objPageHeader.Add(New Line(400, m_fltCurrentY, 450, m_fltCurrentY))
m_objCurrentPage.Elements.Add(New TextArea(FormatNumber(tmpEmpCount, 0, -2, -2, -2) & " Employee(s)", 150, m_fltCurrentY, 100, intReqHeight, Font.TimesRoman, 10))
m_objCurrentPage.Elements.Add(New TextArea("Total: ", 400, m_fltCurrentY, 100, intReqHeight, Font.TimesBold, 10))
m_objCurrentPage.Elements.Add(New TextArea(Int(tmpEventTotalMinutes / 60) & ":" & Int(tmpEventTotalMinutes Mod 60).ToString.PadLeft(2, "0"), 480, m_fltCurrentY, 100, intReqHeight, Font.TimesBold, 10))
tmpEmpCount = 0
tmpEventTotalMinutes = 0
m_fltCurrentY += intReqHeight + 2
End If
End If
If data("schDate") <> tmpLastDate Then
If tmpLastDate <> "" Then
m_objCurrentPage.Elements.Add(New TextArea("Shift Total: ", 377, m_fltCurrentY, 100, intReqHeight, Font.TimesBold, 10))
m_objCurrentPage.Elements.Add(New TextArea(Int(tmpDayTotalMinutes / 60) & ":" & Int(tmpDayTotalMinutes Mod 60).ToString.PadLeft(2, "0"), 480, m_fltCurrentY, 100, intReqHeight, Font.TimesBold, 10))
tmpDayTotalMinutes = 0
m_fltCurrentY += intReqHeight + 2
End If
m_fltCurrentY += 5
m_objCurrentPage.Elements.Add(New Rectangle(0, m_fltCurrentY, 200, (intReqHeight + 6), Grayscale.Black, New WebColor("000000"), 0.0F))
m_objCurrentPage.Elements.Add(New TextArea(FormatDateTime(data("schDate"), DateFormat.LongDate), 1, m_fltCurrentY, 200, 12, Font.TimesBold, 12, TextAlign.Center, RgbColor.White))
m_fltCurrentY += intReqHeight + 12
End If
tmpLastDate = data("schDate")
If tmpLastEvent <> data("evtID") Then
If Not IsDBNull(data("evtDescription")) Then
m_objCurrentPage.Elements.Add(New TextArea(data("evtDescription"), 5, m_fltCurrentY, 120, intReqHeight, Font.TimesBold, 10))
End If
If Not IsDBNull(data("prtDescription")) Then
m_objCurrentPage.Elements.Add(New TextArea(data("prtDescription"), 120, m_fltCurrentY, 100, intReqHeight, Font.TimesBold, 10))
End If
m_fltCurrentY += intReqHeight + 2
m_blnAlternateBG = True
End If
tmpLastEvent = data("evtID")
'Adds alternating background to document if needed
If m_blnAlternateBG Then
m_objCurrentPage.Elements.Add(New Rectangle(0, m_fltCurrentY, 504, (intReqHeight + 2), Grayscale.Black, New WebColor("E0E0FF"), 0.0F))
End If
'Adds Textarea elements to the document with data from current record
If Not IsDBNull(data("empName")) Then
m_objCurrentPage.Elements.Add(New TextArea(data("empName"), 20, m_fltCurrentY, 100, intReqHeight, Font.TimesRoman, 10))
End If
If Not IsDBNull(data("posDescription")) Then
m_objCurrentPage.Elements.Add(New TextArea(data("posDescription"), 125, m_fltCurrentY, 65, intReqHeight, Font.TimesRoman, 10))
End If
If Not IsDBNull(data("locDescription")) Then
m_objCurrentPage.Elements.Add(New TextArea(data("locDescription"), 200, m_fltCurrentY, 175, intReqHeight, Font.TimesRoman, 10))
End If
If Not IsDBNull(data("schActualStart")) Then
m_objCurrentPage.Elements.Add(New TextArea(ew_FormatDateTime(data("schActualStart"), 14), 375, m_fltCurrentY, 50, intReqHeight, Font.TimesRoman, 10))
End If
If Not IsDBNull(data("schActualEnd")) Then
m_objCurrentPage.Elements.Add(New TextArea(ew_FormatDateTime(data("schActualEnd"), 14), 425, m_fltCurrentY, 50, intReqHeight, Font.TimesRoman, 10))
End If
If Not IsDBNull(data("schActualStart")) And Not IsDBNull(data("schActualEnd")) Then
tmpTime = DateDiff(DateInterval.Minute, data("schActualStart"), data("schActualEnd"))
tmpHours = Int(tmpTime / 60)
tmpMinutes = Int(tmpTime Mod 60)
m_objCurrentPage.Elements.Add(New TextArea(tmpHours & ":" & tmpMinutes.ToString.PadLeft(2, "0"), 480, m_fltCurrentY, 50, intReqHeight, Font.TimesRoman, 10))
tmpEventTotalMinutes = tmpEventTotalMinutes + tmpMinutes + (tmpHours * 60)
tmpDayTotalMinutes = tmpDayTotalMinutes + tmpMinutes + (tmpHours * 60)
End If
tmpEmpCount += 1
tmpCount += 1
'Toggles alternating background
m_blnAlternateBG = Not m_blnAlternateBG
'Increments the current Y position on the page
m_fltCurrentY += intReqHeight + 2
End Sub
Private Function GetOpenDBConn() As OleDbConnection
'Creates and opens a database connection
Dim sConnStr As String = EW_DB_CONNECTION_STRING
Dim objConnection As New OleDbConnection(sConnStr)
objConnection.Open()
Return objConnection
End Function
Private Function GetData(ByVal connection As OleDbConnection) As OleDbDataReader
'Creates a DataReader for the report
Dim strSQL As String
Dim objCommand As OleDbCommand = connection.CreateCommand()
strSQL = "SELECT tblSchedule.schSchID, tblSchedule.schDate, tblEvents.evtDescription, tblParts.prtDescription, " _
& "tblLocations.locDescription, tblEmployees.empName, tblEmployees.empLastName, tblPositions.posDescription, " _
& "tblSchedule.schActualStart, tblSchedule.schActualEnd, tblEvents.evtID " _
& "FROM tblPositions RIGHT JOIN (tblParts RIGHT JOIN (tblLocations RIGHT JOIN (tblEvents " _
& "RIGHT JOIN (tblEmployees INNER JOIN tblSchedule ON tblEmployees.empID = tblSchedule.schEmpID) " _
& "ON tblEvents.evtID = tblSchedule.schEvtID) ON tblLocations.locID = tblSchedule.schLocID) ON tblParts.prtID = " _
& "tblSchedule.schPartsID) ON tblPositions.posID = tblSchedule.schPosID WHERE "
If Not IsDBNull(sStartDate) Then
strSQL = strSQL & "(schDate >= #" & sStartDate & "#) "
End If
If Not IsDBNull(sEndDate) Then
If Not IsDBNull(sEndDate) Then
strSQL = strSQL & " AND "
End If
strSQL = strSQL & "(schDate <= #" & sEndDate & "#) "
End If
strSQL = strSQL & "ORDER BY tblSchedule.schDate, tblEvents.evtDescription, tblParts.prtDescription, tblLocations.locDescription, " _
& "tblEmployees.empLastName, tblSchedule.schActualStart"
Session("strSQL") = strSQL
objCommand.CommandText = strSQL
Dim objDataReader As OleDbDataReader = objCommand.ExecuteReader()
Return objDataReader
End Function
Private Sub PrintTotals(ByVal document As Document)
m_objCurrentPage.Elements.Add(New TextArea(FormatNumber(tmpEmpCount, 0, -2, -2, -2) & " Employee(s)", 150, m_fltCurrentY, 100, 10, Font.TimesRoman, 10))
m_objCurrentPage.Elements.Add(New TextArea("Total: ", 400, m_fltCurrentY, 100, 10, Font.TimesBold, 10))
m_objCurrentPage.Elements.Add(New TextArea(Int(tmpEventTotalMinutes / 60) & ":" & Int(tmpEventTotalMinutes Mod 60).ToString.PadLeft(2, "0"), 480, m_fltCurrentY, 100, 10, Font.TimesBold, 10))
tmpEventTotalMinutes = 0
m_fltCurrentY += 10 + 2
m_blnAlternateBG = Not m_blnAlternateBG
m_objCurrentPage.Elements.Add(New TextArea("Shift Total: ", 377, m_fltCurrentY, 100, 10, Font.TimesBold, 10))
m_objCurrentPage.Elements.Add(New TextArea(Int(tmpDayTotalMinutes / 60) & ":" & Int(tmpDayTotalMinutes Mod 60).ToString.PadLeft(2, "0"), 480, m_fltCurrentY, 100, 10, Font.TimesBold, 10))
tmpDayTotalMinutes = 0
m_fltCurrentY += 10 + 2
m_blnAlternateBG = Not m_blnAlternateBG
End Sub
End Class