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
No comments:
Post a Comment