public void LigneCnssDelete(int no) { LigneCnss ligne = _ligneCnssRepository.Get(no); if (ligne == null) { throw new ApplicationException("Ligne cnss invalide!"); } var option = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(15) }; using (var scope = new TransactionScope(TransactionScopeOption.Required, option)) { _ligneCnssRepository.Delete(ligne); List <LigneCnss> lignes = _ligneCnssRepository.GetLignesByEmployees(ligne.EmployeeNo).ToList(); if (lignes.Count == 0) { Employee emplyee = _employeeRepository.Get(ligne.EmployeeNo); if (emplyee == null) { throw new ArgumentException("Emplayée invalide!"); } _employeeRepository.Delete(emplyee.Id); } scope.Complete(); } }
private LigneView ToLigneView(LigneCnss ligne) { return(new LigneView { No = ligne.Id, Cin = ligne.Cin, AutresNom = ligne.AutresNom, Brut1 = ligne.Brut1, Brut2 = ligne.Brut2, Brut3 = ligne.Brut3, Civilite = ligne.Civilite, CleCnss = ligne.CleCnss, Nom = ligne.Nom, NomJeuneFille = ligne.NomJeuneFille, NumeroCnss = ligne.NumeroCnss, Prenom = ligne.Prenom, CategorieNo = ligne.CategorieNo, CodeExploitation = ligne.CodeExploitation, DeclarationNo = ligne.DeclarationNo, EmployeeNo = ligne.EmployeeNo, NumeroInterne = ligne.NumeroInterne, Ligne = ligne.Ligne, Page = ligne.Page }); }
public void Delete(LigneCnss ligne) { using (var con = new SqlConnection(ConnectionString)) { con.Execute(QueryDelete, new { No = ligne.Id }); } }
public void Update(LigneCnss ligne) { using (var con = new SqlConnection(ConnectionString)) { con.Execute(QueryUpdate, ligne); } ; }
public void Create(LigneCnss ligne) { using (var con = new SqlConnection(ConnectionString)) { con.Query <int>(QueryInsert, ligne); } ; }
// modifier ligne declaration public void UpdateLigneDeclarationCnss( int ligneNo, string nom, string prenom, Civilite civilite, string numeroCnss, string cleCnss, string nomJeuneFille, string autreNom, string numeroInterne, int categorieNo, decimal brut1, decimal brut2, decimal brut3) { // tester si le l'exercice est cloturé if (Exercice.IsCloturer) { throw new InvalidOperationException("Exercice est cloturé"); } try { var option = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(15) }; using (var scope = new TransactionScope(TransactionScopeOption.Required, option)) { // charger la ligne declaration LigneCnss ligne = _ligneCnssRepository.Get(ligneNo); if (ligne == null) { throw new ArgumentNullException("ligne"); } ligne.Brut1 = brut1; ligne.Brut2 = brut2; ligne.Brut3 = brut3; ligne.CategorieNo = categorieNo; ligne.NumeroCnss = numeroCnss; ligne.CleCnss = cleCnss; ligne.AutresNom = autreNom; ligne.NomJeuneFille = nomJeuneFille; ligne.Nom = nom; ligne.Prenom = prenom; ligne.Civilite = civilite; // update ligne declaration _ligneCnssRepository.Update(ligne); // charger l'employee var employee = _employeeRepository.Get(ligne.EmployeeNo); if (employee == null) { throw new InvalidOperationException("Employée invalide!"); } // modifier les données du l'employée employee.Nom = nom; employee.Prenom = prenom; employee.NumeroCnss = numeroCnss; employee.NumeroInterne = numeroInterne; employee.Civilite = civilite; employee.CleCnss = cleCnss; employee.CategorieNo = categorieNo; employee.AutresNom = autreNom; employee.NomJeuneFille = nomJeuneFille; // update emplaye _employeeRepository.Update(employee); scope.Complete(); } } catch (Exception ex) { throw ex; } }
public void ImporterLignesCnss(int declarationNo, IEnumerable <LigneImport> lignes) { if (Exercice.IsCloturer) { throw new InvalidOperationException("Exercice est cloturé"); } try { // charger toutes les categories var categories = GetAllCategories().ToList(); if (categories.Count == 0) { throw new ApplicationException("Veuillez paramétrer les categories!"); } // charger declaration var declaration = DeclarationGet(declarationNo); if (declaration == null) { throw new ApplicationException("Déclaration invalide!"); } var option = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.MaxValue }; using (var scope = new TransactionScope(TransactionScopeOption.Required, option)) { foreach (var ligneImport in lignes.ToList()) { // charger categorie cnss var categorie = categories.FirstOrDefault(x => x.No == ligneImport.TypeCnss); if (categorie == null) { throw new InvalidOperationException("Catégorie invalide!"); } // charger l'employe var emp = _employeeRepository.Get(ligneImport.Cin, Societe.Id); var employeeNo = 0; if (emp != null) { // charger les lignes declarations cnss //var ligneExiste = _ligneCnssRepository.GetLignesByEmployees(emp.Id); var ligneIsExiste = _ligneCnssRepository.Existe(emp.Id, declarationNo, ligneImport.Matricule, categorie.Id); if (ligneIsExiste) { throw new ApplicationException(string.Format("Salarié [{0}] est déja déclaré!", ligneImport.Cin)); } emp.Civilite = ligneImport.Civilite; emp.Nom = ligneImport.Nom; emp.Prenom = ligneImport.Prenom; emp.SituationFamille = ligneImport.SituationFamille; emp.CleCnss = ligneImport.CleCnss; emp.NumeroCnss = ligneImport.NumeroCnss; emp.Cin = ligneImport.Cin; emp.NomJeuneFille = ligneImport.NomJeuneFille; emp.CategorieNo = categorie.Id; employeeNo = EmployeeUpdate(emp); } else { // modifier ou creer employe employeeNo = EmployeeCreate(ligneImport.Cin, ligneImport.Nom, ligneImport.Prenom, ligneImport.Civilite, ligneImport.SituationFamille, ligneImport.NumeroCnss, ligneImport.CleCnss, ligneImport.NomJeuneFille, ligneImport.AutresNom, ligneImport.Matricule, categorie); } if (employeeNo == 0) { throw new InvalidOperationException("Erreur d'importation!"); } if (categorie.CodeExploitation == null) { throw new InvalidOperationException("Erreur Code d'exploitation"); } var ligne = new LigneCnss { DeclarationNo = declarationNo, EmployeeNo = employeeNo, Civilite = ligneImport.Civilite, CategorieNo = categorie.Id, Nom = ligneImport.Nom, Brut3 = ligneImport.BrutC, Brut2 = ligneImport.BrutB, Brut1 = ligneImport.BrutA, CleCnss = ligneImport.CleCnss, CodeExploitation = categorie.CodeExploitation.PadLeft(4, '0'), AutresNom = ligneImport.AutresNom, Cin = ligneImport.Cin, Prenom = ligneImport.Prenom, NumeroCnss = ligneImport.NumeroCnss, NomJeuneFille = ligneImport.NomJeuneFille, SocieteNo = DeclarationService.Societe.Id, NumeroInterne = ligneImport.Matricule, }; _ligneCnssRepository.Create(ligne); } scope.Complete(); } } catch (Exception ex) { throw ex; } }
// creation de ligne de déclaration public void LigneDeclarationCreate(int declarationNo, string employeeCin, decimal brutA, decimal brutB, decimal brutC) { if (Exercice.IsCloturer) { throw new InvalidOperationException("Exercice est cloturé"); } //charger la declaration var declaration = _declarationCnssRepository.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é]."); } //charger l'employee Employee employee = _employeeRepository.Get(employeeCin, Societe.Id); if (employee == null) { throw new ApplicationException("Employee n'existe pas!"); } //charger categorie employee CategorieCnss categorie = _categorieRepository.GetCategorie(employee.CategorieNo); if (categorie == null) { throw new ApplicationException("Categorie employee invalide!"); } IEnumerable <LigneCnss> exist = _ligneCnssRepository.GetAll(declarationNo, employee.Id, employee.NumeroInterne); if (exist != null) { throw new ApplicationException("Ligne déclaration déja existe!"); } // vérifier les montants if (brutA < 0) { throw new InvalidOperationException(string.Format("Brut 1 invalid! Employee {0}", employee.Cin)); } if (brutB < 0) { throw new InvalidOperationException(string.Format("Brut 2 invalid! Employee {0}", employee.Cin)); } if (brutC < 0) { throw new InvalidOperationException(string.Format("Brut 3 invalid! Employee {0}", employee.Cin)); } if (brutA == 0 && brutB == 0 && brutC == 0) { throw new ApplicationException("Opération invalide! [Montant égale O]"); } var ligne = new LigneCnss { Ligne = 0, Page = 0, Brut1 = brutA, Brut2 = brutB, Brut3 = brutC, CategorieNo = categorie.Id, DeclarationNo = declarationNo, SocieteNo = Societe.Id, EmployeeNo = employee.Id, CleCnss = employee.CleCnss, Prenom = employee.Prenom, CodeExploitation = categorie.CodeExploitation, NumeroCnss = employee.NumeroCnss, Cin = employee.Cin, Nom = employee.Nom, NomJeuneFille = employee.NomJeuneFille, Civilite = employee.Civilite, NumeroInterne = employee.NumeroInterne, AutresNom = employee.AutresNom, }; _ligneCnssRepository.Create(ligne); }
public System.Data.DataSet GetDataSet(LigneCnss ligne, DeclarationCnss dec, Exercice ex, int tr) { if (ligne == null) { throw new ArgumentNullException(nameof(ligne)); } var dataSet = new DsAttestation(); // ajout de la ligne societe var tableSociete = dataSet.Societe; tableSociete.AddSocieteRow( _societe.Id, _societe.MatriculFiscal, _societe.MatriculCle, _societe.MatriculCategorie, int.Parse(_societe.MatriculEtablissement), _societe.RaisonSocial, _societe.Activite, _societe.Ville, _societe.Adresse, 0, int.Parse(_societe.CodePostal), _societe.MatriculCodeTva); // ajout de la ligne annexe un DateTime t1 = new DateTime(); DateTime t2 = new DateTime(); if (tr == 1) { t1 = new DateTime(Convert.ToInt32(ex.Annee), 01, 01); t2 = new DateTime(Convert.ToInt32(ex.Annee), 03, 31); } else if (tr == 2) { t1 = new DateTime(Convert.ToInt32(ex.Annee), 04, 01); t2 = new DateTime(Convert.ToInt32(ex.Annee), 06, 30); } else if (tr == 3) { t1 = new DateTime(Convert.ToInt32(ex.Annee), 07, 01); t2 = new DateTime(Convert.ToInt32(ex.Annee), 09, 30); } else if (tr == 4) { t1 = new DateTime(Convert.ToInt32(ex.Annee), 10, 01); t2 = new DateTime(Convert.ToInt32(ex.Annee), 12, 31); } var tableAnnexeUn = dataSet.LigneCNSS; tableAnnexeUn.AddLigneCNSSRow( ligne.Id, ligne.Nom, ligne.Brut1 + ligne.Brut2 + ligne.Brut3, ligne.Page.GetValueOrDefault(), ligne.Ligne.GetValueOrDefault(), ligne.Prenom, ligne.NumeroCnss, t1, t2, ex.Annee.ToString(), tr.ToString()); return(dataSet); }