public Tva ModelToData(Tva tva, TvaViewModels model)
        {
            tva.Name  = model.Name;
            tva.Value = (double)model.Value / 100;

            return(tva);
        }
Example #2
0
        public void Edit(TvaViewModels model)
        {
            Tva tva = Repository.GetById(model.TVA_ID);

            tva = Mapper.ModelToData(tva, model);
            Repository.Save();
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Tvaid,Nom,Valeur,Visible")] Tva tva)
        {
            if (id != tva.Tvaid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tva);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TvaExists(tva.Tvaid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tva));
        }
Example #4
0
 public PrintTva(Tva tva, decimal ht, decimal tvaDecimal, decimal ttc)
 {
     Tva        = tva;
     Ht         = ht;
     TvaDecimal = tvaDecimal;
     Ttc        = ttc;
 }
 public TvaViewModels DataToModel(Tva tva)
 {
     return(new TvaViewModels
     {
         TVA_ID = tva.TVA_ID.ToString(),
         Name = tva.Name,
         Value = tva.Value
     });
 }
Example #6
0
        public void Add(TvaViewModels model)
        {
            Tva tva = new Tva();

            tva        = Mapper.ModelToData(tva, model);
            tva.TVA_ID = Guid.NewGuid();

            Repository.Add(tva);
            Repository.Save();
        }
Example #7
0
        public Tva Details(int id)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Tva tva = (from t in db.Tva
                           where t.Id == id
                           select t).FirstOrDefault();

                return(tva);
            }
        }
Example #8
0
        private static void SaveFile()
        {
            _document = new XDocument(new XElement("tva"));

            foreach (var tva in Tvases)
            {
                _document.GetXElement("tva").Add(Tva.ToXElement(tva));
            }

            _document.Save(Path);
        }
Example #9
0
        public async Task <IActionResult> Create([Bind("Tvaid,Nom,Valeur,Visible")] Tva tva)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tva);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tva));
        }
Example #10
0
        private void BtnAddClick(object sender, RoutedEventArgs e)
        {
            var window = new TextWindow(false, Properties.Resources.LabelVat);

            if (window.ShowDialog() == true)
            {
                var tva = new Tva(Guid.NewGuid(), RepositoryTva.Tvases.Count + 1, window.NameText.ToDecimal());
                RepositoryTva.Add(tva);

                DataGridGroups.ItemsSource = null;
                DataGridGroups.ItemsSource = RepositoryTva.Tvases;
            }
        }
Example #11
0
        private static void LoadFile()
        {
            if (File.Exists(Path))
            {
                _document = XDocument.Load(Path);

                Tvases.Clear();
                foreach (var element in _document.GetXElements("tva", "rec"))
                {
                    Tvases.Add(Tva.FromXElement(element));
                }
            }
        }
Example #12
0
        public static void Add(Tva tva)
        {
            if (!File.Exists(Path))
            {
                SaveFile();
            }

            var document = XDocument.Load(Path);

            document.GetXElement("tva").Add(Tva.ToXElement(tva));
            File.WriteAllText(Path, document.ToString());

            Tvases.Add(tva);

            if (SyncData.IsConnect)
            {
                using (var connection = ConnectionFactory.CreateConnection())
                    connection.Execute(InsertQuery, tva);
            }
        }
        /// <summary>
        /// Ajoute une nouvelle civilité à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Tva Add()
        {
            //Affichage du message "ajout en cours"
            ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une tva en cours ...";

            //Initialisation de la fenêtre
            TvaWindow tvaWindow = new TvaWindow();

            //Création de l'objet temporaire
            Tva tmp = new Tva();

            //Mise de l'objet temporaire dans le datacontext
            tvaWindow.DataContext = tmp;

            //booléen nullable vrai ou faux ou null
            bool? dialogResult = tvaWindow.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                //Si j'appuie sur le bouton Ok, je renvoi l'objet banque se trouvant dans le datacontext de la fenêtre
                return (Tva)tvaWindow.DataContext;
            }
            else
            {
                try
                {
                    //On détache la commande
                    ((App)App.Current).mySitaffEntities.Detach((Tva)tvaWindow.DataContext);
                }
                catch (Exception)
                {
                }

                //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout
                ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false;
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une tva annulée : " + this.listTva.Count() + " / " + this.max;

                return null;
            }
        }
        /// <summary>
        /// Met à jour l'état en bas pour l'utilisateur
        /// </summary>
        /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param>
        /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param>
        public void MiseAJourEtat(string typeEtat, Tva lib)
        {
            //Je racalcul le nombre max d'élements
            this.recalculMax();
            //En fonction de l'libion, j'affiche le message
            if (typeEtat == "Filtrage")
            {
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "filtrage des tva terminée : " + this.listTva.Count() + " / " + this.max;
            }
            else if (typeEtat == "Ajout")
            {
                //J'ajoute la commande_fournisseur dans le linsting
                this.listTva.Add(lib);
                //Je racalcul le nombre max d'élements après l'ajout
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout de la tva dénommée '" + lib.Libelle + "' effectué avec succès. Nombre d'élements : " + this.listTva.Count() + " / " + this.max;
            }
            else if (typeEtat == "Modification")
            {
                //Je raffraichis mon datagrid
                this._DataGridMain.Items.Refresh();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification de la tva dénommée : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.listTva.Count() + " / " + this.max;
            }
            else if (typeEtat == "Suppression")
            {
                //Je supprime de mon listing l'élément supprimé
                this.listTva.Remove(lib);
                //Je racalcul le nombre max d'élements après la suppression
                this.recalculMax();
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Suppression de la tva dénommée : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.listTva.Count() + " / " + this.max;
            }
            else if (typeEtat == "Look")
            {

            }
            else
            {
                ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Chargement des tva terminée : " + this.listTva.Count() + " / " + this.max;
            }
            //Je retri les données dans le sens par défaut
            this.triDatas();
            //J'arrete la progressbar
            ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false;
        }
Example #15
0
        public TvaViewModels GetById(string id)
        {
            Tva tva = Repository.GetById(id);

            return(tva == null ? null : Mapper.DataToModel(tva));
        }
Example #16
0
 public void Add(Tva tva)
 {
     Entities.Tvas.Add(tva);
 }