Esempio n. 1
0
 /// <inheritdoc />
 public int AddFacture(FactureDTO factureDTO)
 {
     try
     {
         return factureDAO.Add(factureDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message);
     }
 }
Esempio n. 2
0
        /// <inheritdoc />
        public int Add(FactureDTO factureDTO)
        {
            int n = 0;
            try
            {
                connexion.Open();
                command.CommandText = ADD_REQUEST;

                command.Parameters.Add(new MySqlParameter("@idLocation", factureDTO.IdLocation));
                command.Parameters.Add(new MySqlParameter("@idEmploye", factureDTO.IdEmploye));
                command.Parameters.Add(new MySqlParameter("@dateFacture", factureDTO.DateFacture));
                n = command.ExecuteNonQuery();
            }
            catch (MySqlException mySqlException)
            {
                throw mySqlException;
            }
            finally
            {
                connexion.Close();
            }
            return n;
        }
Esempio n. 3
0
 /// <inheritdoc />
 public int UpdateFacture(FactureDTO factureDTO, int id)
 {
     try
     {
         return factureDAO.Update(factureDTO,id);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message);
     }
 }
Esempio n. 4
0
        /// <inheritdoc />
        public FactureDTO Read(int id)
        {
            FactureDTO factureDTO = new FactureDTO();
            try
            {
                connexion.Open();
                command.CommandText = READ_REQUEST;

                command.Parameters.Add(new MySqlParameter("@idFacture", id));
                MySqlDataReader dr = command.ExecuteReader();

                if (dr.Read())
                {
                    factureDTO.IdFacture = dr.GetInt32(0);
                    factureDTO.IdLocation = dr.GetInt32(1);
                    factureDTO.IdEmploye = dr.GetInt32(2);
                    factureDTO.DateFacture = dr.GetDateTime(3).ToString();
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException);
            }
            finally
            {
                connexion.Close();
            }
            return factureDTO;
        }
Esempio n. 5
0
        /// <inheritdoc />
        public List<FactureDTO> GetAll()
        {
            List<FactureDTO> factures = new List<FactureDTO>();
            FactureDTO factureDTO = new FactureDTO();
            try
            {
                connexion.Open();
                command.CommandText = GET_ALL_REQUEST;

                MySqlDataReader dr = command.ExecuteReader();

                while (dr.Read())
                {
                    factureDTO.IdFacture = dr.GetInt32(0);
                    factureDTO.IdLocation = dr.GetInt32(1);
                    factureDTO.IdEmploye = dr.GetInt32(2);
                    factureDTO.DateFacture = dr.GetDateTime(3).ToString();
                    factures.Add(factureDTO);
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException);
            }
            finally
            {
                connexion.Close();
            }
            return factures;
        }
Esempio n. 6
0
        /// <inheritdoc />
        public List<FactureDTO> FindByLocation(int id)
        {
            List<FactureDTO> factures = new List<FactureDTO>();
            FactureDTO factureDTO = new FactureDTO();
            try
            {
                connexion.Open();
                command.CommandText = FIND_BY_LOCATION;

                command.Parameters.Add(new MySqlParameter("@idLocation", id));

                MySqlDataReader dr = command.ExecuteReader();

                while (dr.Read())
                {
                    factureDTO.IdFacture = dr.GetInt32(0);
                    factureDTO.IdLocation = dr.GetInt32(1);
                    factureDTO.IdEmploye = dr.GetInt32(2);
                    factureDTO.DateFacture = dr.GetDateTime(3).ToString();
                    factures.Add(factureDTO);
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException);
            }
            finally
            {
                connexion.Close();
            }
            return factures;
        }