public WindowCreerModifierTrancheUI()
        {
            CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);

            ci.DateTimeFormat.ShortDatePattern  = "dd-MM-yyyy";
            Thread.CurrentThread.CurrentCulture = ci;

            InitializeComponent();

            creerModifierTrancheBL = new CreerModifierTrancheBL();
            ancienneTranche        = new TrancheBE();

            etat = 0;

            // A mettre pour que le binding avec le DataGrid fonctionne !
            grdListeTranche.DataContext = this;

            // Initialisation de la collection, qui va s'afficher dans la DataGrid :
            ListeTranches = new ObservableCollection <TrancheBE>();
            List <TrancheBE> LTrancheBE = creerModifierTrancheBL.listerToutesLesTranche();

            // on met la liste "LSerieBE" dans le DataGrid
            RemplirDataGrid(LTrancheBE);

            radioManuelle.IsChecked = true;
        }
        private void grdListeTranche_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (grdListeTranche.SelectedIndex != -1)
            {
                etat = 1;
                TrancheBE tranche = new TrancheBE();

                tranche = creerModifierTrancheBL.rechercherTranche(ListeTranches.ElementAt(grdListeTranche.SelectedIndex));
                if (tranche != null)
                {
                    // on charge les informations dans le formulaire
                    txtCodeTranche.Text = tranche.codetranche;
                    txtNom.Text         = tranche.nomtranche;

                    ancienneTranche.codetranche = tranche.codetranche;
                    ancienneTranche.nomtranche  = tranche.nomtranche;

                    //on remet les champs "code" et "nom" éditable
                    txtCodeTranche.IsReadOnly = false;
                    txtNom.IsReadOnly         = false;
                    txtNbreTranche.IsEnabled  = false;
                }

                grdListeTranche.UnselectAll();
            }
        }
Ejemplo n.º 3
0
        internal string obtenirNomTranche(string p)
        {
            TrancheBE tranche = new TrancheBE();

            tranche.codetranche = p;
            tranche             = trancheDA.rechercher(tranche);
            return(tranche.nomtranche);
        }
Ejemplo n.º 4
0
 // modifier une Tranche
 public bool modifierTranche(TrancheBE tranche)
 {
     if (trancheDA.modifier(tranche))
     {
         journalDA.journaliser("modification de la tranche de code " + tranche.codetranche + ". nouveau nom : " + tranche.nomtranche);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 // supprimer une Tranche
 public bool supprinerTranche(TrancheBE tranche)
 {
     if (trancheDA.supprimer(tranche))
     {
         journalDA.journaliser("suppression de la tranche de code " + tranche.codetranche + " et de nom " + tranche.nomtranche);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        //creer une Tranche
        public bool creerTranche(string codeTranche, string nomTranche)
        {
            TrancheBE tranche = new TrancheBE(codeTranche, nomTranche);

            if (trancheDA.ajouter(tranche))
            {
                journalDA.journaliser("enregistrement d'une tranche de code " + codeTranche + " et de nom " + nomTranche);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
 internal TrancheBE rechercherTranche(TrancheBE trancheBE)
 {
     return(trancheDA.rechercher(trancheBE));
 }
        private void gestionRemise()
        {
            decimal pourcentageRemise        = Convert.ToDecimal(txtRemise.Text);
            string  codeprestation           = cmbPrestation.SelectedValue.ToString();
            double  remise                   = 0;
            List <MontantTrancheBE> tranches = new List <MontantTrancheBE>();

            montant        = Convert.ToDouble(txtMontant.Text);
            matricule      = txtMatricule.Text.ToString();
            codeprestation = cmbPrestation.SelectedValue.ToString();
            login          = Ecole.UI.ConnexionUI.utilisateur.login;
            tranches       = prestationBL.listerSuivantCritereMontanttranches("codeprestation = " + "'" + codeprestation + "' and codecateleve = " + "'" + categorie + "' and annee = " + "'" + annee + "'");
            PayerBE   payerBE;
            double    frais;
            CreerEtat etat = null;
            TrancheBE trancheBE;

            if (cmbTranche.SelectedValue != null)
            {
                foreach (MontantTrancheBE mt in tranches)
                {
                    if (mt.codeTranche != tranche)
                    {
                        remise  = (mt.montant * Convert.ToDouble(pourcentageRemise)) / 100;
                        payerBE = new PayerBE(matricule, Ecole.UI.ConnexionUI.utilisateur.login, codeprestation, mt.codeTranche, 0, dpiDateOp.SelectedDate.Value, annee, TRANCHE_INCOMPLET, Convert.ToDecimal(remise));
                        if (prestationBL.ajouterAcheterPayer(payerBE))
                        {
                        }
                        else
                        {
                            MessageBox.Show("Enregistrement echoue");
                        }
                    }
                    else
                    {
                        remise  = (montant * Convert.ToDouble(pourcentageRemise)) / 100;
                        frais   = montant - remise;
                        payerBE = new PayerBE(matricule, login, codeprestation, tranche, frais, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, Convert.ToDecimal(remise));
                        if (prestationBL.rechercherPayer(payerBE) == null)
                        {
                            if (prestationBL.ajouterAcheterPayer(payerBE))
                            {
                                trancheBE             = new TrancheBE();
                                trancheBE.codetranche = payerBE.codeTranche;
                                trancheBE             = prestationBL.rechercherTranche(trancheBE);
                                etat = new CreerEtat("Paiement_prestation" + matricule + DateTime.Today.ToShortDateString(), "Reçu de paiement N° " + prestationBL.rechercherNumeroPayer(payerBE) + "\nDate " + dpiDateOp.SelectedDate.Value);
                                etat.facturePrestation(payerBE, eleve, cmbClasse.Text, prestation.nomPrestation, remise, trancheBE.nomtranche);
                                montant -= frais;
                            }
                            else
                            {
                                MessageBox.Show("Enregistrement echoue");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Cette tranche a déjà été payée pour cet étudiant, faire un dépot pour compléter le paiement si elle est incomplète");
                        }
                    }
                }
            }
            else
            {
                double montantPrestation = montant;
                foreach (MontantTrancheBE mt in tranches)
                {
                    remise  = (mt.montant * Convert.ToDouble(pourcentageRemise)) / 100;
                    payerBE = new PayerBE(matricule, Ecole.UI.ConnexionUI.utilisateur.login, codeprestation, mt.codeTranche, mt.montant - remise, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, Convert.ToDecimal(remise));
                    if (prestationBL.ajouterAcheterPayer(payerBE))
                    {
                        montant -= mt.montant - remise;
                    }
                    else
                    {
                        MessageBox.Show("Enregistrement echoue");
                    }
                }
                remise = (montantPrestation * Convert.ToDouble(pourcentageRemise)) / 100;
                etat   = new CreerEtat("Paiement_prestation" + matricule + DateTime.Today.ToShortDateString(), "Reçu de paiement " + "\nDate " + dpiDateOp.SelectedDate.Value);
                etat.facturePrestation(prestation, eleve, cmbClasse.Text, montantPrestation, remise);
            }
        }
        private void cmdValider_new_Click(object sender, RoutedEventArgs e)
        {
            if (cmbPrestation.SelectedValue == null || cmbPrestation.Text == "")
            {
                if (checkRemise.IsChecked == true)
                {
                    switch (cmbDispense.Text)
                    {
                    case REMISE:
                        MessageBox.Show("La réduction s'effectue sur une prestation, choisissez d'abord la prestation", "school brain:Alerte", MessageBoxButton.OK, MessageBoxImage.Information);
                        break;

                    case BOURSE:
                        gestionDispense();
                        break;
                    }
                }
            }
            else
            {
                if (txtMontant.Text != "")
                {
                    string codeprestation            = cmbPrestation.SelectedValue.ToString();
                    double remise                    = 0;
                    List <MontantTrancheBE> tranches = new List <MontantTrancheBE>();
                    montant        = Convert.ToDouble(txtMontant.Text);
                    matricule      = txtMatricule.Text.ToString();
                    codeprestation = cmbPrestation.SelectedValue.ToString();
                    login          = Ecole.UI.ConnexionUI.utilisateur.login;
                    tranches       = prestationBL.listerSuivantCritereMontanttranches("codeprestation = " + "'" + codeprestation + "' and codecateleve = " + "'" + categorie + "' and annee = " + "'" + annee + "'");
                    PayerBE   payerBE;
                    double    frais;
                    CreerEtat etat = null;
                    TrancheBE trancheBE;
                    switch (codeprestation)
                    {
                        #region gestion de cas d'un depot
                    case "Depot":
                        if (checkRemise.IsChecked == true)
                        {
                            if (cmbDispense.Text == BOURSE)
                            {
                                gestionDispense();
                            }
                        }

                        // on recherche dans la bd à la fois les tranches non complètement payées et les tranches qui n'ont pas encore commencé à être payées
                        bool             b          = true;
                        List <PayerBE>   listes     = prestationBL.listerTrancheNonPayees(categorie, matricule, annee);
                        MontantTrancheBE t          = new MontantTrancheBE();
                        string           numerorecu = "";

                        if (listes != null)
                        {
                            PayerBE p = new PayerBE();

                            foreach (PayerBE pa in listes)
                            {
                                if (b == true)
                                {
                                    t.codeCatEleve   = categorie;
                                    t.codePrestation = pa.codePrestation;
                                    t.codeTranche    = pa.codeTranche;
                                    t.annee          = pa.annee;
                                    t = prestationBL.rechercherMontantTranche(t);
                                    if (montant >= (t.montant - pa.montant - Convert.ToDouble(pa.remise)))
                                    {
                                        payerBE = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, t.montant - Convert.ToDouble(pa.remise),
                                                              dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, pa.remise);
                                        p = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, t.montant - pa.montant - Convert.ToDouble(pa.remise),
                                                        dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, pa.remise);
                                        if (prestationBL.modifierPayer(payerBE, p))
                                        {
                                            payers.Add(payerBE);
                                            numerorecu = prestationBL.rechercherNumeroPayer(payerBE);
                                        }
                                        montant -= (t.montant - pa.montant - Convert.ToDouble(pa.remise));
                                    }
                                    else
                                    {
                                        if (montant > 0)
                                        {
                                            payerBE = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, (pa.montant + montant), dpiDateOp.SelectedDate.Value, annee, TRANCHE_INCOMPLET, pa.remise);
                                            p       = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, montant, dpiDateOp.SelectedDate.Value, annee, TRANCHE_INCOMPLET, pa.remise);

                                            if (prestationBL.modifierPayer(payerBE, p))
                                            {
                                                payers.Add(payerBE);
                                                if (numerorecu == "")
                                                {
                                                    numerorecu = prestationBL.rechercherNumeroPayer(payerBE);
                                                }
                                            }
                                        }
                                        montant = 0;
                                        b       = false;
                                    }
                                }
                            }

                            //enregistrement du versement
                            //prestationBL.enregistrer_versement(matricule, "Opération de dépot d'argent pour les frais de : " + cmbPrestation.Text, (Convert.ToDouble(txtMontant.Text) - montant ),
                            //    dpiDateOp.SelectedDate.Value, annee);
                        }
                        lignes = chargerGrid();
                        etat   = new CreerEtat("Paiement_prestation" + matricule + DateTime.Today.ToShortDateString(), "Reçu de versement N° " + numerorecu + "\nDate " + dpiDateOp.SelectedDate.Value);
                        etat.factureDepot(Convert.ToDouble(txtMontant.Text), montant, totalAPayer, totalVerse, resteAPayer, eleve, cmbClasse.Text);
                        initialiser();
                        break;
                        #endregion

                        #region gestion d'un paiement normal d'une tranche
                    default:
                        if (checkRemise.IsChecked == true)
                        {
                            switch (cmbDispense.Text)
                            {
                            case REMISE:
                                gestionRemise();
                                break;

                            case BOURSE:
                                gestionDispense();
                                break;
                            }
                        }
                        else
                        {
                            if (cmbTranche.SelectedValue != null)
                            {
                                payerBE = new PayerBE(matricule, login, codeprestation, tranche, montant, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, 0);
                                if (prestationBL.rechercherPayer(payerBE) == null)
                                {
                                    if (prestationBL.ajouterAcheterPayer(payerBE))
                                    {
                                        trancheBE             = new TrancheBE();
                                        trancheBE.codetranche = payerBE.codeTranche;
                                        trancheBE             = prestationBL.rechercherTranche(trancheBE);
                                        etat = new CreerEtat("Paiement_prestation" + matricule + DateTime.Today.ToShortDateString(), "Reçu de paiement N° " + prestationBL.rechercherNumeroPayer(payerBE) + "\nDate " + dpiDateOp.SelectedDate.Value);
                                        etat.facturePrestation(payerBE, eleve, cmbClasse.Text, prestation.nomPrestation, 0, trancheBE.nomtranche);
                                        montant -= montant;

                                        //enregistrement du versement
                                        //prestationBL.enregistrer_versement(matricule, "Opération de dépot d'argent pour les frais de : " + cmbPrestation.Text, Convert.ToDouble(txtMontant.Text),
                                        //    dpiDateOp.SelectedDate.Value, annee);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Enregistrement echoue");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Cette tranche a déjà été payée pour cet étudiant, pour modifier cliquer sur la ligne correspondante dans la grille du bas");
                                }
                            }
                            else
                            {
                                double m = montant;
                                numerorecu = "";
                                foreach (MontantTrancheBE mt in tranches)
                                {
                                    payerBE = new PayerBE(matricule, Ecole.UI.ConnexionUI.utilisateur.login, codeprestation, mt.codeTranche, mt.montant, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, Convert.ToDecimal(remise));
                                    if (prestationBL.ajouterAcheterPayer(payerBE))
                                    {
                                        if (numerorecu == "")
                                        {
                                            numerorecu = prestationBL.rechercherNumeroPayer(payerBE);
                                        }
                                        montant -= mt.montant;
                                    }
                                    else
                                    {
                                        MessageBox.Show("Enregistrement echoue");
                                    }
                                }

                                //enregistrement du versement
                                //prestationBL.enregistrer_versement(matricule, "Opération de dépot d'argent pour les frais de : " + cmbPrestation.Text, Convert.ToDouble(txtMontant.Text),
                                //    dpiDateOp.SelectedDate.Value, annee);

                                etat = new CreerEtat("Paiement_prestation" + matricule + DateTime.Today.ToShortDateString(), "Reçu de paiement N° " + numerorecu + "\nDate " + dpiDateOp.SelectedDate.Value);
                                etat.facturePrestation(prestation, eleve, cmbClasse.Text, m, remise);
                            }
                        }
                        initialiser();
                        break;
                        #endregion
                    }
                }
                else
                {
                    MessageBox.Show("Veuillez renseigner le montant!", "school brain:Alerte", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            //enregistrement du versement
            prestationBL.enregistrer_versement(matricule, "Opération de dépot d'argent pour les frais de : " + cmbPrestation.Text, (Convert.ToDouble(txtMontant.Text) - montant),
                                               dpiDateOp.SelectedDate.Value, annee);

            txtReste.Text = montant.ToString();
            lignes.Clear();
            lignes = chargerGrid();
            grdStatus.ItemsSource = lignes;
            grdStatus.Items.Refresh();

            txtMontant.Clear();
            cmbTranche.Text = "";
        }
Ejemplo n.º 10
0
 // rechercher une Tranche
 public TrancheBE rechercherTranche(TrancheBE tranche)
 {
     return(trancheDA.rechercher(tranche));
 }
        private void cmdValider_Click(object sender, RoutedEventArgs e)
        {
            TrancheBE tranche = new TrancheBE();

            if (etat == 1)
            {
                if ((txtCodeTranche.Text != null && txtNom.Text != null) && (txtCodeTranche.Text != "" && txtNom.Text != ""))
                {
                    tranche.codetranche = txtCodeTranche.Text;
                    tranche.nomtranche  = txtNom.Text;

                    if (creerModifierTrancheBL.rechercherTranche(tranche) == null)
                    {
                        creerModifierTrancheBL.modifierTranche(ancienneTranche, tranche);
                        // on met à jour le DataGrid
                        List <TrancheBE> LTranche = creerModifierTrancheBL.listerToutesLesTranche();
                        RemplirDataGrid(LTranche);

                        txtNbreTranche.Text        = "";
                        txtCodeTranche.Text        = "";
                        txtNom.Text                = "";
                        radioAutomatique.IsChecked = false;
                        radioManuelle.IsChecked    = true;

                        //on remet les champs "code" et "nom" éditable
                        txtCodeTranche.IsReadOnly = false;
                        txtNom.IsReadOnly         = false;
                        txtNbreTranche.IsEnabled  = false;

                        etat = 0;
                    }
                    else
                    {
                        MessageBox.Show("Il existe deja une tranche avec ce code dans le système !");
                    }
                }
                else
                {
                    MessageBox.Show("Les champs 'Code' et 'Nom' doivent êtres renseignés !");
                }
            }
            else if (radioAutomatique.IsChecked == true)
            {
                // si on a coché sur "automatique"
                if (txtNbreTranche.Text != null && txtNbreTranche.Text != "")
                {
                    for (int i = 0; i < Convert.ToInt16(txtNbreTranche.Text); i++)
                    {
                        tranche.codetranche = "T" + (i + 1);
                        tranche.nomtranche  = "Tranche" + (i + 1);

                        if (creerModifierTrancheBL.rechercherTranche(tranche) == null)
                        {
                            creerModifierTrancheBL.creerTranche(tranche.codetranche, tranche.nomtranche);
                            //MessageBox.Show(" Echec Enregistrement Tranche [ code : " + tranche.codetranche + ", nom : " + tranche.nomtranche + " ]");
                        }
                        else
                        {
                            MessageBox.Show("Il existe deja une tranche avec le code '" + tranche.codetranche + "' dans le système !");
                        }
                    }
                    // on met à jour le DataGrid
                    List <TrancheBE> LTranche = creerModifierTrancheBL.listerToutesLesTranche();
                    RemplirDataGrid(LTranche);

                    txtNbreTranche.Text        = "";
                    txtCodeTranche.Text        = "";
                    txtNom.Text                = "";
                    radioAutomatique.IsChecked = false;
                    radioManuelle.IsChecked    = true;

                    //on remet les champs "code" et "nom" éditable
                    txtCodeTranche.IsReadOnly = false;
                    txtNom.IsReadOnly         = false;
                    txtNbreTranche.IsEnabled  = false;
                }
                else
                {
                    MessageBox.Show("Vous devez indiquer le nombre de tranches !");
                }
            }
            else if (radioManuelle.IsChecked == true)
            {
                // si on a coché sur "manuelle"
                if ((txtCodeTranche.Text != null && txtNom.Text != null) && (txtCodeTranche.Text != "" && txtNom.Text != ""))
                {
                    tranche.codetranche = txtCodeTranche.Text;
                    tranche.nomtranche  = txtNom.Text;

                    if (creerModifierTrancheBL.rechercherTranche(tranche) == null)
                    {
                        creerModifierTrancheBL.creerTranche(tranche.codetranche, tranche.nomtranche);

                        // on met à jour le DataGrid
                        List <TrancheBE> LTranche = creerModifierTrancheBL.listerToutesLesTranche();
                        RemplirDataGrid(LTranche);

                        txtNbreTranche.Text        = "";
                        txtCodeTranche.Text        = "";
                        txtNom.Text                = "";
                        radioAutomatique.IsChecked = false;
                        radioManuelle.IsChecked    = true;

                        //on remet les champs "code" et "nom" éditable
                        txtCodeTranche.IsReadOnly = false;
                        txtNom.IsReadOnly         = false;
                        txtNbreTranche.IsEnabled  = true;
                    }
                    else
                    {
                        MessageBox.Show("Il existe deja une tranche avec le code '" + tranche.codetranche + "' dans le système !");
                    }
                }
                else
                {
                    MessageBox.Show("Les champs 'Code' et 'Nom' doivent êtres renseignés ! ");
                }
            }
        }