internal OperationBE rechercherOperation(OperationBE operation)
 {
     return(operationDA.rechercher(operation));
 }
        /**
         * fonction qui recupere les conditions pour alimenter la datagrid
         */
        private void chargerDataGrid()
        {
            CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);

            ci.DateTimeFormat.ShortDatePattern  = "yyyy-MM-dd";
            Thread.CurrentThread.CurrentCulture = ci;
            CultureInfo elGR = CultureInfo.CreateSpecificCulture("el-GR");

            string datefin   = DateTime.Today.Date.ToShortDateString();
            string datedebut = DateTime.Today.Date.ToShortDateString();

            if (dpiDateFin.SelectedDate != null)
            {
                datefin = dpiDateFin.SelectedDate.Value.Date.ToShortDateString();
            }
            if (dpiDateDebut.SelectedDate != null)
            {
                datedebut = dpiDateDebut.SelectedDate.Value.Date.ToShortDateString();
            }
            OperationBE operation = new OperationBE();

            entree = 0;

            if (datefin.CompareTo(datedebut) >= 0)
            {
                payers = new List <LigneVersement>();
                payers = caisseBL.listerSuivantCriterePayers_versement("datepaiement between " + "'" + datedebut + "' AND " + "'" + datefin + "'");

                //calcul du montant des entrees et des sorties
                if (payers != null)
                {
                    foreach (LigneVersement p in payers)
                    {
                        entree += (decimal)p.montant;
                    }
                }

                string motif = txtMotif.Text;

                foreach (LigneVersement l in payers)
                {
                    l.nom = caisseBL.obtenirNomEleve(l.matricule);
                    try
                    {
                        l.classe = caisseBL.obtenirClasse(l.matricule);
                    }
                    catch (Exception)
                    {
                        l.classe = " - ";
                    }
                }
                grdEtatCaisse.ItemsSource = payers;
                grdEtatCaisse.Items.Refresh();

                txtTotalEntree.Text = entree.ToString("0,0", elGR);
            }
            else
            {
                MessageBox.Show("La date de debut doit être plus petite ou égale à la date de fin");
                payers = new List <LigneVersement>();
                grdEtatCaisse.ItemsSource = payers;
                grdEtatCaisse.Items.Refresh();
            }
        }
Beispiel #3
0
        /**
         * fonction qui recupere les conditions pour alimenter la datagrid
         */
        private void chargerDataGrid()
        {
            CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);

            ci.DateTimeFormat.ShortDatePattern  = "yyyy-MM-dd";
            Thread.CurrentThread.CurrentCulture = ci;
            CultureInfo       elGR         = CultureInfo.CreateSpecificCulture("el-GR");
            List <RealiserBE> listes       = new List <RealiserBE>();
            List <PayerBE>    payers_avant = new List <PayerBE>();

            lignes = new List <LigneEtat>();
            decimal montantEntrees, montantSorties, solde;

            string datefin   = DateTime.Today.Date.ToShortDateString();
            string datedebut = DateTime.Today.Date.ToShortDateString();

            if (dpiDateFin.SelectedDate != null)
            {
                datefin = dpiDateFin.SelectedDate.Value.Date.ToShortDateString();
            }
            if (dpiDateDebut.SelectedDate != null)
            {
                datedebut = dpiDateDebut.SelectedDate.Value.Date.ToShortDateString();
            }
            OperationBE operation = new OperationBE();

            if (datefin.CompareTo(datedebut) >= 0)
            {
                listes    = caisseBL.listerSuivantCritereRealisers("dateop between " + "'" + datedebut + "' AND " + "'" + datefin + "'");
                realisers = new List <RealiserBE>();
                payers    = new List <PayerBE>();

                foreach (RealiserBE r in listes)
                {
                    realisers.Add(r);
                }
                payers = caisseBL.listerSuivantCriterePayers("datepaiement between " + "'" + datedebut + "' AND " + "'" + datefin + "'");

                lignes = creerDataSource(realisers, payers);


                //calcul du montant des entrees et des sorties
                montantSorties = 0;
                montantEntrees = 0;
                if (listes != null)
                {
                    foreach (RealiserBE r in listes)
                    {
                        //operation.codeOp = r.codeop;
                        //operation = caisseBL.rechercherOperation(operation);
                        if (r.codeop == "entree")
                        {
                            montantEntrees += r.montant;
                        }
                        else
                        {
                            montantSorties += r.montant;
                        }
                    }
                }
                if (payers != null)
                {
                    foreach (PayerBE p in payers)
                    {
                        montantEntrees += (decimal)p.montant;
                    }
                }

                //calcul du solde avant la date de debut
                listes       = caisseBL.listerSuivantCritereRealisers("dateop < " + "'" + datedebut + "'");
                payers_avant = caisseBL.listerSuivantCriterePayers("datepaiement < " + "'" + datedebut + "'");
                //operation = new OperationBE();
                solde = 0;
                if (listes != null)
                {
                    foreach (RealiserBE r in listes)
                    {
                        //operation.codeOp = r.codeop;
                        //operation = caisseBL.rechercherOperation(operation);
                        if (r.codeop == "entree")
                        {
                            solde += r.montant;
                        }
                        else
                        {
                            solde -= r.montant;
                        }
                    }
                }
                if (payers_avant != null)
                {
                    foreach (PayerBE p in payers_avant)
                    {
                        solde += (decimal)p.montant;
                    }
                }


                listes       = caisseBL.listerTousRealiser();
                payers_avant = caisseBL.listerTousPayer();
                //operation = new OperationBE();
                soldetotal = 0;
                if (listes != null)
                {
                    foreach (RealiserBE r in listes)
                    {
                        //operation.codeOp = r.codeop;
                        //operation = caisseBL.rechercherOperation(operation);
                        if (r.codeop == "entree")
                        {
                            soldetotal += r.montant;
                        }
                        else
                        {
                            soldetotal -= r.montant;
                        }
                    }
                }
                if (payers_avant != null)
                {
                    foreach (PayerBE p in payers_avant)
                    {
                        soldetotal += (decimal)p.montant;
                    }
                }

                txtEntreePeriode.Text = montantEntrees.ToString("0,0", elGR);
                txtSortiePeriode.Text = montantSorties.ToString("0,0", elGR);
                txtSoldePeriode.Text  = (montantEntrees - montantSorties).ToString("0,0", elGR);
                txtAncienSolde.Text   = solde.ToString("0,0", elGR);
                txtSoldeTotal.Text    = soldetotal.ToString("0,0", elGR);

                string           motif = txtMotif.Text;
                decimal          entree = 0, sortie = 0;
                List <LigneEtat> tampon = new List <LigneEtat>();
                foreach (LigneEtat l in lignes)
                {
                    if (motif == "" || l.motif.ToUpper().Contains(motif.ToUpper()))
                    {
                        tampon.Add(l);
                    }
                }

                lignes = new List <LigneEtat>();
                foreach (LigneEtat l in tampon)
                {
                    lignes.Add(l);
                    if (l.type.ToLower() == "entree")
                    {
                        entree += l.montant;
                    }
                    else
                    {
                        sortie += l.montant;
                    }
                }

                grdEtatCaisse.ItemsSource = lignes;
                grdEtatCaisse.Items.Refresh();

                txtTotalEntree.Text = entree.ToString("0,0", elGR);
                txtTotalSolde.Text  = (entree - sortie).ToString("0,0", elGR);
                txtTotalSortie.Text = sortie.ToString("0,0", elGR);

                totalEntree = entree;
                totalSortie = sortie;
                totalSolde  = (entree - sortie);
            }
            else
            {
                MessageBox.Show("La date de debut doit être plus petite ou égale à la date de fin");
                lignes = new List <LigneEtat>();
                grdEtatCaisse.ItemsSource = lignes;
                grdEtatCaisse.Items.Refresh();
            }
        }