//metodos para inserir na tabela public bool cadastrarPaciente(string email, string senha, string cpf, string nome, string foto, string dt_aniversario) { //ACESSO////////////////////////////////// StringBuilder query = new StringBuilder(); var session = new DBSession(); query.Append(" INSERT INTO acesso"); query.Append(" VALUES ("); query.AppendFormat(" '{0}', ", email); query.AppendFormat(" '{0}', ", senha); query.AppendFormat(" '{0}') ", "Paciente"); Query executar = session.CreateQuery(query.ToString()); try { executar.ExecuteNonQuery(); } catch { return(false); //insercao nao deu certo } //PACIENTE/////////////////////////////////////// query.Clear(); //Limpar para fazer outra inserção query.Append(" INSERT INTO Paciente"); query.Append(" VALUES ("); query.AppendFormat(" '{0}', ", cpf); query.AppendFormat(" '{0}', ", nome); query.AppendFormat(" '{0}', ", email); query.AppendFormat(" '{0}', ", foto); query.AppendFormat(" '{0}') ", dt_aniversario); executar = session.CreateQuery(query.ToString()); try { executar.ExecuteNonQuery(); } catch { return(false); //insercao nao deu certo } return(true); //insercao deu certo }
public bool cadastrarMedico(string email, string senha, string cpf, string nome, string foto, string dt_nascimento, string crm, int id_esp) { StringBuilder query = new StringBuilder(); var session = new DBSession(); query.Append(" INSERT INTO acesso"); query.Append(" VALUES ("); query.AppendFormat(" '{0}', ", email); query.AppendFormat(" '{0}', ", senha); query.AppendFormat(" '{0}') ", "Medico"); Query executar = session.CreateQuery(query.ToString()); try { executar.ExecuteNonQuery(); } catch { return(false); //insercao nao deu certo } query.Clear(); //Limpar para fazer outra inserção query.Append(" INSERT INTO Medico"); query.Append(" VALUES ("); query.AppendFormat(" '{0}', ", cpf); query.AppendFormat(" '{0}', ", nome); query.AppendFormat(" '{0}', ", email); query.AppendFormat(" '{0}', ", foto); query.AppendFormat(" '{0}', ", dt_nascimento); query.AppendFormat(" '{0}', ", crm); query.AppendFormat(" '{0}') ", id_esp); executar = session.CreateQuery(query.ToString()); try { executar.ExecuteNonQuery(); } catch { return(false); //insercao nao deu certo } return(true); //insercao deu certo }
public String cpfPaciente(String email) { StringBuilder query = new StringBuilder(); var session = new DBSession(); query.Append(" SELECT m.cpf"); query.Append(" FROM Paciente m "); query.Append(" WHERE (1=1) AND "); query.AppendFormat(" m.email = '{0}' ", email); Query executar = session.CreateQuery(query.ToString()); IDataReader reader = executar.ExecuteQuery(); //verificar se ele encontrou algum registro no banco de dados if (reader.Read()) { return(reader["cpf"].ToString()); } return("000"); }
public String id(String email, String tabela) { StringBuilder query = new StringBuilder(); var session = new DBSession(); query.Append(" SELECT u.cpf"); query.AppendFormat(" FROM {0} u ", tabela); query.Append(" WHERE (1=1) "); query.AppendFormat(" AND u.email = '{0}'", email); Query executar = session.CreateQuery(query.ToString()); IDataReader reader = executar.ExecuteQuery(); //verificar se ele encontrou algum registro no banco de dados if (reader.Read()) { return(reader["cpf"].ToString()); } return("0"); }
public bool cadastrarEspecialidade(string nomeEsp) { StringBuilder query = new StringBuilder(); var session = new DBSession(); query.Append(" INSERT INTO Especialidade"); query.Append(" VALUES ("); query.AppendFormat(" '{0}')", nomeEsp); Query executar = session.CreateQuery(query.ToString()); try { executar.ExecuteNonQuery(); } catch { return(false); //insercao nao deu certo } return(true); //insercao deu certo }