Uploaded by samadhi warsha

C assignment

advertisement
Task 01
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 1
Discuss
the
pillar
concepts
of
Object
Oriented
Programming
and
provide
a comprehensive report which includes definitions, characteristics, purposes of using and
demonstrate applications of these pillar concepts with examples (preferably from your
solution).
1.1 Introduction to Object Oriented Programming
Object-oriented programming (OOP) is a programming language model organized around objects
instead of "actions" and data instead of logic. Traditionally, a program has been viewed as a logical
procedure that takes input data, processes it, and produces output data. (techtarget, 2018)
1.2 Pillar concepts of Object Oriented Programming
Encapsulation
Inheritance
Object Oriented
Programming
Abstraction
Polymorphism
Figure 1 Pillar concepts of OOP (Author Developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 2
1.2.1 Encapsulation
Encapsulation is an Object Oriented Programming concept that bind a group of related properties,
functions, and other members are treated as a single unit. Class is the best example of Data
Encapsulation. It sometimes referred to as data hiding that prevents the user to access the
implementation details. Encapsulation therefore guarantees the integrity of the data contained in
the Object. (net-informations, 2018)
Usage of Encapsulation in real life
When a person log into his email account he has a whole lot of processes taking place in the
backend, which he has no control over. So his password, would possibly be retrieved in an
encrypted form, verified and only then given access. He does not have any control, over how the
password is verified, and this keeps it safe from misuse.
Advantages of Encapsulation
 Encapsulation promotes maintenance
 Code changes can be made independently
 Increases usability
-
Improves the understandability of the program.
-
As the data members and functions are bundled inside the class, human errors are
reduced.
-
Encapsulation is alone a powerful feature that leads to information hiding, abstract data
type and friend functions.
-
Ensures the changes easily without affecting rest application code
-
Reduces complexity through hiding information
-
Easily maintained
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 3
Application of encapsulation to the solution
private void ProfLogBtn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(conString);
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Prof_login
where Username='" + txtUsername.Text + "' and Password='" + txtPassword.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
ProfessorRegistration ss = new ProfessorRegistration();
ss.Show();
MessageBox.Show("You are logged in");
}
else
MessageBox.Show("Please Check Your Username & Password");
}
Figure 2 application of encapsulation to the system
1.2.2 Inheritance
Source: (Author developed)
1.2.2 Inheritance
Inheritance is a fundamental feature of an Object-Oriented programming. It is the process of
creating a new Class, called the Derived Class, from the existing class, called the Base Class.
Inheritance is a very elegant way to reuse and modify the data and functionality that has already
been defined in the Base Class, also you can add new data and functionality to the Derived Class.
Since the Derived Class inherits all properties of the Base Class, the Derived Class has a larger set
of properties than the Base Class. However, the Derived Class may override some or all the
properties of the Base Class. (net-informations, 2018)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 4
Usage of Inheritance in real life
The real life example of inheritance is child and parents, all the properties of father are inherited
by his son.
Advantages of Inheritance

One of the key benefits of inheritance is to minimize the amount of duplicate code in
an application by sharing common code amongst several subclasses. Where equivalent
code exists in two related classes, the hierarchy can usually be refactored to move the
common code up to a mutual superclass. This also tends to result in a better
organization of code and smaller, simpler compilation units.

Inheritance can also make application code more flexible to change because classes
that inherit from a common superclass can be used interchangeably. If the return type
of a method is superclass.

Reusability - facility to use public methods of base class without rewriting the same.

Extensibility - extending the base class logic as per business logic of the derived class.

Data hiding - base class can decide to keep some data private so that it cannot be altered
by the derived class.

Overriding - With inheritance, we will be able to override the methods of the base class
so that meaningful implementation of the base class method can be designed in the
derived class.
1.2.3 Abstraction
Abstraction is the process of taking away or removing characteristics from something in order to
reduce it to a set of essential characteristics. (techtarget, 2018)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 5
Usage of Abstraction in real life
In a car we now think of as a car driver or a person traveling in a car. So, to drive a car, what a car
driver should know and what not.
Necessary things
̵
Brake
̵
Gear
̵
Government
Unnecessary things
̵
sewerage system
̵
Gooseberry
Advantages of Abstraction

Makes code as readable and more- simpler. Because complexity of code will be hidden.

Abstraction makes code from longer to small, because abstraction doesn't show
unnecessary things.

Abstraction gives one structure to program code.
Application of abstraction to the solution
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
RegistrarMenu ss = new RegistrarMenu();
ss.Show();
MessageBox.Show("You are logged in");//Abstraction used to messege box
}
else
Figure 3 Application of abstraction to the solution
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 6
1.2.4 Polymorphism
Polymorphism is an object-oriented programming concept that refers to the ability of a variable,
function or object to take on multiple forms. A language that features polymorphism allows
developers to program in the general rather than program in the specific. (techopedia, 2018)
Usage of Polymorphism in real life
We use milk for drinking, but milk can also be used to make curd, butter etc. So, the term
polymorphism means to use something in different forms.
Advantages of Polymorphism

It helps programmers reuse the code and classes once written, tested and implemented.
They can be reused in many ways.

Single variable name can be used to store variables of multiple data types.

Polymorphism helps in reducing the coupling between different functionalities.
1.4 Advantages of Object oriented programming

The programs written with OOP are really easy to understand.

Since everything is treated as objects, so can model a real-world concept using OOP.

OOP approach offers the reusability of classes. Can reuse the classes that are already
created without writing them again and again.

Since the parallel development of classes is possible in OOP concept, it results in the quick
development of the complete programs.

Programs written in OOP technique are marginally easier to test, manage as well as
maintain.
It is a secured development technique since data is hidden and can’t be accessed by external
functions. (csetutor, 2018)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 7
1.5 Advantages of Object oriented programming

Sometimes, the relation among the classes become artificial in nature.

Designing a program in OOP concept is a little bit tricky.

The programmer should have a proper planning before designing a program using OOP
approach.

Since everything is treated as objects in OOP, the programmers need proper skill such as
design skills, programming skills, thinking in terms of objects etc.

The size of programs developed with OOP is larger than the procedural approach.

Since larger in size, that means more instruction to be executed, which results in the slower
execution of programs.
(csetutor, 2018)
1.6 Introduction to C# programming language
C# could theoretically be compiled to machine code, but in real life, it's always used in
combination with the .NET framework. Therefore, applications written in C#, requires the .NET
framework to be installed on the computer running the application. While the .NET framework
makes it possible to use a wide range of languages, C# is sometimes referred to as THE .NET
language, perhaps because it was designed together with the framework. C# is an Object Oriented
language and does not offer global variables or functions. Everything is wrapped in classes, even
simple types like int and string, which inherits from the System. Object class. (csharp, 2018)
1.7 Advantages of C# programming language
According to proprogrammershub (n.d) Following are the advantages of C# programming
language.

C# is pure object-oriented language, this allows you to create modular maintainable
applications and reusable codes. This is one of the biggest advantages of C# over C++.
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 8

C# has got a very efficient system to erase and remove all the garbage present on the
system.

The rich class libraries make many functions easy to be implemented. C# has influence on
most of the programmers of the world and it has a history in the programming world.

Applications written in .NET will have better integration and interpretability with other
NET Technologies. Actually C# runs on CLR, making it easy to integrate with components
written in other languages.

Formalized concept of get-set methods, so the codes becomes more legible. Also in C#, no
need to worry about header files. Coding would be a worth to do in C#.

C# has a strong memory backup. There would be no problem of the memory leak.
Conclusion
It is require to develop a Student Registration System for Stafford University (SU). There are
several requirements to be fulfill. By considering advantages of C# it is better to use C# to develop
the student registration for SU. C# has many key features and technical characteristics. After
considers features and benefits of C# language, it would be the best software solution to build SU
system.
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 9
Task 02
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 10
Identify the objects and data and file structures required to implement a given design.
2.1 Object
Object, in C#, is an instance of a class that is created dynamically. Object is also a keyword that is
an alias for the predefined type System. Object in the .NET framework.
The unified type system of C# allows objects to be defined. These can be user-defined, reference
or value type, but they all inherit directly or indirectly from System. Object. This inheritance is
implicit so that the type of the object need not be declared with System. Object as the base class.
In general, object type is useful where there is a requirement to build generic routines. Because
values of any type can be assigned to variables of object type, object type is used mostly in
designing classes that handle objects of any type that allow code to be reused. The non-generic
collection classes in the .NET framework library, such as ArrayList, Queue, etc., use object type
to define various collections. An object is also known as instance. (techopedia, 2018)
2.2 Class
A class is a construct that enables you to create your own custom types by grouping together
variables of other types, methods and events. A class is like a blueprint. It defines the data and
behavior of a type. (microsoft, 2018)
(wordane)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 11
2.3 Data Structures
A data structure is a specialized format for organizing and storing data. General data structure
types include the array, the file, the record, the table, the tree, and so on. Any data structure is
designed to organize data to suit a specific purpose so that it can be accessed and worked with in
appropriate ways. In computer programming, a data structure may be selected or designed to store
data for the purpose of working on it with various algorithms. (techtarget, 2018)
Following are the general data structures that can be found frequently.
Array- An array is a data structure that contains a group of elements. Typically these elements are
all of the same data type, such as an integer or string. Arrays are commonly used in computer
programs to organize data so that a related set of values can be easily sorted or searched.(techterms,
2018)
List- A group of similar items with connectivity to the previous or/and next data items.
Record- A set of fields, where each field consists of data belongs to one data type.
Trees- A data structure where the data is organized in a hierarchical structure. This type of data
structure follows the sorted order of insertion, deletion and modification of data items.
Tables- Data is persisted in the form of rows and columns. These are similar to records, where
the result or manipulation of data is reflected for the whole table. (careerride,2016)
Objects, files and data structures of Stafford university system.
Table 1-Objects, files and data structures of Stafford University System Source :( Author Developed)
Objects
Data
Data Types
File structure
Register Office
Payment Details
Integer
Generate course catalog
Contact Information
Integer
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 12
Student
Register
Professor
Course Name
String
Course Duration
Integer
Payments
Integer
Selected Courses
String
Student Name
String
Student date of birth
Date
Contact
Integer
Student Name
String
Student Contact
Integer
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Register for courses
Register Students
Select courses to teach
Page 13
Task 03
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 14
Draw the Use Case Diagram, Class Diagram and Sequence Diagrams, ERD for the given
scenario. Use Case diagram should be supported with the Use Case narrations.
3.1 Use case diagram
Figure 4 Use case diagram for proposed system
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 15
3.2 Class diagram
Class diagram describes the structure of proposed system by showing the system's classes, its
attributes, operations and the relationships among objects.
Figure 5 Class diagram for proposed system
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 16
3.3 Sequence diagram
Figure 6 Sequence diagram for proposed system
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 17
3.4 ER Diagram
Figure 7 ER diagram for proposed system
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 18
Task 04
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 19
Implement the Object Oriented solution using C#.Net for the proposed Design using a
suitable IDE.
4.1 User login
The login page of the Stafford university system’s shown as below. User requires a valid username
and password to login to the system.
Figure 8 User login of the system
Source :(Author developed)
Source code of login form
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
txtPassword.PasswordChar = '*';
txtPassword.MaxLength = 10;
}
//database connection
public string conString = "Data Source=DESKTOP-2JUL9IR\\SQLEXPRESS;Initial
Catalog=stafford_uni;Integrated Security=True";
private void exitbtn_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 20
{
this.Close();
}
}
private void loginbtn_Click(object sender, EventArgs e)
{
//encapsulated data,hidden
SqlConnection con = new SqlConnection(conString);
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Stu_Login where
Username='" + txtUsername.Text + "' and Password='" + txtPassword.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
StudentRegistration ss = new StudentRegistration();
ss.Show();
MessageBox.Show("You are logged in");//Abstraction used to messege box
}
else
MessageBox.Show("Please Check Your Username & Password");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_Validating(object sender, CancelEventArgs e)
{
}
private void ProfLogBtn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(conString);
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Prof_login
where Username='" + txtUsername.Text + "' and Password='" + txtPassword.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
ProfessorRegistration ss = new ProfessorRegistration();
ss.Show();
MessageBox.Show("You are logged in");//Abstraction used to messege box
}
else
MessageBox.Show("Please Check Your Username & Password");
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 21
}
private void RegLogBtn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(conString);
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Admin_Login
where Username='" + txtUsername.Text + "' and Password='" + txtPassword.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
RegistrarMenu ss = new RegistrarMenu();
ss.Show();
MessageBox.Show("You are logged in");//Abstraction used to messege box
}
else
MessageBox.Show("Please Check Your Username & Password");
}
4.2 Registrar menu
Below menu is loaded when registrar login to the system
Figure 9 Registrar menu
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 22
Source code for registrar menu
{
public partial class RegistrarMenu : Form
{
public RegistrarMenu()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void btnStuReg_Click(object sender, EventArgs e)
{
this.Hide();//Hide the form
RegistrarStudentRegistration openForm = new RegistrarStudentRegistration();
openForm.Show();
}
private void Main_Load(object sender, EventArgs e)
{
}
private void btnProfReg_Click(object sender, EventArgs e)
{
this.Hide();
RegistrarProfessorRegistration openForm = new
RegistrarProfessorRegistration();
openForm.Show();//display new form
}
private void btnCourseCatalog_Click(object sender, EventArgs e)
{
this.Hide();
CourseCatalog openForm = new CourseCatalog();
openForm.Show();
}
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 23
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)//exit validation
{
this.Close();
}
}
private void btnLogout_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
Login sb = new Login();
sb.Show();
}
}
private void btnPayments_Click(object sender, EventArgs e)
{
this.Hide();
PaymentsViewer openForm = new PaymentsViewer();
openForm.Show();
}
}
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 24
4.3 Student Registration Form in Registrar Menu.
To register student for registrar below form should be filled
Figure 10 Student registration form for registrar
Source: (Author developed)
Source code for student registration in registrar menu
{
public RegistrarStudentRegistration()
{
InitializeComponent();
}
//Database connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP2JUL9IR\SQLEXPRESS;Initial Catalog=stafford_uni;Integrated Security=True");
private void textBox3_TextChanged(object sender, EventArgs e)
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 25
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)//checking the decision
{
this.Close();
}
}
private void RegistrarStudentRegistration_Load(object sender, EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("Select isnull (max(cast(Stu_Reg_No
as int)),0)+1 from Std_Reg_Table", con);
DataTable dt = new DataTable();
sda.Fill(dt);
txtStuRegNo.Text = dt.Rows[0][0].ToString();
this.ActiveControl = txtName;
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees";
cmd.ExecuteNonQuery();//execute the query
DataTable dd = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dd);
foreach (DataRow dr in dd.Rows)
{
txtSelectedCourse.Items.Add(dr["Course_Name"].ToString());
}
con.Close();
}
private void btnReg_Click(object sender, EventArgs e)
{
//check whether the fields are empty
if (txtName.Text == "" || txtAddress.Text == "" || txtContact.Text == "" ||
txtSelectedCourse.Text == "" || txtAlternativeCourse.Text == "")
{
MessageBox.Show("Please fill the blank fields");
}
else
{
int _numOfStudent = 0;
try
{
//select query to be executed
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 26
string sql = "SELECT Selected_Course, count(*) as num_of_students
FROM [stafford_uni].[dbo].[Std_Reg_Table] group by Selected_Course;";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow[] returnRow = ds.Tables[0].Select("Selected_Course = '" +
txtSelectedCourse.Text + "'");
DataRow dr = returnRow[0];
_numOfStudent = Convert.ToInt16(dr["num_of_students"].ToString());
//
MessageBox.Show(_numOfStudent.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "count number of students");
}
if (_numOfStudent < 10)//
{
con.Open();
//Insert query to be executed
String query = "INSERT INTO
Std_Reg_Table(Stu_Reg_No,Name,Address,Contact_No,Selected_Course,Alternative_Course,Semes
ter_Fee,University_Charges,Total_Course_Fee) VALUES ('" + txtStuRegNo.Text + "', '" +
txtName.Text + "', '" + txtAddress.Text + "','" + txtContact.Text + "','" +
txtSelectedCourse.Text + "', '" + txtAlternativeCourse.Text + "','" + txtSemFee.Text +
"','" + txtUniCharges.Text + "','"+ txtTotal.Text+"' )";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("You are Registered Successfully");
this.Hide();
RegistrarStudentRegistration ss = new RegistrarStudentRegistration();
ss.Show();
BillingViewer rptv = new BillingViewer(txtStuRegNo.Text,
txtName.Text, txtSelectedCourse.Text, txtSemFee.Text, txtUniCharges.Text, txtTotal.Text);
rptv.Show();//crystal report view
}
else
{
MessageBox.Show("No seats available.Please select another course");
}
}
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 27
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees where Course_Name= '" +
txtSelectedCourse.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtSemFee.Text = dr["Semester_Fee"].ToString();
txtUniCharges.Text = dr["University_Charges"].ToString();
txtTotal.Text = dr["Total_Course_Fee"].ToString();
}
con.Close();
}
private void btnBack_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
RegistrarMenu sb = new RegistrarMenu();
sb.Show();
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure", "Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
con.Open();
//Delete query to be executed
String query = "DELETE FROM Std_Reg_Table where Stu_Reg_No= '" +
txtStuRegNo.Text+ "'";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Selected Record is Deleted Successfully");
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 28
this.Hide();
RegistrarStudentRegistration ss = new RegistrarStudentRegistration();
ss.Show();
}
else
{
MessageBox.Show("Selected Record is not Deleted", "Delete",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btnView_Click(object sender, EventArgs e)
{
con.Open();//open connection
String sql = "select
Stu_Reg_No,Name,Address,Contact_No,Selected_Course,Alternative_Course,Semester_Fee,Univer
sity_Charges,Total_Course_Fee from Std_Reg_Table";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();//close connection
}
private void btnUpdate_Click(object sender, EventArgs e)
{
con.Open();
//Update query to be executed
String sql = "UPDATE Std_Reg_Table SET Name='" +txtName.Text +"',Address='"
+txtAddress.Text +"',Contact_No='" +txtContact.Text +"',Selected_Course='"
+txtSelectedCourse.Text +"',Alternative_Course='" +txtAlternativeCourse.Text
+"',Semester_Fee='" +txtSemFee.Text +"',University_Charges='" +txtUniCharges.Text
+"',Total_Course_Fee='" +txtTotal.Text + "'WHERE Stu_Reg_No='" + txtStuRegNo.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");
}
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
txtStuRegNo.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
txtName.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
txtAddress.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
txtContact.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
txtSelectedCourse.Text =
dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 29
txtAlternativeCourse.Text =
dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
txtSemFee.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
txtUniCharges.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
txtTotal.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
}
private void RegistrarStudentRegistration_FormClosing(object sender,
FormClosingEventArgs e)
{
}
private void btnHelp_Click(object sender, EventArgs e)
{
RegistrarStuHelpMenu sb = new RegistrarStuHelpMenu();
sb.Show();
}
}
}
4.4 Professor Registration Form in Registrar Menu.
To register a professor registrar must fill below form
Figure 11 Professor Registration for registrar
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 30
Source code for professor registration in registrar menu
{
public partial class RegistrarProfessorRegistration : Form
{
public RegistrarProfessorRegistration()
{
InitializeComponent();
}
//Database Connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP2JUL9IR\SQLEXPRESS;Initial Catalog=stafford_uni;Integrated Security=True");
private void btnDelete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure", "Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
con.Open();
//Delete query to be executed
String query = "DELETE FROM Prof_Reg_Table where Prof_Reg_No= '" +
comboProfRegNo.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Selected Record is Deleted Successfully");
this.Hide();
RegistrarProfessorRegistration ss = new RegistrarProfessorRegistration();
ss.Show();
}
else
{
MessageBox.Show("Selected Record is not Deleted", "Delete",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btnReg_Click(object sender, EventArgs e)
{
if (comboProfRegNo.Text == "" || comboFaculty.Text == "" || comboSem.Text ==
"" || comboCourse1.Text == "" || comboCourse2.Text == "")
{
MessageBox.Show("Please fill the blank fields");//validation
}
else
{
int _numOfStudent = 0;
try
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 31
//Get the count form the database
string sql = "SELECT Selected_Course, count(*) as num_of_students
FROM [stafford_uni].[dbo].[Std_Reg_Table] group by Selected_Course;";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow[] returnRow = ds.Tables[0].Select("Selected_Course = '" +
comboCourse1.Text + "'");
DataRow dr = returnRow[0];
_numOfStudent = Convert.ToInt16(dr["num_of_students"].ToString());
//
MessageBox.Show(_numOfStudent.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "count number of students");
}
if (_numOfStudent > 3)//check whether the no of students
{
con.Open();
//Insert query to be executed
String query = "INSERT INTO
Prof_Reg_Table(Prof_Reg_No,Name,Faculty,Semester,Course1,Course2) VALUES
comboProfRegNo.Text + "', '" + txtName.Text + "', '" + comboFaculty.Text
comboSem.Text + "','" + comboCourse1.Text + "', '" + comboCourse2.Text +
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Successfully Updated");
are less than 3
('" +
+ "','" +
"')";
this.Hide();
RegistrarProfessorRegistration ss = new
RegistrarProfessorRegistration();
ss.Show();
}
else
{
MessageBox.Show("This course has been cancelled.Please select another
course");
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 32
if (dialog == DialogResult.Yes)//validate the decision
{
this.Close();
}
}
private void RegistrarProfessorRegistration_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees";
cmd.ExecuteNonQuery();//execute the query
DataTable dd = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dd);
foreach (DataRow dr in dd.Rows)
{
comboViewStudents.Items.Add(dr["Course_Name"].ToString());
comboCourse1.Items.Add(dr["Course_Name"].ToString());
comboCourse2.Items.Add(dr["Course_Name"].ToString());
}
cmd.CommandText = "select * from Prof_Details";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter db = new SqlDataAdapter(cmd);
db.Fill(dt);
foreach (DataRow ds in dt.Rows)
{
comboProfRegNo.Items.Add(ds["Prof_Reg_No"].ToString());
comboViewRoster.Items.Add(ds["Prof_Reg_No"].ToString());
}
con.Close();
}
private void btnViewStudents_Click(object sender, EventArgs e)
{
if (comboViewStudents.Text == "")
{
MessageBox.Show("Please select a course");
}
else
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 33
con.Open();
String sql = "select * from Std_Reg_Table where Selected_Course= '" +
comboViewStudents.SelectedItem.ToString() + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
RegistrarMenu sb = new RegistrarMenu();
sb.Show();
}
}
private void btnViewProfDetails_Click(object sender, EventArgs e)
{
con.Open();
//Select query to be executed
String sql = "select Prof_Reg_No,Name,Faculty,Semester,Course1,Course2 from
Prof_Reg_Table";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
con.Open();
//Update query to be executed
String sql = "UPDATE Prof_Reg_Table SET Name='" + txtName.Text +
"',Faculty='" + comboFaculty.Text + "',Semester='" + comboSem.Text + "',Course1='" +
comboCourse1.Text + "',Course2='" + comboCourse2.Text + "'WHERE Prof_Reg_No='" +
comboProfRegNo.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 34
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
comboProfRegNo.Text =
dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
txtName.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
comboFaculty.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
comboSem.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
comboCourse1.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
comboCourse2.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Prof_Details where Prof_Reg_No= '" +
comboProfRegNo.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtName.Text = dr["Name"].ToString();
comboFaculty.Text = dr["Faculty"].ToString();
}
con.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void btnViewRoster_Click(object sender, EventArgs e)
{
if (comboViewRoster.Text == "")
{
MessageBox.Show("Please select a your reg.no");
}
else
{
con.Open();//open connection
String sql = "select * from Course_Roster where Prof_Reg_No= '" +
comboViewRoster.SelectedItem.ToString() + "'";
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 35
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();//close connection
}
}
private void RegistrarProfessorRegistration_FormClosing(object sender,
FormClosingEventArgs e)
{
}
private void btnHelp_Click(object sender, EventArgs e)
{
RegistrarProfHelpMenu sb = new RegistrarProfHelpMenu();
sb.Show();
}
4.5 View course catalog
For course catalog registrar must use below form
Figure 12 Course catalog
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 36
Source code for view course catalog
{
public CourseCatalog()
{
InitializeComponent();
}
//Database connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP2JUL9IR\SQLEXPRESS;Initial Catalog=stafford_uni;Integrated Security=True");
private void CourseCatalog_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Prof_Details";
cmd.ExecuteNonQuery();
DataTable dd = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dd);
foreach (DataRow dr in dd.Rows)
{
txtProfReg.Items.Add(dr["Prof_Reg_No"].ToString());
}
cmd.CommandText = "select * from Course_Fees";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter db = new SqlDataAdapter(cmd);
db.Fill(dt);
foreach (DataRow ds in dt.Rows)
{
comboSelectCourseRoster.Items.Add(ds["Course_Name"].ToString());
}
con.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Prof_Reg_Table where Prof_Reg_No= '" +
txtProfReg.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 37
txtCourseName.Text = dr["Course1"].ToString();
txtProfName.Text = dr["Name"].ToString();
}
con.Close();
}
private void btnGenerate_Click(object sender, EventArgs e)
{
if (comboMonth.Text == "" || txtProfReg.Text == "" || comboTimeW1.Text == ""
|| comboTimeW2.Text == "" || comboTimeW3.Text == "" || comboTimesW4.Text == "" ||
dateTimePickerW1.Text == "" || dateTimePickerW2.Text == "" || dateTimePickerW3.Text == ""
|| dateTimePickerW4.Text == "")
{
MessageBox.Show("Please fill the blank fields");//empty fields validation
}
else
{
con.Open();
//Insert query tobeexecuted
String query = "INSERT INTO
Course_Roster(Month,Prof_Reg_No,Course_Name,Professor_Name,Week1_Date,Week1_Time,Week2_Da
te,Week2_Time,Week3_Date,Week3_Time,Week4_Date,Week4_Time) VALUES ('" + comboMonth.Text +
"','" + txtProfReg.Text + "', '" + txtCourseName.Text + "', '" + txtProfName.Text + "','"
+ this.dateTimePickerW1.Text + "' ,'" + comboTimeW1.Text + "','" +
this.dateTimePickerW2.Text + "','" + comboTimeW2.Text + "','" +
this.dateTimePickerW3.Text + "','" + comboTimeW3.Text + "','" +
this.dateTimePickerW4.Text + "','" + comboTimesW4.Text + "')";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Course Roster was Generated Successfully");
this.Hide();
CourseCatalog ss = new CourseCatalog();
ss.Show();
}
}
private void btnViewFullRoster_Click(object sender, EventArgs e)
{
con.Open();//Open connection
String sql = "select * from Course_Roster";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();//Close connection
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 38
private void btnViewCourse_Click(object sender, EventArgs e)
{
if (comboSelectCourseRoster.Text == "")
{
MessageBox.Show("Please select a course");
}
else
{
con.Open();
//Select query to be executed
String sql = "select * from Course_Roster where Course_Name= '" +
comboSelectCourseRoster.SelectedItem.ToString() + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
private void label6_Click(object sender, EventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
RegistrarMenu sb = new RegistrarMenu();
sb.Show();
}
}
private void btnUpdate_Click(object sender, EventArgs e)
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 39
con.Open();
//Update query to be executed
String sql = "UPDATE Course_Roster SET Month='" + comboMonth.Text +
"',Course_Name='" + txtCourseName.Text + "',Professor_Name='" + txtProfName.Text +
"',Week1_Date='" + this.dateTimePickerW1.Text + "',Week1_Time='" + comboTimeW1.Text +
"',Week2_Date='" + this.dateTimePickerW2.Text + "',Week2_Time='" + comboTimeW2.Text +
"',Week3_Date='" + this.dateTimePickerW3.Text + "',Week3_Time='" + comboTimeW3.Text +
"',Week4_Date='" + this.dateTimePickerW4.Text + "',Week4_Time='" + comboTimesW4.Text +
"'WHERE Prof_Reg_No='" + txtProfReg.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");//Operation success messege
this.Hide();
CourseCatalog ss = new CourseCatalog();
ss.Show();
}
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
comboMonth.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
txtProfReg.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
txtCourseName.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
txtProfName.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
dateTimePickerW1.Text =
dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
comboTimeW1.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
dateTimePickerW2.Text =
dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
comboTimeW2.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
dateTimePickerW3.Text =
dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
comboTimeW3.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
dateTimePickerW4.Text =
dataGridView1.SelectedRows[0].Cells[10].Value.ToString();
comboTimesW4.Text = dataGridView1.SelectedRows[0].Cells[11].Value.ToString();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure", "Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
con.Open();
//Delete query to be executed
String query = "DELETE FROM Course_Roster where Prof_Reg_No= '" +
txtProfReg.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();//Execute the query
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 40
con.Close();
MessageBox.Show("Selected Record is Deleted Successfully");
this.Hide();
CourseCatalog ss = new CourseCatalog();
ss.Show();
} else
{
MessageBox.Show("Selected Record is not Deleted", "Delete",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btnHelp_Click(object sender, EventArgs e)
{
CourseCatalogHelpMenu sb = new CourseCatalogHelpMenu();
sb.Show();
}
}
}
4.9 Billing system
Registrar must use this form to print the billing system
Figure 13 Billing system
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 41
Source code for billing system
{
public PaymentsViewer()
{
InitializeComponent();
}
//Database connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP2JUL9IR\SQLEXPRESS;Initial Catalog=stafford_uni;Integrated Security=True");
private void PaymentsDataGridViewer_Load(object sender, EventArgs e)
{
con.Open();//Open connection
//Select query to be executed
String sql = "select
Stu_Reg_No,Name,Selected_Course,Semester_Fee,University_Charges,Total_Course_Fee from
Std_Reg_Table";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
PaymentsdataGridView.DataSource = dt;
con.Close();//close connection
}
private void PaymentsdataGridView_MouseDoubleClick(object sender, MouseEventArgs
e)
{
txtStuRegNo.Text =
PaymentsdataGridView.SelectedRows[0].Cells[0].Value.ToString();
txtName.Text =
PaymentsdataGridView.SelectedRows[0].Cells[1].Value.ToString();
txtCourse.Text =
PaymentsdataGridView.SelectedRows[0].Cells[2].Value.ToString();
txtSemfee.Text =
PaymentsdataGridView.SelectedRows[0].Cells[3].Value.ToString();
txtUniCharges.Text =
PaymentsdataGridView.SelectedRows[0].Cells[4].Value.ToString();
txtTotal.Text =
PaymentsdataGridView.SelectedRows[0].Cells[5].Value.ToString();
}
private void btnPrint_Click(object sender, EventArgs e)
{
BillingViewer rptv = new BillingViewer(txtStuRegNo.Text, txtName.Text,
txtCourse.Text, txtSemfee.Text, txtUniCharges.Text, txtTotal.Text);
rptv.Show();//view crystal report
}
private void PaymentsDataGridViewer_FormClosing(object sender,
FormClosingEventArgs e)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 42
{
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)//exit validation
{
this.Close();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
RegistrarMenu sb = new RegistrarMenu();
sb.Show();
}
}
private void btnHelp_Click(object sender, EventArgs e)
{
PaymentsHelpMenu sb = new PaymentsHelpMenu();
sb.Show();
}
}
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 43
4.7 Student Registration Form.
Students must use following window to register a new student to the system.
Figure 14 Student registration form
Source: (Author developed)
Source code for student registration form
//Database Connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-SSQJ4LL\SQLEXPRESS;Initial
Catalog=SU Student Mangement System;Integrated Security=True");
private void btnReg_Click(object sender, EventArgs e)
{
if (txtName.Text == "" || txtAddress.Text == "" || txtContact.Text == "" ||
comboSelectedCourse.Text == "" || comboAlternativeCourse.Text == "")
{
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 44
MessageBox.Show("Please fill the blank fields");//validation
}
else
{
int _numOfStudent = 0;
try
{
//SELECT query to be executed
string sql = "SELECT Selected_Course, count(*) as num_of_students
FROM [SU Student Mangement System].[dbo].[Std_Reg_Table] group by Selected_Course;";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow[] returnRow = ds.Tables[0].Select("Selected_Course = '" +
comboSelectedCourse.Text + "'");
DataRow dr = returnRow[0];
_numOfStudent = Convert.ToInt16(dr["num_of_students"].ToString());
//
MessageBox.Show(_numOfStudent.ToString());
}
catch (Exception ex)
{
}
if (_numOfStudent < 10)
{
con.Open();
//Insert query to be executed
String query = "INSERT INTO
Std_Reg_Table(Stu_Reg_No,Name,Address,Contact_No,Selected_Course,Alternative_Course,Sem
ester_Fee,University_Charges,Total_Course_Fee) VALUES ('" + RegNoTxt.Text + "', '" +
txtName.Text + "', '" + txtAddress.Text + "','" + txtContact.Text + "','" +
comboSelectedCourse.Text + "', '" + comboAlternativeCourse.Text + "' ,'" +
txtSemFee.Text + "','" + txtUniCharges.Text + "','" + txtTotal.Text + "')";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();//Execute the query
con.Close();
MessageBox.Show("You are Registered Successfully");//Show success messege
this.Hide();
StudentRegistration ss = new StudentRegistration();
ss.Show();
BillingViewer rptv = new BillingViewer(RegNoTxt.Text, txtName.Text,
comboSelectedCourse.Text,txtSemFee.Text,txtUniCharges.Text,txtTotal.Text);
rptv.Show();//crystal report view
}
else
{
MessageBox.Show("No seats available.Please select another course");
}
}
}
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 45
private void StudentRegistration_Load(object sender, EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("Select isnull (max(cast(Stu_Reg_No
as int)),0)+1 from Std_Reg_Table",con);
DataTable dt = new DataTable();
sda.Fill(dt);
RegNoTxt.Text = dt.Rows[0][0].ToString();
this.ActiveControl = txtName;
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees";
cmd.ExecuteNonQuery();
DataTable dd = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dd);
foreach (DataRow dr in dd.Rows)
{
comboSelectedCourse.Items.Add(dr["Course_Name"].ToString());
}
cmd.CommandText = "select * from Std_Reg_Table";
cmd.ExecuteNonQuery();
DataTable dl = new DataTable();
SqlDataAdapter db = new SqlDataAdapter(cmd);
db.Fill(dl);
foreach (DataRow ds in dl.Rows)
{
// comboBox3.Items.Add(ds["Stu_Reg_No"].ToString());
}
con.Close();
}
private void exitbtn_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?",
"Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees where Course_Name= '" +
comboSelectedCourse.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 46
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtSemFee.Text = dr["Semester_Fee"].ToString();
txtUniCharges.Text = dr["University_Charges"].ToString();
txtTotal.Text = dr["Total_Course_Fee"].ToString();
}
con.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?",
"Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Hide();
Login sb = new Login();
sb.Show();
}
}
private void btnViewRegDetails_Click(object sender, EventArgs e)
{
if (txtViewRegDetails.Text == "")
{
MessageBox.Show("Please select your Reg.No");//validation
}
else
{
con.Open();
//select query to be executed
String sql = "select
Stu_Reg_No,Name,Address,Contact_No,Selected_Course,Alternative_Course,Semester_Fee,Univ
ersity_Charges,Total_Course_Fee from Std_Reg_Table where Stu_Reg_No= '" +
txtViewRegDetails.Text.ToString() + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
int _numOfStudent = 0;
try
{
//Get the count from the database
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 47
string sq = "SELECT Selected_Course, count(*) as num_of_students FROM
[SU Student Mangement System].[dbo].[Std_Reg_Table] group by Selected_Course;";
SqlDataAdapter da = new SqlDataAdapter(sq, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow[] returnRow = ds.Tables[0].Select("Selected_Course = '" +
comboSelectedCourse.Text + "'");
DataRow dr = returnRow[0];
_numOfStudent = Convert.ToInt16(dr["num_of_students"].ToString());
//
MessageBox.Show(_numOfStudent.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "count number of students");
}
if (_numOfStudent < 10)
{
con.Open();//open the connection
//Update query to be executed
String sq = "UPDATE Std_Reg_Table SET Selected_Course='" +
comboSelectedCourse.Text +"'WHERE Stu_Reg_No='" + RegNoTxt.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sq, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();//close the connection
MessageBox.Show("Registerd to a new course Successfully");
this.Hide();
StudentRegistration ss = new StudentRegistration();
ss.Show();
BillingViewer rptv = new BillingViewer(RegNoTxt.Text, txtName.Text,
comboSelectedCourse.Text, txtSemFee.Text, txtUniCharges.Text, txtTotal.Text);
rptv.Show();
}
else
{
MessageBox.Show("No seats available.Please select another course");
}
}
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
RegNoTxt.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
txtName.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
txtAddress.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
txtContact.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 48
comboSelectedCourse.Text =
dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
comboAlternativeCourse.Text =
dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
txtSemFee.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
txtUniCharges.Text =
dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
txtTotal.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
}
private void btnDrop_Click(object sender, EventArgs e)
{
//Checking the decision
if (MessageBox.Show("Are you sure", "Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
con.Open();
//Delete query to be executed
String query = "DELETE FROM Std_Reg_Table where Stu_Reg_No= '" +
txtViewRegDetails.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Your Course is Dropped Successfully");
this.Hide();
StudentRegistration ss = new StudentRegistration();
ss.Show();
}
else
{
MessageBox.Show("Selected Record is not Deleted", "Delete",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
}
private void btnLogOut_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?",
"Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
Login sb = new Login();
sb.Show();
}
}
private void btnHelp_Click(object sender, EventArgs e)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 49
{
StudentRegHelpMenu sb = new StudentRegHelpMenu();
sb.Show();
}
}
}
4.8 Professor’s Course Registration Form.
Professors must use following form to register to a new course for the selected semester.
Figure 15 Professor's course registration
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 50
Source code for professor’s course registration
{
public ProfessorRegistration()
{
InitializeComponent();
}
//Database connection
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP2JUL9IR\SQLEXPRESS;Initial Catalog=stafford_uni;Integrated Security=True");
private void btnReg_Click(object sender, EventArgs e)
{
if (comboProfRegNo.Text == "" || comboFaculty.Text == "" ||
comboSemester.Text == "" || comboCourse1.Text == "" || comboCourse2.Text == "")
{
MessageBox.Show("Please fill the blank fields");
}
else
{
int _numOfStudent = 0;
try
{
//Get the count from the database
string sql = "SELECT Selected_Course, count(*) as num_of_students
FROM [stafford_uni].[dbo].[Std_Reg_Table] group by Selected_Course;";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow[] returnRow = ds.Tables[0].Select("Selected_Course = '" +
comboCourse1.Text + "'");
DataRow dr = returnRow[0];
_numOfStudent = Convert.ToInt16(dr["num_of_students"].ToString());
//
MessageBox.Show(_numOfStudent.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "count number of students");
}
if (_numOfStudent > 3)//check wheather the no of students are less than 3
{
con.Open();
//Insert query to be executed
String query = "INSERT INTO
Prof_Reg_Table(Prof_Reg_No,Name,Faculty,Semester,Course1,Course2) VALUES ('" +
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 51
comboProfRegNo.Text + "', '" + txtName.Text + "', '" + comboFaculty.Text + "','" +
comboSemester.Text + "','" + comboCourse1.Text + "', '" + comboCourse2.Text + "')";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();//execute the query
con.Close();
MessageBox.Show("Successfully Updated");
this.Hide();
ProfessorRegistration ss = new ProfessorRegistration();
ss.Show();
}
else
{
MessageBox.Show("This course has been cancelled.Please select another
course");
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
this.Close();
}
}
private void ProfessorRegistration_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Course_Fees";
cmd.ExecuteNonQuery();
DataTable dd = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dd);
foreach (DataRow dr in dd.Rows)
{
comboViewStudents.Items.Add(dr["Course_Name"].ToString());
comboCourse1.Items.Add(dr["Course_Name"].ToString());
comboCourse2.Items.Add(dr["Course_Name"].ToString());
}
cmd.CommandText = "select * from Prof_Details";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 52
SqlDataAdapter db = new SqlDataAdapter(cmd);
db.Fill(dt);
foreach (DataRow ds in dt.Rows)
{
comboProfRegNo.Items.Add(ds["Prof_Reg_No"].ToString());
comboViewCourseRoster.Items.Add(ds["Prof_Reg_No"].ToString());
}
con.Close();
}
private void btnView_Click(object sender, EventArgs e)
{
if (comboViewStudents.Text == "")
{
MessageBox.Show("Please select a course");
}
else
{
con.Open();
//select query for selected course
String sql = "select * from Std_Reg_Table where Selected_Course= '" +
comboViewStudents.SelectedItem.ToString() + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
private void btnLogout_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)//exit validation
{
this.Close();
Login sb = new Login();
sb.Show();
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 53
cmd.CommandText = "select * from Prof_Details where Prof_Reg_No= '" +
comboProfRegNo.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtName.Text = dr["Name"].ToString();
comboFaculty.Text = dr["Faculty"].ToString();
}
con.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void btnCourseRoster_Click(object sender, EventArgs e)
{
if (comboViewCourseRoster.Text == "")
{
MessageBox.Show("Please select your Reg.No");
}
else
{
con.Open();//open connection
String sql = "select * from Course_Roster where Prof_Reg_No= '" +
comboViewCourseRoster.SelectedItem.ToString() + "'";
SqlDataAdapter SDA = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();//close connection
}
}
private void ProfessorRegistration_FormClosing(object sender,
FormClosingEventArgs e)
{
}
private void btnHelp_Click(object sender, EventArgs e)
{
ProfessorRegHelpMenu sb = new ProfessorRegHelpMenu();
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 54
sb.Show();
}
}
}
4.9 Login form help menu
Figure 16 Login form help menu
Source: (Author developed)
4.10 Student registration form help menu
Figure 17 student registration form help menu
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 55
4.11 Professor’s course registration form help menu
Figure 18 Professor’s course registration form help menu
Source: (Author developed)
4.12 Registrar’s student registration form help menu
Figure 19 Registrar’s student registration form help menu
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 56
4.13 Registrar’s professor registration form help menu
Figure 20 Registrar’s professor registration form help menu
Source: (Author developed)
4.14 Course catalog form help menu
Figure 21 Course catalog form help menu
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 57
4.15 Billing system form help menu
Figure 22 billing system form help menu
Source: (Author developed)
A.A.N.N.Amarasinghe.
HND in Computing and System Development- 23.
Business Skills for E commerce.
Esoft Metro Campus-Kurunegala.
Page 58
Download