Professional Documents
Culture Documents
ACADEMIC YEAR
ANSWER SHEET
STUDENT INFORMATION
INDEX NUMBER: 040917007
FULL NAME: Ebenezer Amoasi Yeboah
PROGRAMME: BSC INFORMATION TECHNOLOGY
LEVEL: 300
SESSION: Morning- Regular
LECTURER: Mr. Samuel Oppong
QUESTION 1
a) Create a class for the Art in case one and create member variables for any four (4)
properties.
End Class
b) Create a property procedure to write values into and read values from each of the
member variables created in (a) above. Be mindful to implements all necessary
validation.
End Set
End Property
If IsNumeric(value) Then
length = value
Else
MessageBox.Show("Please, Art Length Must Be A Number")
End If
End Set
End Property
If IsNumeric(value) Then
width = value
Else
MessageBox.Show("Please, Art Width Must Be A Number")
End If
End Set
End Property
End Set
End Property
c) Create a Method to calculate the Age of the painting using the CommissioningDate
and the current date
Return age
End Function
age = value
End Set
End Property
d) In the Click Event of a button that lies on Form1, create an instance of the Class
created in (a)
e) Assign values to the properties created in (b) using Textboxes that are on Form1.
Code for Sub Question e)
'ART TYPE'
If cmbType.SelectedIndex = -1 Then
MessageBox.Show("Please, Choose An Art Type")
cmbType.Select()
Else
newArt.ArtType = cmbType.Text
End If
'ART LENGTH'
If txtLength.Text <> String.Empty Then
If IsNumeric(txtLength.Text) Then
newArt.ArtLength = CDbl(txtLength.Text)
Else
MessageBox.Show("Please, Art Length Must Be A Number")
txtLength.Select()
End If
Else
MessageBox.Show("Please, Fill The Art Length Entry")
txtLength.Select()
End If
'ART WIDTH
If txtWidth.Text <> String.Empty Then
If IsNumeric(txtWidth.Text) Then
newArt.ArtWidth = CDbl(txtWidth.Text)
Else
MessageBox.Show("Please, Art Width Must Be A Number")
txtWidth.Select()
End If
Else
MessageBox.Show("Please, Fill The Art Width Entry")
txtWidth.Select()
End If
'ART DESCRIPTION
If txtDescription.Text = String.Empty Then
MessageBox.Show("Please, Fill The Art Description Entry")
txtDescription.Select()
Else
newArt.ArtDescription = txtDescription.Text
End If
'ART AGE'
newArt.ArtAge = CInt(newArt.CalculateAge(dtpDateOfCommission.Value))
MessageBox.Show("Art Details" & vbNewLine & vbNewLine & "Type: " &
newArt.ArtType & vbNewLine & "Length: " & newArt.ArtLength & vbNewLine & "Width: " &
newArt.ArtWidth & vbNewLine & "Description: " & newArt.ArtDescription & vbNewLine &
"Age: " & newArt.ArtAge & "yrs")
End Sub
f) Using a message box control, display the values assigned to the properties in (e) as
well as the Age of the Painting in (c).
Code for Sub Question f)
QUESTION 2
a) Using the Database structure in figure 1, create a database in Microsoft Access OR Microsoft
SQL server and populate each table with at least fifteen (15) appropriate records. Then, you
are required to design an appropriate user interface, connect it to the database, retrieve and
display all Artist records in a DataGrid View control on the interface.
Try
Myconnection = New OleDbConnection
Myconnection.ConnectionString = connString
dbds = New DataSet
tables = dbds.Tables
dbda = New OleDbDataAdapter("Select * from [Artist_TB]", Myconnection)
dbda.Fill(dbds, "Artist_TB")
Dim view As New DataView(tables(0))
source.DataSource = view
DataGridView1.DataSource = view
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
b) Create functionalities for a user to be able to ADD new Records to the database, Delete and
Update Existing Records(using appropriate user interfaces).
End Sub
End Sub
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
If fulllname_txtbox.Text <> "" And gender_txtbox.Text <> "" And
phonenumber_txtbox.Text <> "" And address_txtbox.Text <> "" And email_txtbox.Text <> ""
Then
sql = "insert into Artist_TB([FullName], [Gender], [PhoneNumber], [Address], [E-
mail]) " & "values(?,?,?,?,?)"
Try
olecommand.ExecuteNonQuery()
olecommand.Dispose()
conn.Close()
MessageBox.Show("New Artist Inserted Successfully")
addnewArtistbtn.Enabled = True
updateArtistbtn.Enabled = True
deleteArtistbtn.Enabled = True
artistIdlabel.Visible = True
artistid_txtbox.Visible = True
saveArtist.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
Else
MessageBox.Show("All fields cannot be empty")
Return
End If
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim cb As New OleDb.OleDbCommandBuilder(dataadapter)
dataset.Tables("Artist_TB").Rows(inc).Item(0) = artistid_txtbox.Text
dataset.Tables("Artist_TB").Rows(inc).Item(1) = fulllname_txtbox.Text
dataset.Tables("Artist_TB").Rows(inc).Item(2) = gender_txtbox.Text
dataset.Tables("Artist_TB").Rows(inc).Item(0) = phonenumber_txtbox.Text
dataset.Tables("Artist_TB").Rows(inc).Item(0) = address_txtbox.Text
dataset.Tables("Artist_TB").Rows(inc).Item(0) = email_txtbox.Text
dataadapter.Update(dataset, "Artist_TB")
MessageBox.Show("Artist Updated Successfully")
clearFilds()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Try
conn = New OleDbConnection
conn.ConnectionString = connString
conn.Open()
dataset = New DataSet
tables = dataset.Tables
dataadapter = New OleDbDataAdapter("Select * from [Artist_TB]", conn)
dataadapter.Fill(dataset, "Artist_TB")
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Dim view As New DataView(tables(0))
source.DataSource = view
artistDataGridView.DataSource = view
End Sub
End If
End Sub
Dim connString As String = “paste the path to your access database file here”
Dim conn As OleDbConnection
Dim dataadapter As OleDbDataAdapter
Dim dataset As DataSet
Dim tables As DataTableCollection
Dim source As New BindingSource
Dim sql As String
Dim inc As Integer
Dim maxrows As Integer
Question Three.
a. Using the Database created in 2 (a), you are required to create a website/web App, design
an appropriate webpage, connect it to the database, retrieve and display all Collector
records in a GridView control on the Webpage.
End Sub