public void rapport() { try { // MessageBox.Show("test"); RAPPORT unRapport = (RAPPORT)bsRapport.Current; textBox1.Text = unRapport.idRapport.ToString(); textBox3.Text = unRapport.dateRapport.ToString(); textBox4.Text = unRapport.MOTIF.libMotif.ToString(); textBox5.Text = unRapport.bilan.ToString(); // textBox4.Text = unRapport..ToString(); bsMedecin.DataSource = Model.MaConnexion.MEDECIN.ToList() .Where(x => x.idMedecin == int.Parse(unRapport.idMedecin.ToString())) .Select(x => new { x.idMedecin, info = x.nom + " " + x.prenom }) .OrderBy(x => x.info); bsMedecin2.DataSource = Model.MaConnexion.MEDECIN.ToList() .Where(x => x.idMedecin == int.Parse(unRapport.idMedecin.ToString())); dataGridView2.Hide(); dataGridView2.DataSource = bsMedecin2; BindingSource MonRapport = new BindingSource(); comboMedecin.ValueMember = "idMedecin"; comboMedecin.DisplayMember = "info"; comboMedecin.DataSource = bsMedecin; bsOffre.DataSource = Model.MaConnexion.OFFRIR.ToList() .Select(x => new { x.idMedicament, x.quantite, x.idRapport }) .Where(x => x.idRapport == int.Parse(unRapport.idRapport.ToString())); // bsPresenter.DataSource = Model.MaConnexion.RAPPORT.Presenter.tolist(); /* foreach (BindingSource bsOffre in uneOffre) * { * bsMedicamen.DataSource = Model.MaConnexion.MEDICAMENT.ToList() * .Where(x => x.idMedicament == int.Parse(unRapport.idMedecin.ToString())) * ; * }*/ dataGridView1.DataSource = bsOffre; this.vRapport = unRapport; } catch { textBox1.Text = "Aucun"; } }
private void button5_Click(object sender, EventArgs e) { // enregistrement new /* try * {*/ RAPPORT newRapport = new RAPPORT(); newRapport.idMedecin = comboMedecin.SelectedIndex; newRapport.dateRapport = dateTimePicker1.Value; newRapport.idMotif = comboBox1.SelectedIndex; newRapport.bilan = textBox5.Text; newRapport.coef = int.Parse(numericUpDown1.Value.ToString()); REMPLACANT newRempla = new REMPLACANT(); newRempla.nom = textBox6.Text; newRempla.prenom = textBox7.Text; newRapport.REMPLACANT = newRempla; Model.MaConnexion.RAPPORT.Add(newRapport); Model.MaConnexion.SaveChanges(); int i; for (i = 0; i < ((dataGridView3.Rows.Count) - 1); i++) { OFFRIR newOffrir = new OFFRIR(); newOffrir.idMedicament = dataGridView3.Rows[i].Cells[0].Value.ToString(); newOffrir.idRapport = int.Parse(newRapport.idRapport.ToString()); newOffrir.quantite = int.Parse(dataGridView3.Rows[i].Cells[2].Value.ToString()); Model.MaConnexion.OFFRIR.Add(newOffrir); Model.MaConnexion.SaveChanges(); } MessageBox.Show("Enregistrement fait"); /* }catch (Exception erreur){ * MessageBox.Show("Erreur : " + erreur); * } */ button1.Show(); button2.Show(); Modif.Show(); button3.Show(); button5.Hide(); comboBox1.Hide(); dataGridView1.Show(); button5.Hide(); dateTimePicker1.Hide(); dataGridView3.Hide(); comboBox2.Hide(); textBox2.Hide(); button6.Hide(); label6.Hide(); rapport(); }