Ejemplo n.º 1
0
        public static AutorisationFormulaire oneAutorisationFormulaire(Int32 id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String                 search = "select * from autorisation_formulaire where id = " + id;
                NpgsqlCommand          Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader       lect   = Lcmd.ExecuteReader();
                AutorisationFormulaire y      = new AutorisationFormulaire();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        y.Id         = id;
                        y.Niveau     = BLL.NiveauAccesBLL.One((Int32)((lect["niveau"] != null) ? (!lect["niveau"].ToString().Trim().Equals("") ? lect["niveau"] : 0) : 0));
                        y.Formulaire = BLL.FormulairesBLL.One((Int32)((lect["formulaire"] != null) ? (!lect["formulaire"].ToString().Trim().Equals("") ? lect["formulaire"] : 0) : 0));
                        y.Update     = (Boolean)((lect["acces"] != null) ? (!lect["acces"].ToString().Trim().Equals("") ? lect["acces"] : false) : false);
                    }
                }
                return(y);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Ejemplo n.º 2
0
        public static List <AutorisationFormulaire> listAutorisationFormulaire(string query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                NpgsqlCommand    Lcmd           = new NpgsqlCommand(query, con);
                NpgsqlDataReader lect           = Lcmd.ExecuteReader();
                List <AutorisationFormulaire> l = new List <AutorisationFormulaire>();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        AutorisationFormulaire y = oneAutorisationFormulaire((Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0));
                        l.Add(y);
                    }
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Ejemplo n.º 3
0
        public static Int32 currentAutorisationFormulaire(AutorisationFormulaire f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from autorisation_formulaire where niveau = " + f.Niveau.Id + " and formulaire = " + f.Formulaire.Id + "";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                Int32            id     = new Int32();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        id = (Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0);
                    }
                }
                return(id);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(0);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Ejemplo n.º 4
0
 private void dgv_form_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgv_form.Rows.Count > 0)
         {
             if (dgv_form.CurrentRow.Cells["id_form_"].Value != null)
             {
                 Int32 id = (Int32)dgv_form.CurrentRow.Cells["id_form_"].Value;
                 if (id > 0)
                 {
                     Formulaires            f = new Formulaires(id);
                     bool                   b = (bool)dgv_form.CurrentRow.Cells[e.ColumnIndex].Value;
                     AutorisationFormulaire a = AutorisationFormulaireBLL.One(AutorisationFormulaireBLL.Current(new AutorisationFormulaire(current, f, b)));
                     if (a != null ? a.Id > 0 : false)
                     {
                         AutorisationFormulaireBLL.Update(new AutorisationFormulaire(a.Id, current, f, b));
                     }
                     else
                     {
                         AutorisationFormulaireBLL.Save(new AutorisationFormulaire(current, f, b));
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Messages.Exception(ex);
     }
 }
 public static bool Delete(AutorisationFormulaire y)
 {
     try
     {
         return(AutorisationFormulaireDAO.deleteAutorisationFormulaire(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Suppression Impossible", ex);
     }
 }
 public static bool Update(AutorisationFormulaire y)
 {
     try
     {
         return(AutorisationFormulaireDAO.updateAutorisationFormulaire(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Modification Impossible", ex);
     }
 }
 public static AutorisationFormulaire Save(AutorisationFormulaire y)
 {
     try
     {
         return(AutorisationFormulaireDAO.saveAutorisationFormulaire(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Insertion Impossible", ex);
     }
 }
 public static Int32 Current(AutorisationFormulaire y)
 {
     try
     {
         return(AutorisationFormulaireDAO.currentAutorisationFormulaire(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Retour Impossible", ex);
     }
 }
Ejemplo n.º 9
0
        private NiveauAcces SuperNiveau()
        {
            NiveauAcces        n     = new NiveauAcces();
            string             query = "select * from niveau_acces where super = true limit 1";
            List <NiveauAcces> l     = NiveauAccesBLL.List(query);

            if (l != null ? l.Count > 0 : false)
            {
                n = l[0];
            }
            else
            {
                n.Super       = true;
                n.Description = "Super Administrateur";
                n.Designation = "Super Administrateur";
                n             = NiveauAccesBLL.Save(n);
            }

            query = "select * from formulaires";
            List <Formulaires> lf = FormulairesBLL.List(query);

            foreach (Formulaires f in lf)
            {
                AutorisationFormulaire a = AutorisationFormulaireBLL.One(AutorisationFormulaireBLL.Current(new AutorisationFormulaire(n, f, true)));
                if (a != null ? a.Id < 1 : true)
                {
                    AutorisationFormulaireBLL.Save(new AutorisationFormulaire(n, f, true));
                }
            }

            query = "select * from ressources";
            List <Ressources> lr = RessourcesBLL.List(query);

            foreach (Ressources r in lr)
            {
                AutorisationRessource a = AutorisationRessourceBLL.One(AutorisationRessourceBLL.Current(new AutorisationRessource(n, r, true)));
                if (a != null ? a.Id < 1 : true)
                {
                    AutorisationRessourceBLL.Save(new AutorisationRessource(n, r, true));
                }
            }
            return(n);
        }
Ejemplo n.º 10
0
        public static bool deleteAutorisationFormulaire(AutorisationFormulaire f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        delete = "delete from autorisation_formulaire where id = " + f.Id;
                NpgsqlCommand cmd    = new NpgsqlCommand(delete, con);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Ejemplo n.º 11
0
        public static bool updateAutorisationFormulaire(AutorisationFormulaire f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "update autorisation_formulaire set acces = '" + f.Update + "' where id = " + f.Id;
                NpgsqlCommand cmd    = new NpgsqlCommand(update, con);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Ejemplo n.º 12
0
        public static AutorisationFormulaire saveAutorisationFormulaire(AutorisationFormulaire f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "insert into autorisation_formulaire (niveau, formulaire, acces) values (" + f.Niveau.Id + "," + f.Formulaire.Id + ",'" + f.Update + "')";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                f.Id = currentAutorisationFormulaire(f);
                return(f);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }