Click here to Skip to main content
15,885,309 members
Articles / Containers / Virtual Machine

ASP.NET Report Kit Grasshoper (Race to Linux)

Rate me:
Please Sign up or sign in to vote.
2.38/5 (5 votes)
2 Oct 20057 min read 37.9K   397   19  
Porting and deploying the report starter kit to Linux (RH7.3/Tomcat5.0.28/Grasshoper1.61)
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
<font color= "blue">Imports</font> System
<font color= "blue">Imports</font> System.Web.UI.WebControls
<font color= "blue">Imports</font> ASPNET.StarterKit.Reports.Components
<font color= "blue"></font>
<font color= "blue">Namespace</font> ASPNET.StarterKit.Reports
<font color= "blue"></font>
<font color= "green">    '*********************************************************************</font>
<font color= "green">    '</font>
<font color= "green">    ' CrossTab.aspx</font>
<font color= "green">    '</font>
<font color= "green">    ' The CrossTab.aspx page shows quarterly breakdown of sales based on the region.</font>
<font color= "green">    ' It also displays the totals for each region, the totals for each month within the quarter,</font>
<font color= "green">    ' and the total for the whole quarter.</font>
<font color= "green">    '</font>
<font color= "green">    '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    Public Class</font> CrossTab
<font color= "blue">        Inherits</font> System.Web.UI.Page
<font color= "blue">        Protected </font>PrintButton <font color= "blue">As </font>System.Web.UI.WebControls.HyperLink
<font color= "blue">        Protected </font>QuartersList <font color= "blue">As </font>System.Web.UI.WebControls.DataList
<font color= "blue">        Protected </font>WithEvents <font color= "blue"></font>YearDropDownList As System.Web.UI.WebControls.DropDownList
<font color= "blue">        Private </font>_eastern <font color= "blue">As </font>Double = 0
<font color= "blue">        Private </font>_western <font color= "blue">As </font>Double = 0
<font color= "blue">        Private </font>_southern <font color= "blue">As </font>Double = 0
<font color= "blue">        Private </font>_northern <font color= "blue">As </font>Double = 0
<font color= "blue">        Private </font>_totals <font color= "blue">As </font>Double = 0
<font color= "blue">        Protected </font>_styleSheet <font color= "blue">As </font>String
<font color= "blue"></font>
<font color= "blue"></font>#Region " Web Form Designer Generated Code "
<font color= "blue"></font>
<font color= "green">        'This call is required by the Web Form Designer.</font>
<font color= "blue">        </font><System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
<font color= "blue"></font>
<font color= "blue">        End Sub</font>
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
<font color= "green">            'CODEGEN: This method call is required by the Web Form Designer</font>
<font color= "green">            'Do not modify it using the code editor.</font>
<font color= "blue">            </font>InitializeComponent()
<font color= "blue">        End Sub</font>
<font color= "blue"></font>
<font color= "blue"></font>#End Region
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
<font color= "blue"></font><font color= "blue">            If </font>Not IsPostBack <font color= "blue">Then</font>
<font color= "blue">                </font>BindList()
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue"></font>
<font color= "green">            ' switches the style sheet based on printer friendly view or not</font>
<font color= "blue"></font><font color= "blue">            If </font>Request.QueryString("Print") = "true" <font color= "blue">Then</font>
<font color= "blue">                </font>_styleSheet <font color= "blue"></font>= "stylesPrint.css"
<font color= "blue">                </font>PrintButton.Visible = True
<font color= "blue"></font><font color= "blue">            Else</font><font color= "blue"></font>
<font color= "blue">                </font>_styleSheet <font color= "blue"></font>= "styles.css"
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue">        End Sub</font><font color= "green"> 'Page_Load</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The BindList method simply binds the Datalist with the four quarters</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> BindList()
<font color= "blue">            </font>QuartersList.DataSource = New Integer(3) {1, 2, 3, 4}
<font color= "blue">            </font>QuartersList.DataBind()
<font color= "blue">        End Sub</font><font color= "green"> 'BindList</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The GetQuarterDetails method is set as the DataSource of the inner datagrid.</font>
<font color= "green">        ' As the QuartsList is being data-bound, this populates the inner datagrids for the quarters.</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Function</font> GetQuarterDetails(ByVal quarter As Integer) As CrossTabReportCollection
<font color= "blue">            </font>Return <font color= "blue"></font>CrossTabReport.GetRegionSales(quarter, Convert.ToInt32(YearDropDownList.SelectedItem.Value))
<font color= "blue"></font><font color= "blue">        End Function</font><font color= "blue"></font><font color= "green"> 'GetQuarterDetails</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The SumItems event handler is for the OnItemDataBound event of the datagrids for each quarter.</font>
<font color= "green">        ' It adds running totals for each region for a particular quarter.</font>
<font color= "green">        ' It also adds the sum totals fo the regions of the quarter as well.</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Sub</font> SumItems(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
<font color= "green">            ' sum up the data in the columns as the datagrid is databinding</font>
<font color= "blue"></font><font color= "blue">            If </font>e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem <font color= "blue">Then</font>
<font color= "green">                ' get the sales value for eastern region</font>
<font color= "blue">                Dim </font>eastern <font color= "blue">As </font>Double = Convert.ToDouble(e.Item.Cells(1).Text)
<font color= "green">                ' add sales value to the running total</font>
<font color= "blue">                </font>_eastern <font color= "blue"></font>+= eastern
<font color= "green">                ' format to display sales value as currency</font>
<font color= "blue">                </font>e.Item.Cells(1).Text = String.Format("{0:c}", eastern)
<font color= "blue"></font>
<font color= "blue">                Dim </font>western <font color= "blue">As </font>Double = Convert.ToDouble(e.Item.Cells(2).Text)
<font color= "blue">                </font>_western <font color= "blue"></font>+= western
<font color= "blue">                </font>e.Item.Cells(2).Text = String.Format("{0:c}", western)
<font color= "blue"></font>
<font color= "blue">                Dim </font>southern <font color= "blue">As </font>Double = Convert.ToDouble(e.Item.Cells(3).Text)
<font color= "blue">                </font>_southern <font color= "blue"></font>+= southern
<font color= "blue">                </font>e.Item.Cells(3).Text = String.Format("{0:c}", southern)
<font color= "blue"></font>
<font color= "blue">                Dim </font>northern <font color= "blue">As </font>Double = Convert.ToDouble(e.Item.Cells(4).Text)
<font color= "blue">                </font>_northern <font color= "blue"></font>+= northern
<font color= "blue">                </font>e.Item.Cells(4).Text = String.Format("{0:c}", northern)
<font color= "blue"></font>
<font color= "blue">                Dim </font>totals <font color= "blue">As </font>Double = Convert.ToDouble(e.Item.Cells(5).Text)
<font color= "blue">                </font>_totals <font color= "blue"></font>+= totals
<font color= "blue">                </font>e.Item.Cells(5).Text = String.Format("{0:c}", totals)
<font color= "blue"></font><font color= "blue">            Else</font><font color= "blue"></font>
<font color= "blue"></font><font color= "blue">                If </font>e.Item.ItemType = ListItemType.Footer <font color= "blue">Then</font>
<font color= "green">                    ' display our summations in footer</font>
<font color= "blue">                    </font>e.Item.Cells(0).Text = "Totals"
<font color= "blue">                    </font>e.Item.Cells(0).HorizontalAlign = HorizontalAlign.Left
<font color= "blue">                    </font>e.Item.Cells(1).Text = String.Format("{0:c}", _eastern)
<font color= "blue">                    </font>e.Item.Cells(2).Text = String.Format("{0:c}", _western)
<font color= "blue">                    </font>e.Item.Cells(3).Text = String.Format("{0:c}", _southern)
<font color= "blue">                    </font>e.Item.Cells(4).Text = String.Format("{0:c}", _northern)
<font color= "blue">                    </font>e.Item.Cells(5).Text = String.Format("{0:c}", _totals)
<font color= "blue"></font>
<font color= "green">                    ' reset the running totals for next datagrid</font>
<font color= "blue">                    </font>_eastern <font color= "blue"></font>= 0
<font color= "blue">                    </font>_western <font color= "blue"></font>= 0
<font color= "blue">                    </font>_southern <font color= "blue"></font>= 0
<font color= "blue">                    </font>_northern <font color= "blue"></font>= 0
<font color= "blue">                    </font>_totals <font color= "blue"></font>= 0
<font color= "blue"></font><font color= "blue">                End If</font><font color= "blue"></font>
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue">        End Sub</font><font color= "green"> 'SumItems</font>
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> YearDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles YearDropDownList.SelectedIndexChanged
<font color= "blue">            </font>BindList()
<font color= "blue">        End Sub</font><font color= "green"> 'YearDropDownList_SelectedIndexChanged</font>
<font color= "blue"></font><font color= "blue">    End Class</font><font color= "blue"></font><font color= "green"> 'CrossTab</font>
<font color= "blue"></font><font color= "blue">End Namespace</font><font color= "blue"></font><font color= "green"> 'ASPNET.StarterKit.Reports</font>
</pre>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
I love to code! Working in C# is my passion, visit my github

Comments and Discussions