Exemplo n.º 1
0
        public static List <Conge> getConges(string code_employe)
        {
            List <Conge> lCarriere = new List <Conge>();
            Connecteur   ct        = new Connecteur();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter(CongeDAL.selectEmployeConges, ct.Connection);
                da.SelectCommand.Parameters.AddWithValue("@CodeEmploye", code_employe);

                DataTable dt = new DataTable("Conge");

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

                Conge s;

                foreach (DataRow dr in dt.Rows)
                {
                    s = new Conge();
                    CongeDAL.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();
            }
        }
Exemplo n.º 2
0
        public static void Insert(Conge c)
        {
            Connecteur ct = new Connecteur();

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

            SqlCommand cmd =
                new SqlCommand(CongeDAL.insertConge, ct.Connection);

            try
            {
                //1 - INSERT Conge
                //Conge Params - Insert
                CongeDAL.setCongeParameters(cmd.Parameters, c);
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }