You are on page 1of 2

Entity framwork

rivate void reservationForm_Load(object sender, EventArgs e)

using(efm2021Entities ctx=new efm2021Entities())

comboBox1.DataSource = ctx.clients.ToList();

comboBox1.DisplayMember = "nom";

comboBox1.ValueMember = "id_c";

//comboBox1.DataSource = ado.das.client;

//comboBox1.DisplayMember = ado.das.client.nomColumn.ColumnName;

//comboBox1.ValueMember = ado.das.client.id_cColumn.ColumnName;

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

using(efm2021Entities ctx=new efm2021Entities())

try

int id = int.Parse(comboBox1.SelectedValue.ToString());

client c = ctx.clients.Find(id);

lbphone.Text = c.telclient.ToString();

lb_nom.Text = c.nom.ToString();

catch { }

private void button1_Click(object sender, EventArgs e)


{

using (efm2021Entities ctx = new efm2021Entities())

int id = int.Parse(comboBox1.SelectedValue.ToString());

reservation res = new reservation();

res.C_id_cl = id;

res.date_res = Convert.ToDateTime(dateTimePicker1.Value.ToString());

if(radioButton1.Checked==true)

res.pensienCom = true;

if (radioButton2.Checked == true)

res.pensienCom = false;

ctx.reservations.Add(res);

MessageBox.Show("bien ajouter");

You might also like