Employee management system report

37
A Project Report On “Employee Management System” Submitted in the partial fulfillment of the requirement For the award of Diploma of COMPUTER ENGINEERING (Batch: 2014-2017) G.B.N GOVT. POLYTECHNIC, NILOKHERI Submitted by:- 1

Transcript of Employee management system report

Page 1: Employee management system report

AProject Report

On “Employee Management System”

Submitted in the partial fulfillment of the requirement

For the award of Diploma of

COMPUTER ENGINEERING

(Batch: 2014-2017)

G.B.N GOVT. POLYTECHNIC, NILOKHERI

Submitted by:-

Toshant Arora(14009080095) Shubham (14009080088)

Tulsi Sharma(14009080096)

1

Page 2: Employee management system report

INDEXTABLE OF CONTENTS

1. PROJECT DESCRIPTION Introduction Scope of project Objective of project

3. SNAPSHOT CONCLUSION FUTURE SCOPE REFERENCES

PROJECT DESCRIPTION

Objective of C# project on Employee Management System :-

The main objective of the C# project on Employee Management is to Manage the details of information, leaves, salaries, login, employee. It manages all the information about information, experience, employee, information. The project is totally built at administrative end thus only administrator is guaranteed the access. The purpose of the project is to build an application program to reduce the manual work for managing the informations, leaves, salary. It tracks all the details about the salary, login, employee.

Functionalities provided by C# project on Employee Management system are as follows:

1).Provides the searching facilities based on various factors. Such as information, salary, Login, Employee2).It tracks all the information of leaves, Login etc3).Manage the information of Leaves4).Shows the information and description of the information, Salary5).To increase efficiency of managing the information, leaves6).Editing, adding and updating of Records is improved which results in proper resource management of information of data.

2

Page 3: Employee management system report

7).Manage the information of login.8).Integration of all records of employee.

Input Data and Validation –

1) All the fields such as Salary, Employee and leave are validated and don’t take invalid arguments.

2) Each form like Employee, Salary don’t take blank values.3) Avoiding errors in data.4) Controlling amount of input.

Scope of the Project:-

For all the s/w there is always a scope of future enhancements. There are few enhancements which are pointed out in the proposed system. They are as follows:

1. Module for Employee Loan.2. Modules for proper arrangement of attendance of employees.3. Introducing online version of the Software.4. Introducing software for Employees side also.5. More proper salary calculations based on various factors.

Objectives of the Project:-

Time and Cost Effective – Software is making the process of keeping database

time and cost effective by making it easy to alter or update database and also keeping

that safe.

Database Creation - A database of the registered users will be created and this

will help the users to fetch the details of Computer Center.

Flexibility – Database provides flexibility to administrator..Records can be

inserted, deleted or updated with just a click.

3

Page 4: Employee management system report

Informative - The software has all the necessary details about the Students and

Courses and provides all the relevant information therefore. For example, searching

of appropriate Student for like admission and then the information of admission is

added to Students records.

Security - Proper authorization and authentication provisions have been made for

the security of the software so that only the registered administrators can look the

Information. Without proper login no one is allowed to access this software.

Snap shots

Welcome Page

4

Page 5: Employee management system report

Fig.3.12: login page

Table of Login Page:

Table 1: Login page

5

Page 6: Employee management system report

Fig.3.13: Employee Info Page

Table of Course Info page:

Table of Employee Info page

6

Page 7: Employee management system report

Salary page

Table of salary page

7

Page 8: Employee management system report

Leave page

Table of leave page

8

Page 9: Employee management system report

Forgot Password Page

9

Page 10: Employee management system report

Fig.3.14: Home Page

Welcome Page Coding :using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;

namespace Employees{ public partial class Welcome : Form { public Welcome() { InitializeComponent(); }

private void timer1_Tick(object sender, EventArgs e) {

}

private void Welcome_Load(object sender, EventArgs e) { }

private void timer2_Tick(object sender, EventArgs e) { try { progressBar1.Value = progressBar1.Value + 1; label1.Text = progressBar1.Value.ToString() + ("% completed"); if (progressBar1.Value == 100) { this.Hide(); Loginf1 login = new Loginf1(); login.Show(); timer2.Stop(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString());

10

Page 11: Employee management system report

} } }}

Login page coding :

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;

namespace Employees{ public partial class Loginf1 : Form { public static string data; public static string value; SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Databasefinal;Integrated Security=True;Pooling=False"); public Loginf1() { InitializeComponent(); }

private void panel1_Paint(object sender, PaintEventArgs e) {

}

private void button1_Click(object sender, EventArgs e) { }

private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); CreateAccount create = new CreateAccount(); create.Show(); }

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); ForgotPassword forgot = new ForgotPassword(); forgot.Show(); }

11

Page 12: Employee management system report

private void Loginf1_Load(object sender, EventArgs e) { panel1.BackColor = Color.FromArgb(125, panel1.BackColor);

}

private void button1_Click_1(object sender, EventArgs e) {

}

private void button1_Click_2(object sender, EventArgs e) { try { if ((textBox1.Text != "") && (textBox2.Text != "")) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "checkuser"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@username", textBox1.Text); cmd.Parameters.AddWithValue("@password", textBox2.Text); SqlParameter status = new SqlParameter("@status", SqlDbType.Char, 1); status.Direction = ParameterDirection.Output; cmd.Parameters.Add(status); SqlParameter ret = new SqlParameter("@ret", SqlDbType.Int); ret.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(ret); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close();

Int32 r = Convert.ToInt32(cmd.Parameters["@ret"].Value); String st = cmd.Parameters["@status"].Value.ToString(); if (r == 0) { MessageBox.Show("Wrong Username","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } else if (r == -1) { MessageBox.Show("Wrong Password","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } else if(r==1) { if (st == "A") { data = textBox1.Text; this.Hide();

12

Page 13: Employee management system report

EmployeeManagementSystem emp = new EmployeeManagementSystem();

emp.Show(); } else if (st == "U") { this.Hide(); EmployeeManagementSystem emp = new EmployeeManagementSystem(); emp.Show(); } } }

else { MessageBox.Show("Please Enter Username and Password", "Warning"); }

} catch (Exception ex) { MessageBox.Show(ex.Message.ToString(),"Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); } finally { con.Close(); } }

private void linkLabel2_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); CreateAccount create = new CreateAccount(); create.Show(); }

private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); ForgotPassword forgot = new ForgotPassword(); forgot.Show();

}

private void checkBox1_CheckedChanged(object sender, EventArgs e) {

13

Page 14: Employee management system report

}

private void button3_Click(object sender, EventArgs e) { button3.Hide(); button2.Show(); textBox2.UseSystemPasswordChar = true; }

private void button2_Click(object sender, EventArgs e) { button2.Hide(); button3.Show(); textBox2.UseSystemPasswordChar = false; }

private void textBox1_Enter(object sender, EventArgs e) { if(textBox1.Text=="User Name") { textBox1.Text = ""; textBox1.ForeColor = Color.Black; } }

private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == "") { textBox1.Text = "User Name"; textBox1.ForeColor = Color.DarkGray; } }

private void textBox2_Enter(object sender, EventArgs e) { if (textBox2.Text == "Password") { textBox2.Text = ""; textBox2.ForeColor = Color.Black; }

}

private void textBox2_Leave(object sender, EventArgs e) { if (textBox2.Text == "") { textBox2.Text = "Password"; textBox2.ForeColor = Color.DarkGray; } }

14

Page 15: Employee management system report

private void linkLabel2_LinkClicked_2(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); CreateAccount create = new CreateAccount(); create.Show(); }

private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { value = "Guest Account"; this.Hide(); EmployeeManagementSystem emp = new EmployeeManagementSystem(); emp.Show(); } }}

Employee Info page Coding :using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.IO;

namespace Employees{ public partial class EmployeeInfo : Form { string imgelocation = ""; SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Databasefinal;Integrated Security=True;Pooling=False"); public EmployeeInfo() { InitializeComponent(); } private void Departmentlist() { SqlDataAdapter adp = new SqlDataAdapter("Select * from Tb_Department", con); DataSet ds=new DataSet(); adp.Fill(ds); comboBox2.DataSource = ds.Tables[0].DefaultView; comboBox2.DisplayMember = "Department_Name"; comboBox2.ValueMember="Department_Id"; } private void Reset() {

15

Page 16: Employee management system report

textBox2.Text = ""; comboBox2.SelectedItem=null ; textBox1.Text = ""; textBox4.Text = ""; maskedTextBox1.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox5.Text = ""; richTextBox1.Text = ""; dateTimePicker1.ResetText(); dateTimePicker2.ResetText(); dateTimePicker3.ResetText(); comboBox1.ResetText();

}

private void EmployeeInfo_Load(object sender, EventArgs e) { try { groupBox1.BackColor = Color.FromArgb(125, groupBox1.BackColor); groupBox2.BackColor = Color.FromArgb(125, groupBox2.BackColor); Employeelist();

Departmentlist(); Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } private Int32 MaxId() { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select isnull(Max(Emp_Id),0) from Tb_Employee where Department_Name='"+comboBox2.SelectedValue+"'"; cmd.Connection = con; con.Open(); Int32 Id = Convert.ToInt32(cmd.ExecuteScalar()) + 1; cmd.Dispose(); con.Close(); return Id; }

private void button3_Click(object sender, EventArgs e) { Reset(); }

private void button1_Click(object sender, EventArgs e) {

16

Page 17: Employee management system report

try { byte[] images = null; FileStream Streem = new FileStream(imgelocation, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(Streem); images = brs.ReadBytes((int)Streem.Length); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "insert into Tb_Employee(Emp_Id,Emp_Name,Department_Name,Job_Title,Mobile,Email_Id,Address,Joining_Date,Gender,DOB,Leaving_Date,Salary,Image,Total_Leave)Values(@empid,@empname,@departmentname,@jobtitle,@mobile,@emailid,@address,@joiningdate,@gender,@dob,@leavingdate,@salary,@image,@totalleave)"; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@empid", textBox1.Text); cmd.Parameters.AddWithValue("@empname", textBox2.Text); cmd.Parameters.AddWithValue("@departmentname",comboBox2.SelectedValue); cmd.Parameters.AddWithValue("@jobtitle", textBox4.Text); cmd.Parameters.AddWithValue("@totalleave", textBox5.Text); cmd.Parameters.AddWithValue("@mobile", maskedTextBox1.Text); cmd.Parameters.AddWithValue("@emailid", textBox6.Text); cmd.Parameters.AddWithValue("@address", richTextBox1.Text); cmd.Parameters.AddWithValue("@joiningdate", dateTimePicker1.Value); cmd.Parameters.AddWithValue("@gender", comboBox1.SelectedItem); cmd.Parameters.AddWithValue("@dob", dateTimePicker2.Value); cmd.Parameters.AddWithValue("@leavingdate", dateTimePicker3.Value); cmd.Parameters.AddWithValue("@salary", textBox7.Text); cmd.Parameters.Add(new SqlParameter("@image", images)); int N = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Employeelist(); Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

} private void Employeelist() { SqlDataAdapter adp = new SqlDataAdapter("Select * from Tb_Employee where Department_Name='"+comboBox2.SelectedValue+"'", con);

17

Page 18: Employee management system report

DataSet ds = new DataSet(); adp.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; }

private void pictureBox1_Click(object sender, EventArgs e) { try {

OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = "C:\\";

open.Filter = "png files(*.png)|jpg files(*.jpg|All files(*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) {

imgelocation = open.FileName.ToString(); pictureBox1.ImageLocation = imgelocation; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}

private void button2_Click(object sender, EventArgs e) { try { byte[] images = null; FileStream Streem = new FileStream(imgelocation, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(Streem); images = brs.ReadBytes((int)Streem.Length); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "update Tb_Employee set Emp_Name=@empname,Job_Title=@jobtitle,Mobile=@mobile,Email_Id=@emailid,Joining_Date=@joiningdate,Address=@address,DOB=@dob,Salary=@salary,Gender=@gender,Department_Id=@departmentid,Leaving_Date=@leavingdate,Image=@image where Emp_Id=@empid"; cmd.Connection = con; con.Open();

cmd.Parameters.AddWithValue("@empid", textBox1.Text); cmd.Parameters.AddWithValue("@empname", textBox2.Text);

18

Page 19: Employee management system report

cmd.Parameters.AddWithValue("@departmentname", comboBox2.SelectedValue); cmd.Parameters.AddWithValue("@jobtitle", textBox4.Text); cmd.Parameters.AddWithValue("@mobile", maskedTextBox1.Text); cmd.Parameters.AddWithValue("@emailid", textBox6.Text); cmd.Parameters.AddWithValue("@address", richTextBox1.Text); cmd.Parameters.AddWithValue("@joiningdate", dateTimePicker1.Value); cmd.Parameters.AddWithValue("@gender", comboBox1.SelectedItem); cmd.Parameters.AddWithValue("@dob", dateTimePicker2.Value); cmd.Parameters.AddWithValue("@leavingdate", dateTimePicker3.Value); cmd.Parameters.AddWithValue("@salary", textBox7.Text); cmd.Parameters.Add(new SqlParameter("@image", images)); int N = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); } }

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); comboBox2.SelectedItem = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); maskedTextBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); textBox6.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); textBox7.Text = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString(); textBox5.Text = dataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();

19

Page 20: Employee management system report

richTextBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); comboBox1.SelectedItem= dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();

dateTimePicker1.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); dateTimePicker2.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); dateTimePicker3.Text = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString(); byte[] Images=new byte[0]; SqlDataAdapter adp = new SqlDataAdapter("Select Image from Tb_Employee where Emp_Id='" + textBox1.Text + "'", con); SqlCommand cmd = new SqlCommand("Select Image from Tb_Employee where Emp_Id='" + textBox1.Text + "'", con); cmd.CommandType=CommandType.Text; DataSet ds = new DataSet(); adp.Fill(ds); foreach(DataRow dr in ds.Tables[0].Rows){ Images=(byte[])dr["Image"];}

byte[] imgData=Images;MemoryStream stream = new MemoryStream(imgData);pictureBox1.Image=Image.FromStream(stream);} catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}

private void button4_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "delete from Tb_Employee where Emp_Id=@empid"; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@empid", textBox1.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Reset(); Employeelist();

20

Page 21: Employee management system report

} catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

}

private void button5_Click_1(object sender, EventArgs e) { try { this.Hide(); EmployeeManagementSystem emp = new EmployeeManagementSystem(); emp.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

}

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { try {

textBox1.Text = MaxId().ToString(); Employeelist(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } }}

Client Info page coding :using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;

namespace Employees{ public partial class ClientInfo : Form { SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Databasefinal;Integrated Security=True;Pooling=False");

21

Page 22: Employee management system report

public ClientInfo() { InitializeComponent(); }

private void ClientInfo_Load(object sender, EventArgs e) { try { panel1.BackColor = Color.FromArgb(125, panel1.BackColor); Clientlist(); Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

} private Int32 MaxId() { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select isnull(Max(Client_Id),0) from Tb_Client"; cmd.Connection = con; con.Open(); Int32 i = Convert.ToInt32(cmd.ExecuteScalar()) + 1; cmd.Dispose(); con.Close(); return i;

} private void Clientlist() { SqlDataAdapter adp = new SqlDataAdapter("Select * from Tb_Client", con); DataSet ds = new DataSet(); adp.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; } private void Reset() { textBox1.Text = MaxId().ToString(); ; textBox2.Text = ""; textBox3.Text = ""; richTextBox1.ResetText(); maskedTextBox1.ResetText(); }

private void button1_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand();

22

Page 23: Employee management system report

cmd.CommandText = "insert into Tb_Client(Client_Id,Client_Name,Address,Contact_No,Email_Id) Values(@clientid,@clientname,@address,@contactno,@emailid)"; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@clientid", textBox1.Text); cmd.Parameters.AddWithValue("@clientname", textBox2.Text); cmd.Parameters.AddWithValue("@address", richTextBox1.Text); cmd.Parameters.AddWithValue("@contactno", maskedTextBox1.Text); cmd.Parameters.AddWithValue("@emailid", textBox3.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Reset(); Clientlist(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString());

} finally { con.Close(); } }

private void button3_Click(object sender, EventArgs e) { try { Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }

private void button2_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Delete from Tb_Client where Client_Id=@clientid"; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@clientid", textBox1.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Reset(); Clientlist(); } catch (Exception ex) {

23

Page 24: Employee management system report

MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}

private void button4_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "update Tb_Client set Client_Name=@clientname,Address=@address,Contact_No=@contactno,Email_Id=@emailid where Client_Id=@clientid"; cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@clientname", textBox2.Text); cmd.Parameters.AddWithValue("@clientid", textBox1.Text); cmd.Parameters.AddWithValue("@address", richTextBox1.Text); cmd.Parameters.AddWithValue("@contactno", maskedTextBox1.Text); cmd.Parameters.AddWithValue("@emailid", textBox3.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Reset(); Clientlist(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}

private void button5_Click(object sender, EventArgs e) { try { this.Hide(); EmployeeManagementSystem emp = new EmployeeManagementSystem(); emp.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }

24

Page 25: Employee management system report

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); richTextBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); maskedTextBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); textBox3.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

} }}

Leave page Coding :using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;

namespace Employees{ public partial class Leave : Form {

SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Databasefinal;Integrated Security=True;Pooling=False"); public Leave() { InitializeComponent(); }

private void Leave_Load(object sender, EventArgs e) {

Leavelist(); Reset();

25

Page 26: Employee management system report

} private void Leavelist() { string query = "Select E.Emp_Id,E.Emp_Name,L.Leave_From,L.Leave_To,L.Leave_Reason,L.Leave_Days,L.Total_Leave from Tb_Employee E,Tb_Leave L where E.Emp_Id=L.Emp_Id";

SqlDataAdapter adp = new SqlDataAdapter(query, con); DataSet ds = new DataSet(); adp.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; con.Close(); } private void Reset() { textBox1.Text = ""; textBox2.Text = ""; dateTimePicker1.ResetText(); dateTimePicker2.ResetText(); richTextBox1.Text = ""; label7.Text = " 0"; } private void button1_Click(object sender, EventArgs e) { try { con.Close(); if (dateTimePicker2.Value > dateTimePicker1.Value) { SqlCommand cmd = new SqlCommand();

cmd.Connection = con;

cmd.CommandText = "insert into Tb_Leave(Emp_Id,Leave_From,Leave_To,Leave_Reason,Leave_Days,Total_Leave)Values(@empid,@leavefrom,@leaveto,@leavereason,@leavedays,@totalleave)"; con.Open();

cmd.Parameters.AddWithValue("@empid", textBox1.Text); cmd.Parameters.AddWithValue("@leavefrom", dateTimePicker1.Value); cmd.Parameters.AddWithValue("@leaveto", dateTimePicker2.Value); cmd.Parameters.AddWithValue("@leavereason", richTextBox1.Text); cmd.Parameters.AddWithValue("@leavedays", textBox2.Text); Int32 i = Convert.ToInt32(label7.Text) + Convert.ToInt32(textBox2.Text); if (i > 15) {

26

Page 27: Employee management system report

MessageBox.Show("You have already taken the number of allowed leaves"); } else { cmd.Parameters.AddWithValue("@totalleave", i.ToString());

cmd.ExecuteNonQuery(); } cmd.Dispose(); con.Close(); Reset(); Leavelist();

}

else { MessageBox.Show("The value of Leave to can't be less than leave from"); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}

private void button2_Click(object sender, EventArgs e) { Reset(); }

private void button4_Click(object sender, EventArgs e) { this.Hide(); EmployeeManagementSystem emp = new EmployeeManagementSystem(); emp.Show(); }

private void button3_Click_1(object sender, EventArgs e)

27

Page 28: Employee management system report

{ try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select Total_Leave from Tb_Leave where Emp_Id=@empid";

cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@empid", textBox1.Text); cmd.ExecuteNonQuery();

cmd.Dispose();

SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) {

label7.Text = reader["Total_Leave"].ToString(); }

con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { con.Close(); }

}}}Forgot Password Coding :using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;

namespace Employees{ public partial class ForgotPassword : Form { SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Databasefinal;Integrated Security=True;Pooling=False"); public ForgotPassword() {

28

Page 29: Employee management system report

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { try { if (textBox1.Text != "") { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; con.Open(); cmd.CommandText = "forgot";

cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@username", textBox1.Text); cmd.Parameters.AddWithValue("@question", comboBox1.SelectedItem); cmd.Parameters.AddWithValue("@answer", textBox2.Text); SqlParameter password = new SqlParameter("@password", SqlDbType.VarChar, 100); password.Direction = ParameterDirection.Output; cmd.Parameters.Add(password); SqlParameter ret = new SqlParameter("@ret", SqlDbType.Int); ret.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(ret); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Int32 r = Convert.ToInt32(cmd.Parameters["@ret"].Value); String st = cmd.Parameters["@password"].Value.ToString(); if (r == 0) { MessageBox.Show("Wrong Information"); } else if (r == -1) { MessageBox.Show("Wrong Question or Invalid Answer","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); } else if (r == 1) { MessageBox.Show("Password is =" + st,"Password",MessageBoxButtons.OK,MessageBoxIcon.Information); } }

else { MessageBox.Show("Enter Username", "Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

29

Page 30: Employee management system report

finally { con.Close(); }

}

private void button2_Click(object sender, EventArgs e) { try { this.Hide(); Loginf1 login = new Loginf1(); login.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

}

private void textBox1_Enter(object sender, EventArgs e) { if (textBox1.Text == "User Name") { textBox1.Text = ""; textBox1.ForeColor = Color.Black; } }

private void textBox2_Enter(object sender, EventArgs e) { if (textBox2.Text == "Password") { textBox2.Text = ""; textBox2.ForeColor = Color.Black; } }

private void textBox2_Leave(object sender, EventArgs e) { if (textBox2.Text == "") { textBox2.Text = "Password"; textBox2.ForeColor = Color.DimGray; } }

private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == "") { textBox1.Text = "User Name"; textBox1.ForeColor = Color.DimGray; } }

30

Page 31: Employee management system report

}}

CONCLUSION

The project is to digitalize the database of Employees in Organizations and enabling

Administrators to have benefit from Computers. Software acts as a Information System between

Employees and administrators. Here the user can keep his/her database secure and safe for a

unlimited period of time.

Software provides Employee management System for inserting ,updating, Searching and

deleting records with ease and simplicity. We will provide a fresh new approach to our esteemed

users to search for records and make databases in a digital way.

31