Example #1
0
        public static void CreateTable()
        {
            var a  = new Agendamentos();
            var tp = new TempPacientes();

            NonQuery("Erro ao criar associação de agendamento-tempPaciente",
                     $"create table if not exists {Name} (" +
                     $"  {nameof(Agendamento)} int," +
                     $"  {nameof(TempPaciente)} nvarchar(50)," +
                     $"  primary key ({nameof(Agendamento)})," +
                     $"  foreign key ({nameof(Agendamento)}) references {Agendamentos.Name} ({nameof(a.ID)}) on delete cascade on update cascade," +
                     $"  foreign key ({nameof(TempPaciente)}) references {TempPacientes.Name} ({nameof(tp.Nome)}) on delete cascade on update cascade" +
                     $");");
        }
Example #2
0
        public static void EnsureCreation()
        {
            //try {
            SQLOperations.MessageExceptions = true;
            SQLOperations.ThrowExceptions   = true;
            //SQLOperations.NonQuery("Erro ao criar banco de dados.", $"create database if not exists {Name};");
            Pessoas.p.CreateTable();
            Pacientes.CreateTable();
            Funcionarios.CreateTable();
            Medicos.CreateTable();
            Recepcionista.CreateTable();
            Tecnico_Enfermagem.CreateTable();
            (new Administradores()).GetCT()();
            TempPacientes.CreateTable();
            ListaEspera.CreateTable();
            Salas.CreateTable();
            Paciente_Sala.CreateTable();
            Convenios.CreateTable();
            ProcedimentosLab.CreateTable();
            ProcedimentoConvenio.CreateTable();
            PacienteProcedimentos.CreateTable();
            Enderecos.CreateTable();
            Anexos.CreateTable();
            Especializacoes.CreateTable();
            MedicoEspecializacoes.CreateTable();
            Agendamentos.CreateTable();
            AgendamentoPaciente.CreateTable();
            AgendamentoTempPaciente.CreateTable();
            AgendamentoFuncionario.CreateTable();
            ListaEspera_Funcionario.CreateTable();
            ListaEspera_Especializacao.CreateTable();
            Historico_Consultas.CreateTable();
            Historico_ProcedimentosLab.CreateTable();
            Pagamentos.CreateTable();
            //Fonoaudiologos.CreateTable();
            Nutricionistas.CreateTable();
            Psicologos.CreateTable();
            Ausentes.CreateTable();

            /*} catch (Exception ex) {
             *  MessageBox.Show(ex.Message);
             * }
             * finally {*/
            SQLOperations.ThrowExceptions = false;
            //}
        }
Example #3
0
        public static Agendamentos Select(int id)
        {
            var a = new Agendamentos();
            var c = new MySqlCommand();

            c.CommandText = $"select {nameof(_Data)}, {nameof(Inicio)}, {nameof(Fim)} from {Name} where {nameof(ID)} = @id";
            c.Parameters.AddWithValue("@id", id);
            QueryR("Erro ao busca em agendamentos", c, (r) => {
                if (r.Read())
                {
                    var dt   = r.GetMySqlDateTime(0);
                    a._Data  = dt.GetDateTime();
                    a.Inicio = Database.GetTimeSpan(r.GetString(1));
                    a.Fim    = Database.GetTimeSpan(r.GetString(2));
                }
                else
                {
                    a = null;
                }
            });
            return(a);
        }
Example #4
0
        public static List <Agendamentos> Select(DateTime begin, DateTime end, string medico = null)
        {
            var agendamento = new AgendamentoFuncionario();
            var c           = new MySqlCommand();
            var a           = "";
            var b           = "";

            if (medico != null)
            {
                a = $"inner join {AgendamentoFuncionario.Name} as b on a.{nameof(ID)} = b.{nameof(agendamento.Agendamento)}";
                b = $" and b.{nameof(agendamento.Funcionario)} = @medico";
            }
            c.CommandText = $"select * " +
                            $"from {Name} as a " +
                            $"{a} " +
                            $"where ({nameof(_Data)} between @begin and @end) {b};";
            c.Parameters.AddWithValue("@begin", begin.ToString("yyyy-MM-dd"));
            c.Parameters.AddWithValue("@end", end.ToString("yyyy-MM-dd"));
            if (medico != null)
            {
                c.Parameters.AddWithValue("@medico", medico);
            }
            var result = new List <Agendamentos>();

            QueryR("Erro ao pesquisar agendamentos.", c, (r) => {
                while (r.Read())
                {
                    var agen = new Agendamentos {
                        ID     = r.GetInt32(0),
                        _Data  = r.GetMySqlDateTime(1).GetDateTime(),
                        Inicio = Database.GetTimeSpan(r.GetString(2)),
                        Fim    = Database.GetTimeSpan(r.GetString(3))
                    };
                    result.Add(agen);
                }
            });
            return(result);
        }