Exemplo n.º 1
0
        public DPFDadosPacienteModel ConsultarDadosPacientePreencherPDF(int idPaciente)
        {
            try {
                MySqlConnection connection = new MySqlConnection(getStringConnection());
                connection.Open();

                var          DALSQL           = new PDFDALSQL();
                MySqlCommand cmdDadosPaciente = new MySqlCommand(DALSQL.ConsultarDadosPacientePreencherPDF(), connection);

                cmdDadosPaciente.Parameters.AddWithValue("@IDPACIENTE", idPaciente);

                var teste = getGeneratedSql(cmdDadosPaciente);

                MySqlDataReader       reader        = cmdDadosPaciente.ExecuteReader();
                DPFDadosPacienteModel dadosPaciente = new DPFDadosPacienteModel();
                dadosPaciente.ListPaciente = new List <ListPaciente>();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ListPaciente paciente = new ListPaciente();

                        if (dadosPaciente.nome == null || dadosPaciente.nome == string.Empty)
                        {
                            dadosPaciente.nome = reader.GetString(0);
                        }
                        if (dadosPaciente.rg == null || dadosPaciente.rg == string.Empty)
                        {
                            dadosPaciente.rg = reader.GetString(1);
                        }
                        if (dadosPaciente.dataNascimento == null || dadosPaciente.dataNascimento != default(DateTime))
                        {
                            dadosPaciente.dataNascimento = reader.GetDateTime(2);
                        }

                        paciente.dataConsulta = reader.GetDateTime(3);
                        paciente.status       = reader.GetInt32(4);

                        dadosPaciente.ListPaciente.Add(paciente);
                    }
                    reader.Close();
                    connection.Close();
                }
                else
                {
                    dadosPaciente = null;
                    reader.Close();
                    connection.Close();
                }

                return(dadosPaciente);
            } catch (Exception ex) {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public RelatorioPacienteModel RelatorioPaciente(RelatorioPacienteModel paciente, int idMedico)
        {
            try {
                var DALSQL = new PacienteDALSQL();
                using (MySqlConnection connection = new MySqlConnection(getStringConnection())) {
                    connection.Open();

                    MySqlCommand cmdPaciente = new MySqlCommand(DALSQL.RelatorioPaciente(paciente), connection);

                    cmdPaciente.Parameters.Add("@IDMEDICO", MySqlDbType.Int32).Value = idMedico;

                    if (paciente.psqNome != string.Empty && paciente.psqNome != null)
                    {
                        cmdPaciente.Parameters.Add("@NOME", MySqlDbType.String).Value = paciente.psqNome;
                    }
                    if (paciente.psqCPF != string.Empty && paciente.psqCPF != null)
                    {
                        cmdPaciente.Parameters.Add("@CPF", MySqlDbType.String).Value = paciente.psqCPF;
                    }
                    if (paciente.psqCPF != string.Empty && paciente.psqTelefoneCelular != null)
                    {
                        cmdPaciente.Parameters.Add("@TELEFONECELULAR", MySqlDbType.String).Value = paciente.psqTelefoneCelular;
                    }

                    var teste2 = getGeneratedSql(cmdPaciente);

                    MySqlDataReader reader = cmdPaciente.ExecuteReader();

                    RelatorioPacienteModel relatorioPacienteModel = new RelatorioPacienteModel();
                    relatorioPacienteModel.ListaPacientes = new List <ListPaciente>();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            ListPaciente pacienteModel = new ListPaciente();

                            pacienteModel.idPaciente      = reader.GetInt32(0);
                            pacienteModel.nome            = reader.GetString(1);
                            pacienteModel.cpf             = reader.GetString(2);
                            pacienteModel.telefoneCelular = reader.GetString(3);

                            relatorioPacienteModel.ListaPacientes.Add(pacienteModel);
                        }
                        reader.NextResult();
                    }
                    else
                    {
                        reader.Close();
                        connection.Close();
                        return(null);
                    }

                    reader.Close();
                    connection.Close();

                    return(relatorioPacienteModel);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }