예제 #1
0
        public void Execute(CommandContext context)
        {
            if (!context.User.DecEmp)
            {
                throw new InvalidOperationException("Vous n'avez pas l'autorisation");
            }
            foreach (Form mdiChild in context.MainForm.MdiChildren)
            {
                var frm = mdiChild as FrmAnnexe <LigneAnnexeCinq, PiedAnnexeCinq>;
                if (frm == null)
                {
                    continue;
                }
                frm.Activate();
                return;
            }

            var pathDirectory = Path.GetDirectoryName(Application.ExecutablePath);

            var annexeRepository       = new AnnexeCinqRepository(context.ConnectionProvider);
            var annexeImportRepository = new LigneAnnexe5ImportRepository();
            var exportRepo             = new FileExportRepository(pathDirectory);
            var annexeCinqservice      = new Annexe5Service(annexeRepository, exportRepo, context.Societe,
                                                            context.Exercice, annexeImportRepository);
            var controller = new DeclarationEmployeurController <LigneAnnexeCinq, PiedAnnexeCinq>(annexeCinqservice);
            var form       = new FrmAnnexe <LigneAnnexeCinq, PiedAnnexeCinq>(controller, context.Societe, context.Exercice);

            form.MdiParent = context.MainForm;
            form.Text      = "Annexe 5";
            form.Show();
        }
        public void Execute(CommandContext context)
        {
            if (!context.User.DecEmp)
            {
                throw new InvalidOperationException("Vous n'avez pas l'autorisation");
            }
            foreach (Form mdiChild in context.MainForm.MdiChildren)
            {
                var frm = mdiChild as FrmRecapDecEmp;
                if (frm == null)
                {
                    continue;
                }
                frm.Close();
                //return;
            }

            var declaredAnnexeView = new IsDeclarationEmployeurView();
            var frmDeclaredAnnexe  = new FrmDeclaredAnnexe(declaredAnnexeView);
            var result             = frmDeclaredAnnexe.ShowDialog();

            if (result != DialogResult.Yes)
            {
                return;
            }

            var pathDirectory = Path.GetDirectoryName(Application.ExecutablePath);

            var exportRepo = new FileExportRepository(pathDirectory);
            // annexe 1
            var annexeUnRepository       = new AnnexeUnRepository(context.ConnectionProvider);
            var annexeUnImportRepository = new LigneAnnexe1ImportRepository();
            var annexeUnService          = new Annexe1Service(annexeUnRepository, exportRepo, context.Societe, context.Exercice,
                                                              annexeUnImportRepository);

            // annexe 2
            var annexeDeuxRepository       = new AnnexeDeuxRepository(context.ConnectionProvider);
            var annexeDeuxImportRepository = new LigneAnnexe2ImportRepository();
            var annexeDeuxservice          = new Annexe2Service(annexeDeuxRepository, exportRepo, context.Societe,
                                                                context.Exercice,
                                                                annexeDeuxImportRepository);

            // annexe 3
            var annexeTroisRepository       = new AnnexeTroisRepository(context.ConnectionProvider);
            var annexeTroisImportRepository = new LigneAnnexe3ImportRepository();
            var annexeTroisService          = new Annexe3Service(annexeTroisRepository, exportRepo, context.Societe,
                                                                 context.Exercice,
                                                                 annexeTroisImportRepository);

            // annexe 4
            var annexeQuatreRepository       = new AnnexeQuatreRepository(context.ConnectionProvider);
            var annexeQuatreImportRepository = new LigneAnnexe4ImportRepository();
            var annexeQuatreService          = new Annexe4Service(annexeQuatreRepository, exportRepo, context.Societe,
                                                                  context.Exercice,
                                                                  annexeQuatreImportRepository);

            // annexe 5
            var annexeCinqRepository       = new AnnexeCinqRepository(context.ConnectionProvider);
            var annexeCinqImportRepository = new LigneAnnexe5ImportRepository();
            var annexeCinqService          = new Annexe5Service(annexeCinqRepository, exportRepo, context.Societe,
                                                                context.Exercice,
                                                                annexeCinqImportRepository);

            // annexe 6
            var annexeSixRepository       = new AnnexeSixRepository(context.ConnectionProvider);
            var annexeSixImportRepository = new LigneAnnexe6ImportRepository();
            var annexeSixService          = new Annexe6Service(annexeSixRepository, exportRepo, context.Societe,
                                                               context.Exercice,
                                                               annexeSixImportRepository);

            //// annexe 7
            //var annexeSeptRepository = new AnnexeSeptRepository(sqliteConnectionProvider);
            //var annexeSeptImportRepository = new LigneAnnexeSeptImportRepository();
            //var annexeSeptService = new AnnexeSeptService(annexeSeptRepository, exportRepo, context.Societe, context.Exercice,
            //    annexeSeptImportRepository);

            // recap service
            var recapService = new RecapService(
                context.Societe,
                context.Exercice,
                annexeUnService,
                annexeDeuxservice,
                annexeTroisService,
                annexeQuatreService,
                annexeCinqService,
                annexeSixService,
                //  annexeSeptService,
                exportRepo);

            var controller = new RecapDeclarationEmployeurController(recapService);

            var form = new FrmRecapDecEmp(controller, declaredAnnexeView);

            form.MdiParent = context.MainForm;
            form.Text      = @"Récap";
            form.Show();
        }