Example #1
0
 public void Update(LigneFc ligne)
 {
     using (var con = new SqlConnection(ConnectionString))
     {
         con.Execute(QueryUpdate, ligne);
     }
 }
Example #2
0
 private LigneView ToLigneView(LigneFc l)
 {
     return(new LigneView
     {
         Id = l.Id,
         MontantDroitConsommation = l.MontantDroitConsommation,
         MontantFodec = l.MontantFodec,
         MontantTva = l.MontantTva,
         SocieteNo = l.SocieteNo,
         PrixVenteHt = l.PrixVenteHt,
         TauxDroitConsommation = l.TauxDroitConsommation,
         TauxFodec = l.TauxFodec,
         TauxTva = l.TauxTva,
         AdresseClient = l.AdresseClient,
         DateAutorisation = l.DateAutorisation,
         DateFacture = l.DateFacture,
         IdentifiantClient = l.IdentifiantClient,
         NomPrenomClient = l.NomPrenomClient,
         NumeroAutorisation = l.NumeroAutorisation,
         NumeroFacture = l.NumeroFacture,
         TypeClient = l.TypeClient,
         DeclarationNo = l.DeclarationNo,
         NumeroOrdre = l.NumeroOrdre
     });
 }
Example #3
0
        public int Create(LigneFc ligne)
        {
            using (var con = new SqlConnection(ConnectionString))
            {
                var result = con.Query <int>(QueryInsert, ligne)
                             .SingleOrDefault();

                return(result);
            }
        }
        public void ImporterLignes(int declarationNo,
                                   IEnumerable <LigneFc> lignes)
        {
            if (Exercice.IsCloturer)
            {
                throw new InvalidOperationException("Exercice est cloturé");
            }

            //charger la declaration
            var declaration = _declarationRepository.GetDeclaration(declarationNo);

            if (declaration == null)
            {
                throw new ApplicationException("Déclaration invalide!");
            }


            // tester si la daclaration est clôturer
            if (declaration.IsCloture)
            {
                throw new InvalidOperationException("Opération invalide [Déclaration est clôturé].");
            }

            var option = new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadCommitted,
                Timeout        = TimeSpan.FromSeconds(15)
            };

            using (var scope = new TransactionScope(TransactionScopeOption.Required, option))
            {
                foreach (var l in lignes)
                {
                    if (string.IsNullOrEmpty(l.NumeroAutorisation))
                    {
                        throw new InvalidOperationException(string.Format("Numéro autorisation invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (string.IsNullOrEmpty(l.NumeroFacture))
                    {
                        throw new InvalidOperationException(
                                  string.Format("Numéro bon commande invalide! N°Autorisation [{0}]", l.NumeroAutorisation));
                    }

                    if (string.IsNullOrEmpty(l.NomPrenomClient))
                    {
                        throw new InvalidOperationException(string.Format("Identifiant client invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (string.IsNullOrEmpty(l.IdentifiantClient))
                    {
                        throw new InvalidOperationException(string.Format("Identifiant client invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.PrixVenteHt <= 0)
                    {
                        throw new InvalidOperationException(string.Format("Prix de vente HT invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.MontantDroitConsommation < 0)
                    {
                        throw new InvalidOperationException(
                                  string.Format("Montant droit de consommation invalide! [{0}]",
                                                l.NumeroFacture));
                    }

                    if (l.MontantTva < 0)
                    {
                        throw new InvalidOperationException(string.Format("Montant tva invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.MontantFodec < 0)
                    {
                        throw new InvalidOperationException(string.Format("Montant fodec invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.TauxFodec < 0)
                    {
                        throw new InvalidOperationException(string.Format("Taux fodec invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.TauxDroitConsommation < 0)
                    {
                        throw new InvalidOperationException(string.Format("Taux  droit de consommation invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    if (l.TauxTva < 0)
                    {
                        throw new InvalidOperationException(string.Format("Taux tva invalide! [{0}]",
                                                                          l.NumeroFacture));
                    }

                    var ligne = new LigneFc
                    {
                        MontantDroitConsommation = l.MontantDroitConsommation,
                        MontantFodec             = l.MontantFodec,
                        MontantTva            = l.MontantTva,
                        SocieteNo             = Societe.Id,
                        PrixVenteHt           = l.PrixVenteHt,
                        TauxDroitConsommation = l.TauxDroitConsommation,
                        TauxFodec             = l.TauxFodec,
                        TauxTva            = l.TauxTva,
                        AdresseClient      = l.AdresseClient,
                        DateAutorisation   = l.DateAutorisation,
                        DateFacture        = l.DateFacture,
                        IdentifiantClient  = l.IdentifiantClient,
                        NomPrenomClient    = l.NomPrenomClient,
                        NumeroAutorisation = l.NumeroAutorisation,
                        NumeroFacture      = l.NumeroFacture,
                        TypeClient         = l.TypeClient,
                        DeclarationNo      = declaration.Id,
                        NumeroOrdre        = l.NumeroOrdre
                    };
                    _ligneFcRepository.Create(ligne);
                }
                scope.Complete();
            }
        }
        public int LigneCreate(
            int declarationNo,
            int numeroOrdre,
            string numeroFacture,
            DateTime dateFacture,
            TypeClient typeClient,
            string identifiantClient,
            string nomPrenomClient,
            string adresseClient,
            string numeroAutorisation,
            DateTime dateAutorisation,
            decimal prixVenteHt,
            decimal tauxFodec,
            decimal montantFodec,
            decimal tauxDroitConsommation,
            decimal montantDroitConsommation,
            decimal tauxTva,
            decimal montantTva
            )
        {
            if (Exercice.IsCloturer)
            {
                throw new InvalidOperationException("Exercice est cloturé");
            }

            //charger la declaration
            var declaration = _declarationRepository.GetDeclaration(declarationNo);

            if (declaration == null)
            {
                throw new ApplicationException("Déclaration invalide!");
            }


            // tester si la daclaration est clôturer
            if (declaration.IsCloture)
            {
                throw new InvalidOperationException("Opération invalide [Déclaration est clôturé].");
            }

            var option = new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadCommitted,
                Timeout        = TimeSpan.FromSeconds(15)
            };

            using (var scope = new TransactionScope(TransactionScopeOption.Required, option))
            {
                if (string.IsNullOrEmpty(numeroAutorisation))
                {
                    throw new InvalidOperationException(string.Format("Numéro autorisation invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (string.IsNullOrEmpty(numeroFacture))
                {
                    throw new InvalidOperationException(
                              string.Format("Numéro facture invalide! N°Autorisation [{0}]", numeroAutorisation));
                }

                if (string.IsNullOrEmpty(nomPrenomClient))
                {
                    throw new InvalidOperationException(string.Format("Identifiant client invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (string.IsNullOrEmpty(identifiantClient))
                {
                    throw new InvalidOperationException(string.Format("Identifiant client invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (prixVenteHt <= 0)
                {
                    throw new InvalidOperationException(string.Format("Prix de vente HT invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (montantDroitConsommation < 0)
                {
                    throw new InvalidOperationException(string.Format("Montant droit de consommation invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (montantTva < 0)
                {
                    throw new InvalidOperationException(string.Format("Montant tva invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (montantFodec < 0)
                {
                    throw new InvalidOperationException(string.Format("Montant fodec invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (tauxFodec < 0)
                {
                    throw new InvalidOperationException(string.Format("Taux fodec invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (tauxDroitConsommation < 0)
                {
                    throw new InvalidOperationException(string.Format("Taux  droit de consommation invalide! [{0}]",
                                                                      numeroFacture));
                }

                if (tauxTva < 0)
                {
                    throw new InvalidOperationException(string.Format("Taux tva invalide! [{0}]",
                                                                      numeroFacture));
                }

                var ligne = new LigneFc
                {
                    MontantDroitConsommation = montantDroitConsommation,
                    MontantFodec             = montantFodec,
                    MontantTva            = montantTva,
                    SocieteNo             = Societe.Id,
                    PrixVenteHt           = prixVenteHt,
                    TauxDroitConsommation = tauxDroitConsommation,
                    TauxFodec             = tauxFodec,
                    TauxTva            = tauxTva,
                    AdresseClient      = adresseClient,
                    DateAutorisation   = dateAutorisation,
                    DateFacture        = dateFacture,
                    IdentifiantClient  = identifiantClient,
                    NomPrenomClient    = nomPrenomClient,
                    NumeroAutorisation = numeroAutorisation,
                    NumeroFacture      = numeroFacture,
                    TypeClient         = typeClient,
                    DeclarationNo      = declaration.Id,
                    NumeroOrdre        = numeroOrdre
                };
                // create ligne facture en suspension
                var no = _ligneFcRepository.Create(ligne);
                if (no <= 0)
                {
                    throw new ApplicationException("Ajout du ligne facture en suspension invalide!");
                }

                scope.Complete();
                // valeur de retour
                return(no);
            }
        }