Example #1
0
        private void txtUser_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && (e.KeyChar != 8) && (!char.IsLetter(e.KeyChar)))
            {
                e.Handled = true;
            }


            switch (cmbHist.selectedIndex)
            {
            case 0:
            {
                carregaGrid();

                break;
            }

            case 1:
                dtoVar.idMaquina = (txtUser.Text);
                try
                {
                    List <histDto> ListDto = new List <histDto>();
                    ListDto            = new histBLL().listarId(dtoVar);
                    dgvHist.DataSource = ListDto;

                    Pintalinhas();
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro Inexperado, contate o T.I.", "Erro de conexão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case 2:
                dtoVar.professor = (txtUser.Text);
                try
                {
                    List <histDto> ListDto = new List <histDto>();
                    ListDto            = new histBLL().listarProf(dtoVar);
                    dgvHist.DataSource = ListDto;

                    Pintalinhas();
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro Inexperado, contate o T.I.", "Erro de conexão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;
            }
        }
Example #2
0
        private void cmbHist_onItemSelected(object sender, EventArgs e)
        {
            if (cmbHist.selectedIndex == 0)
            {
                txtUser.Text    = "Escolha um método de pesquisa";
                txtUser.Enabled = false;
            }
            else if (cmbHist.selectedIndex == 3)
            {
                txtUser.Enabled = false;
                txtUser.Text    = "Data mais antiga";
                try
                {
                    List <histDto> ListDto = new List <histDto>();
                    ListDto            = new histBLL().listaPorData();
                    dgvHist.DataSource = ListDto;

                    Pintalinhas();
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro Inexperado, contate o T.I.", "Erro de conexão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (cmbHist.selectedIndex == 4)
            {
                txtUser.Enabled = false;
                txtUser.Text    = "Data mais atual";
                try
                {
                    List <histDto> ListDto = new List <histDto>();
                    ListDto            = new histBLL().listaPorDataAtual();
                    dgvHist.DataSource = ListDto;

                    Pintalinhas();
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro Inexperado, contate o T.I.", "Erro de conexão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                txtUser.Clear();
                txtUser.Enabled = true;
                txtUser.Focus();
            }
        }
Example #3
0
        private void carregaGrid()
        {
            dgvHist.AutoGenerateColumns = false;
            try
            {
                List <histDto> ListDto = new List <histDto>();
                ListDto = new histBLL().listarTudo();


                dgvHist.DataSource = ListDto;

                Pintalinhas();
            }
            catch (Exception erro)
            {
                MessageBox.Show("Falha ao conectar com o banco de dados, por favor enre em contato com o T.I.", "Erro de conexão", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }