public Plataforma getPlataforma(string id)
        {
            Plataforma cat   = new Plataforma();
            DataTable  tabla = ds.ObtenerTabla("Plataforma", "Select * from plataformas where Cod_Plataforma_P=" + id);

            cat.setCodigoPlataforma(tabla.Rows[0][0].ToString());
            cat.setNombrePlataforma(tabla.Rows[0][1].ToString());
            return(cat);
        }
        public bool eliminarPlataforma(string id)
        {
            //Validar id existente
            DaoPlataforma dao = new DaoPlataforma();
            Plataforma    p   = new Plataforma();

            p.setCodigoPlataforma(id);
            int op = dao.eliminarPlataforma(p);

            if (op == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        protected void grdPlataformas_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            String s_codigoPlataforma = ((Label)grdPlataformas.Rows[e.RowIndex].FindControl("lbl_eit_codigoPlataforma")).Text.Trim();
            String s_nombrePlataforma = ((TextBox)grdPlataformas.Rows[e.RowIndex].FindControl("txt_eit_nombrePlataforma")).Text.Trim();



            Plataforma plat = new Plataforma();

            plat.setCodigoPlataforma(s_codigoPlataforma);
            plat.setNombrePlataforma(s_nombrePlataforma);

            N_Plataforma n_Plataforma = new N_Plataforma();

            n_Plataforma.ActualizarPlataforma(plat);

            grdPlataformas.EditIndex = -1;
            cargarGridview();
        }
Exemple #4
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            Plataforma   plataforma   = new Plataforma();
            N_Plataforma n_Plataforma = new N_Plataforma();

            string nombrePlataforma = TxtNombrePlataforma.Text.Trim();

            if (nombrePlataforma != "")
            {
                if (!n_Plataforma.getBuscarNombrePlataforma(nombrePlataforma))
                {
                    int ultimaPlataforma = n_Plataforma.getConsultaUltimaPlataforma() + 1;
                    plataforma.setCodigoPlataforma("PF" + ultimaPlataforma);
                    plataforma.setNombrePlataforma(nombrePlataforma);
                    n_Plataforma.AltaPlataforma(plataforma);
                    Response.Write("<script>alert('Plataforma agregada con exito');</script>");
                    TxtNombrePlataforma.Text = "";
                    grdPlataformas.EditIndex = -1;
                    cargarGridview();
                }
                else
                {
                    Response.Write("<script>alert('La plataforma ya existe');</script>");
                    TxtNombrePlataforma.Text = "";
                    grdPlataformas.EditIndex = -1;
                    cargarGridview();
                }
            }
            else
            {
                Response.Write("<script>alert('Debe ingresar una Plataforma');</script>");
                TxtNombrePlataforma.Text = "";
                grdPlataformas.EditIndex = -1;
                cargarGridview();
            }
        }
        protected void btnComprar_Click(object sender, EventArgs e)
        {
            int          filasventa = 0;
            int          filasdet   = 0;
            Venta        venta      = new Venta();
            Usuario      usr        = new Usuario();
            TipoDePago   tp         = new TipoDePago();
            TipoUsuario  tu         = new TipoUsuario();
            N_Usuario    negu       = new N_Usuario();
            N_Venta      negv       = new N_Venta();
            N_Producto   negp       = new N_Producto();
            N_Plataforma negpl      = new N_Plataforma();

            string codUsuario  = negu.getIDporUsername(this.Session["username"].ToString().Trim());
            string tipoUsuario = this.Session["usertype"].ToString();
            string tipoPago    = ddlTipoPago.SelectedValue.ToString();

            tu.setCodigoTipoUsuario(tipoUsuario);
            usr.setCodigoUsuario(codUsuario);
            usr.setIdTipoUsuario(tu);
            venta.setIdCodigoUsuario(usr);
            venta.setFechaVenta(DateTime.Now);
            tp.setcodigoTipo(tipoPago);
            venta.setIdTipoPago(tp);
            filasventa = negv.GuardarVenta(venta);


            DataTable dt         = (DataTable)Session["carrito"];
            int       stockTotal = 0;

            ///COMPROBAR QUE TODOS LOS PRODUCTOS TENGAN STOCK
            for (int c = 0; c < dt.Rows.Count; c++)
            {
                N_PlataformaXProducto negPXP = new N_PlataformaXProducto();
                string codProd    = negp.getCodigoProductoConNombre(dt.Rows[c]["Nombre"].ToString());
                string stockProd  = negPXP.getStockProducto(codProd);
                int    stockFinal = Convert.ToInt32(stockProd) - Convert.ToInt32(dt.Rows[c]["Cantidad"].ToString());
                if (stockFinal >= 0)
                {
                    stockTotal++;
                }
            }

            if (stockTotal == dt.Rows.Count)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    N_DetalleVenta        negd    = new N_DetalleVenta();
                    N_PlataformaXProducto pxp     = new N_PlataformaXProducto();
                    DetalleVenta          detalle = new DetalleVenta();
                    Venta              v          = new Venta();
                    ENTIDAD.Producto   p          = new ENTIDAD.Producto();
                    ENTIDAD.Plataforma pl         = new Plataforma();
                    string             codProd    = negp.getCodigoProductoConNombre(dt.Rows[i]["Nombre"].ToString());
                    string             codPlat    = negpl.getCodigoPlataformaConNombre(dt.Rows[i]["Plataforma"].ToString());
                    int    cant        = Convert.ToInt32(dt.Rows[i]["Cantidad"].ToString());
                    float  preciototal = float.Parse(dt.Rows[i]["PrecioUnitario"].ToString());
                    string stockProd   = pxp.getStockProducto(codProd);
                    int    nuevostock  = Convert.ToInt32(stockProd) - Convert.ToInt32(dt.Rows[i]["Cantidad"].ToString());
                    int    codVenta    = negv.getCodVenta();

                    v.setCodigoVenta(codVenta);
                    detalle.setIdCodigoVenta(v);
                    p.setCodigoProducto(codProd);
                    detalle.setIdCodigoProducto(p);
                    pl.setCodigoPlataforma(codPlat);
                    detalle.setIdCodigoPlataforma(pl);
                    detalle.setCantidadVendida(cant);
                    detalle.setPrecioUnitario(preciototal / cant);

                    filasdet = negd.GuardarDetalleVenta(detalle);

                    pxp.modificarStockProducto(codProd, nuevostock.ToString());
                }

                if (filasventa > 0 && filasdet > 0)
                {
                    this.Session["carrito"] = null;
                    Response.Redirect("CarritoCheckout.aspx");
                }
                else
                {
                    this.Session["carrito"] = null;
                    Response.Redirect("CarritoError.aspx");
                }
            }
            else
            {
                this.Session["carrito"] = null;
                Response.Redirect("CarritoStock.aspx");
            }
        }