public IList <Pacientes> BuscaPorNome(string nome) { SqlCommand comando = new SqlCommand(); comando.CommandType = System.Data.CommandType.Text; comando.CommandText = "Select * from Pacientes where NOME like @NOME"; comando.Parameters.AddWithValue("@NOME", "%" + nome + "%"); SqlDataReader dr = Conexao.Selecionar(comando); IList <Pacientes> pacientes = new List <Pacientes>(); if (dr.HasRows) { while (dr.Read()) { Pacientes paciente = new Model.Pacientes(); paciente.nome = (string)dr["NOME"]; paciente.cpf = (int)dr["CPF"]; paciente.rg = (int)dr["RG"]; paciente.sangue = (char)dr["SANGUE"]; paciente.sexo = (char)dr["SEXO"]; paciente.coments = (string)dr["COMENTS"]; paciente.senha = (string)dr["SENHA"]; pacientes.Add(paciente); } } else { pacientes = null; } return(pacientes); }
public Pacientes BuscarPorCPF(int cpf) { SqlCommand comando = new SqlCommand(); comando.CommandType = System.Data.CommandType.Text; comando.CommandText = "Select * from Pacientes Where CPF=@CPF"; comando.Parameters.AddWithValue("@CPF", cpf); SqlDataReader dr = Conexao.Selecionar(comando); Pacientes paciente = new Model.Pacientes(); if (dr.HasRows) { dr.Read(); paciente.nome = (string)dr["NOME"]; paciente.cpf = (int)dr["CPF"]; paciente.rg = (int)dr["RG"]; paciente.sangue = (char)dr["SANGUE"]; paciente.sexo = (char)dr["SEXO"]; paciente.coments = (string)dr["COMENTS"]; paciente.senha = (string)dr["SENHA"]; } else { paciente = null; } return(paciente); }
//public static void guardarPaciente(Model.Pacientes paciente) public static void guardarPaciente(string nombre, string apPaterno, string apMaterno, string fechaNacimiento, string Edad, string genero, string Horario, string turnoid, string Motivo, string MedioDifusion, bool activo, string NombreTutor, string TelefonoTutor, string ViaContactoTutor, string ParentezcoTutor, string IdDerivado) { try { var uow = new UnitOfWork(); Model.Pacientes paciente = new Model.Pacientes(); var userId = Int32.Parse(HttpContext.Current.Session["userID"].ToString()); paciente.Nombre = nombre; paciente.ApPaterno = apPaterno; paciente.ApMaterno = apMaterno; paciente.FechaNacimiento = fechaNacimiento; paciente.Edad = Edad != "" ? Convert.ToInt32(Edad): 0; paciente.Genero = genero; paciente.Horario = Horario; paciente.IdTurno = turnoid != "" ? Convert.ToInt16(turnoid) : (short?)null; paciente.Motivo = Motivo; paciente.MedioDifusion = MedioDifusion; paciente.Activo = activo; paciente.IdUsuarioRegistro = userId;// Queries.GetCurrentUser().ID; paciente.FechaRegistro = DateTime.Now; paciente.IdDerivado = Convert.ToInt16(IdDerivado); Model.Tutores Tutores = new Model.Tutores(); Tutores.Nombre = NombreTutor; Tutores.Telefono = TelefonoTutor; Tutores.ViaContacto = ViaContactoTutor; Tutores.Parentezco = ParentezcoTutor; //pendiente guardar tutores uow.TutoresRepository.Add(Tutores); paciente.IdTutor = Tutores.ID; uow.PacientesRepository.Add(paciente); uow.Save(); } catch (Exception ex) { Log.Error("[ System ] " + " [ Page ] " + "[ " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name.ToString() + " ] [ " + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() + " ] [ Fin ]", ex); throw; } }
public PacienteLogic() { context = new Model.DB_DMAEntities(); pacientesModel = new Model.Pacientes(); }