public static void CreateTable() { var s = new Salas(); var p = new Pacientes(); NonQuery("Erro ao criar associação paciente-sala.", $"create table if not exists {Name} (" + $" {nameof(Funcionario)} varchar(15)," + $" {nameof(Paciente)} varchar(15) unique," + $" primary key ({nameof(Funcionario)})," + $" foreign key ({nameof(Funcionario)}) references {Salas.Name} ({nameof(s.Funcionario)}) on delete cascade on update cascade," + $" foreign key ({nameof(Paciente)}) references {Pacientes.Name} ({nameof(p.CPF)}) on delete cascade on update cascade " + $");"); }
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; //} }
public static Salas Select_Sala(string nome) { var c = new MySqlCommand(); c.CommandText = $"select * from {Name} where {nameof(Nome)} = @nome;"; c.Parameters.AddWithValue("@nome", nome); Salas salas = null; QueryRLoop("Erro ao obter sala através do nome da sala.", c, (r) => { salas = new Salas(); salas.Funcionario = r.GetString(0); salas.Nome = r.GetString(1); salas.Funcao = r.GetString(2); salas._Status = r.GetString(3); }); return(salas); }