Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 64 lines (53 sloc) 2.969 kb
159371fe »
2012-10-13 Add the VB COMP4 coursework code, for the fun of it.
1 Imports System.Data
2 Imports System.Data.OleDb
3 Public Class frmSurveyForm
4
5 Public accConnection As New OleDbConnection
6
7 Private Sub frmSurveyForm_Load(ByVal sender As System.Object, _
8 ByVal e As System.EventArgs) Handles MyBase.Load
9 'All this does, for now, is display the selected customer details.
10 'In the future, full survey details will be able to be entered by
11 'the user, however at this moment I cannot implement this due to
12 'time constraints, so it will be implemented in after-development.
13 'To show this to the user when he or she hunts around, there
14 'exists a placeholder text label that states that features are
15 'coming soon.
16
17 If frmLoginForm.accConnection.State <> ConnectionState.Open Then
18 frmLoginForm.accConnection.Open()
19 End If
20
21 accConnection = frmLoginForm.accConnection
22 'Input customer name from the other form and attribute it to CN.
23 Dim cn As String = frmReportSurvey.txtcbReportSurvey.SelectedItem
24 Dim cmdString As String = "SELECT * FROM Customer WHERE cust_name = '" & cn & "'"
25 Dim accCommand As New OleDbCommand
26 Dim da As New OleDbDataAdapter(cmdString, accConnection)
27 Dim ds As New DataSet
28
29 da.Fill(ds, "Customer")
30
31 Dim dt As DataTable = ds.Tables(0)
32 Dim dr As DataRow '<- This is redundant.sss
33
34 'Populate the textboxes in the form with existing customer details.
35 'All the customer data text boxes are read-only to avoid data error:
36 'to edit those, edit the customer details directly, then come back.
37
38 'Populate the customer name textbox with the customer name
39 'from the other form, before getting info from db about others.
40 txtscn.Text = cn
41 If ds.Tables(0).Rows.Count <> 0 Then
42 cbsct.Text = ds.Tables(0).Rows(0).Item("cust_title")
43 txtscba.Text = ds.Tables(0).Rows(0).Item("cust_billaddress")
44 txtscbp.Text = ds.Tables(0).Rows(0).Item("cust_billpostcode")
45 txtscia.Text = ds.Tables(0).Rows(0).Item("cust_instaddress")
46 txtscip.Text = ds.Tables(0).Rows(0).Item("cust_instpostcode")
47 txtschtn.Text = ds.Tables(0).Rows(0).Item("cust_hometelno")
48 txtscmtn.Text = ds.Tables(0).Rows(0).Item("cust_mobtelno")
49 txtscmpan.Text = ds.Tables(0).Rows(0).Item("cust_mpan")
50 txtscea.Text = ds.Tables(0).Rows(0).Item("cust_email")
51 End If
52
53 accCommand.Connection = frmLoginForm.accConnection
54 accCommand.CommandType = CommandType.Text
55 accCommand.CommandText = cmdString
56
57 End Sub
58
59 Private Sub btnClose_Click(ByVal sender As System.Object, _
60 ByVal e As System.EventArgs) Handles btnClose.Click
61 Me.Close()
62 frmReportSurvey.Show()
63 End Sub
64 End Class
Something went wrong with that request. Please try again.