Imports OASIS.BusinessLogicLayer
Public Class Rpt_MioTVOrders_TeamLeader_FTA1
Inherits System.Web.UI.Page
....
Dim _dealer As String = ""
Dim _nric As String = ""
Dim _month, _year As Integer
Dim myNewTable As New DataTable
Dim headerList As String() = {"S/N", _
"Name", _
"FTA Orders", _
"Incentive Amount $"}
Dim columnList As String() = {"SN", "Name", "FTAOrders", "IncentiveAmount"}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If (Not IsDBNull(Request.Params("Dealer")) And Not IsDBNull(Request.Params("Month")) And Not IsDBNull(Request.Params("Year"))) Then
_dealer = Request.Params("Dealer")
_month = Request.Params("Month")
_year = Request.Params("Year")
lblErrMsg.Text = ""
PopulateDataGrid()
If Request.Params("Action") = "PRINT" Then
Response.Write("<script language=javascript>")
Response.Write("alert('Please set your printer orientation to Landscape');")
Response.Write("window.print();")
Response.Write("</script>")
End If
End If
End Sub
Function PopulateDataGrid()
Try
'--- Create DataColumn ---
Dim myDataColumn As DataColumn
Dim i As Integer = 0
For i = 0 To headerList.Length
If i = 0 Then
myDataColumn = New DataColumn("colType", GetType(System.String))
Else
myDataColumn = New DataColumn(columnList(i - 1), GetType(System.String))
End If
myNewTable.Columns.Add(myDataColumn)
Next
ShowReportHeader()
ShowHeader()
ShowOrders()
dgTeamLeaderFTA.DataSource = myNewTable
dgTeamLeaderFTA.DataBind()
Catch ex As Exception
lblErrMsg.Text = ex.Message
End Try
End Function
Function ShowReportHeader()
'--- Report Headers ---
Dim myNewRow_ReportHeader As DataRow = myNewTable.NewRow
myNewRow_ReportHeader("colType") = "REPORT_HEADER"
myNewRow_ReportHeader("Name") = "Team Leader FTA Orders for " & _month & "/" & _year
myNewRow_ReportHeader("Name") += "(" & _dealer & ")"
myNewTable.Rows.Add(myNewRow_ReportHeader)
End Function
Function ShowHeader()
'--Header--
Dim i As Integer = 0
Dim myNewRow_Header As DataRow = myNewTable.NewRow
For i = 0 To headerList.Length - 1
myNewRow_Header(columnList(i)) = headerList(i)
Next
myNewRow_Header("colType") = "HEADER"
myNewTable.Rows.Add(myNewRow_Header)
End Function
Function ShowOrders()
Dim myTable As DataTable
Dim myRow As DataRow
Dim iRowCount As Integer = 0
Dim OrdersTotal As Integer = 0
Dim IncentiveTotal As Integer = 0
myTable = Mioplan.GetMioTeamLeaderForFTA(_dealer, _month, _year)
For Each myRow In myTable.Rows
Dim myNewRow As DataRow = myNewTable.NewRow
myNewRow("SN") = myRow("SN")
myNewRow("Name") = myRow("Name")
myNewRow("FTAOrders") = myRow("FTAOrders")
myNewRow("IncentiveAmount") = "$" & myRow("IncentiveAmount")
myNewTable.Rows.Add(myNewRow)
Next
For Each myRow In myTable.Rows
OrdersTotal += myRow("FTAOrders")
IncentiveTotal += myRow("IncentiveAmount")
Next
Dim myNewRow_Total As DataRow = myNewTable.NewRow
myNewRow_Total("colType") = "OrdersTotal"
myNewRow_Total("Name") = "Total"
myNewRow_Total("FTAOrders") = OrdersTotal
myNewRow_Total("IncentiveAmount") = "$" & IncentiveTotal
myNewTable.Rows.Add(myNewRow_Total)
End Function
Private Sub dgTeamLeaderFTA_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgTeamLeaderFTA.ItemDataBound
'If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim i As Integer = 0
If Request.Params("Action") = "PRINT" Then
For i = 1 To headerList.Length
e.Item.Cells(i).Font.Size = FontUnit.Point(6)
e.Item.Cells(i).Font.Bold = True
Next
End If
Select Case e.Item.Cells(0).Text
Case "HEADER"
For i = 1 To headerList.Length
e.Item.Cells(i).Attributes.Add("align", "Center")
e.Item.Cells(i).Font.Bold = True
e.Item.Cells(i).BackColor = Color.FromArgb(CInt(&HB5C7DE))
Next
Case "REPORT_HEADER"
For i = 1 To headerList.Length
e.Item.Cells(i).Style.Add("BORDER", "none")
e.Item.Cells(i).BackColor = Color.Transparent
Next
e.Item.Cells(2).Font.Size = FontUnit.Medium
e.Item.Cells(2).Font.Underline = True
e.Item.Cells(2).ForeColor = Color.Black
e.Item.Cells(2).Attributes.Add("align", "Left")
e.Item.Cells(2).Font.Bold = True
e.Item.Cells(2).ColumnSpan = headerList.Length
e.Item.Cells.RemoveAt(1)
Case "OrdersTotal"
For i = 1 To headerList.Length
e.Item.Cells(i).Style.Add("BORDER", "none")
If i >= 2 Then
e.Item.Cells(i).BackColor = Color.Transparent
e.Item.Cells(i).Font.Underline = True
e.Item.Cells(i).ForeColor = Color.Black
e.Item.Cells(i).Font.Bold = True
End If
Next
End Select
End Sub
End Class