Beispiel #1
0
        public static Acte GetActe(Guid codeActe)
        {
            Acte result = new Acte();

            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT LC.CodeConsultation, LC.NumLigne, LC.CodeGroupement, LC.DateVigueur, LC.Prix, B.TypeActe, B.Libelle FROM LignesConsultations LC JOIN Baremes B ON LC.CodeGroupement = B.CodeGroupement WHERE LC.NumLigne = @codeActe AND LC.Archive = 0;";
                    command.Parameters.AddWithValue("@codeActe", codeActe);

                    SqlDataReader dt = command.ExecuteReader();

                    int colCode        = dt.GetOrdinal("CodeConsultation");
                    int colActe        = dt.GetOrdinal("NumLigne");
                    int colGroup       = dt.GetOrdinal("CodeGroupement");
                    int colDateVigueur = dt.GetOrdinal("DateVigueur");
                    int colPrix        = dt.GetOrdinal("Prix");
                    int colType        = dt.GetOrdinal("TypeActe");
                    int colLibelle     = dt.GetOrdinal("Libelle");

                    while (dt.Read())
                    {
                        result.numConsultation = dt.GetGuid(colCode);
                        result.numActe         = dt.GetGuid(colActe);
                        result.codeGroupement  = dt.GetString(colGroup);
                        result.dateVigueur     = dt.GetString(colDateVigueur);
                        result.prix            = dt.GetDecimal(colPrix);
                        result.typeActe        = dt.GetString(colType);
                        result.libelle         = dt.GetString(colLibelle);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(result);
        }
Beispiel #2
0
        public static int GetDernierCodeVaccin()
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT MAX(CodeGroupement) + 1 FROM Baremes WHERE TypeActe = 'VACC'";

                    String dResult  = command.ExecuteScalar().ToString();
                    int    resultat = int.Parse(dResult);

                    return(resultat);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
Beispiel #3
0
        public static List <Vaccin> GetVaccins()
        {
            List <Vaccin> list = new List <Vaccin>();

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

                    SqlDataReader dt = command.ExecuteReader();
                    list = builderObject(dt);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
            return(list);
        }
Beispiel #4
0
        public static Guid AddVaccin(Vaccin leVaccin)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_vaccin @nomvaccin, @periodevalidite, @quantite";
                    command.Parameters.AddWithValue("@nomvaccin", leVaccin.nomVaccin);
                    command.Parameters.AddWithValue("@periodevalidite", leVaccin.periodeValidite);
                    command.Parameters.AddWithValue("@quantite", leVaccin.quantiteStock);

                    Guid dResult = (Guid)command.ExecuteScalar();
                    return(dResult);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
        public static Guid AddConsultation(Consultation consultation)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_consultation @dateconsultation, @codeVeto, @codeAnimal, @commentaire";
                    command.Parameters.AddWithValue("@dateconsultation", consultation.dateConsultation);
                    command.Parameters.AddWithValue("@codeVeto", consultation.codeVeto);
                    command.Parameters.AddWithValue("@codeAnimal", consultation.codeAnimal);
                    command.Parameters.AddWithValue("@commentaire", consultation.commentaire == null ? String.Empty : consultation.commentaire);

                    Guid dResult = (Guid)command.ExecuteScalar();
                    return(dResult);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
Beispiel #6
0
        public static int AddLogin(Login login)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_login @login, @password, 0;";
                    command.Parameters.AddWithValue("@login", login.loginUser);
                    command.Parameters.AddWithValue("@password", login.passwordUser);

                    Decimal dResult  = (decimal)command.ExecuteScalar();
                    int     resultat = (int)dResult;

                    return(resultat);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
Beispiel #7
0
        public static Guid AddFacture(Facture facture)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "EXEC ajout_facture @DateFact, @nomVeto, @nomanimal, @dateConsultation, @etat";
                    command.Parameters.AddWithValue("@DateFact", facture.dateFacture);
                    command.Parameters.AddWithValue("@nomVeto", facture.nomVeto);
                    command.Parameters.AddWithValue("@nomanimal", facture.nomAnimal);
                    command.Parameters.AddWithValue("@dateConsultation", facture.dateConsult);
                    command.Parameters.AddWithValue("@etat", facture.etat);

                    Guid dResult = (Guid)command.ExecuteScalar();
                    return(dResult);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }
Beispiel #8
0
        public static Veterinaire GetVeterinaireConnect(String User, String Passwd)
        {
            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 V JOIN Logins L ON V.RefLogin = L.ID WHERE L.Login = @login AND L.Password = @password";
                    command.Parameters.AddWithValue("@login", User);
                    command.Parameters.AddWithValue("@password", Passwd);

                    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);
        }
        public static bool CheckRDV(Guid codeVeto, DateTime laDate)
        {
            try
            {
                using (SqlConnection cnx = DALAccess.GetConnection())
                {
                    SqlCommand command = cnx.CreateCommand();
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = "SELECT * FROM Agendas WHERE CodeVeto = @codeVeto AND DateRdv = @date";
                    command.Parameters.AddWithValue("@codeVeto", codeVeto);
                    command.Parameters.AddWithValue("@date", laDate);

                    SqlDataReader dt = command.ExecuteReader();

                    int resultat = 0;

                    while (dt.Read())
                    {
                        resultat++;
                    }

                    if (resultat == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erreur : " + ex.Message);
            }
        }