コード例 #1
0
        public List <ClasePaciente> MostrarHistorial(ClasePaciente paciente)
        {
            sqlConnection.Open();

            try
            {
                SqlCommand sqlCommand = new SqlCommand("MostrarHistorial", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.AddWithValue("@idpaciente", paciente.Id_paciente);
                SqlDataReader reader = sqlCommand.ExecuteReader();

                List <ClasePaciente> pacientes = new List <ClasePaciente>();

                while (reader.Read())
                {
                    pacientes.Add(new ClasePaciente {
                        Fecha = Convert.ToDateTime(reader["fecha"].ToString()), NombreTratamiento = reader["tratamiento"].ToString()
                    });
                }

                return(pacientes);
            }
            catch
            {
                throw;
            }
            finally
            {
                sqlConnection.Close();
            }
        }
コード例 #2
0
 public void AgregarPaciente(ClasePaciente paciente)
 {
     sqlConnection.Open();
     try
     {
         SqlCommand sqlCommand = new SqlCommand("IngresoPacientes", sqlConnection);
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.AddWithValue("@id", paciente.Id_paciente);
         sqlCommand.Parameters.AddWithValue("@nombre", paciente.NombrePaciente);
         sqlCommand.Parameters.AddWithValue("@apellido", paciente.ApellidoPaciente);
         sqlCommand.Parameters.AddWithValue("@telefono", paciente.Telefono);
         sqlCommand.Parameters.AddWithValue("@edad", paciente.Edad);
         sqlCommand.Parameters.AddWithValue("@genero", paciente.Genero);
         sqlCommand.Parameters.AddWithValue("@estado", 1);
         sqlCommand.ExecuteNonQuery();
     }
     catch
     {
         throw;
     }
     finally
     {
         sqlConnection.Close();
     }
 }
コード例 #3
0
        /// <summary>
        /// Metodo para actualizar los datos del paciente seleccionado
        /// </summary>
        /// <returns>Lista de todos los datos de los pacientes</returns>
        public void ActualizarDatosPaciente(ClasePaciente paciente)
        {
            try
            {//Abrir la conexion sql
                sqlConnection.Open();
                //crear el comando SQL
                SqlCommand sqlCommand = new SqlCommand("EditarPacientes", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                //Definir las variables del procedimiento mediante los parametros obtenidos
                sqlCommand.Parameters.AddWithValue("@id", paciente.Id_paciente);
                sqlCommand.Parameters.AddWithValue("@nombre", paciente.NombrePaciente);
                sqlCommand.Parameters.AddWithValue("@apellido", paciente.ApellidoPaciente);
                sqlCommand.Parameters.AddWithValue("@telefono", paciente.Telefono);
                sqlCommand.Parameters.AddWithValue("@edad", paciente.Edad);
                sqlCommand.Parameters.AddWithValue("@genero", paciente.Genero);
                sqlCommand.ExecuteNonQuery();
            }

            catch (Exception e)
            {
                throw e;
            }

            finally
            {
                sqlConnection.Close();
            }
        }