Exemple #1
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            gerador                  = new Gerador();
            gerador.OnGerarJogo     += OnGerarJogo;
            gerador.OnBolaSorteada  += OnBolaSorteada;
            gerador.OnJogoAprovado  += OnJogoAprovado;
            gerador.OnJogoReprovado += OnJogoReprovado;

            chkLimparArquivo.Enabled = !File.Exists(BancoDados.BancoDados.CAMINHO_COMPLETO);

            if (!File.Exists(BancoDados.BancoDados.CAMINHO_COMPLETO))
            {
                Faxineiro faxineiro = new Faxineiro();
                faxineiro.OnArquivoLido += OnArquivoLidoFaxineiro;
                faxineiro.OnLinhaLida   += OnLinhaLida;

                Carregador carregador = new Carregador();
                carregador.OnArquivoLido += OnArquivoLidoCarregador;
                carregador.OnLinhaLida   += OnLinhaLida;

                banco.Faxineiro  = faxineiro;
                banco.Carregador = carregador;
            }
            lbCoincidencias.Text = ValidadorGeral.FATOR_COINCIDENCIA + "+ bolas coincidentes em outro jogo: 0";
            CarregarValidadores();
        }
Exemple #2
0
        public void CarregarArquivo(bool limpar)
        {
            if (Carregador == null)
            {
                throw new Exception("O carregador não foi associado ao gerenciador de banco de dados.");
            }
            if ((limpar) && (Faxineiro == null))
            {
                throw new Exception("O faxineiro não foi associado ao gerenciador de banco de dados.");
            }

            if (limpar)
            {
                Faxineiro.LimparArquivo(CAMINHO + "\\base.txt");
            }

            List <Jogo> jogos = Carregador.LerArquivo(CAMINHO + "\\base.txt");

            foreach (Jogo jogo in jogos)
            {
                AdicionarJogoPassado(jogo);
            }

            Salvar();
        }