public static ModePaiement getOneModePaiement(long id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from yvs_mode_paiement where id = " + id + "";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                ModePaiement     a      = new ModePaiement();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        a.Id           = Convert.ToInt64(lect["id"].ToString());
                        a.TypePaiement = lect["type_paiement"].ToString();
                        a.Update       = true;
                    }
                    lect.Close();
                }
                return(a);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static List <ModePaiement> getListModePaiement(String query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                List <ModePaiement> l    = new List <ModePaiement>();
                NpgsqlCommand       Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader    lect = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        ModePaiement a = new ModePaiement();
                        a.Id           = Convert.ToInt64(lect["id"].ToString());
                        a.TypePaiement = lect["type_paiement"].ToString();
                        a.Update       = true;
                        l.Add(a);
                    }
                    lect.Close();
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        private void dgvModePaiements_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvModePaiements.SelectedRows.Count != 0)
            {
                etatNew = false;
                ModePaiement mp = ModePaiement.Charge((int)dgvModePaiements.SelectedRows[0].Cells["Id"].Value);
                txtLibelle.Text        = mp.Libelle;
                cbDebCred.SelectedItem = mp.Type == KEY.MODEPAIEMENTCREDIT ? KEY.MODEPAIEMENTCREDITLIB : KEY.MODEPAIEMENTDEBITLIB;
                kCbDiffere.Checked     = mp.Differe;
                if (mp.CompteGestion != null)
                {
                    cbCompteGestion.SelectedValue = mp.CompteGestion.Id;
                }
                if (mp.CompteDebite != null)
                {
                    cbCompteDeb.SelectedValue = mp.CompteDebite.Id;
                }
                kNudPeriodeDebut.Value      = Convert.ToDecimal(mp.PerdiodeDebut);
                kCbTypeDiffere.SelectedItem = mp.TypeDiffere;
                kNudDecalage.Value          = Convert.ToDecimal(mp.Decalage);
                txtDecaleSamedi.Checked     = mp.DecalageSamedi;
                txtDecaleDimanche.Checked   = mp.DecalageDimanche;
                txtDecaleJourFerie.Checked  = mp.DecalageFerie;

                if (mp.Type == KEY.MODEPAIEMENTCREDIT)
                {
                    kCbDiffere.Enabled = false;
                }
                else
                {
                    kCbDiffere.Enabled = true;
                }
            }
        }
        private void btnValid_Click(object sender, EventArgs e)
        {
            ModePaiement mp = etatNew ? new ModePaiement() : ModePaiement.Charge((int)dgvModePaiements.SelectedRows[0].Cells["Id"].Value);

            mp.Libelle          = txtLibelle.Text;
            mp.Type             = (string)cbDebCred.SelectedItem == KEY.MODEPAIEMENTCREDITLIB ? KEY.MODEPAIEMENTCREDIT : KEY.MODEPAIEMENTDEBIT;
            mp.Differe          = kCbDiffere.Checked;
            mp.CompteGestion    = (Compte)cbCompteGestion.SelectedItem;
            mp.CompteDebite     = (Compte)cbCompteDeb.SelectedItem;
            mp.PerdiodeDebut    = Convert.ToInt32(kNudPeriodeDebut.Value);
            mp.TypeDiffere      = (string)kCbTypeDiffere.SelectedItem;
            mp.Decalage         = Convert.ToInt32(kNudDecalage.Value);
            mp.DecalageSamedi   = txtDecaleSamedi.Checked;
            mp.DecalageDimanche = txtDecaleDimanche.Checked;
            mp.DecalageFerie    = txtDecaleJourFerie.Checked;

            if (etatNew)
            {
                ModePaiement.Sauve(mp);
            }
            else
            {
                ModePaiement.Maj(mp);
            }
        }
Exemple #5
0
        /// <summary>
        /// Méthode qui construit un objet Don à partir d'un DataRow
        /// </summary>
        /// <param name="don">DataRow de réponse d'une requête MySql</param>
        /// <returns></returns>
        private Don ConstruireDon(DataRow don)
        {
            DateTime DateHeureTransaction = (DateTime)don["dateDon"];
            float    Montant   = (float)don["montant"];
            string   NomAuteur = (string)don["Auteur"];
            //À partir du nom, la méthode StringToValue de ModePaiement retournera l'instance recherché pour le type de carte.
            ModePaiement mode = ModePaiement.StringToValue((string)don["ModePaiement"]);

            return(new Don(NomAuteur, Montant, mode, DateHeureTransaction));
        }
 private void btnSupModePaiement_Click(object sender, EventArgs e)
 {
     if (dgvModePaiements.SelectedRows.Count != 0)
     {
         if (MessageBox.Show("Etes-vous sur de supprimer ce Mode de Paiement ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ModePaiement.Delete(ModePaiement.Charge((int)dgvModePaiements.SelectedRows[0].Cells["Id"].Value));
             Charge();
         }
     }
 }
 public static string ModePaiementToCode(ModePaiement mode)
 {
     switch (mode)
     {
         case ModePaiement.CHEQUE:
             return "che";
         case ModePaiement.PRELEVEMENT:
             return "pre";
         case ModePaiement.VIREMENT:
             return "vir";
         default:
             return string.Empty;
     }
 }
Exemple #8
0
        public void ControleModePaiement(ModePaiement mode, int action)
        {
            InitializeConnexion();

            using (IDbCommand cmd = ImplementeConnexion.Instance.Con.CreateCommand())
            {
                cmd.CommandText = "sp_merge_mode_pmt";
                cmd.CommandType = CommandType.StoredProcedure;

                SetParameter(cmd, "@code", DbType.Int32, 4, mode.Code);
                SetParameter(cmd, "@designation", DbType.String, 100, mode.Designation);
                SetParameter(cmd, "@action", DbType.Int32, 4, action);

                cmd.ExecuteNonQuery();
            }
        }
Exemple #9
0
        private Operation CreateOperation(Compte c)
        {
            Operation o = new Operation
            {
                Compte       = c,
                Date         = txtOperationDate.Value,
                Categorie    = Categorie.Charge((int)txtOperationCategorie.SelectedValue),
                Libelle      = txtOperationLibelle.Text,
                Tiers        = txtOperationTiers.Text,
                ModePaiement = ModePaiement.Charge((int)txtOperationModePaiement.SelectedValue),
                Montant      = double.Parse(txtOperationMontant.Value.ToString(System.Globalization.CultureInfo.CurrentCulture), System.Globalization.CultureInfo.CurrentCulture),
                DatePointage = txtOperationPointage.Checked ? (DateTime?)DateTime.Now : null
            };

            return(Operation.Sauve(o));
        }
Exemple #10
0
        /// <summary>
        /// Méthode pour valider le champ du numéro de carte de crédit
        /// </summary>
        private void ValidationNoCarte()
        {
            //Utilise les trois regex connues pour reconnaitre le type de carte entre MasterCard, Visa et American Express.
            // http://www.regular-expressions.info/creditcard.html
            Regex  regexMasterCard = new Regex("^5[1-5][0-9]{14}$");
            Regex  regexVisa       = new Regex("^4[0-9]{12}(?:[0-9]{3})?$");
            Regex  regexAmex       = new Regex("^3[47][0-9]{13}$");
            string txtNo           = txtNoCarte.Text;
            //Passe à travers les trois regex pour essayer de trouver un match.
            bool isMastercard = regexMasterCard.IsMatch(txtNo);
            bool isVisa       = regexVisa.IsMatch(txtNo);
            bool isAmex       = regexAmex.IsMatch(txtNo);

            //Désactive les images de carte de crédit selon le match trouvé. Pour faire ressortir le type de carte détecté.
            imgAmex.IsEnabled       = isAmex;
            imgVisa.IsEnabled       = isVisa;
            imgMasterCard.IsEnabled = isMastercard;

            //Met la valeur de modePaiement selon le type de carte détecté avec notre classe singleton ModePaiement.
            if (isAmex)
            {
                modePaiement = ModePaiement.Amex;
            }
            else if (isVisa)
            {
                modePaiement = ModePaiement.Visa;
            }
            else if (isMastercard)
            {
                modePaiement = ModePaiement.MasterCard;
            }

            //Le type est détecté, donc on cache le label d'erreur associé au champ.
            if (isMastercard || isVisa || isAmex)
            {
                isNoCarteGood = true;
                lblErreurNoCarte.Visibility = Visibility.Hidden;
            }
            //Type non détecté.
            else
            {
                isNoCarteGood = false;
            }
        }
        public static bool getUpdateModePaiement(ModePaiement a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "";
                NpgsqlCommand Ucmd   = new NpgsqlCommand(update, con);
                Ucmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static ModePaiement getAjoutModePaiement(ModePaiement a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                a.Id = getCurrent();
                return(a);
            }
            catch
            {
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #13
0
        public static ModePaiement GetModePaiement(string mp, string mnt)
        {
            ModePaiement retour = ModePaiement.ChargeParNom(mp);

            if (retour.Id == 0)
            {
                // Création du mode de paiement car il n'existe pas
                retour.Libelle = mp;
                if (double.Parse(mnt, System.Globalization.CultureInfo.CurrentCulture) > 0)
                {
                    // Le montant est positif=> Crédit
                    retour.Type = "C";
                }
                else
                {
                    // le montant est négatif => Débit
                    retour.Type = "D";
                }
                ModePaiement.Sauve(retour);
                retour = ModePaiement.ChargeParNom(mp);
            }
            return(retour);
        }
Exemple #14
0
        private Operation ModifieOperation(Compte c)
        {
            Operation o = Operation.Charge(int.Parse(dgvOperations.SelectedRows[0].Cells[0].Value.ToString(), System.Globalization.CultureInfo.CurrentCulture));

            o.Compte       = c;
            o.Date         = txtOperationDate.Value;
            o.Categorie    = Categorie.Charge((int)txtOperationCategorie.SelectedValue);
            o.Libelle      = txtOperationLibelle.Text;
            o.Tiers        = txtOperationTiers.Text;
            o.ModePaiement = ModePaiement.Charge((int)txtOperationModePaiement.SelectedValue);
            o.Montant      = double.Parse(txtOperationMontant.Value.ToString(System.Globalization.CultureInfo.CurrentCulture), System.Globalization.CultureInfo.CurrentCulture);
            if (txtOperationPointage.Checked)
            {
                if (o.DatePointage is null)
                {
                    o.DatePointage = DateTime.Now;
                }
            }
            else
            {
                o.DatePointage = null;
            }
            return(Operation.Maj(o));
        }
 private void ChargeDgv()
 {
     dgvModePaiements.DataSource            = ModePaiement.ChargeToutDS();
     dgvModePaiements.DataMember            = "ModePaiements";
     dgvModePaiements.Columns["Id"].Visible = false;
 }
 public static string ModePaiementToString(ModePaiement mode)
 {
     var codepaiment = ModePaiementToCode(mode);
     return LanguageData.GetContent(codepaiment);
 }
Exemple #17
0
 private void LanceFiltreOperation()
 {
     if (txtFiltreModePaiement.SelectedValue != null)
     {
         DataSet ds = Operation
                      .ChargeGrilleOperationFiltre(GetCompteCourant(),
                                                   kFiltreDate.Checked, cbFiltreDate.SelectedItem.ToString(), txtFiltreDate.Value,
                                                   kFiltreModePaiement.Checked, ModePaiement.Charge((int)txtFiltreModePaiement.SelectedValue),
                                                   kFiltreTiers.Checked, txtFiltreTiers.Text,
                                                   kFiltreCategorie.Checked, Categorie.Charge((int)txtFiltreCategorie.SelectedValue),
                                                   kFiltreMontant.Checked, cbFiltreMontant.SelectedItem.ToString(), double.Parse(txtFiltreMontant.Value.ToString(System.Globalization.CultureInfo.CurrentCulture), System.Globalization.CultureInfo.CurrentCulture),
                                                   txtFiltrePointe.Checked);
         dgvOperations.DataSource = ds;
         dgvOperations.DataMember = "Operations";
         dgvOperations.Sort(dgvOperations.Columns["ordre"], System.ComponentModel.ListSortDirection.Descending);
     }
 }
Exemple #18
0
 public ModePaiementBll(ModePaiement unModePaiement)
 {
     mode = unModePaiement;
 }
Exemple #19
0
 private void RemplisModePaiements()
 {
     txtFiltreModePaiement.DataSource    = ModePaiement.ChargeTout();
     txtOperationModePaiement.DataSource = ModePaiement.ChargeTout();
 }