Thursday, 16 June 2016

Term 2 Week 8

Throughout week 8 i have made good progress with my program. I have successfully got the products to load into the productlist listbox after a few problems with a loop that would load the products into the listbox to many times. Also this week i have successfully coded the button that transfers a quote to an invoice. This took a lot of trial and error testing as well as some peer checking and help from mr chapman. Eventually the algorithm was quite long and complex as seen below. As for todays double i have attempted to work through the save invoice algorithm, however coming up with the index is outsides the bounds of the array error. I will hopefully resolve this error next week. However i did have a chance to move onto my search and sort algorithms with occur all throughout my program. I have got the search to work correctly and my sort is still being tested. I also decided to put in a reset button that resets the listbox to contain all the records. This was done because if the clients searches for the wrong name and needs to see the hole listbox again they can click this button to reset it.

During this week i believe my coding skills have improved greatly. I have also found that i have a greater understanding now of how the clients are going to interact with my project and what things they will require, things i didnt initially consider. This as a whole has improved my knowledge and understanding of the Software Development course.

Here is the Quote to Invoice Algorithm 

Private Sub btnQuotetoInvoice_Click(sender As System.Object, e As System.EventArgs) Handles btnQuotetoInvoice.Click
        mystringQuotes = lstQuotes.SelectedItem
        mystringQuotes = Replace(mystringQuotes, vbTab, "")
        MsgBox(mystringQuotes)
        For i = 0 To UBound(arrQuotes)
            If mystringQuotes = arrQuotes(i).QuoteCode & arrQuotes(i).QuoteDate & arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname & arrQuotes(i).HireorSale Then
                If arrQuotes(i).HireorSale = "Hire" Then
                    frmHireInvoice.lblGivenName.Text = arrQuotes(i).ClientGivenName
                    frmHireInvoice.lblSurname.Text = arrQuotes(i).ClientSurname
                    If mystringQuotes = arrQuotes(i).QuoteCode & arrQuotes(i).QuoteDate & arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname & arrQuotes(i).HireorSale Then
                        frmViewQuote.lblGivenName.Text = arrQuotes(i).ClientGivenName
                        frmViewQuote.lblSurname.Text = arrQuotes(i).ClientSurname
                        frmViewQuote.lblHireorSale.Text = arrQuotes(i).HireorSale
                        frmViewQuote.lblDate.Text = arrQuotes(i).QuoteDate
                        searchProductString = arrQuotes(i).ProductCode
                        loadProductNamesInvoices()
                    End If
                End If
                For z = 0 To UBound(arrClients)
                    If arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname = arrClients(z).GivenName & arrClients(z).Surname Then
                        frmHireInvoice.lblPhoneNumber.Text = arrClients(z).PhoneNumber
                        frmHireInvoice.lblAddress.Text = arrClients(z).Address
                        frmHireInvoice.lblEmail.Text = arrClients(z).Email
                    End If
                Next
            End If
        Next
        frmHireInvoice.Show()
        Me.Hide()
        Exit Sub
        For i = 0 To UBound(arrQuotes)
            If mystringQuotes = arrQuotes(i).QuoteCode & arrQuotes(i).QuoteDate & arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname & arrQuotes(i).HireorSale Then
                If arrQuotes(i).HireorSale = "Sale" Then
                    frmHireInvoice.lblGivenName.Text = arrQuotes(i).ClientGivenName
                    frmHireInvoice.lblSurname.Text = arrQuotes(i).ClientSurname
                    If mystringQuotes = arrQuotes(i).QuoteCode & arrQuotes(i).QuoteDate & arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname & arrQuotes(i).HireorSale Then
                        frmViewQuote.lblGivenName.Text = arrQuotes(i).ClientGivenName
                        frmViewQuote.lblSurname.Text = arrQuotes(i).ClientSurname
                        frmViewQuote.lblHireorSale.Text = arrQuotes(i).HireorSale
                        frmViewQuote.lblDate.Text = arrQuotes(i).QuoteDate
                        searchProductString = arrQuotes(i).ProductCode
                        loadProductNamesInvoices()
                    End If
                End If
                For z = 0 To UBound(arrClients)
                    If arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname = arrClients(z).GivenName & arrClients(z).Surname Then
                        frmHireInvoice.lblPhoneNumber.Text = arrClients(z).PhoneNumber
                        frmHireInvoice.lblAddress.Text = arrClients(z).Address
                        frmHireInvoice.lblEmail.Text = arrClients(z).Email
                    End If
                Next
            End If
        Next
        frmSalesInvoice.Show()
        Me.Hide()
    End Sub

This is the algorithms that load the clients and products into their labels and listbox 

  Private Sub btnEntireQuote_Click(sender As System.Object, e As System.EventArgs) Handles btnEntireQuote.Click
        mystringQuotes = lstQuotes.SelectedItem
        mystringQuotes = Replace(mystringQuotes, vbTab, "")
        MsgBox(mystringQuotes)

        For i = 0 To UBound(arrQuotes)
            If mystringQuotes = arrQuotes(i).QuoteCode & arrQuotes(i).QuoteDate & arrQuotes(i).ClientGivenName & arrQuotes(i).ClientSurname & arrQuotes(i).HireorSale Then
                frmViewQuote.lblGivenName.Text = arrQuotes(i).ClientGivenName
                frmViewQuote.lblSurname.Text = arrQuotes(i).ClientSurname
                frmViewQuote.lblHireorSale.Text = arrQuotes(i).HireorSale
                frmViewQuote.lblDate.Text = arrQuotes(i).QuoteDate
                searchProductString = arrQuotes(i).ProductCode
                loadProductNamesQuotes()
                frmViewQuote.Show()
            End If
        Next
    End Sub

    Private Sub loadProductNamesQuotes()
        For x = 0 To UBound(arrProducts) - 1
            If InStr(searchProductString, arrProducts(x).ProductCode) Then
                frmViewQuote.lstProductList.Items.Add(arrProducts(x).ProductName)
            End If
        Next
    End Sub

Here is my Search Algorithm and the reset button

Private Sub btnSearchName_Click(sender As System.Object, e As System.EventArgs) Handles btnSearchName.Click
        Dim SearchText As String
        SearchText = txtSearchName.Text
        Dim found As Boolean = False
        lstClients.Items.Clear()
        If txtSearchName.Text = "" Then
            MsgBox("Please enter a surname")
            Exit Sub
        Else
            For i = 0 To UBound(arrClients)
                If arrClients(i).GivenName = SearchText Then
                    found = True
                    lstClients.Items.Add(arrClients(i).ClientCode & vbTab & arrClients(i).GivenName & vbTab & arrClients(i).Surname & vbTab & arrClients(i).PhoneNumber & vbTab & arrClients(i).Address & vbTab & arrClients(i).Email & vbTab & arrClients(i).Comments)
                End If
                txtSearchName.Text = ""
            Next
        End If
        If found = False Then
            MsgBox("Client not found")
            Exit Sub
        End If
    End Sub
    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
        For i = 0 To UBound(arrClients)
            If arrClients(i).active = True Then
                lstClients.Items.Clear()
            End If
        Next
        For i = 0 To UBound(arrClients)
            If arrClients(i).active = True Then
                lstClients.Items.Add(arrClients(i).ClientCode & vbTab & arrClients(i).GivenName & vbTab & arrClients(i).Surname & vbTab & arrClients(i).PhoneNumber & vbTab & arrClients(i).Address & vbTab & arrClients(i).Email & vbTab & arrClients(i).Comments)
            End If
        Next
    End Sub

Sunday, 5 June 2016

Term 2 Week 7

During this week Mr chapman and i sat down to sort through an logic error within my code. This is in relation to the view quote form i built last lesson, loading the products codes product name into the productlist listbox on the view quote form as well as the clients information. Through a range of trial and error testing i eventually got the clients information to load into labels across the forms. However i could not get the products names to load into the listbox this week. I will contiune working on this issue next week as this error is building my coding knowledge and skills on how to pass information across forms.

Thursday, 2 June 2016

Term 2 Week 6

During this week of coding i have moved both forwards and backwards. I have successfully coding the subroutine to save the quote to file, a massive step forward in my project. However i found an issue with the product and client codes not being able to rewrite themselves as client name and product name. This caused a reconsideration of how my forms will work and the creation of a view quote and view invoice forms are currently being created. Therefore the quote form will now load the quote code, the date and the clients given name and surname. Then a view entire quote/invoice button can be clicked in which the details including whether the quote/invoice is hire or sale will load and the products also shall load into a listbox. 

This decision was made on the bases of improving ergonomic design and effective use of listbox not being enormously big with a scroll bar. 

During this week i have gained a greater knowledge of coding techniques including string processing, concatenating strings as well as the instring function. I have also further gained knowledge of good ergonomic design, carrying data across forms and appropriate use of listboxes and other tools.