Go to Home Page

 

View Output

 

 

'MSSE Fairfield University

'SW403- Fall 2005

'Guillermo V. Julca

'http://www.gjp2s.com

 

Public Class frmMain

    Inherits System.Windows.Forms.Form

    Public blnRepaintChart As Boolean               'Global boolean variable to indicate if we want to repaint or not the chart(s)

    Dim blnIsAmericanCurrentCD As Boolean           'Global boolean variable to indicate if the American Express is the current selected credit card

    Dim blnIsVisaCurrentCD As Boolean               'Global boolean variable to indicate if the Visa is the current selected credit card

    Dim blnIsMasterCurrentCD As Boolean             'Global boolean variable to indicate if the Master is the current selected credit card

    Dim blnAreAllCurrentCD As Boolean               'Global boolean variable to indicate if all credit cards were selected or not

    Dim blnIsLineCurrentChart As Boolean            'Global boolean variable to indicate if the line chart is the current graph

    Dim blnIsBarCurrentChart As Boolean             'Global boolean variable to indicate if the bar chart is the current graph

    Dim sngXLabelSpacingForLineChart As Single      'Gaps among X-Axis labels

    Dim sngXLabelSpacingForBarChart As Single       'Gaps among Y-Axis labels

    Dim objAmericanCreditCard As CreditCardYear     'Global object belongs to the CreditCardYear class

    Dim objVisaCreditCard As CreditCardYear         'Global object belongs to the CreditCardYear class

    Dim objMasterCreditCard As CreditCardYear       'Global object belongs to the CreditCardYear class

    Dim sngBarWidth As Single                       'Bar width

    Dim sngFirstBarGap As Single                    'First Bar Gap

    Dim blnCurrentlyPaintingCharts As Boolean       'Global boolean variable to indicate if currently we are painting the Chart(s)

    Dim blnCurrentlyPaintingAxisLabels As Boolean   'Global boolean variable to indicate if currently we are painting the Axis Labels

    Dim sngFinalMax As Single                       'Maximun amount value(charge) for the credit card(s)

    Dim sngFinalMin As Single                       'Minimum amount value(charge) for the credit card(s)

    Dim strChartTitle As String                     'Chart Title

    Dim strInstructions As String                   'Global string variable to store the Instructions

 

    'Enumeration type for the months of the year

    Public Enum enuMonthsOfYear As Integer

        Jan = 1

        Feb = 2

        Mar = 3

        Apr = 4

        May = 5

        Jun = 6

        Jul = 7

        Aug = 8

        Sep = 9

        Oct = 10

        Nov = 11

        Dec = 12

    End Enum 'enuMonthsOfYear

 

    Public MonthsOfYear As enuMonthsOfYear

    'Credit card names

    Public Const AMERICAN_EXPRESS_NAME As String = "American Express Credit Card"

    Public Const VISA_NAME As String = "Visa Credit Card"

    Public Const MASTER_NAME As String = "Master Credit Card"

    Public Const ALL_CREDIT_CARDS_NAME As String = "All Credit Cards"

    'Credit cards currency

    Public Const AMERICAN_CURRENCY_USD As String = "USD"

    Public Const VISA_CURRENCY_USD As String = "USD"

    Public Const MASTER_CURRENCY_USD As String = "USD"

    'Title for Line/Bar Chart

    Public Const LINE_CHART_TITLE As String = " Line Chart - Monthly Charges for 2005"

    Public Const BAR_CHART_TITLE As String = " Bar Chart - Monthly Charges for 2005"

 

#Region " Windows Form Designer generated code "

 

    Public Sub New()

        MyBase.New()

 

        'This call is required by the Windows Form Designer.

        InitializeComponent()

 

        'Add any initialization after the InitializeComponent() call

 

    End Sub

 

    'Form overrides dispose to clean up the component list.

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

 

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    Friend WithEvents grdAmerican As System.Windows.Forms.DataGrid

    Friend WithEvents grdVisa As System.Windows.Forms.DataGrid

    Friend WithEvents grdMaster As System.Windows.Forms.DataGrid

    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

    Friend WithEvents mnuFile As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit_ShowAllCards As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit_ShowAmerican As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit_ShowVisa As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit_ShowMaster As System.Windows.Forms.MenuItem

    Friend WithEvents mnuFile_Exit As System.Windows.Forms.MenuItem

    Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem

    Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem

    Friend WithEvents mnuView As System.Windows.Forms.MenuItem

    Friend WithEvents mnuViewLineChart As System.Windows.Forms.MenuItem

    Friend WithEvents mnuViewBarChart As System.Windows.Forms.MenuItem

    Friend WithEvents cmuGraphicType As System.Windows.Forms.ContextMenu

    Friend WithEvents cmuLineChart As System.Windows.Forms.MenuItem

    Friend WithEvents cmuBarChat As System.Windows.Forms.MenuItem

    Friend WithEvents pnlAxisLabels As System.Windows.Forms.Panel

    Friend WithEvents pnlChartArea As System.Windows.Forms.Panel

    Friend WithEvents tbrMain As System.Windows.Forms.ToolBar

    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList

    Friend WithEvents tbrLineChart As System.Windows.Forms.ToolBarButton

    Friend WithEvents tbrBarChart As System.Windows.Forms.ToolBarButton

    Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton

    Friend WithEvents tbrDelete As System.Windows.Forms.ToolBarButton

    Friend WithEvents tbrHelp As System.Windows.Forms.ToolBarButton

    Friend WithEvents tbrExit As System.Windows.Forms.ToolBarButton

    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem

    Friend WithEvents mnuEdit_Delete As System.Windows.Forms.MenuItem

    Friend WithEvents lblInstructions As System.Windows.Forms.Label

    Friend WithEvents mnuHelp_Content As System.Windows.Forms.MenuItem

    Friend WithEvents mnuHelp_About As System.Windows.Forms.MenuItem

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.components = New System.ComponentModel.Container

        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmMain))

        Me.grdAmerican = New System.Windows.Forms.DataGrid

        Me.grdVisa = New System.Windows.Forms.DataGrid

        Me.grdMaster = New System.Windows.Forms.DataGrid

        Me.MainMenu1 = New System.Windows.Forms.MainMenu

        Me.mnuFile = New System.Windows.Forms.MenuItem

        Me.mnuFile_Exit = New System.Windows.Forms.MenuItem

        Me.mnuEdit = New System.Windows.Forms.MenuItem

        Me.mnuEdit_ShowAllCards = New System.Windows.Forms.MenuItem

        Me.MenuItem6 = New System.Windows.Forms.MenuItem

        Me.mnuEdit_ShowAmerican = New System.Windows.Forms.MenuItem

        Me.mnuEdit_ShowVisa = New System.Windows.Forms.MenuItem

        Me.mnuEdit_ShowMaster = New System.Windows.Forms.MenuItem

        Me.MenuItem1 = New System.Windows.Forms.MenuItem

        Me.mnuEdit_Delete = New System.Windows.Forms.MenuItem

        Me.mnuView = New System.Windows.Forms.MenuItem

        Me.mnuViewLineChart = New System.Windows.Forms.MenuItem

        Me.mnuViewBarChart = New System.Windows.Forms.MenuItem

        Me.MenuItem7 = New System.Windows.Forms.MenuItem

        Me.mnuHelp_Content = New System.Windows.Forms.MenuItem

        Me.mnuHelp_About = New System.Windows.Forms.MenuItem

        Me.pnlAxisLabels = New System.Windows.Forms.Panel

        Me.cmuGraphicType = New System.Windows.Forms.ContextMenu

        Me.cmuLineChart = New System.Windows.Forms.MenuItem

        Me.cmuBarChat = New System.Windows.Forms.MenuItem

        Me.pnlChartArea = New System.Windows.Forms.Panel

        Me.tbrMain = New System.Windows.Forms.ToolBar

        Me.tbrLineChart = New System.Windows.Forms.ToolBarButton

        Me.tbrBarChart = New System.Windows.Forms.ToolBarButton

        Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton

        Me.tbrDelete = New System.Windows.Forms.ToolBarButton

        Me.tbrHelp = New System.Windows.Forms.ToolBarButton

        Me.tbrExit = New System.Windows.Forms.ToolBarButton

        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)

        Me.lblInstructions = New System.Windows.Forms.Label

        CType(Me.grdAmerican, System.ComponentModel.ISupportInitialize).BeginInit()

        CType(Me.grdVisa, System.ComponentModel.ISupportInitialize).BeginInit()

        CType(Me.grdMaster, System.ComponentModel.ISupportInitialize).BeginInit()

        Me.pnlAxisLabels.SuspendLayout()

        Me.SuspendLayout()

        '

        'grdAmerican

        '

        Me.grdAmerican.CaptionBackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(255, Byte), CType(128, Byte))

        Me.grdAmerican.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle))

        Me.grdAmerican.CaptionForeColor = System.Drawing.SystemColors.ControlText

        Me.grdAmerican.CaptionText = "American Express   (USD Monthly Charges - Year 2005)"

        Me.grdAmerican.DataMember = ""

        Me.grdAmerican.GridLineColor = System.Drawing.SystemColors.ControlDark

        Me.grdAmerican.HeaderBackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(255, Byte), CType(128, Byte))

        Me.grdAmerican.HeaderForeColor = System.Drawing.SystemColors.ControlText

        Me.grdAmerican.Location = New System.Drawing.Point(32, 424)

        Me.grdAmerican.Name = "grdAmerican"

        Me.grdAmerican.Size = New System.Drawing.Size(696, 80)

        Me.grdAmerican.TabIndex = 0

        Me.grdAmerican.Visible = False

        '

        'grdVisa

        '

        Me.grdVisa.CaptionBackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(128, Byte), CType(255, Byte))

        Me.grdVisa.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle))

        Me.grdVisa.CaptionForeColor = System.Drawing.Color.White

        Me.grdVisa.CaptionText = "Visa Credit Card  (USD Monthly Charges - Year 2005)"

        Me.grdVisa.DataMember = ""

        Me.grdVisa.GridLineColor = System.Drawing.SystemColors.ControlDark

        Me.grdVisa.HeaderBackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(128, Byte), CType(255, Byte))

        Me.grdVisa.HeaderForeColor = System.Drawing.Color.White

        Me.grdVisa.Location = New System.Drawing.Point(32, 512)

        Me.grdVisa.Name = "grdVisa"

        Me.grdVisa.Size = New System.Drawing.Size(696, 80)

        Me.grdVisa.TabIndex = 1

        Me.grdVisa.Visible = False

        '

        'grdMaster

        '

        Me.grdMaster.CaptionBackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))

        Me.grdMaster.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle))

        Me.grdMaster.CaptionForeColor = System.Drawing.Color.Black

        Me.grdMaster.CaptionText = "Master Credit Card  (USD Monthly Charges - Year 2005)"

        Me.grdMaster.DataMember = ""

        Me.grdMaster.GridLineColor = System.Drawing.SystemColors.ControlDark

        Me.grdMaster.HeaderBackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))

        Me.grdMaster.HeaderForeColor = System.Drawing.SystemColors.ControlText

        Me.grdMaster.Location = New System.Drawing.Point(32, 600)

        Me.grdMaster.Name = "grdMaster"

        Me.grdMaster.Size = New System.Drawing.Size(696, 80)

        Me.grdMaster.TabIndex = 2

        Me.grdMaster.Visible = False

        '

        'MainMenu1

        '

        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuEdit, Me.mnuView, Me.MenuItem7})

        '

        'mnuFile

        '

        Me.mnuFile.Index = 0

        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile_Exit})

        Me.mnuFile.Text = "File"

        '

        'mnuFile_Exit

        '

        Me.mnuFile_Exit.Index = 0

        Me.mnuFile_Exit.Text = "Exit"

        '

        'mnuEdit

        '

        Me.mnuEdit.Index = 1

        Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEdit_ShowAllCards, Me.MenuItem6, Me.mnuEdit_ShowAmerican, Me.mnuEdit_ShowVisa, Me.mnuEdit_ShowMaster, Me.MenuItem1, Me.mnuEdit_Delete})

        Me.mnuEdit.Text = "Edit"

        '

        'mnuEdit_ShowAllCards

        '

        Me.mnuEdit_ShowAllCards.Index = 0

        Me.mnuEdit_ShowAllCards.Text = " All Credit Cards"

        '

        'MenuItem6

        '

        Me.MenuItem6.Index = 1

        Me.MenuItem6.Text = "-"

        '

        'mnuEdit_ShowAmerican

        '

        Me.mnuEdit_ShowAmerican.Index = 2

        Me.mnuEdit_ShowAmerican.Text = " American Express"

        '

        'mnuEdit_ShowVisa

        '

        Me.mnuEdit_ShowVisa.Index = 3

        Me.mnuEdit_ShowVisa.Text = " Visa Card"

        '

        'mnuEdit_ShowMaster

        '

        Me.mnuEdit_ShowMaster.Index = 4

        Me.mnuEdit_ShowMaster.Text = " Master Card"

        '

        'MenuItem1

        '

        Me.MenuItem1.Index = 5

        Me.MenuItem1.Text = "-"

        '

        'mnuEdit_Delete

        '

        Me.mnuEdit_Delete.Index = 6

        Me.mnuEdit_Delete.Text = "Delete"

        '

        'mnuView

        '

        Me.mnuView.Enabled = False

        Me.mnuView.Index = 2

        Me.mnuView.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuViewLineChart, Me.mnuViewBarChart})

        Me.mnuView.Text = "View"

        '

        'mnuViewLineChart

        '

        Me.mnuViewLineChart.Index = 0

        Me.mnuViewLineChart.Text = "Line Chart"

        '

        'mnuViewBarChart

        '

        Me.mnuViewBarChart.Index = 1

        Me.mnuViewBarChart.Text = "Bar Chart"

        '

        'MenuItem7

        '

        Me.MenuItem7.Index = 3

        Me.MenuItem7.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuHelp_Content, Me.mnuHelp_About})

        Me.MenuItem7.Text = "Help"

        '

        'mnuHelp_Content

        '

        Me.mnuHelp_Content.Index = 0

        Me.mnuHelp_Content.Text = "Content"

        '

        'mnuHelp_About

        '

        Me.mnuHelp_About.Index = 1

        Me.mnuHelp_About.Text = "About"

        '

        'pnlAxisLabels

        '

        Me.pnlAxisLabels.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(128, Byte))

        Me.pnlAxisLabels.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D

        Me.pnlAxisLabels.ContextMenu = Me.cmuGraphicType

        Me.pnlAxisLabels.Controls.Add(Me.pnlChartArea)

        Me.pnlAxisLabels.Location = New System.Drawing.Point(40, 56)

        Me.pnlAxisLabels.Name = "pnlAxisLabels"

        Me.pnlAxisLabels.Size = New System.Drawing.Size(688, 352)

        Me.pnlAxisLabels.TabIndex = 3

        Me.pnlAxisLabels.Visible = False

        '

        'cmuGraphicType

        '

        Me.cmuGraphicType.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.cmuLineChart, Me.cmuBarChat})

        '

        'cmuLineChart

        '

        Me.cmuLineChart.Index = 0

        Me.cmuLineChart.Text = "LineChart"

        '

        'cmuBarChat

        '

        Me.cmuBarChat.Index = 1

        Me.cmuBarChat.Text = "BarChart"

        '

        'pnlChartArea

        '

        Me.pnlChartArea.BackColor = System.Drawing.Color.White

        Me.pnlChartArea.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.pnlChartArea.ContextMenu = Me.cmuGraphicType

        Me.pnlChartArea.Location = New System.Drawing.Point(72, 48)

        Me.pnlChartArea.Name = "pnlChartArea"

        Me.pnlChartArea.Size = New System.Drawing.Size(552, 240)

        Me.pnlChartArea.TabIndex = 0

        '

        'tbrMain

        '

        Me.tbrMain.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbrLineChart, Me.tbrBarChart, Me.ToolBarButton1, Me.tbrDelete, Me.tbrHelp, Me.tbrExit})

        Me.tbrMain.DropDownArrows = True

        Me.tbrMain.ImageList = Me.ImageList1

        Me.tbrMain.Location = New System.Drawing.Point(0, 0)

        Me.tbrMain.Name = "tbrMain"

        Me.tbrMain.ShowToolTips = True

        Me.tbrMain.Size = New System.Drawing.Size(872, 44)

        Me.tbrMain.TabIndex = 4

        '

        'tbrLineChart

        '

        Me.tbrLineChart.Enabled = False

        Me.tbrLineChart.ImageIndex = 0

        Me.tbrLineChart.ToolTipText = "Line Chart Graph"

        '

        'tbrBarChart

        '

        Me.tbrBarChart.Enabled = False

        Me.tbrBarChart.ImageIndex = 1

        Me.tbrBarChart.ToolTipText = "Bar Chart Graph"

        '

        'ToolBarButton1

        '

        Me.ToolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator

        '

        'tbrDelete

        '

        Me.tbrDelete.ImageIndex = 4

        Me.tbrDelete.ToolTipText = "Delete"

        '

        'tbrHelp

        '

        Me.tbrHelp.ImageIndex = 5

        Me.tbrHelp.ToolTipText = "Help"

        '

        'tbrExit

        '

        Me.tbrExit.ImageIndex = 6

        Me.tbrExit.ToolTipText = "Exit"

        '

        'ImageList1

        '

        Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32)

        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)

        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent

        '

        'lblInstructions

        '

        Me.lblInstructions.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(128, Byte))

        Me.lblInstructions.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        Me.lblInstructions.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))

        Me.lblInstructions.Location = New System.Drawing.Point(744, 120)

        Me.lblInstructions.Name = "lblInstructions"

        Me.lblInstructions.Size = New System.Drawing.Size(112, 88)

        Me.lblInstructions.TabIndex = 5

        Me.lblInstructions.Text = "Instructions"

        '

        'frmMain

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

        Me.ClientSize = New System.Drawing.Size(872, 669)

        Me.Controls.Add(Me.lblInstructions)

        Me.Controls.Add(Me.tbrMain)

        Me.Controls.Add(Me.pnlAxisLabels)

        Me.Controls.Add(Me.grdMaster)

        Me.Controls.Add(Me.grdVisa)

        Me.Controls.Add(Me.grdAmerican)

        Me.Menu = Me.MainMenu1

        Me.Name = "frmMain"

        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

        Me.Text = "GJ- Financial Consulting"

        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

        CType(Me.grdAmerican, System.ComponentModel.ISupportInitialize).EndInit()

        CType(Me.grdVisa, System.ComponentModel.ISupportInitialize).EndInit()

        CType(Me.grdMaster, System.ComponentModel.ISupportInitialize).EndInit()

        Me.pnlAxisLabels.ResumeLayout(False)

        Me.ResumeLayout(False)

 

    End Sub

 

#End Region

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'To initialize some global variables

        grdAmerican.Visible = False

        grdMaster.Visible = False

        grdVisa.Visible = False

        pnlChartArea.Visible = False

        pnlAxisLabels.Visible = False

        mnuView.Enabled = False

        tbrLineChart.Enabled = False

        tbrBarChart.Enabled = False

        blnIsAmericanCurrentCD = False

        blnIsVisaCurrentCD = False

        blnIsMasterCurrentCD = False

        blnIsLineCurrentChart = False

        blnIsBarCurrentChart = False

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

        sngXLabelSpacingForLineChart = 0.98 * pnlChartArea.Width / 11

        sngXLabelSpacingForBarChart = 0.9 * pnlChartArea.Width / 11

        sngBarWidth = 0.25 * sngXLabelSpacingForBarChart

        sngFirstBarGap = 0.125 * sngXLabelSpacingForBarChart

        blnAreAllCurrentCD = False

        strChartTitle = ""

        lblInstructions.Top = pnlAxisLabels.Top

        lblInstructions.Left = pnlAxisLabels.Left

        lblInstructions.Width = pnlAxisLabels.Width

        lblInstructions.Height = pnlAxisLabels.Height

        strInstructions = "Instructions : " & vbCrLf & vbCrLf & vbCrLf _

                               & "     1) Select a credit card or all them from Edit menu." & vbCrLf & vbCrLf _

                               & "     2) Enter the monthly amounts values into the grid(s) for each credit card." & vbCrLf & vbCrLf _

                               & "     3) Using the menu item or toolbar item you will be able to display line chart(s) or" & vbCrLf & vbCrLf _

                               & "        bar chart(s) graphs."

        lblInstructions.Text = strInstructions

        lblInstructions.Visible = True

    End Sub

 

    Private Sub mnuEdit_ShowAllCards_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEdit_ShowAllCards.Click

        'This subroutine will display the grids for all the credit cards

        grdAmerican.Visible = True

        grdMaster.Visible = True

        grdVisa.Visible = True

        mnuView.Enabled = True

        tbrLineChart.Enabled = True

        tbrBarChart.Enabled = True

        blnIsAmericanCurrentCD = True

        blnIsVisaCurrentCD = True

        blnIsMasterCurrentCD = True

        blnAreAllCurrentCD = True

        pnlAxisLabels.Visible = False

        pnlChartArea.Visible = False

        lblInstructions.Visible = True

        PopulateGrid(grdAmerican)

        PopulateGrid(grdVisa)

        PopulateGrid(grdMaster)

    End Sub

 

    Private Sub mnuEdit_ShowAmerican_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEdit_ShowAmerican.Click

        'This subroutine will display the grid for American Express credit card

        grdAmerican.Visible = True

        grdMaster.Visible = False

        grdVisa.Visible = False

        mnuView.Enabled = True

        tbrLineChart.Enabled = True

        tbrBarChart.Enabled = True

        blnIsAmericanCurrentCD = True

        blnIsVisaCurrentCD = False

        blnIsMasterCurrentCD = False

        blnAreAllCurrentCD = False

        pnlAxisLabels.Visible = False

        pnlChartArea.Visible = False

        lblInstructions.Visible = True

        PopulateGrid(grdAmerican)

    End Sub

 

    Private Sub mnuEdit_ShowVisa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEdit_ShowVisa.Click

        'This subroutine will display the grid for Visa credit card

        grdAmerican.Visible = False

        grdMaster.Visible = False

        grdVisa.Visible = True

        mnuView.Enabled = True

        tbrLineChart.Enabled = True

        tbrBarChart.Enabled = True

        blnIsAmericanCurrentCD = False

        blnIsVisaCurrentCD = True

        blnIsMasterCurrentCD = False

        blnAreAllCurrentCD = False

        pnlAxisLabels.Visible = False

        pnlChartArea.Visible = False

        lblInstructions.Visible = True

        PopulateGrid(grdVisa)

    End Sub

 

    Private Sub mnuEdit_ShowMaster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEdit_ShowMaster.Click

        'This subroutine will display the grid for Master credit card

        grdAmerican.Visible = False

        grdMaster.Visible = True

        grdVisa.Visible = False

        mnuView.Enabled = True

        tbrLineChart.Enabled = True

        tbrBarChart.Enabled = True

        blnIsAmericanCurrentCD = False

        blnIsVisaCurrentCD = False

        blnIsMasterCurrentCD = True

        blnAreAllCurrentCD = False

        pnlAxisLabels.Visible = False

        pnlChartArea.Visible = False

        lblInstructions.Visible = True

        PopulateGrid(grdMaster)

    End Sub

 

    Private Sub PopulateGrid(ByVal grdGridCD As DataGrid)

        'Subroutine to populate a specific data grid

        Dim dt As New DataTable

        Dim intCount As Integer

        For intCount = 1 To 12

            MonthsOfYear = intCount

            dt.Columns.Add(New DataColumn(MonthsOfYear.ToString, GetType(String)))

        Next

        grdGridCD.DataSource = dt

 

    End Sub

 

    Private Sub mnuFile_Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_Exit.Click

        Me.Close()

    End Sub

 

    Private Sub pnlAxisLabels_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlAxisLabels.Paint

        'Subroutine to draw the (X-Y)Axis labels

        Dim objAmericanCreditCard As CreditCardYear

        Dim objVisaCreditCard As CreditCardYear

        Dim objMasterCreditCard As CreditCardYear

        Dim arrMonthlyCharges(11) As Single

        Dim blnRtnCode As Boolean

        Dim sngNextXLabelLocation As Single

        Dim sngHPanel As Single

        Dim drawFont As New Font("Arial", 8)

        Dim drawBrush As New SolidBrush(Color.Black)

        Dim i As Integer

        Dim drawFormat As New StringFormat

        Dim arrMaxAmounts(2) As Single

        Dim arrMinAmounts(2) As Single

 

        If blnCurrentlyPaintingCharts = True Then

            Exit Sub

        End If

        'To initialize Maxs and Mins Amounts

        For i = arrMaxAmounts.GetLowerBound(0) To arrMaxAmounts.GetUpperBound(0)

            arrMaxAmounts(i) = -1

            arrMinAmounts(i) = -1

        Next

 

        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

        blnCurrentlyPaintingAxisLabels = True

 

        If blnRepaintChart = True _

          And blnCurrentlyPaintingCharts = False _

        Then

            'To draw X-Axis Label just for an specified card or all them

            If blnIsAmericanCurrentCD = True Then

                grdAmerican.CurrentCell = New DataGridCell(1, 1)

                GetChartPointFromGrid(grdAmerican, blnRtnCode, arrMonthlyCharges)

                If blnRtnCode = True Then

                    objAmericanCreditCard = New CreditCardYear(AMERICAN_EXPRESS_NAME, _

                                                               AMERICAN_CURRENCY_USD, _

                                                               arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    Array.Sort(arrMonthlyCharges)

                    arrMaxAmounts(0) = arrMonthlyCharges(arrMonthlyCharges.GetUpperBound(0))

                    arrMinAmounts(0) = arrMonthlyCharges(arrMonthlyCharges.GetLowerBound(0))

                    For i = 0 To 11

                        If blnIsBarCurrentChart = True Then

                            sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForBarChart + sngFirstBarGap

                        Else

                            sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForLineChart

                        End If

                        MonthsOfYear = objAmericanCreditCard.MonthlyCharges.Item(i + 1).Month

                        e.Graphics.DrawString(MonthsOfYear.ToString, _

                                              drawFont, _

                                              drawBrush, _

                                              sngNextXLabelLocation, _

                                              pnlChartArea.Top + pnlChartArea.Height + 5, _

                                              drawFormat)

                    Next

                    blnRepaintChart = True

                End If

            End If

            If blnIsVisaCurrentCD = True Then

                grdVisa.CurrentCell = New DataGridCell(1, 1)

                GetChartPointFromGrid(grdVisa, blnRtnCode, arrMonthlyCharges)

                If blnRtnCode = True Then

                    objVisaCreditCard = New CreditCardYear(VISA_NAME, _

                                                           VISA_CURRENCY_USD, _

                                                           arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    Array.Sort(arrMonthlyCharges)

                    arrMaxAmounts(1) = arrMonthlyCharges(arrMonthlyCharges.GetUpperBound(0))

                    arrMinAmounts(1) = arrMonthlyCharges(arrMonthlyCharges.GetLowerBound(0))

                    'We will need to draw X-labels just if Visa is the unique current credit card.

                    'Otherwise it was done already

                    If blnAreAllCurrentCD = False Then

                        For i = 0 To 11

                            If blnIsBarCurrentChart = True Then

                                sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForBarChart + sngFirstBarGap

                            Else

                                sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForLineChart

                            End If

                            MonthsOfYear = objVisaCreditCard.MonthlyCharges.Item(i + 1).Month

                            e.Graphics.DrawString(MonthsOfYear.ToString, _

                                                  drawFont, _

                                                  drawBrush, _

                                                  sngNextXLabelLocation, _

                                                  pnlChartArea.Top + pnlChartArea.Height + 5, _

                                                  drawFormat)

                        Next

                    End If

                    blnRepaintChart = True

                End If

            End If

            If blnIsMasterCurrentCD = True Then

                grdMaster.CurrentCell = New DataGridCell(1, 1)

                GetChartPointFromGrid(grdMaster, blnRtnCode, arrMonthlyCharges)

                If blnRtnCode = True Then

                    objMasterCreditCard = New CreditCardYear(MASTER_NAME, _

                                                             MASTER_CURRENCY_USD, _

                                                             arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    Array.Sort(arrMonthlyCharges)

                    arrMaxAmounts(2) = arrMonthlyCharges(arrMonthlyCharges.GetUpperBound(0))

                    arrMinAmounts(2) = arrMonthlyCharges(arrMonthlyCharges.GetLowerBound(0))

                    'We will need to draw X-labels just if Visa is the unique current credit card.

                    'Otherwise it was done already

                    If blnAreAllCurrentCD = False Then

                        For i = 0 To 11

                            If blnIsBarCurrentChart = True Then

                                sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForBarChart + sngFirstBarGap

                            Else

                                sngNextXLabelLocation = pnlChartArea.Left + i * sngXLabelSpacingForLineChart

                            End If

                            MonthsOfYear = objMasterCreditCard.MonthlyCharges.Item(i + 1).Month

                            e.Graphics.DrawString(MonthsOfYear.ToString, _

                                                  drawFont, _

                                                  drawBrush, _

                                                  sngNextXLabelLocation, _

                                                  pnlChartArea.Top + pnlChartArea.Height + 5, _

                                                  drawFormat)

                        Next

                    End If

                    blnRepaintChart = True

                End If

            End If

            If blnRtnCode = True Then

                drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft

                'To draw Y-Axis Label just for an specified card or all them

                'Note: We will divided the Y-Axis in four equal intervals from 0 to Maximum Amount Value

                'Sort the Maximum(s) values for the one (three) credit card(s)

                Array.Sort(arrMaxAmounts)

                sngFinalMax = arrMaxAmounts(arrMaxAmounts.GetUpperBound(0))

                'Sort the Minimum(s) values for the one (three) credit card(s)

                Array.Sort(arrMinAmounts)

                If blnAreAllCurrentCD = True Then

                    sngFinalMin = arrMinAmounts(arrMinAmounts.GetLowerBound(0))

                Else

                    sngFinalMin = arrMinAmounts(arrMinAmounts.GetUpperBound(0))

                End If

 

                e.Graphics.DrawString("$0", _

                                      drawFont, _

                                      drawBrush, _

                                      pnlAxisLabels.Left + 1, _

                                      pnlChartArea.Top + pnlChartArea.Height - 1, _

                                      drawFormat)

                If sngFinalMax >= sngHPanel Then

                    e.Graphics.DrawString("$" & FormatNumber(sngFinalMax, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(3 * sngFinalMax / 4, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + pnlChartArea.Height / 4, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(sngFinalMax / 2, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + pnlChartArea.Height / 2, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(sngFinalMax / 4, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + 3 * pnlChartArea.Height / 4, _

                                          drawFormat)

                Else

                    e.Graphics.DrawString("$" & FormatNumber(sngHPanel, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(3 * sngHPanel / 4, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + pnlChartArea.Height / 4, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(sngHPanel / 2, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + pnlChartArea.Height / 2, _

                                          drawFormat)

                    e.Graphics.DrawString("$" & FormatNumber(sngHPanel / 4, 0), _

                                          drawFont, _

                                          drawBrush, _

                                          pnlAxisLabels.Left + 1, _

                                          pnlChartArea.Top + 3 * pnlChartArea.Height / 4, _

                                          drawFormat)

                End If

                'To draw the title of the chart

                drawFont = New Font("Arial", 10, FontStyle.Bold)

                e.Graphics.DrawString(strChartTitle, _

                                      drawFont, _

                                      drawBrush, _

                                      pnlChartArea.Left + 0.85 * pnlChartArea.Width, _

                                      pnlChartArea.Top / 2, _

                                      drawFormat)

            End If

            blnCurrentlyPaintingAxisLabels = False

        End If

 

    End Sub

 

    Private Sub mnuViewLineChart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewLineChart.Click

        Call GraphLineChart()

    End Sub

 

    Private Sub mnuViewBarChart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewBarChart.Click

        Call GraphBarChart()

    End Sub

 

    Private Sub cmuLineChart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuLineChart.Click

        Call GraphLineChart()

    End Sub

 

    Private Sub cmuBarChat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuBarChat.Click

        Call GraphBarChart()

    End Sub

 

    Public Sub GraphLineChart()

        ' This routine draws the lines for the chart.

        Dim strCreditCardTitle As String

 

        blnIsLineCurrentChart = True

        blnIsBarCurrentChart = False

        blnRepaintChart = True

        lblInstructions.Visible = False

        pnlAxisLabels.Visible = True

        pnlChartArea.Visible = True

        If blnAreAllCurrentCD = True Then

            strCreditCardTitle = ALL_CREDIT_CARDS_NAME

        ElseIf blnIsAmericanCurrentCD = True Then

            strCreditCardTitle = AMERICAN_EXPRESS_NAME

        ElseIf blnIsVisaCurrentCD = True Then

            strCreditCardTitle = VISA_NAME

        ElseIf blnIsMasterCurrentCD = False Then

            strCreditCardTitle = MASTER_NAME

        End If

        strChartTitle = strCreditCardTitle & LINE_CHART_TITLE

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

        pnlAxisLabels.Invalidate()

        pnlChartArea.Invalidate()

 

    End Sub

 

    Public Sub GraphBarChart()

        ' This routine draws the bars for the chart.

        Dim strCreditCardTitle As String

 

        blnIsLineCurrentChart = False

        blnIsBarCurrentChart = True

        blnRepaintChart = True

        lblInstructions.Visible = False

        pnlAxisLabels.Visible = True

        pnlChartArea.Visible = True

        If blnAreAllCurrentCD = True Then

            strCreditCardTitle = ALL_CREDIT_CARDS_NAME

        ElseIf blnIsAmericanCurrentCD = True Then

            strCreditCardTitle = AMERICAN_EXPRESS_NAME

        ElseIf blnIsVisaCurrentCD = True Then

            strCreditCardTitle = VISA_NAME

        ElseIf blnIsMasterCurrentCD = False Then

            strCreditCardTitle = MASTER_NAME

        End If

        strChartTitle = strCreditCardTitle & BAR_CHART_TITLE

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

        pnlAxisLabels.Invalidate()

        pnlChartArea.Invalidate()

    End Sub

 

    Private Sub pnlChartArea_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlChartArea.Paint

        'Subroutine to draw the line(s) or bar(s) chart(s)

        Dim myPen As Pen

        Dim myBrush As SolidBrush

        Dim arrMonthlyCharges(11) As Single

        Dim blnRtnCode As Boolean

        Dim sngHPanel As Single

        Dim arrPoints(11) As PointF

        Dim arrRects(11) As RectangleF

        Dim i As Integer

        Dim sngNextXLabelLocation As Single

        Dim objAmericanCreditCard As CreditCardYear

        Dim objVisaCreditCard As CreditCardYear

        Dim objMasterCreditCard As CreditCardYear

 

        If blnCurrentlyPaintingAxisLabels = True Then

            Exit Sub

        End If

 

        blnCurrentlyPaintingCharts = True

        If blnRepaintChart = True _

            And blnCurrentlyPaintingAxisLabels = False _

        Then

            'To draw chart for American Express Card

            If blnIsAmericanCurrentCD = True Then

                grdAmerican.CurrentCell = New DataGridCell(1, 1)

                GetChartPointFromGrid(grdAmerican, blnRtnCode, arrMonthlyCharges)

                If blnRtnCode = True Then

                    objAmericanCreditCard = New CreditCardYear(AMERICAN_EXPRESS_NAME, _

                                                               AMERICAN_CURRENCY_USD, _

                                                               arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    ' Create points that define the curve line.

                    For i = 0 To 11

                        If blnIsBarCurrentChart = True Then

                            sngNextXLabelLocation = i * sngXLabelSpacingForBarChart + sngFirstBarGap

                        Else

                            sngNextXLabelLocation = i * sngXLabelSpacingForLineChart

                        End If

                        If sngFinalMax < sngHPanel Then

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel - objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount)

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel - objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount, _

                                                         sngBarWidth, _

                                                         objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount)

                        Else

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel * (1 - objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax))

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel * (1 - objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax), _

                                                         sngBarWidth, _

                                                         objAmericanCreditCard.MonthlyCharges.Item(i + 1).Amount)

 

                        End If

 

 

                    Next

                    Dim curvePoints As PointF() = {arrPoints(0), arrPoints(1), arrPoints(2), arrPoints(3), arrPoints(4), arrPoints(5), _

                                                   arrPoints(6), arrPoints(7), arrPoints(8), arrPoints(9), arrPoints(10), arrPoints(11)}

                    myPen = New Pen(Color.Green, 3)

                    'If the user wants to display Line Chart

                    If blnIsLineCurrentChart = True Then

                        ' Draw Line Chart to screen.

                        e.Graphics.DrawLines(myPen, curvePoints)

                    End If

                    Dim rects As RectangleF() = {arrRects(0), arrRects(1), arrRects(2), arrRects(3), arrRects(4), arrRects(5), _

                                                 arrRects(6), arrRects(7), arrRects(8), arrRects(9), arrRects(10), arrRects(11)}

                    'If the user wants to display Bar Chart

                    If blnIsBarCurrentChart = True Then

                        ' Draw Bar Chart to screen.

                        myBrush = New SolidBrush(Color.Green)

                        e.Graphics.FillRectangles(myBrush, rects)

                    End If

                End If

            End If

            'To draw chart for Visa Card

            If blnIsVisaCurrentCD = True Then

                If blnIsAmericanCurrentCD = True Then

                    If blnRtnCode = True Then

                        grdVisa.CurrentCell = New DataGridCell(1, 1)

                        GetChartPointFromGrid(grdVisa, blnRtnCode, arrMonthlyCharges)

                    End If

                Else

                    grdVisa.CurrentCell = New DataGridCell(1, 1)

                    GetChartPointFromGrid(grdVisa, blnRtnCode, arrMonthlyCharges)

                End If

                If blnRtnCode = True Then

                    objVisaCreditCard = New CreditCardYear(VISA_NAME, _

                                                           VISA_CURRENCY_USD, _

                                                           arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    ' Create points that define curve line.

                    For i = 0 To 11

                        If blnIsBarCurrentChart = True Then

                            If blnIsAmericanCurrentCD = True Then

                                sngNextXLabelLocation = i * sngXLabelSpacingForBarChart + sngBarWidth + sngFirstBarGap

                            Else

                                sngNextXLabelLocation = i * sngXLabelSpacingForBarChart + sngBarWidth

                            End If

                        Else

                            sngNextXLabelLocation = i * sngXLabelSpacingForLineChart

                        End If

                        If sngFinalMax < sngHPanel Then

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel - objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount)

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel - objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount, _

                                                         sngBarWidth, _

                                                         objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount)

                        Else

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel * (1 - objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax))

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel * (1 - objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax), _

                                                         sngBarWidth, _

                                                         objVisaCreditCard.MonthlyCharges.Item(i + 1).Amount)

 

                        End If

                    Next

                    Dim curvePoints As PointF() = {arrPoints(0), arrPoints(1), arrPoints(2), arrPoints(3), arrPoints(4), arrPoints(5), _

                                                   arrPoints(6), arrPoints(7), arrPoints(8), arrPoints(9), arrPoints(10), arrPoints(11)}

 

                    myPen = New Pen(Color.Blue, 3)

                    'If the user wants to display Line Chart

 

                    If blnIsLineCurrentChart = True Then

                        ' Draw Line Chart to screen.

 

                        e.Graphics.DrawLines(myPen, curvePoints)

                    End If

                    Dim rects As RectangleF() = {arrRects(0), arrRects(1), arrRects(2), arrRects(3), arrRects(4), arrRects(5), _

                                                 arrRects(6), arrRects(7), arrRects(8), arrRects(9), arrRects(10), arrRects(11)}

                    'If the user wants to display Bar Chart

                    If blnIsBarCurrentChart = True Then

                        ' Draw Bar Chart to screen.

                        myBrush = New SolidBrush(Color.Blue)

                        e.Graphics.FillRectangles(myBrush, rects)

                    End If

                End If

            End If

            'To draw chart for Master Card

            If blnIsMasterCurrentCD = True Then

                If blnIsVisaCurrentCD = True Then

                    If blnRtnCode = True Then

                        grdMaster.CurrentCell = New DataGridCell(1, 1)

                        GetChartPointFromGrid(grdMaster, blnRtnCode, arrMonthlyCharges)

                    End If

                Else

                    grdMaster.CurrentCell = New DataGridCell(1, 1)

                    GetChartPointFromGrid(grdMaster, blnRtnCode, arrMonthlyCharges)

                End If

                If blnRtnCode = True Then

                    objMasterCreditCard = New CreditCardYear(MASTER_NAME, _

                                                             MASTER_CURRENCY_USD, _

                                                             arrMonthlyCharges)

                    sngHPanel = pnlChartArea.Height

                    ' Create points that define curve line.

                    For i = 0 To 11

                        If blnIsBarCurrentChart = True Then

                            If blnIsVisaCurrentCD = True Then

                                sngNextXLabelLocation = i * sngXLabelSpacingForBarChart + 2 * sngBarWidth + sngFirstBarGap

                            Else

                                sngNextXLabelLocation = i * sngXLabelSpacingForBarChart + sngBarWidth

                            End If

                        Else

                            sngNextXLabelLocation = i * sngXLabelSpacingForLineChart

                        End If

                        If sngFinalMax < sngHPanel Then

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel - objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount)

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel - objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount, _

                                                         sngBarWidth, _

                                                         objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount)

                        Else

                            arrPoints(i) = New PointF(sngNextXLabelLocation, _

                                                      sngHPanel * (1 - objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax))

                            arrRects(i) = New RectangleF(sngNextXLabelLocation, _

                                                         sngHPanel * (1 - objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount / sngFinalMax), _

                                                         sngBarWidth, _

                                                         objMasterCreditCard.MonthlyCharges.Item(i + 1).Amount)

 

                        End If

                    Next

                    Dim curvePoints As PointF() = {arrPoints(0), arrPoints(1), arrPoints(2), arrPoints(3), arrPoints(4), arrPoints(5), _

                                                   arrPoints(6), arrPoints(7), arrPoints(8), arrPoints(9), arrPoints(10), arrPoints(11)}

 

                    myPen = New Pen(Color.Tan, 3)

                    'If the user wants to display Line Chart

                    If blnIsLineCurrentChart = True Then

                        ' To Draw Line Chart to screen.

                        e.Graphics.DrawLines(myPen, curvePoints)

                    End If

                    Dim rects As RectangleF() = {arrRects(0), arrRects(1), arrRects(2), arrRects(3), arrRects(4), arrRects(5), _

                                                   arrRects(6), arrRects(7), arrRects(8), arrRects(9), arrRects(10), arrRects(11)}

                    'If the user wants to display Bar Chart

                    If blnIsBarCurrentChart = True Then

                        ' To Draw Bar Chart to screen.

                        myBrush = New SolidBrush(Color.Tan)

                        e.Graphics.FillRectangles(myBrush, rects)

                    End If

                End If

            End If

            blnCurrentlyPaintingCharts = False

        End If

    End Sub

 

    Private Sub GetChartPointFromGrid(ByVal myGrid As DataGrid, _

                                      ByRef blnRtnCode As Boolean, _

                                      ByRef arrMonthlyCharges() As Single)

        'Subroutine to get the values from the data grid

        Dim selectedItem As Object

        Dim cellValue As Single

        Dim iRow As Integer

        Dim iCol As Integer

        Dim myTable As DataTable

        blnRtnCode = True

        Dim foundRows As DataRow()

 

        ' Assumes the DataGrid is bound to a DataTable.

        myTable = CType(myGrid.DataSource, DataTable)

        foundRows = myTable.Select()

        If foundRows.Length > 0 Then

            iRow = 0

            For iCol = 0 To myTable.Columns.Count - 1

                selectedItem = myGrid.Item(iRow, iCol)

                If IsNumeric(selectedItem) Then

                    If selectedItem < 0 Then

                        cellValue = 0 'The system automatically will convert negative values to $0 USD charge.

                    Else

                        cellValue = CSng(selectedItem)

                    End If

                    arrMonthlyCharges(iCol) = cellValue

                Else

                    blnRtnCode = False

                    MessageBox.Show("Invalid $Amount in the follow Grid: '" & myGrid.CaptionText() & "', for Month= " & myTable.Columns.Item(iCol).ColumnName & "." & vbCrLf & vbCrLf _

                                    & "Please Enter a Valid Amount then continue, Thank You.", "Invalid Input")

                    blnRepaintChart = False

                    myGrid.Focus()

                    myGrid.CurrentCell = New DataGridCell(iRow, iCol)

                    Exit For

                End If

            Next iCol

            If blnRtnCode = True Then

                myGrid.CurrentCell = New DataGridCell(0, 0)

            End If

        Else

            blnRtnCode = False

            MessageBox.Show("Please Fill the Grid: '" & myGrid.CaptionText() & "' With Some $Amounts then continue", "Grid(s) is(are) Empty(ies)")

            blnRepaintChart = False

            myGrid.Focus()

        End If

    End Sub

 

    'We Have to take control over some Data Grid Events that will invoke automatically the panel paint event

    Private Sub grdAmerican_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles grdAmerican.Navigate

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdAmerican_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdAmerican.Click

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdAmerican_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdAmerican.CurrentCellChanged

        'blnRepaintChart = False

        'blnCurrentlyPaintingCharts = False

        'blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdAmerican_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdAmerican.GotFocus

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdVisa_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles grdVisa.Navigate

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdVisa_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdVisa.Click

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdVisa_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdVisa.CurrentCellChanged

        'blnRepaintChart = False

        'blnCurrentlyPaintingCharts = False

        'blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdVisa_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdVisa.GotFocus

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdMaster_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles grdMaster.Navigate

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdMaster_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMaster.Click

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdMaster_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMaster.CurrentCellChanged

        'blnRepaintChart = False

        'blnCurrentlyPaintingCharts = False

        'blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub grdMaster_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMaster.GotFocus

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

    End Sub

 

    Private Sub tbrMain_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbrMain.ButtonClick

        'Subroutine to drive ToolBar buttons selection

        Select Case tbrMain.Buttons.IndexOf(e.Button)

            Case 0

                Call GraphLineChart()

            Case 1

                Call GraphBarChart()

            Case 3

                Call DeleteAllCurrentCreditCardInfo()

            Case 4

 

            Case 5

                Me.Close()

        End Select

    End Sub

    Private Sub DeleteAllCurrentCreditCardInfo()

        'Subroutine to delete all current grid(s) and chart(s)

        grdAmerican.Visible = False

        grdMaster.Visible = False

        grdVisa.Visible = False

        pnlChartArea.Visible = False

        pnlAxisLabels.Visible = False

        mnuView.Enabled = False

        tbrLineChart.Enabled = False

        tbrBarChart.Enabled = False

        blnIsAmericanCurrentCD = False

        blnIsVisaCurrentCD = False

        blnIsMasterCurrentCD = False

        blnIsLineCurrentChart = False

        blnIsBarCurrentChart = False

        blnRepaintChart = False

        blnCurrentlyPaintingCharts = False

        blnCurrentlyPaintingAxisLabels = False

        blnAreAllCurrentCD = False

        strChartTitle = ""

        lblInstructions.Top = pnlAxisLabels.Top

        lblInstructions.Left = pnlAxisLabels.Left

        lblInstructions.Width = pnlAxisLabels.Width

        lblInstructions.Height = pnlAxisLabels.Height

        lblInstructions.Text = strInstructions

        lblInstructions.Visible = True

    End Sub

 

    Private Sub mnuEdit_Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEdit_Delete.Click

        Call DeleteAllCurrentCreditCardInfo()

    End Sub

 

    Private Sub mnuHelp_About_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelp_About.Click

        Dim objfrmAbout As New frmAbout

        objfrmAbout.ShowDialog()

    End Sub

End Class

 'MSSE Fairfield University

'SW403- Fall 2005

'Guillermo V. Julca

'http://www.gjp2s.com

 

Public Class CreditCardMonth

    Private _Amount As Single  'Private member variable to store the monthly amount(charge)for a credit card object

    Private _Month As Integer  'Private member variable to store the numeric month of the year

    'Default Constructor

    Sub New()

        'set the defaults

        _Amount = 25 'Year fee paid at the begin of the year

        _Month = 1

    End Sub

    'Constructor with specific values

    Sub New(ByVal sngAmount As Single, ByVal intMonth As Integer)

        _Amount = sngAmount

        _Month = intMonth

    End Sub

    'Amount - get/set the amount of USD per month

    Property Amount() As Single

        Get

            Return _Amount

        End Get

        Set(ByVal Value As Single)

            Try

                _Amount = Value

            Catch ex As Exception

                MessageBox.Show("Invalid USD Amount." & ex.Message, _

                                "Invalid Input Data ($)", _

                                MessageBoxButtons.OK, _

                                MessageBoxIcon.Exclamation)

            End Try

        End Set

    End Property

    'Month - get/set the month

    Property Month() As Integer

        Get

            Return _Month

        End Get

        Set(ByVal Value As Integer)

            Try

                _Month = Value

            Catch ex As Exception

                MessageBox.Show("Invalid Month Value." & ex.Message, _

                                "Invalid Input Data ", _

                                MessageBoxButtons.OK, _

                                MessageBoxIcon.Exclamation)

            End Try

        End Set

    End Property

 

End Class

 

'MSSE Fairfield University

'SW403- Fall 2005

'Guillermo V. Julca

'http://www.gjp2s.com

 

Public Class CreditCardYear

    Private _Name As String                     'Private member variable to store the credit card name

    Private _Currency As String                 'Private member variable to store the credit card currency

    Private _MonthlyCharges As New Collection   'Collection of objects of type "CreditCardMonth"

    'Default Constructor

    Sub New()

        Dim intCount As Integer

        _Name = "Default Credit Card Name"

        _Currency = "USD" '$

        For intCount = 1 To 12

            Dim objCreditCardMonth As CreditCardMonth

            objCreditCardMonth = New CreditCardMonth(0, intCount)

            _MonthlyCharges.Add(objCreditCardMonth)

        Next

    End Sub

    'Constructor with specific parameters

    Sub New(ByVal Name As String, ByVal Currency As String, ByVal arrMonthlyAmounts() As Single)

        Dim intCount As Integer

        'Credit card name

        _Name = Name

        'Credit card currency

        _Currency = Currency

        'Credit card monthly charges description "USD Amount/Month"

        Try

            For intCount = 1 To 12

                Dim objCreditCardMonth As CreditCardMonth

                objCreditCardMonth = New CreditCardMonth(arrMonthlyAmounts(intCount - 1), intCount)

                _MonthlyCharges.Add(objCreditCardMonth)

            Next

        Catch ex As Exception

            MessageBox.Show("Invalid Monthly USD Amount(s)." & ex.Message, _

                            "Invalid Input Data ", _

                            MessageBoxButtons.OK, _

                            MessageBoxIcon.Exclamation)

        End Try

    End Sub

    'Name - get/set credit card name

    Property Name() As String

        Get

            Return _Name

        End Get

        Set(ByVal Value As String)

            Try

                _Name = Value

            Catch ex As Exception

                MessageBox.Show("Invalid Credit Card Name." & ex.Message, _

                                "Invalid Input Data ", _

                                MessageBoxButtons.OK, _

                                MessageBoxIcon.Exclamation)

            End Try

        End Set

    End Property

    'Currency - get/set credit card currency

    Property Currency() As String

        Get

            Return _Currency

        End Get

        Set(ByVal Value As String)

            Try

                _Currency = Value

            Catch ex As Exception

                MessageBox.Show("Invalid Credit Card Currency." & ex.Message, _

                                "Invalid Input Data ", _

                                MessageBoxButtons.OK, _

                                MessageBoxIcon.Exclamation)

            End Try

        End Set

    End Property

    Property MonthlyCharges() As Collection

        Get

            Return _MonthlyCharges

        End Get

        Set(ByVal Value As Collection)

            Try

                _MonthlyCharges = Value

            Catch ex As Exception

 

                MessageBox.Show(ex.Message, _

                                "Invalid Input Data ", _

                                MessageBoxButtons.OK, _

                                MessageBoxIcon.Exclamation)

            End Try

        End Set

    End Property

 

End Class

 

 

 

 

 

 

 

 

 

 

 

'MSSE Fairfield University

'SW403- Fall 2005

'Guillermo V. Julca

'http://www.gjp2s.com

 

Public Class frmAbout

    Inherits System.Windows.Forms.Form

 

#Region " Windows Form Designer generated code "

 

    Public Sub New()

        MyBase.New()

 

        'This call is required by the Windows Form Designer.

        InitializeComponent()

 

        'Add any initialization after the InitializeComponent() call

 

    End Sub

 

    'Form overrides dispose to clean up the component list.

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

 

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    Friend WithEvents btnOK As System.Windows.Forms.Button

    Friend WithEvents lblCopyRight As System.Windows.Forms.Label

    Friend WithEvents lblWarning As System.Windows.Forms.Label

    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents Label3 As System.Windows.Forms.Label

    Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmAbout))

        Me.btnOK = New System.Windows.Forms.Button

        Me.lblCopyRight = New System.Windows.Forms.Label

        Me.lblWarning = New System.Windows.Forms.Label

        Me.PictureBox1 = New System.Windows.Forms.PictureBox

        Me.PictureBox2 = New System.Windows.Forms.PictureBox

        Me.Label1 = New System.Windows.Forms.Label

        Me.Label2 = New System.Windows.Forms.Label

        Me.Label3 = New System.Windows.Forms.Label

        Me.LinkLabel1 = New System.Windows.Forms.LinkLabel

        Me.SuspendLayout()

        '

        'btnOK

        '

        Me.btnOK.Location = New System.Drawing.Point(512, 360)

        Me.btnOK.Name = "btnOK"

        Me.btnOK.Size = New System.Drawing.Size(88, 24)

        Me.btnOK.TabIndex = 0

        Me.btnOK.Text = "OK"

        '

        'lblCopyRight

        '

        Me.lblCopyRight.Location = New System.Drawing.Point(144, 24)

        Me.lblCopyRight.Name = "lblCopyRight"

        Me.lblCopyRight.Size = New System.Drawing.Size(472, 288)

        Me.lblCopyRight.TabIndex = 3

        '

        'lblWarning

        '

        Me.lblWarning.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D

        Me.lblWarning.Location = New System.Drawing.Point(16, 336)

        Me.lblWarning.Name = "lblWarning"

        Me.lblWarning.Size = New System.Drawing.Size(480, 88)

        Me.lblWarning.TabIndex = 4

        Me.lblWarning.Text = "Warning: This program is protected by all applicable copyright laws.  It is illeg" & _

        "al to reverse engineer or otherwise use the contents of this program  or other f" & _

        "iles used by this program without the express written permission from GJ."

        '

        'PictureBox1

        '

        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)

        Me.PictureBox1.Location = New System.Drawing.Point(16, 16)

        Me.PictureBox1.Name = "PictureBox1"

        Me.PictureBox1.Size = New System.Drawing.Size(104, 96)

        Me.PictureBox1.TabIndex = 5

        Me.PictureBox1.TabStop = False

        '

        'PictureBox2

        '

        Me.PictureBox2.BackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(128, Byte), CType(255, Byte))

        Me.PictureBox2.Location = New System.Drawing.Point(16, 112)

        Me.PictureBox2.Name = "PictureBox2"

        Me.PictureBox2.Size = New System.Drawing.Size(104, 200)

        Me.PictureBox2.TabIndex = 6

        Me.PictureBox2.TabStop = False

        '

        'Label1

        '

        Me.Label1.Font = New System.Drawing.Font("Times New Roman", 16.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        Me.Label1.ForeColor = System.Drawing.Color.Black

        Me.Label1.Location = New System.Drawing.Point(160, 16)

        Me.Label1.Name = "Label1"

        Me.Label1.Size = New System.Drawing.Size(432, 40)

        Me.Label1.TabIndex = 7

        Me.Label1.Text = "GJ Financial Consulting Co."

        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

        '

        'Label2

        '

        Me.Label2.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        Me.Label2.Location = New System.Drawing.Point(168, 48)

        Me.Label2.Name = "Label2"

        Me.Label2.Size = New System.Drawing.Size(424, 32)

        Me.Label2.TabIndex = 8

        Me.Label2.Text = "Software Program Version 1.0.0"

        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

        '

        'Label3

        '

        Me.Label3.Font = New System.Drawing.Font("Times New Roman", 11.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        Me.Label3.Location = New System.Drawing.Point(144, 144)

        Me.Label3.Name = "Label3"

        Me.Label3.Size = New System.Drawing.Size(464, 24)

        Me.Label3.TabIndex = 9

        Me.Label3.Text = "Copyright (c) 2005-2006      All Rights Reserved."

        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

        '

        'LinkLabel1

        '

        Me.LinkLabel1.Location = New System.Drawing.Point(24, 392)

        Me.LinkLabel1.Name = "LinkLabel1"

        Me.LinkLabel1.Size = New System.Drawing.Size(160, 16)

        Me.LinkLabel1.TabIndex = 10

        Me.LinkLabel1.TabStop = True

        Me.LinkLabel1.Text = "http://www.gjp2s.com"

        '

        'frmAbout

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

        Me.ClientSize = New System.Drawing.Size(640, 474)

        Me.Controls.Add(Me.LinkLabel1)

        Me.Controls.Add(Me.Label3)

        Me.Controls.Add(Me.Label2)

        Me.Controls.Add(Me.Label1)

        Me.Controls.Add(Me.PictureBox2)

        Me.Controls.Add(Me.PictureBox1)

        Me.Controls.Add(Me.lblWarning)

        Me.Controls.Add(Me.lblCopyRight)

        Me.Controls.Add(Me.btnOK)

        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D

        Me.MaximizeBox = False

        Me.MinimizeBox = False

        Me.Name = "frmAbout"

        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

        Me.Text = "About GJ Financial Consulting"

        Me.ResumeLayout(False)

 

    End Sub

 

#End Region

 

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        'Dim objfrmMain As New frmMain

        Me.Close()

        'If objfrmMain.pnlChartArea.Visible = True Then

        '    objfrmMain.blnRepaintChart = True

        '    Call objfrmMain.GraphLineChart()

        'End If

    End Sub

 

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked

        Dim p As New ProcessStartInfo

        p.FileName = "http://www.gjp2s.com"

        p.UseShellExecute = True

        Process.Start(p)

    End Sub

 

End Class

 

 

Go to Home Page

 

View Output