Example #1
0
 public static Negocio.CD obtenerCD(int codigoCD)
 {
     DataTable dt, ej;
     string sql = "Select * from CD where cod_CD = @codigo";
     string sql2 = "Select * from Ejemplar where cod_CD = @codigo";
     List<SqlParameter> parametros = new List<SqlParameter>();
     parametros.Add(new SqlParameter("@cod_CD", codigoCD));
     dt = DAO.AccesoDatos.consultar(sql, parametros);
     if (dt.Rows.Count > 0)
     {
         int cod_CD = (int)dt.Rows[0]["cod_CD"];
         String nombre = (String)dt.Rows[0]["nombre"];
         int cod_genero = (int)dt.Rows[0]["cod_Genero"];
         Negocio.Genero g = (Negocio.Genero)GeneroManager.obtenerGenero(cod_genero);
         int cod_Artista = (int)dt.Rows[0]["cod_Artista"];
         Negocio.Artista a = (Negocio.Artista)ArtistaManager.obtenerArtistaPorCodigo(cod_Artista);
         int año_Edicion = (int)dt.Rows[0]["año_Edicion"];
         string discografica = (string)dt.Rows[0]["discografica"];
         List<Negocio.Tema> temas = TemaManager.obtenerTemas(codigoCD);
         Negocio.CD cd = new Negocio.CD(cod_CD, nombre, temas, g, a, año_Edicion, discografica);
         return cd;
     }
     else
     {
         return null;
     }
 }
Example #2
0
        protected void btn_Comprar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                List<Negocio.Tema> temas = new List<Negocio.Tema>();
                List<Negocio.Ejemplar> ejemplares = new List<Negocio.Ejemplar>();
                int codCD = CDManager.obtenerUltimo() + 1;

                for (int i = 0; i < gv_Temas.Rows.Count; i++)
                {
                    int nro = Convert.ToInt32(gv_Temas.Rows[i].Cells[0].Text);
                    string nom = gv_Temas.Rows[i].Cells[1].Text;
                    string dur = gv_Temas.Rows[i].Cells[2].Text;
                    Negocio.Tema tema = new Negocio.Tema(codCD, nro, nom, dur);
                    temas.Add(tema);
                }

                string nombre = txt_NombreCD.Text;
                int codGenero = ddl_Genero.SelectedIndex + 1;
                Negocio.Genero genero = GeneroManager.obtenerGenero(codGenero);
                int codArtista = Convert.ToInt32(lbl_Codigo.Text);
                Negocio.Artista artista = ArtistaManager.obtenerArtistaPorCodigo(codArtista);
                int año = Convert.ToInt32(txt_AñoEdicion.Text);
                string discografica = txt_Discografica.Text;

                Negocio.CD cd = new Negocio.CD(codCD, nombre, temas, genero, artista, año, discografica);

                for (int i = 0; i < Convert.ToInt32(txt_ejemplares.Text); i++)
                {
                    int nroEjemplar = i + 1;
                    double precioCompra = Convert.ToDouble(txt_precioCompra.Text);
                    double precioVenta = Convert.ToDouble(txt_precioVenta.Text);
                    Negocio.Ejemplar ejemplar = new Negocio.Ejemplar(nroEjemplar, codCD, precioVenta, precioCompra);
                    ejemplares.Add(ejemplar);
                }

                if (DAO.Transaccion.comprarCD(cd, ejemplares))
                {
                    Response.Redirect("ABM_Artista.aspx?accion=informar&mensaje=exito");
                }
                else
                {
                    Response.Redirect("ABM_Artista.aspx?accion=informar&mensaje=fracaso");
                }
            }
        }