Esempio n. 1
0
        public FormModal(T_elements thisElement = null)
        {
            InitializeComponent();

            if (_parties != null && _parties.Count > 0)
            {
                Dictionary <int, string> parties = _parties.ToDictionary(p => p.Id_partie, p => p.partieLibelle);

                select_partie.DataSource    = new BindingSource(parties, null);
                select_partie.DisplayMember = "Value";
                select_partie.ValueMember   = "Key";

                if (thisElement != null)
                {
                    name_element.Text           = thisElement.elementLibelle;
                    display_image.Image         = DisplayBase64Picture(thisElement.elementsImg);
                    select_partie.SelectedValue = thisElement.partie_id;
                    id_element.Text             = thisElement.Id_element.ToString();

                    add_element.Click -= new EventHandler(add_element_Click);
                    add_element.Click += new EventHandler(update_element_Click);

                    admin_titre.Text = "Modifier un element";
                }
            }
            else
            {
                MessageBox.Show("Impossible de récupérer les parties de licorne", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Dispose();
            }
        }
Esempio n. 2
0
        public static List <T_elements> getAllElements()
        {
            SQLiteConnection conn = new SQLiteConnection(_db);

            conn.Open();
            string            sql      = "SELECT Id_element, elementLibelle, elementsImg, partie_id from t_elements";
            SQLiteCommand     command  = new SQLiteCommand(sql, conn);
            SQLiteDataReader  reader   = command.ExecuteReader();
            List <T_elements> elements = new List <T_elements>();

            while (reader.Read())
            {
                T_elements e = new T_elements();
                e.Id_element     = Convert.ToInt32(reader.GetValue(0));
                e.elementLibelle = reader.GetValue(1).ToString();
                e.elementsImg    = reader.GetValue(2).ToString();
                e.partie_id      = Convert.ToInt32(reader.GetValue(3));
                elements.Add(e);
            }
            conn.Close();
            return(elements);
        }