3 Replies - 1614 Views - Last Post: 07 December 2012 - 12:39 PM Rate Topic: -----

#1 piyuchoxi23  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 2
  • Joined: 07-December 12

how can i refreshing data in datagridview after inserting and editing?

Posted 07 December 2012 - 10:28 AM

form1 
Imports System.Data.SqlClient
Imports System.Data.DataSet


Public Class Form1

    Dim ds1 As New DataSet
    Dim da As New SqlDataAdapter
    Dim cn As New SqlConnection
    Public PatientID As Integer
    Public edPatientID As Integer = Integer.Parse(0)
    Dim dt As DataTable
    Dim cmd As SqlCommand
    Dim dc As Integer
    Dim dr As DataRow
    Dim i As Integer





    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'PatientDataSet2.tblShowDetail' table. You can move, or remove it, as needed.
        Me.TblShowDetailTableAdapter1.Fill(Me.PatientDataSet2.tblShowDetail)
        'TODO: This line of code loads data into the 'PatientDataSet.tblDetails' table. You can move, or remove it, as needed.
        Me.TblDetailsTableAdapter.Fill(Me.PatientDataSet.tblDetails)
        'TODO: This line of code loads data into the 'PatientDataSet1.tblShowDetail' table. You can move, or remove it, as needed.
        Me.TblShowDetailTableAdapter.Fill(Me.PatientDataSet1.tblShowDetail)
        'TODO: This line of code loads data into the 'PatientDataSet.tblDetails' table. You can move, or remove it, as needed.
        'Me.TblDetailsTableAdapter.Fill(Me.PatientDataSet1.tblDetails)

    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        CheckList.Show()
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

        ' DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
        'Dim row As DataGridViewRow = Me.DataGridView1.CurrentRow
        'Me.DataGridView1.Rows.Remove(row)

        Dim cmd As SqlCommand
        Dim i As Integer = DataGridView1.SelectedRows(0).Cells(0).Value
        DataGridView1.Rows.Remove(DataGridView1.SelectedRows(0))
        cn = New SqlConnection("Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True")
        cn.Open()
        Me.PatientID = Convert.ToInt32(i)
        cmd = New SqlCommand("Delete from tblShowDetail where PatientID  = @PatientID", cn)
        cmd.Parameters.AddWithValue("@PatientID", Me.PatientID)
        cmd.ExecuteNonQuery()
        Call databind()

    End Sub

    Private Sub databind()
        Dim cmd As SqlCommand
        cn = New SqlConnection("Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True")
        cn.Open()
        cmd = New SqlCommand("Select * from tblShowDetail", cn)
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        dt = New DataTable()
        dt.Load(dr)
        Me.DataGridView1.DataSource = dt
    End Sub



    Private Sub DataGridView1_CellBeginEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DataGridView1.CellBeginEdit
        Me.WindowState = FormWindowState.Minimized
        CheckList.Show()

    End Sub



    Private Sub btnEdit_Click(sender As System.Object, e As System.EventArgs) Handles btnEdit.Click

        CheckList.Show()
        dc = DataGridView1.CurrentRow.Index
        datafill(dc)



    End Sub


    Public Sub datafill(ByVal z As Integer)
        Dim cmd As SqlCommand
        cn = New SqlConnection("Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True")
        cmd = New SqlCommand("Select * from tblShowDetail", cn)
        ds1 = New DataSet
        da = New SqlDataAdapter(cmd)
        da.Fill(ds1, "CB")
        dt = ds1.Tables(0)
        DataGridView1.DataSource = dt
        dr = dt.Rows(z)
        edPatientID = DataGridView1.Item(0, z).Value
        CheckList.Txtfn.Text = DataGridView1.Item(1, z).Value.ToString
        CheckList.txtln.Text = DataGridView1.Item(2, z).Value.ToString
        CheckList.txtadd.Text = DataGridView1.Item(3, z).Value.ToString
        CheckList.txtaptno.Text = DataGridView1.Item(4, z).Value.ToString
        CheckList.txtct.Text = DataGridView1.Item(5, z).Value.ToString
        CheckList.txtstate.Text = DataGridView1.Item(6, z).Value.ToString
        CheckList.txtemrnmcont.Text = DataGridView1.Item(7, z).Value.ToString
        CheckList.DateTimePicker1.Text = DataGridView1.Item(8, z).Value.ToString
        CheckList.txtcontno.Text = DataGridView1.Item(9, z).Value.ToString
        CheckList.txtaidnm.Text = DataGridView1.Item(10, z).Value.ToString
        CheckList.sdtInitial.Text = DataGridView1.Item(11, z).Value.ToString
        'CheckList.ldtInitial.Text = DataGridView1.Item(12, z).Value.ToString
        CheckList.initialint.Text = DataGridView1.Item(12, z).Value.ToString
        CheckList.cdtInitial.Text = DataGridView1.Item(13, z).Value.ToString
        CheckList.sdtPC.Text = DataGridView1.Item(14, z).Value.ToString
        'CheckList.ldtPC.Text = DataGridView1.Item(15, z).Value.ToString
        CheckList.phycicerti.Text = DataGridView1.Item(15, z).Value.ToString
        CheckList.cdtPC.Text = DataGridView1.Item(16, z).Value.ToString
        CheckList.sdtdss.Text = DataGridView1.Item(17, z).Value.ToString
        CheckList.ldtdss.Text = DataGridView1.Item(18, z).Value.ToString
        CheckList.cdtdss.Text = DataGridView1.Item(19, z).Value.ToString
        CheckList.sdtad.Text = DataGridView1.Item(20, z).Value.ToString
        CheckList.ldtad.Text = DataGridView1.Item(21, z).Value.ToString
        CheckList.cdtad.Text = DataGridView1.Item(22, z).Value.ToString
        CheckList.sdtsa.Text = DataGridView1.Item(23, z).Value.ToString
        CheckList.ldtsa.Text = DataGridView1.Item(24, z).Value.ToString
        CheckList.cdtsa.Text = DataGridView1.Item(25, z).Value.ToString
        CheckList.sdtpbor.Text = DataGridView1.Item(26, z).Value.ToString
        CheckList.ldtpbor.Text = DataGridView1.Item(27, z).Value.ToString
        CheckList.cdtpbor.Text = DataGridView1.Item(28, z).Value.ToString
        CheckList.sdtia.Text = DataGridView1.Item(29, z).Value.ToString
        CheckList.ldtia.Text = DataGridView1.Item(30, z).Value.ToString
        CheckList.cdtia.Text = DataGridView1.Item(31, z).Value.ToString
        CheckList.sdtmp.Text = DataGridView1.Item(32, z).Value.ToString
        CheckList.ldtmp.Text = DataGridView1.Item(33, z).Value.ToString
        CheckList.cdtmp.Text = DataGridView1.Item(34, z).Value.ToString
        CheckList.sdtPlan.Text = DataGridView1.Item(35, z).Value.ToString
        CheckList.ldtPlan.Text = DataGridView1.Item(36, z).Value.ToString
        CheckList.cdtPlan.Text = DataGridView1.Item(37, z).Value.ToString
        CheckList.sdtdp.Text = DataGridView1.Item(38, z).Value.ToString
        CheckList.ldtdp.Text = DataGridView1.Item(39, z).Value.ToString
        CheckList.cdtdp.Text = DataGridView1.Item(40, z).Value.ToString
        CheckList.sdtotc.Text = DataGridView1.Item(41, z).Value.ToString
        CheckList.ldtotc.Text = DataGridView1.Item(42, z).Value.ToString
        CheckList.cdtotc.Text = DataGridView1.Item(43, z).Value.ToString
        CheckList.sdtstc.Text = DataGridView1.Item(44, z).Value.ToString
        CheckList.ldtstc.Text = DataGridView1.Item(45, z).Value.ToString
        CheckList.cdtstc.Text = DataGridView1.Item(46, z).Value.ToString
        CheckList.sdtcmn.Text = DataGridView1.Item(47, z).Value.ToString
        CheckList.ldtcmn.Text = DataGridView1.Item(48, z).Value.ToString
        CheckList.cdtcmn.Text = DataGridView1.Item(49, z).Value.ToString
        CheckList.sdtas.Text = DataGridView1.Item(50, z).Value.ToString
        CheckList.ldtas.Text = DataGridView1.Item(51, z).Value.ToString
        CheckList.cdtas.Text = DataGridView1.Item(52, z).Value.ToString
        CheckList.sdtre.Text = DataGridView1.Item(53, z).Value.ToString
        CheckList.ldtre.Text = DataGridView1.Item(54, z).Value.ToString
        CheckList.cdtre.Text = DataGridView1.Item(55, z).Value.ToString
        CheckList.txtcomm.Text = DataGridView1.Item(56, z).Value.ToString





    End Sub

    Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick


    End Sub
End Class

form2- checklist

Imports System.Data.SqlClient

Public Class CheckList
    Dim cn As New SqlConnection
    Dim cmd As SqlCommand
    Dim rd As SqlDataReader
    Dim ds1 As New DataSet
    Dim da As New SqlDataAdapter
    Dim strACID As String
    Dim intACID As Integer
    Dim strInitialID As String
    Dim intInitialID As Integer
    Dim strPOCID As String
    Dim intPOCID As Integer
    Dim strADID As String
    Dim intADID As Integer
    Dim strAidID As String
    Dim intAidID As Integer
    Dim strCMNID As String
    Dim intCMNID As Integer
    Dim strCommID As String
    Dim intCommID As Integer
    Dim strDisID As String
    Dim intDisID As Integer
    Dim strInAssementID As String
    Dim intInAssementID As Integer
    Dim strMediID As String
    Dim intMediID As Integer
    Dim strOrientationID As String
    Dim intOrientationID As Integer
    Dim strPBORID As String
    Dim intPBORID As Integer
    Dim strPatientID As String
    Dim intPatientID As Integer
    Dim strPSCID As String
    Dim intPCSID As Integer
    Dim strREID As String
    Dim intREID As Integer
    Dim strServiceAID As String
    Dim intServiceAID As Integer
    Dim strServiceDID As String
    Dim intServiceDID As Integer
    Dim strSupervisionID As String
    Dim intSupervisionID As Integer
    Dim dt As DataTable
    Dim df As Integer
    'Dim table As DataTable = ds1.Table(0)



    Private Property ex As Object
    Public Property datasource() As Object


    Public Sub ClearTextBox(ByVal root As Control)
        For Each ctrl As Control In root.Controls
            ClearTextBox(ctrl)
            If TypeOf ctrl Is TextBox Then
                CType(ctrl, TextBox).Text = String.Empty
            End If
        Next ctrl
    End Sub

    Private Sub btnAdd1_Click(sender As Object, e As EventArgs) Handles btnAdd1.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(InitialID) from tblIntake"
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblIntake values( @PatientID, @SDate, @LDate, @CDate)"
        cmd.Connection = cn


        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SDate", DateTime.Parse(sdtInitial.Text))
        cmd.Parameters.AddWithValue("@LDate", DateTime.Parse(initialint.Text))
        cmd.Parameters.AddWithValue("@CDate", DateTime.Parse(cdtInitial.Text))
        

        cmd.ExecuteNonQuery()
        cn.Close()


        MsgBox("Added....!!!!")

    End Sub

    Private Sub btnAdd2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd2.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(PSCID) from tblPCP "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblPCP values(@PatientID, @SPh_Certification, @LPh_Certification, @CPh_Certification)"
        cmd.Connection = cn


        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SPh_Certification", DateTime.Parse(sdtPC.Text))
        cmd.Parameters.AddWithValue("@LPh_Certification", DateTime.Parse(phycicerti.Text))
        cmd.Parameters.AddWithValue("@CPh_Certification", DateTime.Parse(cdtPC.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd3_Click(sender As Object, e As EventArgs) Handles btnAdd3.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(ServiceDtID) from tblServicesDt "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblServicesDt values(@PatientID, @SServiceDt, @LServiceDt, @CServiceDt)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@ServiceDtID", intServiceDID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SServiceDt", DateTime.Parse(sdtdss.Text))
        cmd.Parameters.AddWithValue("@LServiceDt", DateTime.Parse(ldtdss.Text))
        cmd.Parameters.AddWithValue("@CServiceDt", DateTime.Parse(cdtdss.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd4_Click(sender As Object, e As EventArgs) Handles btnAdd4.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(ADID) from tblADirectives "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblADirectives values(@PatientID, @SAD_Directives, @LAD_Directives, @CAD_Directives)"
        cmd.Connection = cn

        ' cmd.Parameters.AddWithValue("@ADID", intServiceDID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SAD_Directives", DateTime.Parse(sdtad.Text))
        cmd.Parameters.AddWithValue("@LAD_Directives", DateTime.Parse(ldtad.Text))
        cmd.Parameters.AddWithValue("@CAD_Directives", DateTime.Parse(cdtad.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd5_Click(sender As Object, e As EventArgs) Handles btnAdd5.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(ServiceAID) from tblServiceAgree "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblServiceAgree values(@PatientID, @SServiece_Agreement, @LServiece_Agreement, @CServiece_Agreement)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@ServiceAID", intServiceAID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SServiece_Agreement", DateTime.Parse(sdtsa.Text))
        cmd.Parameters.AddWithValue("@LServiece_Agreement", DateTime.Parse(ldtsa.Text))
        cmd.Parameters.AddWithValue("@CServiece_Agreement", DateTime.Parse(cdtsa.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")

    End Sub

    Private Sub btnAdd6_Click(sender As Object, e As EventArgs) Handles btnAdd6.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(PBORID) from tblPatientBill "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblPatientBill values(@PatientID, @SPBill_Of_Rights, @LPBill_Of_Rights, @CPBill_Of_Rights)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@ServiceAID", intServiceAID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SPBill_Of_Rights", DateTime.Parse(sdtpbor.Text))
        cmd.Parameters.AddWithValue("@LPBill_Of_Rights", DateTime.Parse(ldtpbor.Text))
        cmd.Parameters.AddWithValue("@CPBill_Of_Rights", DateTime.Parse(cdtpbor.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")


        'cn = New SqlConnection()
        'cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        'cn.Open()

        'cmd = New SqlCommand()
        'cmd.CommandText = "Select max(PBORID) from tblPatientBill "
        'cmd.Connection = cn

        'rd = cmd.ExecuteReader()

        'While rd.Read()


        '    intPatientID = 1
        'End While

        'rd.Close()

        'cmd = New SqlCommand()
        'cmd.CommandText = "Insert into tblPatientBill values(@PatientID, @SPBill_Of_Rights, @LPBill_Of_Rights, @CPBill_Of_Rights)"
        'cmd.Connection = cn

        ''cmd.Parameters.AddWithValue("@PBORID", intPBORID)
        'cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        'cmd.Parameters.AddWithValue("@SPBill_Of_Rights", DateTime.Parse(sdtpbor.Text))
        'cmd.Parameters.AddWithValue("@LPBill_Of_Rights", DateTime.Parse(ldtpbor.Text))
        'cmd.Parameters.AddWithValue("@CPBill_Of_Rights", DateTime.Parse(cdtpbor.Text))


        'cmd.ExecuteNonQuery()
        'cn.Close()

        'MsgBox("Added....!!!!")
    End Sub


    Private Sub btnAdd7_Click(sender As Object, e As EventArgs) Handles btnAdd7.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(InAssementID) from tblInitialAssessment "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblInitialAssessment values(@PatientID, @SInitial_Assement, @LInitial_Assement, @CInitial_Assement)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@InAssementID", intInAssementID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SInitial_Assement", DateTime.Parse(sdtia.Text))
        cmd.Parameters.AddWithValue("@LInitial_Assement", DateTime.Parse(ldtia.Text))
        cmd.Parameters.AddWithValue("@CInitial_Assement", DateTime.Parse(cdtia.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd8_Click(sender As Object, e As EventArgs) Handles btnAdd8.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(MediID) from tblMedication "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblMedication values(@PatientID, @SMedication_Profile, @LMedication_Profile, @CMedication_Profile)"
        cmd.Connection = cn

        'cmd.Parameters.AddWthValue("@MediID", intMediID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SMedication_Profile", DateTime.Parse(sdtmp.Text))
        cmd.Parameters.AddWithValue("@LMedication_Profile", DateTime.Parse(ldtmp.Text))
        cmd.Parameters.AddWithValue("@CMedication_Profile", DateTime.Parse(cdtmp.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd9_Click(sender As Object, e As EventArgs) Handles btnAdd9.Click

        If Date.Now.Day <> 60 Then
            MsgBox("Your Plan Of Care, is out-of-date and needs update", MsgBoxStyle.Information, "Trial mode")
            cn = New SqlConnection()
            cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
            cn.Open()
            cmd = New SqlCommand
            cmd.CommandText = "Select max(POCID) from tblPlanOfCare"
            cmd.Connection = cn

            rd = cmd.ExecuteReader()

            While rd.Read()


                intPatientID = 1
            End While

            rd.Close()

            cmd = New SqlCommand()
            cmd.CommandText = "Insert into tblPlanOfCare values (@PatientID, @AidID, @SPlan_Of_Care, @LPlan_Of_Care, @CPlan_Of_Care)"
            cmd.Connection = cn

            'cmd.Parameters.AddWithValue("@POCID", intPOCID)
            cmd.Parameters.AddWithValue("@PatientID", intPatientID)
            cmd.Parameters.AddWithValue("@AidID", intAidID)
            cmd.Parameters.AddWithValue("@SPlan_Of_Care", DateTime.Parse(sdtPlan.Text))
            cmd.Parameters.AddWithValue("@LPlan_Of_Care", DateTime.Parse(ldtPlan.Text))
            cmd.Parameters.AddWithValue("@CPlan_Of_Care", DateTime.Parse(cdtPlan.Text))

            cmd.ExecuteNonQuery()
            cn.Close()
           
            MsgBox("Added...!!!")


        End If
    End Sub


   
    Private Sub CheckList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        If MsgBox("Are you sure to exit", MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.No Then
            e.Cancel = True
        End If
    End Sub


    Private Sub CheckList_Load(sender As Object, e As EventArgs) Handles Me.Load
        'fade_in()
        'If Date.Now.Day <> 60 Then
        '    MsgBox("Your Plan Of Care, Supervision, Case Monitoring are out-of-date and needs update", MsgBoxStyle.Information, "Trial mode")
        '    Me.Close()
        'Else

        cdtInitial.Value = Now
        Me.Show()

        'End If
    End Sub

    Public Sub fade_in()
        For FadeIn = 0.0 To 1.1 Step 0.1
            Me.Opacity = FadeIn
            Me.Refresh()
            Threading.Thread.Sleep(100)
        Next
    End Sub

    Public Sub fade_out()
        For FadeOut = 90 To 10 Step -10
            Me.Opacity = FadeOut / 100
            Me.Refresh()
            Threading.Thread.Sleep(50)
        Next
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        cn = New SqlConnection()


        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()
        cmd = New SqlCommand()
        cmd.Connection = cn
        Try
            Me.Controls.Add(New DataGridView)
            

            cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
            cn.Open()

            da = New SqlDataAdapter(cmd.CommandText, cn)
            da.Fill(ds1)
            Dim datagridview1 As New DataGridView
            Controls.Add(datagridview1)
            datagridview1.DataSource = (ds1.Tables(0))
            MsgBox(ex.ToString)
        Catch ex As Exception

        End Try


        Dim str As String = "SELET tblShowDetail * FROM tblShowDetail"
        cmd = New SqlCommand()
        cmd.CommandText = "select * from tblShowDetail;"


        cmd.Connection = cn

        rd = cmd.ExecuteReader()
        ' DataGridView1.show()
        MsgBox(Form1.edPatientID)


        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()
        If (Form1.edPatientID = 0) Then

            cmd = New SqlCommand()
            ' cmd.CommandText = "Insert into tblShowDetail values(@patientID, @FName, @LName, @Address, @AptNo, @City, @State, @DOB, @Contact, @EName_Number, @AidName, @SDate, @LDate, @CDate, @SPh_Certification, @LPh_Certification ,@CPh_Certification, @SServiceDt, @LServiceDt, @CServiceDt, @SAD_Directives, @LAD_Directives, @CAD_Directives, @SServiece_Agreement, @LServiece_Agreement, @CServiece_Agreement, @SPBill_Of_Rights, @LPBill_Of_Rights, @CPBill_Of_Rights, @SInitial_Assement, @LInitial_Assement, @CInitial_Assement, @SMedication_Profile, @LMedication_Profile, @CMedication_Profile, @SPlan_Of_Care, @LPlan_Of_Care, @CPlan_Of_Care, @SDischarge_Plan, @LDischarge_Plan, @CDischarge_Plan, @SOrientation, @LOrientation, @COrientation, @SSupervision, @LSupervision, @CSupervision, @SCMN, @LCMN, @CCMN, @SAC, @LAC, @CAC, @LReAssement, @SReAssement, @CReAssement, @Comment)"
            cmd.CommandText = "Insert into tblShowDetail (FName, LName, Address, AptNo, City, State, DOB, Contact, EName_Number, AidName, SDate, LDate, CDate, SPh_Certification, LPh_Certification ,CPh_Certification, SServiceDt, LServiceDt, CServiceDt, SAD_Directives, LAD_Directives, CAD_Directives, SServiece_Agreement, LServiece_Agreement, CServiece_Agreement, SPBill_Of_Rights, LPBill_Of_Rights, CPBill_Of_Rights, SInitial_Assement, LInitial_Assement, CInitial_Assement, SMedication_Profile, LMedication_Profile, CMedication_Profile, SPlan_Of_Care, LPlan_Of_Care, CPlan_Of_Care, SDischarge_Plan, LDischarge_Plan, CDischarge_Plan, SOrientation, LOrientation, COrientation, SSupervision, LSupervision, CSupervision, SCMN, LCMN, CCMN, SAC, LAC, CAC, LReAssement, SReAssement, CReAssement, Comment) values(@FName, @LName, @Address, @AptNo, @City, @State, @DOB, @Contact, @EName_Number, @AidName, @SDate, @LDate, @CDate, @SPh_Certification, @LPh_Certification ,@CPh_Certification, @SServiceDt, @LServiceDt, @CServiceDt, @SAD_Directives, @LAD_Directives, @CAD_Directives, @SServiece_Agreement, @LServiece_Agreement, @CServiece_Agreement, @SPBill_Of_Rights, @LPBill_Of_Rights, @CPBill_Of_Rights, @SInitial_Assement, @LInitial_Assement, @CInitial_Assement, @SMedication_Profile, @LMedication_Profile, @CMedication_Profile, @SPlan_Of_Care, @LPlan_Of_Care, @CPlan_Of_Care, @SDischarge_Plan, @LDischarge_Plan, @CDischarge_Plan, @SOrientation, @LOrientation, @COrientation, @SSupervision, @LSupervision, @CSupervision, @SCMN, @LCMN, @CCMN, @SAC, @LAC, @CAC, @LReAssement, @SReAssement, @CReAssement, @Comment)"
            cmd.Connection = cn

            'cmd.Parameters.AddWithValue("@patientID", intPatientID)
            cmd.Parameters.AddWithValue("@FName", Txtfn.Text)
            cmd.Parameters.AddWithValue("@LName", txtln.Text)
            cmd.Parameters.AddWithValue("@Address", txtadd.Text)
            cmd.Parameters.AddWithValue("@AptNo", txtaptno.Text)
            cmd.Parameters.AddWithValue("@City", txtct.Text)
            cmd.Parameters.AddWithValue("@State", txtstate.Text)
            cmd.Parameters.AddWithValue("@DOB", DateTime.Parse(DateTimePicker1.Text))
            cmd.Parameters.AddWithValue("@Contact", txtcontno.Text)
            cmd.Parameters.AddWithValue("@EName_Number", txtemrnmcont.Text)
            cmd.Parameters.AddWithValue("@AidName", txtaidnm.Text)
            cmd.Parameters.AddWithValue("@SDate", DateTime.Parse(sdtInitial.Text))
            cmd.Parameters.AddWithValue("@LDate", DateTime.Parse(initialint.Text))
            cmd.Parameters.AddWithValue("@CDate", DateTime.Parse(cdtInitial.Text))
            cmd.Parameters.AddWithValue("@SPh_Certification", DateTime.Parse(sdtPC.Text))
            cmd.Parameters.AddWithValue("@LPh_Certification", DateTime.Parse(phycicerti.Text))
            cmd.Parameters.AddWithValue("@CPh_Certification", DateTime.Parse(cdtPC.Text))
            cmd.Parameters.AddWithValue("@SServiceDt", DateTime.Parse(sdtdss.Text))
            cmd.Parameters.AddWithValue("@LServiceDt", DateTime.Parse(ldtdss.Text))
            cmd.Parameters.AddWithValue("@CServiceDt", DateTime.Parse(cdtdss.Text))
            cmd.Parameters.AddWithValue("@SAD_Directives", DateTime.Parse(sdtad.Text))
            cmd.Parameters.AddWithValue("@LAD_Directives", DateTime.Parse(ldtad.Text))
            cmd.Parameters.AddWithValue("@CAD_Directives", DateTime.Parse(cdtad.Text))
            cmd.Parameters.AddWithValue("@SServiece_Agreement", DateTime.Parse(sdtsa.Text))
            cmd.Parameters.AddWithValue("@LServiece_Agreement", DateTime.Parse(ldtsa.Text))
            cmd.Parameters.AddWithValue("@CServiece_Agreement", DateTime.Parse(cdtsa.Text))
            cmd.Parameters.AddWithValue("@SPBill_Of_Rights", DateTime.Parse(sdtpbor.Text))
            cmd.Parameters.AddWithValue("@LPBill_Of_Rights", DateTime.Parse(ldtpbor.Text))
            cmd.Parameters.AddWithValue("@CPBill_Of_Rights", DateTime.Parse(cdtpbor.Text))
            cmd.Parameters.AddWithValue("@SInitial_Assement", DateTime.Parse(sdtia.Text))
            cmd.Parameters.AddWithValue("@LInitial_Assement", DateTime.Parse(ldtia.Text))
            cmd.Parameters.AddWithValue("@CInitial_Assement", DateTime.Parse(cdtia.Text))
            cmd.Parameters.AddWithValue("@SMedication_Profile", DateTime.Parse(sdtmp.Text))
            cmd.Parameters.AddWithValue("@LMedication_Profile", DateTime.Parse(ldtmp.Text))
            cmd.Parameters.AddWithValue("@CMedication_Profile", DateTime.Parse(cdtmp.Text))
            cmd.Parameters.AddWithValue("@SPlan_Of_Care", DateTime.Parse(sdtPlan.Text))
            cmd.Parameters.AddWithValue("@LPlan_Of_Care", DateTime.Parse(ldtPlan.Text))
            cmd.Parameters.AddWithValue("@CPlan_Of_Care", DateTime.Parse(cdtPlan.Text))
            cmd.Parameters.AddWithValue("@SDischarge_Plan", DateTime.Parse(sdtdp.Text))
            cmd.Parameters.AddWithValue("@LDischarge_Plan", DateTime.Parse(ldtdp.Text))
            cmd.Parameters.AddWithValue("@CDischarge_Plan", DateTime.Parse(cdtdp.Text))
            cmd.Parameters.AddWithValue("@SOrientation", DateTime.Parse(sdtotc.Text))
            cmd.Parameters.AddWithValue("@LOrientation", DateTime.Parse(ldtotc.Text))
            cmd.Parameters.AddWithValue("@COrientation", DateTime.Parse(cdtotc.Text))
            cmd.Parameters.AddWithValue("@SSupervision", DateTime.Parse(sdtstc.Text))
            cmd.Parameters.AddWithValue("@LSupervision", DateTime.Parse(ldtstc.Text))
            cmd.Parameters.AddWithValue("@CSupervision", DateTime.Parse(cdtstc.Text))
            cmd.Parameters.AddWithValue("@SCMN", DateTime.Parse(sdtcmn.Text))
            cmd.Parameters.AddWithValue("@LCMN", DateTime.Parse(ldtcmn.Text))
            cmd.Parameters.AddWithValue("@CCMN", DateTime.Parse(cdtcmn.Text))
            cmd.Parameters.AddWithValue("@SAC", DateTime.Parse(sdtas.Text))
            cmd.Parameters.AddWithValue("@LAC", DateTime.Parse(ldtas.Text))
            cmd.Parameters.AddWithValue("@CAC", DateTime.Parse(cdtas.Text))
            cmd.Parameters.AddWithValue("@SReAssement", DateTime.Parse(sdtre.Text))
            cmd.Parameters.AddWithValue("@LReAssement", DateTime.Parse(ldtre.Text))
            cmd.Parameters.AddWithValue("@CReAssement", DateTime.Parse(cdtre.Text))
            cmd.Parameters.AddWithValue("@Comment", txtcomm.Text)
            cmd.ExecuteNonQuery()
            cn.Close()



            MsgBox("Added....!!!!")
            MessageBox.Show("Button on Form1 was clicked!")
            Form1.Show()
        Else
            cmd = New SqlCommand()
            ' cmd.CommandText = "Insert into tblShowDetail values(@patientID, @FName, @LName, @Address, @AptNo, @City, @State, @DOB, @Contact, @EName_Number, @AidName, @SDate, @LDate, @CDate, @SPh_Certification, @LPh_Certification ,@CPh_Certification, @SServiceDt, @LServiceDt, @CServiceDt, @SAD_Directives, @LAD_Directives, @CAD_Directives, @SServiece_Agreement, @LServiece_Agreement, @CServiece_Agreement, @SPBill_Of_Rights, @LPBill_Of_Rights, @CPBill_Of_Rights, @SInitial_Assement, @LInitial_Assement, @CInitial_Assement, @SMedication_Profile, @LMedication_Profile, @CMedication_Profile, @SPlan_Of_Care, @LPlan_Of_Care, @CPlan_Of_Care, @SDischarge_Plan, @LDischarge_Plan, @CDischarge_Plan, @SOrientation, @LOrientation, @COrientation, @SSupervision, @LSupervision, @CSupervision, @SCMN, @LCMN, @CCMN, @SAC, @LAC, @CAC, @LReAssement, @SReAssement, @CReAssement, @Comment)"
            cmd.CommandText = "Update tblShowDetail set FName = @FName, LName = @LName, Address = @Address, AptNo = @AptNo, City = @City, State = @State, DOB = @DOB, Contact = @Contact, EName_Number = @EName_Number, AidName = @AidName, SDate = @SDate, LDate = LDate, CDate = CDate, SPh_Certification = @SPh_Certification, LPh_Certification = @LPh_Certification ,CPh_Certification = @CPh_Certification, SServiceDt = @SServiceDt, LServiceDt = @LServiceDt, CServiceDt = @CServiceDt, SAD_Directives = @SAD_Directives, LAD_Directives = @LAD_Directives, CAD_Directives = @CAD_Directives, SServiece_Agreement = @SServiece_Agreement, LServiece_Agreement = @LServiece_Agreement, CServiece_Agreement = @CServiece_Agreement, SPBill_Of_Rights = @SPBill_Of_Rights, LPBill_Of_Rights = @LPBill_Of_Rights, CPBill_Of_Rights = @CPBill_Of_Rights, SInitial_Assement = @SInitial_Assement, LInitial_Assement = @LInitial_Assement, CInitial_Assement = @CInitial_Assement, SMedication_Profile = @SMedication_Profile, LMedication_Profile = @LMedication_Profile, CMedication_Profile = @CMedication_Profile, SPlan_Of_Care = @SPlan_Of_Care, LPlan_Of_Care = @LPlan_Of_Care, CPlan_Of_Care = @CPlan_Of_Care, SDischarge_Plan = @SDischarge_Plan, LDischarge_Plan = @LDischarge_Plan, CDischarge_Plan = @CDischarge_Plan, SOrientation = @SOrientation, LOrientation = @LOrientation, COrientation = @COrientation, SSupervision = @SSupervision, LSupervision = @LSupervision, CSupervision = @CSupervision, SCMN = @SCMN, LCMN = @LCMN, CCMN = @CCMN, SAC = @SAC, LAC = @LAC, CAC = @CAC, LReAssement = @LReAssement, SReAssement = @SReAssement, CReAssement = @CReAssement, Comment = @Comment where PatientID = @edPatientID"
            cmd.Connection = cn

            cmd.Parameters.AddWithValue("@edPatientID", Form1.edPatientID)
            cmd.Parameters.AddWithValue("@FName", Txtfn.Text)
            cmd.Parameters.AddWithValue("@LName", txtln.Text)
            cmd.Parameters.AddWithValue("@Address", txtadd.Text)
            cmd.Parameters.AddWithValue("@AptNo", txtaptno.Text)
            cmd.Parameters.AddWithValue("@City", txtct.Text)
            cmd.Parameters.AddWithValue("@State", txtstate.Text)
            cmd.Parameters.AddWithValue("@DOB", DateTime.Parse(DateTimePicker1.Text))
            cmd.Parameters.AddWithValue("@Contact", txtcontno.Text)
            cmd.Parameters.AddWithValue("@EName_Number", txtemrnmcont.Text)
            cmd.Parameters.AddWithValue("@AidName", txtaidnm.Text)
            cmd.Parameters.AddWithValue("@SDate", DateTime.Parse(sdtInitial.Text))
            cmd.Parameters.AddWithValue("@LDate", DateTime.Parse(initialint.Text))
            cmd.Parameters.AddWithValue("@CDate", DateTime.Parse(cdtInitial.Text))
            cmd.Parameters.AddWithValue("@SPh_Certification", DateTime.Parse(sdtPC.Text))
            cmd.Parameters.AddWithValue("@LPh_Certification", DateTime.Parse(phycicerti.Text))
            cmd.Parameters.AddWithValue("@CPh_Certification", DateTime.Parse(cdtPC.Text))
            cmd.Parameters.AddWithValue("@SServiceDt", DateTime.Parse(sdtdss.Text))
            cmd.Parameters.AddWithValue("@LServiceDt", DateTime.Parse(ldtdss.Text))
            cmd.Parameters.AddWithValue("@CServiceDt", DateTime.Parse(cdtdss.Text))
            cmd.Parameters.AddWithValue("@SAD_Directives", DateTime.Parse(sdtad.Text))
            cmd.Parameters.AddWithValue("@LAD_Directives", DateTime.Parse(ldtad.Text))
            cmd.Parameters.AddWithValue("@CAD_Directives", DateTime.Parse(cdtad.Text))
            cmd.Parameters.AddWithValue("@SServiece_Agreement", DateTime.Parse(sdtsa.Text))
            cmd.Parameters.AddWithValue("@LServiece_Agreement", DateTime.Parse(ldtsa.Text))
            cmd.Parameters.AddWithValue("@CServiece_Agreement", DateTime.Parse(cdtsa.Text))
            cmd.Parameters.AddWithValue("@SPBill_Of_Rights", DateTime.Parse(sdtpbor.Text))
            cmd.Parameters.AddWithValue("@LPBill_Of_Rights", DateTime.Parse(ldtpbor.Text))
            cmd.Parameters.AddWithValue("@CPBill_Of_Rights", DateTime.Parse(cdtpbor.Text))
            cmd.Parameters.AddWithValue("@SInitial_Assement", DateTime.Parse(sdtia.Text))
            cmd.Parameters.AddWithValue("@LInitial_Assement", DateTime.Parse(ldtia.Text))
            cmd.Parameters.AddWithValue("@CInitial_Assement", DateTime.Parse(cdtia.Text))
            cmd.Parameters.AddWithValue("@SMedication_Profile", DateTime.Parse(sdtmp.Text))
            cmd.Parameters.AddWithValue("@LMedication_Profile", DateTime.Parse(ldtmp.Text))
            cmd.Parameters.AddWithValue("@CMedication_Profile", DateTime.Parse(cdtmp.Text))
            cmd.Parameters.AddWithValue("@SPlan_Of_Care", DateTime.Parse(sdtPlan.Text))
            cmd.Parameters.AddWithValue("@LPlan_Of_Care", DateTime.Parse(ldtPlan.Text))
            cmd.Parameters.AddWithValue("@CPlan_Of_Care", DateTime.Parse(cdtPlan.Text))
            cmd.Parameters.AddWithValue("@SDischarge_Plan", DateTime.Parse(sdtdp.Text))
            cmd.Parameters.AddWithValue("@LDischarge_Plan", DateTime.Parse(ldtdp.Text))
            cmd.Parameters.AddWithValue("@CDischarge_Plan", DateTime.Parse(cdtdp.Text))
            cmd.Parameters.AddWithValue("@SOrientation", DateTime.Parse(sdtotc.Text))
            cmd.Parameters.AddWithValue("@LOrientation", DateTime.Parse(ldtotc.Text))
            cmd.Parameters.AddWithValue("@COrientation", DateTime.Parse(cdtotc.Text))
            cmd.Parameters.AddWithValue("@SSupervision", DateTime.Parse(sdtstc.Text))
            cmd.Parameters.AddWithValue("@LSupervision", DateTime.Parse(ldtstc.Text))
            cmd.Parameters.AddWithValue("@CSupervision", DateTime.Parse(cdtstc.Text))
            cmd.Parameters.AddWithValue("@SCMN", DateTime.Parse(sdtcmn.Text))
            cmd.Parameters.AddWithValue("@LCMN", DateTime.Parse(ldtcmn.Text))
            cmd.Parameters.AddWithValue("@CCMN", DateTime.Parse(cdtcmn.Text))
            cmd.Parameters.AddWithValue("@SAC", DateTime.Parse(sdtas.Text))
            cmd.Parameters.AddWithValue("@LAC", DateTime.Parse(ldtas.Text))
            cmd.Parameters.AddWithValue("@CAC", DateTime.Parse(cdtas.Text))
            cmd.Parameters.AddWithValue("@SReAssement", DateTime.Parse(sdtre.Text))
            cmd.Parameters.AddWithValue("@LReAssement", DateTime.Parse(ldtre.Text))
            cmd.Parameters.AddWithValue("@CReAssement", DateTime.Parse(cdtre.Text))
            cmd.Parameters.AddWithValue("@Comment", txtcomm.Text)




            cmd.ExecuteNonQuery()
            cn.Close()

            Form1.edPatientID = Integer.Parse(0)


            MsgBox("In Edit....!!!!")

        End If
    End Sub
    

   



    Private Sub btnAdd10_Click(sender As Object, e As EventArgs) Handles btnAdd10.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(DisID) from tblDischarge "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            ' intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblDischarge values(@PatientID, @SDischarge_Plan, @LDischarge_Plan, @CDischarge_Plan)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@DisID", intDisID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SDischarge_Plan", DateTime.Parse(sdtdp.Text))
        cmd.Parameters.AddWithValue("@LDischarge_Plan", DateTime.Parse(ldtdp.Text))
        cmd.Parameters.AddWithValue("@CDischarge_Plan", DateTime.Parse(cdtdp.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd11_Click(sender As Object, e As EventArgs) Handles btnAdd11.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(OrientationID) from tblOrientation "
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblOrientation values(@PatientID, @AidID, @SOrientation, @LOrientation, @COrientation)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@OrientationID", intOrientationID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@AidID", intAidID)
        cmd.Parameters.AddWithValue("@SOrientation", DateTime.Parse(sdtotc.Text))
        cmd.Parameters.AddWithValue("@LOrientation", DateTime.Parse(ldtotc.Text))
        cmd.Parameters.AddWithValue("@COrientation", DateTime.Parse(cdtotc.Text))


        cmd.ExecuteNonQuery()
        cn.Close()

        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd12_Click(sender As Object, e As EventArgs) Handles btnAdd12.Click
        If Date.Now.Day <> 60 Then
            MsgBox("Your supervision To The Case, is out-of-date and needs update", MsgBoxStyle.Information, "Trial mode")
            cn = New SqlConnection()
            cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
            cn.Open()
            cmd = New SqlCommand
            cmd.CommandText = "Select max(SupervisionID) from tblSupervision "
            cmd.Connection = cn

            rd = cmd.ExecuteReader()

            While rd.Read()


                intPatientID = 1
            End While

            rd.Close()

            cmd = New SqlCommand()
            cmd.CommandText = "Insert into tblSupervision values(@PatientID, @SSupervision, @LSupervision, @CSupervision)"

            cmd.Connection = cn

            'cmd.Parameters.AddWithValue("@SupervisionID", intSupervisionID)
            cmd.Parameters.AddWithValue("@PatientID", intPatientID)
            cmd.Parameters.AddWithValue("@SSupervision", DateTime.Parse(sdtstc.Text))
            cmd.Parameters.AddWithValue("@LSupervision", DateTime.Parse(ldtstc.Text))
            cmd.Parameters.AddWithValue("@CSupervision", DateTime.Parse(cdtstc.Text))


            cmd.ExecuteNonQuery()
            cn.Close()

            MsgBox("Added...!!!")

        End If


    End Sub

    Private Sub btnAdd13_Click(sender As Object, e As EventArgs) Handles btnAdd13.Click
        If Date.Now.Day <> 60 Then
            MsgBox("Your Case Monitoring Notes , Are out-of-date and needs update", MsgBoxStyle.Information, "Trial mode")
            cn = New SqlConnection()
            cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
            cn.Open()
            cmd = New SqlCommand
            cmd.CommandText = "Select max(CMNID) from tblCase_Monitoring "
            cmd.Connection = cn

            rd = cmd.ExecuteReader()

            While rd.Read()


                intPatientID = 1
            End While

            rd.Close()

            cmd = New SqlCommand()
            cmd.CommandText = "Insert into tblCase_Monitoring values(@PatientID, @SCMN, @LCMN, @CCMN)"

            cmd.Connection = cn

            'cmd.Parameters.AddWithValue("@CMNID", intCMNID)
            cmd.Parameters.AddWithValue("@PatientID", intPatientID)
            cmd.Parameters.AddWithValue("@SCMN", DateTime.Parse(sdtcmn.Text))
            cmd.Parameters.AddWithValue("@LCMN", DateTime.Parse(ldtcmn.Text))
            cmd.Parameters.AddWithValue("@CCMN", DateTime.Parse(cdtcmn.Text))


            cmd.ExecuteNonQuery()
            cn.Close()

            MsgBox("Added...!!!")


        End If

    End Sub

    Private Sub btnAdd14_Click(sender As Object, e As EventArgs) Handles btnAdd14.Click
        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(ACID) from tblActivity"
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()

        cmd = New SqlCommand()
        cmd.CommandText = "Insert into tblActivity values(@PatientID, @SAC, @LAC, @CAC)"
        cmd.Connection = cn

        'cmd.Parameters.AddWithValue("@ACID", intACID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@SAC", DateTime.Parse(sdtas.Text))
        cmd.Parameters.AddWithValue("@LAC", DateTime.Parse(ldtas.Text))
        cmd.Parameters.AddWithValue("@CAC", DateTime.Parse(cdtas.Text))


        cmd.ExecuteNonQuery()
        cn.Close()


        MsgBox("Added....!!!!")
    End Sub

    Private Sub btnAdd15_Click(sender As Object, e As EventArgs) Handles btnAdd15.Click
        If Date.Now.Day <> 60 Then
            MsgBox("Your Case Monitoring Notes , Are out-of-date and needs update", MsgBoxStyle.Information, "Trial mode")
            cn = New SqlConnection()
            cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
            cn.Open()
            cmd = New SqlCommand
            cmd.CommandText = "Select max(ReID) from tblReassessment "
            cmd.Connection = cn

            rd = cmd.ExecuteReader()

            While rd.Read()


                intPatientID = 1
            End While

            rd.Close()

            cmd = New SqlCommand()
            cmd.CommandText = "Insert into tblReassessment values(@PatientID, @SReAssement, @LReAssement, @CReAssement)"

            cmd.Connection = cn

            'cmd.Parameters.AddWithValue("@ReID", intREID)
            cmd.Parameters.AddWithValue("@PatientID", intPatientID)
            cmd.Parameters.AddWithValue("@SReAssement", DateTime.Parse(sdtre.Text))
            cmd.Parameters.AddWithValue("@LReAssement", DateTime.Parse(ldtre.Text))
            cmd.Parameters.AddWithValue("@CReAssement", DateTime.Parse(cdtre.Text))


            cmd.ExecuteNonQuery()
            cn.Close()

            MsgBox("Added...!!!")


        End If
    End Sub

    Private Sub btnAdd16_Click(sender As Object, e As EventArgs) Handles btnAdd16.Click

        cn = New SqlConnection()
        cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        cn.Open()

        cmd = New SqlCommand()
        cmd.CommandText = "Select max(CommID) from tblComments"
        cmd.Connection = cn

        rd = cmd.ExecuteReader()

        While rd.Read()


            intPatientID = 1
        End While

        rd.Close()


        cmd = New SqlCommand()

        cmd.CommandText = "Insert into tblComments values(@PatientID, @Comment)"
        cmd.Connection = cn

        ' cmd.Parameters.AddWithValue("@CommID", intCommID)
        cmd.Parameters.AddWithValue("@PatientID", intPatientID)
        cmd.Parameters.AddWithValue("@Comment", txtcomm.Text)



        cmd.ExecuteNonQuery()
        cn.Close()


        MsgBox("Added....!!!!")

    End Sub

    Private Sub btnCan_Click(sender As Object, e As EventArgs) Handles btnCan.Click

        Me.Close()


    End Sub

    Private Function DataGridView1() As Object
        Throw New NotImplementedException
        'Try
        '    Me.Controls.Add(New DataGridView)
        '    cn.ConnectionString = "Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True"
        '    cn.Open()
        '    cmd.CommandText = "select * from tblShowDetail;"
        '    da = New SqlDataAdapter(cmd.CommandText, cn)
        '    da.Fill(ds1)
        '    Dim datagridview1 As New DataGridView


        'Catch ex As Exception

        'End Try
    End Function




    Private Sub btnclear_Click(sender As System.Object, e As System.EventArgs) Handles btnclear.Click
        ClearTextBox(Me)
    End Sub
    Private Sub databind()
        Dim cmd As SqlCommand
        cn = New SqlConnection("Data Source=JIGESH-PC\JIGESH;Initial Catalog=Patient;Integrated Security=True")
        cn.Open()
        cmd = New SqlCommand("Select * from tblShowDetail", cn)
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        dt = New DataTable()
        dt.Load(dr)
        Me.DataGridView1.DataSource = dt
    End Sub



    Private Sub cdtInitial_ValueChanged(sender As System.Object, e As System.EventArgs)


    End Sub


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.initialint.Text = Me.cdtInitial.Value.ToShortDateString
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Me.phycicerti.Text = Me.cdtPC.Value.ToShortDateString
    End Sub

   

End Class


This post has been edited by modi123_1: 07 December 2012 - 10:33 AM
Reason for edit:: fixed botched code tags


Is This A Good Question/Topic? 0
  • +

Replies To: how can i refreshing data in datagridview after inserting and editing?

#2 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1048
  • View blog
  • Posts: 4,075
  • Joined: 02-July 08

Re: how can i refreshing data in datagridview after inserting and editing?

Posted 07 December 2012 - 11:02 AM

You are doing things the hard way. You are referencing data not binding to it. If you were binding to it the changes would be reflected. I use Entity Framework and WPF which allows for drag-and-drop for controls and the binding is done for you - too easy! All I have to do is call SaveChanges on the model and I am done writing to the database. Windows forms can do similar. In the property window you go to the Data group and bind the .Text property of a textbox to a field in your dataset.
Was This Post Helpful? 0
  • +
  • -

#3 piyuchoxi23  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 2
  • Joined: 07-December 12

Re: how can i refreshing data in datagridview after inserting and editing?

Posted 07 December 2012 - 11:31 AM

View Post_HAWK_, on 07 December 2012 - 11:02 AM, said:

You are doing things the hard way. You are referencing data not binding to it. If you were binding to it the changes would be reflected. I use Entity Framework and WPF which allows for drag-and-drop for controls and the binding is done for you - too easy! All I have to do is call SaveChanges on the model and I am done writing to the database. Windows forms can do similar. In the property window you go to the Data group and bind the .Text property of a textbox to a field in your dataset.

[ hi but how can i refreshing data in datagridview. will you write code also?]
[/hi]

[refreshing data]
but how can i refreshing data in datagridview. will you also suggest me the source code?
[/]
Was This Post Helpful? -1
  • +
  • -

#4 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1048
  • View blog
  • Posts: 4,075
  • Joined: 02-July 08

Re: how can i refreshing data in datagridview after inserting and editing?

Posted 07 December 2012 - 12:39 PM

Windows Forms Databinding
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1