Commits

ChrisLowe committed b300a0f

Update fixed

Comments (0)

Files changed (2)

Assignment3/frmArticles.Designer.vb

         Me.Label3 = New System.Windows.Forms.Label()
         Me.Label2 = New System.Windows.Forms.Label()
         Me.GroupBox2 = New System.Windows.Forms.GroupBox()
+        Me.btnSaveChanges = New System.Windows.Forms.Button()
         Me.btnCancel = New System.Windows.Forms.Button()
         Me.btnSave = New System.Windows.Forms.Button()
         Me.btnEdit = New System.Windows.Forms.Button()
         Me.btnDelete = New System.Windows.Forms.Button()
         Me.Label6 = New System.Windows.Forms.Label()
         Me.btnDebug = New System.Windows.Forms.Button()
-        Me.btnSaveChanges = New System.Windows.Forms.Button()
         Me.ArticlesBindingSource = New System.Windows.Forms.BindingSource(Me.components)
         Me.AboutVBDataSet = New Assignment3.AboutVBDataSet()
         Me.ArticlesTableAdapter = New Assignment3.AboutVBDataSetTableAdapters.ArticlesTableAdapter()
         Me.AboutVBDataSet1 = New Assignment3.AboutVBDataSet()
         Me.Button1 = New System.Windows.Forms.Button()
+        Me.Button2 = New System.Windows.Forms.Button()
         Me.GroupBox1.SuspendLayout()
         Me.GroupBox2.SuspendLayout()
         CType(Me.ArticlesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
         Me.GroupBox2.TabStop = False
         Me.GroupBox2.Text = "Navigation"
         '
+        'btnSaveChanges
+        '
+        Me.btnSaveChanges.Location = New System.Drawing.Point(175, 73)
+        Me.btnSaveChanges.Name = "btnSaveChanges"
+        Me.btnSaveChanges.Size = New System.Drawing.Size(75, 55)
+        Me.btnSaveChanges.TabIndex = 13
+        Me.btnSaveChanges.Text = "Save Changes"
+        Me.btnSaveChanges.UseVisualStyleBackColor = True
+        '
         'btnCancel
         '
         Me.btnCancel.Location = New System.Drawing.Point(276, 73)
         Me.btnDebug.Text = "Debug"
         Me.btnDebug.UseVisualStyleBackColor = True
         '
-        'btnSaveChanges
-        '
-        Me.btnSaveChanges.Location = New System.Drawing.Point(175, 73)
-        Me.btnSaveChanges.Name = "btnSaveChanges"
-        Me.btnSaveChanges.Size = New System.Drawing.Size(75, 55)
-        Me.btnSaveChanges.TabIndex = 13
-        Me.btnSaveChanges.Text = "Save Changes"
-        Me.btnSaveChanges.UseVisualStyleBackColor = True
-        '
         'ArticlesBindingSource
         '
         Me.ArticlesBindingSource.DataMember = "Articles"
         Me.Button1.Text = "Button1"
         Me.Button1.UseVisualStyleBackColor = True
         '
+        'Button2
+        '
+        Me.Button2.Location = New System.Drawing.Point(189, 517)
+        Me.Button2.Name = "Button2"
+        Me.Button2.Size = New System.Drawing.Size(75, 23)
+        Me.Button2.TabIndex = 15
+        Me.Button2.Text = "Button2"
+        Me.Button2.UseVisualStyleBackColor = True
+        '
         'frmArticles
         '
         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
         Me.BackColor = System.Drawing.Color.CadetBlue
         Me.ClientSize = New System.Drawing.Size(557, 552)
+        Me.Controls.Add(Me.Button2)
         Me.Controls.Add(Me.Button1)
         Me.Controls.Add(Me.btnDebug)
         Me.Controls.Add(Me.Label6)
     Friend WithEvents btnPrevious As System.Windows.Forms.Button
     Friend WithEvents btnSaveChanges As System.Windows.Forms.Button
     Friend WithEvents Button1 As System.Windows.Forms.Button
+    Friend WithEvents Button2 As System.Windows.Forms.Button
 
 End Class

Assignment3/frmArticles.vb

     Dim myTableName = "Articles"
     Dim editMode = False
     Dim editIndex As Integer
+    Dim lastArticleTitle As String
 
 
     ' Removes the row with the given title
     Private Sub testUpdateDatabase()
 
 
-        Dim sqlString = "UPDATE Articles SET artTitle='New Article' WHERE artKey=2"
+        Dim sqlString = "UPDATE Articles SET artTitle='New Article' WHERE artKey=4;"
         Dim updateSQLCommand As New OleDbCommand(sqlString, myOleDBConnection)
 
         myOleDBConnection.Open()
     End Sub
 
 
-    Private Sub updateRowToDatabase(ByVal dr As DataRow)
+    Private Sub updateRowToDatabase(ByVal dr As DataRow, ByVal idx As Integer)
 
         Dim updateSQLCommand As OleDbCommand
         Dim rowsChanged = 0
 
         Dim updateSQLString = "UPDATE " & myTableName & _
             " SET artTitle='" & aTitle & "', " & _
-            " artDescription = '" & aDescription & "' " & _
-            " WHERE artKey=" & editIndex + 1
+            "artDescription='" & aDescription & "' " & _
+            "WHERE artTitle='" & lastArticleTitle & "'"
 
         updateSQLCommand = New OleDbCommand(updateSQLString, myOleDBConnection)
 
             End If
 
 
-       End Try
+        End Try
 
     End Sub
 
 
         ' Add to the database
 
-        updateRowToDatabase(dr)
+        updateRowToDatabase(dr, cbxArticles.SelectedIndex + 1)
 
     End Sub
 
         btnEdit.Visible = False
         btnDelete.Visible = False
         btnOpen.Enabled = False
-        btnPrevious.Enabled = False
-        btnNext.Enabled = False
+        'btnPrevious.Enabled = False
+        'btnNext.Enabled = False
         editMode = True
 
         ' Reset fields
         txtArticleURL.Text = ""
         cbxArticleVB6.Checked = False
         cbxArticleVBNET.Checked = False
-        cbxArticles.Enabled = False
+        cbxArticles.Enabled = True ''
     End Sub
 
 
     Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
 
         editMode = True
+        lastArticleTitle = txtArticleTitle.Text
         btnAdd.Visible = False
         btnDelete.Visible = False
         btnNext.Enabled = False
         editMode = False
         updateData()
         btnSave.Visible = False
-        btnDelete.Visible = False
+        btnAdd.Visible = True
+        btnEdit.Visible = True
+        btnDelete.Visible = True
         btnOpen.Enabled = True
         btnPrevious.Enabled = True
         btnNext.Enabled = True
-        btnSaveChanges.Visible = True
-        btnCancel.Visible = True
+        btnSaveChanges.Visible = False
+        btnCancel.Visible = False
         openDatabase()
         updateArticle(1)
     End Sub
     End Sub
 
    
+    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
+        MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
+        ' System.Diagnostics.Process.Start("rundll32.exe", "shdocvw.dll,DoOrganizeFavDlg")
+    End Sub
 End Class
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.