コード例 #1
0
        //=========================== Chargement du planning ================================================//
        private void plannig_check()
        {
            string connectString = $@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\ProjetBDD.mdf;Integrated Security=True;Connect Timeout=30";


            DataClasses1DataContext db = new DataClasses1DataContext(connectString);



            // création d'une liste nommée planing et mettre dedans les champs qu'on veut afficher dans le data-grid qu'on prendera des deux bases congé et employé
            List <champ_liste>    planing = new List <champ_liste>();
            IQueryable <congé2>   list    = from recup in db.congé2 select recup;
            IQueryable <Employee> list1   = from recup1 in db.Employee select recup1;

            foreach (var b in list)
            {
                champ_liste champ = new champ_liste();

                champ.matricule = (int)b.matricule;
                foreach (var employe in list1)
                {
                    if (employe.matricule == b.matricule)
                    {
                        champ.nom    = employe.nom;
                        champ.prenom = employe.prenom;
                    }
                }
                champ.debut  = (DateTime)b.debut;
                champ.fin    = (DateTime)b.fin;
                champ.type   = b.type;
                champ.nb_j_r = (int)b.nb_j_r;

                planing.Add(champ);
            }

            // une fois la liste pleine on la met dans le Data-grid et l'afficher ...

            gantt.ItemsSource = adapter_gantt(planing);
        }
コード例 #2
0
ファイル: Congées.xaml.cs プロジェクト: fouadkadi/Gpers
        private void Filtre_actif2(object sender, EventArgs e)
        {
            string connectString = $@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\ProjetBDD.mdf;Integrated Security=True;Connect Timeout=30";


            DataClasses1DataContext db = new DataClasses1DataContext(connectString);

            planing.Clear();

            if (Filtre.Text == "")
            {
                MessageBox.Show("veuillez choisir l'employé ou le mois ou l'année ");
            }
            else
            {
                IQueryable <congé2>   list  = from recup in db.congé2 select recup;
                IQueryable <Employee> list1 = from recup1 in db.Employee select recup1;
                if (Filtre.Text == "Employé")
                {
                    Employee b = list1.ToArray()[choixfiltre.SelectedIndex];

                    foreach (var congé2 in list)
                    {
                        if (congé2.matricule == b.matricule)
                        {
                            champ_liste champ = new champ_liste();
                            champ.matricule = (int)b.matricule;
                            champ.nom       = b.nom;
                            champ.prenom    = b.prenom;
                            champ.debut     = (DateTime)congé2.debut;
                            champ.fin       = (DateTime)congé2.fin;
                            champ.type      = congé2.type;
                            champ.nb_j_r    = (int)congé2.nb_j_r;
                            planing.Add(champ);
                        }
                    }


                    // string chaine = champ.nom + " " + champ.prenom + " " + champ.matricule;
                    //if (chaine == choixfiltre.Text) ;
                }
                else
                {
                    if (Filtre.Text == "Mois")
                    {
                        foreach (var b in list)
                        {
                            champ_liste champ = new champ_liste();

                            champ.matricule = (int)b.matricule;
                            foreach (var employe in list1)
                            {
                                if (employe.matricule == b.matricule)
                                {
                                    champ.nom    = employe.nom;
                                    champ.prenom = employe.prenom;
                                }
                            }
                            champ.debut  = (DateTime)b.debut;
                            champ.fin    = (DateTime)b.fin;
                            champ.type   = b.type;
                            champ.nb_j_r = (int)b.nb_j_r;

                            string chaine = Convert.ToString(champ.debut.Date.Month);
                            if (chaine == choixfiltre.Text)
                            {
                                planing.Add(champ);
                            }
                        }
                    }
                    else
                    {
                        if (Filtre.Text == "Année")
                        {
                            foreach (var b in list)
                            {
                                champ_liste champ = new champ_liste();

                                champ.matricule = (int)b.matricule;
                                foreach (var employe in list1)
                                {
                                    if (employe.matricule == b.matricule)
                                    {
                                        champ.nom    = employe.nom;
                                        champ.prenom = employe.prenom;
                                    }
                                }
                                champ.debut  = (DateTime)b.debut;
                                champ.fin    = (DateTime)b.fin;
                                champ.type   = b.type;
                                champ.nb_j_r = (int)b.nb_j_r;

                                string chaine = Convert.ToString(champ.debut.Date.Year);
                                if (chaine == choixfiltre.Text)
                                {
                                    planing.Add(champ);
                                }
                            }
                        }
                    }
                }
            }
        }