Ejemplo n.º 1
0
        private void AtualizarGraficosGeral()
        {
            graficoCadastros.Titles[0].Text = "CADASTROS POR CATEGORIA - TODO O PERÍODO";
            graficoServicos.Titles[0].Text  = "SERVIÇOS POR CATEGORIA - TODO O PERÍODO";
            int cadastroAnimal      = _animalServico.Contagem();
            int cadastrosCliente    = _cadastroServico.Contagem(x => x.Discriminator == "Cliente");
            int cadastroVeterinario = _cadastroServico.Contagem(x => x.Discriminator == "Veterinario");
            int cadastroFuncionario = _cadastroServico.Contagem(x => x.Discriminator == "Funcionario");

            PreencherGraficoCadastros(cadastroAnimal, cadastrosCliente, cadastroVeterinario, cadastroFuncionario);

            int cadastroConsulta      = _atendimentoServico.Contagem(x => x.Tipo == "Consulta");
            int cadastroExame         = _atendimentoServico.Contagem(x => x.Tipo == "Exame");
            int cadastroVacina        = _atendimentoServico.Contagem(x => x.Tipo == "Vacina");
            int cadastroCirurgia      = _atendimentoServico.Contagem(x => x.Tipo == "Cirurgia");
            int cadastroInternamentos = _internamentoServico.Contagem();
            int cadastroReceitas      = _receitaServico.Contagem();

            PreencherGraficoServicos(cadastroConsulta, cadastroExame, cadastroVacina, cadastroCirurgia, cadastroInternamentos, cadastroReceitas);
        }
        private void VerificarPreenchimento()
        {
            if (_cadastro == null)
            {
                if (_cadastroServico.Contagem(x => x.Cpf == mbCpf.Text) != 0)
                {
                    throw new NaoPreenchidoException("JÁ EXISTE UM REGISTRO COM ESSE CPF!");
                }
            }

            ValidarPreenchimento.Validacao(errorProvider1, txtBairro, txtCidade, txtEmail, txtNome, txtNumero, txtRua, cbSexo, cbCadastro, mbEstado);

            string telefone = mbTelefone.Text.Replace("+", "").Replace("-", "").Replace("(", "").Replace(")", "").Replace(" ", "");
            string cep      = mbCep.Text.Replace("-", "").Replace(" ", "");

            if (string.IsNullOrEmpty(telefone) || telefone.Length != 13)
            {
                errorProvider1.SetError(mbTelefone, "O TELEFONE INSERIDO É INVÁLIDO");
                throw new NaoPreenchidoException("PREENCHIMENTO INVÁLIDO!");
            }
            else
            {
                errorProvider1.SetError(mbTelefone, null);
            }

            if (string.IsNullOrEmpty(cep) || cep.Length != 8)
            {
                errorProvider1.SetError(mbCep, "O TELEFONE INSERIDO É INVÁLIDO");
                throw new NaoPreenchidoException("PREENCHIMENTO INVÁLIDO!");
            }
            else
            {
                errorProvider1.SetError(mbCep, null);
            }

            if (!ValidarCPF.Valida(mbCpf.Text))
            {
                errorProvider1.SetError(mbCpf, "INFORME UM CPF VÁLIDO");
                throw new NaoPreenchidoException("O CPF INSERIDO NÃO É VÁLIDO!");
            }
            else
            {
                errorProvider1.SetError(mbCpf, null);
            }

            if (cbCadastro.Text == "Veterinário")
            {
                ValidarPreenchimento.Validacao(errorProvider1, txtAreasAtuacao, txtCrmv, txtEspecializacao, txtGraduacao, txtInstituicao, mbEstadoCRMV);
            }

            if (cbCadastro.Text == "Funcionário")
            {
                ValidarPreenchimento.Validacao(errorProvider1, txtSalario, txtCargo);
                if (numCargaHoraria.Value == 0)
                {
                    errorProvider1.SetError(numCargaHoraria, "INFORME A CARGA HORÁRIA DO FUNCIONÁRIO!");
                    throw new NaoPreenchidoException("UM OU MAIS CAMPOS OBRIGATÓRIOS NÃO PREENCHIDOS!");
                }
                else
                {
                    errorProvider1.SetError(numCargaHoraria, null);
                }
            }

            if (Convert.ToDateTime(dtNascimento.Text).Date >= DateTime.Now.Date)
            {
                errorProvider1.SetError(dtNascimento, "A DATA INSERIDA É INVÁLIDA!");
                throw new NaoPreenchidoException("PREENCHIMENTO INVÁLIDO!");
            }
            else
            {
                errorProvider1.SetError(dtNascimento, null);
            }
        }