Hello everyone,

I have this assignment that I dont understand. It is a very long assignment I think.
I don't want any code or something like that. I need to understand what i am suppose to do then I have to start thinking about codes. Now you may say just ask your teacher. The problem is It is the weekend and i want to get started on this assignment and I think next week I might miss couple days so that is why I decided to put it here so I can understand just a little what I am suppose to do.

And sorry for the title, it should be seat reservation.

Here is the assignment:

A,local high school needs a reservation application to keep track of seats that are reserved for the school plays scheduled throughout the year.

[B]Main Form — frmReservation
A menustrip control will be needed to have a menu title of File that contain the following menu items" Open, Save, Exit
[/B]

[B]File/Open menu item:[/B]
Check to see if the following disk file exists within the BIN\Debug folder — ReservedSeats.dat
If the file does not exist inform the user that a reservation file is not available to open. If the file exists then the disk file will be opened and the following tasks will have to occur:
1. Read through the entire disk file and load a one dimensional array that has been defined as the following structure...
Structure ReservationStruc
Public Name as string
Public Phone as string
Public DateReserved as date
End structure.
2. Set up the logic so subscript 1 of the array matches to seat number 1, subscript 2 of the array to seat number 2, etc...
3. If a seat is reserved the background color of the label should be yellow. A procedure has been coded for you to use to accomplish this task.

[B]File/Save menu item:[/B] The entries in the array used to keep track of the current session's seating should be written to the ReservedSeats.dat file (DO NOT APPEND IT, overwrite it) ONLY IF the Name array element is not empty.

[B]Two formats can be used to save the disk file:[/B]

[U]The format of the [B]fixed width[/B] disk file is: [/U]
Seat— 2 characters
Name — 30 characters
Phone — 15 characters
Date Reserved — 10 characters
NewLine character — 2 characters

[U]The format of the[B] variable length[/B] disk file is:[/U]
Seat, Name, Phone ,Date Reserved, NewLine characters

[B]Double-Clicking a Seat :[/B] If the seat has already been assigned then the reserved information should be displayed within the Seat Reservation form when loaded.

Seat Assignment Form - frmSeat

[B][U]Save Button:[/U][/B] All fields are required, therefore, make sure the input data is valid. If the data is good then make sure the correct array element is updated and then close the form. The reserved seat's background must be changed to yellow.

[U][B]Remove Button:[/B][/U] When clicked it should remove the person from the array that is defined as the Classroom structure by setting the name and phone members to an empty string. The background color of the seat should be white since it is not reserved anymore.

The teacher designed the two forms for me. I attached 2 snapshot for the forms.

And again I just need to understand how the should the program works.

Thank you guys

Regards

>>Check to see if the following disk file exists within the BIN\Debug folder — ReservedSeats.dat
Hope this helps to get you started. :)

Imports System.IO
Public Class Form1
    Private myCoolDATfile As String = Application.StartupPath & "\ReservedSeats.dat"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If File.Exists(myCoolDATfile) Then
            MsgBox("File.Exists")
        Else
            MsgBox("Sux for you?")
        End If
    End Sub
End Class

Public Class frmClassroom

Private Sub frmClassroom_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing

    'If DirtyData is True ask Yes/No question if student wishes to end application

    If (seats = True) Then
        If MessageBox.Show("Do you want close before saving?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Information) =
            Windows.Forms.DialogResult.OK Then
            Me.Close()
        Else
            e.Cancel = True

        End If


    End If


End Sub

Private Sub Assign_Seat(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSeat1.Click, lblSeat10.Click, lblSeat11.Click, lblSeat12.Click, lblSeat13.Click, lblSeat14.Click, lblSeat15.Click, _
lblSeat16.Click, lblSeat17.Click, lblSeat18.Click, lblSeat19.Click, lblSeat2.Click, lblSeat20.Click, lblSeat21.Click, lblSeat22.Click, lblSeat23.Click, lblSeat24.Click, lblSeat25.Click, lblSeat26.Click, lblSeat27.Click, lblSeat28.Click, lblSeat29.Click, _
lblSeat3.Click, lblSeat30.Click, lblSeat31.Click, lblSeat32.Click, lblSeat33.Click, lblSeat34.Click, lblSeat35.Click, lblSeat36.Click, lblSeat4.Click, lblSeat5.Click, lblSeat6.Click, lblSeat7.Click, lblSeat8.Click, lblSeat9.Click

    'Declare a variable as a Label
    Dim lblSelected As Label

    'Assign variable to Label control that was clicked
    lblSelected = sender

    'Create an instance of Assign Seat Form
    Dim frmSeat As New frmAssignSeat

    'Load controls on Assigned Seat Form with student information from Array

    intSeat = sender.TabIndex

    frmSeat.lblSeat.Text = intSeat
    frmSeat.txtFirst.Text = g_Classroom(intSeat).strFirstName
    frmSeat.txtLast.Text = g_Classroom(intSeat).strLastName
    frmSeat.GroupBox1.Text = g_Classroom(intSeat).strGender
    frmSeat.mtxtHomePhone.Text = g_Classroom(intSeat).mstrPhone

    'Display Assign Seat Form using ShowDialog method
    frmSeat.ShowDialog()

    'Call Display Name In Seat procedure passing in the correct arguments
    Display_Name_In_Seat(intSeat, frmSeat.txtFirst.Text, frmSeat.txtLast.Text)
End Sub


Private Sub tbnFileOpen_Click(sender As Object, e As EventArgs) Handles tbnFileOpen.Click

    'Open the disk file (StudentAssignment.dat) if it exists, if not create a new disk file and display a message to user about new file
    Dim inFile As IO.StreamReader


    If IO.File.Exists("StudentAssignment.dat") = False Then
        MessageBox.Show("Can't find the StudentAssignment.dat file and I will create one for you", "Seat Assigment", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Dim outFile As IO.StreamWriter
        outFile = IO.File.CreateText("StudentAssignment.dat")
        outFile.Close()

        'If file exists Read through the disk file and load the Seating array with the student information and display the
        'name of the student within the seat making sure the first name appears over the last name
    ElseIf IO.File.Exists("StudentAssignment.dat") = True Then
        inFile = IO.File.OpenText("StudentAssignment.dat")

        Do Until inFile.Peek = -1
            Dim strLine As String = inFile.ReadLine
            intSeat = strLine.Substring(0, 2).Trim
            g_Classroom(intSeat).strFirstName = strLine.Substring(2, 20).Trim
            g_Classroom(intSeat).strLastName = strLine.Substring(22, 20).Trim
            g_Classroom(intSeat).strGender = strLine.Substring(42, 1).Trim
            g_Classroom(intSeat).mstrPhone = strLine.Substring(43, 10).Trim

            Display_Name_In_Seat(intSeat, g_Classroom(intSeat).strFirstName, g_Classroom(intSeat).strLastName)
        Loop


        inFile.Close()


    End If



    'Disable File Open menu item
    tbnFileOpen.Enabled = False 
End Sub
Private Sub Display_Name_In_Seat(intSeat As Integer, FirstName As String, LastName As String)

    Dim FormCtrl As Control

    For Each FormCtrl In Me.Controls

        If FormCtrl.TabIndex = intSeat Then

            FormCtrl.Text = FirstName & ControlChars.CrLf & LastName
            Exit For

        End If

    Next


End Sub

Private Sub tbnExit_Click(sender As Object, e As EventArgs) Handles tbnExit.Click
    Me.Close()
End Sub

Private Sub tbnSave_Click(sender As Object, e As EventArgs) Handles tbnSave.Click
    'Open the Disk File (StudentAssignment.dat) for OUTPUT (not Append)
    If IO.File.Exists("StudentAssigment.dat") = False Then
        Dim outFile As IO.StreamWriter
        outFile = IO.File.CreateText("StudentAssignment.dat")



        For intCount As Integer = 1 To 36
            If g_Classroom(intCount).strFirstName = String.Empty Then
                'do nothing
            Else
                strInfo = (intCount.ToString.PadRight(2) & g_Classroom(intCount).strFirstName.PadRight(20) & g_Classroom(intCount).strLastName.PadRight(20) &
                g_Classroom(intCount).strGender.PadRight(1) & g_Classroom(intCount).mstrPhone.PadRight(10))

                outFile.WriteLine(strInfo)
            End If


        Next
        outFile.Close()
    End If



    'Loop through each array element
    '         If first name is not empty then 
    '               Assign string varible strOutput to Seat #, First Name, Last Name, Gender, Phone Number and CRLF characters
    '               write strOutput to disk file
    'End Loop



    'Close Disk File
    'Assign DirtyData boolean to false

    seats = False

End Sub

End Class

Public Class frmAssignSeat

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
    'Validate data first
    If (txtFirst.Text.Trim.Length < 0 OrElse txtFirst.Text.Trim.Length >= 20) Then
        MessageBox.Show("Please revise the first name, it is over 20 charaters!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)
    ElseIf (txtLast.Text.Trim.Length < 0 OrElse txtLast.Text.Trim.Length >= 20) Then
        MessageBox.Show("Please revise the last name, it is over 20 charaters!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)
    ElseIf (radfemale.Checked = False And radMale.Checked = False) Then
        MessageBox.Show("Please choose the gender!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
    ElseIf (mtxtHomePhone.Text.Trim.Length > 10) Then
        MessageBox.Show("Please the phone number, it is over 10 charaters!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)
        'If data is good enter student information into array element
    Else
        Dim intCount As Integer

        intCount = lblSeat.Text
        g_Classroom(intCount).strFirstName = txtFirst.Text
        g_Classroom(intCount).strLastName = txtLast.Text
        If radfemale.Checked Then
            g_Classroom(intCount).strGender = "f"
        Else
            g_Classroom(intCount).strGender = "m"
        End If
        g_Classroom(intCount).mstrPhone = mtxtHomePhone.Text

        If Data_Validated_OK() Then
            Me.Close()
        End If
    End If
    'Assign DirtyData to True
    seats = True
End Sub

Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
    'Clear member variables of array element

    Dim intCount As Integer
    intCount = lblSeat.Text
    txtFirst.Text = String.Empty
    txtLast.Text = String.Empty
    radfemale.Checked = False
    radMale.Checked = False
    mtxtHomePhone.Text = "___-_______"

    g_Classroom(intCount).strFirstName = String.Empty
    g_Classroom(intCount).strLastName = String.Empty
    g_Classroom(intCount).strGender = String.Empty
    g_Classroom(intCount).mstrPhone = "___-_______"

    'Assign DirtyData boolean to True
    seats = True
End Sub

Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click

    txtFirst.Text = String.Empty
    txtLast.Text = String.Empty
    Me.Close()
End Sub

Private Function Data_Validated_OK() As Boolean

    If txtFirst.Text.Trim = String.Empty Then
        'Display error, set focus to control, return false
        MessageBox.Show("Please enter First Name!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Return False

    End If
    If txtLast.Text.Trim = String.Empty Then
        'Display error, set focus to control, return false
        MessageBox.Show("Please enter Last Name!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Return False
    End If
    If radMale.Checked = False And radfemale.Checked = False Then
        'display error, set focus to group box control, return false
        MessageBox.Show("Please select the gender!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Return False
    End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.