'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 frPCRproduct
    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 Label2 As System.Windows.Forms.Label
    Friend WithEvents cbForward As System.Windows.Forms.ComboBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents cbReverse As System.Windows.Forms.ComboBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TxnguL As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents TxGelImageFile As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents TxMethod As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents TxComments As System.Windows.Forms.TextBox
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents TxSource As System.Windows.Forms.TextBox
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents TxDate As System.Windows.Forms.TextBox
    Friend WithEvents Label14 As System.Windows.Forms.Label
    Friend WithEvents TxColumn As System.Windows.Forms.TextBox
    Friend WithEvents Label15 As System.Windows.Forms.Label
    Friend WithEvents TxRow As System.Windows.Forms.TextBox
    Friend WithEvents Label16 As System.Windows.Forms.Label
    Friend WithEvents Label17 As System.Windows.Forms.Label
    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 ButQuit As System.Windows.Forms.Button
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents TxDescription As System.Windows.Forms.TextBox
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents cbTissue As System.Windows.Forms.ComboBox
    Friend WithEvents CbSeqDataFile As System.Windows.Forms.ComboBox
    Friend WithEvents cbLocation As System.Windows.Forms.ComboBox
    Friend WithEvents cbPurificationMethod As System.Windows.Forms.ComboBox
    Friend WithEvents cbTarget 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.TxDescription = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.cbForward = New System.Windows.Forms.ComboBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.cbReverse = New System.Windows.Forms.ComboBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.TxnguL = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.TxGelImageFile = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.TxMethod = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.TxComments = New System.Windows.Forms.TextBox
        Me.Label11 = New System.Windows.Forms.Label
        Me.TxSource = New System.Windows.Forms.TextBox
        Me.Label13 = New System.Windows.Forms.Label
        Me.TxDate = New System.Windows.Forms.TextBox
        Me.Label14 = New System.Windows.Forms.Label
        Me.TxColumn = New System.Windows.Forms.TextBox
        Me.Label15 = New System.Windows.Forms.Label
        Me.TxRow = New System.Windows.Forms.TextBox
        Me.Label16 = New System.Windows.Forms.Label
        Me.Label17 = New System.Windows.Forms.Label
        Me.ButAdd = New System.Windows.Forms.Button
        Me.ButUpdate = New System.Windows.Forms.Button
        Me.ButDelete = New System.Windows.Forms.Button
        Me.ButQuit = New System.Windows.Forms.Button
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.cbTissue = New System.Windows.Forms.ComboBox
        Me.CbSeqDataFile = New System.Windows.Forms.ComboBox
        Me.cbLocation = New System.Windows.Forms.ComboBox
        Me.cbPurificationMethod = New System.Windows.Forms.ComboBox
        Me.cbTarget = New System.Windows.Forms.ComboBox
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(0, -1)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(744, 232)
        Me.DataGrid1.TabIndex = 0
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(7, 240)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(74, 24)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Description"
        '
        'TxDescription
        '
        Me.TxDescription.Location = New System.Drawing.Point(96, 238)
        Me.TxDescription.Name = "TxDescription"
        Me.TxDescription.Size = New System.Drawing.Size(160, 20)
        Me.TxDescription.TabIndex = 2
        Me.TxDescription.Text = "TextBox1"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(7, 272)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 24)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "Forward Primer"
        '
        'cbForward
        '
        Me.cbForward.Location = New System.Drawing.Point(96, 271)
        Me.cbForward.Name = "cbForward"
        Me.cbForward.Size = New System.Drawing.Size(160, 21)
        Me.cbForward.TabIndex = 4
        Me.cbForward.Text = "ComboBox1"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(7, 304)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(88, 24)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Reverse Primer"
        '
        'cbReverse
        '
        Me.cbReverse.Location = New System.Drawing.Point(96, 304)
        Me.cbReverse.Name = "cbReverse"
        Me.cbReverse.Size = New System.Drawing.Size(160, 21)
        Me.cbReverse.TabIndex = 6
        Me.cbReverse.Text = "ComboBox1"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 333)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(88, 21)
        Me.Label4.TabIndex = 7
        Me.Label4.Text = "ng/uL"
        '
        'TxnguL
        '
        Me.TxnguL.Location = New System.Drawing.Point(96, 334)
        Me.TxnguL.Name = "TxnguL"
        Me.TxnguL.Size = New System.Drawing.Size(160, 20)
        Me.TxnguL.TabIndex = 8
        Me.TxnguL.Text = "TextBox1"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(7, 367)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(88, 24)
        Me.Label5.TabIndex = 9
        Me.Label5.Text = "Gel Image File"
        '
        'TxGelImageFile
        '
        Me.TxGelImageFile.Location = New System.Drawing.Point(96, 366)
        Me.TxGelImageFile.Name = "TxGelImageFile"
        Me.TxGelImageFile.Size = New System.Drawing.Size(160, 20)
        Me.TxGelImageFile.TabIndex = 10
        Me.TxGelImageFile.Text = "TextBox1"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(8, 394)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(80, 24)
        Me.Label6.TabIndex = 11
        Me.Label6.Text = "Target"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(8, 424)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(88, 24)
        Me.Label7.TabIndex = 13
        Me.Label7.Text = "Method"
        '
        'TxMethod
        '
        Me.TxMethod.Location = New System.Drawing.Point(95, 423)
        Me.TxMethod.Name = "TxMethod"
        Me.TxMethod.Size = New System.Drawing.Size(161, 20)
        Me.TxMethod.TabIndex = 14
        Me.TxMethod.Text = "TextBox1"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(280, 241)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(104, 24)
        Me.Label8.TabIndex = 15
        Me.Label8.Text = "Sequence data file"
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(7, 466)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(81, 24)
        Me.Label10.TabIndex = 19
        Me.Label10.Text = "Comments"
        '
        'TxComments
        '
        Me.TxComments.Location = New System.Drawing.Point(96, 466)
        Me.TxComments.Name = "TxComments"
        Me.TxComments.Size = New System.Drawing.Size(448, 20)
        Me.TxComments.TabIndex = 20
        Me.TxComments.Text = "TextBox1"
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(280, 271)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(76, 24)
        Me.Label11.TabIndex = 21
        Me.Label11.Text = "Source"
        '
        'TxSource
        '
        Me.TxSource.Location = New System.Drawing.Point(384, 271)
        Me.TxSource.Name = "TxSource"
        Me.TxSource.Size = New System.Drawing.Size(160, 20)
        Me.TxSource.TabIndex = 22
        Me.TxSource.Text = "TextBox1"
        '
        'Label13
        '
        Me.Label13.Location = New System.Drawing.Point(280, 304)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(88, 16)
        Me.Label13.TabIndex = 25
        Me.Label13.Text = "Date"
        '
        'TxDate
        '
        Me.TxDate.Location = New System.Drawing.Point(384, 304)
        Me.TxDate.Name = "TxDate"
        Me.TxDate.Size = New System.Drawing.Size(160, 20)
        Me.TxDate.TabIndex = 26
        Me.TxDate.Text = "TextBox1"
        '
        'Label14
        '
        Me.Label14.Location = New System.Drawing.Point(281, 333)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(96, 24)
        Me.Label14.TabIndex = 27
        Me.Label14.Text = "Column"
        '
        'TxColumn
        '
        Me.TxColumn.Location = New System.Drawing.Point(383, 335)
        Me.TxColumn.Name = "TxColumn"
        Me.TxColumn.Size = New System.Drawing.Size(160, 20)
        Me.TxColumn.TabIndex = 28
        Me.TxColumn.Text = "TextBox1"
        '
        'Label15
        '
        Me.Label15.Location = New System.Drawing.Point(282, 368)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(96, 24)
        Me.Label15.TabIndex = 29
        Me.Label15.Text = "Row"
        '
        'TxRow
        '
        Me.TxRow.Location = New System.Drawing.Point(384, 367)
        Me.TxRow.Name = "TxRow"
        Me.TxRow.Size = New System.Drawing.Size(160, 20)
        Me.TxRow.TabIndex = 30
        Me.TxRow.Text = "TextBox1"
        '
        'Label16
        '
        Me.Label16.Location = New System.Drawing.Point(283, 400)
        Me.Label16.Name = "Label16"
        Me.Label16.Size = New System.Drawing.Size(88, 24)
        Me.Label16.TabIndex = 31
        Me.Label16.Text = "Location"
        '
        'Label17
        '
        Me.Label17.Location = New System.Drawing.Point(283, 434)
        Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(101, 24)
        Me.Label17.TabIndex = 33
        Me.Label17.Text = "Purification Method"
        '
        'ButAdd
        '
        Me.ButAdd.Location = New System.Drawing.Point(560, 240)
        Me.ButAdd.Name = "ButAdd"
        Me.ButAdd.Size = New System.Drawing.Size(176, 32)
        Me.ButAdd.TabIndex = 35
        Me.ButAdd.Text = "Add PCR Product"
        '
        'ButUpdate
        '
        Me.ButUpdate.Location = New System.Drawing.Point(560, 278)
        Me.ButUpdate.Name = "ButUpdate"
        Me.ButUpdate.Size = New System.Drawing.Size(176, 34)
        Me.ButUpdate.TabIndex = 36
        Me.ButUpdate.Text = "Update"
        '
        'ButDelete
        '
        Me.ButDelete.Location = New System.Drawing.Point(560, 318)
        Me.ButDelete.Name = "ButDelete"
        Me.ButDelete.Size = New System.Drawing.Size(176, 33)
        Me.ButDelete.TabIndex = 37
        Me.ButDelete.Text = "Delete"
        '
        'ButQuit
        '
        Me.ButQuit.Location = New System.Drawing.Point(560, 358)
        Me.ButQuit.Name = "ButQuit"
        Me.ButQuit.Size = New System.Drawing.Size(176, 35)
        Me.ButQuit.TabIndex = 38
        Me.ButQuit.Text = "Quit"
        '
        'PictureBox1
        '
        Me.PictureBox1.Location = New System.Drawing.Point(560, 400)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(176, 144)
        Me.PictureBox1.TabIndex = 39
        Me.PictureBox1.TabStop = False
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(8, 502)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(80, 24)
        Me.Label9.TabIndex = 40
        Me.Label9.Text = "Tissue"
        '
        'cbTissue
        '
        Me.cbTissue.Location = New System.Drawing.Point(96, 498)
        Me.cbTissue.Name = "cbTissue"
        Me.cbTissue.Size = New System.Drawing.Size(256, 21)
        Me.cbTissue.TabIndex = 41
        Me.cbTissue.Text = "ComboBox1"
        '
        'CbSeqDataFile
        '
        Me.CbSeqDataFile.Location = New System.Drawing.Point(384, 239)
        Me.CbSeqDataFile.Name = "CbSeqDataFile"
        Me.CbSeqDataFile.Size = New System.Drawing.Size(160, 21)
        Me.CbSeqDataFile.TabIndex = 42
        Me.CbSeqDataFile.Text = "ComboBox1"
        '
        'cbLocation
        '
        Me.cbLocation.Location = New System.Drawing.Point(384, 400)
        Me.cbLocation.Name = "cbLocation"
        Me.cbLocation.Size = New System.Drawing.Size(160, 21)
        Me.cbLocation.TabIndex = 43
        Me.cbLocation.Text = "ComboBox1"
        '
        'cbPurificationMethod
        '
        Me.cbPurificationMethod.Location = New System.Drawing.Point(384, 434)
        Me.cbPurificationMethod.Name = "cbPurificationMethod"
        Me.cbPurificationMethod.Size = New System.Drawing.Size(160, 21)
        Me.cbPurificationMethod.TabIndex = 44
        Me.cbPurificationMethod.Text = "ComboBox1"
        '
        'cbTarget
        '
        Me.cbTarget.Location = New System.Drawing.Point(96, 393)
        Me.cbTarget.Name = "cbTarget"
        Me.cbTarget.Size = New System.Drawing.Size(160, 21)
        Me.cbTarget.TabIndex = 45
        Me.cbTarget.Text = "ComboBox1"
        '
        'frPCRproduct
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(744, 550)
        Me.Controls.Add(Me.cbTarget)
        Me.Controls.Add(Me.cbPurificationMethod)
        Me.Controls.Add(Me.cbLocation)
        Me.Controls.Add(Me.CbSeqDataFile)
        Me.Controls.Add(Me.cbTissue)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.ButQuit)
        Me.Controls.Add(Me.ButDelete)
        Me.Controls.Add(Me.ButUpdate)
        Me.Controls.Add(Me.ButAdd)
        Me.Controls.Add(Me.Label17)
        Me.Controls.Add(Me.Label16)
        Me.Controls.Add(Me.TxRow)
        Me.Controls.Add(Me.Label15)
        Me.Controls.Add(Me.TxColumn)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.TxDate)
        Me.Controls.Add(Me.Label13)
        Me.Controls.Add(Me.TxSource)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.TxComments)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.TxMethod)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.TxGelImageFile)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.TxnguL)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.cbReverse)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.cbForward)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.TxDescription)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.DataGrid1)
        Me.Name = "frPCRproduct"
        Me.Text = "PCR Product"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim ID As Integer
    Dim Mode As Integer
    Dim TissueID As Integer
    Private Sub PCRproduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ShowToolTip()
        Load_PCRproduct()
    End Sub
    Private Sub Load_PCRproduct()
        On Error Resume Next
        Init()
        Dim SQLs As String
        Dim t As String

        Dim connString As String = strConn
        Dim myConnection As OleDb.OleDbConnection = New OleDb.OleDbConnection
        myConnection.ConnectionString = connString
        ' create a data adapter 
        SQLs = "SELECT productID,Description,ForwardPrimer,ReversePrimer,[ng/uL], GelImageFile, " & _
                "  Target,Method,SequenceDataFile,Comments,Source" & _
                " ,Date1,Column1,Row, Location,PurificationMethod, TissueID FROM PCR_product ORDER BY cint(productID)"


        Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(SQLs, myConnection)
        ' create a new dataset 
        Dim ds As DataSet = New DataSet
        ' fill dataset 
        da.Fill(ds, "PCR_product")

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

        DataGrid1.DataSource = ds.DefaultViewManager
        DataGrid1.DataMember = "PCR_product"
        DataGrid1.ColumnHeadersVisible = True
        DataGrid1.Refresh()
        myConnection.Close()

        TxDescription.Text = ""
        cbForward.Items.Clear()
        FillComboBox(cbForward, "Primer_sequences", "PrimerId")
        cbForward.Text = ""
        cbReverse.Items.Clear()
        FillComboBox(cbReverse, "Primer_sequences", "PrimerId")
        cbReverse.Text = ""
        TxnguL.Text = "0.0"
        TxGelImageFile.Text = ""
        cbTarget.Items.Clear()
        FillComboBox(cbTarget, "cbPCR_Target", "Target")
        cbTarget.Text = ""

        TxMethod.Text = ""
        TxSource.Text = ""
        CbSeqDataFile.Text = ""
        TxComments.Text = ""
        cbLocation.Items.Clear()
        FillComboBox(cbLocation, "cbLocation", "Location")
        cbLocation.Text = ""

        TxColumn.Text = ""
        TxRow.Text = ""
        TxDate.Text = ""
        cbPurificationMethod.Items.Clear()
        FillComboBox(cbPurificationMethod, "cbPCR_PurificationMethod", "PurificationMethod")
        cbPurificationMethod.Text = ""

        FillComboBox(cbTissue, "Tissues", "Description")
        cbTissue.Text = ""
    End Sub
    Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
        Dim i As Integer, s As String
        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)
                TxDescription.Text = DataGrid1.Item(i, 1)
                cbForward.Text = DataGrid1.Item(i, 2)
                cbReverse.Text = DataGrid1.Item(i, 3)
                TxnguL.Text = DataGrid1.Item(i, 4)
                TxGelImageFile.Text = DataGrid1.Item(i, 5)
                cbTarget.Text = DataGrid1.Item(i, 6)
                TxMethod.Text = DataGrid1.Item(i, 7)
                CbSeqDataFile.Text = DataGrid1.Item(i, 8)
                ' TxFileFormat.Text = DataGrid1.Item(i, 9)
                TxComments.Text = DataGrid1.Item(i, 9)
                TxSource.Text = DataGrid1.Item(i, 10)
                TxDate.Text = DataGrid1.Item(i, 11)
                TxColumn.Text = DataGrid1.Item(i, 12)
                TxRow.Text = DataGrid1.Item(i, 13)
                cbLocation.Text = DataGrid1.Item(i, 14)
                cbPurificationMethod.Text = DataGrid1.Item(i, 15)
                s = getName("tissues", "tissueID", "Description", DataGrid1.Item(i, 16))

                'MsgBox(s)

                cbTissue.Text = s

                ButUpdate.Enabled = True
                ButDelete.Enabled = True
                t = True
            End If
            i = i + 1
        End While
    End Sub
    Private Sub ButQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButQuit.Click
        Me.Hide()
    End Sub
    Private Sub CbTissue_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTissue.SelectedIndexChanged
        Dim sSQL As String, t As String
        On Error Resume Next
        t = getID("tissues", "tissueID", "Description", cbTissue.Text)
        If Len(t) > 0 Then
            TissueID = CInt(t)
        Else
            TissueID = -1
        End If

        sSQL = "SELECT FileName FROM Sequences WHERE TissueID= " & TissueID

        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(sSQL, myConnection)
        ' create a new dataset 
        Dim ds As DataSet = New DataSet
        ' fill dataset 
        da.Fill(ds, "sequences")

        CbSeqDataFile.DataSource = ds.DefaultViewManager
        CbSeqDataFile.DisplayMember = "Sequences.FileName"
        CbSeqDataFile.Refresh()

    End Sub

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

        t = getID("tissues", "tissueID", "Description", cbTissue.Text)
        If Len(t) > 0 Then
            TissueID = CInt(t)
        Else
            TissueID = 0
        End If

        If Mode = 0 Then

            sSQL = "INSERT INTO PCR_product(Description,ForwardPrimer,ReversePrimer,[ng/uL],GelImageFile," & _
                   " Target,Method,SequenceDataFile,Comments,Source," & _
                   "Date1,column1,row, Location,PurificationMethod,TissueID)" & _
                   " VALUES ('" & TxDescription.Text & _
                   "','" & cbForward.Text & _
                   "','" & cbReverse.Text & _
                   "'," & CDbl(TxnguL.Text) & _
                   ",'" & TxGelImageFile.Text & _
                   "','" & cbTarget.Text & _
                   "','" & TxMethod.Text & _
                   "','" & CbSeqDataFile.Text & _
                   "','" & TxComments.Text & _
                   "','" & TxSource.Text & _
                   "','" & TxDate.Text & _
                   "','" & TxColumn.Text & _
                   "','" & TxRow.Text & _
                   "','" & cbLocation.Text & _
                   "','" & cbPurificationMethod.Text & _
                   "'," & TissueID & ")"

            Dim myCommand As New OleDb.OleDbCommand(sSQL, myConnection)
            myCommand.Connection = myConnection

            myCommand.ExecuteNonQuery()
            myCommand.Dispose()

            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 * FROM PCR_product", myConnection)

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

            ' 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

            strSQL = "UPDATE PCR_product SET Description= '" & TxDescription.Text & _
            "',ForwardPrimer= '" & cbForward.Text & _
            "',ReversePrimer='" & cbReverse.Text & _
            "',[ng/uL]=" & CDbl(TxnguL.Text) & _
            ",GelImageFile='" & TxGelImageFile.Text & _
            "',Target='" & cbTarget.Text & _
            "',Method='" & TxMethod.Text & _
            "',SequenceDataFile='" & CbSeqDataFile.Text & _
            "',Comments='" & TxComments.Text & _
            "',Source='" & TxSource.Text & _
            "',Date1='" & TxDate.Text & _
            "',Column1='" & TxColumn.Text & _
            "',Row='" & TxRow.Text & _
            "',Location='" & cbLocation.Text & _
            "',PurificationMethod='" & cbPurificationMethod.Text & _
            "',TissueID=" & TissueID & _
            "  WHERE  ProductID=" & ID

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

            DataGrid1.Item(DataGrid1.CurrentRowIndex, 1) = TxDescription.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 2) = cbForward.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 3) = cbReverse.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 4) = TxnguL.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 5) = TxGelImageFile.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 6) = cbTarget.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 7) = TxMethod.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 8) = CbSeqDataFile.Text
            'DataGrid1.Item(DataGrid1.CurrentRowIndex, 9) = TxFileFormat.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 9) = TxComments.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 10) = TxSource.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 11) = TxDate.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 12) = TxColumn.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 13) = TxRow.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 14) = cbLocation.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 15) = cbPurificationMethod.Text
            DataGrid1.Item(DataGrid1.CurrentRowIndex, 16) = getID("tissues", "tissueID", "Description", cbTissue.Text)
        End If

        myConnection.Close()
    End Sub

    Private Sub ButAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButAdd.Click
        TxDescription.Text = ""
        cbForward.Text = ""
        cbReverse.Text = ""
        TxnguL.Text = "0.0"
        TxGelImageFile.Text = ""
        cbTarget.Text = ""
        TxMethod.Text = ""
        CbSeqDataFile.Text = ""
        TxComments.Text = ""
        TxSource.Text = ""
        TxDate.Text = ""
        TxColumn.Text = ""
        TxRow.Text = ""
        cbLocation.Text = ""
        cbPurificationMethod.Text = ""

        ButUpdate.Enabled = True
        ButDelete.Enabled = False
        Mode = 0
        TxDescription.Focus()
    End Sub
    Private Sub Flush()
        TxDescription.Text = ""
        cbForward.Text = ""
        cbReverse.Text = ""
        TxnguL.Text = "0.0"
        TxGelImageFile.Text = ""
        cbTarget.Text = ""
        TxMethod.Text = ""
        CbSeqDataFile.Text = ""
        TxComments.Text = ""
        TxSource.Text = ""
        TxDate.Text = ""
        TxColumn.Text = ""
        TxRow.Text = ""
        cbLocation.Text = ""
        cbPurificationMethod.Text = ""
        cbTissue.Text = ""
    End Sub
    Private Sub Load_cbSeqFile()


    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, "The description of the sample as it is writen on the sample label")
        toolTip1.SetToolTip(Me.Label2, "Primer that binds to the sense strand, usually shown to the left of the product")
        toolTip1.SetToolTip(Me.Label3, "Primer that binds to the sense strand, usually shown to the right of the product")

        toolTip1.SetToolTip(Me.Label4, "Concentration of DNA in the column purified PCR product")
        'toolTip1.SetToolTip(Me.ckAvailable, "Check if the sample is available in the in storage. Remove checkmark whenever you use the last of a sample")
        toolTip1.SetToolTip(Me.Label5, "*.doc and 1D files of gels that were run using DNA from this sample")
        toolTip1.SetToolTip(Me.Label6, "DNA region that is targeted by the primer combination used (ie. ascomycete ITS, small subunit DNA, etc.)")
        ' toolTip1.SetToolTip(Me.Label7, "Where preserved form is located (eg. Freeze #2)")
        toolTip1.SetToolTip(Me.Label8, "if amplified DNA has been sequenced, where are the sequence files located ?")
        toolTip1.SetToolTip(Me.Label11, "Genomic DNA ID of the PCR template DNA")
        toolTip1.SetToolTip(Me.Label13, "The day that the PCR reaction was run")
        toolTip1.SetToolTip(Me.Label14, "Box column located in")
        toolTip1.SetToolTip(Me.Label15, "Box row located in")
        toolTip1.SetToolTip(Me.Label16, "Where PCR product is located (eg. Freeze #2). PCR products should be only stored in the refrigerator boxes temporarilly, until gels can be run and samples can be column purified if necessary")

        toolTip1.SetToolTip(Me.Label17, "How was the PCR product purified ? (choose protocol or not purified)")
        toolTip1.SetToolTip(Me.Label10, "Any further information needed for this particular sample")


    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 PCR product 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 PCR_product WHERE productID= " & ID
            OpenConn()

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

    Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate

    End Sub
End Class
