Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

ASSIGNMENT THREE

CICS 314: ADVANCED VISUAL BASIC .NET PROGRAMMING

INDEX NUMBER: 0401200043

NAME: DAMALIE DANIEL DELALI

PROGRAMME: BSC INFORMATION TECHNOLOGY

LEVEL: 300

SESSION: MORNING

BIT GROUP D
SCREENSHOT FOR MESSAGE TAB

CODE FOR MESSAGE


Private Sub MESSAGESTBToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles MESSAGESTBToolStripMenuItem.Click
Dim Person_ID As String = txtId.Text
'txtID is the textbox that contains the ID of the selected contact
Dim messageForm As New frmViewContactMessages
messageForm.Tag = Person_ID
messageForm.ShowDialog() End
Sub
SCREENSHOT FOR VIEW CONTACT MESSAGE

CODE FOR VIEW CONTACT MESSAGE


Imports System.Data.OleDb
Public Class frmViewContactMessages
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim personSQL As String
Dim messageSQL As String
Dim conString As String Dim inc As Integer
Private Sub frmViewContactMessages_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
conString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source ='C:\Users\KELVIN
HELARY\source\repos\contactManagerApp\bin\Debug\Contact_db1.mdb'"
con.ConnectionString = conString
'used to store the ID of the selected contact passed from Form1
Dim Person_ID As String
Person_ID = Me.Tag.ToString
'the parameterize query to fetch data on the selected contact
Dim personSQL As String = "select * from Person_TB where P_ID=?“
Dim cmdPerson As New OleDb.OleDbCommand(personSQL, con)
cmdPerson.CommandType = CommandType.Text
'Creating the parameter and passing the value of the selected ID
cmdPerson.Parameters.AddWithValue("P_ID", Person_ID) con.Open()
cmdPerson.ExecuteNonQuery()
da.SelectCommand = cmdPerson da.Fill(ds,
"selectedPerson")
'the parameterize query to fetch data on the messages sent by the selected contact
Dim messageSQL As String = "select * from Message_TB where Sender_ID=?“
Dim cmdMessage As New OleDb.OleDbCommand(messageSQL, con)
cmdMessage.CommandType = CommandType.Text
'Creating the parameter and passing the value of the selected ID
cmdMessage.Parameters.AddWithValue("Sender_ID", Person_ID)
cmdMessage.ExecuteNonQuery() da.SelectCommand =
cmdMessage da.Fill(ds, "selectedPersonMessages")
con.Close()
showData()

End Sub
Private Sub showData() txtId.Text =
ds.Tables("selectedPerson").Rows(inc).Item(0) txtFName.Text =
ds.Tables("selectedPerson").Rows(inc).Item(1) txtLName.Text =
ds.Tables("selectedPerson").Rows(inc).Item(2) cmbGender.Text =
ds.Tables("selectedPerson").Rows(inc).Item(3) dtpDateOfBirth.Value =
ds.Tables("selectedPerson").Rows(inc).Item(4) txtEmail.Text =
ds.Tables("selectedPerson").Rows(inc).Item(5) txtPhone.Text =
ds.Tables("selectedPerson").Rows(inc).Item(6) txtAddress.Text =
ds.Tables("selectedPerson").Rows(inc).Item(7) txtDetails.Text =
ds.Tables("selectedPerson").Rows(inc).Item(8)
'link (bound) the Datagridview control to the selectedPersonMessages in the ds dataset
DataGridView1.DataSource = ds.Tables("selectedPersonMessages")
'Display the inserted (ViewMessage) column as the last column in the datagridview
DataGridView1.Columns("ViewMessage").DisplayIndex = 4
End Sub

Private Sub DataGridView1_CellContentClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If e.ColumnIndex = 0 Then
' ViewMessage button clicked
' Get the ID of the selected Message
Dim i As Integer = e.RowIndex
Dim row As DataGridViewRow = DataGridView1.Rows(i)
Dim cell As DataGridViewCell = row.Cells(1)
Dim MessageID As String = cell.Value
' Display the ViewMeassage form
Dim messageForm As New frmViewMeassage
messageForm.Tag = MessageID
messageForm.ShowDialog()
End If End Sub

Private Sub EXITToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


EXITToolStripMenuItem.Click
Me.Close()
End Sub

End Class
SCREENSHOT FOR VIEW MESSAGE

CODE FOR VIEW MESSAGE


Imports System.Data.OleDb
Public Class frmViewMeassage
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim personSQL As String
Dim messageSQL As String
Dim conString As String Dim inc As Integer
Private Sub frmViewMeassage_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
conString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source ='C:\Users\KELVIN
HELARY\source\repos\contactManagerApp\bin\Debug\Contact_db1.mdb'"
con.ConnectionString = conString Dim Message_ID As String
Message_ID = Me.Tag.ToString
Dim messageSQL As String = "select * from Message_TB where M_ID=?"
Dim cmdMessage As New OleDb.OleDbCommand(messageSQL, con)
cmdMessage.CommandType = CommandType.Text
cmdMessage.Parameters.AddWithValue("M_ID", Message_ID) con.Open()
cmdMessage.ExecuteNonQuery()
da.SelectCommand = cmdMessage da.Fill(ds,
"selectedMessage")
con.Close()
displayMessage()

End Sub
Private Sub displayMessage() txtContent.Text =
ds.Tables("selectedMessage").Rows(inc).Item(0) txtSender.Text =
ds.Tables("selectedMessage").Rows(inc).Item(1) txtSentDate.Text =
ds.Tables("selectedMessage").Rows(inc).Item(2) txtContent.Text =
ds.Tables("selectedMessage").Rows(inc).Item(3)
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub End Class
SCREENSHOT FOR CALL_TB TAB

CODE FOR CALL_TB TAB


Private Sub CALLTBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
CALLTBToolStripMenuItem.Click
Dim Person_ID As String = txtId.Text
'txtID is the textbox that contains the ID of the selected contact
Dim messageForm As New frmViewContactCALLS
messageForm.Tag = Person_ID
messageForm.ShowDialog() End
Sub
SCREENSHOT FOR VIEW CONTACT CALLS

CODE FOR VIEW CONTACT CALLS


Imports System.Data.OleDb
Public Class frmViewContactCALLS
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim personSQL As String Dim CallSQL As String Dim conString As String Dim
inc As Integer
Private Sub frmViewContactCALLS_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
conString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source ='C:\Users\KELVIN
HELARY\source\repos\contactManagerApp\bin\Debug\Contact_db1.mdb'"
con.ConnectionString = conString
'used to store the ID of the selected contact passed from Form1
Dim Person_ID As String
Person_ID = Me.Tag.ToString
'the parameterize query to fetch data on the selected contact
Dim personSQL As String = "select * from Person_TB where P_ID=?“
Dim cmdPerson As New OleDb.OleDbCommand(personSQL, con)
cmdPerson.CommandType = CommandType.Text
'Creating the parameter and passing the value of the selected ID
cmdPerson.Parameters.AddWithValue("P_ID", Person_ID) con.Open()
cmdPerson.ExecuteNonQuery()
da.SelectCommand = cmdPerson da.Fill(ds,
"selectedPerson")
'the parameterize query to fetch data on the messages sent by the selected contact
Dim CallSQL As String = "select * from Call_TB where Caller_ID=?"
Dim cmdCall As New OleDb.OleDbCommand(CallSQL, con)
cmdCall.CommandType = CommandType.Text
'Creating the parameter and passing the value of the selected ID
cmdCall.Parameters.AddWithValue("Caller_ID", Person_ID)
cmdCall.ExecuteNonQuery() da.SelectCommand = cmdCall
da.Fill(ds, "selectedPersonCall") con.Close()
showData()

End Sub
Private Sub showData() txtId.Text =
ds.Tables("selectedPerson").Rows(inc).Item(0) txtFName.Text =
ds.Tables("selectedPerson").Rows(inc).Item(1) txtLName.Text =
ds.Tables("selectedPerson").Rows(inc).Item(2) cmbGender.Text =
ds.Tables("selectedPerson").Rows(inc).Item(3) dtpDateOfBirth.Value =
ds.Tables("selectedPerson").Rows(inc).Item(4) txtEmail.Text =
ds.Tables("selectedPerson").Rows(inc).Item(5) txtPhone.Text =
ds.Tables("selectedPerson").Rows(inc).Item(6) txtAddress.Text =
ds.Tables("selectedPerson").Rows(inc).Item(7) txtDetails.Text =
ds.Tables("selectedPerson").Rows(inc).Item(8)
'link (bound) the Datagridview control to the selectedPersonMessages in the ds dataset
DataGridView1.DataSource = ds.Tables("selectedPersonCall")
'Display the inserted (ViewMessage) column as the last column in the datagridview
DataGridView1.Columns("viewCall").DisplayIndex = 5
End Sub

Private Sub DataGridView1_CellContentClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If e.ColumnIndex = 0 Then
' ViewCall button clicked
' Get the ID of the selected Message
Dim i As Integer = e.RowIndex
Dim row As DataGridViewRow = DataGridView1.Rows(i)
Dim cell As DataGridViewCell = row.Cells(1)
Dim Caller_ID As Integer = cell.Value

' Display the ViewCall form


Dim messageForm As New frmViewContactCALLS
messageForm.Tag = Caller_ID
messageForm.ShowDialog()
End If End Sub

End Class

You might also like