Sunteți pe pagina 1din 4

Public Class borrowerrecordsform

Dim accountnoval, lastnameval, firstnameval, middlesnameval, extval,


fullnameval, genderval, contactnoval, permanentaddressval, nameofspouseval,
spousecontactnoval As String
Dim dateofbirthval As Date

Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnclose.Click
applicationform.btnaccount.Show()
applicationform.btnbrowse.Show()
applicationform.btncamera.Show()
applicationform.btnclear.Show()
applicationform.btnsave.Show()
applicationform.btnclose.Show()
Me.Close()
Exit Sub
End Sub

Private Sub borrowerrecordsform_Load(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles MyBase.Load
txtsearch.Clear()
listview_borrowerrecords()
Exit Sub
End Sub

Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles txtsearch.TextChanged
txtsearch.Text = Replace(txtsearch.Text, "'", "`")
txtsearch.SelectionStart = Len(txtsearch.Text)
Dim countval As Integer
countval = "0"
con.Connection = connectionserver
con.CommandText = "SELECT borrowerid,accountno, lastname, firstname,
middlesname, ext, fullname, dateofbirth, gender, contactno, permanentaddress,
nameofspouse, spousecontactno FROM tbl_borrower where accountno like '%" &
txtsearch.Text & "%' or fullname like '%" & txtsearch.Text & "%' order by
accountno asc"
data = con.ExecuteReader
Dim List(13) As String
Dim item As ListViewItem
lvwborrower.Items.Clear()
Do Until data.Read = False
countval = Val(countval) + Val(1)
List(0) = data(0)
List(1) = countval
List(2) = data(1)
List(3) = data(2)
List(4) = data(3)
List(5) = data(4)
List(6) = data(5)
List(7) = data(6)
List(8) = Format(CDate(data(7)), "MMMM dd, yyyy")
List(9) = data(8)
List(10) = data(9)
List(11) = data(10)
List(12) = data(11)
List(13) = data(12)
item = New ListViewItem(List)
lvwborrower.Items.Add(item)
Loop
data.Close()
End Sub

Private Sub lvwborrower_DoubleClick(ByVal sender As Object, ByVal e As


System.EventArgs) Handles lvwborrower.DoubleClick
If lvwborrower.SelectedItems.Count > 0 Then
borroweriddec = lvwborrower.SelectedItems(0).SubItems(0).Text
accountnoval = lvwborrower.SelectedItems(0).SubItems(2).Text
lastnameval = lvwborrower.SelectedItems(0).SubItems(3).Text
firstnameval = lvwborrower.SelectedItems(0).SubItems(4).Text
middlesnameval = lvwborrower.SelectedItems(0).SubItems(5).Text
extval = lvwborrower.SelectedItems(0).SubItems(6).Text
dateofbirthval = lvwborrower.SelectedItems(0).SubItems(8).Text
genderval = lvwborrower.SelectedItems(0).SubItems(9).Text
contactnoval = lvwborrower.SelectedItems(0).SubItems(10).Text
permanentaddressval =
lvwborrower.SelectedItems(0).SubItems(11).Text
nameofspouseval = lvwborrower.SelectedItems(0).SubItems(12).Text
spousecontactnoval =
lvwborrower.SelectedItems(0).SubItems(13).Text

applicationform.lblaccount.Text = accountnoval
applicationform.txtlastname.Text = lastnameval
applicationform.txtfirstname.Text = firstnameval
applicationform.txtmiddlename.Text = middlesnameval
applicationform.txtext.Text = extval
applicationform.dtpdateofbirth.Text = dateofbirthval
applicationform.cbogender.Text = genderval
applicationform.txtcontactno.Text = contactnoval
applicationform.txtpermanentaddress.Text = permanentaddressval
applicationform.txtnameofspouse.Text = nameofspouseval
applicationform.txtspousecontactno.Text = spousecontactnoval
accountstatusdec = "1"
Try
con.Connection = connectionserver
con.CommandText = "select pictureid from tbl_borrower where
borrowerid = '" & borroweriddec & "'"
Dim imageData As Byte() = DirectCast(con.ExecuteScalar(),
Byte())
Dim byteImage() As Byte = imageData
Dim stmFoto As New System.IO.MemoryStream(byteImage)
applicationform.pictureid.Image = Image.FromStream(stmFoto)
applicationform.pictureid.SizeMode =
PictureBoxSizeMode.StretchImage
applicationform.btnaccount.Show()
applicationform.btnbrowse.Show()
applicationform.btncamera.Show()
applicationform.btnclear.Show()
applicationform.btnsave.Show()
applicationform.btnclose.Show()
Me.Close()
Exit Sub
Catch ex As Exception
applicationform.btnaccount.Show()
applicationform.btnbrowse.Show()
applicationform.btncamera.Show()
applicationform.btnclear.Show()
applicationform.btnsave.Show()
applicationform.btnclose.Show()
Me.Close()
Exit Sub
End Try
End If
Exit Sub
End Sub

Private Sub lvwborrower_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
lvwborrower.SelectedIndexChanged
If lvwborrower.SelectedItems.Count > 0 Then
borroweriddec = lvwborrower.SelectedItems(0).SubItems(0).Text
accountnoval = lvwborrower.SelectedItems(0).SubItems(2).Text
lastnameval = lvwborrower.SelectedItems(0).SubItems(3).Text
firstnameval = lvwborrower.SelectedItems(0).SubItems(4).Text
middlesnameval = lvwborrower.SelectedItems(0).SubItems(5).Text
extval = lvwborrower.SelectedItems(0).SubItems(6).Text
dateofbirthval = lvwborrower.SelectedItems(0).SubItems(8).Text
genderval = lvwborrower.SelectedItems(0).SubItems(9).Text
contactnoval = lvwborrower.SelectedItems(0).SubItems(10).Text
permanentaddressval =
lvwborrower.SelectedItems(0).SubItems(11).Text
nameofspouseval = lvwborrower.SelectedItems(0).SubItems(12).Text
spousecontactnoval =
lvwborrower.SelectedItems(0).SubItems(13).Text

applicationform.lblaccount.Text = accountnoval
applicationform.txtlastname.Text = lastnameval
applicationform.txtfirstname.Text = firstnameval
applicationform.txtmiddlename.Text = middlesnameval
applicationform.txtext.Text = extval
applicationform.dtpdateofbirth.Text = dateofbirthval
applicationform.cbogender.Text = genderval
applicationform.txtcontactno.Text = contactnoval
applicationform.txtpermanentaddress.Text = permanentaddressval
applicationform.txtnameofspouse.Text = nameofspouseval
applicationform.txtspousecontactno.Text = spousecontactnoval
accountstatusdec = "1"
Try
con.Connection = connectionserver
con.CommandText = "select pictureid from tbl_borrower where
borrowerid = '" & borroweriddec & "'"
Dim imageData As Byte() = DirectCast(con.ExecuteScalar(),
Byte())
Dim byteImage() As Byte = imageData
Dim stmFoto As New System.IO.MemoryStream(byteImage)
applicationform.pictureid.Image = Image.FromStream(stmFoto)
applicationform.pictureid.SizeMode =
PictureBoxSizeMode.StretchImage
Exit Sub
Catch ex As Exception
Exit Sub
End Try
End If
Exit Sub
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
txtsearch.Clear()
listview_borrowerrecords()
applicationform.borrowerfieldclear()
Exit Sub
End Sub
End Class

S-ar putea să vă placă și