public static void ModifyEmploye(Employe employe)
 {
     foreach (ServiceSocial serviceSocial in employe.myPret())
     {
         ConnectionPret.ModifyPret(serviceSocial);
     }
 }
        public static List <Employe> GetEmployes()
        {
            List <Employe> employes      = new List <Employe>();
            SqlConnection  sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     Command    = "SELECT * FROM " + table + " ; ";
            SqlCommand sqlCommand = new SqlCommand(Command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                while (dataReader.Read())
                {
                    Employe employe = new Employe();
                    employe.setID((int)dataReader[0]);
                    employe.setNom((String)dataReader[1]);
                    employe.setPrenom((String)dataReader[2]);
                    employe.setNSS((String)dataReader[3]);
                    employe.setService((String)dataReader[4]);
                    employe.setsalaire(Convert.ToDouble(dataReader[5]));
                    employe.setEtat((String)dataReader[8]);
                    employe.setMypret(ConnectionPret.GetListPrets((int)dataReader[0]));
                    employes.Add(employe);
                }
                dataReader.Close();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
            return(employes);
        }
        public static Employe GetEmploye(int id)
        {
            Employe       employe       = new Employe();
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     Command    = "SELECT * FROM " + table + " WHERE Id = @id ; ";
            SqlCommand sqlCommand = new SqlCommand(Command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", id);

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.Read())
                {
                    employe.setID((int)dataReader[0]);
                    employe.setNom((String)dataReader[1]);
                    employe.setPrenom((String)dataReader[2]);
                    employe.setNSS((String)dataReader[3]);
                    employe.setService((String)dataReader[4]);
                    employe.setsalaire(Convert.ToDouble(dataReader[5]));
                    employe.setEtat((String)dataReader[8]);
                    employe.setMypret(ConnectionPret.GetListPrets((int)dataReader[0]));
                }
                dataReader.Close();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
            return(employe);
        }
        public static void DeleteEmploye(Employe employe)
        {
            foreach (ServiceSocial serviceSocial in employe.myPret())
            {
                ConnectionPret.DeletePret(serviceSocial);
            }
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     Command    = "DELETE FROM " + table + " WHERE Id = @id ";
            SqlCommand sqlCommand = new SqlCommand(Command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", employe.getID());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }