AS level computing project

Page 1

Naina Raisinghani FY-R


Page |2

Table of Contents

Number 1 2 3 4 5

Naina Raisinghani

Content Problem Identification Program Design Program development Testing Implementation

Karachi Grammar School

Page 3 5 12 26 43

PK 500


Page |3

Naina Raisinghani

Karachi Grammar School

PK 500


Page |4

PROBLEM IDENTIFICATION: I work at a screening theater. The theater maintains no record of tickets sold, due to which the seats at the theater are usually over-booked. Due to this we usually have to refund money to those who aren’t able to be seated even though they have purchased a ticket. This causes great confusion when it is time to make the accounts at the end of a financial year. This has also led to a decrease in the theater’s reputation and fewer sales. This system will help the managers of theater keep track of ticket sales and ensure no over-booking of seats by computerizing the inefficient manual system. Also being a new employee at the theater I am not well informed about the movies that are being screened. Therefore I need a log that will provide me upon search with the details of the film so that I may deal with any customers’ queries knowledgably.

INPUT DATA: 1. 2. 3. 4. 5. 6. 7. 8.

Movie ID code: Holds the ID code of the movie, used for easy reference. Movie’s name: Holds the movie’s name Genre: Describes what genre the movie belongs to Director’s name: Holds the name of the director of the movie Rating: Shows what rating has been prescribed to the movie by the censor boards Cast Details: Name of the cast of the movie Movie screening date: Date the movie is being screened on Tickets already sold: number of tickets that have been sold already.

OUTPUT DATA: 1. 2. 3. 4. 5.

Shows a list of all the movies contained in the log Shows all movies showing on a particular date Displays all movies falling in a certain genre Display al movies that have been awarded a certain rating Display all movies according to the seat availability (e.g. fully booked, less than half of the seats booked, barely booked, etc.)

Naina Raisinghani

Karachi Grammar School

PK 500


Page |5

Naina Raisinghani

Karachi Grammar School

PK 500


Page |6

PROGRAM DESIGN: Design a program in Visual Basic which is user friendly and menu based. Here the user will be allowed to add, edit, erase, find and save details about movies, along with being able to perform other basic functions like clear or cancel any ongoing work and quit a menu, or open up another menu. Entry is gained via a log-in screen. The salesperson will be able to issue tickets via this system. The logs will contain details that a person visiting the theater might require to know. Also this new system will ensure that no tickets are sold once the theater’s seating capacity is met, by keeping a track of all transactions, ensuring no over booking. The logs will be saved in a notepad file “project1.txt.” Also print outs of reports can be made according to search by rating, genre, date the movie showing on, seat availability, etc.

RECORDS, FILE, DATA STRUCTURE:

No. 1 2 3 4 5

Field Name m_movieID m_movieName m_Genre m_directorsName m_castDetails

Field size 5 25 25 25 50

Data type Character String String String String

6 7 8

m_Rating m_showingOn m_alreadysold

5 10 3

String Date Integer

Data example 0123 Wanted Comedy Steven Spielberg Tom Hanks, Tim Hallen, Don Rickles, Jim Harney PG 01/02/2008 228

HARDWARE AND SOFTWARE REQUIREMENT: Hardware required: 1. Keyboard/ mouse – to enter data 2. Monitor – to view data 3. Printer – to print out any reports produced 4. CPU/ processor – 800 MHz and above 5. Hard disk – at least 1 GB 6. Memory/ RAM – at least 256 MB 7. CD RW – To make back ups of data that can be kept away from the main system Software required: 1. Windows XP (or any later version) 2. Visual Basic version 6.0 or higher 3. Notepad

Naina Raisinghani

Karachi Grammar School

PK 500


Page |7

MENUS:

Naina Raisinghani

Karachi Grammar School

PK 500


Page |8

Naina Raisinghani

Karachi Grammar School

PK 500


Page |9

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 10

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 11

INPUT DATA FLOW

Data entry Login

Validate

Incorrect

Correct

Display

Movie details

Add Edit Delete Find Save Sell tickets

Naina Raisinghani

Reports

Exit

Display all movies Display all movies showing on a particular date Display all movies showing on a particular date Display all movies by rating Display all movies by seat availability

Karachi Grammar School

PK 500


P a g e | 12

OUTPUT DATA FLOW Display Report screen Yes Input option

Is option to output? Yes Yes Output entire file?

Yes Read file to screen

End

No Input movie name

Search routine to find specific movie

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 13

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 14

frmLogin (Main log-in screen) Option Explicit Public LoginSucceeded As Boolean Private Sub cmdCancel_Click() ‘If the user clicks the command CANCEL the log-in screen is closed’ LoginSucceeded = False Me.Hide End Sub Private Sub cmdOk_Click() ‘checks for correct password and username’ If txtPassword = "admin" And txtUserName = "admin" Then ‘If the password and username fit the parameters the if clause is executed, whereby the log-in screen is hidden and the main menu shown.’ LoginSucceeded = True Me.Hide frmMain.Show Else ‘If the password and the username entered do not fit the parameters then this else clause is carried out and a message box appears informing the user that the entered data is invalid’ MsgBox "Invalid Password, try again!", , "Login" ‘After the message box is removed by the user the following commands will erase the two fields.’ txtUserName.Text = "" txtPassword.Text = "" SendKeys "{Home}+{End}" End If End Sub

frmMain (Main menu) Private Sub cmdDetails_Click() ‘By clicking on this button the user quits the main menu and enters the movie details menu’ Me.Hide frmmovie.Show End Sub Private Sub cmdReports_Click() ‘By clicking on this button the user quits the main menu and enters the reports menu’ Me.Hide frmReports.Show End Sub Private Sub cmdExit_Click() ‘By clicking on this button the user quits the program’ Unload Me End End Sub Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 15

frmmovie (Movie Details menu) ‘Here all the variables are defined with their data type’ Dim m_movieID As String Dim m_movieName, m_Genre, m_castDetails, m_directorsName, m_Rating As String Dim d, m_showingOn As Date Dim X As String Dim cheak, count1, count2, m_alreadysold, tleft As Integer Private Sub Form_Load() ‘When the form is opened initially the Add button is faded (doesn’t work) and the Ok button is not visible to the user’ cmdAdd.Enabled = False cmdOk.Visible = False End Sub Private Sub cmdAdd_Click() ‘Here if the field txtMovieID is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtMovieID = Empty Then MsgBox ("Movie ID field is Empty") txtMovieID.SetFocus Exit Sub End If ‘Here if the field txtMovieName is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtMovieName = Empty Then MsgBox ("Movie name field is Empty") txtMovieName.SetFocus Exit Sub End If ‘Here if the field lstGenre is left without an option chosen and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If lstGenre = Empty Then MsgBox ("No genre has been selected") lstGenre.SetFocus Exit Sub End If ‘Here if the field txtDirectorsName is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtDirectorsName = Empty Then MsgBox ("The director's name has not been entered") txtDirectorsName.SetFocus Exit Sub End If ‘Here if the field txtCastDetails is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtCastDetails = Empty Then MsgBox ("No cast details have been entered") Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 16 txtCastDetails.SetFocus Exit Sub End If ‘Here if the field lstRating is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If lstRating = Empty Then MsgBox ("No rating has been selected") lstRating.SetFocus Exit Sub End If ‘Here if the field txtShowingOn is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtShowingOn = Empty Then MsgBox ("The movie date has not been set") txtShowingOn.SetFocus Exit Sub End If ‘Here if the field txtalreadysold is left empty and the user tries to save a record a message appears informing the user that the field hasn’t been filled in and the cursor is moved to the relevant field’ If txtalreadysold = Empty Then MsgBox ("The number of tickets already sold has not been entered") txtalreadysold.SetFocus Exit Sub End If Open "z:\project1.txt" For Append As #1 ‘Here the program fills the values in the varable fields according to the data filled in the corresponding field’ m_movieID = txtMovieID.Text m_movieName = txtMovieName.Text m_Genre = lstGenre.Text m_directorsName = txtDirectorsName.Text m_castDetails = txtCastDetails.Text m_Rating = lstRating.Text m_showingOn = txtShowingOn.Text m_alreadysold = txtalreadysold.Text ‘Here the program writes the data contained in the variables onto the notepad file’ Write #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, d, m_showingOn, m_alreadysold Close #1 ‘A message appears informing the user that the record has been added’ MsgBox ("The record has been added.") ‘After the record has been added all field in the form are cleared.’ txtMovieID.Text = "" txtMovieName.Text = "" lstGenre.Text = "" txtDirectorsName.Text = "" txtCastDetails.Text = "" lstRating.Text = "" txtShowingOn.Text = "" Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 17 txtalreadysold.Text = "" End Sub Private Sub cmdCancel_Click() ‘Here all the fields are cleared’ txtMovieID.Text = "" txtMovieName.Text = "" lstGenre.Text = "" txtDirectorsName.Text = "" txtCastDetails.Text = "" lstRating.Text = "" txtShowingOn.Text = "" txtalreadysold.Text = "" End Sub Private Sub cmdClear_Click() ‘Here the command CLEAR is called’ Call clear End Sub Private Sub cmdDelete_Click() Close 1 Close 2 ‘Here the program opens the file project1.txt to obtain data from and the file temp1.txt to store data in’ Open "z:\project1.txt" For Input As #1 Open "z:\temp1.txt" For Append As #2 cheak = 0 X = InputBox("Enter the name of the movie that is to deleted:") Do Until EOF(1) ‘Here the program keeps inputing data’ Input #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold If m_movieName = X Then ‘If the movie name entered matches a record then the details of that particular variable are input into the fields and CHEAK is set to 1’ cheak = 1 txtMovieID.Text = m_movieID txtMovieName.Text = m_movieName lstGenre.Text = m_Genre txtDirectorsName.Text = m_directorsName txtCastDetails.Text = m_castDetails lstRating.Text = m_Rating txtShowingOn.Text = m_showingOn txtalreadysold.Text = m_alreadysold ‘Here the user is asked if he wants to delete the record’ a = MsgBox("Are you sure you want to delete this record?", vbYesNo, "Alert!") If a = vbYes Then ‘If option YES is selected, then all fields are cleared’ txtMovieID.Text = "" txtMovieName.Text = "" Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 18 lstGenre.Text = "" txtDirectorsName.Text = "" txtCastDetails.Text = "" lstRating.Text = "" txtShowingOn.Text = "" txtalreadysold.Text = "" End If Else ‘If the user hits the command NO then the same details are written onto temp1.txt’ Write #2, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold End If Loop If cheak = 0 Then ‘If after all records have been searched and yet a match is not found a message box is shown informing the user that a match could not be found’ MsgBox ("The record requested cannot be found.") Close 1, 2 Kill "z:\temp1.txt" Exit Sub End If Close 1, 2 ‘Here the file project1.txt is deleted and temp1.txt is now named as project1.txt’ Kill "z:\project1.txt" Name "z:\temp1.txt" As "z:\project1.txt" End Sub Private Sub cmdEdit_Click() ‘By clicking on the command EDIT the user automatically disables the following commands’ cmdAdd.Enabled = False cmdFind.Enabled = False cmdDelete.Enabled = False cmdClear.Enabled = False Close 1 Close 2 ‘Here the program opens the file project1.txt to obtain data from and the file temp1.txt to store data in’ Open "z:\project1.txt" For Input As #1 Open "z:\temp1.txt" For Append As #2 ‘Here the count is set to 0’ cheak = 0 ‘The user is asked to input the name of the movie which’s details he wants to edit’ X = InputBox("Enter the name of the movie that is to edited:") Do Until EOF(1) ‘To find a match the program keeps obtaining data from project1.txt and comparing it to the search’ Input #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold If m_movieName = X Then ‘Once a match is found the count is set to 1’ cheak = 1 Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 19 ‘Once a match is found the details of the record are filled into the relevant fields’ txtMovieID.Text = m_movieID txtMovieName.Text = m_movieName lstGenre.Text = m_Genre txtDirectorsName.Text = m_directorsName txtCastDetails.Text = m_castDetails lstRating.Text = m_Rating txtShowingOn.Text = m_showingOn txtalreadysold.Text = m_alreadysold Else ‘If a match is not found the same details are written back into the file’ Write #2, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold End If Loop If cheak = 0 Then ‘If even once all records have been checked and no match is found then the following message box appears notifying the user that no match could be found’ MsgBox ("The record requested cannot be found.") End If Close 1, 2 ‘At the end the Save button is enabled while the Add button remains unable to be used’ cmdAdd.Enabled = False cmdSave.Enabled = True End Sub Private Sub cmdSave_Click() Close #1 ‘Here whatever data is filled into the form’s fields is filled into the respective variables as well.’ m_movieID = txtMovieID.Text m_movieName = txtMovieName.Text m_Genre = lstGenre.Text m_directorsName = txtDirectorsName.Text m_castDetails = txtCastDetails.Text m_Rating = lstRating.Text m_showingOn = txtShowingOn.Text m_alreadysold = txtalreadysold.Text ‘Here the file project1.txt is deleted’ Kill "z:\project1.txt" ‘Here the file temp1.txt is renamed project1.txt’ Name "z:\temp1.txt" As "z:\project1.txt" ‘The file project1.txt is opened and changes written onto the file’ Open "z:\project1.txt" For Append As #1 Write #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold Close #1 ‘A message box appears informing the user that any changes have been saved’ MsgBox ("The record has been saved!") ‘The following commands determine whether or not to enable the following buttons’ cmdAdd.Enabled = True Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 20 cmdFind.Enabled = True cmdDelete.Enabled = True cmdEdit.Enabled = True cmdSave.Enabled = False End Sub Private Sub cmdFind_Click() Close #1 ‘Here the file project1.txt is opened to obtain values from’ Open "z:\project1.txt" For Input As #1 ‘Here the user is asked to input the movie name of the record he wishes to find’ X = InputBox("Enter the Name") Do Until EOF(1) ‘Here the data contained in each record is input to see if it matches the search conducted’ Input #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold If m_movieName = X Then ‘If a match is found then the data from the record is written into the respective fields’ txtMovieID.Text = m_movieID txtMovieName.Text = m_movieName lstGenre.Text = m_Genre txtDirectorsName.Text = m_directorsName txtCastDetails.Text = m_castDetails lstRating.Text = m_Rating txtShowingOn.Text = m_showingOn txtalreadysold.Text = m_alreadysold Exit Sub ElseIf EOF(1) Then ‘If no match is found then the following message box appears informing the user of a lack of match’ MsgBox ("Record not found") Exit Sub End If Loop Close #1 End Sub Private Sub cmdQuit_Click() ‘Whereby the user quits the program’ Unload Me End End Sub Private Sub cmdReturnMain_Click() ‘This menu is closed and the main menu is opened’ Me.Hide frmMain.Show End Sub Private Sub cmdSale_Click() Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 21 ‘The following commands determine whether or not to enable the following buttons’ cmdAdd.Enabled = False cmdFind.Enabled = False cmdDelete.Enabled = False cmdClear.Enabled = False cmdOk.Visible = True cmdSale.Visible = False Close 1 Close 2 ‘The file project1.txt is opened and changes written onto the file temp1.txt’ Open "z:\project1.txt" For Input As #1 Open "z:\temp1.txt" For Append As #2 ‘here the count is set to 0’ cheak = 0 ‘The user is asked to input the name of the movie for which a ticket is required’ X = InputBox("Enter the name of the movie:") Do Until EOF(1) ‘To find a match the program keeps obtaining data from project1.txt and comparing it to the search’ Input #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold If m_movieName = X Then ‘Once a match is found the count is set to 1’ cheak = 1 ‘Once a match is found the details of the record are filled into the relevant fields’ txtMovieID.Text = m_movieID txtMovieName.Text = m_movieName lstGenre.Text = m_Genre txtDirectorsName.Text = m_directorsName txtCastDetails.Text = m_castDetails lstRating.Text = m_Rating txtShowingOn.Text = m_showingOn txtalreadysold.Text = m_alreadysold ‘Once a match is found the user is asked for the number of tickets required’ count2 = InputBox("Type in the number of tickets required:") ‘Here the variable count1 is set to have the same value as m_alreadysold’ count1 = m_alreadysold ‘Once the transaction has been carried out the new value of count1 is the number tickets already sold plus the number of tickets just sold’ count1 = count1 + count2 ‘Here any changes made are written onto the file temp1.txt’ Write #2, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold End If Loop If cheak = 0 Then ‘If even once all records have been checked and no match is found then the following message box appears notifying the user that no match could be found’ MsgBox ("The record requested cannot be found.") End If Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 22 Close 1, 2 ‘The following commands determine whether or not to enable the following buttons’ cmdAdd.Enabled = False cmdSave.Enabled = True End Sub Private Sub cmdOk_Click() Close #1 ‘Here whatever data is filled into the form’s fields is filled into the respective variables as well.’ m_movieID = txtMovieID.Text m_movieName = txtMovieName.Text m_Genre = lstGenre.Text m_directorsName = txtDirectorsName.Text m_castDetails = txtCastDetails.Text m_Rating = lstRating.Text m_showingOn = txtShowingOn.Text m_alreadysold = count1 ‘Here the file temp1.txt is renamed project1.txt after the file project1.txt ahs been deleted’ Kill "z:\project1.txt" Name "z:\temp1.txt" As "z:\project1.txt" Open "z:\project1.txt" For Append As #1 ‘Any changes made are saved onto the newly named project1.txt’ Write #1, m_movieID, m_movieName, m_Genre, m_directorsName, m_castDetails, m_Rating, m_showingOn, m_alreadysold Close #1 ‘Here a message box appears informing the user that the transaction has been carried out’ MsgBox ("The sale has been made! Thank you for visiting iMax cinemas!") ‘The following commands determine whether or not to enable the following buttons’ cmdAdd.Enabled = True cmdFind.Enabled = True cmdDelete.Enabled = True cmdEdit.Enabled = True cmdSave.Enabled = False cmdSale.Visible = True cmdOk.Visible = False End Sub Private Sub txtalreadysold_Change() If (Len(txtalreadysold.Text) > 3) Then MsgBox ("Tickets sold can't exceed 3 integers!") txtalreadysold.Text = "" End If End Sub Private Sub txtalreadysold_KeyPress(KeyAscii As Integer) ‘Here the command ensures that only numbers are entered into the field if anything besides numbers is entered the field is erased and the cursor is set to that field’ If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then MsgBox ("Only numbers are allowed in this field") txtalreadysold.Text = Empty Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 23 KeyAscii = 0 txtalreadysold.SetFocus End If End Sub Private Sub txtCastDetails_KeyPress(KeyAscii As Integer) ‘Here the command ensures that only alphabets are entered into the field if anything besides alphabets is entered the field is erased and the cursor is set to that field’ If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then MsgBox ("Only text characters are allowed in this field") txtCastDetails.Text = Empty KeyAscii = 0 txtCastDetails.SetFocus End If End Sub Private Sub txtDirectorsName_KeyPress(KeyAscii As Integer) ‘Here the command ensures that only alphabets are entered into the field if anything besides alphabets is entered the field is erased and the cursor is set to that field’ If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then MsgBox ("Only text characters are allowed in this field") txtDirectorsName.Text = Empty KeyAscii = 0 txtDirectorsName.SetFocus End If End Sub Private Sub txtMovieID_Change() ‘Here the command ADD is only enabled once at least one character has been input into the field MovieID’ If (Len(txtMovieID.Text) > 0) Then cmdAdd.Enabled = True End If End Sub Private Sub txtMovieName_Change() ‘Here the command ADD is only enabled once at least one character has been input into the field MovieName’ If (Len(txtMovieName.Text) > 0) Then cmdAdd.Enabled = True End If End Sub Public Sub clear() ‘here the public function which was called earlier is programmed whereby each field is erased’ Dim a As Control For Each a In Controls If TypeOf a Is TextBox Then a.Text = "" End If Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 24 Next End Sub Private Sub txtSale_KeyPress(KeyAscii As Integer) ‘Here the command ensures that only numbers are entered into the field if anything besides numbers is entered the field is erased and the cursor is set to that field’ If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then MsgBox ("This field can only include numbers.") txtSale.Text = Empty KeyAscii = 0 txtSale.SetFocus End If End Sub Private Sub txtShowingOn_KeyPress(KeyAscii As Integer) ‘Here the command ensures that only numbers and selected symbols are entered into the field if anything besides numbers or the selected symbols is entered the field is erased and the cursor is set to that field’ Dim ch As String ch = Chr$(KeyAscii) If Not ((ch = "-") Or (ch = "/") Or (ch >= "0" And ch <= "9")) Then MsgBox ("Only numbers, - and / are allowed in this field") KeyAscii = 0 End If End Sub

frmReports (Report menu) Private Sub cmdDisplayAll_Click() ‘Displays using DataReport1 all the movies being screened at the theater which are stored in project1.txt’ Load DataReport1 DataReport1.Refresh DataReport1.Show DataEnvironment1.rsCommand1.Close End Sub Private Sub cmdDisplayByDate_Click() Dim required As Date ‘Upon clicking the button DisplayByDate an input box appears asking the user which date he would like to visit the theater on’ required = InputBox("ENTER Date:") If DataEnvironment1.rsCommand1.State Then DataEnvironment1.rsCommand1.Close End If ‘The program then looks through the file project1.txt to see if any record matches this date’ DataEnvironment1.rsCommand1.Open ("SELECT * FROM `project1.txt` WHERE DateShowingOn= #" & required & "#") If DataEnvironment1.rsCommand1.EOF Then

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 25 ‘If no match is found in project1.txt then a message box appears informing the user of the lack of match’ MsgBox "No movies being showed on this date.", vbCritical + vbOKOnly Me.Show Exit Sub End If ‘If a match is found the record is displayed in DataReport1’ Load DataReport1 DataReport1.Refresh DataReport1.Show DataEnvironment1.rsCommand1.Close End Sub Private Sub cmdDisplaybyGenre_Click() Dim required As String ‘Upon clicking the button DisplayByGenre an input box appears asking the user which genre he is looking for’ required = InputBox("ENTER genre:") ‘The program then looks through the file project1.txt to see if any record matches this genre’ DataEnvironment1.rsCommand1.Open ("SELECT * FROM `project1.txt` WHERE MovieGenre= '" & required & "'") If DataEnvironment1.rsCommand1.EOF Then ‘If no match is found in project1.txt then a message box appears informing the user of the lack of match’ MsgBox "We show no movie in this Genre", vbCritical + vbOKOnly Me.Show Exit Sub End If ‘If a match is found the record is displayed in DataReport1’ Load DataReport1 DataReport1.Refresh DataReport1.Show DataEnvironment1.rsCommand1.Close End Sub Private Sub cmdDisplayByRating_Click() Dim required As String ‘Upon clicking the button DisplayByRating an input box appears asking the user which rating he is looking for’ required = InputBox("ENTER Rating:") ‘The program then looks through the file project1.txt to see if any record matches this rating’ DataEnvironment1.rsCommand1.Open ("SELECT * FROM `project1.txt` WHERE MovieRating= '" & required & "'") If DataEnvironment1.rsCommand1.EOF Then ‘If no match is found in project1.txt then a message box appears informing the user of the lack of match’ MsgBox "We show no movies falling under this rating", vbCritical + vbOKOnly Me.Show Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 26 Exit Sub End If ‘If a match is found the record is displayed in DataReport1’ Load DataReport1 DataReport1.Refresh DataReport1.Show DataEnvironment1.rsCommand1.Close End Sub Private Sub cmdReturn_Click() ‘By clicking on this button the user quits the reports menu and is returned to the main menu’ Me.Hide frmMain.Show End Sub Private Sub cmdDisplayBySeats_Click() Dim required2, max_seats, sold As Integer ‘Upon clicking the button DisplayBySeats an input box appears asking the user how many tickets he requires’ required2 = InputBox("ENTER the number of tickets you wish to buy:") ‘Here the theater’s maximum capacity is set to 250’ max_seats = 250 ‘Below the program calculates that according to the number of tickets required how many should have already been sold’ sold = max_seats - required2 ‘Here the program looks for any movie in which the variable TicketsAlreadySold is less than or equal to the variable sold’ DataEnvironment1.rsCommand1.Open ("SELECT * FROM `project1.txt` WHERE TicketsAlreadySold<= " & sold & "") If DataEnvironment1.rsCommand1.EOF Then ‘If no match is found in project1.txt then a message box appears informing the user of the lack of match’ MsgBox "We show no movies with the minimum occupancy you need", vbCritical + vbOKOnly Exit Sub End If ‘If a match is found the record is displayed in DataReport1’ Load DataReport1 DataReport1.Refresh DataReport1.Show DataEnvironment1.rsCommand1.Close End Sub

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 27

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 28

The above screenshot is from when the correct username and password are entered

If the incorrect password and username are entered as seen above the screen on the right appears

A message box appears informing the user that the username and password entered are incorrect

If the correct username and password are entered the main menu appears as seen in the screenshot on the right

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 29

This is the menu where the Movie Details can be entered

This is the message box that appears when the ADD button is clicked. It informs the user that the new record has been added.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 30 The screenshot below is of the notepad file containing the records once the new record has been added

The screen on the left appears when the user clicks the button EDIT. An input box asks the user to enter the name of the movie he/she wants to edit

The screen on the right appears when the user clicks the button SAVE. A message box informs the user that the required changes have been saved.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 31 The screenshot below is of once the changes to the record have been saved.

The screen on the left appears when the button SELL TICKETS is clicked. It asks the user to enter the name of the movie for which he desires to purchase tickets.

Once the user has entered the movie name and clicked OK the following screen appears asking the user to enter the number of tickets he requires.

The user must then click the button Ok on the main movie details menu to carry out the transaction

The screen on the left appears when the user does click the button Ok. It notifies the user that the transaction has been carried out.

The above screen is the notepad file after the transaction has been carried out.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 32

The screen on the left appears when the user clicks on the command button FIND. It is an input box that asks the user to enter the name of the movie they want to find.

This screen appears when the user tries to FIND/ EDIT/ DELETE a record not held in the file.

The screen on the right appears when the user clicks on the command button DELETE. It is an input box that asks the user to enter the name of the movie they want to delete.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 33

The above screen appears once the user enters the name of the movie he wants to delete, it asks the user to confirm his choice by clicking OK.

The above screen is from the notepad where the files are held once the record has been deleted. VAILDATION CHECKS:

The message box on the left appears if the user attempts to enter a number in the text field DIRECTOR’S NAME and CAST DETAILS

The message box on the left appears if the user attempts to enter an alphabet in the field SHOWING ON.

The message box on the left appears if the user attempts to enter an alphabet in the numeric fields NUMBER OF TICKETS WANTED and NUMBER OF TICKETS ALREADY SOLD

The message box on the left appears if the field MOVIE NAME is left empty

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 34

The message box on the left appears if an option from the field GENRE is not selected

The message box on the left appears if the field DIRECTOR’S NAME is left empty

The message box on the left appears if the field CAST DETAILS is left empty

The message box on the left appears if an option from the field RATING is left unselected

The message box on the left appears if the field SHOWING ON is left empty

The message box on the left appears if the field NUMBER OF TICKETS ALREADY SOLD is left empty

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 35

The message on the left appears id the user tries o enter a digit that exceeds 3 digits

The screen on the left appears if the button SEE REPORTS‌ is clicked on the main menu.

The sample on the right is from the report on the left appears if the user clicks on the button DISPLAY ALL MOVIES

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 36

The following screen shot is from when the button DISPLAY ALL MOVIES BY GENRE is clicked. An input box appears asking the user to enter the genre he is looking for.

The report on the left appears as a result of the search the user conducted above.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 37

The following screen shot on the left is from when the button DISPLAY ALL MOVIES BY RATING is clicked. An input box appears asking the user to enter the rating he is looking for.

The report on the left appears as a result of the search the user conducted above.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 38

The following screen shot on the left is from when the button DISPLAY ALL MOVIES BY NUMBER FO SEATS REQUIRED is clicked. An input box appears asking the user to enter the number of tickets he is looking for.

The report on the right appears as a result of the search the user conducted above.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 39

The following screen shot on the left is from when the button DISPLAY ALL MOVIES SHOWING ON A PARTICULAR DATE is clicked. An input box appears asking the user to enter the date he would like to see the movie according to.

The report on the left appears as a result of the search the user conducted above.

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 40

Testing values Log-in Screen (frmLogin) Test No. 1 2 3

4 5

Component tested txtUserName (normal) txtPassword (normal) cmdOK (normal)

Test Data “Admin” “admin” Click on button

cmdCancel (normal) cmdOK (normal)

Click on button after entering username and password are wrong

Expected result Accepts the data as valid Accepts the data as valid If username and password match up then next screen should open up Exits log-in screen Should reject the data as the password and/or the username are incorrect

Actual Result Accepts the data as valid Accepts the data as valid This screen is closed and the main menu opens up Exits log-in screen Rejects the password and user name ad a message box notifying the user of this error appears

Reference page no. 27 27 27

27

Main Menu (frmMain) Test No.

Component tested cmdDetails (normal)

Click on the button

2

cmdReports (normal)

Click on the button

3

cmdExit (normal)

Click on the button

1

Test Data

Expected result Should go to the movie details menu Should go to the reports main menu Should exit the main menu

Actual Result It opens the movie form It opens the reports form It exits the main menu

Reference page no. 28

34

-

Movie Details Menu (frmmovie) Test No.

Component tested

Test Data

1

txtMovieID (normal) txtMovieName

“0002”

2

Naina Raisinghani

“High School

Expected result Accepts the data Accepts the

Karachi Grammar School

Actual Result Accepts the data Accepts the

Reference page no. 28 28 PK 500


P a g e | 41

3 4 5

6

(normal) lstGenre (normal) txtDirectorsName (normal) txtDirectorsName (abnormal)

Musical 2” Click on an option “Kenny Otrega” “5676”

txtCastDetails (normal) txtCastDetails (abnormal)

“Zac Efron”

8

lstRating (normal)

9

txtShowingOn (normal) txtShowingOn (abnormal)

Click on an option “03/06/2001”

7

10

11 12

Txtalreadysold (normal) txtalreadysold (abnormal )

Naina Raisinghani

“12345”

“030a56”

“106” “number”

data Accepts the option Accepts the data Rejects the data, displays message “Only text characters are allowed in this field” and clears the field Accepts the data Rejects the data, displays message “Only text characters are allowed in this field” and clears the field Accepts the option Accepts the data Rejects the data and shows the message “Only numbers, and / are allowed in this field” Accepts the data Rejects the data, displays message “This field can only include numbers” and clears

Karachi Grammar School

data Accepts the option Accepts the data Data rejected, message shown and field cleared

28 28 32

Accepts the data Data rejected, message shown and field cleared

28

Accepts the option Accepts the data Data rejected, message shown and field cleared

28

Accepts the data Data rejected, message shown and field cleared

28

32

28 32

32

PK 500


P a g e | 42

13

txtalreadysold (extreme)

“99999999”

14

cmdAdd (normal)

Click on the button

15

cmdEdit (normal)

Click on the button

16

cmdDelete (normal)

Click on the button

17

cmdFind (normal)

Click on the button

18

cmdClear (normal) cmdSave (normal)

Click on the button Click on the button

cmdQuit (normal) cmdReturnMain (normal) cmdSale

Click on the button Click on the button Click on the button

19

20 21 22

Naina Raisinghani

the field Rejects the data and displays the message “Tickets sold can’t exceed 3 digits!” Adds the record, shows a message Displays an input box asking for the name of the record to be edited Displays an input box asking for7the name of the record to be deleted Displays an input box asking for the name of the record the user wants to find Clears all fields Saves any changes made to the record Stops the program Returns to main menu Displays an input box asking for the movie for which the customer would like to

Karachi Grammar School

Data rejected, message shown and field cleared

34

Adds the record, shows the message Displays an input box asking for the name of the record to be edited Displays an input box asking for the name of the record to be deleted Displays an input box asking for the name of the record to be find

28

Clears all fields Saves any changes made to the record Stops the program Returns to main menu Displays an input box asking for the movie for which the customer would like

-

29

31

31

29

27 30

PK 500


P a g e | 43

23

cmdOk

Click on the button

purchase tickets Message box shows up saying “The sale has been made! Thank you for visiting iMax cinemas!�

to purchase tickets Message box appears

30

Reports Menu (frmReports) Test No.

Component tested

Test Data

1

cmdDisplayAll (normal)

Click on the button

2

cmdDisplayByDate (normal)

Click on the button

3

cmdDisplayByGenre (normal)

Click on the button

4

cmdDisplayByRating (normal)

Click on the button

5

cmdDisplayBySeats (normal)

Click on the button

6

cmdReturn (normal)

Click on the button

Naina Raisinghani

Expected Actual Result result Should Displays a list display a list of all movies of all movies Should Displays all display all movie movies showing on a showing on a particular particular date date Should Should display list of display list of movies falling movies falling under similar under similar Genre Genre Should Displays display list of movie in movies having the having the same rating same rating Should Display list of display list of movies in movies in order of order of numbers of numbers of seats seats available available Should return Returns to to main main menu menu

Karachi Grammar School

Reference page no. 34

38

35

36

37

27

PK 500


P a g e | 44

Naina Raisinghani

Karachi Grammar School

PK 500


P a g e | 45

SOURCE CODE LIST See pages __ to __ under Program Development

SECURITY MEASURES The program is password protected for security. It asks for a username and password upon log in. The set username is “admin” and the set password is “password.” It must be ensured by the user that neither the username nor the password is leaked out. In case the user wants to change the password he/she should follow the following steps: Open the file “mainproject.vbp” Open the coding for frmLogin (the log in form) Change the words highlighted in the following coding to your desired username and password: Private Sub cmdOK_Click() 'check for correct password If txtPassword = "admin" And txtUserName = "admin" Then Press the save button to save changes

BACK UP POLICY Data should be backed up once every week as new films will be up for showing periodically in the theater due to which newer records will be added to the file. To back up the records follow the following procedure: Right click on the notepad file “project1.txt” and click on the option Copy Got to the desired drive where you would like to make a back up of the file Right click anywhere in the explorer window and click on the option paste

HARDWARE AND SOFTWARE REQUIREMENT See page 6 under Program Design

INSTALLATION INSTRUCTIONS Copy the file contents of the CD R (containing tye program) onto your C drive Run a find for the phrase “z:\” and replace it with “c:\” Open the file “mainproject.vbp” and click the play button seen in the top centre Enter the user name (admin) and password (password)

Naina Raisinghani

Karachi Grammar School

PK 500


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.