예제 #1
0
    protected void GvJuguetes_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            EntJuguete ent = new EntJuguete();
            ent.Id           = Convert.ToInt32(GvJuguetes.DataKeys[e.RowIndex].Values["Id"].ToString());
            ent.Marca_Id     = Convert.ToInt32(((DropDownList)GvJuguetes.Rows[e.RowIndex].FindControl("ddlMarcaEIT")).SelectedValue);
            ent.Modelo_Id    = Convert.ToInt32(((DropDownList)GvJuguetes.Rows[e.RowIndex].FindControl("ddlModeloEIT")).SelectedValue);
            ent.Categoria_Id = Convert.ToInt32(((DropDownList)GvJuguetes.Rows[e.RowIndex].FindControl("ddlCategoriaEIT")).SelectedValue);

            ent.Nombre     = ((TextBox)GvJuguetes.Rows[e.RowIndex].FindControl("txtNombreEIT")).Text;
            ent.Precio     = Convert.ToDouble(((TextBox)GvJuguetes.Rows[e.RowIndex].FindControl("txtPrecioEIT")).Text);
            ent.Costo      = Convert.ToDouble(((Label)GvJuguetes.Rows[e.RowIndex].FindControl("lblCostoEIT")).Text);
            ent.Existencia = Convert.ToInt32(((TextBox)GvJuguetes.Rows[e.RowIndex].FindControl("txtExistenciaEIT")).Text);
            FileUpload fu       = (FileUpload)GvJuguetes.Rows[e.RowIndex].FindControl("fuFotoEIT");
            bool       guardado = GuardarFoto(fu);

            ent.Foto    = "Img/" + fu.FileName;
            ent.Fecha   = Convert.ToDateTime(((TextBox)GvJuguetes.Rows[e.RowIndex].FindControl("txtFechaEIT")).Text);
            ent.Estatus = ((CheckBox)GvJuguetes.Rows[e.RowIndex].FindControl("chkEstatusEIT")).Checked;
            new BusJuguete().Actuaizar(ent);
            Response.Redirect(Request.CurrentExecutionFilePath);
        }
        catch (Exception ex)
        {
            MostrarMensaje(ex.Message);
        }
    }
예제 #2
0
    protected void lnkAgregarFT_Click1(object sender, EventArgs e)
    {
        try
        {
            EntJuguete ent = new EntJuguete();


            ent.Marca_Id     = Convert.ToInt32(((DropDownList)GvJuguetes.FooterRow.FindControl("ddlMarcaFT")).SelectedValue);
            ent.Modelo_Id    = Convert.ToInt32(((DropDownList)GvJuguetes.FooterRow.FindControl("ddlModeloFT")).SelectedValue);
            ent.Categoria_Id = Convert.ToInt32(((DropDownList)GvJuguetes.FooterRow.FindControl("ddlCategoriaFT")).SelectedValue);


            ent.Nombre = ((TextBox)GvJuguetes.FooterRow.FindControl("txtNombreFT")).Text;

            ent.Precio     = Convert.ToDouble(((TextBox)GvJuguetes.FooterRow.FindControl("txtPrecioFT")).Text);
            ent.Costo      = ent.Precio * 2.00;
            ent.Existencia = Convert.ToInt32(((TextBox)GvJuguetes.FooterRow.FindControl("txtExistenciaFT")).Text);
            FileUpload fu       = (FileUpload)GvJuguetes.FooterRow.FindControl("fuFotoFT");
            bool       guardado = GuardarFoto(fu);

            ent.Foto    = "Img/" + fu.FileName;
            ent.Fecha   = Convert.ToDateTime(((TextBox)GvJuguetes.FooterRow.FindControl("txtFechaFT")).Text);
            ent.Estatus = ((CheckBox)GvJuguetes.FooterRow.FindControl("chkEstatusFT")).Checked;
            new BusJuguete().Insertar(ent);
            Response.Redirect(Request.CurrentExecutionFilePath);
        }
        catch (Exception ex)
        {
            MostrarMensaje(ex.Message);
        }
    }
예제 #3
0
    protected void GvJuguetes_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            EntJuguete ent = new EntJuguete();
            ent.Id         = Convert.ToInt32(GvJuguetes.DataKeys[e.RowIndex].Values["Id"].ToString());
            ent.Existencia = Convert.ToInt32(((TextBox)GvJuguetes.Rows[e.RowIndex].FindControl("txtExistenciaEIT")).Text);


            if (Convert.ToInt32(ent.Existencia) > Convert.ToInt32(GvJuguetes.DataKeys[e.RowIndex].Values["Existencia"].ToString()))
            {
                throw new ApplicationException("La cantidad de articulos no es suficiente en la exitencia");
            }

            ent.Existencia = Convert.ToInt32(GvJuguetes.DataKeys[e.RowIndex].Values["Existencia"].ToString()) - ent.Existencia;

            new BusJuguete().Actuaizar(ent.Id, ent.Existencia);


            Response.Redirect(Request.CurrentExecutionFilePath);
        }
        catch (Exception ex)
        {
            MostrarMensaje(ex.Message);
        }
    }
예제 #4
0
        public List <EntJuguete> Obtener()
        {
            DataTable         dt  = new DatPametrizadaJuguetes().Obtener();
            List <EntJuguete> lst = new List <EntJuguete>();

            foreach (DataRow dr in dt.Rows)
            {
                EntJuguete ent = new EntJuguete();
                ent.Id               = Convert.ToInt32(dr["Jugue_Id"]);
                ent.Nombre           = dr["Jugue_Nombre"].ToString();
                ent.Marca_Id         = Convert.ToInt32(dr["Jugue_Marca_Id"]);
                ent.Modelo_Id        = Convert.ToInt32(dr["Jugue_Modelo_Id"]);
                ent.Categoria_Id     = Convert.ToInt32(dr["Jugue_Categoria_Id"]);
                ent.Costo            = Convert.ToDouble(dr["Jugue_Costo"]);
                ent.Estatus          = Convert.ToBoolean(dr["Jugue_Estatus"]);
                ent.Existencia       = Convert.ToInt32(dr["Jugue_Existencia"]);
                ent.Fecha            = Convert.ToDateTime(dr["Jugue_Fecha_Alta"]);
                ent.Foto             = dr["Jugue_Foto"].ToString();
                ent.Precio           = Convert.ToDouble(dr["Jugue_Precio"]);
                ent.Marca.Nombre     = Convert.ToString(dr["Cata_Nombre"]);
                ent.Modelo.Nombre    = Convert.ToString(dr["Cata_Modelo_Nombre"]);
                ent.Categoria.Nombre = Convert.ToString(dr["Cate_Nombre"]);
                ent.MarcaNombre      = Convert.ToString(dr["Cata_Nombre"]);
                ent.ModeloNombre     = Convert.ToString(dr["Cata_Modelo_Nombre"]);
                lst.Add(ent);
            }
            return(lst);
        }
예제 #5
0
    protected void GvJuguetes_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        EntJuguete ent = new EntJuguete();

        ent.Id = Convert.ToInt32(GvJuguetes.DataKeys[e.RowIndex].Values["Id"].ToString());
        new BusJuguete().Borrar(ent);
        Response.Redirect(Request.CurrentExecutionFilePath);
    }
예제 #6
0
        public void Borrar(EntJuguete ent)
        {
            int filas = new DatPametrizadaJuguetes().Borrar(ent.Id);

            if (filas != 1)
            {
                throw new ApplicationException(string.Format("Error al Borrar"));
            }
        }
예제 #7
0
        public void Actuaizar(EntJuguete ent)
        {
            int filas = new DatPametrizadaJuguetes().Actualizar(ent.Nombre, ent.Existencia, ent.Marca_Id, ent.Modelo_Id, ent.Categoria_Id, ent.Fecha.ToString("MM/dd/yyyy"), ent.Precio, ent.Estatus, ent.Costo, ent.Foto, ent.Id);

            if (filas != 1)
            {
                throw new ApplicationException(string.Format("Error al Actualizar"));
            }
        }
예제 #8
0
    public static string ObtenerJuguete(string modelo, string marca)
    {
        EntJuguete ent = new EntJuguete();
        BusJuguete obj = new BusJuguete();

        ent = obj.Obtener(Convert.ToInt32(modelo), Convert.ToInt32(marca));

        JavaScriptSerializer oSerealizer = new JavaScriptSerializer();
        string sJSON = oSerealizer.Serialize(ent);

        return(sJSON);
    }
예제 #9
0
    protected void btnActualizar_Click(object sender, EventArgs e)
    {
        EntJuguete ent      = new EntJuguete();
        EntJuguete entVieja = new EntJuguete();

        entVieja         = Session["ENTIDAD"] as EntJuguete;
        ent.Nombre       = txtNombre.Text;
        ent.Existencia   = Convert.ToInt32(txtExistencia.Text);
        ent.Fecha        = Convert.ToDateTime(txtFecha.Text);
        ent.Costo        = Convert.ToInt32(lblCosto.Text);
        ent.Precio       = Convert.ToInt32(txtPrecio.Text);
        ent.Marca_Id     = Convert.ToInt32(ddlMarca.SelectedValue);
        ent.Modelo_Id    = Convert.ToInt32(ddlModelo.SelectedValue);
        ent.Categoria_Id = Convert.ToInt32(ddlCategoria.SelectedValue);
        ent.Id           = Convert.ToInt32(Request.QueryString["ID"]);


        //imgFoto.ImageUrl = "Img/" + fuFoto.FileName;

        if (fuFoto.HasFile)
        {
            ent.Foto = "Img/" + fuFoto.FileName;
            bool guardado = GuardarFoto(fuFoto);
        }

        else
        {
            //imgFoto.ImageUrl = ent.Foto;
            ent.Foto = entVieja.Foto;
        }
        ent.Estatus = chkEstatus.Checked;

        try
        {
            BusJuguete obj = new BusJuguete();
            obj.Actuaizar(ent);
            Response.Redirect("Default.aspx");

            //Response.Redirect("EdicionUrl.aspx?ID=" + ent.Id);
        }
        catch (Exception ex)
        {
            Title = ex.Message;
        }
    }
예제 #10
0
        public EntJuguete Obtener(int modelo, int marca)
        {
            DataRow    dr  = new DatJuguetes().ObtenerJuguete(modelo, marca);
            EntJuguete ent = new EntJuguete();

            ent.Id               = Convert.ToInt32(dr["Jugue_Id"]);
            ent.Nombre           = dr["Jugue_Nombre"].ToString();
            ent.Marca_Id         = Convert.ToInt32(dr["Jugue_Marca_Id"]);
            ent.Modelo_Id        = Convert.ToInt32(dr["Jugue_Modelo_Id"]);
            ent.Categoria_Id     = Convert.ToInt32(dr["Jugue_Categoria_Id"]);
            ent.Costo            = Convert.ToDouble(dr["Jugue_Costo"]);
            ent.Estatus          = Convert.ToBoolean(dr["Jugue_Estatus"]);
            ent.Existencia       = Convert.ToInt32(dr["Jugue_Existencia"]);
            ent.Fecha            = Convert.ToDateTime(dr["Jugue_Fecha_Alta"]);
            ent.Foto             = dr["Jugue_Foto"].ToString();
            ent.Precio           = Convert.ToDouble(dr["Jugue_Precio"]);
            ent.Marca.Nombre     = Convert.ToString(dr["Cata_Nombre"]);
            ent.Modelo.Nombre    = Convert.ToString(dr["Cata_Modelo_Nombre"]);
            ent.Categoria.Nombre = Convert.ToString(dr["Cate_Nombre"]);
            ent.FechaJSon        = ent.Fecha.ToString("dd/MM/yyyy");
            return(ent);
        }
예제 #11
0
        public EntJuguete Obtener(int Id)
        {
            DataRow    dr  = new DatPametrizadaJuguetes().Obtener(Id);
            EntJuguete ent = new EntJuguete();

            //if (dt.Rows.Count == 0)
            //{
            //    ent.Id = 0;
            //    ent.Nombre = "No encontrado";
            //    ent.Marca_Id = 0;
            //    ent.Modelo_Id = 0;
            //    ent.Categoria_Id = 0;
            //    ent.Costo = 0;
            //    ent.Estatus = false;
            //    ent.Existencia = 0;
            //    ent.Fecha = Convert.ToDateTime("01/01/1900");
            //    ent.Foto = "Sin img";
            //    ent.Precio = 0;
            //}
            //else
            //{
            //foreach (DataRow dr in dr.Rows)
            //{
            ent.Id           = Convert.ToInt32(dr["Jugue_Id"]);
            ent.Nombre       = dr["Jugue_Nombre"].ToString();
            ent.Marca_Id     = Convert.ToInt32(dr["Jugue_Marca_Id"]);
            ent.Modelo_Id    = Convert.ToInt32(dr["Jugue_Modelo_Id"]);
            ent.Categoria_Id = Convert.ToInt32(dr["Jugue_Categoria_Id"]);
            ent.Costo        = Convert.ToDouble(dr["Jugue_Costo"]);
            ent.Estatus      = Convert.ToBoolean(dr["Jugue_Estatus"]);
            ent.Existencia   = Convert.ToInt32(dr["Jugue_Existencia"]);
            ent.Fecha        = Convert.ToDateTime(dr["Jugue_Fecha_Alta"]);
            ent.Foto         = dr["Jugue_Foto"].ToString();
            ent.Precio       = Convert.ToDouble(dr["Jugue_Precio"]);
            //}
            //}
            return(ent);
        }