Example #1
0
        private void Increase_Click(object sender, RoutedEventArgs e)
        {
            if (Valor < Maximum)
            {
               
                /*Aumentar en tabla valor  de cantidad de valor seleccionado de producto*/
                if (datagridVentas.SelectedItem != null)
                {
                    if (datagridVentas.Items.Count > 0)
                    {
                        if (datagridVentas.SelectedItem is VentaTemporal)
                        {
                            Valor++;
                            var row = (VentaTemporal)datagridVentas.SelectedItem;
                            ProductoFacade prodFobtener = new ProductoFacade();
                            Producto Prod = new Producto();
                            Prod = prodFobtener.getProductosByID(row.idProducto);
                            int filaProd = 0;
                            int num = 0;
                            if (row != null)
                            {

                                //MessageBox.Show(row.cantidad); 
                                //Tomar valor de cantidad  datagrid y aumentar 
                                List<VentaTemporal> vtemporal = new List<VentaTemporal>();
                                var rows = GetDataGridRows(datagridVentas);
                                foreach (DataGridRow r in rows)
                                {
                                    VentaTemporal rv = (VentaTemporal)r.Item;
                                    vtemporal.Add(rv);
                                }
                                //buscar el id de list con el seleccionado en datagrid
                                foreach (var r in vtemporal)
                                {
                                    if (row.idProducto.Equals(r.idProducto))
                                    {
                                        filaProd = num;
                                    }
                                    num = num + 1;

                                }
                                ProductoFacade prodcantiFacade = new ProductoFacade();
                                int maxstock = Convert.ToInt32(prodcantiFacade.getStockProductoByidProd(row.idProducto));
                                if (Valor <= Convert.ToInt32(row.cantidad))
                                {
                                    int total = Convert.ToInt32(Prod.precio) * Convert.ToInt32(Valor);
                                    vtemporal[filaProd].devolver = Valor.ToString();
                                    //vtemporal[filaProd].total = total.ToString();
                                    ltotal.Content =  total.ToString();
                                    datagridVentas.ItemsSource = null;
                                    datagridVentas.ItemsSource = vtemporal;
                                    datagridVentas.SelectedIndex = filaProd;
                                }
                                else
                                {
                                    //MessageBox.Show("Producto, segun inventario, no cuenta con mas stock");
                                    Valor = Convert.ToInt32(row.cantidad);
                                }

                            }
                        }
                    }
                }
                //Recorrer tabla para sumar total
                /*  subtotal = 0;

                  foreach (var i in venta)
                  {
                      subtotal = subtotal + Convert.ToInt32(i.total);
                      //MessageBox.Show(i.total.ToString());
                  }
                  txtsubtotal.Text = subtotal.ToString*/
                //Recorrer tabla para sumar total
                subtotal = 0;
                int numProducto = 0;
                foreach (var i in venta)
                {
                    subtotal = subtotal + Convert.ToInt32(i.total);
                    //MessageBox.Show(i.total.ToString());
                    numProducto = numProducto + 1;
                }
               /* txtsubtotal.Text = subtotal.ToString();
                txtCantidadProductos.Content = numProducto.ToString();
                if (Convert.ToInt32(txtdescuento.Text) == 0)
                {
                    txttotal.Text = txtsubtotal.Text;
                }
                else
                {
                    double des = Convert.ToDouble(txtdescuento.Text) / Convert.ToDouble(100);
                    txttotal.Text = (Convert.ToInt32(txtsubtotal.Text) - Convert.ToDouble(txtsubtotal.Text) * des).ToString();
                }*/
                RaiseEvent(new RoutedEventArgs(IncreaseClickedEvent));
            }
        }
Example #2
0
        /*********************************/


        /*********************************/


        //buscar producto mediante id ingresado
        private void codProdVenta_TextChanged(object sender, TextChangedEventArgs e)
        {

            ProductoFacade prodF = new ProductoFacade();
            bool existe = prodF.getExisteProductoByidProd(txtcodProdVenta.Text);


            if (existe)
            {
                ProductoFacade prodFobtener = new ProductoFacade();
                Producto Prod = new Producto();
                Prod = prodFobtener.getProductosByID(txtcodProdVenta.Text);
                //Si producto ya esta en tablapara venta aumentar cantidad
                if (Convert.ToInt32(Prod.stock) <= 0)
                {
                    MessageBox.Show("El producto no cuenta con más stock", "Magnolia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {

                    //comparar en datagrid si esta
                    bool sumarCantidad = false;
                    int cantidad = 0;
                    int totaldatos = datagridVentas.Items.Count;
                    int filaProd = 0;
                    List<VentaTemporal> vtemporal = new List<VentaTemporal>();
                    VentaTemporal vtemp = new VentaTemporal();
                    var rows = GetDataGridRows(datagridVentas);
                    int num = 0;
                    //Se verifica si tabla tiene ya ese producto y asi aumentar canditad
                    if (totaldatos > 0)
                    { //Llenar lista con los productos en datagrid para sumarle uno mas en cantidad
                        foreach (DataGridRow r in rows)
                        {
                            VentaTemporal rv = (VentaTemporal)r.Item;
                            vtemporal.Add(rv);

                        }
                        foreach (DataGridRow r in rows)
                        {
                            VentaTemporal rv = (VentaTemporal)r.Item;
                            //MessageBox.Show(txtcodProdVenta.Text+"="+rv.idProducto);
                            if (txtcodProdVenta.Text.Equals(rv.idProducto))
                            {
                                sumarCantidad = true;
                                /*int pre = ToEntero(rv.precio, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                                string m = pre.ToString("#,#", CultureInfo.InvariantCulture);
                                MessageBox.Show(rv.precio);*/
                                vtemp = new VentaTemporal(rv.idVenta, rv.idProducto, rv.nombre, rv.precio, rv.cantidad, rv.total);
                                cantidad = Convert.ToInt32(rv.cantidad) + 1;
                                filaProd = num;
                            }
                            num = num + 1;
                        }
                    }

                    //Verificar stock de producto
                    ProductoFacade prodcantiFacade = new ProductoFacade();
                    int maxstock = Convert.ToInt32(prodcantiFacade.getStockProductoByidProd(txtcodProdVenta.Text));
                    if (cantidad <= maxstock)
                    {

                        if (sumarCantidad)
                        {
                            //Editar cantidad y setear total precio

                            int totalProducto = Convert.ToInt32(Prod.precio) * Convert.ToInt32(cantidad);
                            //borrar fila delista con id y actualizar la cantidad y precio
                            vtemporal[filaProd].cantidad = cantidad.ToString();
                            vtemporal[filaProd].total = totalProducto.ToString();

                            // subtotal = subtotal + totalProducto;

                            datagridVentas.ItemsSource = null;
                            datagridVentas.ItemsSource = vtemporal;

                            //Llenar textbox con total

                        }
                        else
                        {
                            //MessageBox.Show("Primer producto agregado");
                            //Nuevo producto para venta a  proceso de venta
                            venta.Add(new VentaTemporal { idProducto = Prod.idProducto, nombre = Prod.nombre, precio = Prod.precio, cantidad = "1", total = Prod.precio });
                            datagridVentas.ItemsSource = venta;
                            subtotal = subtotal + Convert.ToInt32(Prod.precio);
                        }
                        //txtcodProdVenta.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("El producto no cuenta con más stock", "Magnolia", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                txtcodProdVenta.Text = "";
            }
            else
            {


            }
            //Recorrer tabla para sumar total
            subtotal = 0;
            int numProducto = 0;
            foreach (var i in venta)
            {
                subtotal = subtotal + Convert.ToInt32(i.total);
                //MessageBox.Show(i.total.ToString());
                numProducto = numProducto + 1;
            }
            int mtotalDevo = subtotal - dineroDevolucion;
            if (mtotalDevo < 0)
            {
                //Quiere decir que totaldevolucion tiene saldo 
                txtDiferencia.Text = (mtotalDevo * -1).ToString();
                mtotalDevo = 0;

            }
            else

            {
                txtDiferencia.Text = "0";
            }

            if (mtotalDevo < 0)
            {
                mtotalDevo = mtotalDevo * -1;
            }
            int p = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
            txtsubtotal.Text = p.ToString("#,#", CultureInfo.InvariantCulture);


            txtCantidadProductos.Content = numProducto.ToString();
            if (Convert.ToInt32(txtdescuento.Text) == 0)
            {
                int pr = ToEntero(txtsubtotal.Text, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                txttotal.Text = pr.ToString("#,#", CultureInfo.InvariantCulture);

            }
            else
            {
                int pr = ToEntero(txtsubtotal.Text, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));

                double des = Convert.ToDouble(txtdescuento.Text) / Convert.ToInt32(100);
                double res = (Convert.ToInt32(pr) - Convert.ToDouble(pr) * des);
                txttotal.Text = res.ToString("#,#", CultureInfo.InvariantCulture);
            }

        }
Example #3
0
        //Al presionar enter en spinkbox que se actualice en tabla la cantidad 
        private void TextBoxValue_KeyDown(Object sender, KeyEventArgs e)
        {

            if (e.Key == Key.Enter)
            {
                if (datagridVentas.SelectedItem != null)
                {
                    if (datagridVentas.SelectedItem is VentaTemporal)
                    {
                        var row = (VentaTemporal)datagridVentas.SelectedItem;
                        ProductoFacade prodFobtener = new ProductoFacade();
                        Producto Prod = new Producto();
                        Prod = prodFobtener.getProductosByID(row.idProducto);
                        int filaProd = 0;
                        int num = 0;
                        if (row != null)
                        {
                            //Tomar valor de cantidad  datagrid y aumentar 
                            List<VentaTemporal> vtemporal = new List<VentaTemporal>();
                            var rows = GetDataGridRows(datagridVentas);
                            foreach (DataGridRow r in rows)
                            {
                                VentaTemporal rv = (VentaTemporal)r.Item;
                                vtemporal.Add(rv);
                            }
                            //buscar el id de list con el seleccionado en datagrid
                            foreach (var r in vtemporal)
                            {
                                if (row.idProducto.Equals(r.idProducto))
                                {
                                    filaProd = num;
                                }
                                num = num + 1;

                            }

                            //Verificar stock de producto
                            ProductoFacade prodcantiFacade = new ProductoFacade();
                            int maxstock = Convert.ToInt32(prodcantiFacade.getStockProductoByidProd(row.idProducto));
                            if (Value <= maxstock)
                            {
                                int total = Convert.ToInt32(Prod.precio) * Convert.ToInt32(Value);
                                vtemporal[filaProd].cantidad = Value.ToString();
                                vtemporal[filaProd].total = total.ToString();

                                datagridVentas.ItemsSource = null;
                                datagridVentas.ItemsSource = vtemporal;
                                datagridVentas.SelectedIndex = filaProd;
                            }
                            else
                            {
                                MessageBox.Show("El producto no cuenta con más stock", "Magnolia", MessageBoxButton.OK, MessageBoxImage.Error);
                                Value = maxstock;
                            }

                        }
                    }
                }
                //Recorrer tabla para sumar total
                /* subtotal = 0;

                 foreach (var i in venta)
                 {
                     subtotal = subtotal + Convert.ToInt32(i.total);
                     //MessageBox.Show(i.total.ToString());
                 }
                 txtsubtotal.Text = subtotal.ToString();*/
                subtotal = 0;
                int numProducto = 0;
                foreach (var i in venta)
                {
                    subtotal = subtotal + Convert.ToInt32(i.total);
                    //MessageBox.Show(i.total.ToString());
                    numProducto = numProducto + 1;
                }
                int p = ToEntero(txtsubtotal.Text, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                txtsubtotal.Text = p.ToString("#,#", CultureInfo.InvariantCulture); ;
                //                txtDiferencia.Text = (Convert.ToInt32(txtsubtotal.Text) - dineroDevolucion).ToString();
                txtCantidadProductos.Content = numProducto.ToString();
                if (Convert.ToInt32(txtdescuento.Text) == 0)
                {

                    /********************************************************/
                    int mtotalDevo = subtotal - dineroDevolucion;
                    if (mtotalDevo < 0)
                    {
                        //Quiere decir que totaldevolucion tiene saldo 
                        txtDiferencia.Text = (mtotalDevo * -1).ToString();
                        mtotalDevo = 0;

                    }
                    else

                    {
                        txttotal.Text = "0";
                        txtDiferencia.Text = "0";
                    }

                    if (mtotalDevo < 0)
                    {
                        mtotalDevo = mtotalDevo * -1;
                    }
                    int pr = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txtsubtotal.Text = pr.ToString("#,#", CultureInfo.InvariantCulture); ;

                    int prT = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txttotal.Text = prT.ToString("#,#", CultureInfo.InvariantCulture); ;


                    /********************************************************/

                }
                else
                {
                    //falto en varia parte el pasar 
                    double des = Convert.ToDouble(txtdescuento.Text) / Convert.ToInt32(100);
                    int pr = ToEntero(txtsubtotal.Text, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    double totalDes = Convert.ToInt32(pr) - Convert.ToDouble(pr) * des;

                    int prT = ToEntero(totalDes.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txttotal.Text = prT.ToString("#,#", CultureInfo.InvariantCulture); ;


                    //txtDiferencia.Text = (totalDes - dineroDevolucion).ToString();
                }
            }

        }
Example #4
0
        private void Increase_Click(object sender, RoutedEventArgs e)
        {
            if (Value < Maximum)
            {
                Value++;
                /*Aumentar en tabla valor  de cantidad de valor seleccionado de producto*/
                if (datagridVentas.SelectedItem != null)
                {
                    if (datagridVentas.SelectedItem is VentaTemporal)
                    {
                        var row = (VentaTemporal)datagridVentas.SelectedItem;
                        ProductoFacade prodFobtener = new ProductoFacade();
                        Producto Prod = new Producto();
                        Prod = prodFobtener.getProductosByID(row.idProducto);
                        int filaProd = 0;
                        int num = 0;
                        if (row != null)
                        {

                            //MessageBox.Show(row.cantidad); 
                            //Tomar valor de cantidad  datagrid y aumentar 
                            List<VentaTemporal> vtemporal = new List<VentaTemporal>();
                            var rows = GetDataGridRows(datagridVentas);
                            foreach (DataGridRow r in rows)
                            {
                                VentaTemporal rv = (VentaTemporal)r.Item;
                                vtemporal.Add(rv);
                            }
                            //buscar el id de list con el seleccionado en datagrid
                            foreach (var r in vtemporal)
                            {
                                if (row.idProducto.Equals(r.idProducto))
                                {
                                    filaProd = num;
                                }
                                num = num + 1;

                            }
                            ProductoFacade prodcantiFacade = new ProductoFacade();
                            int maxstock = Convert.ToInt32(prodcantiFacade.getStockProductoByidProd(row.idProducto));
                            if (Value <= maxstock)
                            {
                                int total = Convert.ToInt32(Prod.precio) * Convert.ToInt32(Value);
                                vtemporal[filaProd].cantidad = Value.ToString();
                                vtemporal[filaProd].total = total.ToString();



                                datagridVentas.ItemsSource = null;
                                datagridVentas.ItemsSource = vtemporal;
                                datagridVentas.SelectedIndex = filaProd;
                            }
                            else
                            {
                                MessageBox.Show("El producto no cuenta con más stock", "Magnolia", MessageBoxButton.OK, MessageBoxImage.Error);
                                Value = maxstock;
                            }

                        }
                    }
                }
                subtotal = 0;
                int numProducto = 0;
                foreach (var i in venta)
                {
                    subtotal = subtotal + Convert.ToInt32(i.total);

                    numProducto = numProducto + 1;
                }

                txtCantidadProductos.Content = numProducto.ToString();

                if (Convert.ToInt32(txtdescuento.Text) == 0)
                {
                    /********************************************************/
                    int mtotalDevo = subtotal - dineroDevolucion;
                    if (mtotalDevo < 0)
                    {
                        //Quiere decir que totaldevolucion tiene saldo 
                        txtDiferencia.Text = (mtotalDevo * -1).ToString();
                        mtotalDevo = 0;

                    }
                    else

                    {
                        txttotal.Text = "0";
                        txtDiferencia.Text = "0";
                    }

                    if (mtotalDevo < 0)
                    {
                        mtotalDevo = mtotalDevo * -1;
                    }
                    int p = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txtsubtotal.Text = p.ToString("#,#", CultureInfo.InvariantCulture);

                    int prT = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txttotal.Text = prT.ToString("#,#", CultureInfo.InvariantCulture); ;

                    /********************************************************/

                    //txttotal.Text = txtsubtotal.Text;

                }
                else
                {
                    double des = Convert.ToDouble(txtdescuento.Text) / Convert.ToInt32(100);
                    /********************************************************/
                    int mtotalDevo = subtotal - dineroDevolucion;
                    if (mtotalDevo < 0)
                    {
                        //Quiere decir que totaldevolucion tiene saldo 
                        txtDiferencia.Text = (mtotalDevo * -1).ToString();
                        mtotalDevo = 0;

                    }
                    else

                    {
                        txttotal.Text = "0";
                        txtDiferencia.Text = "0";
                    }

                    if (mtotalDevo < 0)
                    {
                        mtotalDevo = mtotalDevo * -1;
                    }
                    int p = ToEntero(mtotalDevo.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txtsubtotal.Text = p.ToString("#,#", CultureInfo.InvariantCulture);

                    double d = (mtotalDevo - mtotalDevo * des);

                    int prT = ToEntero(d.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    txttotal.Text = prT.ToString("#,#", CultureInfo.InvariantCulture); ;

                    /********************************************************/
                }
                RaiseEvent(new RoutedEventArgs(IncreaseClickedEvent));
            }
        }
Example #5
0
        //Al presionar enter en spinkbox que se actualice en tabla la cantidad 
        private void TextBoxValue_KeyDown(Object sender, KeyEventArgs e)
        {

            if (e.Key == Key.Enter)
            {
                if (datagridVentas.Items.Count > 0)
                {
                    if (datagridVentas.SelectedItem != null)
                    {
                        if (datagridVentas.SelectedItem is VentaTemporal)
                        {
                            var row = (VentaTemporal)datagridVentas.SelectedItem;
                            ProductoFacade prodFobtener = new ProductoFacade();
                            Producto Prod = new Producto();
                            Prod = prodFobtener.getProductosByID(row.idProducto);
                            int filaProd = 0;
                            int num = 0;
                            if (row != null)
                            {
                                //Tomar valor de cantidad  datagrid y aumentar 
                                List<VentaTemporal> vtemporal = new List<VentaTemporal>();
                                var rows = GetDataGridRows(datagridVentas);
                                foreach (DataGridRow r in rows)
                                {
                                    VentaTemporal rv = (VentaTemporal)r.Item;
                                    vtemporal.Add(rv);
                                }
                                //buscar el id de list con el seleccionado en datagrid
                                foreach (var r in vtemporal)
                                {
                                    if (row.idProducto.Equals(r.idProducto))
                                    {
                                        filaProd = num;
                                    }
                                    num = num + 1;

                                }

                                //Verificar stock de producto
                                ProductoFacade prodcantiFacade = new ProductoFacade();
                                int maxstock = Convert.ToInt32(prodcantiFacade.getStockProductoByidProd(row.idProducto));
                                if (Valor <= Convert.ToInt32(row.cantidad))
                                {
                                    int total = Convert.ToInt32(Prod.precio) * Convert.ToInt32(Valor);
                                    vtemporal[filaProd].devolver = Valor.ToString();
                                    //vtemporal[filaProd].total = total.ToString();
                                    int t = ToEntero(total.ToString(), NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                                    string totalF = t.ToString("#,#", CultureInfo.InvariantCulture); ;
                                    ltotal.Content = totalF.ToString();
                                    datagridVentas.ItemsSource = null;
                                    datagridVentas.ItemsSource = vtemporal;
                                    datagridVentas.SelectedIndex = filaProd;
                                }
                                else
                                {
                                    //MessageBox.Show("Producto, segun inventario, no cuenta con mas stock");
                                    Valor = Convert.ToInt32(row.cantidad);
                                }

                            }
                        }
                    }
                }
                //Recorrer tabla para sumar total
                /* subtotal = 0;

                 foreach (var i in venta)
                 {
                     subtotal = subtotal + Convert.ToInt32(i.total);
                     //MessageBox.Show(i.total.ToString());
                 }
                 txtsubtotal.Text = subtotal.ToString();*/
                subtotal = 0;
                int numProducto = 0;
                foreach (var i in venta)
                {
                    int p1 = ToEntero(i.total, NumberStyles.Float | NumberStyles.AllowThousands, new CultureInfo("en-GB"));
                    subtotal = subtotal + Convert.ToInt32(p1);
                    //MessageBox.Show(i.total.ToString());
                    numProducto = numProducto + 1;
                }
                /*txtsubtotal.Text = subtotal.ToString();
                txtCantidadProductos.Content = numProducto.ToString();
                if (Convert.ToInt32(txtdescuento.Text) == 0)
                {
                    txttotal.Text = txtsubtotal.Text;
                }
                else
                {
                    double des = Convert.ToDouble(txtdescuento.Text) / Convert.ToDouble(100);
                    txttotal.Text = (Convert.ToInt32(txtsubtotal.Text) - Convert.ToDouble(txtsubtotal.Text) * des).ToString();
                }*/
            }

        }