Exemplo n.º 1
0
        /**
         * Consulta todos los registros de la tabla pero con Paginacion
         * @param Producto obj
         * @return Retorna la lista de los registros en la tabla con paginacion
         */

        public Producto[] listarProducto(int pagina, int numRegPagina)
        {
            Producto[]      result = null;
            List <Producto> lista  = null;

            if (pagina > 0 && numRegPagina > 0)
            {
                pagina--;
                int limInf = 0;
                int limSup = 0;
                limInf = pagina * numRegPagina + 1;
                limSup = (pagina + 1) * numRegPagina;
                try {
                    ProductoDao dao = new ProductoDao();
                    conn = conexion.conectar();
                    if (limInf <= dao.countAll(conn))
                    {
                        lista = dao.loadAll(conn, limInf, limSup);
                        if (lista != null && lista.Count > 0)
                        {
                            result = lista.ToArray();
                        }
                    }
                } catch (Exception e) {
                    result = null;
                } finally {
                    if (conn != null && conn.State == System.Data.ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /**
         * Busca el primer registro que coincida con los datos enviados
         * @param Producto obj
         * @return Retorna el mismo objeto pero con los datos consultados
         */
        public Producto buscarPrimeroProducto(Producto obj)
        {
            List <Producto> lista = null;

            try {
                ProductoDao dao = new ProductoDao();
                conn  = conexion.conectar();
                lista = dao.searchMatching(conn, obj);
                if (lista != null && lista.Count > 0)
                {
                    obj = (Producto)lista[0];
                }
                else
                {
                    obj.ID_PRODUCTO = -1;
                }
            } catch (Exception e) {
                obj.ID_PRODUCTO = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(obj);
        }
Exemplo n.º 3
0
        public ActionResult OfertaProductoDetalle(long id_producto, long?id_venta)
        {
            /*var OfertaDao = new OfertaDao();
             * var oferta = OfertaDao.GetReference<IOferta>(id);
             * return View(oferta);*/
            ViewBag.valor_producto = id_producto;



            ViewBag.IdVenta = id_venta;
            ViewBag.Message = TempData["message"];

            var ProductoDao = new ProductoDao();
            var producto    = ProductoDao.GetReference <IProducto>(id_producto);


            //NHibernateUtil.Initialize(producto.Ofertas);
            //producto.CODIGO_VENTA_WEB = Convert.ToInt64(TempData["message"]);


            return(View("OfertaProductoDetalle", producto));


            //var OfertaDao = new OfertaDao();
            //var ofertas = OfertaDao.getOfertaPorProducto(id);
            //return View(ofertas);
        }
 public CtlVistaProducto(Form4 form4)
 {
     vista4       = form4;
     producto     = new ProductoDao();
     vista4.Load += new EventHandler(cargarDatos);
     vista4.textBox1.TextChanged += new EventHandler(buscar);
 }
Exemplo n.º 5
0
        /**
         * Inserta nuevo registro en la tabla
         * @param Producto obj
         * @return Retorna el mismo objeto pero con la llave primaria configurada
         */
        public Producto crearProducto(Producto obj)
        {
            List <Producto> lista   = null;
            Producto        obj_new = new Producto();

            try {
                ProductoDao dao = new ProductoDao();
                conn = conexion.conectar();
                int id = Funciones.obtenerId(conn, "PRODUCTO");
                obj.ID_PRODUCTO = id;
                dao.create(conn, obj);
                //verificar existencia
                obj_new.ID_PRODUCTO = obj.ID_PRODUCTO;
                lista = dao.searchMatching(conn, obj_new);
                if (lista != null && lista.Count > 0)
                {
                    obj_new = (Producto)lista[0];
                }
                else
                {
                    obj_new.ID_PRODUCTO = -1;
                }
            } catch (Exception e) {
                obj_new.ID_PRODUCTO = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(obj_new);
        }
Exemplo n.º 6
0
        public JsonResult editarPublicacion(long oferta_id)
        {
            var ProductoDao = new ProductoDao();
            var producto    = ProductoDao.GetReference <IProducto>(oferta_id);

            var ofertas = new { producto.NOMBRE_PRODUCTO, producto.Ofertas.FirstOrDefault().PRECIO, producto.Ofertas.FirstOrDefault().PRECIO_OFERTA, producto.Ofertas.FirstOrDefault().PCT_DESCUENTO, producto.Ofertas.FirstOrDefault().STOCK, producto.Ofertas.FirstOrDefault().Tienda.ID_TIENDA, producto.ID_PRODUCTO, producto.Ofertas.FirstOrDefault().DETALLE, producto.Ofertas.FirstOrDefault().ID_OFERTA, producto.Ofertas.FirstOrDefault().Imagen.ID_IMAGEN };

            return(this.Json(ofertas, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public ActionResult addPedido(int producto)
        {
            ProductoDao pDao = new ProductoDao();

            pDao.CreateTemporaryOrder(1, producto);

            var sproducto = colegioEntities.producto;

            return(View(sproducto.ToList()));
        }
Exemplo n.º 8
0
 public CtlProducto(Form2 vistaPro)
 {
     this.vistaPro                        = vistaPro;
     vistaPro.Load                       += new EventHandler(cargarDatos);
     vistaPro.btAgregar.Click            += new EventHandler(agregar);
     vistaPro.btEliminar.Click           += new EventHandler(eliminar);
     vistaPro.btModificar.Click          += new EventHandler(modificar);
     vistaPro.dataGridProducto.CellClick += new DataGridViewCellEventHandler(selectdata);
     producto   = new ProductoDao();
     contenedor = new Producto();
 }
Exemplo n.º 9
0
        public void cargaHistorial(int mes, int annio)
        {
            dataGridView1.Rows.Clear();
            ProductoDao            dao       = new ProductoDao();
            List <HistorialPrecio> historial = dao.historialCambioPrecios(mes, annio);

            foreach (HistorialPrecio registro in historial)
            {
                dataGridView1.Rows.Add(registro.IdProducto,
                                       registro.Producto,
                                       registro.Fecha.ToString("dd-MMMM-yyyy"),
                                       Math.Round(registro.PrecioAnterior, 2).ToString("N2"),
                                       Math.Round(registro.PrecioActual, 2).ToString("N2"));
            }
        }
Exemplo n.º 10
0
        public ActionResult getProductos()
        {
            using (var productoDao = new ProductoDao())
            {
                IList <Producto>    productos = productoDao.GetAll <Producto>();
                List <SelectOption> ListaProductosPersonalizada = new List <SelectOption>();

                foreach (Producto producto in productos)
                {
                    ListaProductosPersonalizada.Add(new SelectOption(producto.NOMBRE_PRODUCTO, producto.ID_PRODUCTO));
                }

                productoDao.Close();

                return(Json(ListaProductosPersonalizada, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 11
0
        public int contarBusquedaProducto(Producto obj)
        {
            int cantidad = -1;

            try {
                ProductoDao dao = new ProductoDao();
                conn     = conexion.conectar();
                cantidad = dao.countSearchMatching(conn, obj);
            } catch (Exception e) {
                cantidad = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(cantidad);
        }
Exemplo n.º 12
0
        private List <VentaItem> ObtenerVentasPendienteFacturacion(List <VentaItem> ventasTotales, List <VentaItem> ventasFacturadas, List <VentaItem> remitosPendientes)
        {
            ProductoDao      productoDao      = new ProductoDao();
            List <VentaItem> ventasPendientes = new List <VentaItem>();
            List <Producto>  productos        = productoDao.getProductos();

            foreach (Producto pro in productos)
            {
                VentaItem ventaPendiente = new VentaItem();

                ventaPendiente.producto = pro;
                ventaPendiente.cantidad = 0;

                foreach (VentaItem ventaTotal in ventasTotales)
                {
                    if (ventaTotal.producto.productoId == ventaPendiente.producto.productoId)
                    {
                        ventaPendiente.cantidad = ventaPendiente.cantidad + ventaTotal.cantidad;
                    }
                }

                foreach (VentaItem ventaFacturada in ventasFacturadas)
                {
                    if (ventaFacturada.producto.productoId == ventaPendiente.producto.productoId)
                    {
                        ventaPendiente.cantidad = ventaPendiente.cantidad - ventaFacturada.cantidad;
                    }
                }

                foreach (VentaItem remitoPendiente in remitosPendientes)
                {
                    if (remitoPendiente.producto.productoId == ventaPendiente.producto.productoId)
                    {
                        ventaPendiente.cantidad = ventaPendiente.cantidad - remitoPendiente.cantidad;
                    }
                }

                ventasPendientes.Add(ventaPendiente);
            }

            return(ventasPendientes);
        }
Exemplo n.º 13
0
        /**
         * Edita un registro en la tabla
         * @param Producto obj
         * @return boolean indicando si se realizo o no la actualizacion
         */
        public bool editarProducto(Producto obj)
        {
            bool resultado;

            resultado = false;
            try {
                ProductoDao dao = new ProductoDao();
                conn = conexion.conectar();
                dao.save(conn, obj);
                resultado = true;
            } catch (Exception e) {
                resultado = false;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(resultado);
        }
Exemplo n.º 14
0
        /**
         * Inserta nuevo registro en la tabla
         * @param Producto obj
         * @return Retorna el mismo objeto pero con la llave primaria configurada
         */
        public ProductoResponse crearProducto(Producto obj)
        {
            List <Producto>  lista       = null;
            Producto         obj_new     = new Producto();
            ProductoResponse objResponse = new ProductoResponse();

            try {
                ProductoDao dao = new ProductoDao();
                conn = conexion.conectar();
                dao.create(conn, obj);
                //verificar existencia
                obj_new.NOM_PRODUCTO     = obj.NOM_PRODUCTO;
                obj_new.ID_EMPRESA       = obj.ID_EMPRESA;
                obj_new.ID_TIPO_PRODUCTO = obj.ID_TIPO_PRODUCTO;
                lista = dao.searchMatching(conn, obj_new);
                if (lista != null && lista.Count > 0)
                {
                    obj_new = (Producto)lista[0];
                }
                else
                {
                    obj_new.ID_PRODUCTO = -1;
                }
                objResponse.correcto = true;
                objResponse.error    = "";
                objResponse.objeto   = obj_new;
            } catch (Exception e) {
                obj_new.ID_PRODUCTO  = -1;
                objResponse.correcto = false;
                objResponse.error    = e.Message;
                objResponse.objeto   = obj_new;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(objResponse);
        }
Exemplo n.º 15
0
        /**
         * Consulta todos los registros de la tabla
         * @param Producto obj
         * @return Retorna la lista de los registros en la tabla
         */
        public Producto[] listarProducto()
        {
            Producto[]      result = null;
            List <Producto> lista  = null;

            try {
                ProductoDao dao = new ProductoDao();
                conn  = conexion.conectar();
                lista = dao.loadAll(conn);
                if (lista != null && lista.Count > 0)
                {
                    result = lista.ToArray();
                }
            } catch (Exception e) {
                result = null;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(result);
        }
Exemplo n.º 16
0
        /**
         * Edita un registro en la tabla
         * @param Producto obj
         * @return boolean indicando si se realizo o no la actualizacion
         */
        public ProductoResponse editarProducto(Producto obj)
        {
            ProductoResponse resultado = new ProductoResponse();

            resultado.correcto = false;
            try {
                ProductoDao dao = new ProductoDao();
                conn = conexion.conectar();
                dao.save(conn, obj);
                resultado.correcto = true;
                resultado.error    = "";
                resultado.objeto   = obj;
            } catch (Exception e) {
                resultado.correcto = false;
                resultado.error    = e.Message;
                resultado.objeto   = obj;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(resultado);
        }
Exemplo n.º 17
0
        public Inventario()
        {
            InitializeComponent();

            inv_dao  = new InventarioDao();
            prod_dao = new ProductoDao();

            inv_dao.copiaRegistroExistencia();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.Height = 32;
            }

            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                row.Height = 32;
            }

            foreach (DataGridViewRow row in dataGridView3.Rows)
            {
                row.Height = 32;
            }
        }
Exemplo n.º 18
0
 public ProductoService()
 {
     oProductoDao = new ProductoDao();
 }
Exemplo n.º 19
0
 public GestionarProductoService()
 {
     _gestorDaoSql       = new GestorDAO_Sql();
     _productoDao        = new ProductoDao(_gestorDaoSql);
     _detalleProductoDao = new DetalleProductoDao(_gestorDaoSql);
 }
Exemplo n.º 20
0
 public CategoriaNeg()
 {
     objCategoriaDao = new Dao.CategoriaDao();
     objProductoDao  = new ProductoDao();
 }
Exemplo n.º 21
0
        private void carga_idProducto(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                ProductoDao dao        = new ProductoDao();
                int         idProducto = 0;

                if (textBox1.Text.Trim().Equals(""))
                {
                    // obtener nuevo id para guardar nuevo producto
                    if ((idProducto = dao.obtenerIdProducto()) != -1)
                    {
                        textBox1.Text    = idProducto.ToString();
                        textBox4.Text    = "NUEVO";
                        textBox1.Enabled = false;
                        textBox2.Enabled = true;
                        textBox3.Enabled = true;
                        textBox3.Focus();
                        textBox3.Select(0, textBox3.Text.Length);
                    }
                    else
                    {
                        MessageBox.Show("Error de conexion con la base de datos.");
                        textBox1.Text    = "";
                        textBox1.Enabled = true;
                        textBox2.Enabled = false;
                        textBox3.Enabled = false;
                    }
                }
                else
                {
                    try {
                        idProducto = Convert.ToInt32(textBox1.Text);
                    } catch (Exception ex) {
                        ex.ToString();
                        textBox1.Text = "";
                        MessageBox.Show("Ingresa un valor númerico.");
                        return;
                    }

                    // busca si el id existe, si existe puede modificar el producto cargado
                    ProductoE producto = null;
                    if ((producto = dao.obtenerProducto(idProducto)) != null)
                    {
                        textBox1.Enabled = false;
                        textBox2.Enabled = true;
                        textBox3.Enabled = true;
                        textBox2.Text    = producto.PrecioVenta.ToString("N2");
                        textBox3.Text    = producto.Nombre.ToString();
                        textBox4.Text    = "EDITABLE";
                        textBox3.Focus();
                        textBox3.Select(0, textBox3.Text.Length);
                    }
                    else
                    {
                        textBox1.Enabled = false;
                        textBox2.Enabled = true;
                        textBox3.Enabled = true;
                        textBox4.Text    = "NUEVO";
                        textBox3.Focus();
                        textBox3.Select(0, textBox3.Text.Length);
                    }
                }
            }
        }
Exemplo n.º 22
0
 static ProductoBussines()
 {
     productoDao = new ProductoDao();
 }
 public ProductoServicio()
 {
     this.oProductoDao = new ProductoDao();
 }
Exemplo n.º 24
0
        public List <Producto> buscar_productos_descripcion(string value)
        {
            ProductoDao productodao = new ProductoDao();

            return(productodao.buscar_productos_descripcion(value));
        }
Exemplo n.º 25
0
        public List <Producto> buscar_productos_nombre(string value)
        {
            ProductoDao productodao = new ProductoDao();

            return(productodao.buscar_productos_nombre(value));
        }
Exemplo n.º 26
0
        public Producto buscar_producto_id(int id)
        {
            ProductoDao productodao = new ProductoDao();

            return(productodao.buscar_producto_id(id));
        }
Exemplo n.º 27
0
        public List <Producto> listar_productos()
        {
            ProductoDao productodao = new ProductoDao();

            return(productodao.Listar());
        }
 public ProductoNeg()
 {
     objProductoDao     = new ProductoDao();
     objDetalleVentaDao = new DetalleVentaDao();
 }
Exemplo n.º 29
0
        private void guardar_cambios(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F10)
            {
                if (textBox3.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Falta nombre de producto");
                    return;
                }

                double precioVenta = 0;

                try
                {
                    precioVenta = Convert.ToDouble(textBox2.Text);

                    if (precioVenta <= 0)
                    {
                        MessageBox.Show("El precio de venta debe ser mayor a cero.");
                        textBox2.Text = "";
                        return;
                    }
                } catch (Exception ex) {
                    MessageBox.Show("El precio debe ser un valor numérico");
                    textBox2.Text = "";
                    return;
                }

                ProductoE prod = new ProductoE();
                prod.IdProducto  = Convert.ToInt32(textBox1.Text);
                prod.Nombre      = textBox3.Text;
                prod.PrecioVenta = precioVenta;

                ProductoDao dao = new ProductoDao();

                if (textBox4.Text.Equals("NUEVO"))
                {
                    if (dao.registrarProducto(prod) != -1)
                    {
                        MessageBox.Show(prod.Nombre + " guardado correctamente.");
                        limpiarCampos();
                    }
                    else
                    {
                        MessageBox.Show("Error al registrar el producto.");
                    }
                }
                else
                {
                    if (dao.guardarCambios(prod) != -1)
                    {
                        MessageBox.Show(prod.Nombre + " guardado correctamente.");
                        limpiarCampos();
                        cargaHistorial(DateTime.Now.Month, DateTime.Now.Year);
                    }
                    else
                    {
                        MessageBox.Show("Error al guardar los cambios.");
                    }
                }
            }
        }