public static List <Devolucion> ObtenerDevoluciones() { Devolucion devolucion; listaDevoluciones.Clear(); using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string tectoCMD = "select * from Devolucion"; SqlCommand cmd = new SqlCommand(tectoCMD, con); SqlDataReader elLectorDeDatos = cmd.ExecuteReader(); while (elLectorDeDatos.Read()) { devolucion = new Devolucion(); devolucion.Id = elLectorDeDatos.GetInt32(0); devolucion.Motivo_Devolucion = elLectorDeDatos.GetString(1); devolucion.Articulo = Articulo.ObtenerArticulo(elLectorDeDatos.GetInt32(2)); devolucion.FechaDevol = elLectorDeDatos.GetDateTime(3); listaDevoluciones.Add(devolucion); } } return(listaDevoluciones); }
public static void AgregarDevolucion(Devolucion d) { using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string textoCmd = "insert into Devolucion (Motivo_Devolucion, Descripcion, FechaDevol) VALUES (@Motivo_Devolucion, @Descripcion, @FechaDevol)"; SqlCommand cmd = new SqlCommand(textoCmd, con); cmd = d.ObtenerParametros(cmd); cmd.ExecuteNonQuery(); } }
public static void EditarDevolucion(int index, Devolucion d) { using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string textoCMD = "UPDATE Devolucion SET Motivo_Devolucion = @Motivo_Devolucion, Descripcion = @Descripcion, FechaDevol= @FechaDevol where Id = @Id"; SqlCommand cmd = new SqlCommand(textoCMD, con); cmd = d.ObtenerParametros(cmd, true); cmd.ExecuteNonQuery(); } }
public static void EliminarDevolucion(Devolucion devolucion) { using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string SENTENCIA_SQL = "delete from Devolucion where Id = @Id"; SqlCommand cmd = new SqlCommand(SENTENCIA_SQL, con); SqlParameter p1 = new SqlParameter("@Id", devolucion.Id); p1.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(p1); cmd.ExecuteNonQuery(); con.Close(); } }