public static List<FamilleArticle> getListFamilleArticle(String query)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         List<FamilleArticle> l = new List<FamilleArticle>();
         NpgsqlCommand Lcmd = new NpgsqlCommand(query, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 FamilleArticle a = new FamilleArticle();
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Designation = lect["designation"].ToString();
                 a.Description = lect["description"].ToString();
                 a.Reference = lect["reference"].ToString();
                 a.Articles = BLL.ArticleBll.Liste("select * from yvs_articles");
                 a.Update = true;
                 l.Add(a);
             }
             lect.Close();
         }
         return l;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
 public static FamilleArticle getAjoutFamilleArticle(FamilleArticle a)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         string insert = "";
         NpgsqlCommand cmd = new NpgsqlCommand(insert, con);
         cmd.ExecuteNonQuery();
         a.Id = getCurrent();
         return a;
     }
     catch
     {
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
        private List<FamilleArticle> prodListFamille()
        {
            FamilleArticle Dflt = new FamilleArticle(0);
            Dflt.Description = "Articles sans réel famille";
            Dflt.Designation = "Autres";
            List<FamilleArticle> listInter = new List<FamilleArticle> { Dflt };

            List<Article> articless = new List<Article>();
            dpt = TOOLS.Constantes.Creneau.Depot;

            foreach (ArticleDepot arDpt in dpt.Articles)
            {
                articless.Add(arDpt.Article);
            }

            foreach (Article arT in articless)
            {
                if (arT.Famille.Id > 0)
                {
                    if (!listInter.Contains(arT.Famille))
                    {
                        FamilleArticle f = BLL.FamilleArticleBll.One_(arT.Famille.Id);
                        f.Articles.Add(arT);
                        listInter.Add(f);
                    }
                    else
                    {
                        FamilleArticle f = listInter.Find(x => x.Id == arT.Famille.Id);
                        f.Articles.Add(arT);
                        listInter[listInter.FindIndex(x => x.Id == f.Id)] = f;
                    }
                }
                else
                {
                    FamilleArticle f = listInter.Find(x => x.Id == Dflt.Id);
                    f.Articles.Add(arT);
                    listInter[listInter.FindIndex(x => x.Id == f.Id)] = f;
                }
            }
            return listInter;
        }
        //modification des boutons des familles
        private void ModifButton(Button ctl, FamilleArticle cli, Label lbl)
        {
            lbl.Visible = true;
            lbl.Text = cli.Designation;
            ctl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            ctl.Text = "";
            ctl.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            ctl.UseVisualStyleBackColor = true;
            ctl.Visible = true;
            ctl.Font = new System.Drawing.Font("Trebuchet MS", 12F, System.Drawing.FontStyle.Bold,
                System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            ctl.Click += delegate(object sender, EventArgs e)
            {
                tabControl2.SelectedIndex = 1;
                ctl.BackColor = Color.DarkGray;
                indTabA = 0;
                articles.Clear();
                articles.AddRange(cli.Articles);

                nbrPgA = ((articles.Count % 8) > 1) ? (articles.Count / 8) + 1 : (articles.Count / 8);
                btn_cpt_Articles.Text = "0/" + nbrPgA;

                pgGaucheA.Enabled = false;
                pgDroiteA.Enabled = cli.Articles.Count > 8;

                InitArticle();
                ctl.Enabled = false;
                foreach (Button btn in buttonFs)
                {
                    if (btn != ctl)
                    {
                        btn.Enabled = true;
                    }
                }

                //foreach (Button btn in buttonAs)
                //{
                //    if (btn != ctl)
                //    {
                //        btn.Enabled = true;
                //    }
                //}
            };
        }
 public static bool getUpdateFamilleArticle(FamilleArticle a)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         string update = "";
         NpgsqlCommand Ucmd = new NpgsqlCommand(update, con);
         Ucmd.ExecuteNonQuery();
         return true;
     }
     catch (Exception e)
     {
         Messages.Exception(e);
         return false;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
 public static FamilleArticle getOneFamilleArticle_(long id)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select * from yvs_base_famille_article where id = " + id + "";
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         FamilleArticle a = new FamilleArticle();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Designation = lect["designation"].ToString();
                 a.Description = lect["description"].ToString();
                 a.Reference = lect["reference"].ToString();
             }
             a.Update = true;
             lect.Close();
         }
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
 public FamilleArticleBll(FamilleArticle unFamilleArticle)
 {
     famille = unFamilleArticle;
 }