CS6004NP - Application Development - Ashish - Bhandari - 17031918 - CW1
CS6004NP - Application Development - Ashish - Bhandari - 17031918 - CW1
Application Development
Coursework 1
ABSTRACT
This project addresses the study and development of an WPF student registration
management system using c# language. Windows Presentation Foundation(WPF) is a
development framework used to create a desktop application. It is a part of the .NET
framework. This project enable users, make an computerized registration system to
manage student data.
Thus, this project studies some issues on how WPF application is build. This project will
provide Decision Support System to manage student registration data. This app will assist
in future development that would support a fully integrated system.
KEYWORD LIST
• C#
• Student management
• Student registration management
• WPF application
• XML
ACKNOWLEDGEMENTS
I am grateful to Informatics college Pokhara for providing me this opportunity to prove my
academic capabilities in something more professional and practical. This honors project
carried out in crunch time has taught me utterly necessary lessons as to how a WPF
application is developed and how student management system project should be
managed and handled. I am very thank full to my module leader Mr. Ishwor Sapkota for
enduring my steep mistakes and shortcomings.
1
Ashish Bhandari
CS6004NP Application Development
1. INTRODUCTION
As per the requirement of module’s coursework, we have developed a student
management system for an educational institution. The system is used to keep records
of students. Student Management System is a software that is helpful for students as well
as the school authorities.
In the current system all the activities are done manually. It is very time consuming and
costly. Currently most of school, colleges, etc. uses manual system which is old
fashioned. For changes, a digitalized system is required. After the success of system
people are looking for it because of its easy record keeping and generating student report
and also it help in analyze their business. Our Student Management System deals with
the various activities related to the students.
2
Ashish Bhandari
CS6004NP Application Development
As user start the program, the very first step in this program is to login to system. The
program detects whether the user is new or not. The program displays username and
password setup form for new user, once the user set username and password they need
not need to set username and password again. To setup new password, system provides
password confirmation field to enhance security. User can quit the program by clicking
exit button. We can see the username and password setup form below in figure 1:
3
Ashish Bhandari
CS6004NP Application Development
After username and password setup, user needs to login to the system by entering
username and password they created in setup window. If user forget username and
password user can reset it by clicking ‘forget password’ button. The ‘forget password’
button opens new password setup window where user change username and password.
User can quit the process by simply clicking exit button. The login window is shown below
in figure 2 and password change window is shown in figure 3:
4
Ashish Bhandari
CS6004NP Application Development
After login to the system program opens a new window which is home window of program
which contains 5 buttons i.e. ‘change password’ button, ‘register new student’ button,
‘view student report button’, ‘change password’ button, ‘logout’ button and ‘exit’ button.
Program home window is shown below in figure 4:
Let’s discuss from the first, the if user wish to change their password they can click
‘change password’ button. ‘change password’ button opens new window to change
password. Every time user change password user needs to login again to system. The
password change window is shown below in figure 5:
5
Ashish Bhandari
CS6004NP Application Development
To register new student, user have to click ‘Register Student’ button. The button opens
new window where two more option on register are provided. i.e. ‘Register individual
student’ button and ‘Register from existing file’ button. If user wish to register individual
student user can click ‘Register Individual’ and if user wish to register student data from
existing file they can click ‘Register From Existing File’ button. The new window opens by
clicking ‘Register Student’ button is shown below in figure 6:
6
Ashish Bhandari
CS6004NP Application Development
After clicking ‘Register Individual Student’ button system opens a new window, which
contains all the necessary input fields to register student. System have all necessary
validation like email format validation, integer validation e.t.c. user is unable to register
until all these validation get succeed. Integer filed like student phone number, student id
accepts only integer value. Email id of student should be entered properly with valid email
format otherwise registration process can’t be done. In order to choose program, user
first needs to choose department. In every department change, faculty and program are
automatically changed. User can’t choose faculty before choosing department and can’t
choose program until choosing faculty. After choosing department user needs to click
load button near faculty choose field which load the relative faculty according to selected
department. After choosing faculty user needs to choose program, to see available
program user needs to click load button near program choose field which load the relative
program according to selected faculty. The program contains further input fields like
7
Ashish Bhandari
CS6004NP Application Development
nationality, marital status and religion which are not mandatory if user don’t want to enter,
they can simply leave these fields blank. After all successful validation and mandatory
input done user can click register button to go further process. And user can clear the the
input fields by clicking ‘Clear’ button. The new student register window is shown below in
figure 7:
After Clicking ‘Register’ button system opens ‘registration confirmation’ window, which is
provided to avoid mistakes and to ensure that the user entered data is actually correct. If
user finds entered data mistake, user can abort process by clicking ‘Cancel’ button. If all
data are correct and user wish to register data, user can enter ‘Register’ button which
8
Ashish Bhandari
CS6004NP Application Development
save student data in xml file. The student data confirmation window is shown below in
figure 9:
9
Ashish Bhandari
CS6004NP Application Development
To register student from existing file, user have to click ‘‘Register From Existing File’
button. After clicking ‘Register From Existing File’ button system opens a new window,
which contains file browse button, data preview panel, back button and register button.
First user have to click on ‘choose’ button to browse the csv file. System accepts only csv
file. After selecting csv file, system displays all it’s data to provide data convince to user.
If user wish to register all the student data, user can click ‘Register All’ button. And user
can abort process by clicking ‘cancel’ button. The ‘Register from existing file’ window is
shown below in figure 9:
10
Ashish Bhandari
CS6004NP Application Development
11
Ashish Bhandari
CS6004NP Application Development
12
Ashish Bhandari
CS6004NP Application Development
13
Ashish Bhandari
CS6004NP Application Development
14
Ashish Bhandari
CS6004NP Application Development
Methods Description
Methods Description
15
Ashish Bhandari
CS6004NP Application Development
Methods Description
Methods Description
16
Ashish Bhandari
CS6004NP Application Development
Methods Description
Methods Description
Methods Description
17
Ashish Bhandari
CS6004NP Application Development
Methods Description
Methods Description
18
Ashish Bhandari
CS6004NP Application Development
4. Class Diagram
19
Ashish Bhandari
CS6004NP Application Development
5. System Architecture
20
Ashish Bhandari
CS6004NP Application Development
6. Flow Chart
6.1. Flow chart of Program setup
21
Ashish Bhandari
CS6004NP Application Development
22
Ashish Bhandari
CS6004NP Application Development
23
Ashish Bhandari
CS6004NP Application Development
24
Ashish Bhandari
CS6004NP Application Development
7. Algorithms of Reports
7.1. Individual Student Enrolment Algorithm Steps:
1. Start
2. Check whether the user input data is valid or not
3. If not valid, display error message and avoid registration
4. If valid, show confirmation window and ask to register confirm or not
5. If user enter confirm register, write student data in xml file
6. Stop
25
Ashish Bhandari
CS6004NP Application Development
Bubble sort starts with very first two elements, comparing them to check which one
is greater.
In this case, value 33 is greater than 14, so it is already in sorted locations. Next, we
compare 33 with 27.
We find that 27 is smaller than 33 and these two values must be swapped.
26
Ashish Bhandari
CS6004NP Application Development
Next we compare 33 and 35. We find that both are in already sorted positions.
We know then that 10 is smaller 35. Hence they are not sorted.
We swap these values. We find that we have reached the end of the array. After one
iteration, the array should look like this −
To be precise, we are now showing how an array should look like after each
iteration. After the second iteration, it should look like this −
Notice that after each iteration, at least one value moves at the end.
And when there's no swap required, bubble sorts learns that an array is completely
sorted.
27
Ashish Bhandari
CS6004NP Application Development
1) List
When it comes to the list data structure, we should mention that it defines a sequential
set of elements to which you can add new elements and remove or change existing
ones (medium, 2020).
In program list is used in login window, where user name and password from text file
stored in list. The reason for using list in program is mention below:
• The need for this data structure is most obvious when we have the urge to store
items without knowing how much space we’ll need in advance.
• Also, when we often have the need to add or get elements from a data
structure, the array list would suit well because those operations are fast and
efficient.
2) Array
An array is a collection of items stored at contiguous memory locations. The idea is to
store multiple items of the same type together. This makes it easier to calculate the
position of each element by simply adding an offset to a base value, i.e., the memory
location of the first element of the array (geeksforgeeks, 2020).
In this program array is used reading xml value, where program read data from xml
file and store them in an array.
28
Ashish Bhandari
CS6004NP Application Development
Let’s talk about visual studio 2019, Visual Studio IDE is a full-featured development
platform for multiple operating systems as well as the web and the cloud. It allows
users to smoothly navigate the interface so they can write their code speedily and
accurately.
With Visual Studio IDE, developers also have access to a host of debugging tools.
These assist them in profiling bugs and diagnosing them simply. This way, they can
deploy their applications confidently, knowing that they have done away with anything
that could cause performance errors.
Although, it has many good points but I find some issue in visual studio 2019. It needs
really high processor and high ram. When we run visual studio below 4gb ram, visual
studio can not operate well, it consumes a lot of time to load in such low processor/ram
laptops.
Thus, only one issue I experienced using visual studio is, it consumes a lot of ram. I
think the solution to overcome this problem is, developing two version of ‘visual studio’.
One will be developed as light version for low processor computer, so that all the user
who have light processor/ram computer can also use visual studio efficiently.
29
Ashish Bhandari
CS6004NP Application Development
30
Ashish Bhandari
CS6004NP Application Development
II. wrong username and password is entered to see how system handle the
situation, screenshot of output of the application is shown below:
III. username and password is leaved empty to see how system handle the situation,
screenshot of output of the application is shown below:
31
Ashish Bhandari
CS6004NP Application Development
32
Ashish Bhandari
CS6004NP Application Development
II. Here in name input field, integer value is entered to see how system handle the
situation. screenshot of output of the application is shown below:
III. Here, in contact number field, string value is entered to see how system handle
the situation. screenshot of output of the application is shown below:
33
Ashish Bhandari
CS6004NP Application Development
IV. Here, in email input field, wrong format email is entered to see how system
handle the situation. screenshot of output of the application is shown below:
34
Ashish Bhandari
CS6004NP Application Development
V. Here, all the required field are filled correctly and last name filed is leaved blank
to see how system handle the situation. screenshot of output of the application is
shown below:
VI. Here, in contact number field, only two integer value is entered to see how
system handle the situation. screenshot of output of the application is shown
below:
35
Ashish Bhandari
CS6004NP Application Development
11. CONCLUSION
The initial coursework for the module CS6004NA Application Development was to build
up student information system for an organization. It required a long time to build up the
task in Visual Studio 2019 utilizing C# programming dialect. The framework has login
screen to add security to the task. After login, the framework shows an main page where
there are four clickable button along with logout and exit button after clicking any one
button among the four the clickable button the clicked button goes to its respective page
where the data are further inserted and send into XML and the data is saved into XML
and the data is further retrieve to show the report and chart of the students. Aside from
various shape components, class outline for every one of the structures and classes were
utilized.
36
Ashish Bhandari
CS6004NP Application Development
12. References
13. Appendix
Homewindow.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
37
Ashish Bhandari
CS6004NP Application Development
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
InitializeComponent();
System.IO.Directory.CreateDirectory(folderName);
MessageBoxResult messageBoxResult =
System.Windows.MessageBox.Show("Are you sure wanna exit ?", "Exit Confirmation",
System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Close();
}
else
{
//
38
Ashish Bhandari
CS6004NP Application Development
string user;
string pw;
if (user_name == "")
{
MessageBox.Show("Empty username! Please enter username
first","Error", System.Windows.MessageBoxButton.OK, MessageBoxImage.Error);
}
else if (password == "")
{
MessageBox.Show("Password can't be empty!", "Error",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Error);
}
else if (password == pw && user_name == user)
{
// this.Hide();
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
this.Close();
}
else
{
MessageBox.Show("Invalid username and password!", "Error",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
39
Ashish Bhandari
CS6004NP Application Development
}
}
Password.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
40
Ashish Bhandari
CS6004NP Application Development
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
/// <summary>
/// Interaction logic for password.xaml
/// </summary>
public partial class password : Window
{
this.Hide();
HomeWindow hmWindow = new HomeWindow();
hmWindow.Show();
}
else
{
MessageBox.Show("Password does not match!");
}
}
41
Ashish Bhandari
CS6004NP Application Development
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Close();
}
else
{
//
}
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
namespace Student_info
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void exit_btn(object sender, RoutedEventArgs e)
{
42
Ashish Bhandari
CS6004NP Application Development
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Close();
MainWindow mainWindow = new MainWindow();
}
else
{
//
}
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Hide();
HomeWindow homeWindow = new HomeWindow();
homeWindow.Show();
}
else
{
//
}
43
Ashish Bhandari
CS6004NP Application Development
}
}
///////////////
///
RegisterStudent.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
/// <summary>
/// Interaction logic for Register_student.xaml
/// </summary>
public partial class Register_student : Window
{
string sex = "";
public Register_student()
{
InitializeComponent();
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Close();
RegisterMainWindow RmWindow = new RegisterMainWindow();
RmWindow.Show();
}
44
Ashish Bhandari
CS6004NP Application Development
else
{
//
}
}
if (messageBoxResult == MessageBoxResult.Yes)
{
clear_text();
}
else
{
//
}
}
programBox.Items.Clear();
programBox.Items.Add("Click Load button");
programBox.SelectedItem = "Click Load button";
if (departmentBox.Text == "")
{
facultyBox.Items.Add("Select department first");
facultyBox.SelectedItem = ("Select department first");
}
45
Ashish Bhandari
CS6004NP Application Development
if (valid == false)
{
System.Windows.MessageBox.Show("Number can't be String", "Invalid",
System.Windows.MessageBoxButton.OK,MessageBoxImage.Information);
phone.Clear();
}
//validating student id
private void student_id_TextChanged(object sender, TextChangedEventArgs e)
{
if (valid == false)
{
student_id.Clear();
MessageBox.Show("ID can't be
String","Invalid",System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
46
Ashish Bhandari
CS6004NP Application Development
if (mail_id.Text.Trim() != string.Empty)
if (!mRegxExpression.IsMatch(mail_id.Text.Trim()))
{
System.Windows.MessageBox.Show("E-mail address format is not
correct.", "incorrect format", System.Windows.MessageBoxButton.OK,
MessageBoxImage.Warning);
mail_id.Focus();
}
//register student only if email format is correct
else
{
if (valid == true)
{
passValue();
}
}
//getting gender
47
Ashish Bhandari
CS6004NP Application Development
{
sex = "Other";
}
//clearing inputed text in all text fields
private void clear_text()
{
first_name.Clear();
last_name.Clear();
student_id.Clear();
phone.Clear();
mail_id.Clear();
tmp_address.Clear();
permanent_address.Clear();
religion.Clear();
nationality.Clear();
departmentBox.Items.DeferRefresh();
}
if (facultyBox.Text == "")
{
programBox.Items.Add("Select faculty first");
programBox.SelectedItem = ("Select faculty first");
}
else if (facultyBox.Text == "Select department first" || facultyBox.Text ==
"Click Load button")
{
programBox.Items.Add("Select faculty first");
programBox.SelectedItem = ("Select faculty first");
}
48
Ashish Bhandari
CS6004NP Application Development
}
else if (student_id.Text == "")
{
MessageBox.Show("student_id is required", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else if (phone.Text == "")
{
MessageBox.Show("Phone is required", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else if (phone.Text.Length <5)
{
49
Ashish Bhandari
CS6004NP Application Development
}
else if (sex == "")
{
MessageBox.Show("Gender is required", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else if (tmp_address.Text == "" || permanent_address.Text == "")
{
MessageBox.Show("Address is required", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else if (departmentBox.Text == "")
{
MessageBox.Show("Select one Department ");
return false;
}
else if (facultyBox.Text == "" || facultyBox.Text == "Click Load button" ||
facultyBox.Text == "Select department first")
{
MessageBox.Show("Select one Faculty", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else if (programBox.Text == "" || programBox.Text == "Click Load button" ||
programBox.Text == "Select faculty first")
{
MessageBox.Show("Select one Program", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
else
{
return true;
}
50
Ashish Bhandari
CS6004NP Application Development
if (isnumber == false)
{
return false;
}
else
{
return true;
}
}
this.Hide();
Register_confirm register_Confirm = new Register_confirm(Fname, Lname, Id,
Department, Faculty, Program, Phone, Email, Gender, currentAddr, permanentAddr, Religion,
Nationality, MarritalStatus);
register_Confirm.Show();
if (valid == true)
{
first_name.Clear();
MessageBox.Show("Name can't be Number", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
}
}
51
Ashish Bhandari
CS6004NP Application Development
if (valid == true)
{
last_name.Clear();
MessageBox.Show("Name can't be Number", "Invalid",
System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
}
RegisterBulk.xaml.cs
using FileHelpers;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
52
Ashish Bhandari
CS6004NP Application Development
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
/// <summary>
/// Interaction logic for RegisterBulkStdWindow.xaml
/// </summary>
public partial class RegisterBulkStdWindow : Window
{
private string fileName;
private List<StudentInfo> csvStudentList;
public RegisterBulkStdWindow()
{
InitializeComponent();
}
List<StudentInfo> students = new List<StudentInfo>();
try
53
Ashish Bhandari
CS6004NP Application Development
{
using (StreamReader streamReader = new StreamReader(fileName))
{
streamReader.ReadLine();
}
streamReader.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("Sorry! unexpected Error occured! try again", "Error",
MessageBoxButton.OK, MessageBoxImage.Error);
this.Close();
RegisterMainWindow registerMainWindow = new RegisterMainWindow();
registerMainWindow.Show();
}
return students;
}
fileName = theDialog.FileName;
csvStudentList = ReadAll();
gridView.ItemsSource = csvStudentList;
}
else
{
54
Ashish Bhandari
CS6004NP Application Development
dataSet.WriteXmlSchema(@"D:\Student_Management\StudentRegistrationSchema.xml");
dataSet.WriteXml(@"D:\Student_Management\StudentRegistrationData.xml");
}
MessageBox.Show("Successfully Registered");
this.Close();
RegisterMainWindow registerMainWindow = new RegisterMainWindow();
registerMainWindow.Show();
}
private void AddData(DataSet dataSet)
{
var studentData = ReadAll();
foreach (StudentInfo stdData in studentData)
{
var dr = dataSet.Tables["Student"].NewRow();
dr["Name"] = stdData.Name;
dr["StudentID"] = Convert.ToInt32(stdData.StudentID);
dr["Department"] = stdData.Department;
dr["Faculty"] = stdData.Faculty;
dr["Program"] = stdData.Program;
dr["Phone"] = Convert.ToInt32(stdData.Phone);
dr["Email"] = stdData.Email;
dr["Gender"] = stdData.Gender;
dr["CurrentAddress"] = stdData.CurrentAddress;
dr["PermanentAddress"] = stdData.PermanentAddress;
dr["Religion"] = stdData.Religion;
dr["Nationality"] = stdData.Nationility;
dr["MaritalStatus"] = stdData.MarritalStatus;
dr["RegistrationDate"] = stdData.RegistrationDate;
dataSet.Tables["Student"].Rows.Add(dr);
}
if (messageBoxResult == MessageBoxResult.Yes)
{
this.Hide();
55
Ashish Bhandari
CS6004NP Application Development
}
}
56
Ashish Bhandari
CS6004NP Application Development
this.Nationility = splitedStrings[11];
this.MarritalStatus = splitedStrings[12];
this.RegistrationDate = splitedStrings[13];
}
}
Handler.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
57
Ashish Bhandari
CS6004NP Application Development
namespace Student_info
{
public class Handler
{
public DataSet CreateDataSet()
{
var ds = new DataSet();
ds.Tables.Add(CreateStudentTable());
return ds;
}
//dt.Columns.Add(dataColumn);
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("StudentID", typeof(int));
dt.Columns.Add("Department", typeof(string));
dt.Columns.Add("Faculty", typeof(string));
dt.Columns.Add("Program", typeof(string));
dt.Columns.Add("Phone", typeof(int));
dt.Columns.Add("Email", typeof(string));
dt.Columns.Add("Gender", typeof(string));
dt.Columns.Add("CurrentAddress", typeof(string));
dt.Columns.Add("PermanentAddress", typeof(string));
dt.Columns.Add("Religion", typeof(string));
dt.Columns.Add("Nationality", typeof(string));
dt.Columns.Add("MaritalStatus", typeof(string));
dt.Columns.Add("RegistrationDate", typeof(string));
return dt;
}
var dr = dataSet.Tables["Student"].NewRow();
dr["Name"] = "Ashish Bhandari";
dr["StudentID"] = 17031918;
dr["Depaertment"] = "IT";
dr["Faculty"] = "BIT";
dr["Program"] = "Networking";
dr["Phone"] = 986911390;
dr["Email"] = "[email protected]";
dr["Gender"] = "Male";
dr["CurrentAddress"] = "Ratnachowk-07";
dr["PermanentAddress"] = "Kalika-28";
dr["Reiligion"] = "Hindu";
dr["Nationality"] = "Nepali";
dr["MarritalStatus"] = "Unmarried";
dr["RegistrationDate"] = DateTime.Today;
dataSet.Tables["Student"].Rows.Add(dr);
58
Ashish Bhandari
CS6004NP Application Development
}
}
}
ViewModel.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
59
Ashish Bhandari
CS6004NP Application Development
namespace Student_info
{
class ViewModel
{
string path = @"D:\Student_Management\StudentRegistrationData.xml";
int ITData;
int mgtData;
int eduData;
int ITData2;
int mgtData2;
int eduData2;
public List<Sales> Data { get; set; }
public ViewModel()
{
loadData();
Data = new List<Sales>()
{
new Sales { Week=$"{DateTime.Now.AddDays(-
7).ToString("dd/MM/yyyy")}",ITA= ITData ,EducationB=eduData, ManagementC= mgtData},
new Sales { Week=$"{DateTime.Now.AddDays(-
14).ToString("dd/MM/yyyy")}",ITA= ITData2 ,EducationB=eduData2, ManagementC= mgtData2},
};
}
private void loadData()
{
var handler = new Handler();
if (System.IO.File.Exists(path))
{
dataSet.ReadXml(path);
60
Ashish Bhandari
CS6004NP Application Development
}
}
chartWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
61
Ashish Bhandari
CS6004NP Application Development
using System.Windows.Controls;
using System.Windows.Controls.DataVisualization.Charting;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
/// <summary>
/// Interaction logic for ChartWindow.xaml
/// </summary>
public partial class ChartWindow : Window
{
string path = @"D:\Student_Management\StudentRegistrationData.xml";
int ITData;
int mgtData;
int eduData;
LoadColumnChartData();
}
private void LoadColumnChartData()
{
loadData();
((ColumnSeries)mcChart.Series[0]).ItemsSource =
new KeyValuePair<string, int>[]{
new KeyValuePair<string, int>("IT", ITData),
new KeyValuePair<string, int>("Management", mgtData),
new KeyValuePair<string, int>("Education", eduData)
};
try
{
if (System.IO.File.Exists(path))
{
dataSet.ReadXml(path);
62
Ashish Bhandari
CS6004NP Application Development
DataTable dv = stdReportTbl.Select("").CopyToDataTable();
//filtering date of one week
//filtering date of one week
//counting total number of student registered in a week
//counting total number of student registered in a week
ITData = stdReportTbl.Select("Department = 'IT' AND
RegistrationDate>='" + DateTime.Today.AddDays(-7) + "'").Count<DataRow>();
mgtData = stdReportTbl.Select("Department = 'Management' AND
RegistrationDate>='" + DateTime.Today.AddDays(-7) + "'").Count<DataRow>();
eduData = stdReportTbl.Select("Department = 'Education' AND
RegistrationDate>='" + DateTime.Today.AddDays(-7) + "'").Count<DataRow>();
}
else
{
System.Windows.MessageBox.Show("Sorry! XML file is missing", "FIle
Not Found", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show("Sorry! Error occured", "Error",
MessageBoxButton.OK, MessageBoxImage.Error);
this.Close();
ReportMainWindow rpw = new ReportMainWindow();
rpw.Show();
}
}
}
}
}
ViewWeeklyReport.xaml.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
63
Ashish Bhandari
CS6004NP Application Development
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Student_info
{
/// <summary>
/// Interaction logic for WeeklyReportWindow.xaml
/// </summary>
public partial class WeeklyReportWindow : Window
{
string path = @"D:\Student_Management\StudentRegistrationData.xml";
int ITData;
int mgtData;
int eduData;
int BITData;
int CSITData;
int literatureData;
int teachingData;
int bbaData;
int bbsData;
public WeeklyReportWindow()
{
InitializeComponent();
loadData();
}
private void loadData()
{
var handler = new Handler();
try
{
if (System.IO.File.Exists(path))
{
dataSet.ReadXml(path);
64
Ashish Bhandari
CS6004NP Application Development
//faculty
bitLbl.Content = BITData;
CSITLbl.Content = CSITData;
literatureLbl.Content = literatureData;
teachingLbl.Content = teachingData;
bbaLbl.Content = bbaData;
bbsLbl.Content = bbsData;
}
else
{
System.Windows.MessageBox.Show("Sorry! XML file is missing", "FIle
Not Found", MessageBoxButton.OK, MessageBoxImage.Error);
}
}catch (Exception ex)
{
System.Windows.MessageBox.Show("Sorry! Error occured", "Error",
MessageBoxButton.OK, MessageBoxImage.Error);
this.Close();
ReportMainWindow rpw = new ReportMainWindow();
rpw.Show();
}
}
65
Ashish Bhandari