コード例 #1
0
        private async Task CreationApercu(IProgress <ProgressMessage> progress)
        {
            dateSemaine = (DateTime)_dataService.Jour;
            DataRow DtRow;
            string  StSQL;

            StSQL = "";
            DataSet DsTemp       = new DataSet();
            bool    ajoutVirgule = false;

            _ReportSource = new CRBordereauDeclaratif();

            DsBordereauDeclaratif DsBordereauDeclaratif = new DsBordereauDeclaratif();



            ///////////////////////////////////////////////////////////////////////////////////
            /////////////Table Agents///////////////////////////////////////////

            //////Création de la requete/////////////////
            StSQL        = "SELECT * FROM Agents WHERE Agents.Matricule IN (";
            ajoutVirgule = false;


            foreach (string s in Agents)
            {
                if (ajoutVirgule == true)
                {
                    StSQL += ",";
                }
                StSQL       += "'" + s + "'";
                ajoutVirgule = true;
            }
            StSQL += ")";


            oConnection = ClassLibraryProget.DataBase.OpenSqlServer(ParamGlobaux.ConnectionString);


            ////////remplissage du DsTemp///////////////
            try
            {
                DsTemp = ClassLibraryProget.DataBase.SELECTSqlServer(oConnection, "Agents", StSQL);
            }
            catch (SqlException exc)
            {
                System.Windows.MessageBox.Show("Lecture impossible des données de la table " + "Agents" + " " + exc.Message, "Erreur");
            }


            ////////remplissage du DsBordereauDeclaratif///////////////

            for (int i = 0; i < DsTemp.Tables[0].Rows.Count; i++)
            {
                DtRow = DsBordereauDeclaratif.Tables["Agents"].NewRow();
                for (int j = 0; j < DsTemp.Tables[0].Columns.Count; j++)
                {
                    DtRow[j] = DsTemp.Tables[0].Rows[i][j];
                }
                DsBordereauDeclaratif.Tables["Agents"].Rows.Add(DtRow);
            }


            ///////////////////////////////////////////////////////////////////////////////////
            /////////////Table Planning///////////////////////////////////////////



            /////Calcul du numéro de la semaine///////////
            CultureInfo ci = CultureInfo.CurrentCulture;

            weekOfYear = ci.Calendar.GetWeekOfYear(dateSemaine, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

            //////Création de la requete/////////////////
            StSQL        = "SELECT * FROM Planning WHERE Planning.Matricule IN (";
            ajoutVirgule = false;


            foreach (string s in Agents)
            {
                if (ajoutVirgule == true)
                {
                    StSQL += ",";
                }
                StSQL       += "'" + s + "'";
                ajoutVirgule = true;
            }
            StSQL += ") AND Planning.[Num semaine] = " + weekOfYear + " AND YEAR(Jour) = " + dateSemaine.Year;



            ////////remplissage du DsTemp///////////////
            try
            {
                DsTemp = ClassLibraryProget.DataBase.SELECTSqlServer(oConnection, "Planning", StSQL);
            }
            catch (SqlException exc)
            {
                MessageBoxResult _dialogResult = _dialogService.ShowMessageBox(this,
                                                                               "Lecture impossible des données de la table " + "Planning" + " " + exc.Message,
                                                                               "Erreur",
                                                                               MessageBoxButton.OK,
                                                                               MessageBoxImage.Error);
            }
            ///////////////////////si pas resultat///////////////////////////////////////////
            if (DsTemp.Tables[0].Rows.Count == 0)
            {
                MessageBoxResult _dialogResult = _dialogService.ShowMessageBox(this,
                                                                               "Aucun planning correspondant n'a été trouvé",
                                                                               "Erreur",
                                                                               MessageBoxButton.OK,
                                                                               MessageBoxImage.Error);

                _progress.Report(new ProgressMessage(100, "Finished", true));

                Reset();
                await Task.Delay(500);

                Close = true;
                return;
            }


            ////////////////////////Initialisation barre de progression//////////////////////////
            _progressMax = (Agents.Count * 1);
            int _progressValue = 0;


            ////////remplissage du DsBordereauDeclaratif///////////////

            for (int i = 0; i < DsTemp.Tables[0].Rows.Count; i++)
            {
                DtRow = DsBordereauDeclaratif.Tables["Planning"].NewRow();
                for (int j = 0; j < DsTemp.Tables[0].Columns.Count; j++)
                {
                    DtRow[j] = DsTemp.Tables[0].Rows[i][j];
                }
                DsBordereauDeclaratif.Tables["Planning"].Rows.Add(DtRow);
            }

            //////////////////Remplissage Annualisation/////////////////////////////////
            //////////////////////////////////////////////////////////////////////////

            List <Parametre>         Params   = new List <Parametre>();
            List <PeriodeModulation> Periodes = new List <PeriodeModulation>();
            List <Data> ListeData             = new List <Data>();

            ///compteur de tour de boucle//
            int k = 0;

            foreach (var item in Agents)
            {
                //////recherche parametre pour la methode PeriodesModulation//////////////////////////////////
                Params = await Parametres.GetParametresAsync(ParamGlobaux.ConnectionString, ParamGlobaux.IDEtablissement, item,
                                                             new List <string> {
                    "Durée maxi CDD court"
                });

                int DureeMaxCDDCourt = Convert.ToInt32(Params.Single(p => p.Name == "Durée maxi CDD court").Value);

                /////////////////////////////recherche des périodes de modulation/////////////////////////////////////////////


                Periodes = await gestion.PeriodesModulation(ParamGlobaux.ConnectionString, item, dateSemaine, DureeMaxCDDCourt);



                ////////////////////////////Création liste Data Matricule + tempbase///////////////////////////////////////////////////

                foreach (var z in Periodes)
                {
                    if (z.EnCours == true)
                    {
                        ListeData.Add(new Data(item, z.TempsBase, z.Regime));
                    }
                }

                _progressValue++;
                _progress.Report(new ProgressMessage((_progressValue * 100) / _progressMax, "Création de l'aperçu...", false));
            }

            ////////////////////////////////////Remplissage DsBordereauDeclaratif//////////////////////////////////////////////

            foreach (var x in ListeData)
            {
                k = 0;

                foreach (DataRow DtRowBD in DsBordereauDeclaratif.Tables["Planning"].Rows)
                {
                    if (DsBordereauDeclaratif.Tables["Planning"].Rows[k]["Matricule"].ToString() == x.Matricule)
                    {
                        DsBordereauDeclaratif.Tables["Planning"].Rows[k]["Annualisation"] = x.TempBase;
                        DsBordereauDeclaratif.Tables["Planning"].Rows[k]["Regime"]        = x.Regime;
                    }
                    k++;
                }
            }


            // =======================================================================================================================================
            // Définir une structure de données temps de travail pour les calculs
            // =======================================================================================================================================
            ClassGetMS.TpsDeTravail TempsTravail;
            List <Data>             listeCalcul = new List <Data>();
            List <DateTime>         Jours       = new List <DateTime>();

            for (int i = 0; i < 7; i++)
            {
                Jours.Add(dateSemaine);

                dateSemaine = dateSemaine.AddDays(1);
            }



            DateTime dateValue  = new DateTime(1900, 1, 1, 0, 0, 0);
            DateTime dateValue1 = new DateTime(1900, 1, 1, 0, 0, 0);

            foreach (var item in Agents)
            {
                foreach (var d in Jours)
                {
                    TempsTravail = await ClassGetMS.TempsTravail.CalculTpsTravail(ParamGlobaux, item, d, d, ParamGlobaux.IDEtablissement, "", "");

                    listeCalcul.Add(new Data(item, ((TempsTravail.TpsTravailEffectif + TempsTravail.TpsTravailAssimilé + TempsTravail.TpsRéparti) / (double)60.00m), TempsTravail.HeuresAbsencesRémunérées, d));
                }
            }



            foreach (DataRow DtRowBD in DsBordereauDeclaratif.Tables["Planning"].Rows)
            {
                Data jour = listeCalcul.SingleOrDefault(l => l.Matricule == DtRowBD["Matricule"].ToString() && l.Jour == Convert.ToDateTime(DtRowBD["Jour"]));
                if (jour != null)
                {
                    DtRowBD["Temp de travail"] = jour.TempTravail;
                    DtRowBD["Abs"]             = jour.Abs;
                }
            }

            //////////Prévisionnel en string////////////


            if (previsionnel.ToString() == "Oui")
            {
                stringPrevisionnel = "Prévisionnel";
            }
            else
            {
                stringPrevisionnel = "";
            }

            if (entete == null)
            {
                entete = "";
            }


            _ReportSource.SetDataSource(DsBordereauDeclaratif);

            ///////////Nom Etablissement/////////////////////////////
            string NomEtablissement;

            NomEtablissement = ParamGlobaux.Etablissement.ToString();

            TextObject Commentaire;
            TextObject Previsionnel;
            TextObject Etablissement;

            if ((_ReportSource.ReportDefinition.ReportObjects["Text3"] != null) &&
                (_ReportSource.ReportDefinition.ReportObjects["Text4"] != null) &&
                (_ReportSource.ReportDefinition.ReportObjects["Text6"] != null))
            {
                Commentaire        = (TextObject)_ReportSource.ReportDefinition.ReportObjects["Text3"];
                Commentaire.Text   = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(entete.ToString());
                Previsionnel       = (TextObject)_ReportSource.ReportDefinition.ReportObjects["Text4"];
                Previsionnel.Text  = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(stringPrevisionnel.ToString());
                Etablissement      = (TextObject)_ReportSource.ReportDefinition.ReportObjects["Text6"];
                Etablissement.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(NomEtablissement.ToString());
            }

            RaisePropertyChanged("ReportSource");
        }
コード例 #2
0
        private async Task CreationApercu(IProgress <ProgressMessage> progress)
        {
            DataRow DtRow;

            //string StSQL;
            //StSQL = "";
            //DataSet DsTemp = new DataSet();


            _ReportSource = new CRDemandeAbsence();

            DsDemandeAbsence DsDemandeAbsence = new DsDemandeAbsence();

            ////////////////////////Initialisation barre de progression//////////////////////////
            _progressMax = (ListeDemande_Absence.Count);
            int _progressValue = 0;

            ////////remplissage du DsBordereauDeclaratif///////////////

            foreach (var item in ListeDemande_Absence)
            {
                DtRow = DsDemandeAbsence.Tables["Demande_Absence"].NewRow();

                DtRow[0] = item.Matricule;
                DtRow[1] = item.Nom;
                DtRow[2] = item.Prenom;
                DtRow[3] = item.Date_debut;
                DtRow[4] = item.Date_fin;
                DtRow[5] = item.Type_Jour;

                DsDemandeAbsence.Tables["Demande_Absence"].Rows.Add(DtRow);

                _progressValue++;
                _progress.Report(new ProgressMessage((_progressValue * 100) / _progressMax, "Création de l'aperçu...", false));
            }



            _ReportSource.SetDataSource(DsDemandeAbsence);



            //oConnection = ClassLibraryProget.DataBase.OpenSqlServer(ParamGlobaux.ConnectionString);

            ///////////Nom Etablissement/////////////////////////////
            string NomEtablissement;

            NomEtablissement = ParamGlobaux.Etablissement.ToString();


            TextObject Etablissement;

            if (_ReportSource.ReportDefinition.ReportObjects["Text1"] != null)
            {
                Etablissement      = (TextObject)_ReportSource.ReportDefinition.ReportObjects["Text1"];
                Etablissement.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(NomEtablissement.ToString());
            }

            RaisePropertyChanged("ReportSource");

            _progress.Report(new ProgressMessage(100, "Finished", true));
        }