0% found this document useful (0 votes)
102 views

Application Development Simple

This document describes an application for time tracking. It includes an introduction that discusses the background, system features, and tools used. It then describes the software architecture and provides instructions for using the dashboard, registration, time recording, and daily and weekly report pages. It includes class and flow charts, descriptions of methods and algorithms, and testing procedures. The appendices provide code samples for the dashboard, daily report, and weekly report classes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Application Development Simple

This document describes an application for time tracking. It includes an introduction that discusses the background, system features, and tools used. It then describes the software architecture and provides instructions for using the dashboard, registration, time recording, and daily and weekly report pages. It includes class and flow charts, descriptions of methods and algorithms, and testing procedures. The appendices provide code samples for the dashboard, daily report, and weekly report classes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 124

Application Development

CS6004NI
Coursework 1
Submitted By: Submitted To:

Name : Anjil Shrestha Mr. Dhruba Sen

ID: 16034872 Lecturer, IT Faculty

Group: L3C6

Date: 30th January, 2019


Table of Contents
1. Introduction ........................................................................................................................................... 1
1.1. Background ................................................................................................................................... 1
1.2. About the system........................................................................................................................... 1
1.3. Features ......................................................................................................................................... 1
1.4. Tools used ..................................................................................................................................... 3
2. Software Architecture ........................................................................................................................... 4
3. Detail instruction to run the program .................................................................................................... 5
3.1. Dashboard Page ............................................................................................................................ 5
3.2. Register Page ................................................................................................................................ 6
3.3. Record time page .......................................................................................................................... 7
3.4. Daily Report Page ......................................................................................................................... 8
3.5. Weekly Report Page ..................................................................................................................... 9
3.6. Chart Page ................................................................................................................................... 10
4. Class Diagram ..................................................................................................................................... 11
5. Method Description ............................................................................................................................ 15
5.1. Dashboard ................................................................................................................................... 15
5.2. DailyReport ................................................................................................................................. 18
5.3. WeeklyReport ............................................................................................................................. 19
5.4. Search.......................................................................................................................................... 19
6. Algorithm and flow Chart ................................................................................................................... 21
7. Data structure and Algorithm used ..................................................................................................... 25
8. Testing................................................................................................................................................. 27
9. Reflection on own experience ............................................................................................................. 54
10. References ....................................................................................................................................... 58
11. Appendix ......................................................................................................................................... 59
11.1. Dashboard.cs ........................................................................................................................... 59
11.2. DailyReport.cs......................................................................................................................... 94
11.3. WeeklyReport.cs ................................................................................................................... 105
Table of figures
Figure 1 System Architecture ....................................................................................................................... 4
Figure 2 Dashboard Page User Guide ........................................................................................................... 5
Figure 3 Register Page User Guide ............................................................................................................... 6
Figure 4 Record time Page User Guide ........................................................................................................ 7
Figure 5 Daily report Page User Guide ......................................................................................................... 8
Figure 6 Weekly report Page User Guide ..................................................................................................... 9
Figure 7 Flowchart of weekly report 1.1..................................................................................................... 23
Figure 8 Flowchart of weekly report 1.2..................................................................................................... 24
Figure 9 Test case 1 .................................................................................................................................... 27
Figure 10 Test case 2 .................................................................................................................................. 28
Figure 11 Test case 3.1 ............................................................................................................................... 29
Figure 12 Test case 3.2 ............................................................................................................................... 30
Figure 13 Test case 3.3 ............................................................................................................................... 30
Figure 14 Test case 4.1 ............................................................................................................................... 31
Figure 15 Test case 4.2 ............................................................................................................................... 32
Figure 16 Test case 5.1 ............................................................................................................................... 33
Figure 17 Test case 5.2 ............................................................................................................................... 33
Figure 18 Test case 6.1 ............................................................................................................................... 35
Figure 19 Test case 6.2 ............................................................................................................................... 36
Figure 20 Test case 6.3 ............................................................................................................................... 36
Figure 21 Test case 7.1 ............................................................................................................................... 37
Figure 22 Test case 7.2 ............................................................................................................................... 38
Figure 23 Test case 8 .................................................................................................................................. 39
Figure 24 Test case 9 .................................................................................................................................. 41
Figure 25 Test case 10 ................................................................................................................................ 42
Figure 26 Test case 11 ................................................................................................................................ 44
Figure 27 Test case 12 ................................................................................................................................ 45
Figure 28 Test case 13 ................................................................................................................................ 46
Figure 29 Test case 14 ................................................................................................................................ 47
Figure 30 Test case 15 ................................................................................................................................ 48
Figure 31 Test case 16 ................................................................................................................................ 49
Figure 32Test case 17.1 .............................................................................................................................. 50
Figure 33 Test case 17.2 (successful import and populated in datagridview) ............................................ 51
Figure 34 Test case 17.3 (Visitors CSV) .................................................................................................... 51
Figure 35 Test case 17.4 (Checkin CSV) .................................................................................................... 51
Figure 36 Test case 18.1 ............................................................................................................................. 52
Figure 37 Test case 18.2 ............................................................................................................................. 53
Table of tables
Table 1 CheckINs class diagram ................................................................................................................. 11
Table 2 Visitor class diagram...................................................................................................................... 11
Table 3 Dashboard class diagram ............................................................................................................... 13
Table 4 Daily Report class diagram ............................................................................................................ 14
Table 5 WeeklyReport class diagram ......................................................................................................... 14
Table 6 Search class diagram ...................................................................................................................... 14
Table 7 Method description of dashboard class .......................................................................................... 17
Table 8 Method description of DailyReport class....................................................................................... 18
Table 9 Method description of weeklyreport class ..................................................................................... 19
Table 10 Method description of search class .............................................................................................. 20
Table 11 Data structure table ...................................................................................................................... 25
Table 12 Test case 1 .................................................................................................................................... 27
Table 13 Test case 2 .................................................................................................................................... 28
Table 14 Test case 3 .................................................................................................................................... 29
Table 15 Test case 4 .................................................................................................................................... 31
Table 16 Test case 5 .................................................................................................................................... 33
Table 17 Test case 6 .................................................................................................................................... 35
Table 18 Test case 7 .................................................................................................................................... 37
Table 19 Test case 8 .................................................................................................................................... 39
Table 20 Test case 9 .................................................................................................................................... 40
Table 21 Test case 10 .................................................................................................................................. 42
Table 22 Test case 11 .................................................................................................................................. 43
Table 23 Test case 12 .................................................................................................................................. 45
Table 24 Test case 13 .................................................................................................................................. 46
Table 25 Test case 14 .................................................................................................................................. 47
Table 26 Test case 15 .................................................................................................................................. 48
Table 27 Test case 16 .................................................................................................................................. 49
Table 28 Test case 17 .................................................................................................................................. 50
Table 29 Test case 18 .................................................................................................................................. 52
Application Development

1. Introduction

1.1. Background

The task is to design and implement a C# desktop application that helps a museum to
manage the visitor’s entry record. In order to achieve this, algorithm, flow chart and
class diagram will be designed to completely understand and get insight of system
architecture as a whole. The final artefact of the software will have the requirements
achieved and additional features enhancing system efficiency and user experience.

1.2. About the system

Microsoft .NET Framework is an execution environment which contains reusable class


libraries and language compilers like CLR. The system is built under this framework
using C # programming language. Visual studio is used as an integrated development
environment to develop this desktop-based application utilizing its desktop utilities and
the libraries provided by .Net Framework. The system basically records each visitor’s
entry time and out time on basis of unique card number of each visitor. (Glenn, 2017)

1.3. Features

Main features of the system are listed below:

• Record visitor entry and out time using unique card number of visitors.
• Record new visitor’s detail information’s.
• Verify card number before checking in.
• Import visitors’ details from a CSV file.
• Daily report of total number of visitors with total time duration of all visitors in the
museum.
• Weekly report showing the total of visitor on each day from Monday to Friday.
• Sort feature to sort the weekly report list according to total visitors and total time
duration separately.

1
16034872 | Anjil Shrestha
Application Development

• Chart showing each day’s total time duration that visitors spends in museum for five
working days (Monday to Friday) in minutes.
• Search feature to search visitor’s history of museum visit.

2
16034872 | Anjil Shrestha
Application Development

1.4. Tools used

This system is a user interactive desktop application built using Microsoft .NET
Framework. C# programming language was used to develop this application using
many pre-built libraries of Microsoft .NET Framework. (Glenn, 2017)

Visual studio was used as an integrated development environment to develop this


desktop-based application utilizing its desktop utilities and the libraries provided by
.Net Framework.

3
16034872 | Anjil Shrestha
Application Development

2. Software Architecture

Figure 1 System Architecture

4
16034872 | Anjil Shrestha
Application Development

3. Detail instruction to run the program


3.1. Dashboard Page

Figure 2 Dashboard Page User Guide

1: Register Visitor button that opens register panel.

2: Record Time button that opens page for checking in and checking out.

3: Opens a panel that displays weekly chart.

4: Search area to search visitor visit history by using card number.

5: A timer for current time and current day and date.

6: Total visitor count on current date.

7: Total visitor inside the museum.

8: Report menu item containing sub menu daily report and weekly report.

10: Museum label on click opens the dashboard.

5
16034872 | Anjil Shrestha
Application Development

3.2. Register Page

Figure 3 Register Page User Guide

11: Form area to enter visitor details.

12: Generates unique card number.

13: Registers the visitor and saves the data in visitors CSV file.

6
16034872 | Anjil Shrestha
Application Development

3.3. Record time page

Figure 4 Record time Page User Guide

14: Group box containing visitor details.

15: Group box for checking out a visitor.

16: Group box for importing data from CSV file.

17: Datagridview displaying current date visitors in time and out time.

18: Button to check visitor information.

19: Button to record check in time of visitor.

20: Text field to enter card number for checking out.

21: Button to record checkout time of visitor of particular card number.

22: Button to import CSV file.

23: Text field that shows imported file location.

24: Button that uploads the imported CSV file.

25: Button that record check out time of each row data.

7
16034872 | Anjil Shrestha
Application Development

3.4. Daily Report Page

Figure 5 Daily report Page User Guide

26: Datetime picker for selecting a particular date to populate visitor’s data of that date.

8
16034872 | Anjil Shrestha
Application Development

3.5. Weekly Report Page

Figure 6 Weekly report Page User Guide

27: Datetime picker to select a month.

28: Combo box to pick a week.

29: Button to view result of particular week.

30: Datagridview that populates the total visitors and total time spent of each day of selected week.

31: Button that sorts datagridview in ascending order according to total visitor.

32: Button that sorts datagridview in ascending order according to total duration.

33: Bar graph that populates the data from datagridview.

9
16034872 | Anjil Shrestha
Application Development

3.6. Chart Page

34: Button that populates the weekly chart according to selected month and week number.

10
16034872 | Anjil Shrestha
Application Development

4. Class Diagram

CheckIns
+ card_number : string
+ name : string
+ day : string
+ date : DateTime
+ card_number : string
+ checkIn_time : string
+ checkout_time : string
+ total_time : string

Table 1 CheckINs class diagram

Visitor
+ card_number : string
+ first_name : string
+ last_name : string
+ address : DateTime
+ contact : string
+ email : string
+ gender : string
+ occupation : string

Table 2 Visitor class diagram

11
16034872 | Anjil Shrestha
Application Development

Dashboard
+ vstrs : List <string>
+ ls : List <Visitor>
+ rnd : Random
+ ch : CheckIn
+ chkData : List <string>
+ dt : DataTable
+ lines :string [ ]
+ columnNames : string [ ]
+ vstrs1 : List <string>
+ cards : List <string>
+ rowVal: int

+ Dashboard ( visitors : List <string> )


+ readVisitors ( ) : List <string>
+ readCheckIns( ) : List <string>
+ readVisitors ( ) : List <string>
+ BnDataCSV ( firePath : string ) : void
- button1_Click ( sender : object , e : EventArgs ) : void
- button2_Click ( sender : object , e : EventArgs ) : void
- button3_Click ( sender : object , e : EventArgs ) : void
- button4_Click ( sender : object , e : EventArgs ) : void
- Dashboard_Load ( sender : object , e : EventArgs ) : void
- chkInBtn_Click ( sender : object , e : EventArgs ) : void
- button1_Click ( sender : object , e : EventArgs ) : void
- checkChkIn_Click ( sender : object , e : EventArgs ) : void
- dataGridView1_CellContentClick ( sender : object , e : EventArgs ) : void
- dailyMEnu_Click ( sender : object , e : EventArgs ) : void
- generate_Click ( sender : object , e : EventArgs ) : void
- weeklyMenu_Click ( sender : object , e : EventArgs ) : void
- pictureBox3_Click ( sender : object , e : EventArgs ) : void
- label14_Click ( sender : object , e : EventArgs ) : void
- timer1_Click ( sender : object , e : EventArgs ) : void
+ dashboard_content ( ) : void

12
16034872 | Anjil Shrestha
Application Development

- srchBtn_Click ( sender : object , e : EventArgs ) : void


- importBtn_Click ( sender : object , e : EventArgs ) : void
- ImportBind ( filepath : string ) : void
- uploadBtn_Click ( sender : object , e : EventArgs ) : void
- chartBtn_Click ( sender : object , e : EventArgs ) : void
- button5_Click ( sender : object , e : EventArgs ) : void

Table 3 Dashboard class diagram

13
16034872 | Anjil Shrestha
Application Development

DailyReport
+ DailyReport ( )
- DailyReport_Load ( sender : object , e : EventArgs ) : void
- dateTimePicker1_ValueChanged ( sender : object , e : EventArgs ) : void

Table 4 Daily Report class diagram

WeeklyReport
+ WeeklyReport ( )
- sortA_Click ( sender : object , e : EventArgs ) : void
- sortD_Click ( sender : object , e : EventArgs ) : void
- dateTimePicker1_ValueChanged ( sender : object , e : EventArgs ) : void
- chkInBtn_Click ( sender : object , e : EventArgs ) : void

Table 5 WeeklyReport class diagram

Search
+ Search( infos: List<string>, number: String )

Table 6 Search class diagram

14
16034872 | Anjil Shrestha
Application Development

5. Method Description

5.1. Dashboard

Method Description
public Dashboard(List<string> visitors) Parametrized Constructor method of the
class that receives a generic list of type
string through its parameter. This method
also initializes the form components. This
method invokes the readVisitors( ) and
reacCheckIns ( ) method and adds the
created objects of CheckIn class and
Visitors class to a list respectively.
public static List<string> readVisitors() A static method that reads the CSV
containing existing visitor details adding
each line to a generic list of type string
and returns it.
public static List<string> readCheckIns() A static method that reads the CSV
containing check in and check out details
of visitors adding each line to a generic
list of type string and returns it.
private void BndDataCSV(string filePath) This non-return type method uses linq
querry to extract checkin and check out
data of current date and populates the
datagridview.
private void button1_Click(object sender, Brings the register panel to the current
EventArgs e) screen and disables other panels.
private void button2_Click(object sender, Brings the record panel to the current
EventArgs e) screen and disables other panels.
private void button3_Click_1(object sender, Registers new visitor details to the system
EventArgs e) with automatic generation of unique card
numbers and verifying already registered
visitor.
private void button4_Click(object sender, Checks the visitor detail by using the card
EventArgs e) number and displays the detail if visitor

15
16034872 | Anjil Shrestha
Application Development

details exists and enables the check in


button.
private void Dashboard_Load(object sender, Sets the column for datagridview and
EventArgs e) invokes the BndDataCSV method during
the form loadup.
private void chkInBtn_Click(object sender, This method records the in time of the
EventArgs e) visitor checking if the visitor has already
checked it or not. All the in time record
are stored in a separate csv and is
populated in the datagridview.
private void checkChkIn_Click(object sender, Records the out time of the visitor whose
EventArgs e) card number is written on the text field
and calculates the total minutes spent and
updates the csv file and datagridview.
private void Sets the out time of the visitors whose
dataGridView1_CellContentClick(object row is selected in the data grid view and
sender, DataGridViewCellEventArgs e) updates the csv file and datagridview.
private void dailyMEnu_Click(object sender, Opens the daily report windows form.
EventArgs e)
private void generate_Click(object sender, Generates unique card number for new
EventArgs e) visitor.
private void weeklyMenu_Click(object sender, Opens the weekly report windows form.
EventArgs e)
private void pictureBox3_Click(object sender, Brings the dashboard panel to the current
EventArgs e) screen and disables other panels.
private void label14_Click(object sender, Brings the dashboard panel to the current
EventArgs e) screen and disables other panels.
private void timer1_Tick(object sender, Sets the current time with ticking of each
EventArgs e) second in the dashboard panel.
public void dashBoard_content() Displays current day and date in the
dashboard panel.
private void srchBtn_Click(object sender, Opens the search result windows form
EventArgs e) .and searches the detail museum visit
history of a given card number of visitors.

16
16034872 | Anjil Shrestha
Application Development

private void importBtn_Click(object sender, This method opens a dialog box


EventArgs e) prompting user to select a file a csv file to
import old visitor details.
private void ImportBind(string filepath) Reads the csv containing old visitor
details and sets the visitor details to a
visitor object adding that object to a list
of type Visitor and adds new visitor
details to the system csv.
private void uploadBtn_Click(object sender, Invokes the importBind method
EventArgs e)
private void chartBtn_Click(object sender, Brings the chart panel to the current
EventArgs e) screen and disables other panels.
private void button5_Click(object sender, This method creates a chart showing the
EventArgs e) weekly total visitors count and time spent
inside the museum.
Table 7 Method description of dashboard class

17
16034872 | Anjil Shrestha
Application Development

5.2. DailyReport

Method Description
public DailyReport() Constructor method of the class that
initializes the from components and
populates datagridview with the report of
current date which includes the total time
spent by a visitor, total visitors in the
current day, total time spent by visitors in
a current day and detail check in and
checkout information of visitors visited
in current day.
private void Populates datagridview with the report of
dateTimePicker1_ValueChanged(object sender, selected date from datepicker which
EventArgs e) includes the total time spent by a visitor,
total visitors in the current day, total time
spent by visitors in a current day and
detail check in and checkout information
of visitors visited in current day.
public List<string> checkin() Reads the CSV file containing all check
in and check out information’s of all
visitors and returns the generic list of
type string containing the each lines of
CSV file.
Table 8 Method description of DailyReport class

18
16034872 | Anjil Shrestha
Application Development

5.3. WeeklyReport

Method Description
public WeeklyReport() Constructor method of the class that
initializes the form components.
private void sortA_Click(object sender, Sorts the total visitors data in datagridview
EventArgs e) according to ascending order using bubble
sort algorithm.
public List<string> checkin() Reads the CSV file containing all check in
and check out information’s of all visitors
and returns the generic list of type string
containing the each lines of CSV file.
private void sortD_Click(object sender, Sorts the total time duration data in
EventArgs e) datagridview according to ascending order
using bubble sort algorithm.
private void chkInBtn_Click(object sender, This method populates the datagridview
EventArgs e) with total visitor and total duration of each
visitor from Monday to Friday of the
selected week of the month. This method
also creates a chart showing the weekly
total visitors count and time spent inside the
museum.
Table 9 Method description of weeklyreport class

5.4. Search

Method Description
public Search(List<string> infos,String Parametrized constructor method of the
number) class that receives two data types one being
a generic list of type list and another a string
value. This method initializes the form
components and has a linq query that gets

19
16034872 | Anjil Shrestha
Application Development

all the data of particular card number and


displays in the datagridview.
Table 10 Method description of search class

20
16034872 | Anjil Shrestha
Application Development

6. Algorithm and flow Chart

Algorithm of entire system

Step 1: Start

Step 2: Displays dashboard of the system displaying options to select register visitor, record time,
chart and menu bar for selecting reports (daily and weekly) and help file.

Step 3: If register visitor is selected.

3.1: Display register form to record visitor details.

Step 4: If record time option is selected.

4.1: Displays panel to record check in time and checkout time and also a datagridview
showing the check in and checkout information of current date.

4.2: Import option to open a dialog box prompting user to select a csv file to import
visitors’ details to system.

4.3: Checkout out text box to input card number to checkout particular visitor.

Step 5: If chart option is selected.

5.1: Displays a datetime picker to select a month, a combo box for selecting a week to
plot the total visitors and total time duration in a month (Monday to Friday) in bar
graph.

Step 6: If report is selected.

6.1: Displays two kinds of report i.e. daily report and weekly report to select between.

6.2: If daily report is selected.

6.2.1: Displays a form showing a datetime picker to select a date.

6.2.2: Selecting a date populates multiple datagridview with the total time
spent by a visitor, total visitors in the current day, total time spent by visitors
in a current day and detail check in and checkout information of visitors visited
in current day.

6.3: If weekly report is selected.

6.3.1: A window form to display weekly report is displayed. On selecting the


month and week , the datagridview is populated with total visitor and total

21
16034872 | Anjil Shrestha
Application Development

duration of each visitor from Monday to Friday of the selected week of the
month and also creates a chart showing the weekly total visitors count and time
spent inside the museum.

Step 7 : END

22
16034872 | Anjil Shrestha
Application Development

Flow chart of weekly report

Figure 7 Flowchart of weekly report 1.1

23
16034872 | Anjil Shrestha
Application Development

Figure 8 Flowchart of weekly report 1.2

24
16034872 | Anjil Shrestha
Application Development

7. Data structure and Algorithm used

The data structures used in this system are:

• List <T>: It is one of the collection class of C # programming language which can be
dynamically used for data storage and retrieval. List <T> is a generic collection that contains
elements of specified type. It contains methods for dynamically adding data of specified type
and different other methods to manipulate the data containing in this collection class.
In this system, this collection class is used for storing objects of defined type. The objects of
visitor class and checkIn class is stored in this collection class. The data obtained from reading
the CSV files is also stored in this generic list. (TutorialsTeacher, 2019)

• Array: An array stores a sequential set of elements of the same type in a fixed size. This data
structure has been used in this system to store collection of similar data. It is used frequently
while reading the data from CSV file for storing data of each line of CSV file. (tutorialspoint,
2019)

Date Purpose Implementation


structure Classes
List <T> • To store objects of Visitor class. Dashboard.cs,
• To store objects of CheckIn class. DailyReport.cs,
• To store the data obtained from reading the CSV WeeklyReport.cs,
file of visitor details and check ins data. Search.cs,
• To store the data of the imported file. Program.cs

Array • To store each lines of CSV file while reading it Dashboard.cs,


and later accessing its data using its index DailyReport.cs,
number to populate datagridview and writing in WeeklyReport.cs,
CSV file. Search.cs
Table 11 Data structure table

25
16034872 | Anjil Shrestha
Application Development

Bubble Sort

Bubble Sort is a simple algorithm for sorting. This sorting algorithm is a comparison algorithm that
compares each pair of adjacent elements and swaps the elements if not in order. (TutorialsPoint, 2019)

Algorithm of Bubble sorting

Lets’ assume a list is an array of n elements. Lets further assume that swap function swaps the values
of the given array elements.

begin BubbleSort(list)

for all elements of list

if list[i] > list[i+1]

swap(list[i], list[i+1])

end if

end for

return list

end BubbleSort

(TutorialsPoint, 2019)

This algorithm compares the adjacent items and swaps them if they are in order. The algorithm
compares adjacent items, swapping if not in ascending order until the array is sorted. Being simple to
understand and implement it has some disadvantage as it requires several passes over the data
introducing a major factor of inefficient. (Comscigate, 2006)

This sorting algorithm is used to sort the weekly report according to the number of visitors in a day in
ascending order and all visitor total time duration in a particular day. There are two specified buttons
that does the sorting in ascending order for total visitors and total duration respectively.

26
16034872 | Anjil Shrestha
Application Development

8. Testing

8.1. Test case 1

Test No. 1
Action Run the application.
Expected Result The application should start successfully and
display the application dashboard.
Actual Result Application ran successfully and dashboard
panel was displayed.
Test Result The test was successful.
Table 12 Test case 1

Figure 9 Test case 1

27
16034872 | Anjil Shrestha
Application Development

8.2. Test case 2

Test No. 2
Action Click generate button.
Expected Result Unique card number should be generated.
Actual Result Unique card number was generated.
Test Result The test was successful.
Table 13 Test case 2

Figure 10 Test case 2

28
16034872 | Anjil Shrestha
Application Development

8.3. Test case 3

Test No. 3
Action Register a visitor.
Expected Result Visitor detail should be added successfully.
Actual Result Visitor detail was added successfully.
Test Result The test was successful.
Table 14 Test case 3

Figure 11 Test case 3.1

29
16034872 | Anjil Shrestha
Application Development

Figure 12 Test case 3.2

Figure 13 Test case 3.3

30
16034872 | Anjil Shrestha
Application Development

8.4. Test case 4

Test No. 4
Action Check visitor details according to card
number.
Expected Result The visitor details matching with the card
number should be populated in the panel.
Actual Result The visitor details matching with the card
number was populated in the panel.
Test Result The test was successful.
Table 15 Test case 4

Figure 14 Test case 4.1

31
16034872 | Anjil Shrestha
Application Development

Figure 15 Test case 4.2

32
16034872 | Anjil Shrestha
Application Development

8.5. Test case 5

Test No. 5
Action Check in the selected visitor.
Expected Result The visitor check in time should be recorded
in the CSV and should be populated in the
datagridview.
Actual Result The visitor check in time was recorded in the
CSV and was populated in the datagridview.
Test Result The test was successful.
Table 16 Test case 5

Figure 16 Test case 5.1

Figure 17 Test case 5.2

33
16034872 | Anjil Shrestha
Application Development

34
16034872 | Anjil Shrestha
Application Development

8.6. Test case 6

Test No. 6
Action Check out visitor using the card number.
Expected Result The visitor with the card number should be
checked out successfully populating the data
in datagridview with checked out time and
total duration in minute and should be
written in CSV file.
Actual Result The visitor with the card number was
checked out successfully populating the data
in datagridview with checked out time and
total duration in minute and was written in
CSV file.
Test Result The test was successful.
Table 17 Test case 6

Figure 18 Test case 6.1

35
16034872 | Anjil Shrestha
Application Development

Figure 19 Test case 6.2

Figure 20 Test case 6.3

36
16034872 | Anjil Shrestha
Application Development

8.7. Test case 7

Test No. 7
Action Check out visitor using the button on each
populated row of datagridview.
Expected Result The visitor of
Actual Result The visitor with the card number was
checked in successfully populating the data
in datagridview and was written in CSV file..
Test Result The test was successful.
Table 18 Test case 7

Figure 21 Test case 7.1

37
16034872 | Anjil Shrestha
Application Development

Figure 22 Test case 7.2

38
16034872 | Anjil Shrestha
Application Development

8.8. Test case 8


Test No. 8
Action Click daily report from report menu bar.
Expected Result Total visitors and total duration of the current
date should be populated in the datagridview
along with other detailed visit data of
visitors.
Actual Result Total visitors and total duration of the current
date was populated in the datagridview along
with other detailed visit data of visitors.
Test Result The test was successful.
Table 19 Test case 8

Figure 23 Test case 8

39
16034872 | Anjil Shrestha
Application Development

8.9. Test case 9

Test No. 9
Action Click daily report option from report menu
bar.
Expected Result Total visitors and total duration for the
selected date should be populated in the
datagridview along with other detailed visit
data of visitors.
Actual Result Total visitors and total duration for the
selected date was populated in the
datagridview along with other detailed visit
data of visitors.
Test Result The test was successful.
Table 20 Test case 9

40
16034872 | Anjil Shrestha
Application Development

Figure 24 Test case 9

41
16034872 | Anjil Shrestha
Application Development

8.10. Test case 10

Test No. 10
Action Click weekly report option from report menu
bar.
Expected Result The weekly report window form should be
displayed.
Actual Result The weekly report window form was
displayed successfully.
Test Result The test was successful.
Table 21 Test case 10

Figure 25 Test case 10

42
16034872 | Anjil Shrestha
Application Development

8.11. Test case 11

Test No. 11
Action Select a month from date picker, week from
combo box and press view result button.
Expected Result The weekly report containing the total visitor
and total duration visitors spent in that day
(Monday to Friday) of the particular week of
that month should be populated in the grid
view and should be plotted in the chart.
Actual Result The weekly report containing the total visitor
and total duration visitors spent in that day
(Monday to Friday) of the particular week of
that month was populated in the grid view
and was plotted in the chart.
Test Result The test was successful.
Table 22 Test case 11

43
16034872 | Anjil Shrestha
Application Development

Figure 26 Test case 11

44
16034872 | Anjil Shrestha
Application Development

8.12. Test case 12

Test No. 12
Action Select chart option and select a week of a
month.
Expected Result The bar graph should be plotted indicating
weekly report of total visitors and total time
visitors spent in the museum (Monday to
Friday).
Actual Result The bar graph was plotted indicating weekly
report of total visitors and total time visitors
spent in the museum (Monday to Friday).
Test Result The test was successful.
Table 23 Test case 12

Figure 27 Test case 12

45
16034872 | Anjil Shrestha
Application Development

8.13. Test case 13

Test No. 13
Action Register visitor detail without filling all the
value in the form.
Expected Result Error message should be displayed
informing to fill form correctly.
Actual Result Error message informing to fill form
correctly was displayed.
Test Result The test was successful.
Table 24 Test case 13

Figure 28 Test case 13

46
16034872 | Anjil Shrestha
Application Development

8.14. Test case 14

Test No. 14
Action Input in correct card number or not
registered card number while checking in.
Expected Result Error message should be displayed
informing wrong card number.
Actual Result Error message informing wrong card number
was displayed.
Test Result The test was successful.
Table 25 Test case 14

Figure 29 Test case 14

47
16034872 | Anjil Shrestha
Application Development

8.15. Test case 15

Test No. 15
Action Input card number of visitors who has been
checked in but not checked out yet.
Expected Result Error message should be displayed
informing visitor is currently checked in and
not checked out yet.
Actual Result Error message informing visitor is currently
checked in and not checked out yet was
displayed.
Test Result The test was successful.
Table 26 Test case 15

Figure 30 Test case 15

48
16034872 | Anjil Shrestha
Application Development

8.16. Test case 16

Test No. 16
Action Select import button.
Expected Result A dialog box should be displayed asking to
select a file to import.
Actual Result A dialog box asking to select a file to import
was displayed.
Test Result The test was successful.
Table 27 Test case 16

Figure 31 Test case 16

49
16034872 | Anjil Shrestha
Application Development

8.17. Test case 17

Test No. 17
Action Select upload button.
Expected Result The selected file should be uploaded in the
system and visitor details must be populated
in the datagridview and write in CSV file.
Actual Result The selected file was uploaded in the system
and visitor details must be populated in the
datagridview and write in CSV file.
Test Result The test was successful.
Table 28 Test case 17

Figure 32Test case 17.1

50
16034872 | Anjil Shrestha
Application Development

Figure 33 Test case 17.2 (successful import and populated in datagridview)

Figure 34 Test case 17.3 (Visitors CSV)

Figure 35 Test case 17.4 (Checkin CSV)

51
16034872 | Anjil Shrestha
Application Development

8.18. Test case 18

Test No. 18
Action Enter the card number in search text box and
click search button.
Expected Result All the museum visit history of the visitor
with particular card number should be
displayed in a gridview.
Actual Result All the museum visit history of the visitor
with particular card number was displayed in
a gridview.
Test Result The test was successful.
Table 29 Test case 18

Figure 36 Test case 18.1

52
16034872 | Anjil Shrestha
Application Development

Figure 37 Test case 18.2

53
16034872 | Anjil Shrestha
Application Development

9. Reflection on own experience

Object oriented programming is the growing concept of software development and C # is one of
the object-oriented programming languages. C# is developed by Microsoft and is designed for
Common Language Infrastructure, which consists of the executable code and runtime environment.
Adapting to use of this programming language was not that hard because concept of object-oriented
programming was already made familiar in earlier semester and this being an object-oriented
programming language its core concept was easily understood with teacher guidance and help.

Visual studio was used as an integrated development environment to develop this desktop-
based application utilizing its desktop utilities and the libraries provided by .Net
Framework. (Glenn, 2017)

The task was to develop an application that records each visitor’s entry and exit time and
to generate daily and weekly report. The GUI for this application was designed using the
sublime drag and drop feature of Visual studio. The design of all the panels, window forms
and other component was carried out efficiently due to the availability of graphical
customizable tools for each component. Each designed component code could be accessed
which helped in controlling some features in code level. My work in designing this
application has definitely added many skills in development of desktop application.

The incoming visitor visit data needed to be stored in file so heavy file reading and writing
operations was carried out during this system development. A good object-oriented
programming was practiced because inheritance was implemented, encapsulation was
implemented and objects were created to hold properties of similar type. My knowledge in
OOP has further enhanced due to this practice. Collection class was used to hold objects of
similar type and this collection class with objects was further used to achieve other
operations. This has further developed my skill on working with collection classes and
using different data structures. (Rouse, 2008)

Features of .NET Framework and Visual Studio

• Graphical drag and drop interface

This feature of Visual Studio is very compelling because this feature makes the
development process very quick and helps create robust application with strong back

54
16034872 | Anjil Shrestha
Application Development

end as more time can be spent on backend development rather than focusing on frontend
design.

• Debugging tools
Visual studio has a great debugging tools which has been very helpful during the entire
period of task completion. Runtime error and compile error source point can be easily
traced. Breakpoint can be set in particular methods in order to see if a method is working
correctly and to find the specific line of code that is causing the error.

55
16034872 | Anjil Shrestha
Application Development

• LINQ and Lambda Expressions


LINQ(Language Integrated Query) is a uniform query syntax in C# that retrieves data
from different sources and formats like collections, XML Docs and other databases.
LINQ queries has been implemented to built this system because it easily retrieves
designated data from a collection class. Instead of looping through a list and compare
each data to get a specified result linq query can be used to get a result in a single line
of code. Results are returned as objects and thus has enabled to follow object-oriented
approach. (TutorialsTeacher.com, 2019)
Lambda Expression is shorter way of representing anonymous method that can used
alongside with LINQ queries. Lambda expression gives a advantage over writing a
separate function. This method is very useful for quick searching if data in a collection
of objects. (TutorialsTeacher.com, 2019)
• Chart and datagridview components
Visual studio has an easy way of plotting a data in charts like bar, pie, line etc. Charts
are very useful for visualization and analytics. In visual studio any kind of charts can
be drawn easily and data can be plotted in ease by only specifying a data source.
Datagridview is another fascinating component of C# that stores tata in a tabulated form
and also has features of sorting the data. Visual studio has provided a graphical interface
to implement this component of windows by simple dragging and dropping of this
component.

Problems faced

1. Proper user-friendly UI and UX design.


Solution: References from tutorial videos and online web articles on GUI design and
development.
2. Many errors occurred while reading writing a CSV file.
Solution: Thorough research on online documentation of file input and output methods.
3. Problems during the generation of daily report and most importantly during the extraction
of total time spent by a particular visitor in museum.
Solution: Use of LINQ queries helped in solving the problem. LINQ query implementation
was researched from online documentation and tutorial videos.

56
16034872 | Anjil Shrestha
Application Development

4. Many errors occurred during the generation of weekly report. Separation of week from a
date raised many issues.
Solution: Usage of LINQ queries to group a data of similar property.
5. Plotting of values in the chart took a loot of trial and error implementation.
Solution: Online video tutorials on correctly implementing the chart functions and online
documentations.

57
16034872 | Anjil Shrestha
Application Development

10. References

Comscigate, 2006. Comsicate. [Online]


Available at: http://www.comscigate.com/tutorial/KjellStyle/RakshaVasudevan/Page_2.html
[Accessed 26 January 2019].
Glenn, W., 2017. How-To Geek. [Online]
Available at: https://www.howtogeek.com/253588/what-is-the-microsoft-net-framework-and-why-is-
it-installed-on-my-pc/
[Accessed 25 January 2019].
Rouse, M., 2008. Techtarget.com. [Online]
Available at: https://searchmicroservices.techtarget.com/definition/object-oriented-programming-
OOP
[Accessed 26 January 2019].
tutorialspoint, 2019. tutorialspoint. [Online]
Available at: https://www.tutorialspoint.com/csharp/csharp_arrays.htm
[Accessed 24 January 2019].
TutorialsPoint, 2019. TutorialsPoint. [Online]
Available at: https://www.tutorialspoint.com/data_structures_algorithms/bubble_sort_algorithm.htm
[Accessed 24 January 2019].
TutorialsTeacher.com, 2019. TutorialsTeacher. [Online]
Available at: https://www.tutorialsteacher.com/linq/what-is-linq
[Accessed 5 January 2019].
TutorialsTeacher, 2019. TutorialsTeacher. [Online]
Available at: https://www.tutorialsteacher.com/csharp/csharp-generic-collections
[Accessed 24 January 2019].

58
16034872 | Anjil Shrestha
Application Development

11. Appendix
11.1. Dashboard.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ApplicationDev
{
public partial class Dashboard : Form
{

List<string> vstrs;

List<Visitor> ls = new List<Visitor>(); //list to store Visitor objects


Random rnd = new Random();

List<CheckIn> ch = new List<CheckIn>(); //list to store CheckIN objects

List<string> chkData;
DataTable dt = new DataTable();
string[] lines;
string[] columnNames = { "Card Number", "Name", "Day", "Date", "In time", "Out time", "Total
Duration(Min)" };

59
16034872 | Anjil Shrestha
Application Development

/*
* Method for reading vistor CSV file
* */
public static List<string> readVisitors()
{
List<string> ls = new List<string>();
using (StreamReader sr = new StreamReader("../../../visitors.csv"))
{
string line;

int i = 0;

while ((line = sr.ReadLine()) != null)


{
ls.Add(line);

}
}

return ls;

/*

60
16034872 | Anjil Shrestha
Application Development

* Method for reading checkin CSV file


* */
public static List<string> readCheckIns()
{
List<string> ls = new List<string>();
using (StreamReader sr = new StreamReader("../../../checkins.csv"))
{
string line;

while ((line = sr.ReadLine()) != null)


{

ls.Add(line);

}
}

return ls;

/*
* Constructor class that initizalizes the components
* */

61
16034872 | Anjil Shrestha
Application Development

public Dashboard(List<string> visitors)


{
List<string> vstrs1 = readVisitors();

InitializeComponent();
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
barShow.Visible = false;
weekCombo.Text = "Select Week.";

dashCurrentDay.Text = DateTime.Now.DayOfWeek.ToString();
dashCurrentDate.Text = DateTime.Now.Date.ToShortDateString();

//visitor count---------------
int visitorsCount = 0;
int onChk = 0;

List<string> forCounter = readCheckIns();

var visit = from date in forCounter

where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

List<string> cards = new List<string>();

62
16034872 | Anjil Shrestha
Application Development

foreach (string s in visit)


{
Console.WriteLine("Uniques: " + s);

string vals = s.ToString();


string[] n = vals.Split(',');
cards.Add(n[0]);
Console.WriteLine("n[6]: " + n[5]);
if (n[5] == "")
{
onChk = onChk + 1;
}

dashCheckedIN.Text = onChk.ToString();
var uniq = cards.Distinct();
foreach (var u in uniq)
{
visitorsCount = visitorsCount + 1;

}
visitorsCountLbl.Text = visitorsCount.ToString();

//end---------------------------------

63
16034872 | Anjil Shrestha
Application Development

List<string> checkins1 = readCheckIns();

Console.WriteLine("Counted: " + checkins1.Count);

if (checkins1.Count > 1)
{
foreach (string i in checkins1)
{

string[] values = i.Split(',');

CheckIn checkIn = new CheckIn();

if (values.Count() == 7)
{
checkIn.card_number = values[0];

checkIn.name = values[1];
checkIn.day = values[2];
checkIn.date = DateTime.Parse(values[3]);
checkIn.checkIn_time = values[4];
checkIn.checkOut_time = values[5];
if (values[5] != "")
{
checkIn.total_time = Math.Round(DateTime.Parse(values[5]).Subtract(
DateTime.Parse(values[4])).TotalMinutes).ToString();
}
else
{
checkIn.total_time = "";
}

64
16034872 | Anjil Shrestha
Application Development

ch.Add(checkIn);
}

}
}

foreach (string i in visitors)


{

var values = i.Split(',').ToList();


Visitor visitor = new Visitor();
visitor.card_number = values[0];

visitor.first_name = values[1];
visitor.last_name = values[2];
visitor.address = values[3];
visitor.contact = values[4];
visitor.gender = values[5];
visitor.email = values[6];
visitor.occupation = values[7];
ls.Add(visitor);

65
16034872 | Anjil Shrestha
Application Development

/*
* Method that poplulates the datagridvie when the form loads.
**/
private void BndDataCSV(string filePath)
{

lines = System.IO.File.ReadAllLines(filePath);
if (lines.Length > 0)
{

string firstLine = lines[0];

string[] headerLabels = firstLine.Split(',');


}

List<string> ls = readCheckIns();

var visit = from date in ls

where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

List<string> cards = new List<string>();


foreach (string s in visit)
{
Console.WriteLine("Uniques: " + s);

66
16034872 | Anjil Shrestha
Application Development

string vals = s.ToString();


string[] n = vals.Split(',');
chkData = new List<string>();
DateTime day = new DateTime();
DataRow dr = dt.NewRow();
int columnIndex = 0;
day = DateTime.Now;
chkData.Add(n[0]);
chkData.Add(n[1]);
chkData.Add(n[2]);
chkData.Add(n[3]);
chkData.Add(n[4]);
chkData.Add(n[5]);
chkData.Add(n[6]);
dt.Rows.Add(n[0], n[1], n[2], DateTime.Parse(n[3]).ToShortDateString(), n[4], n[5], n[6]);

}
this.dataGridView1.DataSource = dt;

/*
* Enables register panel.
* */
private void button1_Click(object sender, EventArgs e)
{
this.registerPanel.Visible = true;

67
16034872 | Anjil Shrestha
Application Development

this.recordPanel.Visible = false;
barShow.Visible = true;

this.barShow.Width = button1.Width;
this.barShow.Location = new System.Drawing.Point(519, 125);
this.dashboardPanel.Visible = false;
this.chartPanel.Visible = false;

/*
* Enables record panel.
* */

private void button2_Click(object sender, EventArgs e)


{
this.recordPanel.Visible = true;

barShow.Visible = true;
this.barShow.Location = new System.Drawing.Point(699, 125);
this.barShow.Width = button2.Width;

this.registerPanel.Visible = false;
this.dashboardPanel.Visible = false;
this.chartPanel.Visible = false;

private void button3_Click(object sender, EventArgs e)

68
16034872 | Anjil Shrestha
Application Development

/*
* Register new vistors.
* */
private void button3_Click_1(object sender, EventArgs e)
{
try
{

Visitor existinVisitor = ls.Where(x => x.card_number ==


regCardNumber.Text).FirstOrDefault();
if (existinVisitor != null && existinVisitor.card_number == regCardNumber.Text)
{
MessageBox.Show("Card Number Already taken.","Error!");
}
else if (regCardNumber.Text.Equals("") || firstNameTxt.Text.Equals("") ||
last_nameTxt.Text.Equals("") || occupationTxt.Text.Equals("") || addressText.Text.Equals("") ||
genderTxt.Text.Equals("") )
{
MessageBox.Show("Dont leave empty fields.","Error!");

}
else
{

Visitor visitor = new Visitor();


visitor.card_number = regCardNumber.Text;
visitor.first_name = firstNameTxt.Text.Trim();

69
16034872 | Anjil Shrestha
Application Development

visitor.last_name = last_nameTxt.Text.Trim();
visitor.gender = genderTxt.Text.Trim();
visitor.address = addressText.Text.Trim();
visitor.contact = contactTxt.Text.Trim();
visitor.email = emailTxt.Text.Trim();
visitor.occupation = occupationTxt.Text.Trim();

ls.Add(visitor);
string path = "../../../visitors.csv";

if (!File.Exists(path))
{
File.Create(path);
}
using (StreamWriter writer = new StreamWriter(path, append: true))
{

//Console.WriteLine(i.card_number + i.first_name);
writer.WriteLine(regCardNumber.Text.Trim() + "," + firstNameTxt.Text.Trim() + ","
+ last_nameTxt.Text.Trim() + "," + addressText.Text.Trim() + "," + contactTxt.Text.Trim() + "," +
genderTxt.Text.Trim() + "," + emailTxt.Text.Trim() + "," + occupationTxt.Text.Trim());

regCardNumber.Text = "";
firstNameTxt.Text = "";
addressText.Text = "";
contactTxt.Text = "";
last_nameTxt.Text = "";
emailTxt.Text = "";
occupationTxt.Text = "";
genderTxt.Text = "";
MessageBox.Show("Visitor details added.","Success!");

70
16034872 | Anjil Shrestha
Application Development

}
}

}
catch (Exception e1)
{
Console.WriteLine(e1.Message);
}

}
/*
* Checks wether the card number belongs to visitor or not.
* */
private void button4_Click(object sender, EventArgs e)
{

Visitor existinVisitor = ls.Where(x => x.card_number == cardField.Text).FirstOrDefault();


if (existinVisitor != null && existinVisitor.card_number == cardField.Text)
{
nmField.Text = existinVisitor.first_name+" "+existinVisitor.last_name;
ocField.Text = existinVisitor.occupation;
adField.Text = existinVisitor.address;
emField.Text = existinVisitor.email;
conField.Text = existinVisitor.contact;
gnField.Text = existinVisitor.gender;

71
16034872 | Anjil Shrestha
Application Development

chkInBtn.Enabled = true;

}
else
{

MessageBox.Show("Not found.Register First.");


nmField.Text = "";
cardField.Text = "";
ocField.Text = "";
adField.Text = "";
emField.Text = "";
conField.Text = "";
gnField.Text = "";
chkInBtn.Enabled = false;

}
}

private void Dashboard_Load(object sender, EventArgs e)


{

dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Card Number",typeof(string)),
new DataColumn("Name",typeof(string)),
new DataColumn("Day",typeof(string)),

72
16034872 | Anjil Shrestha
Application Development

new DataColumn("Date",typeof(string)),
new DataColumn("In Time",typeof(string)),
new DataColumn("Out Time",typeof(string)),
new DataColumn("Total Duration(Min)",typeof(string)),

});
BndDataCSV("../../../checkins.csv");
}

/*
* This method records the check in time of visior.
* */
private void chkInBtn_Click(object sender, EventArgs e)
{
List<string> forCounter = readCheckIns();
bool checkedOUt = true;

if (cardField.Text != "" && nmField.Text != "")


{
//-------------------
var checkInCheck = from date in forCounter

where date.Contains(cardField.Text)
select date;

foreach (string s in checkInCheck)


{

73
16034872 | Anjil Shrestha
Application Development

string vals = s.ToString();


string[] n = vals.Split(',');

Console.WriteLine("n[6]: " + n[5]);


if (n[5] == "")
{
checkedOUt = false;
}
}

//---------------
if (checkedOUt)
{
string firstLine = lines[0];

string[] headerLabels = firstLine.Split(',');


chkData = new List<string>();
DateTime day = new DateTime();
DataRow dr = dt.NewRow();
int columnIndex = 0;
day = DateTime.Now;
chkData.Add(cardField.Text);
chkData.Add(nmField.Text);
chkData.Add(day.DayOfWeek.ToString());
chkData.Add(day.Date.ToShortDateString());
chkData.Add(day.ToLongTimeString());
//dt.ToString("dd/MM/yyyy HH:mm:ss");
chkData.Add("");
chkData.Add("");
dt.Rows.Add(chkData[0], chkData[1], chkData[2], chkData[3], chkData[4], chkData[5],
chkData[6]);

74
16034872 | Anjil Shrestha
Application Development

this.dataGridView1.DataSource = dt;

CheckIn checkin = new CheckIn();


checkin.card_number = chkData[0];
checkin.name = chkData[1];
checkin.day = chkData[2];
checkin.date = DateTime.Parse(chkData[3]);
checkin.checkIn_time = chkData[4];
checkin.checkOut_time = chkData[5];
checkin.total_time = chkData[6];

ch.Add(checkin);

foreach (CheckIn chk in ch)


{
Console.WriteLine("Objects: " + chk.card_number);
Console.WriteLine("-----------");
}
string path = "../../../checkins.csv";

if (!File.Exists(path))
{
File.Create(path);

using (StreamWriter writer = new StreamWriter(path, append: false))


{

75
16034872 | Anjil Shrestha
Application Development

foreach (CheckIn c in ch)


{
writer.WriteLine(c.card_number + "," + c.name + "," + c.day + "," + c.date + "," +
c.checkIn_time + "," + c.checkOut_time + "," + c.total_time);
}

}
MessageBox.Show("Checked IN.","Success!");
nmField.Text = "";
cardField.Text = "";
ocField.Text = "";
adField.Text = "";
emField.Text = "";
conField.Text = "";
gnField.Text = "";
chkInBtn.Enabled = false;

}
else {
MessageBox.Show("Already checked in. Check out first!!");
}
}
else
{

MessageBox.Show("Fill all fields.");

76
16034872 | Anjil Shrestha
Application Development

}
}

/*
* THis method performs the checout operation by checking the card number.
* */
private void checkChkIn_Click(object sender, EventArgs e)
{

try
{
string cn = checkCheckInTxt.Text;

foreach (DataGridViewRow row in dataGridView1.Rows)


{

foreach (DataGridViewColumn col in dataGridView1.Columns)


{

if (row != null && col != null)


{
if (dataGridView1.Rows[row.Index].Cells[1].Value.ToString() == cn &&
dataGridView1.Rows[row.Index].Cells[6].Value.ToString() == "" &&
dataGridView1.Rows[row.Index].Cells[col.Index].Value != null &&
dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString() != "")
{
Console.WriteLine("New: " +
dataGridView1.Rows[row.Index].Cells[0].Value.ToString());
dataGridView1.Rows[row.Index].Cells[6].Value =
DateTime.Now.ToLongTimeString();

77
16034872 | Anjil Shrestha
Application Development

cn = "";
checkCheckInTxt.Text = "";
chkData[5] = dataGridView1.Rows[row.Index].Cells[6].Value.ToString();
dataGridView1.Rows[row.Index].Cells[7].Value =
Math.Round(DateTime.Parse(chkData[5]).Subtract(DateTime.Parse(dataGridView1.Rows[row.Index
].Cells[5].Value.ToString())).TotalMinutes);
chkData[6] = dataGridView1.Rows[row.Index].Cells[7].Value.ToString();

foreach (CheckIn c1 in ch)


{
if (c1.checkIn_time ==
dataGridView1.Rows[row.Index].Cells[5].Value.ToString() && c1.card_number ==
dataGridView1.Rows[row.Index].Cells[1].Value.ToString())
{
Console.WriteLine("Found: " + c1.checkIn_time + " " + c1.card_number);
c1.checkOut_time =
dataGridView1.Rows[row.Index].Cells[6].Value.ToString();
c1.total_time = dataGridView1.Rows[row.Index].Cells[7].Value.ToString();
string path = "../../../checkins.csv";

if (!File.Exists(path))
{
File.Create(path);

using (StreamWriter writer = new StreamWriter(path, append: false))


{

foreach (CheckIn c in ch)


{
writer.WriteLine(c.card_number + "," + c.name + "," + c.day + "," +
c.date + "," + c.checkIn_time + "," + c.checkOut_time + "," + c.total_time);

78
16034872 | Anjil Shrestha
Application Development

}
}
break;
}
}
break;

}
}

catch (Exception e1)


{
Console.WriteLine(e1.Message);
}
}
int rowVal;
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
rowVal = e.RowIndex;

Console.WriteLine("Row value: " + rowVal);

79
16034872 | Anjil Shrestha
Application Development

DataGridViewRow chkD = dataGridView1.Rows[rowVal];

if (chkD.Cells[6].Value.ToString() == "" && chkD.Cells[0].Value.ToString()!="") {


chkD.Cells[6].Value = DateTime.Now.ToLongTimeString();
Console.WriteLine("Cel data: " + chkD.Cells[6].Value);
chkData[5] = chkD.Cells[6].Value.ToString();
chkD.Cells[7].Value =
Math.Round(DateTime.Parse(chkData[5]).Subtract(DateTime.Parse(chkD.Cells[5].Value.ToString()))
.TotalMinutes);

chkData[6] = chkD.Cells[7].Value.ToString();
Console.WriteLine("Cell Value of date: " +
DateTime.Parse(chkD.Cells[5].Value.ToString()));

foreach (CheckIn c1 in ch)


{
if (c1.checkIn_time == chkD.Cells[5].Value.ToString() && c1.card_number ==
chkD.Cells[1].Value.ToString())
{
Console.WriteLine("Found: " + c1.checkIn_time + " " + c1.card_number);
c1.checkOut_time = chkD.Cells[6].Value.ToString();
c1.total_time = chkD.Cells[7].Value.ToString();
string path = "../../../checkins.csv";

if (!File.Exists(path))
{
File.Create(path);

using (StreamWriter writer = new StreamWriter(path, append: false))


{

80
16034872 | Anjil Shrestha
Application Development

foreach (CheckIn c in ch)


{
writer.WriteLine(c.card_number + "," + c.name + "," + c.day + "," + c.date +
"," + c.checkIn_time + "," + c.checkOut_time + "," + c.total_time);
}

break;
}
else
{
Console.WriteLine("Not Found: ");
}
}
}

foreach (string s in chkData)


{
Console.WriteLine("LList data: " + s);
}
}
catch (Exception e2) {
Console.WriteLine(e2.Message);
}
}

private void dailyMEnu_Click(object sender, EventArgs e)


{

81
16034872 | Anjil Shrestha
Application Development

DailyReport dr = new DailyReport();


dr.Show();
}

private void generate_Click(object sender, EventArgs e)


{
int cno = rnd.Next(1600000,1699999);
regCardNumber.Text = "MUS"+cno.ToString();

private void weeklyMenu_Click(object sender, EventArgs e)


{
WeeklyReport wr = new WeeklyReport();
wr.Show();
}

private void pictureBox3_Click(object sender, EventArgs e)


{
barShow.Visible = true;

barShow.Width = headerLabel.Width + 50;


this.barShow.Location = new System.Drawing.Point(0,125);
this.dashboardPanel.Visible = true;
this.recordPanel.Visible = false;
this.registerPanel.Visible = false;
this.chartPanel.Visible = false;

private void label14_Click(object sender, EventArgs e)


{

82
16034872 | Anjil Shrestha
Application Development

//visitor count---------------
int visitorsCount = 0;
int totalMin = 0;
int onChk = 0;
List<string> forCounter = readCheckIns();

var visit = from date in forCounter

where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

List<string> cards = new List<string>();


foreach (string s in visit)
{

string vals = s.ToString();


string[] n = vals.Split(',');
cards.Add(n[0]);
Console.WriteLine("n[6]: " + n[5] );
if (n[5]=="")
{
onChk = onChk + 1;
}
}
var uniq = cards.Distinct();
foreach (var u in uniq)
{
visitorsCount = visitorsCount + 1;

83
16034872 | Anjil Shrestha
Application Development

}
visitorsCountLbl.Text = visitorsCount.ToString();
dashCheckedIN.Text = onChk.ToString();

barShow.Visible = true;
barShow.Width = headerLabel.Width+50;
this.barShow.Location = new System.Drawing.Point(0, 125);
this.dashboardPanel.Visible = true;
this.recordPanel.Visible = false;
this.registerPanel.Visible = false;

this.chartPanel.Visible = false;

private void timer1_Tick(object sender, EventArgs e)


{
timerLbl.Text= DateTime.Now.ToLongTimeString();
}

public void dashBoard_content() {


dashCurrentDay.Text = DateTime.Now.DayOfWeek.ToString();
dashCurrentDate.Text = DateTime.Now.Date.ToShortDateString();

84
16034872 | Anjil Shrestha
Application Development

private void srchBtn_Click(object sender, EventArgs e)


{
List<string> forSearch = readCheckIns();

var visit = from visitor in forSearch

where visitor.Contains(searchBox.Text)
select visitor;
if (searchBox.Text.Length==10 && visit.Count() >0)
{

Search search = new Search(forSearch,searchBox.Text);


search.Show();

}
else {
MessageBox.Show("Not found." );
}

private void importBtn_Click(object sender, EventArgs e)


{
importDialog.ShowDialog();
importText.Text = importDialog.FileName;
if (importText.Text!="") {
uploadBtn.Enabled = true;
}

85
16034872 | Anjil Shrestha
Application Development

private void ImportBind(string filepath) {


try
{

List<string> impData = new List<string>();


using (StreamReader sr = new StreamReader(filepath))
{
string line;
while ((line = sr.ReadLine()) != null)
{
impData.Add(line);
}
}
foreach (string s in impData)
{
string[] n = s.Split(',');
//------------visitor add

Visitor existinVisitor = ls.Where(x => x.card_number ==


n[0].ToString()).FirstOrDefault();
if (existinVisitor != null && existinVisitor.card_number == n[0].ToString())
{

}
else
{
Visitor visitor = new Visitor();
visitor.card_number = n[0].ToString();
visitor.first_name = n[1].ToString();
visitor.last_name = n[2].ToString();
visitor.gender = n[3].ToString();

86
16034872 | Anjil Shrestha
Application Development

visitor.address = n[4].ToString();
visitor.contact = n[5].ToString();
visitor.email = n[6].ToString();
visitor.occupation = n[7].ToString();
ls.Add(visitor);
string pathVisitor = "../../../visitors.csv";
if (!File.Exists(pathVisitor))
{
File.Create(pathVisitor);
}
using (StreamWriter writer = new StreamWriter(pathVisitor, append: true))
{

writer.WriteLine(n[0] + "," + n[1] + "," + n[2] + "," + n[3] + "," + n[4] + "," + n[5] +
"," + n[6] + "," + n[7]);
}

}
//-----------checins
string path = "../../../checkins.csv";

if (!File.Exists(path))
{
File.Create(path);

using (StreamWriter writer = new StreamWriter(path, append: true))


{

87
16034872 | Anjil Shrestha
Application Development

writer.WriteLine(n[0] + "," + n[1] + " " + n[2] + "," + n[8] + "," + n[9] + "," + n[10] +
"," + n[11] + "," + n[12]);

}
Console.WriteLine("Each lines Visit: " + n[0] + n[1] + n[2] + n[3] + n[4] + n[5] + n[6] +
n[7]);
Console.WriteLine("Eachlines Checkin " + n[0] + n[1] + n[2] + n[8] + n[9] + n[10] +
n[11] + n[12]);

var visit = from date in impData

where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

List<string> cards = new List<string>();


foreach (string s in visit)
{

string vals = s.ToString();


string[] n = vals.Split(',');

dt.Rows.Add(n[0], n[1] + " " + n[2], n[8], DateTime.Parse(n[9]).ToShortDateString(),


n[10], n[11], n[12]);

}
this.dataGridView1.DataSource = dt;

MessageBox.Show("Imported.","Success!");

88
16034872 | Anjil Shrestha
Application Development

}
catch (Exception e2) {
Console.WriteLine(e2.Message);
}

private void uploadBtn_Click(object sender, EventArgs e)


{
ImportBind(importText.Text);
importText.Clear();
uploadBtn.Enabled = false;
}

private void chartBtn_Click(object sender, EventArgs e)


{
this.chartPanel.Visible = true;

barShow.Visible = true;

this.recordPanel.Visible = false;
this.registerPanel.Visible = false;
this.dashboardPanel.Visible = false;
this.barShow.Location = new System.Drawing.Point(905, 125);
this.barShow.Width = chartBtn.Width;
}

private void button5_Click(object sender, EventArgs e)


{
CultureInfo myCI = new CultureInfo("en-US");

89
16034872 | Anjil Shrestha
Application Development

Calendar myCal = myCI.Calendar;

// Gets the DTFI properties required by GetWeekOfYear.


CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

this.chart1.Series["Total Visitor"].Points.Clear();
this.chart1.Series["Total time"].Points.Clear();

if (weekCombo.Text == "1" || weekCombo.Text == "2" || weekCombo.Text == "3" ||


weekCombo.Text == "4" || weekCombo.Text == "5")
{

List<string> checkWeek = readCheckIns();


string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
for (int i = 0; i < days.Length; i++)
{
int visitors = 0;
int totalMin = 0;
var visit2 = from date in checkWeek
where date.Contains(days[i])
select date;

List<string> cards1 = new List<string>();


foreach (string s in visit2)
{

string vals = s.ToString();


string[] n = vals.Split(',');

90
16034872 | Anjil Shrestha
Application Development

int wno = myCal.GetWeekOfYear(DateTime.Parse(n[3]), myCWR, myFirstDOW);

if (DateTime.Parse(n[3]).Month.ToString() ==
DateTime.Parse(dateTimePicker1.Value.ToString()).Month.ToString() &&
myCal.GetWeekOfYear(DateTime.Parse(n[3]), myCWR, myFirstDOW) ==
Convert.ToInt32(weekCombo.Text))
{
cards1.Add(n[0]);
}
}

var uniq1 = cards1.Distinct();


foreach (var u in uniq1)
{
visitors = visitors + 1;

//minutes
foreach (string t in checkWeek)
{

var values = t.Split(',').ToList();

if (DateTime.Parse(values[3]).Month.ToString() ==
DateTime.Parse(dateTimePicker1.Value.ToString()).Month.ToString() &&
myCal.GetWeekOfYear(DateTime.Parse(values[3]), myCWR, myFirstDOW) ==
Convert.ToInt32(weekCombo.Text))
{

var qTotalTime = from date in values


where date.Contains(days[i])

91
16034872 | Anjil Shrestha
Application Development

select values[6];

foreach (var name in qTotalTime)


{

if (name != null && name != "")


{
totalMin = Int32.Parse(name) + totalMin;
}

}
}

this.chart1.Series["Total Visitor"].Points.AddXY(days[i], visitors.ToString());


this.chart1.Series["Total time"].Points.AddXY(days[i], totalMin.ToString());
}

}
else
{
MessageBox.Show("Pick a week.", "Error!");
}

92
16034872 | Anjil Shrestha
Application Development

}
}
}

93
16034872 | Anjil Shrestha
Application Development

11.2. DailyReport.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ApplicationDev
{
public partial class DailyReport : Form
{

public DailyReport()
{
InitializeComponent();
this.MaximizeBox = false;

List<string> ls = checkin();
int visitorsCount = 0;
int totalMin = 0;

var visit = from date in ls

where date.Contains(dateTimePicker1.Value.ToShortDateString())
select date;

94
16034872 | Anjil Shrestha
Application Development

List<string> cards = new List<string>();


List<CheckIn> singleUser = new List<CheckIn>();
foreach (string s in visit)
{
Console.WriteLine("Uniques: "+s);

string vals = s.ToString();


string[] n = vals.Split(',');
this.dataGridViewAllVisitor.Rows.Add(n[0], n[1], n[2],
DateTime.Parse(n[3]).ToShortDateString(), n[4], n[5], n[6]);

CheckIn newChk = new CheckIn();


newChk.card_number = n[0];
newChk.name = n[1];
newChk.total_time = n[6];
singleUser.Add(newChk);

cards.Add(n[0]);
}

var uniq = cards.Distinct();


foreach (var u in uniq)
{
visitorsCount = visitorsCount + 1;

foreach (string i in ls)


{

//Console.WriteLine(i);

95
16034872 | Anjil Shrestha
Application Development

var values = i.Split(',').ToList();


var qTotalVisitor= from date in values
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

// Query execution

foreach (var name in qTotalVisitor)


{

var qTotalTime = from date in values


where date.Contains(DateTime.Now.Date.ToShortDateString())
select values[6];

foreach (var name in qTotalTime)


{
Console.WriteLine("Time: " + name);
if (name!=null && name!="") {
totalMin = Int32.Parse(name)+totalMin;
}

var groupedUser = from s in singleUser


group s by s.card_number;

96
16034872 | Anjil Shrestha
Application Development

string card = "";


string name1 = "";
int totalM = 0;
foreach (var visitors in groupedUser)
{
card = visitors.Key.ToString();
Console.WriteLine("Single Visitor: " + visitors.Key);
foreach (var v in visitors)
{
name1 = v.name;
totalM = Convert.ToInt32(v.total_time) + totalM;
Console.WriteLine(v.card_number + " " + v.total_time);
}

this.dataGridPerVisit.Rows.Add(card, name1, totalM.ToString());


totalM = 0;
card = "";
name1 = "";

this.dataGridView1.Rows.Add(visitorsCount.ToString(), totalMin.ToString());

public List<string> checkin() {


List<string> ls = new List<string>();

using (StreamReader sr = new StreamReader("../../../checkins.csv"))

97
16034872 | Anjil Shrestha
Application Development

{
string line;

int i = 0;

while ((line = sr.ReadLine()) != null)


{
//Console.WriteLine(line);
ls.Add(line);

// Console.WriteLine(ls);

}
}
return ls;

private void DailyReport_Load(object sender, EventArgs e)


{

List<string> values = checkin();

var toPLot = from date in values


where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

98
16034872 | Anjil Shrestha
Application Development

foreach (string s in toPLot) {

string vals = s.ToString();


string[] n = vals.Split(',');

Console.WriteLine("Valuesss: "+n[2]);
//this.chart1.Series["Total Visitors"].Points.AddXY(n[4], DateTime.Parse(n[5]).Minute-
DateTime.Parse(n[4]).Minute);

//this.chart1.Series["Total Visitors"].Points.AddXY("11 AM", 100);


//this.chart1.Series["Total Visitors"].Points.AddXY("11 AM", 20);

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)


{
Console.WriteLine("Hola: "+ dateTimePicker1.Value.ToShortDateString());
this.dataGridView1.Rows.Clear();
this.dataGridView1.Refresh();
this.dataGridViewAllVisitor.Rows.Clear();
this.dataGridViewAllVisitor.Refresh();

this.dataGridPerVisit.Rows.Clear();
this.dataGridPerVisit.Refresh();

99
16034872 | Anjil Shrestha
Application Development

List<string> ls = checkin();
//---each person minutes

int visitorsCount = 0;
int totalMin = 0;

var visit = from date in ls

where date.Contains(dateTimePicker1.Value.ToShortDateString())
select date;

List<string> cards = new List<string>();


//List<string> singleUser = new List<string>();
List<CheckIn> singleUser = new List<CheckIn>();

foreach (string s in visit)


{
Console.WriteLine("Uniques: " + s);

string vals = s.ToString();


string[] n = vals.Split(',');
this.dataGridViewAllVisitor.Rows.Add(n[0], n[1], n[2],
DateTime.Parse(n[3]).ToShortDateString(), n[4], n[5], n[6]);

CheckIn newChk = new CheckIn();


newChk.card_number = n[0];
newChk.name = n[1];
newChk.total_time = n[6];

100
16034872 | Anjil Shrestha
Application Development

singleUser.Add(newChk);

cards.Add(n[0]);

var uniq = cards.Distinct();


foreach (var u in uniq)
{

visitorsCount = visitorsCount + 1;

foreach (string i in ls)


{

//Console.WriteLine(i);
var values = i.Split(',').ToList();
var qTotalVisitor = from date in values
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;

// Query execution

101
16034872 | Anjil Shrestha
Application Development

foreach (var name in qTotalVisitor)


{

var qTotalTime = from date in values


where date.Contains(dateTimePicker1.Value.ToShortDateString())
select values[6];

foreach (var name in qTotalTime)


{
Console.WriteLine("Time: " + name);
if (name != null && name != "")
{
totalMin = Int32.Parse(name) + totalMin;
}

// dt.Rows.Add(chkData[0], chkData[1], chkData[2], chkData[3], chkData[4], chkData[5],


chkData[6]);
// this.dataGridView1.DataSource = dt;

102
16034872 | Anjil Shrestha
Application Development

var groupedUser = from s in singleUser


group s by s.card_number;
string card = "";
string name1 = "";
int totalM = 0;
foreach (var visitors in groupedUser) {
card = visitors.Key.ToString();
Console.WriteLine("Single Visitor: " + visitors.Key);
foreach (var v in visitors) {
name1 = v.name;
totalM = Convert.ToInt32(v.total_time)+totalM;
Console.WriteLine(v.card_number+" " +v.total_time);
}

this.dataGridPerVisit.Rows.Add(card, name1, totalM.ToString());


totalM = 0;
card = "";
name1 = "";

//Console.WriteLine("Total Visitor: " + visitorsCount);


//Console.WriteLine("Total Min: " + totalMin);

this.dataGridView1.Rows.Add(visitorsCount.ToString(), totalMin.ToString());
}

103
16034872 | Anjil Shrestha
Application Development

}
}

104
16034872 | Anjil Shrestha
Application Development

11.3. WeeklyReport.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ApplicationDev
{
public partial class WeeklyReport : Form
{

public WeeklyReport()
{
InitializeComponent();
this.MaximizeBox = false;
//week-----------------
// Gets the Calendar instance associated with a CultureInfo.

105
16034872 | Anjil Shrestha
Application Development

//Console.WriteLine("Parsed value 1: " +


GetWeekNumberOfMonth(DateTime.Parse("1/1/2019")));

CultureInfo myCI = new CultureInfo("en-US");


Calendar myCal = myCI.Calendar;

// Gets the DTFI properties required by GetWeekOfYear.


CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
Console.WriteLine("Cuurent week: "+myCal.GetWeekOfYear(DateTime.Parse("1/1/2019"),
myCWR, myFirstDOW));

//CalendarWeekRule weekRule = CalendarWeekRule.FirstFourDayWeek;

//DayOfWeek firstWeekDay = DayOfWeek.Monday;


//Calendar calendar = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar;

//int currentWeek = calendar.GetWeekOfYear(DateTime.Now, weekRule, firstWeekDay);

//string week = String.Format("{1:00}", dateTimePicker1.Value, currentWeek);

//Console.WriteLine("Weeek: "+week);

weekCombo.Text = "Select Week";

//---------------------

/*
List<string> ls = checkin();
int visitorsCountMonday = 0;

106
16034872 | Anjil Shrestha
Application Development

int totalMinMonday = 0;
string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
for (int i = 0; i < days.Length ; i++)
{
int visitors = 0;
int totalMin = 0;
var visit2 = from date in ls
where date.Contains(days[i])
select date;

List<string> cards1 = new List<string>();


foreach (string s in visit2)
{

string vals = s.ToString();


string[] n = vals.Split(',');
cards1.Add(n[0]);
}

var uniq1 = cards1.Distinct();


foreach (var u in uniq1)
{
visitors = visitors + 1;

}
//minutes
foreach (string t in ls)
{

//Console.WriteLine(i);
var values = t.Split(',').ToList();

107
16034872 | Anjil Shrestha
Application Development

var qTotalTime = from date in values


where date.Contains(days[i])
select values[6];

foreach (var name in qTotalTime)


{

if (name != null && name != "")


{
totalMin = Int32.Parse(name) + totalMin;
}

this.dataGridView1.Rows.Add(days[i], visitors.ToString(), totalMin.ToString());


this.chart1.Series["Total Visitor"].Points.AddXY(days[i], visitors.ToString());
this.chart1.Series["Total time"].Points.AddXY(days[i], totalMin.ToString());

108
16034872 | Anjil Shrestha
Application Development

*/
}

public List<string> checkin()


{
List<string> ls = new List<string>();

using (StreamReader sr = new StreamReader("../../../checkins.csv"))


{
string line;

int i = 0;

while ((line = sr.ReadLine()) != null)


{
//Console.WriteLine(line);
ls.Add(line);

// Console.WriteLine(ls);

}
}
return ls;

109
16034872 | Anjil Shrestha
Application Development

private void WeeklyReport_Load(object sender, EventArgs e)


{

private void sortA_Click(object sender, EventArgs e)


{
try
{
//Console.WriteLine("Row: "+row);
// Console.WriteLine("Total Rows: " + dataGridView1.RowCount + ", Cell: " +
dataGridView1.ColumnCount);
//chkD.Cells[6].Value
string[,] datavalue = new string[dataGridView1.Rows.Count - 1,
dataGridView1.Columns.Count];
foreach (DataGridViewRow row in dataGridView1.Rows)
{

foreach (DataGridViewColumn col in dataGridView1.Columns)


{
if (dataGridView1.Rows[row.Index].Cells[col.Index].Value != null &&
dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString() != "")
{
datavalue[row.Index, col.Index] =
dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString();
}
}

string[] temp = new string[3];

for (int i = 0; i < datavalue.GetLength(0) - 1; i++)

110
16034872 | Anjil Shrestha
Application Development

int j;
j = 0;
for (; j < datavalue.GetLength(0) - 1; j++)
{
if (Int32.Parse(datavalue[j, 1]) > Int32.Parse(datavalue[j + 1, 1]))
{
//put array record j into temp holder
temp[0] = datavalue[j, 0];
temp[1] = datavalue[j, 1];
temp[2] = datavalue[j, 2];

//copy j + 1 into j
datavalue[j, 0] = datavalue[j + 1, 0];
datavalue[j, 1] = datavalue[j + 1, 1];
datavalue[j, 2] = datavalue[j + 1, 2];

//copy temp into j + 1


datavalue[j + 1, 0] = temp[0];
datavalue[j + 1, 1] = temp[1];
datavalue[j + 1, 2] = temp[2];
}

}
}

Console.WriteLine("Sorted array: " + datavalue[4, 2]);


this.dataGridView1.Rows.Clear();
this.dataGridView1.Refresh();
for (int i = 0; i < datavalue.GetLength(0); i++)
{

111
16034872 | Anjil Shrestha
Application Development

Console.WriteLine(datavalue[i, 0] + " , " + datavalue[i, 1] + " , " + datavalue[i, 2]);


this.dataGridView1.Rows.Add(datavalue[i, 0], datavalue[i, 1], datavalue[i, 2]);
}

} catch(Exception ex1)
{
Console.WriteLine(ex1.Message);
}
}

private void sortD_Click(object sender, EventArgs e)


{
try
{
//Console.WriteLine("Row: "+row);
Console.WriteLine("Total Rows: " + dataGridView1.RowCount + ", Cell: " +
dataGridView1.ColumnCount);
//chkD.Cells[6].Value
string[,] datavalue = new string[dataGridView1.Rows.Count - 1,
dataGridView1.Columns.Count];
foreach (DataGridViewRow row in dataGridView1.Rows)
{

foreach (DataGridViewColumn col in dataGridView1.Columns)


{
if (dataGridView1.Rows[row.Index].Cells[col.Index].Value != null &&
dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString() != "")
{
datavalue[row.Index, col.Index] =
dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString();
}
}

112
16034872 | Anjil Shrestha
Application Development

string[] temp = new string[3];


Console.WriteLine("Lgth " + datavalue.GetLength(0) + " R: " +
(dataGridView1.Rows.Count - 1));
Console.WriteLine(" Data D: " + datavalue[4, 2]);

for (int i = 0; i < datavalue.GetLength(0) - 1; i++)


{

int j;
j = 0;
for (; j < datavalue.GetLength(0) - 1; j++)
{
if (Int32.Parse(datavalue[j, 2]) > Int32.Parse(datavalue[j + 1, 2]))
{
//put array record j into temp holder
temp[0] = datavalue[j, 0];
temp[1] = datavalue[j, 1];
temp[2] = datavalue[j, 2];

//copy j + 1 into j
datavalue[j, 0] = datavalue[j + 1, 0];
datavalue[j, 1] = datavalue[j + 1, 1];
datavalue[j, 2] = datavalue[j + 1, 2];

//copy temp into j + 1


datavalue[j + 1, 0] = temp[0];
datavalue[j + 1, 1] = temp[1];
datavalue[j + 1, 2] = temp[2];
}

113
16034872 | Anjil Shrestha
Application Development

Console.WriteLine("Sorted array: " + datavalue[4, 2]);


this.dataGridView1.Rows.Clear();
this.dataGridView1.Refresh();
for (int i = 0; i < datavalue.GetLength(0); i++)
{
Console.WriteLine(datavalue[i, 0] + " , " + datavalue[i, 1] + " , " + datavalue[i, 2]);
this.dataGridView1.Rows.Add(datavalue[i, 0], datavalue[i, 1], datavalue[i, 2]);
}
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)


{
//weekCombo.Items.Clear();
// weekCombo.Text = "Select Week";

private void chkInBtn_Click(object sender, EventArgs e)


{
CultureInfo myCI = new CultureInfo("en-US");
Calendar myCal = myCI.Calendar;

// Gets the DTFI properties required by GetWeekOfYear.


CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
// Console.WriteLine("Cuurent week: " +
myCal.GetWeekOfYear(DateTime.Parse("1/1/2019"), myCWR, myFirstDOW));

114
16034872 | Anjil Shrestha
Application Development

this.chart1.Series["Total Visitor"].Points.Clear();
this.chart1.Series["Total time"].Points.Clear();

this.dataGridView1.Rows.Clear();
this.dataGridView1.Refresh();
if (weekCombo.Text == "1" || weekCombo.Text == "2" || weekCombo.Text == "3" ||
weekCombo.Text == "4" || weekCombo.Text == "5")
{

List<string> checkWeek = checkin();


string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
for (int i = 0; i < days.Length; i++)
{
int visitors = 0;
int totalMin = 0;
var visit2 = from date in checkWeek
where date.Contains(days[i])
select date;

List<string> cards1 = new List<string>();


foreach (string s in visit2)
{

string vals = s.ToString();


string[] n = vals.Split(',');

//Console.WriteLine("Parsed value "+


GetWeekNumberOfMonth(DateTime.Parse("1/1/2019")));
//myCal.GetWeekOfYear(DateTime.Parse("n[3]"), myCWR, myFirstDOW)
Console.WriteLine("Index check: " + n[3]);
int wno = myCal.GetWeekOfYear(DateTime.Parse(n[3]), myCWR, myFirstDOW);

115
16034872 | Anjil Shrestha
Application Development

Console.WriteLine("WNO: " + wno);


if (DateTime.Parse(n[3]).Month.ToString() ==
DateTime.Parse(dateTimePicker1.Value.ToString()).Month.ToString() &&
myCal.GetWeekOfYear(DateTime.Parse(n[3]), myCWR, myFirstDOW) ==
Convert.ToInt32(weekCombo.Text))
{
cards1.Add(n[0]);
}
}

var uniq1 = cards1.Distinct();


foreach (var u in uniq1)
{
visitors = visitors + 1;

//minutes
foreach (string t in checkWeek)
{

//Console.WriteLine(i);
var values = t.Split(',').ToList();
// Console.WriteLine("Valuess "+dateTimePicker1.Text);
//myCal.GetWeekOfYear(DateTime.Parse("values[3]"), myCWR, myFirstDOW)
if (DateTime.Parse(values[3]).Month.ToString() ==
DateTime.Parse(dateTimePicker1.Value.ToString()).Month.ToString() &&
myCal.GetWeekOfYear(DateTime.Parse(values[3]), myCWR, myFirstDOW) ==
Convert.ToInt32(weekCombo.Text))
{

var qTotalTime = from date in values

116
16034872 | Anjil Shrestha
Application Development

where date.Contains(days[i])
select values[6];

foreach (var name in qTotalTime)


{

if (name != null && name != "")


{
totalMin = Int32.Parse(name) + totalMin;
}

}
}

this.dataGridView1.Rows.Add(days[i], visitors.ToString(), totalMin.ToString());


this.chart1.Series["Total Visitor"].Points.AddXY(days[i], visitors.ToString());
this.chart1.Series["Total time"].Points.AddXY(days[i], totalMin.ToString());
}

}
else {
MessageBox.Show("Pick a week.","Error!");
}

117
16034872 | Anjil Shrestha
Application Development

}
}
}

118
16034872 | Anjil Shrestha
Application Development

11.4. Search.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ApplicationDev
{
public partial class Search : Form
{

public Search(List<string> infos,String number)


{
InitializeComponent();
this.MaximizeBox = false;
DataTable dt = new DataTable();

var visit = from visitor in infos

where visitor.Contains(number)
select visitor;

List<string> cards = new List<string>();


foreach (string s in visit)
{

119
16034872 | Anjil Shrestha
Application Development

string vals = s.ToString();


string[] n = vals.Split(',');
cards.Add(n[0]);

this.dataGridView1.Rows.Add(n[0],n[1], n[2],
DateTime.Parse(n[3]).ToShortDateString(), n[4], n[5], n[6]);
}

private void Search_Load(object sender, EventArgs e)


{

}
}
}

120
16034872 | Anjil Shrestha

You might also like