public void AddArticle(Article article)
 {
     if (article.Designation == string.Empty || article.OEM == string.Empty || article.Packaging == null || article.Reference == string.Empty)
     {
         return;
     }
     Catalogue.Articles.Add(article);
     IoCContainer.Get <ModelContainer>().SaveChanges();
 }
        public CataloguePageVM()
        {
            //Importateurs = Parametres.Importateurs;
            //Produits = Parametres.Produits;
            //Attributs = Parametres.Attributs.ToDictionary(a => a, a => string.Empty);
            //Articles = Parametres.Articles;
            var importateur = IoCContainer.Get <Importateur>();

            if (importateur.Catalogue == null)
            {
                importateur.Catalogue = new Catalogue();
            }
            SelectedImportateur = importateur;
        }
        public FactureTransitVM(FactureTransit facture)
        {
            Facture = facture;

            #region Initialisation Divers

            AddFraisDeclare = new RelayCommand(() =>
            {
                Facture.FraisDeclares.Add(new FactureDeclaree()
                {
                    NumFacture = "D01"
                });
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisDeclare));
                OnPropertyChanged(nameof(TotalFraisDeclare));
            });

            AddFraisNonDeclare = new RelayCommand(() =>
            {
                Facture.FraisNonDeclares.Add(new FactureNonDeclaree()
                {
                    NumFacture = "ND01"
                });
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisNonDeclare));
                OnPropertyChanged(nameof(TotalFraisNonDeclare));
            });

            DeleteFraisDeclare = new RelayCommand(() =>
            {
                Facture.FraisDeclares.Remove(SelectedFraisDeclare.Facture as FactureDeclaree);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisDeclare));
                OnPropertyChanged(nameof(TotalFraisDeclare));
            });

            DeleteFraisNonDeclare = new RelayCommand(() =>
            {
                Facture.FraisNonDeclares.Remove(SelectedFraisNonDeclare.Facture as FactureNonDeclaree);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisNonDeclare));
                OnPropertyChanged(nameof(TotalFraisNonDeclare));
            });

            #endregion

            #region Initialisation Facture

            #endregion
        }
        public NegociationPageVM()
        {
            AddCommande = new RelayCommand(() =>
            {
                var importation = IoCContainer.Get <Importation>();
                if (importation.Commande != null)
                {
                    return;
                }
                importation.Commande = new Commande()
                {
                    NumFacture = "Comm 0", Date = DateTime.Today
                };
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Factures));
            });

            AddOffre = new RelayCommand(() =>
            {
                var offres = IoCContainer.Get <Importation>().Offres;
                if (offres == null)
                {
                    offres = new Collection <Offre>();
                }
                var lignes   = new List <LigneFacture>();
                var commande = IoCContainer.Get <Importation>().Commande;
                if (commande != null)
                {
                    lignes.AddRange(commande.LignesCommande.Select(l => new LigneFacture()
                    {
                        Article = l.Article, Quantite = l.Quantite
                    }));
                }
                offres.Add(new Offre()
                {
                    NumFacture = "Offre " + (offres.Count() + 1), Date = DateTime.Today, LignesFacture = lignes
                });
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Factures));
            });

            Delete = new RelayCommand(() =>
            {
                var container = IoCContainer.Get <ModelContainer>();
                container.Factures.Remove(SelectedFacture.Facture);
                container.SaveChanges();
                OnPropertyChanged(nameof(Factures));
            });
        }
        public FactureFraisVM()
        {
            #region Initialisation Divers

            AddFraisDeclare = new RelayCommand(() =>
            {
                IoCContainer.Get <Importation>().FraisDivers.Add(new FactureDeclaree()
                {
                    NumFacture = "FraisD01"
                });
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisDeclare));
                OnPropertyChanged(nameof(TotalFraisDeclare));
            });

            AddFraisNonDeclare = new RelayCommand(() =>
            {
                IoCContainer.Get <Importation>().FraisDivers.Add(new FactureNonDeclaree()
                {
                    NumFacture = "FraisND01"
                });
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisNonDeclare));
                OnPropertyChanged(nameof(TotalFraisNonDeclare));
            });

            DeleteFraisDeclare = new RelayCommand(() =>
            {
                IoCContainer.Get <Importation>().FraisDivers.Remove(SelectedFraisDeclare.Facture);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisDeclare));
                OnPropertyChanged(nameof(TotalFraisDeclare));
            });

            DeleteFraisNonDeclare = new RelayCommand(() =>
            {
                IoCContainer.Get <Importation>().FraisDivers.Remove(SelectedFraisDeclare.Facture);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(FraisNonDeclare));
                OnPropertyChanged(nameof(TotalFraisNonDeclare));
            });

            #endregion
        }
        public void SetArticle(Article article)
        {
            if (article.Designation == string.Empty || article.OEM == string.Empty || article.Packaging == null || article.Reference == string.Empty)
            {
                return;
            }
            var tmp = Catalogue.Articles.SingleOrDefault(a => a.Id == article.Id);

            if (tmp == null)
            {
                return;
            }

            tmp.Designation = article.Designation;
            tmp.OEM         = article.OEM;
            tmp.Packaging   = article.Packaging;
            tmp.PoidsNet    = article.PoidsNet;
            tmp.Reference   = article.Reference;
            tmp.Volume      = article.Volume;
            IoCContainer.Get <ModelContainer>().SaveChanges();
        }
Esempio n. 7
0
        public AttributVM(Attribut attribut)
        {
            Attribut = attribut;

            AddValeur = new RelayCommand(() =>
            {
                if (Pere != null)
                {
                    if (SelectedValeurPere == null)
                    {
                        return;
                    }
                    Attribut.Valeurs.Add(new Valeur()
                    {
                        Pere = SelectedValeurPere
                    });
                }
                else
                {
                    Attribut.Valeurs.Add(new Valeur());
                }
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Valeurs));

                OnPropertyChanged(nameof(SelectedValeur));
            });

            DeleteValeur = new RelayCommand(() =>
            {
                if (SelectedValeur == null)
                {
                    return;
                }
                Attribut.Valeurs.Remove(SelectedValeur.Valeur);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Valeurs));
                SelectedValeur = Valeurs.Last();
                OnPropertyChanged(nameof(SelectedValeur));
            });
        }
        public CommandeVM(Commande commande)
        {
            Commande = commande;

            Print = new RelayCommand(() =>
            {
                string directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ImportManager\Assets";

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                var fullPath = directory + @"\Commande.xlsx";
                var newFile  = directory + @"\Commande_New.xlsx";
                File.Copy(fullPath, newFile, true);

                var app      = new Microsoft.Office.Interop.Excel.Application();
                app.Visible  = false;
                var workbook = app.Workbooks.Open(newFile);
                var sheet    = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
                sheet.Range["Fournisseur"].Value = IoCContainer.Get <Importation>().Fournisseur.Denomination;
                sheet.Range["NumCommande"].Value = Commande.NumFacture;
                sheet.Range["Date"].Value        = Commande.Date.ToString();
                var com = sheet.ListObjects.Item["Commande"];

                foreach (LigneCommandeVM l in Lignes)
                {
                    com.ListRows.Add();
                    com.Range[com.Range.Rows.Count, 2] = l.Designation;
                    com.Range[com.Range.Rows.Count, 3] = l.Quantite;
                }
                app.Visible = true;
                var path    = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + Commande.NumFacture.Replace("/", "_") + ".xlsx";
                app.Dialogs.Item[Microsoft.Office.Interop.Excel.XlBuiltInDialog.xlDialogSaveAs].Show(path);
                workbook.Save();
                workbook.Close();
                app.Quit();
            });
        }
        private void InitCommands()
        {
            ShowImportation = new RelayCommand(() =>
            {
                IsImportationsListVisible = false;
                IsImportationSelected     = true;
            });

            HideImportation = new RelayCommand(() =>
            {
                IsImportationSelected     = false;
                IsImportationsListVisible = true;
            });

            AddImportation = new RelayCommand(() =>
            {
                var container = IoCContainer.Get <ModelContainer>();
                container.Importations.Add(new Importation()
                {
                    DateCreation = DateTime.Today, D10 = new TaxeDouanier()
                    {
                        NumD10 = "D10-02"
                    }
                });
                container.SaveChanges();
                OnPropertyChanged(nameof(Importations));
            });

            DeleteImportation = new RelayCommand(() =>
            {
                var container = IoCContainer.Get <ModelContainer>();
                container.TaxeDouaniers.Remove(SelectedImportation.Importation.D10);
                container.Importations.Remove(SelectedImportation.Importation);
                container.SaveChanges();
                OnPropertyChanged(nameof(Importations));
            });
        }
        public DomiciliationPageVM()
        {
            PrintTaxe = new RelayCommand(() =>
            {
                var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ImportManager\Assets";

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                var fullPath    = directory + @"\C25.pdf";
                var newFile     = directory + @"\C25_New.pdf";
                var reader      = new PdfReader(fullPath);
                var stamper     = new PdfStamper(reader, new FileStream(newFile, FileMode.OpenOrCreate));
                var importateur = IoCContainer.Get <Importation>().Importateur;
                var importation = IoCContainer.Get <Importation>();
                var fields      = stamper.AcroFields;

                fields.SetField("DE", RecetteImpots.Wilaya.Designation);
                fields.SetField("RECETTE DES IMPOTS DE", RecetteImpots.Designation);
                fields.SetField("Code de la recette Ll", RecetteImpots.Code);
                fields.SetField("Nom et prénom ou raison sociale", importateur.Denomination);
                fields.SetField("Statut juridique", importateur.StatutJuridique.Designation);
                fields.SetField("Capital social", importateur.Capital.ToString());
                var adresse = (importateur.Adresse1 as AdresseLocale);
                fields.SetField("Adresse", adresse.LigneAdresse + ", " + adresse.Commune + ", " + adresse.Wilaya.Designation);
                fields.SetField("Texte1", importateur.NIF);
                fields.SetField("Texte2", "NIF 2");
                fields.SetField("Texte4", importateur.RegistreCommerce.Substring(0, 2));
                fields.SetField("Texte3", importateur.RegistreCommerce.Substring(2));
                fields.SetField("Code dactivité", importation.Activite.Code);
                fields.SetField("Texte5", importateur.ComptesBancaires.SingleOrDefault(c => c.Banque == importation.BanqueImportateur.Banque)?.NumCompte);
                var gerant        = importateur.Gerant;
                var adresseGerant = gerant.Adresse as AdresseLocale;
                var nomGerant     = gerant.Nom + " " + gerant.Prenom + ", " + adresseGerant?.LigneAdresse + ", " + adresseGerant?.Commune + ", " + adresseGerant?.Wilaya.Designation;
                fields.SetField("Nom prénom et adresse du gérant", nomGerant);
                fields.SetField("LI 1", gerant.NIF);
                fields.SetField("Texte9", "NIF Gérant 2");
                var positions = importation.FactureProforma.LignesFacture.Select(l => l.Article.Produit.PositionTarifaire);

                fields.SetField("Texte6", "Position Tarifaire 1");
                fields.SetField("Texte7", positions.Select(p => p.Code.Replace(".", "")).Aggregate((current, next) => current + " " + (!current.Contains(next) ? next : "")));
                var proforma = new FactureProformaVM(importation.FactureProforma);
                fields.SetField("Texte8", proforma.TotalPrix + proforma.Devise.Designation + " = " + (proforma.TotalPrix * Cours) + " DA");
                fields.SetField("Texte10", Developpez.Dotnet.NumberConverter.Spell(Convert.ToInt64((proforma.TotalPrix * Cours).Value)) + " DA");
                fields.SetField("Numéro de la facture ou autre document commercial", proforma.InvoiceN);
                fields.SetField("Banque de domiciliation", AgenceBanqueImportateur.Banque.Denomination);
                fields.SetField("Désignation de lagence", AgenceBanqueImportateur.Designation);
                fields.SetField("Code de lagence", AgenceBanqueImportateur.Code);
                fields.SetField("Bénéficiaire étranger", importation.Fournisseur.Denomination);
                var adressFournisseur = importation.Fournisseur.Adresse1;
                fields.SetField("Adresse du bénéficiaire étranger", adressFournisseur.LigneAdresse + " " + adressFournisseur.CodePostal + " " + adressFournisseur.Pays.Designation);
                fields.SetField("le", DateTaxeDomiciliation.ToShortDateString());
                //fields.SetField("Numéro", "Numéro");
                //fields.SetField("Date", "Date");
                //fields.SetField("Mode de paiement", "Mode Paiement");
                fields.SetField("Fait à", RecetteImpots.Designation);
                //fields.SetField("Code de la recette Ll_3", "Code Recette");
                stamper.Close();
                reader.Close();

                Process.Start(newFile);
            });

            PrintFranchise = new RelayCommand(() =>
            {
                var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ImportManager\Assets";

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                var fullPath    = directory + @"\DemFranchise.pdf";
                var newFile     = directory + @"\DemFranchise_New.pdf";
                var reader      = new PdfReader(fullPath);
                var stamper     = new PdfStamper(reader, new FileStream(newFile, FileMode.OpenOrCreate));
                var importateur = IoCContainer.Get <Importation>().Importateur;
                var importation = IoCContainer.Get <Importation>();
                var fields      = stamper.AcroFields;

                fields.SetField("RaisonSociale", importateur.Denomination);
                fields.SetField("RaisonSociale_AR", importateur.DenominationAR);
                fields.SetField("Tel", importateur.Tel);
                fields.SetField("Fax", importateur.Fax);
                var adresse = (importateur.Adresse1 as AdresseLocale);
                fields.SetField("Adresse", adresse.LigneAdresse + ", " + adresse.Commune + ", " + adresse.Wilaya.Designation);
                fields.SetField("DesignationMarchandise", "A Déterminer");
                fields.SetField("SousPosition", "A Déterminer");
                fields.SetField("AgenceCNRC", "A Déterminer");
                fields.SetField("AgenceCNRC_AR", "A Déterminer");
                fields.SetField("NIF", importateur.NIF);
                fields.SetField("PoidsNet", "A Déterminer");
                fields.SetField("ValeurFOB", "A Déterminer");
                fields.SetField("Fret", "A Déterminer");
                fields.SetField("PaysOrigine", importation.PaysOrigine.Designation);
                fields.SetField("PaysProvenance", importation.FactureProforma.PortEmbarquement.Pays.Designation);
                stamper.Close();
                reader.Close();
            });

            PrintOrdreAchat = new RelayCommand(() =>
            {
                var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ImportManager\Assets";

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                var fullPath    = directory + @"\OrdreAchat.pdf";
                var newFile     = directory + @"\OrdreAchat_New.pdf";
                var reader      = new PdfReader(fullPath);
                var stamper     = new PdfStamper(reader, new FileStream(newFile, FileMode.OpenOrCreate));
                var importateur = IoCContainer.Get <Importation>().Importateur;
                var importation = IoCContainer.Get <Importation>();
                var fields      = stamper.AcroFields;

                fields.SetField("TypeMarchandise", "A Déterminer");
                fields.SetField("Quantite", new FactureProformaVM(importation.FactureProforma).TotalQuantite.ToString());
                fields.SetField("Prix", new FactureProformaVM(importation.FactureProforma).TotalPrix.ToString());
                fields.SetField("NumFacture", importation.FactureProforma.NumFacture);
                fields.SetField("Lieu", LieuOrdreAchat);
                fields.SetField("Date", DateOrdreAchat);
                stamper.Close();
                reader.Close();
            });
        }
Esempio n. 11
0
        public EntrepriseVM(Entreprise entreprise)
        {
            Entreprise = entreprise;
            AddAgence  = new RelayCommand(() =>
            {
                var banque = Entreprise as Banque;
                banque.Agences.Add(new AgenceBanque());
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Agences));
            });

            DeleteAgence = new RelayCommand(() =>
            {
                if (SelectedAgence.Agence == null)
                {
                    return;
                }
                var container = IoCContainer.Get <ModelContainer>();
                container.AgenceBanques.Remove(SelectedAgence.Agence);
                container.SaveChanges();
                OnPropertyChanged(nameof(Agences));
            });

            AddCompte = new RelayCommand(() =>
            {
                Entreprise.ComptesBancaires.Add(new CompteBancaire());
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Comptes));
            });

            DeleteCompte = new RelayCommand(() =>
            {
                if (SelectedCompte.Compte == null)
                {
                    return;
                }
                var container = IoCContainer.Get <ModelContainer>();
                container.ComptesBancaires.Remove(SelectedCompte.Compte);
                container.SaveChanges();
                OnPropertyChanged(nameof(Comptes));
            });

            AddMotif = new RelayCommand(() =>
            {
                Entreprise.Motifs.Add(new MotifFacture());
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Motifs));
            });

            DeleteMotif = new RelayCommand(() =>
            {
                if (SelectedMotif == null)
                {
                    return;
                }
                var container = IoCContainer.Get <ModelContainer>();
                Entreprise.Motifs.Remove(SelectedMotif);
                container.SaveChanges();
                OnPropertyChanged(nameof(Motifs));
                OnPropertyChanged(nameof(ListeMotifs));
            });

            SelectMotif = new RelayCommand(() =>
            {
                if (AvailableMotif == null)
                {
                    return;
                }
                Entreprise.Motifs.Add(AvailableMotif);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Motifs));
            });

            DeleteActivite = new RelayCommand(() =>
            {
                (Entreprise as Importateur).Activites.Remove(SelectedActivite);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Activites));
            });

            SelectActivite = new RelayCommand(() =>
            {
                if (AvailableActivite == null)
                {
                    return;
                }
                (Entreprise as Importateur).Activites.Add(AvailableActivite);
                IoCContainer.Get <ModelContainer>().SaveChanges();
                OnPropertyChanged(nameof(Activites));
            });
        }