private void AtualizaForm()
        {
            if (ListAgenda != null)
            {
                ListAgenda.Clear();
            }

            ListAgenda = AgendaRepositorySQLite.GetAll().ToList <Agenda>();
            var a       = ListAgenda.OrderBy(p => p.PacienteNome).ThenBy(p => p.Data).ThenBy(p => p.Horas).ToList();
            var binding = new BindingList <Agenda>(a);

            grdAgenda.DataSource = binding;
            grdAgenda.Refresh();

            lblResults.Text = ListAgenda.Count.ToString() + " registros encontrados";

            var listaPaciente = ClienteRepositorySQLite.GetAll();
            AutoCompleteStringCollection dados = new AutoCompleteStringCollection();

            foreach (var item in listaPaciente)
            {
                dados.Add(item.Nome + " • " + item.Id);
            }

            txtPaciente.AutoCompleteCustomSource = dados;

            txtPaciente.Text    = "";
            txtDataInicial.Text = "__/__/____";
            txtDataFim.Text     = "__/__/____";
            txtHoraInicial.Text = "__:__";
            txtHoraInicial.Text = "__:__";

            FillDdl();
        }
Exemple #2
0
        private void btnAgendar_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtPaciente.Text.Trim()))
                {
                    txtPaciente.Focus();
                    throw new ErrorMessageException("Informe um paciente.");
                }

                GetFields();

                AgendaRepositorySQLite.Save(agenda);

                string message = string.Format(@"                                     === AGENDA ===
                                                 Paciente: {0} 
                                                 Data: {1} {2}Hrs
                                                 Tipo: {3}
                                               CRIADA COM SUCESSO!", agenda.PacienteNome, agenda.Data.ToString("dd/MM/yyyy"), agenda.Horas, agenda.Tipo);

                MessageBox.Show(message, "Agenda", MessageBoxButtons.OK, MessageBoxIcon.None);
                this.Close();
            }
            catch (ErrorMessageException eme)
            {
                MessageBox.Show(eme.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) { }
        }
Exemple #3
0
        private void btnSaveUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtPaciente.Text.Trim()))
                {
                    throw new ErrorMessageException("Informe um paciente.");
                }

                GetFields();
                AgendaRepositorySQLite.Update(agenda);

                MessageBox.Show("Atualização", "Agenda Atualizada.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.Close();
            }
            catch (Exception ex) { }
        }
Exemple #4
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string path = @"Clinica_01.Reports.AgendaReport.rdlc";

            if (this.reportViewer == null)
            {
                this.reportViewer = new ReportViewer();
            }

            var ListAgenda = AgendaRepositorySQLite.GetAll().ToList <Agenda>();

            this.reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", ListAgenda));

            FormReport frmReport = new FormReport(this.reportViewer, path, GetParametersToPrint());

            frmReport.ShowDialog();
        }
Exemple #5
0
        private void GetFields()
        {
            if (agenda == null)
            {
                agenda = new Agenda();
            }

            var hora = txtHora.Text.Replace(":", "").Trim();

            if (string.IsNullOrWhiteSpace(hora))
            {
                txtHora.Focus();
                throw new ErrorMessageException("Por gentileza, informe a Hora da consulta.");
            }
            DateTime hora02 = DateTime.Now;

            if (!DateTime.TryParse(txtHora.Text, out hora02))
            {
                txtHora.Focus();
                throw new ErrorMessageException("Hora da consulta inválida, verifique!");
            }

            if (txtPaciente.Text.Contains("•"))
            {
                agenda.PacienteNome = txtPaciente.Text.Split('•')[0];
                var idPaciente = 0;
                int.TryParse(txtPaciente.Text.Split('•')[1], out idPaciente);
                agenda.IdPaciente = idPaciente;
            }
            else
            {
                DialogResult result = MessageBox.Show("Paciente não cadastrado, deseja cadastrar? ", "Paciente não cadastrado", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    var clienteOldLast = clientRepository.LastId();

                    CadastroCliente frmCadastroCliente = new CadastroCliente(5, txtPaciente.Text);
                    frmCadastroCliente.ShowDialog();
                    var clienteOldLastOrDefault = clientRepository.LastId();

                    if (clienteOldLast.Id != clienteOldLastOrDefault.Id)
                    {
                        var listaPaciente = clientRepository.GetAll();
                        AutoCompleteStringCollection dados = new AutoCompleteStringCollection();
                        foreach (var item in listaPaciente)
                        {
                            dados.Add(item.Nome + " • " + item.Id);
                        }
                        txtPaciente.AutoCompleteCustomSource = dados;

                        txtPaciente.Text = clienteOldLastOrDefault.Nome + " • " + clienteOldLastOrDefault.Id;
                    }
                }
            }

            agenda.Data       = Convert.ToDateTime(dateTimePicker1.Text);
            agenda.Horas      = txtHora.Text.Trim();
            agenda.Tipo       = ddlTipo.Text;
            agenda.Observacao = txtObs.Text;
            if (!string.IsNullOrWhiteSpace(txtValor.Text.Trim()))
            {
                decimal valor = 0;

                if (!decimal.TryParse(txtValor.Text.Trim(), out valor))
                {
                    txtValor.Focus();
                    throw new ErrorMessageException("Valor da consulta inválido, verifique.");
                }

                agenda.Valor = valor;
            }

            if (string.IsNullOrWhiteSpace(ddlSituacao.SelectedText))
            {
                agenda.Situation = "Agendado";
            }
            else
            {
                agenda.Situation = ddlSituacao.SelectedText;
            }

            Agenda agendaOld = new Agenda();

            agendaOld = AgendaRepositorySQLite.GetAgenda(agenda.Data, agenda.Horas, agenda.Id);

            if (agendaOld != null)
            {
                if (string.IsNullOrWhiteSpace(agendaOld.Situation.Trim()) || agendaOld.Situation == "Agendado")
                {
                    throw new ErrorMessageException(string.Format("Já existe uma agenda para a data {0} - {1}", agenda.Data.ToString("dd/MM/yyyy"),
                                                                  agenda.Horas));
                }
            }
        }