コード例 #1
0
        public void factureVM()
        {
            accessUserControl = new FactureVM();

            Btn_receptionColor      = Brushes.Teal;
            Btn_renduColor          = Brushes.Teal;
            Btn_factureColor        = Brushes.Crimson;
            Btn_clientProColor      = Brushes.Teal;
            Btn_convoyeurColor      = Brushes.Teal;
            Btn_impressionColor     = Brushes.Teal;
            Btn_administrateurColor = Brushes.Teal;
        }
コード例 #2
0
        // GET: Factures
        //Afficher la liste de facture selon Année Sélectionnée
        public async Task <IActionResult> Afficher(string AnneeSelected)
        {
            //Récuperer l'info de client connecté
            var user = await _userManager.GetUserAsync(User);

            var clientId = await _context.Client.Where(e => e.Email == user.Email).Select(i => i.Id).SingleOrDefaultAsync();

            if (clientId == 0)
            {
                return(RedirectToAction("Create", "Clients"));
            }

            var clientNom = await _context.Client.Where(e => e.Email == user.Email).Select(i => i.Nom).SingleOrDefaultAsync();

            var clientPrenom = await _context.Client.Where(e => e.Email == user.Email).Select(i => i.Prenom).SingleOrDefaultAsync();

            //Récuperer Id,Nom,Prénom de client pour l'afficher dans View
            ViewBag.Nom   = clientPrenom + " " + clientNom;
            ViewBag.Id    = clientId;
            ViewBag.Annee = AnneeSelected;

            //Par défaut, afficher pour l'année
            if (AnneeSelected == null)
            {
                AnneeSelected = "2018";
            }
            int year = int.Parse(AnneeSelected);

            //ajouter l'année en cours
            List <int> listYears = new List <int>();

            listYears.Add(DateTime.Today.Year);
            //ajouter l'année du factures
            int yearToAdd = 0;
            var factures  = await _context.Facture.Where(f => f.IdClient == clientId).OrderByDescending(o => o.DateFacture).ToListAsync();

            foreach (var facture in factures)
            {
                yearToAdd = facture.DateFacture.Year;
                if (!listYears.Contains(yearToAdd))
                {
                    listYears.Add(yearToAdd);
                }
            }
            ViewBag.Years = listYears;

            //liste factures selon l'année sélectionné
            var facturesVM = new FactureVM();

            facturesVM.Factures = await _context.Facture.Include(f => f.LigneFacture).Where(f => f.IdClient == clientId && f.DateFacture.Year == year).OrderByDescending(o => o.DateFacture).ToListAsync();

            return(View(facturesVM));
        }
        public ActionResult ENREGISTRERFACTURE(String Id)
        {
            using (IDAL dal = new Dal())
            {
                if (dal.VerifierAccesParUtilisateurIdParPrivilegePeut(HttpContext.User.Identity.Name, "ENREGISTRER_FACTURE"))
                {
                    FactureVM factureVM = new FactureVM();

                    DOSSIER dossierPatient = dal.ObtenirDossierParId(CRYPTAGE.StringHelpers.Encrypt(Id));
                    if (dossierPatient != null)
                    {
                        factureVM.DossierID   = CRYPTAGE.StringHelpers.Decrypt(dossierPatient.DossierID);
                        factureVM.CodeDossier = CRYPTAGE.StringHelpers.Decrypt(dossierPatient.Code);
                        factureVM.Patient     = CRYPTAGE.StringHelpers.Decrypt(dossierPatient.Patient.Nom) + " " + CRYPTAGE.StringHelpers.Decrypt(dossierPatient.Patient.Prenom);

                        UTILISATEUR u = dal.ObtenirUtilisateurParId(HttpContext.User.Identity.Name);
                        if (u != null)
                        {
                            factureVM.NomCaissier = CRYPTAGE.StringHelpers.Decrypt(u.Personne.Nom) + " " + CRYPTAGE.StringHelpers.Decrypt(u.Personne.Prenom);
                            factureVM.CaissierID  = CRYPTAGE.StringHelpers.Decrypt(u.UtilisateurID);
                        }
                    }

                    List <PRODUIT>   ListeProduits  = dal.ObtenirTousLesProduits();
                    List <ProduitVM> ListeProduitVM = new List <ProduitVM>();

                    if (ListeProduits.Count > 0)
                    {
                        ProduitVM pVM;
                        foreach (var p in ListeProduits)
                        {
                            pVM = new ProduitVM();
                            pVM = dal.ConvertirProduitProduitVM(p);
                            ListeProduitVM.Add(pVM);
                        }
                    }
                    factureVM.ListeProduits = ListeProduitVM;

                    return(View("FormulaireAjoutFacture", factureVM));
                }
                else
                {
                    ViewBag.ErrorMessage = dal.getErrorMessageFailedAuthorization();
                    return(View("Error"));
                }
            }
        }