Beispiel #1
0
        /// <summary>
        /// Ajoute une sous catégorie provenant de l'outil s de restauration
        /// </summary>
        /// <param name="sousCategorie">la sous catégorie à ajouter</param>
        /// <returns>la task</returns>
        public async Task AjouterSousCategorieFmRestauration(SousCategorie sousCategorie)
        {
            sousCategorie.IsSousCategPerso = true;
            await Bdd.AjouterDonnee(sousCategorie);

            await RoamingCategorieBusiness.AjouterSousCategorie(sousCategorie);
        }
Beispiel #2
0
        /// <summary>
        /// Ajoute une catégorie provenant de l'outil s de restauration
        /// </summary>
        /// <param name="categorie">la catégorie à ajouter</param>
        /// <returns>la task</returns>
        public async Task AjouterCategorieFmRestauration(Categorie categorie)
        {
            categorie.SousCategorieList = new List <SousCategorie>();
            categorie.IsCategPerso      = true;
            await Bdd.AjouterDonnee(categorie);

            await RoamingCategorieBusiness.AjouterCategorie(categorie);
        }
Beispiel #3
0
        /// <summary>
        /// Efface une sous categorie
        /// </summary>
        /// <param name="idSousCategorie">l'id de la sous categorie</param>
        /// <returns></returns>
        public async Task DeleteSousCategorie(int idSousCategorie)
        {
            var sousCateg = await Bdd.Connection.Table <SousCategorie>().Where(x => x.Id == idSousCategorie).FirstOrDefaultAsync();

            await Bdd.DeleteDonnee(sousCateg);

            await RoamingCategorieBusiness.SupprimerSousCategorie(sousCateg);
        }
Beispiel #4
0
        /// <summary>
        /// Modifie une catégorie en base
        /// </summary>
        /// <param name="categorie">la catégorie à modifier</param>
        /// <returns>la task</returns>
        public async Task ModifierCategorie(Categorie categorie)
        {
            var categToModif = await Bdd.Connection.Table <Categorie>().Where(x => x.Id == categorie.Id).FirstOrDefaultAsync();

            categToModif.Libelle = categorie.Libelle;
            await Bdd.UpdateDonnee(categToModif);

            await RoamingCategorieBusiness.ModifierCategorie(categToModif);
        }
Beispiel #5
0
        /// <summary>
        /// modifie une sous categorie
        /// </summary>
        /// <param name="sousCategorie"> l'id de la sous catégorie à modifier</param>
        /// <returns>la task</returns>
        public async Task ModifierSousCategorie(SousCategorie sousCategorie)
        {
            var sousCategToModif =
                await Bdd.Connection.Table <SousCategorie>().Where(x => x.Id == sousCategorie.Id).FirstOrDefaultAsync();

            sousCategToModif.IdCategorie = sousCategorie.IdCategorie;
            sousCategToModif.Libelle     = sousCategorie.Libelle;

            await Bdd.UpdateDonnee(sousCategToModif);

            await RoamingCategorieBusiness.ModifierSousCategorie(sousCategToModif);
        }
Beispiel #6
0
        /// <summary>
        /// Recalcul les infos d'espace pour le romaing
        /// </summary>
        private async Task CalculerEspaceDispo()
        {
            var espaceTotal = await RoamingUtils.GetEspaceRoamingOccupePourcent();

            EspaceDispoTextBlock.Text       = ResourceLoader.GetForCurrentView().GetString("EspaceDispo") + " " + espaceTotal + " %";
            EspaceDispoTextBlock.Foreground = espaceTotal >= ContexteStatic.EspaceMaxAutoriseRoaming ? new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)) : new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            EspaceCompteOccupe.Text         = await RoamingCompteBusiness.GetEspaceFichierOccupePourcent() + " %";

            EspaceMouvementOccupe.Text = await RoamingMouvementBusiness.GetEspaceFichierOccupePourcent() + " %";

            EcheancierCheckBox.Content = await RoamingEcheancierBusiness.GetEspaceFichierOccupePourcent() + " %";

            CategorieCheckBox.Content = await RoamingCategorieBusiness.GetEspaceFichierOccupePourcent() + " %";
        }
Beispiel #7
0
        /// <summary>
        /// active ou désactive la synchro du roaming des catégories
        /// </summary>
        /// <returns>la task</returns>
        public async Task ChangeSynchroCategorie()
        {
            await _applicationBusiness.SetRoamingCategorieActive(IsRoamingCategorieActive);

            App.IsRoamingCategorieActive = IsRoamingCategorieActive;

            if (!IsRoamingCategorieActive)
            {
                await RoamingCategorieBusiness.DeleteRoaming();
            }
            else
            {
                await RoamingCategorieBusiness.ReCreerFichierRoaming();
            }
        }
Beispiel #8
0
        /// <summary>
        /// efface une categorie
        /// </summary>
        /// <param name="idCategorie">la catégorie à effacer</param>
        /// <returns></returns>
        public async Task DeleteCategorie(int idCategorie)
        {
            var categ = await Bdd.Connection.Table <Categorie>().Where(x => x.Id == idCategorie).FirstOrDefaultAsync();

            var listeSousCateg = await Bdd.Connection.Table <SousCategorie>().Where(x => x.IdCategorie == idCategorie).ToListAsync();

            await Bdd.DeleteDonnee(categ);

            foreach (var sousCategory in listeSousCateg)
            {
                await DeleteSousCategorie(sousCategory.Id);
            }

            await RoamingCategorieBusiness.SupprimerCategorie(categ);
        }
Beispiel #9
0
        /// <summary>
        /// Ajoute une catégorie en base
        /// </summary>
        /// <param name="libelle">le libelle de la catégorie à ajouter</param>
        /// <returns>la catégorie créer</returns>
        public async Task <Categorie> AddCategorie(string libelle)
        {
            var categorie = new Categorie();
            var categId   = await Bdd.Connection.Table <Categorie>().OrderByDescending(x => x.Id).FirstOrDefaultAsync();

            var id = 1;

            if (categId != null)
            {
                id = categId.Id + 1;
            }
            categorie.Id                = id;
            categorie.IsCategPerso      = true;
            categorie.Libelle           = libelle;
            categorie.SousCategorieList = new List <SousCategorie>();

            await Bdd.AjouterDonnee(categorie);

            await RoamingCategorieBusiness.AjouterCategorie(categorie);

            return(categorie);
        }
Beispiel #10
0
        /// <summary>
        /// Efface toute les données devant être restauré
        /// </summary>
        /// <returns>la task</returns>
        public async Task DeleteForRestauration()
        {
            await Bdd.Connection.DropTableAsync <Banque>();

            await Bdd.Connection.DropTableAsync <Compte>();

            await Bdd.Connection.DropTableAsync <Echeancier>();

            await Bdd.Connection.DropTableAsync <Mouvement>();

            await Bdd.Connection.DropTableAsync <Categorie>();

            await Bdd.Connection.DropTableAsync <SousCategorie>();

            await Bdd.Connection.DropTableAsync <SoldeInitial>();

            await Bdd.Connection.CreateTableAsync <Banque>();

            await Bdd.Connection.CreateTableAsync <Compte>();

            await Bdd.Connection.CreateTableAsync <Echeancier>();

            await Bdd.Connection.CreateTableAsync <Mouvement>();

            await Bdd.Connection.CreateTableAsync <Categorie>();

            await Bdd.Connection.CreateTableAsync <SousCategorie>();

            await Bdd.Connection.CreateTableAsync <SoldeInitial>();

            await RoamingCategorieBusiness.DeleteRoaming();

            await RoamingCompteBusiness.DeleteRoaming();

            await RoamingEcheancierBusiness.DeleteRoaming();

            await RoamingMouvementBusiness.DeleteRoaming();
        }
Beispiel #11
0
        private static async Task AjoutCategorieUserFmRoaming()
        {
            //ajout des catégories
            var listeCateg = await RoamingCategorieBusiness.GetCategorieRoaming();

            if (listeCateg != null && listeCateg.Count > 0)
            {
                ListeCategoriesMouvement.AddRange(listeCateg);
            }

            //ajout des sous catégories
            var listeSousCateg = await RoamingCategorieBusiness.GetSousCategorieRoaming();

            if (listeSousCateg != null && listeSousCateg.Count > 0)
            {
                foreach (var sousCategory in listeSousCateg)
                {
                    var category = ListeCategoriesMouvement.FirstOrDefault(c => c.Id == sousCategory.IdCategorie && c.IsCategPerso == sousCategory.IsCategPerso);
                    sousCategory.CategorieMere = category;
                    category.SousCategorieList.Add(sousCategory);
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Créer une sous catégorie perso
        /// </summary>
        /// <param name="libelle">le libelle de la sous catégorie</param>
        /// <param name="idCategorie">l'id de la catégorie mère</param>
        /// <param name="isCategoriePerso">si la catégorie mère est perso ou non</param>
        /// <returns>la sous catégorie de créer</returns>
        public async Task <SousCategorie> AddSousCategorie(string libelle, int idCategorie, bool isCategoriePerso)
        {
            var sousCategorie = new SousCategorie();
            var sousCategId   = await Bdd.Connection.Table <SousCategorie>().OrderByDescending(x => x.Id).FirstOrDefaultAsync();

            var id = 1;

            if (sousCategId != null)
            {
                id = sousCategId.Id + 1;
            }
            sousCategorie.Id               = id;
            sousCategorie.Libelle          = libelle;
            sousCategorie.IdCategorie      = idCategorie;
            sousCategorie.IsCategPerso     = isCategoriePerso;
            sousCategorie.IsSousCategPerso = true;

            await Bdd.AjouterDonnee(sousCategorie);

            await RoamingCategorieBusiness.AjouterSousCategorie(sousCategorie);

            return(sousCategorie);
        }
Beispiel #13
0
        /// <summary>
        /// Créer la base de donnée à partir des données présentes dans le fihier Roaming
        /// </summary>
        /// <returns>las task</returns>
        public async Task CreerBaseDeDonneeFromRoaming(AppareilEnum appareil)
        {
            //creer la base
            await CreerBase(appareil);

            if (appareil == AppareilEnum.ModeAppareilPrincipal)
            {
                //ajout des banques et des comptes
                var listeBanques = await RoamingCompteBusiness.GetListeBanques();

                foreach (var banque in listeBanques)
                {
                    // ajout de la banque
                    var banqueId = await Bdd.Connection.Table <Banque>().OrderByDescending(x => x.Id).FirstOrDefaultAsync();

                    var idbanque = 1;
                    if (banqueId != null)
                    {
                        idbanque = banqueId.Id + 1;
                    }
                    banque.Id = idbanque;
                    await Bdd.AjouterDonnee(banque);

                    //ajout des comtpes
                    foreach (var compte in banque.ListeCompte)
                    {
                        var compteId = await Bdd.Connection.Table <Compte>().OrderByDescending(x => x.Id).FirstOrDefaultAsync();

                        var id = 1;
                        if (compteId != null)
                        {
                            id = compteId.Id + 1;
                        }
                        compte.Id       = id;
                        compte.IdBanque = banque.Id;
                        await Bdd.AjouterDonnee(compte);
                    }
                }

                //Ajout des échéanciers
                var listeEcheancier = await RoamingEcheancierBusiness.GetAllEcheancier();

                foreach (var echeancier in listeEcheancier)
                {
                    await Bdd.AjouterDonnee(echeancier);
                }

                //ajout des catégories perso
                var listeCategorie = await RoamingCategorieBusiness.GetCategorieRoaming();

                foreach (var category in listeCategorie)
                {
                    await Bdd.AjouterDonnee(category);
                }

                var listeSousCategorie = await RoamingCategorieBusiness.GetSousCategorieRoaming();

                foreach (var sousCategory in listeSousCategorie)
                {
                    await Bdd.AjouterDonnee(sousCategory);
                }
            }
        }