Esempio n. 1
0
        public List <Producto> Buscarproducto(string busqueda)
        {
            ProductoDAO     productoDAO = new ProductoDAO();
            List <Producto> productos   = productoDAO.BuscarProducto(busqueda + "%");

            return(productos);
        }
Esempio n. 2
0
        protected void ddlproductorecoger_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductoDAO     db          = new ProductoDAO();
            int             idpro       = Convert.ToInt32(ddlproductorecoger.SelectedValue);
            Producto        producto    = db.BuscarProducto(idpro);
            DataTable       detalles    = (DataTable)Session["DetallesNota"];
            bool            seEncuentra = false;
            int             cod         = producto.Id_prod;
            List <Producto> art         = new List <Producto>();

            foreach (GridViewRow grv in grvDetalles.Rows)
            {
                Producto ar = new Producto();
                ar.Id_prod = Convert.ToInt32(grv.Cells[0].Text);
                art.Add(ar);
            }
            seEncuentra = art.Exists(x => x.Id_prod == cod);
            if (seEncuentra == false)
            {
                string  id          = Convert.ToString(producto.Id_prod);
                string  Descripcion = producto.descripcion;
                decimal precio      = Convert.ToDecimal(producto.PVentaS);
                Util.Helper.Agregar_DetallesNota(detalles, id, Descripcion, precio);
                cargarDetalles();
                Session["DetallesNota"] = detalles;
            }
            else
            {
                txtmensaje.Text = "El producto ya fue ingresado.";
                string script = "openModal();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
                ddlproductorecoger.SelectedValue = "0";
            }
        }
        public ActionResult RegistrarVenta(int ID)
        {
            ProductoDAO = new ProductoDAO(_con);
            Producto MiProducto = ProductoDAO.BuscarProducto(ID);

            return(View(MiProducto));
        }
Esempio n. 4
0
        public ActionResult EditarProducto(int id)
        {
            ProductoBEAN oProdBean  = oProdDAO.BuscarProducto(id);
            var          listaProds = oTipoProdDAO.ListarTipoProducto().ToList();

            ViewBag.ListaTipoPrd = new SelectList(listaProds, "IdTipoProd", "NombreTipoProd");
            return(View(oProdBean));
        }
        // GET: VentaController/Details/5
        public ActionResult MostrarVenta(int id)
        {
            MiVentaDAO  = new VentaDAO(_con);
            ProductoDAO = new ProductoDAO(_con);
            Venta    MiVENTA   = MiVentaDAO.BuscarVenta(id);
            Producto Producto1 = ProductoDAO.BuscarProducto(MiVENTA.id_producto);

            ViewBag.ProductoName = Producto1.nombre;
            return(View(MiVENTA));
        }
Esempio n. 6
0
        void cargar()
        {
            int         id  = Convert.ToInt32(Request.QueryString["IDP"]);
            ProductoDAO db  = new ProductoDAO();
            Producto    pro = db.BuscarProducto(id);

            txtcodpro.Text                = pro.Id_prod.ToString();
            ddlfamilia.SelectedValue      = pro.Id_Familia.ToString();
            txtdescripcion.Text           = pro.descripcion;
            ddlmarca.SelectedValue        = pro.IdMarca.ToString();
            ddligv.SelectedValue          = pro.IdAfectoIGV.ToString();
            ddlunidadmedida.SelectedValue = pro.IdMedida.ToString();
            txtpeso.Text          = pro.PesoKilos.ToString();
            txtpreciocompras.Text = pro.PComprasS.ToString();
            txtpreciocomprad.Text = pro.PCompraD.ToString();
            txtprecioventas.Text  = pro.PVentaS.ToString();
            txtprecioventad.Text  = pro.PVentaD.ToString();
            txtstockmax.Text      = pro.StockMax.ToString();
            txtstockmin.Text      = pro.StockMax.ToString();
            txtstockact.Text      = pro.StockAct.ToString();
            txtunidad.Text        = pro.Unidades.ToString();
            txtobservacion.Text   = pro.Observacion;
        }
Esempio n. 7
0
        protected void btnguardar_Click(object sender, EventArgs e)
        {
            if ((txtpreciocomprad.Text.Length) < 1)
            {
                txtpreciocomprad.Text = "0.00";
            }
            if (txtpeso.Text.Length < 1)
            {
                txtpeso.Text = "0.00";
            }
            if (txtpreciocompras.Text.Length < 1)
            {
                txtpreciocompras.Text = "0.00";
            }
            if (txtprecioventad.Text.Length < 1)
            {
                txtprecioventad.Text = "0.00";
            }
            if (txtprecioventas.Text.Length < 1)
            {
                txtprecioventas.Text = "0.00";
            }
            if (txtstockmax.Text.Length < 1)
            {
                txtstockmax.Text = "0";
            }
            if (txtstockmin.Text.Length < 1)
            {
                txtstockmin.Text = "0";
            }
            if (txtstockact.Text.Length < 1)
            {
                txtstockact.Text = "0";
            }
            if (txtunidad.Text.Length < 1)
            {
                txtstockact.Text = "0";
            }
            ProductoDAO db  = new ProductoDAO();
            Producto    pro = new Producto();

            if (txtcodigo.Text.Length > 0)
            {
                pro = db.BuscarProducto(Convert.ToInt32(txtcodigo.Text));
                if (pro.descripcion == null)
                {
                    pro.Id_prod     = Convert.ToInt32(txtcodigo.Text);
                    pro.IdAfectoIGV = Convert.ToInt32(ddligv.SelectedValue);
                    pro.Id_Familia  = Convert.ToInt32(ddlfamilia.SelectedValue);
                    pro.descripcion = txtdescripcion.Text;
                    pro.IdMarca     = Convert.ToInt32(ddlmarca.SelectedValue);
                    pro.IdMedida    = Convert.ToInt32(ddlunidadmedida.SelectedValue);
                    pro.PesoKilos   = Convert.ToDecimal(txtpeso.Text);
                    pro.PCompraD    = Convert.ToDecimal(txtpreciocomprad.Text);
                    pro.PComprasS   = Convert.ToDecimal(txtpreciocompras.Text);
                    pro.PVentaD     = Convert.ToDecimal(txtprecioventad.Text);
                    pro.PVentaS     = Convert.ToDecimal(txtprecioventas.Text);
                    pro.StockMax    = Convert.ToInt32(txtstockmax.Text);
                    pro.StockMin    = Convert.ToInt32(txtstockmin.Text);
                    pro.StockAct    = Convert.ToInt32(txtstockact.Text);
                    pro.Unidades    = Convert.ToInt32(txtunidad.Text);
                    pro.Observacion = txtobservacion.Text;
                    db.CrearProducto(pro);
                    Response.Redirect("ManteProducto.aspx", true);
                }
                else
                {
                    Label1.Text = "El codigo ya existe.";
                    string script = "openModal();";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "error", script, true);
                }
            }
            else
            {
                Label1.Text = "Debe poner un codigo al producto.";
                string script = "openModal();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "error", script, true);
            }
        }
Esempio n. 8
0
        //protected void ddlclientes_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    ClienteDAO db = new ClienteDAO();
        //    int id = Convert.ToInt32(ddlclientes.SelectedValue);
        //    Cliente clie = db.Buscarcliente(id, "");
        //    lblnombre.Text = clie.NombrePropietario;
        //    txtnumeropuesto.Text = clie.NumeroPuesto;
        //}

        //protected void ddlmercados_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    string id = ddlmercados.SelectedValue;
        //    Util.Helper.ListarClientesxMerZon(ddlclientes, id);
        //    txtnumeropuesto.Enabled = true;
        //    ddlclientes.Enabled = true;
        //    txtnumeropuesto.Text = "";
        //}

        //protected void txtnumeropuesto_TextChanged(object sender, EventArgs e)
        //{
        //    ClienteDAO db = new ClienteDAO();
        //    string numero = txtnumeropuesto.Text;
        //    string idmercado = ddlmercados.SelectedValue;
        //    Cliente clie = db.BuscarclientexPuesto(numero, idmercado);
        //    lblnombre.Text = clie.NombrePropietario;
        //    ddlclientes.SelectedValue = clie.Id_cliente.ToString();
        //}

        protected void txtcodproducto_TextChanged(object sender, EventArgs e)
        {
            if (txtcodproducto.Text.Length > 0)
            {
                ProductoDAO db    = new ProductoDAO();
                int         idpro = Convert.ToInt32(txtcodproducto.Text);
                Producto    pro   = db.BuscarProducto(idpro);
                if (pro.Id_prod != 0)
                {
                    DataTable       detalles    = (DataTable)Session["Detalles"];
                    bool            seEncuentra = false;
                    int             cod         = Convert.ToInt32(pro.Id_prod);
                    List <Producto> art         = new List <Producto>();
                    foreach (GridViewRow grv in grvDetalles.Rows)
                    {
                        Producto ar = new Producto();
                        ar.Id_prod = Convert.ToInt32(grv.Cells[0].Text);
                        art.Add(ar);
                    }
                    seEncuentra = art.Exists(x => x.Id_prod == cod);
                    if (seEncuentra == false)
                    {
                        string  id          = Convert.ToString(pro.Id_prod);
                        string  Descripcion = pro.descripcion;
                        decimal precio      = Convert.ToDecimal(pro.PVentaS);
                        decimal peso        = Convert.ToDecimal(pro.PesoKilos);
                        int     afecto      = Convert.ToInt32(pro.IdAfectoIGV);
                        decimal igv         = 0.00m;
                        int     unidad      = Convert.ToInt32(pro.Unidades);
                        int     idmedida    = Convert.ToInt32(pro.IdMedida);
                        if (afecto == 1)
                        {
                            igv = 0.18m;
                        }
                        decimal cantidad      = 1m;
                        decimal cantidadkilos = Math.Round(cantidad * peso, 2);
                        if (pro.Id_prod == 486 || pro.Id_prod == 488 || pro.Id_prod == 487 || pro.Id_prod == 297)
                        {
                            decimal subtotal = Math.Round(cantidad * precio * peso, 2);
                            decimal igvsub   = subtotal - Math.Round(subtotal / (1 + igv), 2);
                            Util.Helper.Agregar_Detalles(detalles, id, Descripcion, precio, cantidad, peso, igvsub, subtotal, cantidadkilos, unidad, idmedida);
                            cargarDetalles();
                            Session["Detalles"] = detalles;
                            decimal total = Util.Helper.TotalizarGrilla(grvDetalles, 6);
                            lbltotal.Text = total.ToString();
                        }
                        else
                        {
                            if (precio <= 14.00m)
                            {
                                decimal subtotal = Math.Round(cantidad * precio * peso, 2);
                                decimal igvsub   = subtotal - Math.Round(subtotal / (1 + igv), 2);
                                Util.Helper.Agregar_Detalles(detalles, id, Descripcion, precio, cantidad, peso, igvsub, subtotal, cantidadkilos, unidad, idmedida);
                                cargarDetalles();
                                Session["Detalles"] = detalles;
                                if (igv == 0.18m)
                                {
                                    decimal total    = Util.Helper.TotalizarGrilla(grvDetalles, 6);
                                    decimal totaligv = Util.Helper.TotalizarGrilla(grvDetalles, 5);
                                    lbligv.Text   = totaligv.ToString();
                                    lbltotal.Text = total.ToString();
                                }
                                else
                                {
                                    decimal total = Util.Helper.TotalizarGrilla(grvDetalles, 6);
                                    lbltotal.Text = total.ToString();
                                }
                                //decimal total = Util.Helper.TotalizarGrilla(grvDetalles, 5);

                                ddlproducto.SelectedValue = "0";
                                btnguardar.Enabled        = true;
                                txtcodproducto.Text       = "";
                            }
                            else
                            {
                                decimal subtotal = Math.Round(cantidad * precio, 2);
                                decimal igvsub   = subtotal - Math.Round(subtotal / (1 + igv), 2);
                                Util.Helper.Agregar_Detalles(detalles, id, Descripcion, precio, cantidad, peso, igvsub, subtotal, cantidadkilos, unidad, idmedida);
                                cargarDetalles();
                                Session["Detalles"] = detalles;
                                if (igv == 0.18m)
                                {
                                    decimal total    = Util.Helper.TotalizarGrilla(grvDetalles, 6);
                                    decimal totaligv = Util.Helper.TotalizarGrilla(grvDetalles, 5);
                                    lbligv.Text   = totaligv.ToString();
                                    lbltotal.Text = total.ToString();
                                }
                                else
                                {
                                    decimal total = Util.Helper.TotalizarGrilla(grvDetalles, 6);
                                    lbltotal.Text = total.ToString();
                                }
                                //decimal total = Util.Helper.TotalizarGrilla(grvDetalles, 5);

                                ddlproducto.SelectedValue = "0";
                                btnguardar.Enabled        = true;
                                txtcodproducto.Text       = "";
                            }
                        }
                    }
                    else
                    {
                        txtmensaje.Text = "El producto ya fue ingresado.";
                        string script = "openModal();";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
                        txtcodproducto.Text = "";
                    }
                }
                else
                {
                    txtmensaje.Text = "El producto no existe.";
                    string script = "openModal();";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
                    txtcodproducto.Text = "";
                }
            }
            else
            {
                txtmensaje.Text = "Debe poner el código del producto.";
                string script = "openModal();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
                txtcodproducto.Text = "";
            }
        }
        public void BuscarProductoTest()
        {
            ProductoDAO productoDAO = new ProductoDAO();

            Assert.IsTrue(productoDAO.BuscarProducto("papa").Any());
        }