public ActionResult ImprimerReleverSituationMasse(AgregCritereReleveSituationViewModel critere)
        {
            int releveType = 1;            
            Guid idClient = Guid.Empty;
            if (Request.Form["releveType"] != null)
            {
                releveType = int.Parse(Request.Form["releveType"]);
            }            
            if (Request.Form["idClient"] != null)
            {
                idClient = Guid.Parse(Request.Form["idClient"]);
            }

            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Recueil");
            var iserror = true;
            var errormsg = string.Empty;
            try
            {
                Guid idCgpAgreg = Guid.Empty;
                User currentUser = SessionManager.GetUserSession();
                if (currentUser.IsEndUser())
                {
                    CustomerProspect currentCustomer = SessionManager.GetCustomerProspectSession();
                    User currenttUserCreated = currentCustomer.User1;
                    idCgpAgreg = currenttUserCreated.idAgregCGP.Value;
                }
                else
                {
                    idCgpAgreg = currentUser.idAgregCGP.Value;
                }
                //
                Guid idFirm = Guid.Empty;
                SessionManager.Get<Guid>(UserBL.AgregCurrentUserFirmId, out idFirm);
                FirmInstitution firm = null;
                if (idFirm == Guid.Empty)
                {
                    if (currentUser != null && currentUser.idAgregCGP.HasValue)
                    {
                        var cgp = AgregCgpBL.GetCgpById(idCgpAgreg);
                        firm = FirmInstitutionBL.GetFirmInstitutionByIdAgregCabinet(cgp.idcrmcabinet);
                        if (firm != null)
                        {
                            SessionManager.Set<Guid>(UserBL.AgregCurrentUserFirmId, firm.idFirmInstitution);
                            idFirm = firm.idFirmInstitution;
                        }
                    }
                }
                AgregReleverSituationBL.GenererReleveSituation(idCgpAgreg.ToString(), idClient.ToString(), string.Empty, true, releveType, string.Empty,idFirm);
            }
            catch (Exception ex)
            {
                errormsg = ex.Message;
                iserror = false;
                Upsilab.Business.Log.Log.AppendException(ex);
            }
            return Content("ok");
        }
        public ActionResult ImprimerReleverSituation(AgregCritereReleveSituationViewModel critere)
        {
            int releveType = 1;            
            string listCompte = "";
            Guid idClient = Guid.Empty;
            DateTime dateReleve = DateTime.Now;
            if (Request.Form["releveType"] != null)
            {
                releveType = int.Parse(Request.Form["releveType"]);
            }
            if (Request.Form["IdCompte"] != null)
            {
                listCompte = Request.Form["IdCompte"];
            }
            if (Request.Form["idClient"] != null)
            {
                idClient = Guid.Parse(Request.Form["idClient"]);
            }
            if (Request.Form["DateReleve"] != null)
            {
                DateTime.TryParseExact(Request.Form["DateReleve"].ToString(), "dd/MM/yyyy",
                       CultureInfo.InvariantCulture,
                       DateTimeStyles.None, out dateReleve);
            }
            
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Recueil");
            var errormsg = string.Empty;
            try
            {
                Guid idCgpAgreg = Guid.Empty;
                var currentUser = SessionManager.GetUserSession();
                if (currentUser.IsEndUser())
                {
                    CustomerProspect currentCustomer = SessionManager.GetCustomerProspectSession();
                    User currenttUserCreated = currentCustomer.User1;
                    idCgpAgreg = currenttUserCreated.idAgregCGP.Value;
                }
                else
                {
                    idCgpAgreg = currentUser.idAgregCGP.Value;
                }
                //
                Guid idFirm = Guid.Empty;
                SessionManager.Get<Guid>(UserBL.AgregCurrentUserFirmId, out idFirm);
                FirmInstitution firm = null;
                if (idFirm == Guid.Empty)
                {                    
                    if (currentUser != null && currentUser.idAgregCGP.HasValue)
                    {
                        var cgp = AgregCgpBL.GetCgpById(idCgpAgreg);
                        firm = FirmInstitutionBL.GetFirmInstitutionByIdAgregCabinet(cgp.idcrmcabinet);
                        if (firm != null)
                        {
                            SessionManager.Set<Guid>(UserBL.AgregCurrentUserFirmId, firm.idFirmInstitution);
                            idFirm = firm.idFirmInstitution;
                        }
                    }
                }
                //
                AgregReleverSituationBL.GenererReleveSituation(idCgpAgreg.ToString(), idClient.ToString(), string.Empty, true, releveType, listCompte, idFirm, dateReleve.ToString("dd/MM/yyyy"));

            }
            catch (Exception ex)
            {
                errormsg = ex.Message;
                Upsilab.Business.Log.Log.AppendException(ex);
            }
            return Content("ok");
        }
        public PartialViewResult LoadPopupFiltreImpressionMasse(string id)
        {            
            //get configuration
            ConfigurationFieldVM config = ReloadConfiguration();                     
            //model à retourner
            AgregCritereReleveSituationViewModel model = new AgregCritereReleveSituationViewModel();
            model.configurationField = config;
            if (!string.IsNullOrEmpty(id))
            {
                model.listeIdClient = id;
            }

            return PartialView("PopupFiltreReleverSituationMasse", model);
        }
        public PartialViewResult LoadPopupFiltreImpression(string id)
        {
            Guid idclient = Guid.Empty;
            if (!string.IsNullOrEmpty(id))
            {
                idclient = Guid.Parse(id);
            }            


            //get configuration
            ConfigurationFieldVM config = ReloadConfiguration();
            //get compte contrat
            List<SqlAgregCompteModel> listecompte = new List<SqlAgregCompteModel>();
            if (idclient != Guid.Empty)
            {
                listecompte = agupsideocompteBL.GetComptesClient(idclient);

                listecompte = listecompte.Where(c => c.Typecontrat.ToLower() == agupsideocompteBL.assurancevie.ToLower()
                    || c.Typecontrat.ToLower() == agupsideocompteBL.comptetitrespea.ToLower()
                    || c.Typecontrat.ToLower() == agupsideocompteBL.capitalisation.ToLower()
                    || c.Typecontrat.ToLower() == agupsideocompteBL.comptebancaire.ToLower()
                    ).ToList();
            }
            //
            ag_upsideo_client client = AgregClientReleveSituationBL.GetClientById(idclient);
            //model à retourner
            AgregCritereReleveSituationViewModel model = new AgregCritereReleveSituationViewModel();
            model.configurationField = config;
            model.listeCompte = listecompte;
            model.idClient = idclient;
            model.client = client;
            model.DateReleve = DateTime.Now;

            return PartialView("PopupFiltreReleverSituation",model);
        }