コード例 #1
0
ファイル: Surveillance.cs プロジェクト: smartyAe/FinalPro
        private void Btn_Ajouter_Click(object sender, EventArgs e)
        {
            Ajouter_Surveillance AjoutSurv = new Ajouter_Surveillance(
                CurrentListSurv,
                CurrentEns);
            var result = AjoutSurv.ShowDialog();

            if (result == DialogResult.OK)
            {
                Surveillances NewSurv = new Surveillances(AjoutSurv.CurrentSurveillance);
                CurrentListSurv.Add(NewSurv);

                /*
                 * foreach (Surveillances Row in CurrentListSurv)
                 * {
                 *  MessageBox.Show("Ens : " + Row.PropEnseignant.PropId + " " + Row.PropEnseignant.PropNom + " " + Row.PropEnseignant.PropPrenom + " " + Row.PropEnseignant.PropEmail + " " + Row.PropEnseignant.PropStatut + " " + Row.PropEnseignant.PropDepartements.PropCode + " " + Row.PropEnseignant.PropDepartements.PropNom
                 + "\n\nSeance : " + Row.PropSeance.PropCode + " " + Row.PropSeance.PropNom + " " + Row.PropSeance.PropHeureDebut + " " + Row.PropSeance.PropHeureFin
                 + "\n\nSalle : " + Row.PropSalle.PropNom + " " + Row.PropSalle.PropType
                 + "\n\nDate : " + Row.PropDateSurveillance);
                 + }*/
                CurrentDataTableProgrammes.Rows.Add(
                    NewSurv.PropSalle.PropNom,
                    NewSurv.PropSeance.PropNom,
                    NewSurv.PropSeance.PropHeureDebut,
                    NewSurv.PropSeance.PropHeureFin,
                    NewSurv.PropDateSurveillance
                    );
                IsUpdated = true;
                DtgListeProgrames.DataSource = CurrentDataTableProgrammes;
            }
        }
コード例 #2
0
 public Modifier_Surveillance(List <Surveillances> ListSurveillances, Enseignants Ens, int Index)
 {
     InitializeComponent();
     AllSurv             = ListSurveillances;
     CurrentEns          = Ens;
     IndexCurrent        = Index;
     CurrentSurveillance = ListSurveillances[Index];
 }
コード例 #3
0
 public Surveillances(Surveillances NewSurveillance)
 {
     Id               = NewSurveillance.PropId;
     Enseignant       = new Enseignants(NewSurveillance.PropEnseignant);
     Seance           = new Seances(NewSurveillance.PropSeance);
     Salle            = new Salles(NewSurveillance.PropSalle);
     DateSurveillance = NewSurveillance.PropDateSurveillance;
 }
コード例 #4
0
ファイル: Surveillance.cs プロジェクト: smartyAe/FinalPro
        private void Btn_Modifier_Click(object sender, EventArgs e)
        {
            if (CurrentListSurv != null && CurrentListSurv.Count > 0)
            {
                if (DtgListeProgrames.SelectedCells.Count > 0)
                {
                    int             IndexRowSelected = DtgListeProgrames.SelectedCells[0].RowIndex;
                    DataGridViewRow SelectedRow      = DtgListeProgrames.Rows[IndexRowSelected];

                    if (SelectedRow.Cells["Nom Salle"].Value != null &&
                        SelectedRow.Cells["Nom Salle"].Value.ToString().Trim().Length != 0 &&
                        IndexRowSelected < CurrentListSurv.Count)
                    {
                        CurrentIndex = IndexRowSelected;
                        //MessageBox.Show("ind " + CurrentIndex + " Count " + CurrentListSurv.Count);
                        Modifier_Surveillance ModifierSurv = new Modifier_Surveillance(
                            CurrentListSurv, CurrentEns, CurrentIndex);

                        if (ModifierSurv.ShowDialog() == DialogResult.OK)
                        {
                            Surveillances NewSurv = new Surveillances(ModifierSurv.CurrentSurveillance);
                            CurrentListSurv.RemoveAt(CurrentIndex);
                            CurrentListSurv.Add(NewSurv);

                            CurrentDataTableProgrammes.Rows.RemoveAt(CurrentIndex);
                            CurrentDataTableProgrammes.Rows.Add(
                                NewSurv.PropSalle.PropNom,
                                NewSurv.PropSeance.PropNom,
                                NewSurv.PropSeance.PropHeureDebut,
                                NewSurv.PropSeance.PropHeureFin,
                                NewSurv.PropDateSurveillance
                                );
                            IsUpdated = true;
                            DtgListeProgrames.DataSource = CurrentDataTableProgrammes;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Selectionner un valid programme");
                    }
                }
                else
                {
                    MessageBox.Show("Selectionner un programme");
                }
            }
            else
            {
                MessageBox.Show("Ajouter des programmes");
            }
        }
コード例 #5
0
        public int AddSurveillances(Surveillances newSurveillances)
        {
            MyOleDbCommand = new OleDbCommand("insert into Surveillances (IdEnseignant, CodeSeances, NomSalle, HeureDebut, HeureFin, DateSurveillance)" +
                                              "values (@IdEnseignant, @CodeSeance, @NomSalle, @HeureDebut, @HeureFin, @DateSurveillance)");

            MyOleDbCommand.Parameters.Add("@IdEnseignant", OleDbType.Integer).Value = newSurveillances.PropEnseignant.PropId;

            MyOleDbCommand.Parameters.Add("@CodeSeance", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropCode;

            MyOleDbCommand.Parameters.Add("@NomSalle", OleDbType.VarChar).Value = newSurveillances.PropSalle.PropNom;

            MyOleDbCommand.Parameters.Add("@HeureDebut", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropHeureDebut;

            MyOleDbCommand.Parameters.Add("@HeureFin", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropHeureFin;

            MyOleDbCommand.Parameters.Add("@DateSurveillance", OleDbType.Date).Value = (newSurveillances.PropDateSurveillance != null) ? newSurveillances.PropDateSurveillance : Convert.DBNull;

            return(DBConnection.FunctionToWrite(MyOleDbCommand));
        }
コード例 #6
0
 private void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (!CbSalleUpdate.SelectedItem.ToString().ToLower().Equals("pas de salle") &&
         !CbSeanceUpdate.SelectedItem.ToString().ToLower().Equals("pas de seance"))
     {
         if (SeanceExistAtThisDayAlready(AllSeances[CbSeanceUpdate.SelectedIndex], DtpDateUpdate.Value))
         {
             MessageBox.Show("SVP, changer de seance ou de date, car elle existe deja dans le programme");
         }
         else if (CurrentEns != null)
         {
             CurrentSurveillance = new Surveillances(CurrentEns, AllSeances[CbSeanceUpdate.SelectedIndex], AllSalles[CbSalleUpdate.SelectedIndex], DtpDateUpdate.Value);
             this.DialogResult   = DialogResult.OK;
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Veuillez selectionner une bonne salle ou seance");
     }
 }
コード例 #7
0
        public int UpdateSurveillances(int OldId, Surveillances newSurveillances)
        {
            MyOleDbCommand = new OleDbCommand("update Surveillances set IdEnseignant = @IdEnseignant, CodeSeances = @CodeSeance, NomSalle = @NomSalle, " +
                                              "HeureDebut = @HeureDebut, DateSurveillance = @DateSurveillance, HeureFin = @HeureFin  where Id = @OldId");

            MyOleDbCommand.Parameters.Add("@OldId", OleDbType.Integer).Value = OldId;

            MyOleDbCommand.Parameters.Add("@IdEnseignant", OleDbType.Integer).Value = newSurveillances.PropEnseignant.PropId;

            MyOleDbCommand.Parameters.Add("@CodeSeance", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropCode;

            MyOleDbCommand.Parameters.Add("@NomSalle", OleDbType.VarChar).Value = newSurveillances.PropSalle.PropNom;

            MyOleDbCommand.Parameters.Add("@HeureDebut", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropHeureDebut;

            MyOleDbCommand.Parameters.Add("@DateSurveillance", OleDbType.Date).Value = (newSurveillances.PropDateSurveillance != null) ? newSurveillances.PropDateSurveillance : Convert.DBNull;

            MyOleDbCommand.Parameters.Add("@HeureFin", OleDbType.VarChar).Value = newSurveillances.PropSeance.PropHeureFin;


            return(DBConnection.FunctionToWrite(MyOleDbCommand));
        }
コード例 #8
0
        public Surveillances ConvertRowToSurveillances(DataRow row)
        {
            int Id = 0;

            try
            {
                Id = int.Parse(row["Id"].ToString());
            }
            catch (Exception e)
            {
                Id = 0;
            }
            int IdEnseignant = 0;

            try
            {
                IdEnseignant = int.Parse(row["IdEnseignant"].ToString());
            }
            catch (Exception e)
            {
                IdEnseignant = 0;
            }

            string   CodeSeance       = (row["CodeSeances"].ToString().Length != 0) ? row["CodeSeances"].ToString() : "";
            string   NomSalle         = (row["NomSalle"].ToString().Length != 0) ? row["NomSalle"].ToString() : "";
            string   DateText         = (row["DateSurveillance"].ToString().Length >= 8) ? row["DateSurveillance"].ToString() : null;
            DateTime DateSurveillance = DateTime.MinValue;

            if (DateText != null)
            {
                DateSurveillance = DateTime.Parse(DateText);
            }


            Enseignants CurrentProf = new Enseignants();

            CurrentProf.PropId = IdEnseignant;

            if (IdEnseignant != 0)
            {
                string NomEns = (row["NomEns"].ToString().Length != 0) ? row["NomEns"].ToString() : "pas de Nom D'enseignant";
                CurrentProf.PropNom = NomEns;

                string PrenomEns = (row["PrenomEns"].ToString().Length != 0) ? row["PrenomEns"].ToString() : "pas de Prenom d'enseignant";
                CurrentProf.PropPrenom = PrenomEns;

                string Email = (row["Email"].ToString().Length != 0) ? row["Email"].ToString() : "pas d'Email";
                CurrentProf.PropEmail = Email;

                string Statut = (row["Statut"].ToString().Length != 0) ? row["Statut"].ToString() : "pas de statut";
                CurrentProf.PropStatut = Statut;

                string CodeDep = row["CodeDep"].ToString();
                if (CodeDep.Length != 0)
                {
                    Departements CurrentDepartements = new Departements();

                    string NomDep = (row["NomDep"].ToString().Length != 0) ? row["NomDep"].ToString() : "pas de Nom de Departement";
                    CurrentDepartements.PropNom  = NomDep;
                    CurrentDepartements.PropCode = CodeDep;

                    CurrentProf.PropDepartements = new Departements(CurrentDepartements);
                }
                else
                {
                    CodeDep = "pas de Departement";
                    CurrentProf.PropDepartements = null;
                }
                CurrentProf.PropStatut = Statut;
            }

            Seances CurrentSeance = new Seances();

            CurrentSeance.PropCode       = CodeSeance;
            CurrentSeance.PropNom        = (row["NomSeance"].ToString().Length != 0) ? row["NomSeance"].ToString() : "pas de Nom de Seance";
            CurrentSeance.PropHeureDebut = (row["HeureDebut"].ToString().Length != 0) ? row["HeureDebut"].ToString() : "pas de HeureDebut";
            CurrentSeance.PropHeureFin   = (row["HeureFin"].ToString().Length != 0) ? row["HeureFin"].ToString() : "pas de HeureFin";

            Salles CurrentSalle = new Salles();

            CurrentSalle.PropNom  = NomSalle;
            CurrentSalle.PropType = (row["type"].ToString().Length != 0) ? row["type"].ToString() : "pas de type salle";



            Surveillances CurrentSurveillances = new Surveillances(CurrentProf, CurrentSeance, CurrentSalle, DateSurveillance);

            CurrentSurveillances.PropId = Id;

            return(CurrentSurveillances);
        }
コード例 #9
0
        public static DataTable AdaptDataTableProgrammes(DataTable CurrentDataTable)
        {
            AllSurveillance = new List <Surveillances>();

            DataTable Datatable = new DataTable();

            Datatable = InitialiseDataGridProgrammes(Datatable);

            //Get All The Rows Of The First DataTable
            foreach (DataRow row in CurrentDataTable.Rows)
            {
                Surveillances CurrentSurveillance = new Surveillances();
                int           Id = 0;
                try
                {
                    Id = int.Parse(row["Id"].ToString());
                }
                catch (Exception e)
                {
                    Id = 0;
                }
                int IdEnseignant = 0;

                try
                {
                    IdEnseignant = int.Parse(row["IdEnseignant"].ToString());
                }
                catch (Exception e)
                {
                    IdEnseignant = 0;
                }

                string   CodeSeance       = (row["CodeSeances"].ToString().Length != 0) ? row["CodeSeances"].ToString() : "";
                string   NomSalle         = (row["NomSalle"].ToString().Length != 0) ? row["NomSalle"].ToString() : "";
                string   DateText         = (row["DateSurveillance"].ToString().Length >= 8) ? row["DateSurveillance"].ToString() : null;
                DateTime DateSurveillance = DateTime.MinValue;

                if (DateText != null)
                {
                    DateSurveillance = DateTime.Parse(DateText);
                }


                Enseignants CurrentProf = new Enseignants();
                CurrentProf.PropId = IdEnseignant;

                if (IdEnseignant != 0)
                {
                    string NomEns = (row["NomEns"].ToString().Length != 0) ? row["NomEns"].ToString() : "pas de Nom D'enseignant";
                    CurrentProf.PropNom = NomEns;

                    string PrenomEns = (row["PrenomEns"].ToString().Length != 0) ? row["PrenomEns"].ToString() : "pas de Prenom d'enseignant";
                    CurrentProf.PropPrenom = PrenomEns;

                    string Email = (row["Email"].ToString().Length != 0) ? row["Email"].ToString() : "pas d'Email";
                    CurrentProf.PropEmail = Email;

                    string Statut = (row["Statut"].ToString().Length != 0) ? row["Statut"].ToString() : "pas de statut";
                    CurrentProf.PropStatut = Statut;

                    string CodeDep = row["CodeDep"].ToString();
                    if (CodeDep.Length != 0)
                    {
                        Departements CurrentDepartements = new Departements();

                        string NomDep = (row["NomDep"].ToString().Length != 0) ? row["NomDep"].ToString() : "pas de Nom de Departement";
                        CurrentDepartements.PropNom  = NomDep;
                        CurrentDepartements.PropCode = CodeDep;

                        CurrentProf.PropDepartements = new Departements(CurrentDepartements);
                    }
                    else
                    {
                        CodeDep = "pas de Departement";
                        CurrentProf.PropDepartements = null;
                    }
                    CurrentProf.PropStatut = Statut;
                }

                Seances CurrentSeance = new Seances();
                CurrentSeance.PropCode       = CodeSeance;
                CurrentSeance.PropNom        = (row["NomSeance"].ToString().Length != 0) ? row["NomSeance"].ToString() : "pas de Nom de Seance";
                CurrentSeance.PropHeureDebut = (row["HeureDebut"].ToString().Length != 0) ? row["HeureDebut"].ToString() : "pas de HeureDebut";
                CurrentSeance.PropHeureFin   = (row["HeureFin"].ToString().Length != 0) ? row["HeureFin"].ToString() : "pas de HeureFin";

                Salles CurrentSalle = new Salles();
                CurrentSalle.PropNom  = NomSalle;
                CurrentSalle.PropType = (row["type"].ToString().Length != 0) ? row["type"].ToString() : "pas de type salle";



                Surveillances CurrentSurveillances = new Surveillances(CurrentProf, CurrentSeance, CurrentSalle, DateSurveillance);
                CurrentSurveillances.PropId = Id;

                Datatable.Rows.Add(
                    CurrentSalle.PropNom,
                    CurrentSeance.PropNom,
                    CurrentSeance.PropHeureDebut,
                    CurrentSeance.PropHeureFin,
                    DateSurveillance
                    );

                AllSurveillance.Add(CurrentSurveillances);
            }

            return(Datatable);
        }