JayBeeOH

LocalDB 1st App - MainForm.vb

Jul 31st, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.82 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   LocalDB 1st App
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Jul 2015
  16. '
  17. ' Description:    A simple Parent/Child table maintenance form using an embeded LocalDB
  18. '                 SQL database.  The strongly typed DataSet has had the relation
  19. '                 (FK_Orders_Customers) between the Parent table and the Child table
  20. '                 modified to have the Update Rule: Cascade, the Delete Rule: Casecade and
  21. '                 the Accept/Reject Rule: None.
  22. '
  23. ' Documentation:  Code at: http://pastebin.com/KU0U1bXR
  24. '                 Video Tutorial at: https://www.youtube.com/user/BolenPresents/
  25. '
  26. '-------------------------------------------------------------------------------------------
  27.  
  28. Public Class MainForm
  29.  
  30.     Private Sub CustomersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) _
  31.         Handles CustomersBindingNavigatorSaveItem.Click
  32.  
  33.         Me.Validate()
  34.         Me.CustomersBindingSource.EndEdit()
  35.         Me.OrdersBindingSource.EndEdit()
  36.         Me.TableAdapterManager.UpdateAll(Me.SampleDBDataSet)
  37.  
  38.     End Sub
  39.  
  40.     Private Sub MainForm_Load(sender As Object, e As EventArgs) _
  41.         Handles MyBase.Load
  42.  
  43.         ' Make DataGridView Column Headings bold.
  44.         Me.OrdersDataGridView.ColumnHeadersDefaultCellStyle.Font =
  45.             New Font(Me.OrdersDataGridView.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold)
  46.  
  47.         ' Fill the Customer (Parent) table in the DataSet with all records from the database.
  48.         Me.CustomersTableAdapter.Fill(Me.SampleDBDataSet.Customers)
  49.  
  50.         ' File the Orders (Child) table in the DataSet with all records
  51.         ' From the database after the Parent table.
  52.         Me.OrdersTableAdapter.Fill(Me.SampleDBDataSet.Orders)
  53.  
  54.     End Sub
  55.  
  56.     Private Sub OrdersBindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) _
  57.         Handles OrdersBindingSource.AddingNew
  58.  
  59.         ' When adding a new row to the Child table,
  60.         ' push From the form the Parent table's data.
  61.         CustomersBindingSource.EndEdit()
  62.     End Sub
  63. End Class
Advertisement
Add Comment
Please, Sign In to add comment