Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionusing System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Threading.Tasks; using System.Text; using System.Windows.Forms; using WindowsFormsApp1.BLL; using WindowsFormsApp1.DAL; using WindowsFormsApp1.TOOL; using MySql.Data.MySqlClient; namespace WindowsFormsApp1.Windows_Form.enseignant { public partial class modifierense : Form { //Appel des controleurs , info et chaines de connexion databasehelper dh = new databasehelper(); MySqlDataReader dr; operateurcontroleur opc = new operateurcontroleur(); operateurinfo opi = new operateurinfo(); FormCollection listform; DataSet ds1, ds2, ds3; //variable bool result; private UserControl modiens; public modifierense(UserControl mde) { InitializeComponent(); this.modiens = mde; } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { } private void button4_TextChanged(object sender, EventArgs e) { } private void button4_BackColorChanged(object sender, EventArgs e) { } private void txtdemande_SelectedIndexChanged(object sender, EventArgs e) { try { if (txtdemande.Text == "Accepter") { button4.FlatAppearance.MouseOverBackColor = Color.ForestGreen; button4.FlatAppearance.MouseDownBackColor = Color.ForestGreen; } else if (txtdemande.Text == "En attente") { button4.FlatAppearance.MouseOverBackColor = Color.Orange; button4.FlatAppearance.MouseDownBackColor = Color.Orange; } else if (txtdemande.Text == "Refuser") { button4.FlatAppearance.MouseOverBackColor = Color.Red; button4.FlatAppearance.MouseDownBackColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button1_Click(object sender, EventArgs e) { this.Close(); } private void modifierense_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { } private void button4_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Voulez vous modifier cet programme enseignant?", "GSED", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { dh.ExecuteNonQuery("update enseignant set demande_de_permission = '" + txtdemande.Text.Replace("'", "''") + "' where code_enseignant='" + txtcodeenseignant.Text + "' "); MessageBox.Show("Le Programme enseignant modifié avec succès", "GSED"); (modiens as UCenseignant).affie(); txtnom.Text = ""; txtnom.Focus(); txtfiliere.Focus(); txtfiliere.Text = ""; txtniveau.Text = ""; txtniveau.Focus(); txtmatiere.Text = ""; txtmatiere.Focus(); txtcours.Text = ""; txtcours.Focus(); txtdevoir.Text = ""; txtdevoir.Focus(); txttotal.Text = ""; txttotal.Focus(); txtfiliere.Focus(); txtfiliere.Text = ""; txtniveau.Text = ""; txtniveau.Focus(); txtmatiere.Text = ""; txtmatiere.Focus(); txtsemaine.Text = ""; txtsemaine.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Threading.Tasks; using System.Text; using System.Windows.Forms; using WindowsFormsApp1.BLL; using WindowsFormsApp1.DAL; using WindowsFormsApp1.TOOL; using MySql.Data.MySqlClient; using WindowsFormsApp1.user_controler; namespace WindowsFormsApp1.Windows_Form.cours { public partial class ajoutcours : Form { databasehelper dh = new databasehelper(); MySqlDataReader dr; operateurcontroleur opc = new operateurcontroleur(); operateurinfo opi = new operateurinfo(); FormCollection listform; DataSet ds1, ds2, ds3,ds4,ds5,ds6; //variable bool result; private void button3_Click(object sender, EventArgs e) { this.Close(); } private void txtsalle_SelectedIndexChanged(object sender, EventArgs e) { } private void txttotal_TextChanged(object sender, EventArgs e) { } private void label7_Click(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } private void txtfin_ValueChanged(object sender, EventArgs e) { //calcul d'heure TimeSpan rr = TimeSpan.Parse(txtfin.Text) - TimeSpan.Parse(txtdebut.Text); txttotal.Text = rr.ToString(); } private void txtdebut_ValueChanged(object sender, EventArgs e) { //calcul d'heure TimeSpan rr = TimeSpan.Parse(txtfin.Text) - TimeSpan.Parse(txtdebut.Text); txttotal.Text = rr.ToString(); } private UserControl ajoucou; private void textBox1_TextChanged(object sender, EventArgs e) { } public ajoutcours(UserControl ajc) { InitializeComponent(); this.ajoucou = ajc; txtcodecours.Enabled = false; txttotal.Enabled = false; } private void ajoutcours_Load(object sender, EventArgs e) { try { //charger les noms des matieres ds1 = dh.ExecuteDataSet("select distinct nom_matiere from matiere order by nom_matiere asc"); txtmatiere.DataSource = ds1.Tables[0]; txtmatiere.DisplayMember = "nom_matiere"; txtmatiere.Text = ""; //charger les noms des filieres ds2 = dh.ExecuteDataSet("select distinct abrege from filiere order by abrege asc"); txtfiliere.DataSource = ds2.Tables[0]; txtfiliere.DisplayMember = "abrege"; txtfiliere.Text = ""; //charger les noms des niveaux ds3 = dh.ExecuteDataSet("select distinct abrege from niveau order by abrege asc"); txtniveau.DataSource = ds3.Tables[0]; txtniveau.DisplayMember = "abrege"; txtniveau.Text = ""; //charger les noms des enseignants ds4 = dh.ExecuteDataSet("select distinct nom_enseignant from enseignant where demande_de_permission='Accepter' order by nom_enseignant asc "); txtenseig.DataSource = ds4.Tables[0]; txtenseig.DisplayMember = "nom_enseignant"; txtenseig.Text = ""; //charger les noms des salles ds5 = dh.ExecuteDataSet("select distinct numero from salle order by numero asc"); txtsalle.DataSource = ds5.Tables[0]; txtsalle.DisplayMember = "numero"; txtsalle.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button4_Click(object sender, EventArgs e) { try { if (txtmatiere.Text == "" || txtfiliere.Text == "" || txtniveau.Text == "" || txtenseignant.Text == "" || date.Text == "" || txtdebut.Text == "" || txtfin.Text == "" || txttotal.Text == "" || txtjour.Text == "" ||txtsalle.Text=="") { MessageBox.Show("Désolé tous les champs doivent être renseignés", "GSED"); } else { dh.ExecuteNonQuery("insert into cours (code_matiere,code_filiere,code_niveau, code_enseignant,date,heure_debut,heure_fin,nbr_heure,jour,salle ) values ('" + txtmatiere.Text.Replace("'", "''") + "', '" + txtfiliere.Text.Replace("'", "''") + "','" + txtniveau.Text.Replace("'", "''") + "','" + txtenseig.Text.Replace("'", "''") + "','" + DateTime.Now.ToString("yyyy/MM/dd") + "','" + txtdebut.Text.Replace("'", "''") + "','" + txtfin.Text.Replace("'", "''") + "','" + txttotal.Text.Replace("'", "''") + "','" + txtjour.Text.Replace("'", "''") + "','" + txtsalle.Text.Replace("'", "''") + "')"); MessageBox.Show("La séance a été enregistré avec succès"); (ajoucou as UCcours).affic(); txtmatiere.Text = ""; txtmatiere.Focus(); txtfiliere.Text = ""; txtfiliere.Focus(); txtniveau.Text = ""; txtniveau.Focus(); txtenseignant.Text = ""; txtenseignant.Focus(); date.Text = ""; date.Focus(); txtdebut.Focus(); txtdebut.Text = ""; txtfin.Text = ""; txtfin.Focus(); txttotal.Text = ""; txttotal.Focus(); txtjour.Text = ""; txtjour.Focus(); txtsalle.Text = ""; txtsalle.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
using System; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; namespace Tests { class Enseignant { public Enseignant(string LeNom, TimeSpan LaDureeCoursPrevue) { Nom = LeNom; DureeCoursPrevue = LaDureeCoursPrevue; Creneaux.CollectionChanged += Creneaux_CollectionChanged; } /// <summary> /// Quand la collection subit un changement /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Creneaux_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch(e.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Reset: case NotifyCollectionChangedAction.Replace: DureeCoursRestant = DureeCoursPrevue - TimeSpan.FromHours(Creneaux.OfType<Cours>().Sum(cours => cours.Duree.TotalHours)); break; } } /// <summary> /// Nom de l'enseignant /// </summary> public string Nom { get; private set; } /// <summary> /// Creneaux de l'enseignant /// </summary> public ObservableCollection<Creneau> Creneaux { get; private set; } = new ObservableCollection<Creneau>(); /// <summary> /// Durée de cours prévue /// </summary> public TimeSpan DureeCoursPrevue { get; private set; } /// <summary> /// Durée de cours restant /// </summary> public TimeSpan DureeCoursRestant { get; private set; } } }
using System; namespace Tests { /// <summary> /// Définit un créneau /// </summary> abstract class Creneau { protected string info; protected Creneau(DateTime LeDebut, DateTime LaFin) { debut = LeDebut; fin = LaFin; } protected DateTime debut; /// <summary> /// Debut du créneau horaire /// </summary> public DateTime Debut { get { return debut; } set { debut = value; } } private DateTime fin; /// <summary> /// Fin du créneau horaire /// </summary> public DateTime Fin { get { return fin; } set { fin = value; } } /// <summary> /// Fin du créneau horaire /// </summary> public TimeSpan Duree { get { return fin - debut; } } public override string ToString() { return string.Format( @"{0} Le {1:dd/MM/yyyy} De {1:HH:mm} à {2:HH:mm} Durée {3} ", info, Debut,Fin, Duree); } } class Cours : Creneau { public Cours(DateTime LeDebut, DateTime LaFin, string LaMatiere) : base(LeDebut, LaFin) { info = LaMatiere; } public string Matiere { get { return info; } } } class Abscence : Creneau { public Abscence(DateTime LeDebut, DateTime LaFin, string LaRaison) : base(LeDebut, LaFin) { info = LaRaison; } public string Raison { get { return info; } } } }
Enseignant en = new Enseignant("Prof", TimeSpan.FromHours(5)); en.Creneaux.Add(new Abscence(DateTime.Parse("01/06/2021 8:00"), DateTime.Parse("01/06/2021 18:00"), "Congés")); DateTime pasLesJeudisPM = DateTime.Parse("03/06/2021 12:00"); while(pasLesJeudisPM.Month < 7) { en.Creneaux.Add(new Abscence(pasLesJeudisPM, pasLesJeudisPM.AddHours(6), "Pas les jeudis après midi")); pasLesJeudisPM = pasLesJeudisPM.AddDays(7); } string duree1 = en.DureeCoursRestant.ToString(); en.Creneaux.Add(new Cours(DateTime.Parse("02/06/2021 8:00"), DateTime.Parse("02/06/2021 9:00"), "Maths")); string duree2 = en.DureeCoursRestant.ToString(); en.Creneaux.Add(new Cours(DateTime.Parse("04/06/2021 11:00"), DateTime.Parse("04/06/2021 12:00"), "Maths")); string duree3 = en.DureeCoursRestant.ToString(); foreach (Creneau cr in en.Creneaux) Console.WriteLine(cr); Console.WriteLine("durée 1 {0}", duree1); Console.WriteLine("durée 2 {0}", duree2); Console.WriteLine("durée 3 {0}", duree3);
using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Threading.Tasks; using System.Text; using System.Windows.Forms; using WindowsFormsApp1.BLL; using WindowsFormsApp1.DAL; using WindowsFormsApp1.TOOL; using MySql.Data.MySqlClient; using WindowsFormsApp1.user_controler; namespace WindowsFormsApp1.Windows_Form.cours { public partial class ajoutcours : Form { databasehelper dh = new databasehelper(); MySqlDataReader dr; operateurcontroleur opc = new operateurcontroleur(); operateurinfo opi = new operateurinfo(); FormCollection listform; DataSet ds1, ds2, ds3,ds4,ds5,ds6, ds7,ds8; //variable bool result; private UserControl ajoucou; public ajoutcours(UserControl ajc) { InitializeComponent(); this.ajoucou = ajc; txtnb.Enabled = false; txtenseig.Enabled = false; txtmatiere.Enabled = false; txtfiliere.Enabled = false; txtniveau.Enabled = false; txtrest.Enabled = false; txttotal.Enabled = false; } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void txtsalle_SelectedIndexChanged(object sender, EventArgs e) { } private void txttotal_TextChanged(object sender, EventArgs e) { string Total = txttotal.Text; string nombre = txtnb.Text; string[] T = Total.Split(':'); string[] Nbr = nombre.Split(':'); //pour l'heure int T0 = int.Parse(T[0]); int Nbr0 = int.Parse(Nbr[0]); //Pour les minutes int T1 = int.Parse(T[1]); int Nbr1 = int.Parse(Nbr[1]); //Pour les secondes int T2= int.Parse(T[2]); int Nbr2 = int.Parse(Nbr[2]); int restheure = T0 - Nbr0; int restminute = T1 + Nbr1; int restsecond = T2 + Nbr2; if(int.Parse(Nbr[1]) > int.Parse(T[1])) { restheure = restheure - 1; restminute = 60 - int.Parse(Nbr[1]); } string resultat = restheure.ToString() + ":" + restminute.ToString() + ":" + restsecond.ToString(); txtrest.Text = resultat.ToString(); } private void label7_Click(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } private void txtfin_ValueChanged(object sender, EventArgs e) { TimeSpan rr = TimeSpan.Parse(txtfin.Text) - TimeSpan.Parse(txtdebut.Text); txtnb.Text = rr.ToString(); } private void txtdebut_ValueChanged(object sender, EventArgs e) { } private void txttotal_SelectedIndexChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { //calcul d'heure //TimeSpan rr = TimeSpan.Parse(txtrest1.Text) - TimeSpan.Parse(txtnb.Text); //txtreste.Text = rr.ToString(); } private void txtrest1_ValueChanged(object sender, EventArgs e) { } private void txttotal1_TextChanged(object sender, EventArgs e) { } private void btnfermer_Click(object sender, EventArgs e) { this.Close(); } private void txtrest1_TextChanged(object sender, EventArgs e) { } private void txttotal_SelectedIndexChanged_1(object sender, EventArgs e) { } private void txteneig_SelectedIndexChanged(object sender, EventArgs e) { ds6 = dh.ExecuteDataSet("select distinct nom_enseignant from enseignant where code_enseignant ='" + txtcden.Text + "' "); txtenseig.DataSource = ds6.Tables[0]; txtenseig.DisplayMember = "nom_enseignant"; txtenseig.Text = ""; ds1 = dh.ExecuteDataSet("select distinct code_matiere from enseignant where code_enseignant ='" + txtcden.Text + "' "); txtmatiere.DataSource = ds1.Tables[0]; txtmatiere.DisplayMember = "code_matiere"; txtmatiere.Text = ""; ds2 = dh.ExecuteDataSet("select distinct code_filiere from enseignant where code_enseignant ='" + txtcden.Text + "' "); txtfiliere.DataSource = ds2.Tables[0]; txtfiliere.DisplayMember = "code_filiere"; txtfiliere.Text = ""; ds3 = dh.ExecuteDataSet("select distinct code_niveau from enseignant where code_enseignant ='" + txtcden.Text + "' "); txtniveau.DataSource = ds3.Tables[0]; txtniveau.DisplayMember = "code_niveau"; txtniveau.Text = ""; ds7 = dh.ExecuteDataSet("select distinct heure_cours_rest from enseignant where code_enseignant ='" + txtcden.Text + "' "); txttotal.DataSource = ds7.Tables[0]; txttotal.DisplayMember = "heure_cours_rest"; txttotal.Text = ""; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void ajoutcours_Load(object sender, EventArgs e) { try { //charger les noms des enseignants ds4 = dh.ExecuteDataSet("select distinct code_enseignant from enseignant where demande_de_permission='Accepter' order by nom_enseignant asc "); txtcden.DataSource = ds4.Tables[0]; txtcden.DisplayMember = "code_enseignant"; txtcden.Text = ""; //charger les noms des salles ds5 = dh.ExecuteDataSet("select distinct numero from salle order by numero asc"); txtsalle.DataSource = ds5.Tables[0]; txtsalle.DisplayMember = "numero"; txtsalle.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button4_Click(object sender, EventArgs e) { try { string Total = txttotal.Text; string nombre = txtnb.Text; string[] T = Total.Split(':'); string[] Nbr = nombre.Split(':'); //pour l'heure int T0 = int.Parse(T[0]); int Nbr0 = int.Parse(Nbr[0]); //Pour les minutes int T1 = int.Parse(T[1]); int Nbr1 = int.Parse(Nbr[1]); //Pour les secondes int T2 = int.Parse(T[2]); int Nbr2 = int.Parse(Nbr[2]); string nbr = Nbr0.ToString(); string nb = Nbr1.ToString(); string th = T0.ToString(); string tm = T1.ToString(); if (txtmatiere.Text == "" || txtfiliere.Text == "" || txtniveau.Text == "" || txtenseignant.Text == "" || date.Text == "" || txtdebut.Text == "" || txtfin.Text == "" || txtnb.Text == "" || txtjour.Text == "" || txtsalle.Text == "") { MessageBox.Show("Désolé tous les champs doivent être renseignés", "GSED"); } else { if (Nbr0 > T0) { MessageBox.Show("Désolé vous pouvez pas ajouter une séance de '" + nbr + "'h'" + nb + "'mn alors qu'il vous reste un total de '" + th + "'h'" + tm + "'mn", "GSED", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { dh.ExecuteNonQuery("insert into cours (code_matiere,code_filiere,code_niveau, code_enseignant,date,heure_debut,heure_fin,nbr_heure,jour,salle ) values ('" + txtmatiere.Text.Replace("'", "''") + "', '" + txtfiliere.Text.Replace("'", "''") + "','" + txtniveau.Text.Replace("'", "''") + "','" + txtenseig.Text.Replace("'", "''") + "','" + DateTime.Now.ToString("yyyy/MM/dd") + "','" + txtdebut.Text.Replace("'", "''") + "','" + txtfin.Text.Replace("'", "''") + "','" + txtnb.Text.Replace("'", "''") + "','" + txtjour.Text.Replace("'", "''") + "','" + txtsalle.Text.Replace("'", "''") + "')"); dh.ExecuteNonQuery("update enseignant set heure_cours ='"+txtrest.Text.Replace("'", "''") + "' where code_enseignant='" + txtcden.Text + "' "); MessageBox.Show("La séance a été enregistré avec succès"); (ajoucou as UCcours).affic(); txtmatiere.Text = ""; txtmatiere.Focus(); txtfiliere.Text = ""; txtfiliere.Focus(); txtniveau.Text = ""; txtniveau.Focus(); txtenseig.Text = ""; txtenseig.Focus(); date.Text = ""; date.Focus(); txtdebut.Focus(); txtdebut.Text = ""; txtfin.Text = ""; txtfin.Focus(); txtnb.Text = ""; txtnb.Focus(); txtjour.Text = ""; txtjour.Focus(); txtsalle.Text = ""; txtsalle.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }