Killsoft Sugdok

pa HELP po sa listview problem

Go down

pa HELP po sa listview problem

Post by Jennessie on Sat Mar 08, 2014 11:48 pm

NAG eerror yung program ko kapag nag blank yung kht isang field ng database ko...
sa listview lng yung problem

ginaya ko kse yung nasa video ni ugdok na nasa listview lng yung program Very Happy


pde nyo ba ko matulungan sa

pag nag click ako sa listview kht na CASE NUMBER lng yung naka lagay e

lalabas na din sa textbox yung 20+ pa na data galing sa database


pa help mga sir!!

kelngan lng sa SYSDES PROJECT NAMIN

Public Class Finder

    Private Sub Finder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        loadlistview()

    End Sub

    'Column names of listview'

    Public Sub loadlistview()

        datareader.Close()

        ListView1.FullRowSelect = True
        ListView1.MultiSelect = False
        ListView1.View = View.Details

        ListView1.Columns.Clear()
        ListView1.Items.Clear()

        ListView1.Columns.Add("Case Number", 105, HorizontalAlignment.Center)
        ListView1.Columns.Add("Last Name", 110, HorizontalAlignment.Center)
        ListView1.Columns.Add("First Name", 110, HorizontalAlignment.Center)
        ListView1.Columns.Add("Middle Name", 110, HorizontalAlignment.Center)

    End Sub

    'Selecting data from database to textbox'

    Public caseno As Integer
    Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
        Dim sqlquery As String = "SELECT * FROM PATIENT"
        Dim sqlcommand As New OleDb.OleDbCommand
        Dim sqladpter As New OleDb.OleDbDataAdapter
        Dim TABLE As New DataTable

        With sqlcommand
            .CommandText = sqlquery
            .Connection = connection
        End With

        With sqladpter
            .SelectCommand = sqlcommand
            .Fill(TABLE)
        End With


        If ListView1.SelectedItems.Count > 0 Then
            caseno = ListView1.SelectedItems(0).Text
            Record.TextBox1.Text = ListView1.SelectedItems(0).SubItems(0).Text  'caseno
            Record.info1.Text = ListView1.SelectedItems(0).SubItems(1).Text     'surname
            Record.info2.Text = ListView1.SelectedItems(0).SubItems(2).Text     'fname  
            Record.info3.Text = ListView1.SelectedItems(0).SubItems(3).Text     'midname
            Record.info4.Text = ListView1.SelectedItems(0).SubItems(4).Text     'birthday
            Record.info5.Text = ListView1.SelectedItems(0).SubItems(5).Text     'age
            Record.info6.Text = ListView1.SelectedItems(0).SubItems(6).Text     'gender
            Record.info7.Text = ListView1.SelectedItems(0).SubItems(7).Text     'senior
            Record.info8.Text = ListView1.SelectedItems(0).SubItems(Cool.Text     'contact1
            Record.info9.Text = ListView1.SelectedItems(0).SubItems(9).Text     'emailadd
            Record.info10.Text = ListView1.SelectedItems(0).SubItems(10).Text   'admitted
            Record.info11.Text = ListView1.SelectedItems(0).SubItems(11).Text   'discharge
            Record.info12.Text = ListView1.SelectedItems(0).SubItems(12).Text   'address1
            Record.info13.Text = ListView1.SelectedItems(0).SubItems(13).Text   'guardian
            Record.info14.Text = ListView1.SelectedItems(0).SubItems(14).Text   'relationship
            Record.info15.Text = ListView1.SelectedItems(0).SubItems(15).Text   'address2
            Record.info16.Text = ListView1.SelectedItems(0).SubItems(16).Text   'contact2
            Record.info17.Text = ListView1.SelectedItems(0).SubItems(17).Text   'diagnosis
            Record.info18.Text = ListView1.SelectedItems(0).SubItems(18).Text   'complication
            Record.info19.Text = ListView1.SelectedItems(0).SubItems(19).Text   'surgical
            Record.info20.Text = ListView1.SelectedItems(0).SubItems(20).Text   'physician
        End If

        TextBox1.Text = ""

        Me.Hide()
        Record.Show()

    End Sub

    'For update'

    Public Sub morph()

        Try

            Dim sqlquery As String = "UPDATE PATIENT SET surname = '" & Record.info1.Text & _
                "', fname = '" & Record.info2.Text & _
                "', midname = '" & Record.info3.Text & _
                "', birthday = '" & Record.info4.Text & _
                "', age = '" & Record.info5.Text & _
                "', gender = '" & Record.info6.Text & _
                "', senior = '" & Record.info7.Text & _
                "', contact1 = '" & Record.info8.Text & _
                "', emailadd = '" & Record.info9.Text & _
                "', admitted = '" & Record.info10.Text & _
                "', discharge = '" & Record.info11.Text & _
                "', address1 = '" & Record.info12.Text & _
                "', guardian = '" & Record.info13.Text & _
                "', relationship = '" & Record.info14.Text & _
                "', address2 = '" & Record.info15.Text &
                "', contact2 = '" & Record.info16.Text & _
                "', diagnosis = '" & Record.info17.Text & _
                "', complication = '" & Record.info18.Text & _
                "', surgical = '" & Record.info19.Text & _
                "', physician = '" & Record.info20.Text & "' WHERE caseno = " & caseno & ";"

            Dim sqlcommand As New OleDb.OleDbCommand

            With sqlcommand
                .CommandText = sqlquery
                .Connection = connection
                .ExecuteNonQuery()
            End With
            MsgBox("Saved")
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

    End Sub

    'Finder'

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        ListView1.Items.Clear()

        Dim sqlquery As String = "SELECT * FROM PATIENT WHERE caseno like '%" & TextBox1.Text & _
            "%' OR surname like '%" & TextBox1.Text & _
            "%' OR fname like '%" & TextBox1.Text & _
            "%' OR midname like '%" & TextBox1.Text & "%'"
        Dim sqlcommand As New OleDb.OleDbCommand
        Dim sqladpter As New OleDb.OleDbDataAdapter
        Dim TABLE As New DataTable

        With sqlcommand
            .CommandText = sqlquery
            .Connection = connection
        End With
        With sqladpter
            .SelectCommand = sqlcommand
            .Fill(TABLE)
        End With

        For i = 0 To TABLE.Rows.Count - 1
            With ListView1
                .Items.Add(TABLE.Rows(i)("caseno"))             '0
                With .Items(.Items.Count - 1).SubItems
                    .Add(TABLE.Rows(i)("surname"))              '1
                    .Add(TABLE.Rows(i)("fname"))                '2      
                    .Add(TABLE.Rows(i)("midname"))              '3
                    .Add(TABLE.Rows(i)("birthday"))             '4
                    .Add(TABLE.Rows(i)("age"))                  '5
                    .Add(TABLE.Rows(i)("gender"))               '6
                    .Add(TABLE.Rows(i)("senior"))               '7
                    .Add(TABLE.Rows(i)("contact1"))             '8
                    .Add(TABLE.Rows(i)("emailadd"))             '9
                    .Add(TABLE.Rows(i)("admitted"))             '10
                    .Add(TABLE.Rows(i)("discharge"))            '11
                    .Add(TABLE.Rows(i)("address1"))             '12
                    .Add(TABLE.Rows(i)("guardian"))             '13
                    .Add(TABLE.Rows(i)("relationship"))         '14
                    .Add(TABLE.Rows(i)("address2"))             '15
                    .Add(TABLE.Rows(i)("contact2"))             '16
                    .Add(TABLE.Rows(i)("diagnosis"))            '17
                    .Add(TABLE.Rows(i)("complication"))         '18
                    .Add(TABLE.Rows(i)("surgical"))             '19
                    .Add(TABLE.Rows(i)("physician"))            '20

                End With
            End With
        Next

        If TextBox1.Text = "" Then

            cleanandgreen()

        End If

    End Sub

    Sub cleanandgreen()

        ListView1.Items.Clear()

    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

        Me.Close()

    End Sub

End Class

Jennessie
Newbie
Newbie

Posts : 1
Join date : 2014-03-08

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum