public ActionResult addLot(Lot lot, int agent) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { Debug.WriteLine(lot); LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); LotService.Add(lot); LotService.Commit(); Affectation affectation = new Affectation { DateAffectation = DateTime.Now, LotId = lot.LotId, EmployeId = agent }; AffectationService.Add(affectation); AffectationService.Commit(); return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
public ActionResult Edit(EditEmployeDTO personne) { AffectationService nouvelleAffectation = new AffectationService(); Employe employeOrigine = new Employe(); //On prépare la nouvelle affectation if (personne.serviceIdPourAffectation != 0 && personne.groupeIdPourAffectation != 0) { nouvelleAffectation.isPrincipal = personne.isAffecttionPrincipal; nouvelleAffectation.service = _serviceService.Get(personne.serviceIdPourAffectation); nouvelleAffectation.groupe = _droitService.Get(personne.groupeIdPourAffectation); } if (personne.id != 0)//update { try { employeOrigine = _employeService.Get(personne.id); _insertOrUpdateAffectation(ref employeOrigine, nouvelleAffectation); _employeService.Update(employeOrigine, _donneNomPrenomUtilisateur()); _employeService.Save(); FlashMessage.Confirmation("Employé mis à jour avec succès"); } catch (Exception e) { FlashMessage.Danger("Erreur lors de mis à jour de l'employé"); } } else//create { try { employeOrigine = Mapper.Map <EditEmployeDTO, Employe>(personne); employeOrigine.utilisateur.password = _utilisateurService.Crypte(Parametres.defaultPassword); employeOrigine.affectationServices.Add(nouvelleAffectation); employeOrigine.utilisateur.login = employeOrigine.nom.ToUpper() + '.' + employeOrigine.prenom.ToUpper().First(); //On prépare le type d'employé employeOrigine.typeEmploye = _temployeService.Get(personne.typeEmploye.id); _employeService.Create(employeOrigine, _donneNomPrenomUtilisateur()); FlashMessage.Confirmation("Employé créé avec succès"); } catch (Exception e) { FlashMessage.Danger("Erreur lors de l'ajout de l'employé"); } } _employeService.Save(); return(RedirectToAction("Index", "Employe", new { area = "RessourcesHumaines" })); }
public ActionResult mensuelStatTraite(string year, string month) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); int mensuelPoste1Tot = 0; int mensuelPoste2Tot = 0; int mensuelPoste3Tot = 0; int mensuelPoste4Tot = 0; int tot = 0; double mensuelRentaPoste1Tot = 0; double mensuelRentaPoste2Tot = 0; double mensuelRentaPoste3Tot = 0; double mensuelRentaPoste4Tot = 0; double totRenta = 0; List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).ToList(); if (month != "" && year != "" && month != null && year != null) { mensuelPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); tot = mensuelPoste1Tot + mensuelPoste2Tot + mensuelPoste3Tot + mensuelPoste4Tot; mensuelRentaPoste1Tot = rentabiliteAgents(year, month, "POSTE1", LotService, FormulaireService, AffectationService); mensuelRentaPoste2Tot = rentabiliteAgents(year, month, "POSTE2", LotService, FormulaireService, AffectationService); mensuelRentaPoste3Tot = rentabiliteAgents(year, month, "POSTE3", LotService, FormulaireService, AffectationService); mensuelRentaPoste4Tot = rentabiliteAgents(year, month, "POSTE4", LotService, FormulaireService, AffectationService); totRenta = mensuelRentaPoste1Tot + mensuelRentaPoste2Tot + mensuelRentaPoste3Tot + mensuelRentaPoste4Tot; } return(Json(new { tot = tot, mensuelPoste1Tot = mensuelPoste1Tot, mensuelPoste2Tot = mensuelPoste2Tot, mensuelPoste3Tot = mensuelPoste3Tot, mensuelPoste4Tot = mensuelPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), mensuelRentaPoste1Tot = mensuelRentaPoste1Tot, mensuelRentaPoste2Tot = mensuelRentaPoste2Tot, mensuelRentaPoste3Tot = mensuelRentaPoste3Tot, mensuelRentaPoste4Tot = mensuelRentaPoste4Tot })); } } }
public ActionResult updateLot(ClientAffecteViewModel cavm) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); Lot newlot = LotService.GetById(cavm.Lot.LotId); newlot.Adresse = cavm.Lot.Adresse; newlot.Compte = cavm.Lot.Compte; newlot.DescIndustry = cavm.Lot.DescIndustry; newlot.Emploi = cavm.Lot.Emploi; newlot.IDClient = cavm.Lot.IDClient; newlot.NomClient = cavm.Lot.NomClient; newlot.NumLot = cavm.Lot.NumLot; newlot.PostCode = cavm.Lot.PostCode; newlot.SoldeDebiteur = cavm.Lot.SoldeDebiteur; newlot.TelFixe = cavm.Lot.TelFixe; newlot.TelPortable = cavm.Lot.TelPortable; newlot.Type = cavm.Lot.Type; newlot.Emploi = cavm.Lot.Emploi; LotService.Update(newlot); LotService.Commit(); Affectation affectation = AffectationService.GetById(cavm.Affectation.AffectationId); Debug.WriteLine(cavm.Affectation.EmployeId); if (affectation == null) { Affectation aff = new Affectation { EmployeId = cavm.Affectation.EmployeId, LotId = cavm.Lot.LotId, DateAffectation = DateTime.Now }; AffectationService.Add(aff); AffectationService.Commit(); } else { affectation.EmployeId = cavm.Affectation.EmployeId; affectation.LotId = cavm.Lot.LotId; affectation.DateAffectation = DateTime.Now; AffectationService.Update(affectation); AffectationService.Commit(); } return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
public void Create(AffectationService affectationService, string user = "") { _affectationServiceRepository.Insert(affectationService); _applicationTraceService.create(new ApplicationTrace { utilisateur = user, action = Parametres.Action.Creation.ToString(), description = String.Format("Ajout d'une nouvelle affectation au service {0} en tant que {1}", affectationService.service.libe, affectationService.groupe.libe), }); }
public void Update(AffectationService affectationService, string user = "") { _affectationServiceRepository.Update(affectationService); _applicationTraceService.create(new ApplicationTrace { utilisateur = user, action = Parametres.Action.Modification.ToString(), description = String.Format("Mise à jour de l'affectation affec_id = {0} au service {1} en tant que {2}", affectationService.id, affectationService.service.libe, affectationService.groupe.libe) }); }
/// <summary> /// Permet de mettre à jour les affectations d'un employé /// </summary> /// <param name="personne"></param> /// <param name="nouvelleAffectation"></param> private void _insertOrUpdateAffectation(ref Employe personne, AffectationService nouvelleAffectation) { if (nouvelleAffectation.service != null) { //On regarde si cet employé a déjà une affectation sur ce service if (personne.affectationServices.FirstOrDefault(x => x.service.id == nouvelleAffectation.service.id) != null)//On met à jour l'affectation { personne.affectationServices.First(x => x.service.libe == nouvelleAffectation.service.libe).isPrincipal = nouvelleAffectation.isPrincipal; personne.affectationServices.First(x => x.service.libe == nouvelleAffectation.service.libe).groupe = nouvelleAffectation.groupe; } else//On ajoute l'affectation { nouvelleAffectation.employe = personne; personne.affectationServices.Add(nouvelleAffectation); } } }
public DataTable GenerateDatatableFromJoinedList(List <ClientCompte> list) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); List <ClientCompte> newList = new List <ClientCompte>(); DataTable dataTable = new DataTable(); newList = list.Select(j => new ClientCompte { Nom = j.Nom, Compte = j.Compte }).ToList(); dataTable.Columns.Add("Nom", typeof(string)); dataTable.Columns.Add("Compte", typeof(string)); foreach (ClientCompte c in newList) { DataRow row = dataTable.NewRow(); row["Nom"] = c.Nom; row["Compte"] = c.Compte; dataTable.Rows.Add(row); } Debug.WriteLine("---->" + dataTable.Rows.Count); return(dataTable); } } }
public ActionResult updateLot(int id) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); ViewData["list"] = new SelectList(NumLotListForDropDown(), "Value", "Text"); ViewData["agent"] = new SelectList(AgentListForDropDown(), "Value", "Text"); //Lot lot = LotService.GetById(id); ClientAffecteViewModel cavm = new ClientAffecteViewModel(); cavm = (from a in AffectationService.GetAll() join l in LotService.GetAll() on a.LotId equals l.LotId where l.LotId == id select new ClientAffecteViewModel { Affectation = a, Lot = l }).FirstOrDefault(); if (cavm == null) { cavm = new ClientAffecteViewModel(); Lot lot = LotService.GetById(id); cavm.Lot = lot; } return(View(cavm)); } } }
public ActionResult DetailAjoutAffectation(NouvelleAffectationDTO nouvelleAffectation) { CardAffectationServiceViewModel modelOut = new CardAffectationServiceViewModel(); AffectationService newAffectation = new AffectationService(); Employe emp = new Employe(); EmployeDTO emplo = new EmployeDTO(); try { emp = _employeService.Get(nouvelleAffectation.emplyeId); newAffectation.groupe = _droitService.Get(nouvelleAffectation.groupeIdPourAffectation); newAffectation.service = _serviceService.Get(nouvelleAffectation.serviceIdPourAffectation); newAffectation.isPrincipal = nouvelleAffectation.isAffecttionPrincipal; _insertOrUpdateAffectation(ref emp, newAffectation); _employeService.Update(emp, _donneNomPrenomUtilisateur()); _employeService.Save(); FlashMessage.Confirmation("Ajout de l'affectation avec succès"); #region tableau des affectations de l'employé //On récupère l'employé avecla dernière affectation emplo = Mapper.Map <Employe, EmployeDTO>(_employeService.Get(nouvelleAffectation.emplyeId)); //On prépare le tableau récapitulant les affectations de l'employé modelOut.tableauAffectations.avecActionCrud = false; modelOut.tableauAffectations.lesLignes.Add(new List <object> { "Service", "Droit", "Activité principale", "" }); if (emplo.affectationServices != null) { foreach (AffectationServiceDTO affectation in emplo.affectationServices) { modelOut.tableauAffectations.lesLignes.Add(new List <object> { affectation.service.libe, affectation.groupe.libe, affectation.affectationPrincipaleOuiNon(), affectation.id }); } } #endregion modelOut.nouvelleAffectation.emplyeId = nouvelleAffectation.emplyeId; modelOut.lesDroits = _donneListeGroupeUtilisateur(); modelOut.lesServices = _donneListeService(); //On met à jour l'utilisateur en session, car lesa ffectations influes sur les éléments du menu de navigation _updateSession(); } catch (Exception e) { emplo = Mapper.Map <Employe, EmployeDTO>(_employeService.Get(nouvelleAffectation.emplyeId)); #region tableau des affectations de l'employé //On prépare le tableau récapitulant les affectations de l'employé modelOut.tableauAffectations.avecActionCrud = false; modelOut.tableauAffectations.lesLignes.Add(new List <object> { "Service", "Droit", "Activité principale", "" }); if (emplo.affectationServices != null) { foreach (AffectationServiceDTO affectation in emplo.affectationServices) { modelOut.tableauAffectations.lesLignes.Add(new List <object> { affectation.service.libe, affectation.groupe.libe, affectation.affectationPrincipaleOuiNon(), "" }); } } #endregion modelOut.nouvelleAffectation.emplyeId = nouvelleAffectation.emplyeId; modelOut.lesDroits = _donneListeGroupeUtilisateur(); modelOut.lesServices = _donneListeService(); FlashMessage.Danger("Erreur lors de la création de l'affectation"); } return(PartialView("~/Areas/RessourcesHumaines/Views/Employe/_CardAffectationPartial.cshtml", modelOut)); }
public ActionResult quotidienStatTraite(string date) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); DateTime d = new DateTime(); int quotidienPoste1Tot = 0; int quotidienPoste2Tot = 0; int quotidienPoste3Tot = 0; int quotidienPoste4Tot = 0; int tot = 0; double quotidienRentaPoste1Tot = 0; double quotidienRentaPoste2Tot = 0; double quotidienRentaPoste3Tot = 0; double quotidienRentaPoste4Tot = 0; double totRenta = 0; List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).ToList(); if (date != "" && date != null) { if (DateTime.TryParse(date, out d)) { quotidienPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date == d.Date).Count(); quotidienPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date == d.Date).Count(); quotidienPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date == d.Date).Count(); quotidienPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date == d.Date).Count(); tot = quotidienPoste1Tot + quotidienPoste2Tot + quotidienPoste3Tot + quotidienPoste4Tot; quotidienRentaPoste1Tot = rentabiliteAgents(d, "POSTE1", LotService, FormulaireService, AffectationService); quotidienRentaPoste2Tot = rentabiliteAgents(d, "POSTE2", LotService, FormulaireService, AffectationService); quotidienRentaPoste3Tot = rentabiliteAgents(d, "POSTE3", LotService, FormulaireService, AffectationService); quotidienRentaPoste4Tot = rentabiliteAgents(d, "POSTE4", LotService, FormulaireService, AffectationService); totRenta = quotidienRentaPoste1Tot + quotidienRentaPoste2Tot + quotidienRentaPoste3Tot + quotidienRentaPoste4Tot; } } return(Json(new { tot = tot, quotidienPoste1Tot = quotidienPoste1Tot, quotidienPoste2Tot = quotidienPoste2Tot, quotidienPoste3Tot = quotidienPoste3Tot, quotidienPoste4Tot = quotidienPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), quotidienRentaPoste1Tot = quotidienRentaPoste1Tot, quotidienRentaPoste2Tot = quotidienRentaPoste2Tot, quotidienRentaPoste3Tot = quotidienRentaPoste3Tot, quotidienRentaPoste4Tot = quotidienRentaPoste4Tot })); } } }
public double rentabiliteAgents(DateTime date, string agent, LotService LotService, FormulaireService FormulaireService, AffectationService AffectationService) { List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> TempJoinedList = new List <ClientAffecteViewModel>(); double trancheTot = 0; double soldeTot = 0; double res = 0; JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where f.Status == Domain.Entities.Status.VERIFIE select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).Where(j => j.Affectation.Employe.Username == agent && j.Formulaire.TraiteLe.Date == date).ToList(); foreach (ClientAffecteViewModel cvm in JoinedList) { if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE) { trancheTot += (cvm.Formulaire.MontantVerseDeclare); } if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE) { TempJoinedList = getTraitHist(cvm.Affectation.AffectationId, FormulaireService, AffectationService, LotService); if (TempJoinedList.Count() == 0) { soldeTot += (cvm.Formulaire.MontantDebInitial); } else { soldeTot += (TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ); } } } res = soldeTot + trancheTot; return(res); }
public ActionResult extraireFacture(string numLot, string factureNum, string pourcentage, string debutDate, string finDate) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { FormulaireService FormulaireService = new FormulaireService(UOW); LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); FactureService factureService = new FactureService(UOW); ViewData["list"] = new SelectList(NumLotListForDropDown(LotService), "Value", "Text"); DateTime startDate = DateTime.Parse(debutDate); DateTime endDate = DateTime.Parse(finDate); double trancheTot = 0; double soldeTot = 0; double tot = 0; float revenuParOp = float.Parse(pourcentage.Replace(".", ",")); List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> TempJoinedList = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> AnnexeJoinedList = new List <ClientAffecteViewModel>(); if (numLot == "0") { JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where f.Status == Domain.Entities.Status.VERIFIE select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).Where(j => j.Formulaire.TraiteLe.Date >= startDate.Date && j.Formulaire.TraiteLe.Date <= endDate.Date).ToList(); } else { JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where f.Status == Domain.Entities.Status.VERIFIE && l.NumLot.Equals(numLot) select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).Where(j => j.Formulaire.TraiteLe.Date >= startDate.Date && j.Formulaire.TraiteLe.Date <= endDate.Date).ToList(); } foreach (ClientAffecteViewModel cvm in JoinedList) { if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE) { trancheTot += (cvm.Formulaire.MontantVerseDeclare * revenuParOp) / 100; cvm.vers = cvm.Formulaire.MontantVerseDeclare; cvm.recouvre = cvm.Formulaire.MontantVerseDeclare; AnnexeJoinedList.Add(cvm); } if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE) { TempJoinedList = getTraitHist(cvm.Affectation.AffectationId, FormulaireService, AffectationService, LotService); if (TempJoinedList.Count() == 0) { soldeTot += (cvm.Formulaire.MontantDebInitial * revenuParOp) / 100; cvm.recouvre = cvm.Formulaire.MontantDebInitial; cvm.vers = cvm.Formulaire.MontantVerseDeclare; AnnexeJoinedList.Add(cvm); } else { soldeTot += (TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ *revenuParOp) / 100; cvm.vers = cvm.Formulaire.MontantVerseDeclare; cvm.recouvre = TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ; AnnexeJoinedList.Add(cvm); } } } string lotsNames = ""; List <string> listNameLot = JoinedList.DistinctBy(j => j.Lot.NumLot).Select(l => l.Lot.NumLot).ToList(); if (listNameLot.Count() == 1) { lotsNames = listNameLot.FirstOrDefault(); } else if (listNameLot.Count() > 1) { string lastlots = JoinedList.DistinctBy(j => j.Lot.NumLot).Select(l => l.Lot.NumLot).LastOrDefault(); listNameLot.RemoveAt(listNameLot.Count - 1); string lots = String.Join(", ", listNameLot); lotsNames = lots + " et " + lastlots; } tot = soldeTot + trancheTot; FactureContent factureContent = new FactureContent(); factureContent.FacNum = factureNum; factureContent.Date = DateTime.Today; factureContent.Beneficiere = "Zitouna Bank"; factureContent.PrixHT = tot; factureContent.PrixTVA = (tot * 19) / 100; factureContent.TimbreFiscal = 0.600; factureContent.PrixTTC = tot + factureContent.PrixTVA; string annexeFileName = "Annexe_" + DateTime.Now.ToString("dd.MM.yyyy") + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + ".xlsx"; string factureFileName = "Facture_" + DateTime.Now.ToString("dd.MM.yyyy") + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + ".pdf"; string pathAnnexe = GetFolderName() + "/" + annexeFileName; string pathFacture = GetFolderName() + "/" + factureFileName; Facture facture = new Facture() { AnnexePathName = annexeFileName, FacturePathName = factureFileName, DateDeb = startDate, DateFin = endDate, DateExtrait = DateTime.Now }; factureService.Add(facture); factureService.Commit(); GenerateExcel(GenerateDatatableFromJoinedList(AnnexeJoinedList), pathAnnexe, String.Format("{0:0.000}", AnnexeJoinedList.Sum(j => j.recouvre))); GeneratePDF(pathFacture, lotsNames, factureContent); return(RedirectToAction("genererFacture", new { page = 1 })); } } }
public ActionResult StatLot(int numLot, string typeStat, string dateStat, string agent) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); ViewData["list"] = new SelectList(NumLotListForDropDown(), "Value", "Text"); ViewData["sortOrder"] = new SelectList(TypeStatForDropDown(), "Value", "Text"); ViewBag.AgentList = new SelectList(AgentListForDropDown(), "Value", "Text"); int nb = 0; int rdv = 0; int fn = 0; int versement = 0; int encours = 0; string avgRdv = 0 + ""; string avgVers = 0 + ""; string avgFn = 0 + ""; string avgencours = 0 + ""; ViewData["years"] = new SelectList(YearListForDropDown(), "Value", "Text"); ViewData["month"] = new SelectList(MonthListForDropDown(), "Value", "Text"); List <Affectation> affectations = new List <Affectation>(); List <Lot> lots = new List <Lot>(); List <ClientAffecteViewModel> rdvCAVm = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> fnCAVm = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> versCAVm = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> encoursCAVm = new List <ClientAffecteViewModel>(); List <ClientAffecteViewModel> tot = new List <ClientAffecteViewModel>(); if (numLot == 0) { tot = (from a in AffectationService.GetAll() join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Affectation = a, Lot = l, }).ToList(); rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList(); fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList(); versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList(); encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList(); } else { tot = (from a in AffectationService.GetAll() join l in LotService.GetAll() on a.LotId equals l.LotId where l.NumLot == numLot.ToString() select new ClientAffecteViewModel { Affectation = a, Lot = l, }).ToList(); rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where l.NumLot == numLot + "" select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList(); fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where l.NumLot == numLot + "" select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList(); versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where l.NumLot == numLot + "" select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList(); encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe) join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where l.NumLot == numLot + "" select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList(); } if (typeStat == "1") { nb = tot.Count(); rdv = rdvCAVm.Count(); fn = fnCAVm.Count(); versement = versCAVm.Count(); encours = encoursCAVm.Count(); avgRdv = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100); avgFn = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100); avgVers = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100); avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100); } else if (typeStat == "2") { rdv = rdvCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); fn = fnCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); versement = versCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); encours = encoursCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); nb = rdv + fn + versement + encours; avgRdv = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100); avgFn = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100); avgVers = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100); avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100); } else if (typeStat == "3") { rdv = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count(); fn = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count(); versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count(); encours = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count(); nb = rdv + fn + versement + encours; avgRdv = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100); avgFn = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100); avgVers = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100); avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100); } else if (typeStat == "4") { rdv = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); fn = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); encours = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count(); nb = rdv + fn + versement + encours; avgRdv = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100); avgFn = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100); avgVers = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100); avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100); } StatLot statLot = new StatLot() { nb = nb, rdv = rdv, fn = fn, versement = versement, encours = encours, avgRdv = avgRdv.Replace(",", "."), avgFn = avgFn.Replace(",", "."), avgVers = avgVers.Replace(",", "."), avgencours = avgencours.Replace(",", ".") }; return(View("Index", statLot)); } } }
public ActionResult ExtraireLettreAction(string numLot, string debutDate, string finDate, string agent) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); LotService LotService = new LotService(UOW); LettreService lettreService = new LettreService(UOW); EmployeService EmployeService = new EmployeService(UOW); ViewData["list"] = new SelectList(NumLotListForDropDown(LotService), "Value", "Text"); ViewBag.AgentList = new SelectList(AgentListForDropDown(EmployeService), "Value", "Text"); string lettreDir = GetFolderNameForLettre(); DateTime startDate = DateTime.Parse(debutDate); DateTime endDate = DateTime.Parse(finDate); if (!Directory.Exists(lettreDir)) { Directory.CreateDirectory(lettreDir); } string lettreDirList = Directory.GetDirectories(lettreDir).Length + 1 + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + ""; string dirLettre = ""; if (!Directory.Exists(lettreDir + "/" + lettreDirList)) { Directory.CreateDirectory(lettreDir + "/" + lettreDirList); dirLettre = lettreDir + "/" + lettreDirList; } List <LettreContent> lettreJoinedList = new List <LettreContent>(); if (numLot == "0") { lettreJoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) select new LettreContent { NumLot = l.NumLot, Adresse = l.Adresse, NomClient = l.NomClient, Agence = l.DescIndustry, Compte = l.Compte }).ToList(); if (int.Parse(agent) != 0) { lettreJoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && a.EmployeId == int.Parse(agent) select new LettreContent { NumLot = l.NumLot, Adresse = l.Adresse, NomClient = l.NomClient, Agence = l.DescIndustry, Compte = l.Compte }).ToList(); } else { lettreJoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) select new LettreContent { NumLot = l.NumLot, Adresse = l.Adresse, NomClient = l.NomClient, Agence = l.DescIndustry, Compte = l.Compte }).ToList(); } } else { if (int.Parse(agent) != 0) { lettreJoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot)) && a.EmployeId == int.Parse(agent) select new LettreContent { NumLot = l.NumLot, Adresse = l.Adresse, NomClient = l.NomClient, Agence = l.DescIndustry, Compte = l.Compte, IdAgent = a.EmployeId + "" }).ToList(); } else { lettreJoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot)) select new LettreContent { NumLot = l.NumLot, Adresse = l.Adresse, NomClient = l.NomClient, Agence = l.DescIndustry, Compte = l.Compte, IdAgent = a.EmployeId + "" }).ToList(); } } int x = 0; ViewBag.total = lettreJoinedList.Count(); foreach (LettreContent lc in lettreJoinedList) { string path = dirLettre + "/" + x + "_" + "lettre" + "_" + lc.Compte + ".docx"; if (Directory.Exists(dirLettre)) { GenerateWordForLettre(path, lc); } ViewData["currClient"] = x; x++; } string zipPath = zipFolderResult(dirLettre); string adressExcelPath = Server.MapPath("~/Uploads/Lettre/0_Result/") + DateTime.Now.ToString("dd.MM.yyyy") + "_" + Path.GetFileName(dirLettre) + ".xlsx"; GenerateExcelForLettre(GenerateDatatableFromJoinedListForLettre(lettreJoinedList), adressExcelPath); Lettre lettre = new Lettre { DateDeb = startDate.Date, DateFin = endDate.Date, DateExtrait = DateTime.Now, LettrePathName = zipPath, LettreAdressPathName = Path.GetFileName(adressExcelPath) }; lettreService.Add(lettre); lettreService.Commit(); return(RedirectToAction("Renseigner", new { page = 1 })); } } }
public List <ClientAffecteViewModel> getTraitHist(int idAff, FormulaireService FormulaireService, AffectationService AffectationService, LotService LotService) { List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId where f.Status == Domain.Entities.Status.VERIFIE && f.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE && f.AffectationId == idAff select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).OrderByDescending(f => f.Formulaire.TraiteLe).ToList(); return(JoinedList); }
public ActionResult Index() { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { EmployeService EmpService = new EmployeService(UOW); RoleService RoleService = new RoleService(UOW); AffectationService AffectationService = new AffectationService(UOW); LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); List <ClientAffecteViewModel> traiteList = new List <ClientAffecteViewModel>(); List <HomeViewModel> result = new List <HomeViewModel>(); List <Lot> lots = new List <Lot>(); string[] lotsLst = { }; lots = LotService.GetAll().ToList(); lotsLst = lots.DistinctBy(l => l.NumLot).Select(l => l.NumLot).ToArray(); List <Affectation> Affectations = new List <Affectation>(); List <Formulaire> Formulaires = new List <Formulaire>(); string[] agents = { }; Affectations = AffectationService.GetAll().ToList(); Formulaires = FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe).ToList(); foreach (string numlot in lotsLst) { lots = LotService.GetAll().Where(l => l.NumLot.Equals(numlot)).ToList(); traiteList = (from f in Formulaires join a in Affectations on f.AffectationId equals a.AffectationId join l in lots on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).DistinctBy(d => d.Formulaire.AffectationId).ToList(); var agentLinq = (from a in Affectations join l in lots on a.LotId equals l.LotId select new ClientAffecteViewModel { Affectation = a }); agents = agentLinq.DistinctBy(a => a.Affectation.Employe.Username).Select(a => a.Affectation.Employe.Username).ToArray(); string agentsStr = string.Join(", ", agents); float nbAffTotal = agentLinq.Count(); float nbTraite = traiteList.Count(); string avgLot = String.Format("{0:0.00}", (nbTraite / nbAffTotal) * 100); HomeViewModel homeViewModel = new HomeViewModel { agents = agentsStr, nbAffTotal = nbAffTotal + "", nbTraite = nbTraite + "", numLot = numlot, avancement = avgLot.Replace(",", ".") }; result.Add(homeViewModel); } return(View(result)); } } }