private DeclarationView ToView(DeclarationCnss declaration) { return(new DeclarationView { Complementaire = declaration.Complementaire, Date = declaration.Date, IsArchive = declaration.IsArchive, IsCloture = declaration.IsCloture, Trimestre = declaration.Trimestre, ExerciceId = declaration.ExerciceId, Id = declaration.Id, }); }
public static void CreateLignes(IEnumerable <LigneImportView> lignesImport, DeclarationService service, DeclarationCnss declaration) { List <CategorieCnss> categories = service.CnssService.GetAllCategories().ToList(); var _employee = new List <Employee>(); foreach (LigneImportView ligne in lignesImport) { if (_employee.Any(x => x.Cin == ligne.Cin)) { throw new ApplicationException(string.Format("Employee {0} est déclaré deux ou plusieurs fois!")); } var categorie = categories.Single(x => x.No == ligne.TypeCnss); var emp = new Employee { AutresNom = ligne.AutresNom, CleCnss = ligne.CleCnss, SituationFamille = (SituationFamille)ligne.SituationFamilleNo, Prenom = ligne.Prenom, Cin = ligne.Cin, Nom = ligne.Nom, Civilite = (Civilite)ligne.CiviliteNo, NumeroInterne = ligne.Matricule, NumeroCnss = ligne.NumeroCnss, NomJeuneFille = ligne.NomJeuneFille, CategorieNo = categorie.No, }; _employee.Add(emp); } foreach (var employee in _employee) { service.CnssService.EmployeeCreateOrUpdate(employee.Cin, employee.Nom, employee.Prenom, employee.Civilite, employee.SituationFamille, employee.NumeroCnss, employee.CleCnss, employee.NomJeuneFille, employee.AutresNom, employee.NumeroInterne, categories.Single(x => x.No == employee.CategorieNo)); } foreach (var l in lignesImport) { service.CnssService.LigneDeclarationCreate(declaration.Id, l.Cin, l.BrutA, l.BrutB, l.BrutC); } }
public LigneCnss Get(DeclarationCnss declaration, Employee employe) { const string query = @" WHERE [DeclarationNo] = @declarationNo AND [EmployeeNo] = @EmployeeNo"; string queryGet = string.Concat(QueryGet, query); using (var con = new SqlConnection(ConnectionString)) { var result = con.Query <LigneCnss>(queryGet, new { DeclarationNo = declaration.Id, EmployeeNo = employe.Id }); return(result.FirstOrDefault()); } }
public int Create(DeclarationCnss declaration) { using (var con = new SqlConnection(ConnectionString)) { return(con.Query <int>(QueryInsert, new { declaration.Date, declaration.ExerciceId, declaration.IsCloture, declaration.IsArchive, declaration.SocieteId, declaration.Trimestre, declaration.Complementaire }).SingleOrDefault()); } }
public int DeclarationCreate(int trimestre, bool isComplement) { // check current societe if (DeclarationService.Societe == null) { throw new InvalidOperationException("Societe courante invalide!"); } //check current exercice if (DeclarationService.Exercice == null) { throw new InvalidOperationException("Exercice courant invalid!"); } if (DeclarationService.Exercice.IsCloturer) { throw new InvalidOperationException("Exercice est cloturé"); } // check trimestre if (trimestre < 1 || trimestre > 4) { throw new ApplicationException("Trimestre invalide!"); } if (!isComplement) { var exist = _declarationCnssRepository.GetDeclaration(trimestre, DeclarationService.Exercice.Id, DeclarationService.Societe.Id); if (exist != null) { throw new ApplicationException("Opération invalide! [déclaration existe déja]"); } } var declaration = new DeclarationCnss { Complementaire = isComplement, Trimestre = trimestre, IsCloture = false, ExerciceId = DeclarationService.Exercice.Id, Date = DateTime.Now, IsArchive = false, SocieteId = DeclarationService.Societe.Id }; return(_declarationCnssRepository.Create(declaration)); }
public DeclarationDs(DeclarationService service, DeclarationCnss declaration) : this() { if (service == null) { throw new ArgumentNullException("service"); } if (declaration == null) { throw new InvalidOperationException("declaration"); } Societe societe = service.Societe; if (societe == null) { throw new InvalidOperationException("Erreur chargement societe"); } List <CategorieCnss> categories = service.CnssService.GetAllCategories().ToList(); foreach (CategorieCnss categorieCnss in categories) { tableTCategorie.AddTCategorieRow(categorieCnss.Id, categorieCnss.Intitule, categorieCnss.CodeExploitation, categorieCnss.TauxPatronal, categorieCnss.TauxSalarial, categorieCnss.AccidentTravail); } var exercice = service.ExerciceGetAll().FirstOrDefault(x => x.Id == declaration.ExerciceId); if (exercice == null) { throw new ArgumentNullException("exercice"); } var lignes = service.CnssService.GetLigneDeclarationCnss(declaration.Id); tableTSociete.AddTSocieteRow(societe.RaisonSocial, societe.Activite, societe.Adresse, societe.CodePostal, societe.Ville, societe.Pays, societe.NumeroEmployeur.PadLeft(8, '0'), $"{societe.MatriculFiscal} {societe.MatriculCle}/{societe.MatriculCodeTva}/{societe.MatriculCategorie}/{societe.MatriculEtablissement}", societe.CodeBureau, exercice.Annee, declaration.Trimestre, societe.CleEmployeur.PadLeft(2, '0'), societe.MatriculCle, societe.MatriculCategorie, societe.MatriculEtablissement, societe.MatriculCodeTva); foreach (LigneCnss ligne in lignes) { CategorieCnss cat = categories.Single(x => x.Id == ligne.CategorieNo); if (cat == null) { throw new InvalidOperationException("Catégorie"); } tableTDeclaration.AddTDeclarationRow(ligne.Id, ligne.Page.Value, ligne.Ligne.Value, ligne.Brut1, ligne.Brut2, ligne.Brut3, cat.Intitule, ligne.CodeExploitation, ligne.NumeroCnss, ligne.CleCnss, ligne.Cin, ligne.Nom, ligne.Prenom, ligne.Civilite.ToString(), ligne.AutresNom, ligne.NomJeuneFille, ligne.NumeroInterne, cat.Id); } }
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); }