Ejemplo n.º 1
0
        public static bool DelPrevision(Prevision pr)
        {
            using (SqlConnection sqlConnect = DaoProjet.ConnectSQLServ())
            {
                using (SqlCommand sqlCde = new SqlCommand())
                {//TODO verifier le conflict
                    try
                    {
                        // Ouvre la connection. 
                        sqlConnect.Open();
                        // Création de la commande  
                        SqlDataReader sqlRdr;
                        sqlCde.Connection = sqlConnect;
                        // Constitution Requête SQL  

                        //sqlCde.CommandText = strSql;
                        sqlCde.CommandType = System.Data.CommandType.StoredProcedure;
                        sqlCde.CommandText = "DelPrevision";
                        //affectation du parametre à la procédure stockée
                        sqlCde.Parameters.Add(new SqlParameter("@idprevision", System.Data.SqlDbType.Int)).Value = pr.CodePrevision;
                        // Exécution de la commande  
                        sqlRdr = sqlCde.ExecuteReader();
                        sqlRdr.Close();

                        return true;




                    }
                    catch (Exception ex)
                    {
                        throw new DaoException("Suppression prévision impossible  : " + ex.Message, ex);
                    }
                    finally { sqlConnect.Close(); }
                }
            }
        }
Ejemplo n.º 2
0
        public static bool AddPrevision(Prevision pr)
        {
            using (SqlConnection sqlConnect = DaoProjet.ConnectSQLServ())
            {
                using (SqlCommand sqlCde = new SqlCommand())
                {//TODO verifier le conflict
                    try
                    {
                        // Ouvre la connection. 
                        sqlConnect.Open();
                        // Création de la commande  
                        SqlDataReader sqlRdr;
                        sqlCde.Connection = sqlConnect;
                        // Constitution Requête SQL  

                        //sqlCde.CommandText = strSql;
                        sqlCde.CommandType = System.Data.CommandType.StoredProcedure;
                        sqlCde.CommandText = "AddPrevision";
                        //affectation du parametre à la procédure stockée
                        sqlCde.Parameters.Add(new SqlParameter("@idProjet", System.Data.SqlDbType.Int)).Value = pr.CodeProjet;
                        sqlCde.Parameters.Add(new SqlParameter("@idQualif", System.Data.SqlDbType.TinyInt)).Value = pr.LaQualif.CodeQualif;
                        sqlCde.Parameters.Add(new SqlParameter("@nbJours", System.Data.SqlDbType.SmallInt)).Value = pr.NbJours;

                        //affectation du parametre OUT à la procédure stockée
                        SqlParameter pOut = new SqlParameter("@idPrevision", System.Data.SqlDbType.Int);
                        pOut.Direction = System.Data.ParameterDirection.Output;
                        sqlCde.Parameters.Add(pOut);

                        // Exécution de la commande  
                        sqlRdr = sqlCde.ExecuteReader();
                        sqlRdr.Close();

                        return true;
                    }
                    catch (Exception ex)
                    {
                        throw new DaoException("Ajout prévision impossible  : " + ex.Message, ex);
                    }
                    finally { sqlConnect.Close(); }
                }
            }
        }
Ejemplo n.º 3
0
        public static List<Prevision> GetAllPrevisions(int idProj)
        {

            using (SqlConnection sqlConnect = DaoProjet.ConnectSQLServ())
            {
                using (SqlCommand sqlCde = new SqlCommand())
                {
                    try
                    {
                        // Ouvre la connection. 
                        sqlConnect.Open();
                        // Création de la commande  
                        SqlDataReader sqlRdr;
                        sqlCde.Connection = sqlConnect;
                        // Constitution Requête SQL  +++++++++
                        string strSql = string.Format("Select * from Prevision where idProjet = '{0}'", idProj);
                        //// Positionnement des propriétés
                        sqlCde.CommandText = strSql;
                        //sqlCde.CommandType = System.Data.CommandType.StoredProcedure;
                        //sqlCde.CommandText = "GetAllPrevisions";
                        // Exécution de la commande  
                        sqlRdr = sqlCde.ExecuteReader();
                        // Lecture des données du DataReader 
                        Prevision = new List<Prevision>();
                        while (sqlRdr.Read())
                        {

                            Prevision prev = new Prevision()
                            {
                                CodePrevision = sqlRdr.GetInt32(0),
                                CodeProjet = sqlRdr.GetInt32(1),
                                LaQualif = new Qualification()
                                {
                                    CodeQualif = (sbyte)sqlRdr.GetByte(2)
                                },
                                NbJours = sqlRdr.GetInt16(3)

                            };
                            Prevision.Add(prev);


                        }

                        // Fin des données  
                        sqlRdr.Close();
                        
                        return Prevision;
                    }
                    catch (Exception ex)
                    {
                        throw new DaoException("Récupération des prevision impossible  :" + ex.Message, ex);
                    }
                    finally { sqlConnect.Close(); }
                }
            }

        }
Ejemplo n.º 4
0
 public bool DelPrevision(Prevision pr)
 {
     prevision.Remove(pr);
     return true;
 }
Ejemplo n.º 5
0
 public bool UpgPrevision(Prevision pr)
 {
     prevision.Remove(pr);
     prevision.Add(pr);
     return true;
 }
Ejemplo n.º 6
0
 public bool AddPrevision(Prevision pr)
 {
     prevision.Add(pr);
     return true;
 }