protected void DL_Productos_ItemCommand(object source, DataListCommandEventArgs e)
    {
        ClientScriptManager cm = this.ClientScript;
        int stock = int.Parse(((Label)e.Item.FindControl("L_Disponible")).Text);
        int cantidadSolicitada = int.Parse(((TextBox)e.Item.FindControl("TB_Cantidad")).Text);
        int cantidadDisponible = new DaoProducto().obtenerCantidadxProdcuto(int.Parse(e.CommandArgument.ToString()));

        if (e.Item.FindControl("TB_Cantidad") != null || cantidadSolicitada > cantidadDisponible)
        {
            if (cantidadSolicitada > stock)
            {
                cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Cantidad No disponible. Disponible:');</script>");
                //this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('Cantidad No disponible. Disponible: '" + cantidadDisponible.ToString() + "');</script>");
                return;
            }

            Carrito agregar = new Carrito();
            agregar.ProductoId = int.Parse(e.CommandArgument.ToString());
            agregar.UserId     = int.Parse(Session["userId"].ToString());
            agregar.Cantidad   = cantidadSolicitada;
            agregar.Fecha      = DateTime.Now;

            new DaoProducto().agregarCarrito(agregar);
            cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Producto agregado a Carrito.');</script>");
            Response.Redirect("Catalogo.aspx");
        }
    }
        public bool agregarProducto(string s_Idproc, decimal Precio, int stock, string categoria, string descripcion, string s_imagen)
        {
            int cant_flias = 0;


            Productos Cue = new Productos();

            Cue.set_codigo_producto(s_Idproc);
            Cue.set_precio_producto(Precio);
            Cue.set_Stock(stock);
            Cue.set_categoria(categoria);
            Cue.set_nombre_producto(descripcion);

            Cue.set_url_imagen(s_imagen);



            DaoProducto dao = new DaoProducto();

            if (dao.existeProducto(Cue) == true)
            {
                cant_flias = dao.agregarProducto(Cue);
            }
            if (cant_flias == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public static List <ProductoView> listarProductos(string nombre)
        {
            List <ProductoView> listaFiltrada = new List <ProductoView>();

            foreach (var prod in DaoProducto.obtenerProductos(nombre))
            {
                ProductoView producto = new ProductoView();

                producto.Id             = prod.Id;
                producto.Nombre         = prod.Nombre;
                producto.NombreTipo     = prod.Tipo_Producto.Nombre;
                producto.CodigoProducto = prod.Codigo_Producto;
                producto.Precio         = "$" + prod.Precio.ToString();
                if (prod.Vigente)
                {
                    producto.Vigente = "SI";
                }
                else
                {
                    producto.Vigente = "NO";
                }

                listaFiltrada.Add(producto);
            }

            return(listaFiltrada);
        }
Esempio n. 4
0
        public Producto get(string id)
        {
            DaoProducto dao = new DaoProducto();

            //Validar si existe esa Producto
            return(dao.getProducto(id));
        }
        public List <Cl_Producto> obtenerProductos()
        {
            DaoProducto        daoProducto = new DaoProducto();
            List <Cl_Producto> listaProd   = daoProducto.listarProductos();

            return(listaProd);
        }
        public bool actualizarProducto(string s_Idproc, decimal Precio, int stock, string s_imagen)
        {
            int       cant_flias = 0;
            Productos Cue        = new Productos();

            Cue.set_codigo_producto(s_Idproc);
            Cue.set_precio_producto(Precio);
            Cue.set_Stock(stock);

            Cue.set_url_imagen(s_imagen);


            DaoProducto dao = new DaoProducto();

            if (dao.existeProducto(Cue) == true)
            {
                cant_flias = dao.ActualizarProducto(Cue);
            }
            if (cant_flias == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public DataTable GenerarTabla_Productos()

        {
            DaoProducto tabla   = new DaoProducto();
            DataTable   glibros = tabla.getTablaCategorias();

            return(glibros);
        }
Esempio n. 8
0
 public VendedorControl()
 {
     InitializeComponent();
     daoProducto = new DaoProducto();
     daoVenta    = new DaoVenta();
     cargarProductos();
     cargarVentas();
     agregarBotonesDgVenta();
     agregarBotonesDgDetalleVenta();
 }
Esempio n. 9
0
 public VendedorControl(Cl_Usuario vend)
 {
     InitializeComponent();
     daoProducto = new DaoProducto();
     daoVenta    = new DaoVenta();
     vendedor    = vend;
     cargarProductos();
     cargarVentas();
     agregarBotonesDgVenta();
     agregarBotonesDgDetalleVenta();
     TCVendedor.SelectedTab = venderPage;
 }
Esempio n. 10
0
        public static Producto buscarProducto(Producto producto)
        {
            DataTable dt = DaoProducto.sqlLeer(producto);

            Producto pv = new Producto(int.Parse(dt.Rows[0]["Id"].ToString()),
                                       dt.Rows[0]["Descripcion"].ToString(),
                                       DateTime.Parse(dt.Rows[0]["Fecha_vencimiento"].ToString()),
                                       int.Parse(dt.Rows[0]["Precio"].ToString()),
                                       int.Parse(dt.Rows[0]["Stock"].ToString()),
                                       int.Parse(dt.Rows[0]["Tipo_producto_id"].ToString()));

            return(pv);
        }
Esempio n. 11
0
        public bool AltaProducto(Producto p)
        {
            DaoProducto dao             = new DaoProducto();
            int         FilasInsertadas = dao.AltaProducto(p);

            if (FilasInsertadas == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
 public FormCambiarProducto(int idProd, int idDet, int idVen, VendedorControl vc, int idTrab)
 {
     InitializeComponent();
     //servicio = new ServicioClient();
     daoProducto    = new DaoProducto();
     listaProductos = daoProducto.listarProductos();
     agregarColumnasCambiarProd();
     cargarProductos();
     modificarColumnas();
     idProductoAntiguo = idProd;
     idDetalleVenta    = idDet;
     idVenta           = idVen;
     vendControl       = vc;
     idTrabajador      = idTrab;
 }
Esempio n. 13
0
        public static bool ActualizarProducto(Producto producto)
        {
            int respuesta = 0;

            respuesta = DaoProducto.sqlActualizar(producto);


            if (respuesta > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 14
0
        public bool eliminarProducto(string id)
        {
            //Validar id existente
            DaoProducto dao = new DaoProducto();
            Producto    p   = new Producto();

            p.setCodigoProducto(id);
            int op = dao.eliminarProducto(p);

            if (op == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 15
0
        public static bool EliminarProducto(Producto producto)
        {
            int respuesta = 0;

            if (DaoProducto.sqlExiste(producto))
            {
                respuesta = DaoProducto.sqlEliminar(producto);
            }



            if (respuesta > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    protected General informacionReporte()
    {
        General        informe     = new General();
        List <Carrito> listCarrito = new DaoProducto().obtenerProductosCarrito(1);

        DataTable datosFinal = informe.Carrito;
        DataRow   fila;

        foreach (Carrito registro in listCarrito)
        {
            fila                   = datosFinal.NewRow();
            fila["Id"]             = registro.Id;
            fila["ProductoNombre"] = registro.NombreProducto;
            fila["ProductoImagen"] = obtenerImagen(registro.Url);
            fila["Cantidad"]       = registro.Cantidad;
            fila["Precio"]         = registro.Precio;
            fila["Fecha"]          = registro.Fecha;
            datosFinal.Rows.Add(fila);
        }

        return(informe);
    }
        public bool eliminarProducto(string idProducto)
        {
            //Validar id existente
            int         cant_flias = 0;
            DaoProducto dao        = new DaoProducto();
            Productos   cat        = new Productos();

            cat.set_codigo_producto(idProducto);
            if (dao.existeProducto(cat))
            {
                cant_flias = dao.eliminarProducto(cat);
            }

            if (cant_flias == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 18
0
        public static bool CrearProducto(Producto producto)
        {
            int respuesta = 0;

            if (DaoProducto.sqlExiste(producto))
            {
                respuesta = DaoProducto.sqlActualizar(producto);
            }
            else
            {
                respuesta = DaoProducto.sqlAgregar(producto);
            }


            if (respuesta > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 19
0
        private void cargarStock()
        {
            List <UserControl> tarjetaProdControl = new List <UserControl>();

            if (tarjetaProdControl != null)
            {
                foreach (UserControl item in this.stockPage.Controls.OfType <UserControl>())
                {
                    //DO NOT REMOVE COMPONENT IN THIS LOOP BECAUSE
                    //YOU DECREASE THE .Controls  ARRAY AND YOU WILL HAVE AN ERROR
                    tarjetaProdControl.Add(item);
                    //MessageBox.Show(item.Name);
                }
                foreach (UserControl item in tarjetaProdControl)
                {
                    item.Dispose();
                }
            }
            DaoProducto        daoProducto = new DaoProducto();
            List <Cl_Producto> listaProd   = daoProducto.listarProductos();
            int x = 5;
            int y = 50;

            foreach (var prod in listaProd)
            {
                TarjetaProdControl tp = new TarjetaProdControl(prod);
                tp.Location = new Point(x, y);
                x          += 175;
                if (x > 650)
                {
                    x  = 5;
                    y += 230;
                }
                stockPage.Controls.Add(tp);
            }
        }
Esempio n. 20
0
 public static Boolean eliminarProducto(int codigo)
 {
     return(DaoProducto.eliminarProducto(codigo));
 }
        public int obtenerStock(int idProducto)
        {
            DaoProducto daoProducto = new DaoProducto();

            return(daoProducto.obtenerStock(idProducto));
        }
Esempio n. 22
0
        public static void registrarProducto(Producto producto)
        {
            DaoProducto dao = new DaoProducto();

            dao.insertarProducto(producto);
        }
Esempio n. 23
0
 public static Boolean existeProducto(int codigo)
 {
     return(DaoProducto.existeProducto(codigo));
 }
Esempio n. 24
0
 public static Producto buscarProducto(int codigo)
 {
     return(DaoProducto.buscarProducto(codigo));
 }
Esempio n. 25
0
        public void algoritmoBusqueda(String busqueda, int pagina)
        {
            daoProducto = new DaoProducto();

            List <Producto> listaPaginacion = new List <Producto>();

            try
            {
                Conexion.abrirConexion();
                listaElementos = daoProducto.buscar(busqueda);
                Conexion.cerrarConexion();

                //Si la consulta tuvo más de un registro, se hace la paginación
                double totalPaginacion = Convert.ToDouble(listaElementos.Count) / 10.0;

                int i       = (((pagina) - 1) * (10)) + 1;
                int f       = 0;
                int paginaS = pagina + 1;

                totalPaginacion = totalPaginacion + 1;
                String[] auxiliar = totalPaginacion.ToString().Split('.');
                lblTotalPaginas.Text = auxiliar[0];

                if (banderaUltimaPagina)
                {
                    f = listaElementos.Count;
                    banderaUltimaPagina = false;
                }
                else if (listaElementos.Count < 10)
                {
                    f = listaElementos.Count;
                    banderaUltimaPagina = false;
                }
                else
                {
                    f = ((paginaS) - 1) * 10;
                }

                totalPaginacion = totalPaginacion - 1;

                for (int j = i - 1; j < f; j++)
                {
                    Producto obj = new Producto();

                    obj.Barras         = listaElementos[j].Barras;
                    obj.Nombre         = listaElementos[j].Nombre;
                    obj.PrecioCompra   = listaElementos[j].PrecioCompra;
                    obj.IVA            = listaElementos[j].IVA;
                    obj.TipoIVA        = listaElementos[j].TipoIVA;
                    obj.Utilidad       = listaElementos[j].Utilidad;
                    obj.PrecioNeto     = listaElementos[j].PrecioNeto;
                    obj.PrecioVenta    = listaElementos[j].PrecioVenta;
                    obj.Unidad         = listaElementos[j].Unidad;
                    obj.CantidadUnidad = listaElementos[j].CantidadUnidad;
                    obj.Insuficiencia  = listaElementos[j].Insuficiencia;
                    obj.Descripcion    = listaElementos[j].Descripcion;

                    listaPaginacion.Add(obj);
                }

                tbProductos.Columns.Clear();
                tbProductos.Refresh();
                tbProductos.DataSource = listaPaginacion;

                //Total de registros totales en la tabla
                lblTotalRegistros.Text  = listaElementos.Count.ToString();
                lblRegistrosActual.Text = listaPaginacion.Count.ToString();

                //Obtener el total de páginas
                if (totalPaginacion == 0)
                {
                    int aux = 1;
                    lblTotalPaginas.Text = aux.ToString();
                }
                else if (totalPaginacion.ToString().Contains('.'))
                {
                    totalPaginacion = totalPaginacion + 1;
                    String[] auxiliar2 = totalPaginacion.ToString().Split('.');
                    lblTotalPaginas.Text = auxiliar2[0];
                }
                else
                {
                    lblTotalPaginas.Text = totalPaginacion.ToString();
                }

                lblPaginasActual.Text = pagina.ToString();

                lblTotalRegistros.Text = listaElementos.Count.ToString();

                if (listaElementos.Count == 0)
                {
                    lblRegistrosActual.Text = "0";
                    lblTotalRegistros.Text  = "0";
                    lblPaginasActual.Text   = "0";
                    lblTotalPaginas.Text    = "0";
                }
                tbProductos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                tbProductos.Columns[0].Visible  = false;
                tbProductos.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                tbProductos.Columns[3].Visible = false;
                tbProductos.Columns[4].Visible = false;
                tbProductos.Columns[5].Visible = false;
                tbProductos.Columns[6].Visible = false;
                tbProductos.Columns[7].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                tbProductos.Columns[9].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                tbProductos.Columns[8].Visible  = false;
                tbProductos.Columns[10].Visible = false;
                tbProductos.Columns[11].Visible = false;
                tbProductos.Columns[12].Visible = false;
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 26
0
 public static Producto obtenerProductoPorID(int id)
 {
     return(DaoProducto.obtenerProductoPorID(id));
 }
Esempio n. 27
0
        public static int obtenerAgregados(int id)
        {
            Producto prod = DaoProducto.buscarAgregados(id);

            return(prod.Agregados);
        }
Esempio n. 28
0
 public static List <Producto> listaProductosVendibles()
 {
     return(DaoProducto.obtenerProductosVenta());
 }
Esempio n. 29
0
 public static List <Producto> listaSabores()
 {
     return(DaoProducto.obtenerSabores());
 }
Esempio n. 30
0
 public static Boolean modificarProducto(Producto producto)
 {
     return(DaoProducto.modificarProducto(producto));
 }