/// <summary> /// id, procedimento, Convênio, valor /// </summary> /// <param name="procedimento"></param> /// <returns></returns> public static List <_ProcedimentoConvenio> SelectLike(string procedimento) { var pc = new ProcedimentoConvenio(); var c = new MySqlCommand(); c.CommandText = $"select " + $" a.{nameof(ID)}, " + $" a.{nameof(Procedimento)}, " + $" b.{nameof(pc.Convenio)}, " + $" b.{nameof(pc.Valor)}," + $" c.{nameof(Convenios.Convenio)} " + $"from {Name} as a " + $"inner join {ProcedimentoConvenio.Name} as b on a.{nameof(ID)} = b.{nameof(pc.Procedimento)} " + $"inner join {Convenios.Name} as c on b.{nameof(pc.Convenio)} = c.{nameof(Convenios.ID)} " + $"where a.{nameof(Procedimento)} like concat(@p, '%') " + $"limit 500;"; c.Parameters.AddWithValue("@p", procedimento); var lista = new List <_ProcedimentoConvenio>(); QueryRLoop($"Erro ao pesquisar na tabela {Name}. ({ErrorCodes.DB0008})", c, (r) => { lista.Add(new _ProcedimentoConvenio() { Proc_ID = r.GetInt32(0), Procedimento = r.IsDBNull(1)? null : r.GetString(1), Con_ID = r.IsDBNull(2)? -1 : r.GetInt32(2), Convenio = r.IsDBNull(4) ? null : r.GetString(4), Valor = r.IsDBNull(3)? double.NaN : r.GetDouble(3) }); }); return(lista); }
public static void CreateTable() { var le = new ListaEspera(); var pc = new ProcedimentoConvenio(); NonQuery($"Erro ao criar a associação de paciente e procedimentos.", $"create table if not exists {nameof(PacienteProcedimentos)} (" + $" {nameof(Senha)} int," + $" {nameof(Procedimento)} int," + $" {nameof(Convenio)} int," + $" {nameof(_Status)} enum('Pendente', 'Em andamento', 'Pronto')," + $" primary key ({nameof(Senha)}, {nameof(Procedimento)})," + $" foreign key ({nameof(Senha)}) references {ListaEspera.Name} ({nameof(le.Senha)}) on delete cascade on update cascade," + $" foreign key ({nameof(Procedimento)}, {nameof(Convenio)}) references {ProcedimentoConvenio.Name} ({nameof(pc.Procedimento)}, {nameof(pc.Convenio)}) 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; //} }