Sample VB Solution
Sample VB Solution
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 One
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 Get
Set(value As String)
artId = value
End Set
End Property
End Get
Set(value As String)
artistId = value
End Set
End Property
End Get
Set(value As String)
description = value
End Set
End Property
c) Create a Method to calculate the Age of the painting using the CommissioningDate and the
current date
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.
artid = artid_tb.Text
artistid = artistid_tb.Text
description = description_tb.Text
datecommissioned = date_commissioned_tb.Text
datecommissioned = Convert.ToDateTime("01-04-2014")
myart.Art_Id = artid
myart.Artist_Id = artistid
myart.Artist_Description = description
myart.DateOfCommissioning = datecommissioned
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).
End Class
Question Two.
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
Private Sub saveArtist_Click(sender As Object, e As EventArgs) Handles
saveArtist.Click
commitArtist()
End Sub
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
maxrows = maxrows - 1
inc = 0
dataadapter.Update(dataset, "EXAMDATABASE")
clearFilds()
End If
End Sub
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.
b. Create a functionality in your web App that will enable a user to search for an Artist, and if
the Artist is found, the user can then select it to display details of the Artist as well as the list
of all the Arts/painting created by that artist on a new webpage
End Sub