'This source code has been developed by Cuong Pham (cuong@nmsu.edu) & Mary Lucero
'Any use of this software MUST contain this message.
Public Class FrFungal
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TxID As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents TxDateIsolate As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TxGenus As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents TxSpecies As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents TxFreezeDriedStocks As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents TxGlycerolStocks As System.Windows.Forms.TextBox
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents TxDriedAgarStocks As System.Windows.Forms.TextBox
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents TxMAcroscopicAppearance As System.Windows.Forms.TextBox
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents TxMicroscopicAppearance As System.Windows.Forms.TextBox
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents TxComment As System.Windows.Forms.TextBox
    Friend WithEvents ButAdd As System.Windows.Forms.Button
    Friend WithEvents ButUpdate As System.Windows.Forms.Button
    Friend WithEvents ButDelete As System.Windows.Forms.Button
    Friend WithEvents tonQuit As System.Windows.Forms.Button
    Friend WithEvents CkAvailable As System.Windows.Forms.CheckBox
    Friend WithEvents cbCultureMedium As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.DataGrid1 = New System.Windows.Forms.DataGrid
        Me.Label1 = New System.Windows.Forms.Label
        Me.TxID = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.CkAvailable = New System.Windows.Forms.CheckBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.TxDateIsolate = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.TxGenus = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.TxSpecies = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.TxFreezeDriedStocks = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.TxGlycerolStocks = New System.Windows.Forms.TextBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.TxDriedAgarStocks = New System.Windows.Forms.TextBox
        Me.Label10 = New System.Windows.Forms.Label
        Me.TxMAcroscopicAppearance = New System.Windows.Forms.TextBox
        Me.Label11 = New System.Windows.Forms.Label
        Me.TxMicroscopicAppearance = New System.Windows.Forms.TextBox
        Me.Label12 = New System.Windows.Forms.Label
        Me.TxComment = New System.Windows.Forms.TextBox
        Me.ButAdd = New System.Windows.Forms.Button
        Me.ButUpdate = New System.Windows.Forms.Button
        Me.ButDelete = New System.Windows.Forms.Button
        Me.tonQuit = New System.Windows.Forms.Button
        Me.cbCultureMedium = New System.Windows.Forms.ComboBox
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = "Fungal_Isolates"
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(8, 8)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(688, 216)
        Me.DataGrid1.TabIndex = 0
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 232)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(112, 32)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Fungal ID"
        '
        'TxID
        '
        Me.TxID.Location = New System.Drawing.Point(121, 232)
        Me.TxID.Name = "TxID"
        Me.TxID.Size = New System.Drawing.Size(136, 20)
        Me.TxID.TabIndex = 2
        Me.TxID.Text = "TextBox1"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(8, 264)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(112, 24)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "Available"
        '
        'CkAvailable
        '
        Me.CkAvailable.AllowDrop = True
        Me.CkAvailable.Location = New System.Drawing.Point(120, 264)
        Me.CkAvailable.Name = "CkAvailable"
        Me.CkAvailable.Size = New System.Drawing.Size(112, 16)
        Me.CkAvailable.TabIndex = 4
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 297)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(112, 24)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Date Isolates"
        '
        'TxDateIsolate
        '
        Me.TxDateIsolate.Location = New System.Drawing.Point(120, 296)
        Me.TxDateIsolate.Name = "TxDateIsolate"
        Me.TxDateIsolate.Size = New System.Drawing.Size(136, 20)
        Me.TxDateIsolate.TabIndex = 6
        Me.TxDateIsolate.Text = "TextBox1"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 328)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(112, 24)
        Me.Label4.TabIndex = 7
        Me.Label4.Text = "Genus"
        '
        'TxGenus
        '
        Me.TxGenus.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxGenus.Location = New System.Drawing.Point(120, 328)
        Me.TxGenus.Name = "TxGenus"
        Me.TxGenus.Size = New System.Drawing.Size(136, 20)
        Me.TxGenus.TabIndex = 8
        Me.TxGenus.Text = "TextBox1"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(8, 360)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(112, 24)
        Me.Label5.TabIndex = 9
        Me.Label5.Text = "Species"
        '
        'TxSpecies
        '
        Me.TxSpecies.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxSpecies.Location = New System.Drawing.Point(120, 360)
        Me.TxSpecies.Name = "TxSpecies"
        Me.TxSpecies.Size = New System.Drawing.Size(136, 20)
        Me.TxSpecies.TabIndex = 10
        Me.TxSpecies.Text = "TextBox1"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(285, 232)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(112, 24)
        Me.Label6.TabIndex = 11
        Me.Label6.Text = "Culture Medium"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(285, 262)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(120, 24)
        Me.Label7.TabIndex = 13
        Me.Label7.Text = "Freeze Dried Stocks"
        '
        'TxFreezeDriedStocks
        '
        Me.TxFreezeDriedStocks.Location = New System.Drawing.Point(400, 264)
        Me.TxFreezeDriedStocks.Name = "TxFreezeDriedStocks"
        Me.TxFreezeDriedStocks.Size = New System.Drawing.Size(136, 20)
        Me.TxFreezeDriedStocks.TabIndex = 14
        Me.TxFreezeDriedStocks.Text = "TextBox1"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(285, 296)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(120, 32)
        Me.Label8.TabIndex = 15
        Me.Label8.Text = "Glycerol Stocks"
        '
        'TxGlycerolStocks
        '
        Me.TxGlycerolStocks.Location = New System.Drawing.Point(400, 296)
        Me.TxGlycerolStocks.Name = "TxGlycerolStocks"
        Me.TxGlycerolStocks.Size = New System.Drawing.Size(136, 20)
        Me.TxGlycerolStocks.TabIndex = 16
        Me.TxGlycerolStocks.Text = "TextBox1"
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(287, 328)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(112, 24)
        Me.Label9.TabIndex = 17
        Me.Label9.Text = "Dried Agar Stocks"
        '
        'TxDriedAgarStocks
        '
        Me.TxDriedAgarStocks.Location = New System.Drawing.Point(400, 328)
        Me.TxDriedAgarStocks.Name = "TxDriedAgarStocks"
        Me.TxDriedAgarStocks.Size = New System.Drawing.Size(136, 20)
        Me.TxDriedAgarStocks.TabIndex = 18
        Me.TxDriedAgarStocks.Text = "TextBox1"
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(8, 392)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(176, 24)
        Me.Label10.TabIndex = 20
        Me.Label10.Text = "Macroscopic Appearance"
        '
        'TxMAcroscopicAppearance
        '
        Me.TxMAcroscopicAppearance.Location = New System.Drawing.Point(152, 392)
        Me.TxMAcroscopicAppearance.Name = "TxMAcroscopicAppearance"
        Me.TxMAcroscopicAppearance.Size = New System.Drawing.Size(384, 20)
        Me.TxMAcroscopicAppearance.TabIndex = 21
        Me.TxMAcroscopicAppearance.Text = "TextBox1"
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(8, 424)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(136, 24)
        Me.Label11.TabIndex = 22
        Me.Label11.Text = "Microscopic  Characters"
        '
        'TxMicroscopicAppearance
        '
        Me.TxMicroscopicAppearance.Location = New System.Drawing.Point(152, 424)
        Me.TxMicroscopicAppearance.Name = "TxMicroscopicAppearance"
        Me.TxMicroscopicAppearance.Size = New System.Drawing.Size(384, 20)
        Me.TxMicroscopicAppearance.TabIndex = 23
        Me.TxMicroscopicAppearance.Text = "TextBox1"
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(8, 456)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(136, 32)
        Me.Label12.TabIndex = 24
        Me.Label12.Text = "Comments"
        '
        'TxComment
        '
        Me.TxComment.Location = New System.Drawing.Point(152, 456)
        Me.TxComment.Name = "TxComment"
        Me.TxComment.Size = New System.Drawing.Size(384, 20)
        Me.TxComment.TabIndex = 25
        Me.TxComment.Text = "TextBox1"
        '
        'ButAdd
        '
        Me.ButAdd.Location = New System.Drawing.Point(552, 232)
        Me.ButAdd.Name = "ButAdd"
        Me.ButAdd.Size = New System.Drawing.Size(136, 48)
        Me.ButAdd.TabIndex = 26
        Me.ButAdd.Text = "Add a fungal"
        '
        'ButUpdate
        '
        Me.ButUpdate.Location = New System.Drawing.Point(552, 295)
        Me.ButUpdate.Name = "ButUpdate"
        Me.ButUpdate.Size = New System.Drawing.Size(136, 48)
        Me.ButUpdate.TabIndex = 27
        Me.ButUpdate.Text = "Update"
        '
        'ButDelete
        '
        Me.ButDelete.Location = New System.Drawing.Point(552, 361)
        Me.ButDelete.Name = "ButDelete"
        Me.ButDelete.Size = New System.Drawing.Size(136, 48)
        Me.ButDelete.TabIndex = 28
        Me.ButDelete.Text = "Delete"
        '
        'tonQuit
        '
        Me.tonQuit.Location = New System.Drawing.Point(552, 425)
        Me.tonQuit.Name = "tonQuit"
        Me.tonQuit.Size = New System.Drawing.Size(136, 48)
        Me.tonQuit.TabIndex = 29
        Me.tonQuit.Text = "Quit"
        '
        'cbCultureMedium
        '
        Me.cbCultureMedium.Location = New System.Drawing.Point(400, 232)
        Me.cbCultureMedium.Name = "cbCultureMedium"
        Me.cbCultureMedium.Size = New System.Drawing.Size(136, 21)
        Me.cbCultureMedium.TabIndex = 30
        Me.cbCultureMedium.Text = "ComboBox1"
        '
        'FrFungal
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(696, 494)
        Me.Controls.Add(Me.cbCultureMedium)
        Me.Controls.Add(Me.tonQuit)
        Me.Controls.Add(Me.ButDelete)
        Me.Controls.Add(Me.ButUpdate)
        Me.Controls.Add(Me.ButAdd)
        Me.Controls.Add(Me.TxComment)
        Me.Controls.Add(Me.TxMicroscopicAppearance)
        Me.Controls.Add(Me.TxMAcroscopicAppearance)
        Me.Controls.Add(Me.TxDriedAgarStocks)
        Me.Controls.Add(Me.TxGlycerolStocks)
        Me.Controls.Add(Me.TxFreezeDriedStocks)
        Me.Controls.Add(Me.TxSpecies)
        Me.Controls.Add(Me.TxGenus)
        Me.Controls.Add(Me.TxDateIsolate)
        Me.Controls.Add(Me.TxID)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.CkAvailable)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.DataGrid1)
        Me.Name = "FrFungal"
        Me.Text = "Fungal Isolates"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Mode As Integer
    Private ID As String

    Private Sub FrFungal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ShowToolTip()
        Load_Fungal()
    End Sub
    Private Sub Load_Fungal()
        ' create a connection string 
        On Error Resume Next
        Init()
        Dim connString As String = strConn
        Dim myConnection As OleDb.OleDbConnection = New OleDb.OleDbConnection
        myConnection.ConnectionString = connString
        ' create a data adapter 
        Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("Select ID,Available,DateIsolate,Genus,Species,CultureMedium,FreezeDriedStocks,GlycerolStocks,DriedAgarStocks,MacroscopicAppearance,MicroscopicCharacters,Comments from Fungal_Isolates", myConnection)
        ' create a new dataset 
        Dim ds As DataSet = New DataSet
        ' fill dataset 
        da.Fill(ds, "Fungal_Isolates")


        ' write dataset contents to an xml file by calling WriteXml method 
        ' Attach DataSet to DataGrid

        DataGrid1.DataSource = ds.DefaultViewManager
        DataGrid1.DataMember = "Fungal_Isolates"
        DataGrid1.ColumnHeadersVisible = True
        DataGrid1.Refresh()

        TxID.Text = ""
        CkAvailable.Checked = True
        TxDateIsolate.Text = ""
        TxGenus.Text = ""
        TxSpecies.Text = ""
        cbCultureMedium.Items.Clear()
        FillComboBox(cbCultureMedium, "cbCultureMedium", "CultureMedium")
        cbCultureMedium.Text = ""
        TxFreezeDriedStocks.Text = ""
        TxGlycerolStocks.Text = ""
        TxDriedAgarStocks.Text = ""
        TxMAcroscopicAppearance.Text = ""
        TxMicroscopicAppearance.Text = ""
        TxComment.Text = ""

    End Sub
    Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
        Dim i As Integer
        Dim t As Boolean
        t = False
        Flush()
        Mode = 1
        i = 0
        On Error Resume Next
        While (t = False)
            If DataGrid1.IsSelected(i) Then
                ID = DataGrid1.Item(i, 0)
                TxID.Text = DataGrid1.Item(i, 0)
                CkAvailable.Checked = DataGrid1.Item(i, 1)
                TxDateIsolate.Text = DataGrid1.Item(i, 2)
                TxGenus.Text = DataGrid1.Item(i, 3)
                TxSpecies.Text = DataGrid1.Item(i, 4)
                cbCultureMedium.Text = DataGrid1.Item(i, 5)
                TxFreezeDriedStocks.Text = DataGrid1.Item(i, 6)
                TxGlycerolStocks.Text = DataGrid1.Item(i, 7)
                TxDriedAgarStocks.Text = DataGrid1.Item(i, 8)
                TxMAcroscopicAppearance.Text = DataGrid1.Item(i, 9)
                TxMicroscopicAppearance.Text = DataGrid1.Item(i, 10)
                TxComment.Text = DataGrid1.Item(i, 11)
                ButUpdate.Enabled = True
                ButDelete.Enabled = True
                t = True
            End If
            i = i + 1
        End While
    End Sub

    Private Sub tonQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tonQuit.Click
        Me.Hide()

        'CloseConn()

    End Sub

    Private Sub ButAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButAdd.Click
        TxID.Text = ""
        CkAvailable.Checked = True
        TxDateIsolate.Text = ""
        TxGenus.Text = ""
        TxSpecies.Text = ""
        cbCultureMedium.Text = ""
        TxFreezeDriedStocks.Text = ""
        TxGlycerolStocks.Text = ""
        TxDriedAgarStocks.Text = ""
        TxMAcroscopicAppearance.Text = ""
        TxMicroscopicAppearance.Text = ""
        TxComment.Text = ""
        ButUpdate.Enabled = True
        ButDelete.Enabled = False
        Mode = 0
        TxID.Focus()
    End Sub
    Private Sub Flush()
        TxID.Text = ""
        CkAvailable.Checked = True
        TxDateIsolate.Text = ""
        TxGenus.Text = ""
        TxSpecies.Text = ""
        cbCultureMedium.Text = ""
        TxFreezeDriedStocks.Text = ""
        TxGlycerolStocks.Text = ""
        TxDriedAgarStocks.Text = ""
        TxMAcroscopicAppearance.Text = ""
        TxMicroscopicAppearance.Text = ""
        TxComment.Text = ""

    End Sub
    Private Sub ShowToolTip()
        Dim toolTip1 As New ToolTip

        ' Set up the delays for the ToolTip.
        toolTip1.AutoPopDelay = 5000
        toolTip1.InitialDelay = 1000
        toolTip1.ReshowDelay = 500
        ' Force the ToolTip text to be displayed whether or not the form is active.
        toolTip1.ShowAlways = True

        ' Set up the ToolTip text for the Button and Checkbox.
        toolTip1.SetToolTip(Me.Label1, "Name or number used to identify the strain")
        toolTip1.SetToolTip(Me.Label4, "Taxonomic group containing one or more species")
        toolTip1.SetToolTip(Me.Label5, "Taxonomic group whose members can interbreed")
        toolTip1.SetToolTip(Me.Label6, "What medium can the isolate be grown on eg. PDA,LB, GNSA etc. for removing contaminating strains")
        toolTip1.SetToolTip(Me.Label2, "Check if the sample is available in storage. Remove checkmark whenever you use the last of a sample")
        toolTip1.SetToolTip(Me.Label7, "Location stored and date the stock was prepared")
        toolTip1.SetToolTip(Me.Label9, "location stored and date the stock was prepared")
        toolTip1.SetToolTip(Me.Label10, "What fungal tissue looked like without the aid of magnifying")
        toolTip1.SetToolTip(Me.Label11, "How fungus looked under microscope")
        toolTip1.SetToolTip(Me.Label12, "Any further information needed on this particular fungus. Include comments such as how long the stocks take to produce hyphae on agar media, and any alternative media that the fungus is known to grow on")
    End Sub


    Private Sub ButUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButUpdate.Click
        Dim strSQL As String
        On Error Resume Next

        OpenConn()

        If Mode = 0 Then
            If TxID.Text = "" Then
                MsgBox("Fungal ID can not be left blank, pls enter Fungal ID")
                TxID.Focus()
                Exit Sub
            End If


            strSQL = "INSERT INTO Fungal_Isolates(ID,Available,DateIsolate," & _
            "Genus,Species,CultureMedium,FreezeDriedStocks,GlycerolStocks," & _
            "DriedAgarStocks,MAcroscopicAppearance, MicroscopicCharacters, Comments)" & _
            " VALUES ('" & TxID.Text & _
             "'," & CkAvailable.Checked & _
             ",'" & TxDateIsolate.Text & _
             "','" & TxGenus.Text & _
             "','" & TxSpecies.Text & _
             "','" & cbCultureMedium.Text & _
             "','" & TxFreezeDriedStocks.Text & _
             "','" & TxGlycerolStocks.Text & _
             "','" & TxDriedAgarStocks.Text & _
             "','" & TxMAcroscopicAppearance.Text & _
             "','" & TxMicroscopicAppearance.Text & _
             "','" & TxComment.Text & "')"


            Dim myCommand As New OleDb.OleDbCommand(strSQL, myConnection)
            myCommand.Connection = myConnection
            'myCommand.Connection.Open()
            myCommand.ExecuteNonQuery()

            myCommand.Dispose()

            'Redraw
            Init()

            Dim myCon As OleDb.OleDbConnection = New OleDb.OleDbConnection
            myCon.ConnectionString = strConn
            ' create a data adapter 
            Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("Select ID,Available,DateIsolate,Genus,Species,CultureMedium,FreezeDriedStocks,GlycerolStocks,DriedAgarStocks,MacroscopicAppearance,MicroscopicCharacters,Comments from Fungal_Isolates", myConnection)

            ' create a new dataset 
            Dim ds As DataSet = New DataSet
            ' fill dataset 
            da.Fill(ds, "Fungal_Isolates")

            ' write dataset contents to an xml file by calling WriteXml method 
            ' Attach DataSet to DataGrid

            DataGrid1.DataSource = ds.DefaultViewManager
            DataGrid1.ColumnHeadersVisible = True
            DataGrid1.Refresh()

            da.Dispose()
            ds.Dispose()
            myCon.Close()

        End If



        If Mode = 1 Then
            If TxID.Text = "" Then
                MsgBox("Fungal ID can not be left blank, pls enter Fungal ID")
                TxID.Focus()
                Exit Sub
            End If



            strSQL = "UPDATE Fungal_Isolates SET ID= '" & TxID.Text & _
             "', Available= " & CkAvailable.Checked & _
             ",  DateIsolate='" & TxDateIsolate.Text & _
             "', Genus='" & TxGenus.Text & _
             "', Species= '" & TxSpecies.Text & _
             "', CultureMedium= '" & cbCultureMedium.Text & _
             "', FreezeDriedStocks= '" & TxFreezeDriedStocks.Text & _
             "', GlycerolStocks='" & TxGlycerolStocks.Text & _
             "', DriedAgarStocks='" & TxDriedAgarStocks.Text & _
             "', MAcroscopicAppearance='" & TxMAcroscopicAppearance.Text & _
             "', MicroscopicCharacters='" & TxMicroscopicAppearance.Text & _
             "',Comments='" & TxComment.Text & _
             "' WHERE ID='" & ID & "'"

            Dim myCommand As New OleDb.OleDbCommand(strSQL)
            myCommand.Connection = myConnection
            myCommand.ExecuteNonQuery()


            DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) = TxID.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 1) = CkAvailable.Checked
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 2) = TxDateIsolate.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 3) = TxGenus.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 4) = TxSpecies.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 5) = cbCultureMedium.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 6) = TxFreezeDriedStocks.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 7) = TxGlycerolStocks.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 8) = TxDriedAgarStocks.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 9) = TxMAcroscopicAppearance.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 10) = TxMicroscopicAppearance.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 11) = TxComment.Text

            myCommand.Dispose()

        End If

        myConnection.Close()

    End Sub

    Private Sub ButDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButDelete.Click
        On Error Resume Next
        Dim msg As String
        Dim title As String
        Dim style As MsgBoxStyle
        Dim response As MsgBoxResult
        msg = "Do you  really want to delete the Fungal ID :" & ID & " ?"  ' Define message.
        style = MsgBoxStyle.DefaultButton2 Or _
           MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
        title = "Delete Comfirmation"   ' Define title.
        ' Display message.
        response = MsgBox(msg, style, title)
        If response = MsgBoxResult.Yes Then   ' User chose Yes.

            strSQL = "DELETE FROM Fungal_Isolates  WHERE ID='" & ID & "'"
            OpenConn()

            Dim myCommand As New OleDb.OleDbCommand(strSQL)
            myCommand.Connection = myConnection
            myCommand.ExecuteNonQuery()
            DataGrid1.Refresh()
            myCommand.Dispose()
            myConnection.Close()
            Load_Fungal()
        Else
            ' Perform some other action.
        End If

    End Sub
End Class
