예제 #1
0
        public static bool DeleteAnimalByClient(Client leClient)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Animaux SET Archive = 1 WHERE CodeClient = @codeClient";
                    command.Parameters.AddWithValue("@codeClient", leClient.codeClient);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #2
0
        public static bool SetRelanceEnvoye(RelanceVaccins relance)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE LignesConsultations SET RappelEnvoye='1' WHERE CodeConsultation=@Code AND NumLigne=@Num";
                    command.Parameters.AddWithValue("@Code", relance.codeConsultation);
                    command.Parameters.AddWithValue("@Num", relance.numLigne);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #3
0
        public static bool SetAnimal(Animal animal)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Animaux SET NomAnimal = @nom, Sexe = @sexe, Couleur = @couleur, Race = @race, Espece = @espece, CodeClient = @codeClient, Tatouage = @tatouage WHERE CodeAnimal = @id";
                    command.Parameters.AddWithValue("@nom", animal.nomAnimal);
                    command.Parameters.AddWithValue("@sexe", animal.sexe);
                    command.Parameters.AddWithValue("@couleur", animal.couleur);
                    command.Parameters.AddWithValue("@race", animal.race);
                    command.Parameters.AddWithValue("@espece", animal.espece);
                    command.Parameters.AddWithValue("@codeClient", animal.client);
                    command.Parameters.AddWithValue("@tatouage", animal.tatouage);
                    command.Parameters.AddWithValue("@id", animal.codeAnimal);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #4
0
        public static bool SetTatouage(String tatouage, Guid codeAnimal)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Animaux SET Tatouage = @tatouage WHERE CodeAnimal = @id";
                    command.Parameters.AddWithValue("@tatouage", tatouage);
                    command.Parameters.AddWithValue("@id", codeAnimal);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #5
0
        public static bool SetClient(Client client)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Clients SET Nom = @nom, Prenom = @prenom, Adresse1 = @adresse, Adresse2 = @adresse2, CodePostal = @cp, Ville = @ville WHERE CodeClient = @id";
                    command.Parameters.AddWithValue("@nom", client.nomClient);
                    command.Parameters.AddWithValue("@prenom", client.prenomClient);
                    command.Parameters.AddWithValue("@adresse", client.adresse);
                    command.Parameters.AddWithValue("@adresse2", client.adresse2);
                    command.Parameters.AddWithValue("@cp", client.cp);
                    command.Parameters.AddWithValue("@ville", client.ville);
                    command.Parameters.AddWithValue("@id", client.codeClient);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #6
0
 public static bool SetVaccin(Vaccin vaccin)
 {
     try
     {
         using (SqlConnection cnx = DALAccess.GetConnection())
         {
             SqlCommand command = cnx.CreateCommand();
             command.CommandType = System.Data.CommandType.Text;
             command.CommandText = "UPDATE Vaccins SET QuantiteStock = @quantite WHERE CodeVaccin = @code";
             command.Parameters.AddWithValue("@code", vaccin.codeVaccin);
             command.Parameters.AddWithValue("@quantite", vaccin.quantiteStock);
             int resultat = command.ExecuteNonQuery();
             if (resultat == 0)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Erreur : " + ex.Message);
     }
 }
예제 #7
0
        public static Login GetLogin(int IdLogin)
        {
            Login login = new Login();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Logins WHERE ID = @id";
                    command.Parameters.AddWithValue("@id", IdLogin);

                    SqlDataReader dt = command.ExecuteReader();

                    int colId       = dt.GetOrdinal("Id");
                    int colLogin    = dt.GetOrdinal("Login");
                    int colPassword = dt.GetOrdinal("Password");

                    while (dt.Read())
                    {
                        login.loginUser    = dt.GetString(colLogin);
                        login.passwordUser = dt.GetString(colPassword);
                        login.id           = dt.GetInt32(colId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(login);
        }
예제 #8
0
        public static Guid AddClient(Client client)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_client @nom, @prenom, @add, @add2, @cp, @ville, @tel, @ass, @mail, @arch";
                    command.Parameters.AddWithValue("@nom", client.nomClient);
                    command.Parameters.AddWithValue("@prenom", client.prenomClient);
                    command.Parameters.AddWithValue("@add", client.adresse);
                    command.Parameters.AddWithValue("@add2", client.adresse2);
                    command.Parameters.AddWithValue("@cp", client.cp);
                    command.Parameters.AddWithValue("@ville", client.ville);
                    command.Parameters.AddWithValue("@tel", client.numTel);
                    command.Parameters.AddWithValue("@ass", client.assurance);
                    command.Parameters.AddWithValue("@mail", client.email);
                    command.Parameters.AddWithValue("@arch", (client.archive != false) ? 1 : 0);

                    Guid dResult = (Guid)command.ExecuteScalar();
                    return(dResult);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #9
0
        public static bool DeleteLogin(Login login)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "DELETE FROM Logins WHERE Id = @Id";
                    command.Parameters.AddWithValue("@id", login.id);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #10
0
        public static List <Login> GetLogins()
        {
            List <Login> list = new List <Login>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Logins ORDER BY Login";

                    SqlDataReader dt = command.ExecuteReader();

                    int colId       = dt.GetOrdinal("Id");
                    int colLogin    = dt.GetOrdinal("Login");
                    int colPassword = dt.GetOrdinal("Password");

                    while (dt.Read())
                    {
                        Login login = new Login();
                        login.loginUser    = dt.GetString(colLogin);
                        login.passwordUser = dt.GetString(colPassword);
                        login.id           = dt.GetInt32(colId);
                        list.Add(login);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #11
0
        public static bool SetLogin(Login login)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Logins SET Login = @login, Password = @password WHERE Id = @Id";
                    command.Parameters.AddWithValue("@login", login.loginUser);
                    command.Parameters.AddWithValue("@password", login.passwordUser);
                    command.Parameters.AddWithValue("@id", login.id);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #12
0
        public static bool SetBaremeArchive(Bareme bareme)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Baremes SET Archive = '1' WHERE CodeGroupement = @code AND DateVigueur = @date";
                    command.Parameters.AddWithValue("@code", bareme.codeGroupement);
                    command.Parameters.AddWithValue("@date", bareme.dateVigueur);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #13
0
        public static List <Decimal> GetTarifsActes(String libelle)
        {
            List <Decimal> list = new List <Decimal>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT ISNULL(TarifFixe, 0) AS TarifFixe, ISNULL(TarifMini, 0) AS TarifMini, ISNULL(TarifMaxi, 0) AS TarifMaxi FROM Baremes WHERE Libelle LIKE ('%' + @libelle + '%')";
                    command.Parameters.AddWithValue("@libelle", libelle);

                    SqlDataReader dt      = command.ExecuteReader();
                    int           colFixe = dt.GetOrdinal("TarifFixe");
                    int           colMini = dt.GetOrdinal("TarifMini");
                    int           colMaxi = dt.GetOrdinal("TarifMaxi");

                    while (dt.Read())
                    {
                        list.Add(dt.GetDecimal(colFixe));
                        list.Add(dt.GetDecimal(colMini));
                        list.Add(dt.GetDecimal(colMaxi));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #14
0
        public static List <String> GetDateVigueurActe(String libelle)
        {
            List <String> list = new List <String>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT DateVigueur WHERE Libelle LIKE ('%' + @libelle + '%')";
                    command.Parameters.AddWithValue("@libelle", libelle);

                    SqlDataReader dt      = command.ExecuteReader();
                    int           colDate = dt.GetOrdinal("DateVigueur");

                    while (dt.Read())
                    {
                        list.Add(dt.GetString(colDate));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #15
0
 public static bool AddRace(Race laRace)
 {
     try
     {
         using (SqlConnection cnx = DALAccess.GetConnection())
         {
             SqlCommand command = cnx.CreateCommand();
             command.CommandType = System.Data.CommandType.Text;
             command.CommandText = "EXEC ajout_race @race ,@espece";
             command.Parameters.AddWithValue("@race", laRace.race);
             command.Parameters.AddWithValue("@espece", laRace.espece);
             int resultat = command.ExecuteNonQuery();
             if (resultat == 0)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Erreur : " + ex.Message);
     }
 }
예제 #16
0
        public static bool DeleteRDV(RendezVous rdv)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "DELETE A FROM Agendas A JOIN Veterinaires V ON A.CodeVeto = V.CodeVeto WHERE DateRdv = @dateRDV AND V.NomVeto = @nomVeto";
                    command.Parameters.AddWithValue("@dateRDV", rdv.dateRDV);
                    command.Parameters.AddWithValue("@nomVeto", rdv.nomVeto);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #17
0
        public static List <String> GetRaces(String espece)
        {
            List <String> list = new List <String>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT DISTINCT Race FROM Races WHERE Espece = @espece";
                    command.Parameters.AddWithValue("@espece", espece);

                    SqlDataReader dt      = command.ExecuteReader();
                    int           colRace = dt.GetOrdinal("Race");

                    while (dt.Read())
                    {
                        list.Add(dt.GetString(colRace));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #18
0
        public static bool GetFacturesImpayees(Guid codeClient)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Clients C JOIN Factures F ON C.CodeClient = F.CodeClient WHERE F.Etat != 2 AND F.CodeClient = @codeClient";
                    command.Parameters.AddWithValue("@codeClient", codeClient);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #19
0
 public static bool AddAnimal(Animal animal, Client client)
 {
     try
     {
         using (SqlConnection cnx = DALAccess.GetConnection())
         {
             SqlCommand command = cnx.CreateCommand();
             command.CommandType = System.Data.CommandType.Text;
             command.CommandText = "EXEC ajout_animal @nomCli,@prenomCli,@nom,@sexe,@couleur,@espece,@race,@tatouage,@arch";
             command.Parameters.AddWithValue("@nomCli", client.nomClient);
             command.Parameters.AddWithValue("@prenomCli", client.prenomClient);
             command.Parameters.AddWithValue("@nom", animal.nomAnimal);
             command.Parameters.AddWithValue("@sexe", animal.sexe);
             command.Parameters.AddWithValue("@couleur", animal.couleur);
             command.Parameters.AddWithValue("@espece", animal.espece);
             command.Parameters.AddWithValue("@race", animal.race);
             command.Parameters.AddWithValue("@tatouage", animal.tatouage);
             command.Parameters.AddWithValue("@arch", (animal.archive != false) ? 1 : 0);
             int resultat = command.ExecuteNonQuery();
             if (resultat == 0)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Erreur : " + ex.Message);
     }
 }
예제 #20
0
        public static bool AddActe(Acte acte)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_acte @codeConsultation, @codeGroupement, @datevigueur, @prix";
                    command.Parameters.AddWithValue("@codeConsultation", acte.numConsultation);
                    command.Parameters.AddWithValue("@codeGroupement", acte.codeGroupement);
                    command.Parameters.AddWithValue("@datevigueur", acte.dateVigueur);
                    command.Parameters.AddWithValue("@prix", acte.prix);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #21
0
 public static bool AddRDV(RendezVous rdv)
 {
     try
     {
         using (SqlConnection cnx = DALAccess.GetConnection())
         {
             SqlCommand command = cnx.CreateCommand();
             command.CommandType = System.Data.CommandType.Text;
             command.CommandText = "EXEC ajout_agenda @nomclient, @prenomclient,	@nomanimal,	@nomveto, @daterdv, @urgence";
             command.Parameters.AddWithValue("@nomclient", rdv.nomClient);
             command.Parameters.AddWithValue("@prenomclient", rdv.prenomClient);
             command.Parameters.AddWithValue("@nomanimal", rdv.nomAnimal);
             command.Parameters.AddWithValue("@nomveto", rdv.nomVeto);
             command.Parameters.AddWithValue("@daterdv", rdv.dateRDV);
             command.Parameters.AddWithValue("@urgence", (rdv.urgence != false) ? 1 : 0);
             int resultat = command.ExecuteNonQuery();
             if (resultat == 0)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Erreur : " + ex.Message);
     }
 }
예제 #22
0
        public static List <String> GetTypesActes()
        {
            List <String> list = new List <String>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT DISTINCT TypeActe FROM Baremes";

                    SqlDataReader dt      = command.ExecuteReader();
                    int           colType = dt.GetOrdinal("TypeActe");

                    while (dt.Read())
                    {
                        list.Add(dt.GetString(colType));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #23
0
        public static Veterinaire GetVeterinaire(Guid Id)
        {
            Veterinaire veto = new Veterinaire();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Veterinaires WHERE Archive = 0 AND CodeVeto = @id";
                    command.Parameters.AddWithValue("@id", Id);

                    SqlDataReader dt = command.ExecuteReader();

                    int colId       = dt.GetOrdinal("CodeVeto");
                    int colNom      = dt.GetOrdinal("NomVeto");
                    int colArchive  = dt.GetOrdinal("Archive");
                    int colRefLogin = dt.GetOrdinal("RefLogin");

                    while (dt.Read())
                    {
                        veto.nomVeto  = dt.GetString(colNom);
                        veto.archive  = dt.GetBoolean(colArchive);
                        veto.refLogin = dt.GetInt32(colRefLogin);
                        veto.codeVeto = dt.GetGuid(colId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(veto);
        }
예제 #24
0
        public static bool SetFacturePayee(Guid numFacture)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Factures SET Etat = 2 WHERE NumFacture = @id";
                    command.Parameters.AddWithValue("@id", numFacture);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #25
0
        public static List <Veterinaire> GetVeterinaires()
        {
            List <Veterinaire> list = new List <Veterinaire>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Veterinaires WHERE Archive = 0 ORDER BY NomVeto";

                    SqlDataReader dt          = command.ExecuteReader();
                    int           colID       = dt.GetOrdinal("CodeVeto");
                    int           colNom      = dt.GetOrdinal("NomVeto");
                    int           colArchive  = dt.GetOrdinal("Archive");
                    int           colRefLogin = dt.GetOrdinal("RefLogin");

                    while (dt.Read())
                    {
                        Veterinaire veto = new Veterinaire();
                        veto.codeVeto = dt.GetGuid(colID);
                        veto.nomVeto  = dt.GetString(colNom);
                        veto.archive  = dt.GetBoolean(colArchive);
                        veto.refLogin = dt.GetInt32(colRefLogin);
                        list.Add(veto);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #26
0
        public static bool DeleteVeterinaire(Veterinaire veterinaire)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Veterinaires SET Archive = 1 WHERE CodeVeto = @id";
                    command.Parameters.AddWithValue("@id", veterinaire.codeVeto.ToString().ToUpper());

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #27
0
 public static bool AddVeterinaire(Veterinaire veterinaire)
 {
     try
     {
         using (SqlConnection cnx = DALAccess.GetConnection())
         {
             SqlCommand command = cnx.CreateCommand();
             command.CommandType = System.Data.CommandType.Text;
             command.CommandText = "EXEC ajout_veterinaire @nomveto, @archive, @reflogin";
             command.Parameters.AddWithValue("@nomveto", veterinaire.nomVeto);
             command.Parameters.AddWithValue("@archive", veterinaire.archive);
             command.Parameters.AddWithValue("@reflogin", veterinaire.refLogin);
             int resultat = command.ExecuteNonQuery();
             if (resultat == 0)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Erreur : " + ex.Message);
     }
 }
예제 #28
0
        public static bool SetRelanceEnvoye(Facture relance)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "UPDATE Factures SET RappelEnvoye=@date WHERE NumFacture=@Num";
                    command.Parameters.AddWithValue("@Num", relance.numFacture);
                    command.Parameters.AddWithValue("@date", relance.rappelEnvoye);

                    int resultat = command.ExecuteNonQuery();
                    if (resultat == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
예제 #29
0
        public static List <Facture> GetRelances()
        {
            List <Facture> list = new List <Facture>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT F.NumFacture, F.DateFacture, F.CodeClient, V.NomVeto, A.NomAnimal, Cl.NomClient + ' ' + Cl.PrenomClient AS Client, C.DateConsultation, F.TotalFacture, F.Archive, F.Etat, F.RappelEnvoye FROM Veterinaires V JOIN Consultations C ON V.CodeVeto = C.CodeVeto JOIN Factures F ON C.NumFacture = F.NumFacture JOIN Clients Cl ON F.CodeClient = Cl.CodeClient JOIN Animaux A ON Cl.CodeClient = A.CodeClient WHERE F.Etat = '1'";

                    SqlDataReader dt = command.ExecuteReader();

                    int colNumFacture  = dt.GetOrdinal("NumFacture");
                    int colDateFacture = dt.GetOrdinal("DateFacture");
                    int colCodeClient  = dt.GetOrdinal("CodeClient");
                    int colNomVeto     = dt.GetOrdinal("NomVeto");
                    int colNomAnimal   = dt.GetOrdinal("NomAnimal");
                    int colNomClient   = dt.GetOrdinal("Client");
                    int colDateConsult = dt.GetOrdinal("DateConsultation");
                    int colTotal       = dt.GetOrdinal("TotalFacture");
                    int colArchive     = dt.GetOrdinal("Archive");
                    int colEtat        = dt.GetOrdinal("Etat");
                    int colRappel      = dt.GetOrdinal("RappelEnvoye");

                    while (dt.Read())
                    {
                        Facture relance = new Facture();
                        relance.numFacture   = dt.GetGuid(colNumFacture);
                        relance.dateFacture  = dt.GetDateTime(colDateFacture);
                        relance.codeClient   = dt.GetGuid(colCodeClient);
                        relance.nomVeto      = dt.GetString(colNomVeto);
                        relance.nomAnimal    = dt.GetString(colNomAnimal);
                        relance.nomClient    = dt.GetString(colNomClient);
                        relance.dateConsult  = dt.GetDateTime(colDateConsult);
                        relance.totalFacture = dt.GetDecimal(colTotal);
                        relance.archive      = dt.GetBoolean(colArchive);
                        relance.etat         = dt.GetInt32(colEtat);
                        relance.rappelEnvoye = dt.GetValue(colRappel) == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dt.GetDateTime(colRappel));

                        if (relance.rappelEnvoye == null && relance.dateFacture.AddMonths(1) <= DateTime.Now)
                        {
                            list.Add(relance);
                        }
                        else if (relance.rappelEnvoye != null && ((DateTime)relance.rappelEnvoye).AddMonths(1) <= DateTime.Now)
                        {
                            list.Add(relance);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
예제 #30
0
        public static List <Facture> GetFacturesImpayees()
        {
            List <Facture> list = new List <Facture>();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT F.NumFacture, F.DateFacture, F.CodeClient, V.NomVeto, A.NomAnimal, Cl.NomClient + ' ' + Cl.PrenomClient AS Client, Cl.Adresse1 + ' ' + ISNULL(Cl.Adresse2, ' ') + ' ' + Cl.CodePostal + ' ' + Cl.Ville AS Adresse, C.CodeConsultation, C.DateConsultation, F.TotalFacture, F.Archive, F.Etat, F.RappelEnvoye FROM Veterinaires V JOIN Consultations C ON V.CodeVeto = C.CodeVeto JOIN Factures F ON C.NumFacture = F.NumFacture JOIN Clients Cl ON F.CodeClient = Cl.CodeClient JOIN Animaux A ON C.CodeAnimal = A.CodeAnimal WHERE F.Archive = 0 AND F.Etat = 1";

                    SqlDataReader dt = command.ExecuteReader();

                    int colNumFacture    = dt.GetOrdinal("NumFacture");
                    int colDateFacture   = dt.GetOrdinal("DateFacture");
                    int colCodeClient    = dt.GetOrdinal("CodeClient");
                    int colNomVeto       = dt.GetOrdinal("NomVeto");
                    int colNomAnimal     = dt.GetOrdinal("NomAnimal");
                    int colAdresseClient = dt.GetOrdinal("Adresse");
                    int colNomClient     = dt.GetOrdinal("Client");
                    int colDateConsult   = dt.GetOrdinal("DateConsultation");
                    int colCodeConsult   = dt.GetOrdinal("CodeConsultation");
                    int colTotal         = dt.GetOrdinal("TotalFacture");
                    int colArchive       = dt.GetOrdinal("Archive");
                    int colEtat          = dt.GetOrdinal("Etat");
                    int colRappel        = dt.GetOrdinal("RappelEnvoye");

                    while (dt.Read())
                    {
                        Facture result = new Facture();
                        result.numFacture    = dt.GetGuid(colNumFacture);
                        result.dateFacture   = dt.GetDateTime(colDateFacture);
                        result.codeClient    = dt.GetGuid(colCodeClient);
                        result.nomVeto       = dt.GetString(colNomVeto);
                        result.adresseClient = dt.GetString(colAdresseClient).ToUpper();
                        result.nomAnimal     = dt.GetString(colNomAnimal);
                        result.nomClient     = dt.GetString(colNomClient);
                        result.dateConsult   = dt.GetDateTime(colDateConsult);
                        result.codeConsult   = dt.GetGuid(colCodeConsult);
                        result.totalFacture  = dt.GetDecimal(colTotal);
                        result.archive       = dt.GetBoolean(colArchive);
                        result.etat          = dt.GetInt32(colEtat);
                        result.rappelEnvoye  = dt.GetValue(colRappel) == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dt.GetDateTime(colRappel));
                        list.Add(result);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }