Beispiel #1
0
        public static TarifVol GetTarifVol(int id)
        {
            bdd.OpenConnection();
            string       query = "SELECT * FROM tarif_vol WHERE id = @id;";
            MySqlCommand cmd   = new MySqlCommand(query, bdd.GetConnection());

            cmd.Parameters.AddWithValue("@id", id);
            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            TarifVol TarifVol = new TarifVol(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetFloat(3));

            reader.Close();
            bdd.CloseConnection();
            return(TarifVol);
        }
        private void Edit(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.EditAction == DataGridEditAction.Commit)
            {
                DataGridColumn column = e.Column;
                if (column != null)
                {
                    string   column_nom = (string)column.Header;
                    TextBox  el         = e.EditingElement as TextBox;
                    TarifVol TarifVol   = DAL_TarifVol.GetTarifVol(IdTarifVol);
                    int      value;

                    switch (column_nom)
                    {
                    case "Tarif":
                        if (!int.TryParse(el.Text, out value))
                        {
                            value = TarifVol.Tarif;
                        }
                        TarifVol.Tarif = value;
                        break;

                    case "Vol":
                        if (!int.TryParse(el.Text, out value))
                        {
                            value = TarifVol.Vol;
                        }
                        TarifVol.Vol = value;
                        break;

                    case "Prix":
                        float prix;
                        if (!float.TryParse(el.Text, out prix))
                        {
                            prix = TarifVol.Prix;
                        }
                        TarifVol.Prix = prix;
                        break;

                    default:
                        break;
                    }
                    DAL_TarifVol.ModifierTarifVol(TarifVol.Id, TarifVol.Tarif, TarifVol.Vol, TarifVol.Prix);
                }
            }
        }
Beispiel #3
0
        public static ObservableCollection <TarifVol> SelectTarifVols()
        {
            ObservableCollection <TarifVol> TarifVols = new ObservableCollection <TarifVol>();

            bdd.OpenConnection();
            string       query = "SELECT * FROM tarif_vol;";
            MySqlCommand cmd   = new MySqlCommand(query, bdd.GetConnection());

            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                TarifVol TarifVol = new TarifVol(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetFloat(3));
                TarifVols.Add(TarifVol);
            }
            reader.Close();
            bdd.CloseConnection();
            return(TarifVols);
        }