Home

Example Database Application:

College Park Auto Repair

   

Introduction

A car repair shop is a business where people bring their cars to have them serviced. Before working on the car,the company would get some basic information about the customer (such as name) and the car (such as what is wrong with the car).

We are going to create a graphical application that can assist a car repair shop manage its business.

Practical LearningPractical Learning: Introducing the Application

  1. Start Microsoft Visual Studio
  2. To start a new project, on the main menu, click File -> New -> Project...
  3. Select the language or environment you will use. We will use Visual Basic
  4. Make sure Windows Forms Application is selected.
    Set the Name to CollegeParkAutoRepair1
  5. Click OK
  6. In the Solution Explorer, right-click Form1.cs and click Rename
  7. Type CollegeParkAutoRepair.vb and press Enter
  8. Double-click the body of the form to generate its Load event
  9. Implement the event as follows:
    Imports System.Data.SqlClient
    
    Public Class CollegeParkAutoRepair
        Private Sub CreateDatabase()
            ' Specify the name of your server. Ours is named EXPRESSION
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
            New SqlConnection("Data Source=" & strServerName & ";" &
                                      "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                                   New SqlCommand("IF EXISTS (" &
                                                  "SELECT name " &
                                                  "FROM sys.databases " &
                                                  "WHERE name = N'CollegeParkAutoRepair1')" &
                                                  "DROP DATABASE CollegeParkAutoRepair1; " &
                                                  "CREATE DATABASE CollegeParkAutoRepair1;", cntCPAR)
                cntCPAR.Open()
                cmdCPAR.ExecuteNonQuery()
            End Using
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                                New SqlCommand("CREATE SCHEMA Repairs;", cntCPAR)
                cntCPAR.Open()
                cmdCPAR.ExecuteNonQuery()
            End Using
    
            MsgBox("The CollegeParkAutoRepair1 database has been created.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
        End Sub
    
        Private Sub CollegeParkAutoRepair_Load(sender As System.Object,
                                               e As System.EventArgs) Handles MyBase.Load
            CreateDatabase()
        End Sub
    End Class
    
    
  10. Execute the application
  11. When the message box displays, click OK
  12. Close the form and return to your programming environment

Repair Orders

A repair order is the core operation of this business. A customer has to bring a car to the shop. An employee must first create a repair order. To do this, the employee must get some basic information about the customer such as the name, the car make, the model, the year, and the problem with the car. The system must create a repair order that also has a receipt number.

Practical LearningPractical Learning: Creating a Repair Order

  1. Change the document as follows:
    Imports System.Data.SqlClient
    
    Public Class CollegeParkAutoRepair
        Private Sub CreateRepairOrders()
            ' Specify the name of your server. Ours is named EXPRESSION
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("CREATE TABLE Repairs.Orders" &
                                       "(" &
                                       "    ReceiptNumber int not null, " &
                                       "    DateReceived nvarchar(50), " &
                                       "    TimeReceived nvarchar(20), " &
                                       "    DateCompleted nvarchar(50), " &
                                       "    TimeCompleted nvarchar(20), " &
                                       "    DatePickedUp nvarchar(50), " &
                                       "    TimePickedUp nvarchar(20), " &
                                       "    CustomerName nvarchar(50), " &
                                       "    Address nvarchar(60), " &
                                       "    City nvarchar(40), " &
                                       "    State nvarchar(40), " &
                                       "    ZIPCode nvarchar(20), " &
                                       "    Make nvarchar(50), " &
                                       "    Model nvarchar(50), " &
                                       "    CarYear int, " &
                                       "    ProblemDescription nvarchar(max), " &
                                       "    TaxRate decimal(6, 2), " &
                                       "    Recommendations nvarchar(max), " &
                                       "    Constraint PK_RepairOrders Primary Key (ReceiptNumber)" &
                                       ");",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            MsgBox("A table for repair orders has been created.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
        End Sub
    
        Private Sub CollegeParkAutoRepair_Load(sender As System.Object,
                                               e As System.EventArgs) Handles MyBase.Load
            CreateRepairOrders()
        End Sub
    End Class
    
    
  2. Execute the application
  3. When the message box displays, click OK
  4. Close the form and return to your programming environment

Parts Used

Most of the time, to repair a car, a technician must used one or parts. In some cases, the company may have easy-to-find parts in place. In most other cases, the parts must be ordered. Either way, the company must keep track of the parts that were used to repair the car because the customer will have to pay for them (in some cases, especially in small companies, the technician would ask the customer to purchase the part(s) first; in some other cases, the company would ask the customer to approve using or purchasing a part; this would be added to the customer's invoice who would then pay for the part(s)).

To keep track of the parts that were used to repair a car, we will create a table for parts used. The record of each part would hold a receipt number. That way, with the magic of relational databases, we will be able to know what repair order used this or that part.

Practical LearningPractical Learning: Keeping Track or Parts Used

  1. Change the document as follows:
    Imports System.Data.SqlClient
    
    Public Class CollegeParkAutoRepair
        Private Sub CreatePartsUsed()
            ' Specify the name of your server. Ours is named EXPRESSION
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("CREATE TABLE Repairs.PartsUsed" &
                                       "(" &
                                       "    PartUsedID int identity(1, 1) not null, " &
                                       "    ReceiptNumber int, " &
                                       "    PartName nvarchar(50), " &
                                       "    UnitPrice money, " &
                                       "    Quantity int, " &
                                       "    Constraint PK_PartsUsed Primary Key (PartUsedID)" &
                                       ");",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            MsgBox("A table has been created to keep track of parts used in a repair order.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
        End Sub
    
        Private Sub CollegeParkAutoRepair_Load(sender As System.Object,
                                               e As System.EventArgs) Handles MyBase.Load
            CreatePartsUsed()
        End Sub
    End Class
    
    
  2. Execute the application
  3. When the message box displays, click OK
  4. Close the form and return to your programming environment

Jobs Performed

Another important part of a car repair invoice is to know what was done to fix the vehicle. To inform the customer of this, a list of jobs performed should be included in the invoice.

To keep track of the jobs that were performe to repair a car, we will create a table for them. The record of each job would have a receipt number. When we access the record of a job, we would know what repair order it is associated with.

Practical LearningPractical Learning: Keeping Track or Jobs Performed

  1. Change the document as follows:
    Imports System.Data.SqlClient
    
    Public Class CollegeParkAutoRepair
        Private Sub CreateJobsPerformed()
            ' Specify the name of your server. Ours is named EXPRESSION
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("CREATE TABLE Repairs.JobsPerformed" &
                                       "(" &
                                       "    JobPerformedID int identity(1, 1) not null, " &
                                       "    ReceiptNumber int, " &
                                       "    JobPerformed nvarchar(100), " &
                                       "    JobPrice money, " &
                                       "    Constraint PK_JobsPerformed Primary Key (JobPerformedID)" &
                                       ");",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            MsgBox("A table has been created to keep track of job performed for a repair order.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
        End Sub
    
        Private Sub CollegeParkAutoRepair_Load(sender As System.Object,
                                               e As System.EventArgs) Handles MyBase.Load
            CreateJobsPerformed()
        End Sub
    End Class
    
    
  2. Execute the application
  3. When the message box displays, click OK
  4. Close the form and return to your programming environment

Creating a New Repair Order

When a customer brings a car to the shop for a repair, an employee must start a new repart order. We will create a form that provides such graphic functionality.

Practical LearningPractical Learning: Starting a New Repair Order

  1. On the main menu, click Project -> Add Windows Form...
  2. Set the Name to NewRepairOrder
  3. Click Add
  4. Design the form as follows:
     
    College Park Auto Repair - New Repair Order
    Control (Name) Text Other Properties
    GroupBox GroupBox   Customer Order Identification  
    Label Label   Customer Name:  
    TextBox TextBox TxtCustomerName    
    Label Label   Address:  
    TextBox TextBox TxtAddress    
    Label Label   City:  
    TextBox TextBox TxtCity    
    Label Label   State:  
    TextBox TextBox TxtState    
    Label Label   ZIP Code:  
    TextBox TextBox TxtZIPCode    
    Label Label   Make/Model:  
    TextBox TextBox TxtMake    
    TextBox TextBox TxtModel    
    Label Label   Year:  
    TextBox TextBox TxtCarYear   AlignText: Right
    Label Label   Problem Description:  
    TextBox TextBox TxtProblemDescription   Multine: True
    Scrollbars: Vertical
    GroupBox GroupBox   Parts Used  
    Label Label   Part Name/Description  
    Label Label   Unit Price  
    Label Label   Quantity  
    Label Label   Sub-Total  
    TextBox TextBox TxtPartName    
    TextBox TextBox TxtUnitPrice 0.00 AlignText: Right
    TextBox TextBox TxtQuantity 0 AlignText: Right
    TextBox TextBox TxtSubTotal 0.00 AlignText: Right
    Button Button BtnAddPart Add Part  
    ListView ListView LvwPartsUsed    
    Columns  
    (Name) Text TextAlign Width
    ColPartName Part Name/Description   220
    ColUnitPrice Unit Price Right  
    ColQuantity Qty Right 30
    ColSubTotal Sub-Total Right  
    GroupBox GroupBox   Repair Summary  
    Label Label   Total Parts:  
    TextBox TextBox TxtTotalParts 0.00 AlignText: Right
    Label Label   Total Labor:  
    TextBox TextBox TxtTotalLabor 0.00 AlignText: Right
    Label Label   Total Parts && Labor:  
    TextBox TextBox TxtTotalPartsLabor 0.00 AlignText: Right
    Label Label   Tax Rate:  
    TextBox TextBox TxtTaxRate 5.75 AlignText: Right
    Label Label   %  
    Label Label   Tax Amount:  
    TextBox TextBox TxtTaxAmount 0.00 AlignText: Right
    Label Label   Repair Total:  
    TextBox TextBox TxtRepairTotal 0.00 AlignText: Right
    Label Label   Recommendations:  
    TextBox TextBox TxtRecommendations   Multine: True
    Scrollbars: Vertical
    Label Label   Date Received:  
    DateTimePicker DateTimePicker DtpDateReceived    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimeReceived   Format: Time
    ShowUpDown: True
    Label Label   Date Completed:  
    DateTimePicker DateTimePicker DtpDateCompleted    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimeCompleted   Format: Time
    ShowUpDown: True
    Label Label   Date Picked Up:  
    DateTimePicker DateTimePicker DtpDatePickedUp    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimePickedUp   Format: Time
    ShowUpDown: True
    GroupBox GroupBox   Jobs Performed  
    Label Label   Job Performed  
    Label Label   Job Cost  
    TextBox TextBox TxtJobPerformed    
    TextBox TextBox TxtJobCost 0.00 AlignText: Right
    ListView ListView LvwJobsPerformed    
    Columns  
    (Name) Text TextAlign Width
    ColJobPerformed Job Performed   310
    ColJobCost Job Cost Right  
    Label Label   Receipt #:  
    TextBox TextBox TxtReceiptNumber    
    Button Button BtnSubmit Submit  
    Button Button BtnReset Reset  
    Button Button BtnClose Close  
    StatusStrip StatusStrip      
  5. Right-click the form and click View Code
  6. Create a procedure as follows:
    Imports System.Data.SqlClient
    
    Public Class NewRepairOrder
        Private Sub CalculateRepairOrder()
    	Dim TaxRate As Double
            Dim TotalJobs As Double
            Dim TaxAmount As Double
            Dim TotalParts As Double
            Dim LviJob As ListViewItem
            Dim LviPart As ListViewItem
            Dim TotalPartsAndLabor As Double
    
            If LvwPartsUsed.Items.Count = 0 Then
                TotalParts = 0.0
            Else
                For Each LviPart In LvwPartsUsed.Items
                    TotalParts += CDbl(LviPart.SubItems(3).Text)
                Next
            End If
    
            If LvwJobsPerformed.Items.Count = 0 Then
                TotalJobs = 0.0
            Else
                For Each LviJob In LvwJobsPerformed.Items
                    TotalJobs += CDbl(LviJob.SubItems(1).Text)
                Next
            End If
    
            Try
                TaxRate = CDbl(TxtTaxRate.Text)
                TotalPartsAndLabor = TotalParts + TotalJobs
                TaxAmount = TotalPartsAndLabor * TaxRate / 100
    
                TxtTotalParts.Text = FormatNumber(TotalParts)
                TxtTotalLabor.Text = FormatNumber(TotalJobs)
                TxtTotalPartsLabor.Text = FormatNumber(TotalPartsAndLabor)
                TxtTaxAmount.Text = FormatNumber(TaxAmount)
                TxtRepairTotal.Text = FormatNumber(TotalPartsAndLabor + TaxAmount)
            Catch ex As FormatException
                MsgBox("The calculation could not be carried. Please report the error as:" & vbCrLf &
                       "Error Message: " & ex.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                       "College Park Auto Repair")
    
            End Try
        End Sub
    End Class
    
    
  7. In the Object combo box, select TxtQuantity
  8. In the Procedure combo box, select Leave
  9. Implement the event as follows:
    Private Sub TxtQuantity_Leave(sender As Object,
                                  e As System.EventArgs) Handles TxtQuantity.Leave
            Dim UnitPrice As Double
            Dim Quantity As Integer
            Dim SubTotal As Double
    
            If String.IsNullOrEmpty(TxtUnitPrice.Text) Then
                Exit Sub
            End If
    
            If String.IsNullOrEmpty(TxtQuantity.Text) Then
                Exit Sub
            End If
    
            Try
                UnitPrice = CDbl(TxtUnitPrice.Text)
                Quantity = CInt(TxtQuantity.Text)
                SubTotal = FormatNumber(UnitPrice * Quantity)
    
                TxtSubTotal.Text = FormatNumber(SubTotal)
            Catch ex As FormatException
                MsgBox("The calculation could not be carried. Please report the error as:" & vbCrLf &
                       "Error Message: " & ex.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                       "College Park Auto Repair")
            End Try
    
            CalculateRepairOrder()
    End Sub
    
    
  10. In the Object combo box, select BtnAddPart
  11. In the Procedure combo box, select Click
  12. Implement the event as follows:
    Private Sub BtnAddPart_Click(sender As Object,
                                  e As System.EventArgs) Handles BtnAddParts.Click
            If String.IsNullOrEmpty(TxtPartName.Text) Then
                Exit Sub
            End If
    
            Dim LviPart As New ListViewItem(TxtPartName.Text)
    
            LviPart.SubItems.Add(FormatNumber(TxtUnitPrice.Text))
            LviPart.SubItems.Add(TxtQuantity.Text)
            LviPart.SubItems.Add(FormatNumber(TxtSubTotal.Text))
            LvwPartsUsed.Items.Add(LviPart)
    
            TxtPartName.Text = ""
            TxtUnitPrice.Text = "0.00"
            TxtQuantity.Text = "0"
            TxtSubTotal.Text = "0.00"
    
            CalculateRepairOrder()
    End Sub
  13. In the Object combo box, select LvwPartsUsed
  14. In the Procedure combo box, select DoubleClick
  15. Implement the event as follows:
    Private Sub LvwPartsUsed_DoubleClick(sender As Object,
                                         e As System.EventArgs) Handles LvwPartsUsed.DoubleClick
        ' This code acts if the user double-clicks an item in the list of parts used.
        ' We conclude that either the user wants to edit the part
        ' or the user wants to delete the part that was added by mistake
        Dim LviPartUsed As ListViewItem = LvwPartsUsed.SelectedItems(0)
    
        TxtPartName.Text = LviPartUsed.SubItems(0).Text
        TxtUnitPrice.Text = LviPartUsed.SubItems(1).Text
        TxtQuantity.Text = LviPartUsed.SubItems(2).Text
        TxtSubTotal.Text = LviPartUsed.SubItems(3).Text
    
        ' Remove the selected item from the list view
        LviPartUs.Remove()
    End Sub
    
    
  16. In the Object combo box, select BtnAddJob
  17. In the Procedure combo box, select Click
  18. Implement the event as follows:
    Private Sub BtnAddJob_Click(sender As Object,
                                    e As System.EventArgs) Handles BtnAddJob.Click
            If String.IsNullOrEmpty(TxtJobPerformed.Text) Then
                Exit Sub
            End If
    
            Dim LviJob As New ListViewItem(TxtJobPerformed.Text)
    
            LviJob.SubItems.Add(FormatNumber(TxtJobCost.Text))
            LvwJobsPerformed.Items.Add(LviJob)
    
            TxtJobPerformed.Text = ""
            TxtJobCost.Text = "0.00"
            CalculateRepairOrder()
    End Sub
  19. In the Object combo box, select LvwJobsPerformed
  20. In the Procedure combo box, select DoubleClick
  21. Implement the event as follows:
    Private Sub LvwJobsPerformed_DoubleClick(sender As Object,
                                                 e As System.EventArgs) Handles LvwJobsPerformed.DoubleClick
            ' This code acts if the user double-clicks a job
            ' from the list of jobs performed.
            ' We conclude that either the user wants to edit the job
            ' or the user wants to remove/cancel the job
            Dim LviJobPerformed As ListViewItem = LvwJobsPerformed.SelectedItems(0)
    
            TxtJobPerformed.Text = LviJobPerformed.SubItems(0).Text
            TxtJobCost.Text = LviJobPerformed.SubItems(1).Text
    
            ' Remove the selected job from the list view
            LviJobPerformed.Remove()
    End Sub
    
    
  22. In the Object combo box, select BtnReset
  23. In the Procedure combo box, select Click
  24. Implement the event as follows:
    Private Sub BtnReset_Click(sender As Object, e As System.EventArgs) Handles BtnReset.Click
            Dim ReceiptNumber As Integer
            Dim strServerName As String = "EXPRESSION"
    
            ReceiptNumber = 100000
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                        New SqlCommand("SELECT MAX(ReceiptNumber) FROM Repairs.Orders;",
                                       cntCPAR)
    
                cntCPAR.Open()
                Dim sdrReceipts As SqlDataReader
    
                sdrReceipts = cmdCPAR.ExecuteReader()
    
                Do While sdrReceipts.Read()
                    If Not String.IsNullOrEmpty(sdrReceipts(0).ToString()) Then
                        ReceiptNumber = CInt(sdrReceipts.GetSqlInt32(0).ToString())
                    End If
                Loop
    
                TxtReceiptNumber.Text = CStr(ReceiptNumber + 1)
            End Using
    
            DtpDateReceived.Value = Today
            DtpTimeReceived.Value = Now
            TxtCustomerName.Text = ""
            TxtAddress.Text = ""
            TxtCity.Text = ""
            TxtState.Text = ""
            TxtZIPCode.Text = ""
            TxtMake.Text = ""
            TxtModel.Text = ""
            TxtCarYear.Text = ""
            TxtProblemDescription.Text = ""
    
            TxtPartName.Text = ""
            TxtUnitPrice.Text = "0.00"
            TxtQuantity.Text = "0"
            TxtSubTotal.Text = "0.00"
            LvwPartsUsed.Items.Clear()
    
            TxtJobPerformed.Text = ""
            TxtJobCost.Text = "0.00"
            LvwJobsPerformed.Items.Clear()
            
            TxtTotalParts.Text = "0.00"
            TxtTotalLabor.Text = "0.00"
            TxtTaxRate.Text = "5.75"
            TxtTaxAmount.Text = "0.00"
            TxtTotalPartsLabor.Text = "0.00"
            TxtRepairTotal.Text = "0.00"
            TxtRecommendations.Text = ""
    End Sub
  25. In the Object combo box, select (NewrepairOrder Events)
  26. In the Procedure combo box, select Load
  27. Implement the event as follows:
    Private Sub NewRepairOrder_Load(sender As System.Object,
                                        e As System.EventArgs) Handles MyBase.Load
            BtnReset_Click(sender, e)
    End Sub
  28. In the Object combo box, select BtnSubmit
  29. In the Procedure combo box, select Click
  30. Implement the event as follows:
    Private Sub BtnSubmit_Click(sender As Object, e As System.EventArgs) Handles BtnSubmit.Click
            Dim LviJob As ListViewItem
            Dim LviPart As ListViewItem
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("INSERT INTO Repairs.Orders" &
                                       "(ReceiptNumber, CustomerName, Address, City, State, ZIPCode, Make, Model, " &
                                       "CarYear, ProblemDescription, TaxRate, Recommendations, " &
                                       "DateReceived, TimeReceived, DateCompleted, TimeCompleted, " &
                                       "DatePickedUp, TimePickedUp) " &
                                       "VALUES(" & CInt(TxtReceiptNumber.Text) & ", '" & TxtCustomerName.Text &
                                       "', '" & TxtAddress.Text & "', '" & TxtCity.Text & "', '" &
                                       TxtState.Text & "', '" & TxtZIPCode.Text & "', '" & TxtMake.Text &
                                       "', '" & TxtModel.Text & "', " & CInt(TxtCarYear.Text) & ", '" &
                                       TxtProblemDescription.Text & "', " & CDbl(TxtTaxRate.Text) &
                                       ", '" & TxtRecommendations.Text & "', '" &
                                       DtpDateReceived.Value.ToShortDateString() & "', '" &
                                       DtpTimeReceived.Value.ToShortTimeString() & "', '" &
                                       DtpDateCompleted.Value.ToShortDateString() & "', '" &
                                       DtpTimeCompleted.Value.ToShortTimeString & "', '" &
                                       DtpDatePickedUp.Value.ToShortDateString() & "', '" &
                                       DtpTimePickedUp.Value.ToShortTimeString & "');",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            If LvwPartsUsed.Items.Count > 0 Then
                For Each LviPart In LvwPartsUsed.Items
                    Using cntCPAR As SqlConnection =
                        New SqlConnection("Data Source=" & strServerName & ";" &
                                          "Database='CollegeParkAutoRepair1';" &
                                          "Integrated Security=Yes")
                        Dim cmdCeilInn As SqlCommand =
                                New SqlCommand("INSERT INTO Repairs.PartsUsed" &
                                               "(ReceiptNumber, PartName, UnitPrice, Quantity) " &
                                               "VALUES(" & CInt(TxtReceiptNumber.Text) & ", '" &
                                               LviPart.SubItems(0).Text & "', " & CDbl(LviPart.SubItems(1).Text) &
                                               ", " & CInt(LviPart.SubItems(2).Text) & ");",
                                               cntCPAR)
                        cntCPAR.Open()
                        cmdCeilInn.ExecuteNonQuery()
                    End Using
                Next
            End If
    
            If LvwJobsPerformed.Items.Count > 0 Then
                For Each LviJob In LvwJobsPerformed.Items
                    Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                        Dim cmdCeilInn As SqlCommand =
                                New SqlCommand("INSERT INTO Repairs.JobsPerformed" &
                                               "(ReceiptNumber, JobPerformed, JobPrice) " &
                                               "VALUES(" & CInt(TxtReceiptNumber.Text) & ", '" &
                                               LviJob.SubItems(0).Text & "', '" &
                                               LviJob.SubItems(1).Text & "');",
                                               cntCPAR)
                        cntCPAR.Open()
                        cmdCeilInn.ExecuteNonQuery()
                    End Using
                Next
            End If
    
            MsgBox("The new repair order has been created.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
            BtnReset_Click(sender, e)
    End Sub
    
    
  31. In the Object combo box, select BtnClose
  32. In the Procedure combo box, select Click
  33. Implement the event as follows:
    Private Sub BtnClose_Click(sender As System.Object,
                               e As System.EventArgs) Handles BtnClose.Click
        Close()
    End Sub

Updating a Repair Order

As opposed to creating a new repair order, when the customer has been repaired, or when  the customer comes to pick up the car, entries should/must be made in the repair record. For example, a technician can make a note that the car has been repaired. Another time, a cashier can make a note that the customer has come to pay the invoice and picked up the car. In this and other circumstances, an update must be made into the repair order.

Practical LearningPractical Learning: Updating a Repair Order

  1. On the main menu, click Project -> Add Windows Form...
  2. Set the Name to UpdateRepairOrder
  3. Click Add
  4. Design the form as follows:
     
    College Park Auto Repair - Update Repair Order
    Control (Name) Text Other Properties
    GroupBox GroupBox   Customer Order Identification  
    Label Label   Customer Name:  
    TextBox TextBox TxtCustomerName    
    Label Label   Address:  
    TextBox TextBox TxtAddress    
    Label Label   City:  
    TextBox TextBox TxtCity    
    Label Label   State:  
    TextBox TextBox TxtState    
    Label Label   ZIP Code:  
    TextBox TextBox TxtZIPCode    
    Label Label   Make/Model:  
    TextBox TextBox TxtMake    
    TextBox TextBox TxtModel    
    Label Label   Year:  
    TextBox TextBox TxtCarYear   AlignText: Right
    Label Label   Problem Description:  
    TextBox TextBox TxtProblemDescription   Multine: True
    Scrollbars: Vertical
    GroupBox GroupBox   Parts Used  
    Label Label   Part Name/Description  
    Label Label   Unit Price  
    Label Label   Quantity  
    Label Label   Sub-Total  
    TextBox TextBox TxtPartName    
    TextBox TextBox TxtUnitPrice 0.00 AlignText: Right
    TextBox TextBox TxtQuantity 0 AlignText: Right
    TextBox TextBox TxtSubTotal 0.00 AlignText: Right
    Button Button BtnAddPart Add Part  
    ListView ListView LvwPartsUsed    
    Columns  
    (Name) Text TextAlign Width
    ColPartName Part Name/Description   220
    ColUnitPrice Unit Price Right  
    ColQuantity Qty Right 30
    ColSubTotal Sub-Total Right  
    GroupBox GroupBox   Repair Summary  
    Label Label   Total Parts:  
    TextBox TextBox TxtTotalParts 0.00 AlignText: Right
    Label Label   Total Labor:  
    TextBox TextBox TxtTotalLabor 0.00 AlignText: Right
    Label Label   Total Parts && Labor:  
    TextBox TextBox TxtTotalPartsLabor 0.00 AlignText: Right
    Label Label   Tax Rate:  
    TextBox TextBox TxtTaxRate 5.75 AlignText: Right
    Label Label   %  
    Label Label   Tax Amount:  
    TextBox TextBox TxtTaxAmount 0.00 AlignText: Right
    Label Label   Repair Total:  
    TextBox TextBox TxtRepairTotal 0.00 AlignText: Right
    Label Label   Recommendations:  
    TextBox TextBox TxtRecommendations   Multine: True
    Scrollbars: Vertical
    Label Label   Date Received:  
    DateTimePicker DateTimePicker DtpDateReceived    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimeReceived   Format: Time
    ShowUpDown: True
    Label Label   Date Completed:  
    DateTimePicker DateTimePicker DtpDateCompleted    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimeCompleted   Format: Time
    ShowUpDown: True
    Label Label   Date Picked Up:  
    DateTimePicker DateTimePicker DtpDatePickedUp    
    Label Label   Time:  
    DateTimePicker DateTimePicker DtpTimePickedUp   Format: Time
    ShowUpDown: True
    GroupBox GroupBox   Jobs Performed  
    Label Label   Job Performed  
    Label Label   Job Cost  
    TextBox TextBox TxtJobPerformed    
    TextBox TextBox TxtJobCost 0.00 AlignText: Right
    ListView ListView LvwJobsPerformed    
    Columns  
    (Name) Text TextAlign Width
    ColJobPerformed Job Performed   310
    ColJobCost Job Cost Right  
    Label Label   Receipt #:  
    TextBox TextBox TxtReceiptNumber    
    Button Button BtnOpen Open  
    Button Button BtnSubmit Submit  
    Button Button BtnClose Close  
    StatusStrip StatusStrip      
  5. Double-click the Open button
  6. Implement the event as follows:
    Imports System.Data.SqlClient
    
    Public Class UpdateRepairOrder
    
        Private Sub CalculateRepairOrder()
            Dim TaxRate As Double
            Dim TotalJobs As Double
            Dim TaxAmount As Double
            Dim TotalParts As Double
            Dim LviJob As ListViewItem
            Dim LviPart As ListViewItem
            Dim TotalPartsAndLabor As Double
    
            If LvwPartsUsed.Items.Count = 0 Then
                TotalParts = 0.0
            Else
                For Each LviPart In LvwPartsUsed.Items
                    TotalParts += CDbl(LviPart.SubItems(3).Text)
                Next
            End If
    
            If LvwJobsPerformed.Items.Count = 0 Then
                TotalJobs = 0.0
            Else
                For Each LviJob In LvwJobsPerformed.Items
                    TotalJobs += CDbl(LviJob.SubItems(1).Text)
                Next
            End If
    
            Try
                TaxRate = CDbl(TxtTaxRate.Text)
                TotalPartsAndLabor = TotalParts + TotalJobs
                TaxAmount = TotalPartsAndLabor * TaxRate / 100
    
                TxtTotalParts.Text = FormatNumber(TotalParts)
                TxtTotalLabor.Text = FormatNumber(TotalJobs)
                TxtTotalPartsLabor.Text = FormatNumber(TotalPartsAndLabor)
                TxtTaxAmount.Text = FormatNumber(TaxAmount)
                TxtRepairTotal.Text = FormatNumber(TotalPartsAndLabor + TaxAmount)
            Catch ex As FormatException
                MsgBox("The calculation could not be carried. Please report the error as:" & vbCrLf &
                       "Error Message: " & ex.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                       "College Park Auto Repair")
    
            End Try
        End Sub
    
        Private Sub ResetRepairOrder()
            DtpDateReceived.Value = Today
            DtpTimeReceived.Value = Now
            TxtCustomerName.Text = ""
            TxtAddress.Text = ""
            TxtCity.Text = ""
            TxtState.Text = ""
            TxtZIPCode.Text = ""
            TxtMake.Text = ""
            TxtModel.Text = ""
            TxtCarYear.Text = ""
            TxtProblemDescription.Text = ""
    
            TxtPartName.Text = ""
            TxtUnitPrice.Text = "0.00"
            TxtQuantity.Text = "0"
            TxtSubTotal.Text = "0.00"
            LvwPartsUsed.Items.Clear()
    
            TxtJobPerformed.Text = ""
            TxtJobCost.Text = "0.00"
            LvwJobsPerformed.Items.Clear()
    
            TxtTotalParts.Text = "0.00"
            TxtTotalLabor.Text = "0.00"
            TxtTaxRate.Text = "5.75"
            TxtTaxAmount.Text = "0.00"
            TxtTotalPartsLabor.Text = "0.00"
            TxtRepairTotal.Text = "0.00"
            TxtRecommendations.Text = ""
        End Sub
    
        Private Sub BtnOpen_Click(sender As System.Object, e As System.EventArgs) Handles BtnOpen.Click
            Dim strServerName As String = "EXPRESSION"
    
            ResetRepairOrder
    
            If String.IsNullOrEmpty(TxtReceiptNumber.Text) Then
                MsgBox("You must enter a receipt number to open its repair order.",
                       MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                       "College Park Auto Repair")
                Exit Sub
            End If
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                        New SqlCommand("SELECT ALL * " &
                                       "FROM Repairs.Orders " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
    
                cntCPAR.Open()
                Dim sdrReceipts As SqlDataReader
    
                sdrReceipts = cmdCPAR.ExecuteReader()
    
                Do While sdrReceipts.Read()
                    If Not String.IsNullOrEmpty(sdrReceipts(0).ToString()) Then
                        DtpDateReceived.Value = CDate(sdrReceipts(1).ToString())
                        DtpTimeReceived.Value = New DateTime(DtpDateReceived.Value.Year,
                                                             DtpDateReceived.Value.Month,
                                                             DtpDateReceived.Value.Day,
                                                             Hour(CDate(sdrReceipts(2).ToString())),
                                                             Minute(CDate(sdrReceipts(2).ToString())),
                                                             Second(CDate(sdrReceipts(2).ToString())))
                        DtpDateCompleted.Value = CDate(sdrReceipts(3).ToString())
                        DtpTimeCompleted.Value = New DateTime(DtpDateCompleted.Value.Year,
                                                              DtpDateCompleted.Value.Month,
                                                              DtpDateCompleted.Value.Day,
                                                              Hour(CDate(sdrReceipts(4).ToString())),
                                                              Minute(CDate(sdrReceipts(4).ToString())),
                                                              Second(CDate(sdrReceipts(4).ToString())))
                        DtpDatePickedUp.Value = CDate(sdrReceipts(5).ToString())
                        DtpTimePickedUp.Value = New DateTime(DtpDatePickedUp.Value.Year,
                                                             DtpDatePickedUp.Value.Month,
                                                             DtpDatePickedUp.Value.Day,
                                                             Hour(CDate(sdrReceipts(6).ToString())),
                                                             Minute(CDate(sdrReceipts(6).ToString())),
                                                             Second(CDate(sdrReceipts(6).ToString())))
                        TxtCustomerName.Text = sdrReceipts(7).ToString()
                        TxtAddress.Text = sdrReceipts(8).ToString()
                        TxtCity.Text = sdrReceipts(9).ToString()
                        TxtState.Text = sdrReceipts(10).ToString()
                        TxtZIPCode.Text = sdrReceipts(11).ToString()
                        TxtMake.Text = sdrReceipts(12).ToString()
                        TxtModel.Text = sdrReceipts(13).ToString()
                        TxtCarYear.Text = sdrReceipts(14).ToString()
                        TxtProblemDescription.Text = sdrReceipts(15).ToString()
                        TxtTaxRate.Text = CDbl(sdrReceipts(16).ToString())
                        TxtRecommendations.Text = sdrReceipts(17).ToString()
                    End If
                Loop
            End Using
    
            LvwPartsUsed.Items.Clear()
    
            Using cntCPAR As SqlConnection =
           New SqlConnection("Data Source=" & strServerName & ";" &
                             "Database='CollegeParkAutoRepair1';" &
                             "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                        New SqlCommand("SELECT ALL * " &
                                       "FROM Repairs.PartsUsed " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
    
                Dim sdaPartsUsed As SqlDataAdapter = New SqlDataAdapter
                Dim dsPartsUsed As DataSet = New DataSet("PartsUsed")
    
                cntCPAR.Open()
                sdaPartsUsed.SelectCommand = cmdCPAR
                sdaPartsUsed.Fill(dsPartsUsed)
    
                For Each drPartUsed As DataRow In dsPartsUsed.Tables(0).Rows
                    Dim LviPartUsed As ListViewItem = New ListViewItem(CStr(drPartUsed("PartName")))
                    LviPartUsed.SubItems.Add(FormatNumber(CStr(drPartUsed("UnitPrice"))))
                    LviPartUsed.SubItems.Add(CStr(drPartUsed("Quantity")))
                    LviPartUsed.SubItems.Add(FormatNumber(CStr(CDbl(CStr(drPartUsed("UnitPrice"))) * CInt(CStr(drPartUsed("Quantity"))))))
                    LvwPartsUsed.Items.Add(LviPartUsed)
                Next
            End Using
    
            LvwJobsPerformed.Items.Clear()
    
            Using cntCPAR As SqlConnection = New SqlConnection("Data Source=" & strServerName & ";" &
                             "Database='CollegeParkAutoRepair1';" &
                             "Integrated Security=Yes")
                Dim cmdCPAR As SqlCommand =
                        New SqlCommand("SELECT ALL * " &
                                       "FROM Repairs.JobsPerformed " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
    
                Dim sdaJobsPerformed As SqlDataAdapter = New SqlDataAdapter
                Dim dsJobsPerformed As DataSet = New DataSet("JobsPerformed")
    
                cntCPAR.Open()
                sdaJobsPerformed.SelectCommand = cmdCPAR
                sdaJobsPerformed.Fill(dsJobsPerformed)
    
                For Each drJobPerformed As DataRow In dsJobsPerformed.Tables(0).Rows
                    Dim LviJobPerformed As ListViewItem = New ListViewItem(CStr(drJobPerformed("JobPerformed")))
                    LviJobPerformed.SubItems.Add(FormatNumber(CStr(drJobPerformed("JobPrice"))))
                    LvwJobsPerformed.Items.Add(LviJobPerformed)
                Next
            End Using
    
            CalculateRepairOrder()
    
        End Sub
    End Class
    
    
  7. In the Object combo box, select BtnAddPart
  8. In the Procedure combo box, select Click
  9. Implement the event as follows:
    Private Sub BtnAddPart_Click(sender As System.Object,
                                 e As System.EventArgs) Handles BtnAddPart.Click
            If String.IsNullOrEmpty(TxtPartName.Text) Then
                Exit Sub
            End If
    
            Dim LviPart As New ListViewItem(TxtPartName.Text)
    
            LviPart.SubItems.Add(FormatNumber(TxtUnitPrice.Text))
            LviPart.SubItems.Add(TxtQuantity.Text)
            LviPart.SubItems.Add(FormatNumber(TxtSubTotal.Text))
            LvwPartsUsed.Items.Add(LviPart)
    
            TxtPartName.Text = ""
            TxtUnitPrice.Text = "0.00"
            TxtQuantity.Text = "0"
            TxtSubTotal.Text = "0.00"
            CalculateRepairOrder()
    End Sub
    
    
  10. In the Object combo box, select BtnAddJob
  11. In the Procedure combo box, select Click
  12. Implement the event as follows:
    Private Sub BtnAddJob_Click(sender As System.Object,
                                e As System.EventArgs) Handles BtnAddJob.Click
            If String.IsNullOrEmpty(TxtJobPerformed.Text) Then
                Exit Sub
            End If
    
            Dim LviJob As New ListViewItem(TxtJobPerformed.Text)
    
            LviJob.SubItems.Add(FormatNumber(TxtJobCost.Text))
            LvwJobsPerformed.Items.Add(LviJob)
    
            TxtJobPerformed.Text = ""
            TxtJobCost.Text = "0.00"
            CalculateRepairOrder()
    End Sub
  13. In the Object combo box, select LvwPartsUsed
  14. In the Procedure combo box, select DoubleClick
  15. Implement the event as follows:
    Private Sub LvwPartsUsed_DoubleClick(sender As Object,
                             e As System.EventArgs) Handles LvwPartsUsed.DoubleClick
        ' This code acts if the user double-clicks an item in the list of parts used.
        ' We conclude that either the user wants to edit the part
        ' or the user wants to delete the part that was added by mistake
        Dim LviPartUsed As ListViewItem = LvwPartsUsed.SelectedItems(0)
    
        TxtPartName.Text = LviPartUsed.SubItems(0).Text
        TxtUnitPrice.Text = LviPartUsed.SubItems(1).Text
        TxtQuantity.Text = LviPartUsed.SubItems(2).Text
        TxtSubTotal.Text = LviPartUsed.SubItems(3).Text
    
        ' Remove the selected item from the list view
        LviPartUsed.Remove()
    End Sub
  16. In the Object combo box, select LvwJobsPerformed
  17. In the Procedure combo box, select Double-Click
  18. Implement the event as follows
    Private Sub LvwJobsPerformed_DoubleClick(sender As Object,
                      e As System.EventArgs) Handles LvwJobsPerformed.DoubleClick
            ' This code acts if the user double-clicks a job
            ' from the list of jobs performed.
            ' We conclude that either the user wants to edit the job
            ' or the user wants to remove/cancel the job
            Dim LviJobPerformed As ListViewItem = LvwJobsPerformed.SelectedItems(0)
    
            TxtJobPerformed.Text = LviJobPerformed.SubItems(0).Text
            TxtJobCost.Text = LviJobPerformed.SubItems(1).Text
    
            ' Remove the selected job from the list view
            LviJobPerformed.Remove()
    End Sub
  19. In the Object combo box, select BtnSubmit
  20. In the Procedure combo box, select Click
  21. Implement the event as follows:
     
    Private Sub BtnSubmit_Click(sender As System.Object, e As System.EventArgs) Handles BtnSubmit.Click
            Dim LviJob As ListViewItem
            Dim LviPart As ListViewItem
            Dim strServerName As String = "EXPRESSION"
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("UPDATE Repairs.Orders " &
                                       "SET DateReceived = N'" & DtpDateReceived.Value.ToShortDateString() & "', " &
                                       "    TimeReceived = N'" & DtpTimeReceived.Value.ToShortTimeString() & "', " &
                                       "    DateCompleted = N'" & DtpDateCompleted.Value.ToShortDateString() & "', " &
                                       "    TimeCompleted = N'" & DtpTimeCompleted.Value.ToShortTimeString & "', " &
                                       "    DatePickedUp = N'" & DtpDatePickedUp.Value.ToShortDateString() & "', " &
                                       "    TimePickedUp = N'" & DtpTimePickedUp.Value.ToShortTimeString() & "', " &
                                       "    CustomerName = N'" & TxtCustomerName.Text & "', " &
                                       "    Address = N'" & TxtAddress.Text & "', " &
                                       "    City = N'" & TxtCity.Text & "', " &
                                       "    State = N'" & TxtState.Text & "', " &
                                       "    ZIPCode = N'" & TxtZIPCode.Text & "', " &
                                       "    Make = N'" & TxtMake.Text & "', " &
                                       "    Model = N'" & TxtModel.Text & "', " &
                                       "    CarYear = " & CInt(TxtCarYear.Text) & ", " &
                                       "    ProblemDescription = N'" & TxtProblemDescription.Text & "', " &
                                       "    TaxRate = " & CDbl(TxtTaxRate.Text) & ", " &
                                       "    Recommendations = N'" & TxtRecommendations.Text & "' " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
    
            Using cntCPAR As SqlConnection =
                New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("DELETE Repairs.PartsUsed " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            If LvwPartsUsed.Items.Count > 0 Then
                For Each LviPart In LvwPartsUsed.Items
                    Using cntCPAR As SqlConnection =
                        New SqlConnection("Data Source=" & strServerName & ";" &
                                          "Database='CollegeParkAutoRepair1';" &
                                          "Integrated Security=Yes")
                        Dim cmdCeilInn As SqlCommand =
                                New SqlCommand("INSERT INTO Repairs.PartsUsed" &
                                               "(ReceiptNumber, PartName, UnitPrice, Quantity) " &
                                               "VALUES(" & CInt(TxtReceiptNumber.Text) & ", N'" &
                                               LviPart.SubItems(0).Text & "', " & CDbl(LviPart.SubItems(1).Text) &
                                               ", " & CInt(LviPart.SubItems(2).Text) & ");",
                                               cntCPAR)
                        cntCPAR.Open()
                        cmdCeilInn.ExecuteNonQuery()
                    End Using
                Next
            End If
    
            Using cntCPAR As SqlConnection =
                        New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                Dim cmdCeilInn As SqlCommand =
                        New SqlCommand("DELETE Repairs.JobsPerformed " &
                                       "WHERE ReceiptNumber = " & CInt(TxtReceiptNumber.Text) & ";",
                                       cntCPAR)
                cntCPAR.Open()
                cmdCeilInn.ExecuteNonQuery()
            End Using
    
            If LvwJobsPerformed.Items.Count > 0 Then
                For Each LviJob In LvwJobsPerformed.Items
                    Using cntCPAR As SqlConnection =
                        New SqlConnection("Data Source=" & strServerName & ";" &
                                  "Database='CollegeParkAutoRepair1';" &
                                  "Integrated Security=Yes")
                        Dim cmdCeilInn As SqlCommand =
                                New SqlCommand("INSERT INTO Repairs.JobsPerformed" &
                                               "(ReceiptNumber, JobPerformed, JobPrice) " &
                                               "VALUES(" & CInt(TxtReceiptNumber.Text) & ", N'" &
                                               LviJob.SubItems(0).Text & "', N'" &
                                               LviJob.SubItems(1).Text & "');",
                                               cntCPAR)
                        cntCPAR.Open()
                        cmdCeilInn.ExecuteNonQuery()
                    End Using
                Next
            End If
    
            MsgBox("The repair order has been updated.",
                   MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
                   "College Park Auto Repair")
            ResetRepairOrder()
    End Sub
    
    
  22. In the Object combo box, select BtnClose
  23. In the Procedure combo boxl select Click
  24. Implement the event as follows:
    Private Sub BtnClose_Click(sender As Object,
                               e As System.EventArgs) Handles BtnClose.Click
            Close()
    End Sub
  25. Access the main form
  26. Design it as follows:
     
    College Park Auto Repair - Switchboard
    Control (Name) Text
    Button Button btnNewRepairOrder New Repair Order...
    Button Button btnUpdateRepairOrder Update Repair Order...
    Button Button btnClose Close
  27. Double-click the New Repair button
  28. In the Procedure combo box, select Click
  29. Implement its event as follows:
    Private Sub CollegeParkAutoRepair_Load(sender As System.Object,
                                     e As System.EventArgs) Handles MyBase.Load
           ' CreateJobsPerformed()
    End Sub
    
    Private Sub BtnNewRepairOrder_Click(sender As System.Object,
                          e As System.EventArgs) Handles BtnNewRepairOrder.Click
            Dim Nro As NewRepairOrder
    
            Nro = New NewRepairOrder
            Nro.ShowDialog()
    End Sub
  30. In the Object combo box, select BtnUpdateRepairOrder
  31. Im the Procedure combo box, select Click
  32. Implement their event as follows:
    Private Sub BtnUpdateRepairOrder_Click(sender As Object,
                        e As System.EventArgs) Handles BtnUpdateRepairOrder.Click
            Dim Uro As UpdateRepairOrder
    
            Uro = New UpdateRepairOrder
            Uro.ShowDialog()
    End Sub
  33. In the Object combo box, select BtnClose
  34. In the Procedure combo box, select Click
  35. Implement the event as follows:
    Private Sub BtnClose_Click(sender As Object, 
    	e As System.EventArgs) Handles BtnClose.Click
            Close()
    End Sub
  36. Execute the application
  37. Click the New Repair Order button Create a repair order:
     
    College Park Auto Repair - New Repair Order
  38. Click Submit
  39. Create another repair order
     
    College Park Auto Repair - New Repair Order
  40. Click Submit
  41. Close the forms
  42. Execute the application again
  43. Update an existing repair
  44. Change some values in the record. Here is an example:
     
    College Park Auto Repair - New Repair Order
  45. Close the forms
 
 
     
 

Home Copyright © 2012 FunctionX Home