Example #1
0
        private void buscaHorárioVerãoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder DataInicio   = new StringBuilder(10);
            StringBuilder DataFim      = new StringBuilder(10);
            StringBuilder MensagemErro = new StringBuilder(256);
            int           TotalRegistros;

            REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_BuscaHorarioVerao(REPZPM_DLL.Handle);

            if (REPZPM_DLL.ID_Comando > 0)
            {
                /**************************************************************************************************************************
                 * MODO PENDRIVE                                                                                                            *
                 ***************************************************************************************************************************/
                if (REPZPM_DLL.Modo == 1)
                {
                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_VerificaRetornoPenDrive(REPZPM_DLL.Handle, REPZPM_DLL.ID_Comando);

                    /*Verifica se o retorno já está disponível*/
                    if (REPZPM_DLL.Retorno < 0)
                    {
                        REPZPM_DLL.Retorno = REPZPM_DLL.Trata_Retorno_Pendrive(REPZPM_DLL.Retorno);

                        /*Verifica se o arquivo foi processado, 1 = OK*/
                        if (REPZPM_DLL.Retorno == 1)
                        {
                            /*Verifica no arquivo do pendrive se houve erro na execução do comando*/
                            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);

                            /*Comando executado*/
                            if (REPZPM_DLL.Retorno == 0)
                            {
                                MessageBox.Show("Comando executado com sucesso via pendrive!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                /*Verifica a quantidade de registros retornados*/
                                TotalRegistros = REPZPM_DLL.DLLREP_TotalRetornos(REPZPM_DLL.Handle);

                                /*Verifica se retornaram registros*/
                                if (TotalRegistros > 0)
                                {
                                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_RetornoHorarioVerao(REPZPM_DLL.Handle, DataInicio, DataFim);

                                    /*Sucesso na execução do comando*/
                                    if (REPZPM_DLL.Retorno == 1)
                                    {
                                        if ((Convert.ToString(DataInicio) == "0") && (Convert.ToString(DataFim) == "0"))
                                        {
                                            MessageBox.Show("Não há nenhum Horário de Verão definido!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            return;
                                        }
                                        else
                                        {
                                            MessageBox.Show("Data Início: " + DataInicio + "\nData Fim: " + DataFim, "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        /*Trata o retorno de erro do REP*/
                                        REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                                        MessageBox.Show(Convert.ToString(MensagemErro), "Erro DLL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                }
                                else
                                {
                                    /*Houve erro no retorno do comando via pendrive*/
                                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                                    MessageBox.Show(Convert.ToString(MensagemErro), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            /*Houve erro no processamento do arquivo do pendrive*/
                            REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1);
                            MessageBox.Show(Convert.ToString(MensagemErro), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }

                /**************************************************************************************************************************
                 * MODO IP                                                                                                                  *
                 ***************************************************************************************************************************/
                if (REPZPM_DLL.Modo == 0)
                {
                    /*Executa o comando de leitura*/
                    REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_RetornoHorarioVerao(REPZPM_DLL.Handle, DataInicio, DataFim);

                    /*Sucesso na execução*/
                    if (REPZPM_DLL.Retorno == 1)
                    {
                        if ((Convert.ToString(DataInicio) == "0") && (Convert.ToString(DataFim) == "0"))
                        {
                            MessageBox.Show("Não há nenhum Horário de Verão definido!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Data Início: " + DataInicio + "\n    DataFim: " + DataFim, "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    else
                    {
                        /*Trata o erro da execução do comando*/
                        REPZPM_DLL.Retorno = REPZPM_DLL.Trata_Retorno_REP(REPZPM_DLL.Retorno);
                        return;
                    }
                }
            }
            else
            {
                REPZPM_DLL.Retorno = REPZPM_DLL.Trata_Retorno_DLL(REPZPM_DLL.ID_Comando);
                return;
            }
        }