private void addSecurityGuardBtn_Click(object sender, RoutedEventArgs e)
        {
            SecurityManagementSystemEngine.SecurityInformation newSecurity = new SecurityManagementSystemEngine.SecurityInformation();

            newSecurity.id = GenerateId();

            newSecurity.name = securityNameTxtbox.Text;
            newSecurity.addres = AddressNameTxtbox.Text;
            newSecurity.contact = contactTxtbox.Text;
            newSecurity.email = emailTxtbox.Text;
            newSecurity.homeNumber = homeNumberTxtbox.Text;
            newSecurity.joiningdate = joiningdateP.SelectedDate.Value;
            newSecurity.remark = remarkTxtbox.Text;

            SecurityManagementSystemStorage.SecurityManagementSystemStorageInteraction.DoEnterSecurity(newSecurity);

            securityTC.SelectedIndex = 0;
            clearSecurityFields();
        }
        private static List<SecurityInformation> QueryAllSecurityList()
        {
            List<SecurityInformation> SecurityList = new List<SecurityInformation>();

            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 security ;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    SecurityInformation Security = new SecurityInformation();

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

                    SecurityList.Add(Security);
                }

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

            return SecurityList;
        }
        public static void EditSecurity(SecurityInformation newUpdateSecurity)
        {
            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 security SET name=@name,address=@address,contact=@contact,joiningdate=@joiningdate,email=@email,homenumber=@homenumber,remark=@remark WHERE id=@id";

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

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
        private static int DoRegisterNewSecurityindb(SecurityInformation Newsecurity)
        {
            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 security(id,name,address,contact,joiningdate,email,homenumber,remark) "
                                    + "VALUES(@id,@name,@address,@contact,@joiningdate,@email,@homenumber,@remark)";

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

                msqlCommand.ExecuteNonQuery();

                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }
 public static int DoEnterSecurity(SecurityInformation NewSecurity)
 {
     return DoRegisterNewSecurityindb(NewSecurity);
 }