private void addEmployeeBtn_Click(object sender, RoutedEventArgs e)
        {
            SecurityManagementSystemEngine.EmployeeInformation newEmployee = new SecurityManagementSystemEngine.EmployeeInformation();

            newEmployee.id = GenerateId();

            newEmployee.name = employeeNameTxtbox.Text;
            newEmployee.addres = AddressNameTxtbox.Text;
            newEmployee.contact = contactTxtbox.Text;
            newEmployee.email = emailTxtbox.Text;
            newEmployee.homeNumber = homeNumberTxtbox.Text;
            newEmployee.joiningdate = joiningdateP.SelectedDate.Value;
            newEmployee.employeeType= employeeTypeCombobox.Text;
            newEmployee.remark = remarkTxtbox.Text;

            SecurityManagementSystemStorage.SecurityManagementSystemStorageInteraction.DoEnterEmployee(newEmployee);
            EmployeeTC.SelectedIndex = 0;
            clearEmployeeFields();
        }
        private static List<EmployeeInformation> QueryAllEmployeeList()
        {
            List<EmployeeInformation> EmployeeList = new List<EmployeeInformation>();

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From employee ;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    EmployeeInformation Employee = new EmployeeInformation();

                    Employee.id = msqlReader.GetString("id");
                    Employee.name = msqlReader.GetString("name");
                    Employee.addres = msqlReader.GetString("address");
                    Employee.contact = msqlReader.GetString("contact");
                    Employee.joiningdate = msqlReader.GetDateTime("joiningdate");
                    Employee.email = msqlReader.GetString("email");
                    Employee.homeNumber = msqlReader.GetString("homenumber");
                    Employee.employeeType = msqlReader.GetString("employeeType");
                    Employee.remark = msqlReader.GetString("remark");

                    EmployeeList.Add(Employee);
                }

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return EmployeeList;
        }
        private static int DoRegisterNewEmployeeindb(EmployeeInformation Newemployee)
        {
            int returnVal = 0;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "INSERT INTO employee(id,name,address,contact,joiningdate,email,homenumber,employeeType,remark) "
                                    + "VALUES(@id,@name,@address,@contact,@joiningdate,@email,@homenumber,@employeeType,@remark)";

                msqlCommand.Parameters.AddWithValue("@id", Newemployee.id);
                msqlCommand.Parameters.AddWithValue("@name", Newemployee.name);
                msqlCommand.Parameters.AddWithValue("@address", Newemployee.addres);
                msqlCommand.Parameters.AddWithValue("@contact", Newemployee.contact);
                msqlCommand.Parameters.AddWithValue("@joiningdate", Newemployee.joiningdate);
                msqlCommand.Parameters.AddWithValue("@email", Newemployee.email);
                msqlCommand.Parameters.AddWithValue("@homenumber", Newemployee.homeNumber);
                msqlCommand.Parameters.AddWithValue("@employeeType", Newemployee.employeeType);
                msqlCommand.Parameters.AddWithValue("@remark", Newemployee.remark);

                msqlCommand.ExecuteNonQuery();

                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }
        public static EmployeeInformation GetEmployeeInfo(string employeeId)
        {
            EmployeeInformation employee = new EmployeeInformation();

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From employee WHERE id=@id;";
                msqlCommand.Parameters.AddWithValue("@id", employeeId);
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                msqlReader.Read();

                employee.id = msqlReader.GetString("id");

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return employee;
        }
        public static void EditEmployee(EmployeeInformation newUpdateEmployee)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "UPDATE employee SET name=@name,address=@address,contact=@contact,joiningdate=@joiningdate,email=@email,homenumber=@homenumber,employeeType=@employeeType,remark=@remark  WHERE id=@id";

                msqlCommand.Parameters.AddWithValue("@name", newUpdateEmployee.name);
                msqlCommand.Parameters.AddWithValue("@address", newUpdateEmployee.addres);
                msqlCommand.Parameters.AddWithValue("@contact", newUpdateEmployee.contact);
                msqlCommand.Parameters.AddWithValue("@joiningdate", newUpdateEmployee.joiningdate);
                msqlCommand.Parameters.AddWithValue("@email", newUpdateEmployee.email);
                msqlCommand.Parameters.AddWithValue("@homenumber", newUpdateEmployee.homeNumber);
                msqlCommand.Parameters.AddWithValue("@employeeType", newUpdateEmployee.employeeType);
                msqlCommand.Parameters.AddWithValue("@remark", newUpdateEmployee.remark);
                msqlCommand.Parameters.AddWithValue("@id", newUpdateEmployee.id);

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
 public static int DoEnterEmployee(EmployeeInformation NewEmployee)
 {
     return DoRegisterNewEmployeeindb(NewEmployee);
 }