Beispiel #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!txtConcepto.Equals("") && !txtValorCompra.Equals(""))
     {
         LogicaGo logica = new LogicaGo();
         double   valor  = double.Parse(txtValorCompra.Text, NumberStyles.Currency);
         double   total  = double.Parse(txtTotal.Text, NumberStyles.Currency);
         int      res    = logica.insertarGasto(txtConcepto.Text, txtCantidad.Value, valor.ToString(), total.ToString(), dpFecha.Text);
         if (res != 1)
         {
             MessageBox.Show("No se pudo ingresar el registro");
         }
         else
         {
             MessageBox.Show("Gasto Cargado Correctamente");
             cargarGastos();
         }
     }
     else
     {
         MessageBox.Show("Debe ingresar una descripcion");
     }
 }
Beispiel #2
0
        private void txtCodigoBarras_TextChanged(object sender, EventArgs e)
        {
            LogicaGo logica = new LogicaGo();

            producto = logica.obtenerProductoByCodigo(txtCodigoBarras.Text);
            if (producto == null || producto.Nombre == null || txtCodigoBarras.Text.Equals(""))
            {
                return;
            }
            lblId.Text          = producto.IdProducto;
            lblNombre.Text      = producto.Nombre;
            lblDescripcion.Text = "Descripción: " + producto.Descripcion;

            Double value;

            if (Double.TryParse(producto.Precio.ToString(), out value))
            {
                lblPrecio.Text = "Precio: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
            }
            else
            {
                lblPrecio.Text = "Precio: " + String.Empty;
            }
            cbUnidades.Value                = 1;
            cbUnidades.Maximum              = !producto.Servicio ? producto.Existencias : 1000;
            lblMaxUnidades.Text             = "Max: " + producto.Existencias + " unidades";
            lblTipo.Text                    = "Tipo: " + producto.Tipo;
            txtCbEstado.SelectedValue       = producto.IdEstado;
            txtCbCategoria.SelectedValue    = producto.Categoria;
            txtCbSubCategoria.SelectedValue = producto.Subcategoria;
            lblEstado.Text                  = "Estado: " + txtCbEstado.Text;
            lblFecha.Text                   = "Fecha Ingreso: " + producto.Fecha.ToString();
            lblCategoria.Text               = "Categoria: " + txtCbCategoria.Text;
            lblSubCategoria.Text            = "SubCategoria: " + txtCbSubCategoria.Text;
            btnAdd.PerformClick();
            txtCodigoBarras.Text = "";
        }
Beispiel #3
0
        private void lbProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            LogicaGo logica = new LogicaGo();

            lblId.Text = lbProductos.SelectedValue.ToString();
            producto   = logica.ObtenerProducto(lblId.Text);
            if (producto == null)
            {
                return;
            }

            lblId.Text          = producto.IdProducto;
            lblNombre.Text      = producto.Nombre;
            lblDescripcion.Text = "Descripción: " + producto.Descripcion;

            Double value;

            if (Double.TryParse(producto.Precio.ToString(), out value))
            {
                lblPrecio.Text = "Precio: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
            }
            else
            {
                lblPrecio.Text = "Precio: " + String.Empty;
            }
            cbUnidades.Value = 1;
            if (!producto.Servicio)
            {
                cbUnidades.Maximum = producto.Existencias;
            }
            else
            {
                cbUnidades.Maximum = 1000;
            }
            lblMaxUnidades.Text             = "Max: " + producto.Existencias + " unidades";
            lblTipo.Text                    = "Tipo: " + producto.Tipo;
            txtCbEstado.SelectedValue       = producto.IdEstado;
            txtCbCategoria.SelectedValue    = producto.Categoria;
            txtCbSubCategoria.SelectedValue = producto.Subcategoria;
            lblEstado.Text                  = "Estado: " + txtCbEstado.Text;
            lblFecha.Text                   = "Fecha Ingreso: " + producto.Fecha.ToString();
            lblCategoria.Text               = "Categoria: " + txtCbCategoria.Text;
            lblSubCategoria.Text            = "SubCategoria: " + txtCbSubCategoria.Text;
            if (producto.RutaImagen != "")
            {
                string rutaArchivo = ConfigurationManager.AppSettings["rutaImagenes"];
                Image  image;
                if (File.Exists(rutaArchivo + producto.RutaImagen))
                {
                    image = Image.FromFile(rutaArchivo + producto.RutaImagen);
                }
                else
                {
                    image = Image.FromFile(rutaArchivo + @"Images\Productos\default_product.png");
                }
                Rectangle newRect = ImageHandling.GetScaledRectangle(image, pictureBox1.ClientRectangle);
                pictureBox1.Image  = ImageHandling.GetResizedImage(image, newRect);
                pictureBox1.Height = 120;
                pictureBox1.Width  = 120;
            }
            else
            {
                pictureBox1.Image = null;
            }
        }
Beispiel #4
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            LogicaGo logica = new LogicaGo();

            Double value;

            if (txtRecibido.Text.Equals(""))
            {
                //txtRecibido.Text = "0";
                MessageBox.Show("Debe ingresar el valor entregado por el Cliente");
            }
            else
            {
                if (listaProductosVenta.Count == 0)
                {
                    MessageBox.Show("No ha Seleccionado Productos");
                }
                else
                {
                    if (txtNombre.Text.Equals(""))
                    {
                        txtNombre.Text = "Usuario No Definido";
                    }
                    if (Convert.ToDecimal(txtRecibido.Text) < valorFactura)
                    {
                        MessageBox.Show("El valor Recibido no debe ser inferior del total de la factura");
                    }

                    else
                    {
                        if (Double.TryParse((Convert.ToDecimal(txtRecibido.Text) - valorFactura).ToString(), out value))
                        {
                            lblCambio.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
                        }
                        lblCambioTitulo.Text = "Cambio: ";
                        int factura = logica.insertarFactura(txtNombre.Text, txtCelular.Text, txtDireccion.Text, valorFactura, user.Nombres + " " + user.Apellidos);
                        foreach (ProductoVenta p in listaProductosVenta)
                        {
                            logica.insertarVenta(factura, p.IdProducto, (int)p.Cantidad, (double)p.Valor, (double)p.Total);
                        }
                        //int factura = 100;
                        btnCheck.Enabled = false;

                        var confirmResult = MessageBox.Show("Desea Imprimir la factura?",
                                                            "Confirmar Impresión!!",
                                                            MessageBoxButtons.YesNo);
                        if (confirmResult == DialogResult.Yes)
                        {
                            LocalReport reporte = new LocalReport();
                            //reporte.ReportPath = @"..\..\rptFactura.rdlc";
                            reporte.ReportPath = ConfigurationManager.AppSettings["rutaReporteFactura"];
                            ReportParameter[] parameters = new ReportParameter[2];
                            parameters[0] = new ReportParameter("nombre", txtNombre.Text);
                            parameters[1] = new ReportParameter("facturaId", factura.ToString());
                            reporte.SetParameters(parameters);
                            ReportDataSource rds = new ReportDataSource("dsProductosVentas", ConvertToDataTable(listaProductosVenta));
                            reporte.DataSources.Add(rds);
                            Export(reporte);
                            Print();
                        }
                        else
                        {
                            MessageBox.Show("Venta Realizada Correctamente..");
                        }
                    }
                }
            }
            //frmReportFactura reporteFactura = new frmReportFactura();
            //reporteFactura.generarReporte(listaProductosVenta, txtNombre.Text, valorFactura, factura);
            //reporteFactura.Show();
            //MessageBox.Show("Factura generada con exito. Cambio: "+ String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value) +" idFactura: "+factura);
        }