public static Poste GetPoste(int code_poste)
        {
            Poste      d  = new Poste();
            Connecteur ct = new Connecteur();

            try
            {
                SqlDataAdapter dae = new SqlDataAdapter(StatutCarriereDAL.selectPoste, ct.Connection);
                dae.SelectCommand.Parameters.AddWithValue("@CodePoste", code_poste);

                DataTable dt = new DataTable("Poste");

                ct.Connection.Open();
                dae.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    StatutCarriereDAL.Hydrate(d, dr);
                }

                return(d);
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
        public static Departement GetDepartement(string code_departement)
        {
            Departement d  = new Departement();
            Connecteur  ct = new Connecteur();

            try
            {
                SqlDataAdapter dae = new SqlDataAdapter(StatutCarriereDAL.selectDepartement, ct.Connection);
                dae.SelectCommand.Parameters.AddWithValue("@CodeDepartement", code_departement);

                DataTable dt = new DataTable("Departement");

                ct.Connection.Open();
                dae.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    StatutCarriereDAL.Hydrate(d, dr);
                }

                return(d);
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
        public static StatutCarriere GetStatutCarriereActuel(string code)
        {
            StatutCarriere s  = new StatutCarriere();
            Connecteur     ct = new Connecteur();

            try
            {
                SqlDataAdapter dae = new SqlDataAdapter(StatutCarriereDAL.selectActualEmployeStatutCarriere, ct.Connection);
                dae.SelectCommand.Parameters.AddWithValue("@CodeEmploye", code);

                DataTable dt = new DataTable("StatutCarriere");

                ct.Connection.Open();
                dae.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    StatutCarriereDAL.Hydrate(s, dr);
                }

                return(s);
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
        public static List <StatutCarriere> GetStatutCarrieres(string code)
        {
            List <StatutCarriere> lCarriere = new List <StatutCarriere>();
            Connecteur            ct        = new Connecteur();

            try
            {
                SqlDataAdapter dae = new SqlDataAdapter(StatutCarriereDAL.selectEmployeStatutCarrieres, ct.Connection);
                dae.SelectCommand.Parameters.AddWithValue("@CodeEmploye", code);

                DataTable dt = new DataTable("StatutCarriere");

                ct.Connection.Open();
                dae.Fill(dt);

                StatutCarriere s;

                foreach (DataRow dr in dt.Rows)
                {
                    s = new StatutCarriere();
                    StatutCarriereDAL.Hydrate(s, dr);
                    lCarriere.Add(s);
                }

                return(lCarriere);
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
Exemple #5
0
        public static void Insert(Employe emp, StatutCarriere stc)
        {
            Connecteur ct = new Connecteur();


            if (ct.Connection.State == ConnectionState.Closed)
            {
                ct.Connection.Open();
            }

            //----Begin Transaction---
            SqlTransaction trans = ct.Connection.BeginTransaction();

            try
            {
                //Proceed Database Command-------------------------------------
                SqlCommand employeCmd =
                    new SqlCommand(EmployeDAL.insertEmploye, ct.Connection, trans);

                SqlCommand carriereCmd =
                    new SqlCommand(StatutCarriereDAL.InsertStatutCarriere, ct.Connection, trans);

                //1 - INSERT Employe
                //Employe Params - Insert
                EmployeDAL.setEmployeParameters(employeCmd.Parameters, emp);
                employeCmd.ExecuteNonQuery();

                //2 - INSERT StatutCarriere
                //StatutCarriere Params  - Insert
                StatutCarriereDAL.setStatutCarriereParameters(carriereCmd.Parameters, stc);
                carriereCmd.ExecuteNonQuery();

                //Commit Transaction
                trans.Commit();

                //-------------------------------------------------------------
            }
            catch (SqlException ex)
            {
                trans.Rollback();
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
        public static void AjouterStatut(StatutCarriere stc)
        {
            Connecteur ct = new Connecteur();

            //Proceed Database Command-------------------------------------
            if (ct.Connection.State == ConnectionState.Closed)
            {
                ct.Connection.Open();
            }

            //----Begin Transaction---
            SqlTransaction trans = ct.Connection.BeginTransaction();

            SqlCommand ancienCarriereCmd =
                new SqlCommand(StatutCarriereDAL.updateAncienStatut, ct.Connection, trans);

            SqlCommand carriereCmd =
                new SqlCommand(StatutCarriereDAL.insertStatutCarriere, ct.Connection, trans);

            try
            {
                //1 - Update FinStatut de l'Ancien Statut
                //Employe Params - Insert
                ancienCarriereCmd.Parameters.AddWithValue("@CodeEmploye", stc.CodeEmploye);
                ancienCarriereCmd.Parameters.AddWithValue("@FinStatut", stc.Debut);
                ancienCarriereCmd.ExecuteNonQuery();

                //2 - INSERT StatutCarriere
                //StatutCarriere Params  - Insert
                StatutCarriereDAL.setStatutCarriereParameters(carriereCmd.Parameters, stc);
                carriereCmd.ExecuteNonQuery();

                //Commit Transaction
                trans.Commit();

                //-------------------------------------------------------------
            }
            catch (SqlException ex)
            {
                trans.Rollback();
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }