Application Development Simple
Application Development Simple
CS6004NI
Coursework 1
Submitted By: Submitted To:
Group: L3C6
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.3. Features
• 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
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)
3
16034872 | Anjil Shrestha
Application Development
2. Software Architecture
4
16034872 | Anjil Shrestha
Application Development
2: Record Time button that opens page for checking in and checking out.
8: Report menu item containing sub menu daily report and weekly report.
5
16034872 | Anjil Shrestha
Application Development
13: Registers the visitor and saves the data in visitors CSV file.
6
16034872 | Anjil Shrestha
Application Development
17: Datagridview displaying current date visitors in time and out time.
25: Button that record check out time of each row data.
7
16034872 | Anjil Shrestha
Application Development
26: Datetime picker for selecting a particular date to populate visitor’s data of that date.
8
16034872 | Anjil Shrestha
Application Development
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.
9
16034872 | Anjil Shrestha
Application Development
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
Visitor
+ card_number : string
+ first_name : string
+ last_name : string
+ address : DateTime
+ contact : string
+ email : string
+ gender : string
+ occupation : string
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
12
16034872 | Anjil Shrestha
Application Development
13
16034872 | Anjil Shrestha
Application Development
DailyReport
+ DailyReport ( )
- DailyReport_Load ( sender : object , e : EventArgs ) : void
- dateTimePicker1_ValueChanged ( sender : object , e : EventArgs ) : void
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
Search
+ Search( infos: List<string>, number: String )
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
16
16034872 | Anjil Shrestha
Application Development
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
20
16034872 | Anjil Shrestha
Application Development
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.
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.
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.
6.1: Displays two kinds of report i.e. daily report and weekly report to select between.
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.
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
23
16034872 | Anjil Shrestha
Application Development
24
16034872 | Anjil Shrestha
Application Development
• 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)
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)
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)
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
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
27
16034872 | Anjil Shrestha
Application Development
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
28
16034872 | Anjil Shrestha
Application Development
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
29
16034872 | Anjil Shrestha
Application Development
30
16034872 | Anjil Shrestha
Application Development
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
31
16034872 | Anjil Shrestha
Application Development
32
16034872 | Anjil Shrestha
Application Development
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
33
16034872 | Anjil Shrestha
Application Development
34
16034872 | Anjil Shrestha
Application Development
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
35
16034872 | Anjil Shrestha
Application Development
36
16034872 | Anjil Shrestha
Application Development
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
37
16034872 | Anjil Shrestha
Application Development
38
16034872 | Anjil Shrestha
Application Development
39
16034872 | Anjil Shrestha
Application Development
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
41
16034872 | Anjil Shrestha
Application Development
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
42
16034872 | Anjil Shrestha
Application Development
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
44
16034872 | Anjil Shrestha
Application Development
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
45
16034872 | Anjil Shrestha
Application Development
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
46
16034872 | Anjil Shrestha
Application Development
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
47
16034872 | Anjil Shrestha
Application Development
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
48
16034872 | Anjil Shrestha
Application Development
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
49
16034872 | Anjil Shrestha
Application Development
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
50
16034872 | Anjil Shrestha
Application Development
51
16034872 | Anjil Shrestha
Application Development
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
52
16034872 | Anjil Shrestha
Application Development
53
16034872 | Anjil Shrestha
Application Development
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)
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
Problems faced
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
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<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;
}
}
return ls;
/*
60
16034872 | Anjil Shrestha
Application Development
ls.Add(line);
}
}
return ls;
/*
* Constructor class that initizalizes the components
* */
61
16034872 | Anjil Shrestha
Application Development
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;
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;
62
16034872 | Anjil Shrestha
Application Development
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
if (checkins1.Count > 1)
{
foreach (string i in checkins1)
{
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);
}
}
}
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)
{
List<string> ls = readCheckIns();
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;
66
16034872 | Anjil Shrestha
Application Development
}
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.
* */
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;
68
16034872 | Anjil Shrestha
Application Development
/*
* Register new vistors.
* */
private void button3_Click_1(object sender, EventArgs e)
{
try
{
}
else
{
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)
{
71
16034872 | Anjil Shrestha
Application Development
chkInBtn.Enabled = true;
}
else
{
}
}
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;
where date.Contains(cardField.Text)
select date;
73
16034872 | Anjil Shrestha
Application Development
//---------------
if (checkedOUt)
{
string firstLine = lines[0];
74
16034872 | Anjil Shrestha
Application Development
this.dataGridView1.DataSource = dt;
ch.Add(checkin);
if (!File.Exists(path))
{
File.Create(path);
75
16034872 | Anjil Shrestha
Application Development
}
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
{
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;
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();
if (!File.Exists(path))
{
File.Create(path);
78
16034872 | Anjil Shrestha
Application Development
}
}
break;
}
}
break;
}
}
79
16034872 | Anjil Shrestha
Application Development
chkData[6] = chkD.Cells[7].Value.ToString();
Console.WriteLine("Cell Value of date: " +
DateTime.Parse(chkD.Cells[5].Value.ToString()));
if (!File.Exists(path))
{
File.Create(path);
80
16034872 | Anjil Shrestha
Application Development
break;
}
else
{
Console.WriteLine("Not Found: ");
}
}
}
81
16034872 | Anjil Shrestha
Application Development
82
16034872 | Anjil Shrestha
Application Development
//visitor count---------------
int visitorsCount = 0;
int totalMin = 0;
int onChk = 0;
List<string> forCounter = readCheckIns();
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;
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;
84
16034872 | Anjil Shrestha
Application Development
where visitor.Contains(searchBox.Text)
select visitor;
if (searchBox.Text.Length==10 && visit.Count() >0)
{
}
else {
MessageBox.Show("Not found." );
}
85
16034872 | Anjil Shrestha
Application Development
}
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);
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]);
where date.Contains(DateTime.Now.Date.ToShortDateString())
select date;
}
this.dataGridView1.DataSource = dt;
MessageBox.Show("Imported.","Success!");
88
16034872 | Anjil Shrestha
Application Development
}
catch (Exception e2) {
Console.WriteLine(e2.Message);
}
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;
}
89
16034872 | Anjil Shrestha
Application Development
this.chart1.Series["Total Visitor"].Points.Clear();
this.chart1.Series["Total time"].Points.Clear();
90
16034872 | Anjil Shrestha
Application Development
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]);
}
}
//minutes
foreach (string t in checkWeek)
{
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))
{
91
16034872 | Anjil Shrestha
Application Development
select values[6];
}
}
}
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;
where date.Contains(dateTimePicker1.Value.ToShortDateString())
select date;
94
16034872 | Anjil Shrestha
Application Development
cards.Add(n[0]);
}
//Console.WriteLine(i);
95
16034872 | Anjil Shrestha
Application Development
// Query execution
96
16034872 | Anjil Shrestha
Application Development
this.dataGridView1.Rows.Add(visitorsCount.ToString(), totalMin.ToString());
97
16034872 | Anjil Shrestha
Application Development
{
string line;
int i = 0;
// Console.WriteLine(ls);
}
}
return ls;
98
16034872 | Anjil Shrestha
Application Development
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.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;
where date.Contains(dateTimePicker1.Value.ToShortDateString())
select date;
100
16034872 | Anjil Shrestha
Application Development
singleUser.Add(newChk);
cards.Add(n[0]);
visitorsCount = visitorsCount + 1;
//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
102
16034872 | Anjil Shrestha
Application Development
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("Weeek: "+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;
}
//minutes
foreach (string t in ls)
{
//Console.WriteLine(i);
var values = t.Split(',').ToList();
107
16034872 | Anjil Shrestha
Application Development
108
16034872 | Anjil Shrestha
Application Development
*/
}
int i = 0;
// Console.WriteLine(ls);
}
}
return ls;
109
16034872 | Anjil Shrestha
Application Development
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];
}
}
111
16034872 | Anjil Shrestha
Application Development
} catch(Exception ex1)
{
Console.WriteLine(ex1.Message);
}
}
112
16034872 | Anjil Shrestha
Application Development
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];
113
16034872 | Anjil Shrestha
Application Development
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")
{
115
16034872 | Anjil Shrestha
Application Development
//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))
{
116
16034872 | Anjil Shrestha
Application Development
where date.Contains(days[i])
select values[6];
}
}
}
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
{
where visitor.Contains(number)
select visitor;
119
16034872 | Anjil Shrestha
Application Development
this.dataGridView1.Rows.Add(n[0],n[1], n[2],
DateTime.Parse(n[3]).ToShortDateString(), n[4], n[5], n[6]);
}
}
}
}
120
16034872 | Anjil Shrestha