Esempio n. 1
0
        public bool Agregar(ObservacionModel Obs)
        {
            SqlConnection connection = null;


            connection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand("OBSERVACIONES_ACT", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@ACCION", 1);
            command.Parameters.AddWithValue("@USR", Obs.usr_id);
            //command.Parameters.AddWithValue("@OBS", -1);
            command.Parameters.AddWithValue("@PER", Obs.per_id);
            command.Parameters.AddWithValue("@OBSERVACION", Obs.observacion);

            connection.Open();
            int i = command.ExecuteNonQuery();

            connection.Close();

            if (i >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public IEnumerable <ObservacionModel> ListadoObservaciones(int per)
        {
            List <ObservacionModel> myModel = new List <ObservacionModel>();

            using (SqlConnection connection = new SqlConnection(connectionString))

                using (SqlCommand command = new SqlCommand("", connection))
                {
                    connection.Open();
                    command.CommandText = "EXEC OBSERVACIONES_SEL @ACCION, @OBS, @PER";
                    command.Parameters.AddWithValue("@ACCION", 1);
                    command.Parameters.AddWithValue("@OBS", -1);
                    command.Parameters.AddWithValue("@PER", per);
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        ObservacionModel model = new ObservacionModel();
                        model.per_id         = (int)reader["per_id_silicio"];
                        model.obs_id         = (int)reader["obs_id"];
                        model.observacion    = (string)reader["observacion"];
                        model.fecha          = (DateTime)reader["fecha"];
                        model.usr_id         = (int)reader["usr_id"];
                        model.nombre_usuario = (string)reader["nombre_usuario"];
                        myModel.Add(model);
                    }
                    reader.Close();
                    connection.Close();
                }
            return(myModel);
        }