internal void supprimerPayer(PayerBE payer) { if (payerDA.supprimer(payer)) { journalDA.journaliser("Annulation de la vente d'une prestation - " + payer.codePrestation + " - " + payer.matricule); } }
private void gestionDispense() { double montantDispense = Convert.ToDouble(txtRemise.Text); matricule = txtMatricule.Text.ToString(); login = Ecole.UI.ConnexionUI.utilisateur.login; PayerBE payerBE; bool b = true; // 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 List <PayerBE> listes = prestationBL.listerTrancheNonPayees(categorie, matricule, annee); MontantTrancheBE t = new MontantTrancheBE(); 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 (montantDispense >= (t.montant - pa.montant - Convert.ToDouble(pa.remise))) { payerBE = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, pa.montant, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, Convert.ToDecimal(t.montant - pa.montant)); p = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, 0, dpiDateOp.SelectedDate.Value, annee, TRANCHE_COMPLET, Convert.ToDecimal(t.montant - pa.montant - (double)pa.remise)); if (prestationBL.modifierPayer(payerBE, p)) { payers.Add(payerBE); } montantDispense -= (t.montant - pa.montant - Convert.ToDouble(pa.remise)); } else { if (montantDispense > 0) { payerBE = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, pa.montant, dpiDateOp.SelectedDate.Value, annee, TRANCHE_INCOMPLET, pa.remise + Convert.ToDecimal(montantDispense)); p = new PayerBE(pa.matricule, login, pa.codePrestation, pa.codeTranche, 0, dpiDateOp.SelectedDate.Value, annee, TRANCHE_INCOMPLET, Convert.ToDecimal(montantDispense)); if (prestationBL.modifierPayer(payerBE, p)) { payers.Add(payerBE); } } montantDispense = 0; b = false; } } } } }
internal bool ajouterAcheterPayer(PayerBE payer) { if (payerDA.ajouter(payer)) { journalDA.journaliser("Vente d'une prestation - " + payer.codePrestation + " - " + payer.matricule); return(true); } else { return(false); } }
//internal bool modifierPayer(PayerBE pa, PayerBE payer) //{ // if (payerDA.modifier(pa, payer)) // { // journalDA.journaliser("Modification de la vente d'une prestation - " + payer.codePrestation + " - " + payer.matricule); // return true; // } // else // return false; //} internal bool modifierPayer(PayerBE payer, PayerBE net_payer) { if (payerDA.modifier(payer, net_payer)) { journalDA.journaliser("Modification de la vente d'une prestation - " + payer.codePrestation + " - " + payer.matricule); return(true); } else { return(false); } }
public List <PayerBE> tranchesNonReglees(string categorie, string matricule, string annee) { List <PayerBE> listes = new List <PayerBE>(); try { MySqlCommand cmd = con.connexion.CreateCommand(); cmd.CommandText = "SELECT * FROM ((SELECT p.codetranche, '', p.codeprestation, m.montant, p.annee, m.delai, pr.priorite, p.montant as montantPaye, p.remise" + " FROM payer p, prestation pr, montanttranche m " + " WHERE p.matricule = '" + matricule + "' AND p.observation = 'Incomplet' and pr.codeprestation=p.codeprestation and p.codeprestation=m.codeprestation and m.codetranche=p.codetranche" + " and m.annee=p.annee and p.annee='" + annee + "' and m.codecateleve='" + categorie + "') " + " UNION " + " (select *, 0 as montantPaye,0 as remise " + " FROM ((SELECT mt.*, p.priorite " + " FROM montanttranche mt, prestation p " + " WHERE mt.codecateleve = '" + categorie + "' and mt.codeprestation=p.codeprestation)) t" + " where (t.codeprestation,codetranche)" + " NOT IN" + " (SELECT codeprestation,codetranche" + " FROM payer WHERE matricule = '" + matricule + "' and annee='" + annee + "')" + " and annee ='" + annee + "')) tb" + " order by tb.codetranche , tb.priorite"; using (MySqlDataReader dataReader = cmd.ExecuteReader()) { while (dataReader.Read()) { PayerBE payer = new PayerBE(); payer.annee = Convert.ToInt32(annee); payer.codePrestation = Convert.ToString(dataReader["codeprestation"]); payer.codeTranche = Convert.ToString(dataReader["codetranche"]); payer.datePaiement = DateTime.Today; payer.login = ""; payer.matricule = matricule; payer.montant = Convert.ToDouble(dataReader["montantPaye"]); payer.observation = "Incomplet"; payer.remise = Convert.ToDecimal(dataReader["remise"]); listes.Add(payer); } dataReader.Close(); return(listes); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public Payer_Prestation() { InitializeComponent(); dpiDateOp.SelectedDate = DateTime.Today; dpiDateOp.IsTodayHighlighted = true; dpiDateOp.Text = DateTime.Now.ToString(); CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name); ci.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy"; Thread.CurrentThread.CurrentCulture = ci; prestationBL = new GestionPrestationBL(); montanttranches = new List <MontantTrancheBE>(); listprestation = new List <string>(); listtranches = new List <string>(); choixDispense = new List <string>() { BOURSE, REMISE }; classes = new List <string>(); eleves = new List <string>(); payers = new List <PayerBE>(); lignes = new List <LignePrestation>(); eleve = new EleveBE(); payer = new PayerBE(); prestation = new PrestationBE(); // fraisInscription = 0; fraisPrestation = 0; totalAPayer = 0; classes = prestationBL.listerValeursColonneClasse("codeclasse"); cmbClasse.ItemsSource = classes; cmbDispense.ItemsSource = choixDispense; annee = prestationBL.AnneeEnCours(); listtranches = prestationBL.listerValeursColonneTranche("codetranche"); cmbTranche.ItemsSource = listtranches; txtAnnee.Text = " / " + annee; txtAnneeScolaire.Text = (annee - 1).ToString(); txtTotal.IsEnabled = false; txtTotalVerse.IsEnabled = false; txtResteAPayer.IsEnabled = false; txtReste.IsEnabled = false; txtRemise.IsEnabled = false; cmbDispense.IsEnabled = false; txtMontant.IsEnabled = false; }
private void grdStatus_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { if (MessageBox.Show("Voulez vous supprimer?", "School : Confirmation", System.Windows.MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (grdStatus.SelectedIndex != -1) { PayerBE payer = new PayerBE(); payer = payers.ElementAt(grdStatus.SelectedIndex); payers.Remove(payer); prestationBL.supprimerPayer(payer); lignes = chargerGrid(); grdStatus.ItemsSource = lignes; grdStatus.Items.Refresh(); } else { MessageBox.Show("Aucune ligne sélectionnée", "School brain:Alerte"); } } } }
internal string rechercherNumeroPayer(PayerBE payerBE) { return(payerDA.rechercherNumeroPayer(payerBE).ToString()); }
internal PayerBE rechercherPayer(PayerBE payer) { return(payerDA.rechercher(payer)); }
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 = ""; }