예제 #1
0
        public static List<Paciente> GetAll()
        {
            DBConnect db = new DBConnect();
            try
            {
                List<Paciente> pacientes = new List<Paciente>();
                string query = "SELECT * FROM pacientes;";
                //Open connection
                db.OpenConnection();

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, db.connection);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    var paciente = new Paciente();
                    paciente.cod_paciente = Convert.ToInt32(dataReader["cod_paciente"]);
                    paciente.nombre = Convert.ToString(dataReader["nombre"]);
                    paciente.Apellido = Convert.ToString(dataReader["Apellido"]);
                    paciente.ObraSocial = Convert.ToString(dataReader["obraSocial"]);
                    paciente.Sexo = Convert.ToString(dataReader["sexo"]);
                    pacientes.Add(paciente);

                }

                dataReader.Close();

                db.CloseConnection();
                return pacientes;
            }
            catch (Exception ex)
            {
                db.CloseConnection();
                throw new Exception(ex.Message);
            }
            finally
            {
                if (db.OpenConnection() == true)
                {
                    db.CloseConnection();
                };
            }
        }
예제 #2
0
        public static List<Estudio> GetAll()
        {
            DBConnect db = new DBConnect();
            try
            {
                List<Estudio> estudios = new List<Estudio>();
                string query = "SELECT * FROM Estudios;";
                //Open connection
                db.OpenConnection();

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, db.connection);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    var estudio = new Estudio();
                    estudio.cod_estudio = Convert.ToInt32(dataReader["cod_estudio"]);
                    estudio.desc_estudio = Convert.ToString(dataReader["desc_estudio"]);
                    estudios.Add(estudio);

                }

                dataReader.Close();

                db.CloseConnection();
                return estudios;
            }
            catch (Exception ex)
            {
                db.CloseConnection();
                throw new Exception(ex.Message);
            }
            finally {
                if (db.OpenConnection() == true) {
                    db.CloseConnection();
                };
            }
        }
예제 #3
0
 public static void Update(int cod_estudio, string desc_estudio)
 {
     string query = "UPDATE estudios SET desc_estudio=" + "'" + desc_estudio + "'" + " WHERE cod_estudio = " + cod_estudio + ";";
     DBConnect db = new DBConnect();
     db.Update(query);
 }
예제 #4
0
 public static void Insert(string desc_estudio)
 {
     var query = "INSERT INTO estudios (desc_estudio, estado_estudio) VALUES( " + "'" + desc_estudio + "'" + ", true)";
     DBConnect db = new DBConnect();
     db.Insert(query);
 }
예제 #5
0
 public static void Update(int cod_paciente, string nombre, string apellido)
 {
     string query = "UPDATE pacientes SET nombre=" + "'" + nombre + "'" + ", " + "Apellido = " + "'" + apellido + "'" + " WHERE cod_paciente = " + cod_paciente + ";";
     DBConnect db = new DBConnect();
     db.Update(query);
 }
예제 #6
0
 public static void Insert(string nombre, string apellido)
 {
     DBConnect db = new DBConnect();
     var query = "INSERT INTO pacientes (nombre, Apellido, sexo) VALUES( " + "'" + nombre + "'" + ", " + "'" + apellido + "'" + ", 'Femenino')";
     db.Insert(query);
 }