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; //} }
/// <summary> /// Obtem a instencia de 'Medicos' com as informações references ao cpf dado. /// </summary> /// <param name="cpf"></param> /// <returns></returns> public static Medicos Select(string cpf) { var c = new MySqlCommand(); c.CommandText = $"select * from {Name} where {nameof(CPF)} = @cpf limit 100;"; c.Parameters.AddWithValue("@cpf", cpf); Medicos m = null; QueryRLoop("Erro ao obter médico.", c, (r) => { m = new Medicos() { CPF = r.GetString(0), CRM = r.GetString(1), Porcentagem = r.GetString(2) }; }); return(m); }
/// <summary> /// CPF, Nome, Sexo, Nascimento, Ativo, Administrador, Recepcionista, Tecnico_Enfermagem, Medico /// </summary> /// <param name="cpf"></param> /// <param name="nome"></param> /// <returns></returns> public static List <string[]> Select(string cpf, string nome) { var p = new Pessoas(); var aa = new Administradores(); var bb = new Recepcionista(); var cc = new Tecnico_Enfermagem(); var d = new Medicos(); var c = new MySqlCommand(); c.CommandText = $"select a.{nameof(CPF)}, {nameof(p.Nome)}, {nameof(p.Sexo)}, {nameof(p.Nascimento)}, {nameof(Ativo)}, c.cpf, d.{nameof(bb.CPF)}, e.{nameof(cc.CPF)}, f.{nameof(d.CPF)} " + $"from {Name} as a " + $"inner join {Pessoas.p.TableName} as b on a.{nameof(CPF)} = b.{nameof(p.CPF)} " + $"left join {aa.TableName} as c on a.{nameof(CPF)} = c.cpf " + $"left join {Recepcionista.Name} as d on a.{nameof(CPF)} = d.{nameof(bb.CPF)} " + $"left join {Tecnico_Enfermagem.Name} as e on a.{nameof(CPF)} = e.{nameof(cc.CPF)} " + $"left join {Medicos.Name} as f on a.{nameof(CPF)} = f.{nameof(d.CPF)} " + $"where a.{nameof(CPF)} like concat(@cpf, '%') and {nameof(p.Nome)} like concat(@nome, '%');"; c.Parameters.AddWithValue("@cpf", cpf); c.Parameters.AddWithValue("@nome", nome); List <string[]> a = new List <string[]>(); QueryR($"Erro ao obter registros da tabela {Name}.", c, (r) => { while (r.Read()) { var b = new string[r.FieldCount]; int i = 0; b[i++] = r.GetString(0); b[i++] = r.GetString(1); b[i++] = r.GetBoolean(2) ? "M" : "F"; var dt = r.GetMySqlDateTime(3); b[i++] = $"{dt.Day}/{dt.Month}/{dt.Year}"; b[i++] = r.GetBoolean(4) ? "Ativo" : "Inativo"; b[i++] = r.IsDBNull(5) ? "✗" : "✓"; b[i++] = r.IsDBNull(6) ? "✗" : "✓"; b[i++] = r.IsDBNull(7) ? "✗" : "✓"; b[i++] = r.IsDBNull(8) ? "✗" : "✓"; a.Add(b); } }); return(a); }