public PaginaAgendamento()
 {
     InitializeComponent();
     _agendamentoServico   = new AgendamentoServico();
     _animalServico        = new AnimalServico();
     cbStatus.SelectedItem = "Pendente";
 }
 private void AtualizarCbAgendamentos()
 {
     cbAgendamento.Enabled = true;
     cbAgendamento.Items.Clear();
     _agendamentoServico = new AgendamentoServico();
     foreach (var item in _agendamentoServico.Buscar(x => x.DataAtendimento.Date == DateTime.Today.Date && x.Tipo == cbTipo.Text))
     {
         cbAgendamento.Items.Add(item.AgendamentoID + " - " + item.DataAtendimento.ToShortDateString() + " " + item.DataAtendimento.ToShortTimeString() + ". " + item.Animal.Nome);
     }
 }
Ejemplo n.º 3
0
 private void BuscarData()
 {
     _agendamentoServico = new AgendamentoServico();
     if (cbStatus.Text == "Todos")
     {
         PreencherDataGrid(_agendamentoServico.Buscar(x => x.DataAtendimento.Date == dtPesquisa.Value.Date && x.Tipo == cbTipo.Text));
     }
     else
     {
         PreencherDataGrid(_agendamentoServico.Buscar(x => x.DataAtendimento.Date == dtPesquisa.Value.Date && x.Tipo == cbTipo.Text && x.Status == cbStatus.Text));
     }
 }
        private void CbAgendamento_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            _agendamentoServico = new AgendamentoServico();
            Agendamento agendamento = _agendamentoServico.Buscar(x => x.AgendamentoID == Convert.ToInt64(cbAgendamento.Text.Split(' ')[0])).FirstOrDefault();

            if (agendamento != null)
            {
                cbPaciente.Text = agendamento.Animal.AnimalID + " - " + agendamento.Animal.Nome + ". " + agendamento.Animal.Raca;
                dtHora.Text     = agendamento.DataAtendimento.ToShortTimeString();
                txtResumo.Text  = agendamento.Resumo;
            }
        }
Ejemplo n.º 5
0
 private Agendamento AgendamentoSelecionado()
 {
     try
     {
         int id = Convert.ToInt32(dgvRegistros.CurrentRow.Cells[0].Value.ToString());
         _agendamentoServico = new AgendamentoServico();
         return(_agendamentoServico.Buscar(x => x.AgendamentoID == Convert.ToInt32(id)).FirstOrDefault());
     }
     catch (Exception)
     {
         MessageBox.Show("Selecione um cadastro primeiro!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.None);
         return(null);
     }
 }
Ejemplo n.º 6
0
        private void BtnExcluir_Click(object sender, EventArgs e)
        {
            Agendamento agendamento = AgendamentoSelecionado();

            if (agendamento != null)
            {
                if (MessageBox.Show("TEM CERTEZA QUE DESEJA APAGAR ESSE REGISTRO?\n\nOBS:\nESSA AÇÃO NÃO PODE SER DESFEITA!\nDADOS ASSOCIADOS TAMBÉM SERÃO APAGADOS!", "ATENÇÃO!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    _agendamentoServico = new AgendamentoServico();
                    _agendamentoServico.Excluir(agendamento);
                    dgvRegistros.Rows.Clear();
                }
            }
        }
Ejemplo n.º 7
0
 private void BtnPesquisar_Click(object sender, EventArgs e)
 {
     try
     {
         if (cbCriterio.Text == "" || cbPesquisa.Text == "")
         {
             MessageBox.Show("Um ou mais campos da pesquisa estão incompletos!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             _agendamentoServico = new AgendamentoServico();
             if (cbStatus.Text == "Todos")
             {
                 if (cbCriterio.Text == "ID")
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.AgendamentoID == Convert.ToInt32(cbPesquisa.Text) && x.Tipo == cbTipo.Text));
                 }
                 else if (cbCriterio.Text == "Paciente")
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.Animal.Nome.Contains(cbPesquisa.Text) && x.Tipo == cbTipo.Text));
                 }
                 else
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.Animal.Cadastro.Nome.Contains(cbPesquisa.Text) && x.Tipo == cbTipo.Text));
                 }
             }
             else
             {
                 if (cbCriterio.Text == "ID")
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.AgendamentoID == Convert.ToInt32(cbPesquisa.Text) && x.Tipo == cbTipo.Text && x.Status == cbStatus.Text));
                 }
                 else if (cbCriterio.Text == "Paciente")
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.Animal.Nome.Contains(cbPesquisa.Text) && x.Tipo == cbTipo.Text && x.Status == cbStatus.Text));
                 }
                 else
                 {
                     PreencherDataGrid(_agendamentoServico.Buscar(x => x.Animal.Cadastro.Nome.Contains(cbPesquisa.Text) && x.Tipo == cbTipo.Text && x.Status == cbStatus.Text));
                 }
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("O conteúdo inserido não é válido para a pesquisa!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
 private void AtualizarStatusAgendamento()
 {
     if (cbAgendamento.Text != "")
     {
         try
         {
             long id = Convert.ToInt64(cbAgendamento.Text.Split(' ')[0]);
             _agendamentoServico = new AgendamentoServico();
             Agendamento agendamento = _agendamentoServico.Buscar(x => x.AgendamentoID == id).FirstOrDefault();
             agendamento.Status = "Concluído";
             _agendamentoServico.Editar(agendamento);
         }
         catch (Exception)
         {
         }
     }
 }
        ////////////////////////////////////// APAGAR CADASTRO /////////////////////////////////////////////
        private void BtnDeletar_Click(object sender, EventArgs e)
        {
            try
            {
                _internamentoServico = new InternamentoServico();
                if (_internamentoServico.Buscar(x => x.AnimalID == _animal.AnimalID && x.DataSaida == null).Count != 0)
                {
                    throw new AcaoProibidaException("NÃO É POSSÍVEL EXCLUIR O REGISTRO DE UM ANIMAL  QUE ESTÁ INTERNADO!");
                }
                if (MessageBox.Show("TEM CERTEZA QUE DESEJA APAGAR ESSE REGISTRO?\n\nOBS:\nESSA AÇÃO NÃO PODE SER DESFEITA!\nINFORMAÇÔES REFERENTES A CONSULTAS, EXAMES, RECEITAS E OUTROS TAMBÉM SERÃO APAGADOS!", "ATENÇÃO!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    AtendimentoServico atendimentoServico = new AtendimentoServico();
                    foreach (var item in atendimentoServico.Buscar(x => x.AnimalID == _animal.AnimalID))
                    {
                        atendimentoServico.Excluir(item);
                    }
                    InternamentoServico internamentoServico = new InternamentoServico();
                    foreach (var item in internamentoServico.Buscar(x => x.AnimalID == _animal.AnimalID))
                    {
                        internamentoServico.Excluir(item);
                    }
                    ReceitaServico receitaServico = new ReceitaServico();
                    foreach (var item in receitaServico.Buscar(x => x.AnimalID == _animal.AnimalID))
                    {
                        receitaServico.Excluir(item);
                    }
                    AgendamentoServico agendamentoServico = new AgendamentoServico();
                    foreach (var item in agendamentoServico.Buscar(x => x.AnimalID == _animal.AnimalID))
                    {
                        agendamentoServico.Excluir(item);
                    }

                    _animalServico = new AnimalServico();
                    _animalServico.Excluir(_animal);
                    MessageBox.Show("REGISTRO APAGADO!", "INFO", MessageBoxButtons.OK, MessageBoxIcon.None);
                    Close();
                }
            }
            catch (AcaoProibidaException erro)
            {
                MessageBox.Show($"ATENÇÃO!\n\n{erro.Message}", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }