Exemplo n.º 1
0
        public static List <Pro_Productos> BuscarProductos_Codigo(Int64 pCodigo)
        {
            List <Pro_Productos> Lista = new List <Pro_Productos>();

            using (MySqlConnection conexion = Conexion.MiConexion())
            {
                MySqlCommand comando = new MySqlCommand(string.Format(
                                                            //"Select Codigo, Nombre,  Descripcion, Precio from Productos where Codigo like '%{0}%' or Nombre like '%{1}%'", pCodigo, pNombre), conexion);
                                                            "Select Codigo, Nombre,  Descripcion, Precio, Stock, TipoUnidad from Productos where Codigo={0}", pCodigo), conexion);
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Pro_Productos pProducto = new Pro_Productos();
                    pProducto.Codigo      = reader.GetInt64(0);
                    pProducto.Nombre      = reader.GetString(1);
                    pProducto.Descripcion = reader.GetString(2);
                    pProducto.Precio      = reader.GetDouble(3);
                    pProducto.Stock       = reader.GetInt16(4);
                    pProducto.TipoUnidad  = reader.GetString(5);

                    Lista.Add(pProducto);
                }
                conexion.Close();
                return(Lista);
            }
        }
Exemplo n.º 2
0
        public static List <Pro_Productos> CargarProductos()
        {
            List <Pro_Productos> ListaProductos = new List <Pro_Productos>();

            using (MySqlConnection conexion = Conexion.MiConexion())
            {
                string          Consulta = "SELECT * FROM Productos";
                MySqlCommand    Comando  = new MySqlCommand(Consulta, conexion);
                MySqlDataReader reader   = Comando.ExecuteReader();

                while (reader.Read())
                {
                    Pro_Productos pProducto = new Pro_Productos();
                    pProducto.Codigo      = Convert.ToInt64(reader[0].ToString());
                    pProducto.Nombre      = reader[1].ToString();
                    pProducto.Descripcion = reader[2].ToString();
                    pProducto.Precio      = Convert.ToDouble(reader[3].ToString());
                    pProducto.Stock       = Convert.ToDouble(reader[4].ToString());
                    pProducto.TipoUnidad  = reader[5].ToString();

                    ListaProductos.Add(pProducto);
                }
            }
            return(ListaProductos);
        }
Exemplo n.º 3
0
        private void btnGuardar_Producto_Click(object sender, EventArgs e)
        {
            try
            {
                Pro_Productos Pro_Productos = new Pro_Productos();
                if (txtStock.Text.Length == 0)
                {
                    MessageBox.Show("Error en campo Stock", "Campos Obligatorio, verifique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtStock.Focus();
                    return;
                }

                Pro_Productos.Codigo      = Convert.ToInt32(txtCodigo.Text);
                Pro_Productos.Nombre      = txtNombre.Text;
                Pro_Productos.Descripcion = txtDescripcion.Text;
                Pro_Productos.Precio      = Convert.ToDouble(txtPrecio.Text);
                Pro_Productos.Stock       = Convert.ToInt32(txtStock.Text);
                Pro_Productos.TipoUnidad  = cmbTipo.Text;
                Met_Productos.Modificar(Pro_Productos);
                MessageBox.Show("Stock Modificado Correctamente", "Datos Guardados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dataGridView1.DataSource = Met_Productos.CargarProductos();
                limpiar();
            }
            catch
            {
                MessageBox.Show("No se pudieron Guardar lo datos", "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 4
0
        public static int Modificar(Pro_Productos pProducto)
        {
            int retorno = 0;

            using (MySqlConnection conexion = Conexion.MiConexion())
            {
                MySqlCommand comando = new MySqlCommand(string.Format("Update Productos set Nombre='{0}', Descripcion='{1}', Precio='{2}', Stock='{3}', TipoUnidad='{4}' where Codigo={5}",
                                                                      pProducto.Nombre, pProducto.Descripcion, pProducto.Precio, pProducto.Stock, pProducto.TipoUnidad, pProducto.Codigo), conexion);

                retorno = comando.ExecuteNonQuery();
                conexion.Close();
            }
            return(retorno);
        }
Exemplo n.º 5
0
        public static int Agregar(Pro_Productos pProducto)
        {
            int retorno = 0;

            using (MySqlConnection conexion = Conexion.MiConexion())
            {
                MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Productos (Codigo, Nombre, Descripcion, Precio, Stock, TipoUnidad) values ('{0}', '{1}','{2}','{3}','{4}','{5}')",
                                                                      pProducto.Codigo, pProducto.Nombre, pProducto.Descripcion, pProducto.Precio, pProducto.Stock, pProducto.TipoUnidad), conexion);

                retorno = Comando.ExecuteNonQuery();
                conexion.Close();
            }
            return(retorno);
        }
Exemplo n.º 6
0
        public static int Modificar_Stock(Pro_Productos pProducto)
        {
            int retorno = 0;

            using (MySqlConnection conexion = Conexion.MiConexion())
            {
                MySqlCommand comando = new MySqlCommand(string.Format("Update Productos set Stock='{0}' where Codigo={1}",
                                                                      pProducto.Stock, pProducto.Codigo), conexion);

                retorno = comando.ExecuteNonQuery();
                conexion.Close();
            }
            return(retorno);
        }
Exemplo n.º 7
0
        private void btnAgregar_Carrito_Click(object sender, EventArgs e)
        {
            Pro_Productos Pro_Productos = new Pro_Productos();

            //Validar si los campos codigo de producto y nombre de producto estan vacios
            if (txtProducto.Text.Length == 0 && txtNombre.Text.Length == 0)
            {
                MessageBox.Show("Error en campo codigo o nombre estan vacios", "Campo Obligatorio, verifique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtProducto.Focus();
                return;
            }
            //Validar si el campo codigo de producto es diferencte de vacio y si nombre de producto esta vacio
            else if (txtProducto.Text.Length != 0 && txtNombre.Text.Length == 0)
            {
                long   Codigo;
                string Nombre, Descripcion, TipoUnidad;
                double PrecioUnitario, Cantidad, Importe;
                listView1.Items.Clear();

                if (txtProducto.Text.Length != 0)
                {
                    if (!Venta.Existe(Convert.ToInt64(txtProducto.Text)) == true)
                    {
                        MySqlConnection conexion = Conexion.MiConexion();
                        string          query    = "SELECT * FROM Productos WHERE Codigo ='" + this.txtProducto.Text + "' ";
                        MySqlCommand    comando  = new MySqlCommand(query, conexion);
                        MySqlDataReader leer     = comando.ExecuteReader();

                        if (leer.Read() == true)
                        {
                            Codigo         = long.Parse(leer["Codigo"].ToString());
                            Nombre         = leer["Nombre"].ToString();
                            Descripcion    = leer["Descripcion"].ToString();
                            TipoUnidad     = leer["TipoUnidad"].ToString();
                            PrecioUnitario = double.Parse(leer["Precio"].ToString());
                            Cantidad       = double.Parse(txtCantidad.Text);
                            Importe        = double.Parse(PrecioUnitario.ToString()) * double.Parse(Cantidad.ToString());

                            //Provisional

                            /*
                             * txtCodigo1.Text = Convert.ToString(Codigo);
                             * txtNombre1.Text = Nombre;
                             * txtDescripcion1.Text = Descripcion;
                             * txtTipoUnidad1.Text = TipoUnidad;
                             * txtPrecio1.Text = Convert.ToString(PrecioUnitario);
                             * txtCantidad1.Text = Convert.ToString(Cantidad);
                             * txtImporte1.Text = Convert.ToString(Importe);
                             */
                            ///////////////////////////////////////////////////////////////

                            //Guardar productos en tabla temporal
                            Pro_Venta Pro_Venta = new Pro_Venta();
                            Pro_Venta.Codigo         = Convert.ToInt64(Codigo);
                            Pro_Venta.Nombre         = Nombre;
                            Pro_Venta.Descripcion    = Descripcion;
                            Pro_Venta.TipoUnidad     = TipoUnidad;
                            Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario);
                            Pro_Venta.Cantidad       = Convert.ToDouble(Cantidad);
                            Pro_Venta.Importe        = Convert.ToDouble(Importe);
                            Venta.AgregarVenta_Proceso(Pro_Venta);
                            //////////////////////////////////////////////////////////////
                        }
                        else
                        {
                            MessageBox.Show("Producto no encontrado");
                        }
                    }
                    else
                    {
                        //MessageBox.Show("Error, datos repetidos");
                        if (txtCantidad.Text == "1")
                        {
                            MySqlConnection conexion = Conexion.MiConexion();
                            string          query    = "SELECT * FROM Venta_Proceso WHERE Codigo ='" + this.txtProducto.Text + "' ";
                            MySqlCommand    comando  = new MySqlCommand(query, conexion);
                            MySqlDataReader leer     = comando.ExecuteReader();
                            if (leer.Read() == true)
                            {
                                Codigo         = long.Parse(leer["Codigo"].ToString());
                                Nombre         = leer["Nombre"].ToString();
                                Descripcion    = leer["Descripcion"].ToString();
                                TipoUnidad     = leer["TipoUnidad"].ToString();
                                PrecioUnitario = double.Parse(leer["PrecioUnitario"].ToString());
                                double Cant     = double.Parse(leer["Cantidad"].ToString());
                                double quantity = Cant = Cant + 1;
                                Importe = double.Parse(PrecioUnitario.ToString()) * double.Parse(quantity.ToString());
                                ///////////////////////////////////////////////////////////////////////////
                                //Guardar productos en tabla temporal
                                Pro_Venta Pro_Venta = new Pro_Venta();
                                Pro_Venta.Codigo         = Convert.ToInt64(Codigo);
                                Pro_Venta.Nombre         = Nombre;
                                Pro_Venta.Descripcion    = Descripcion;
                                Pro_Venta.TipoUnidad     = TipoUnidad;
                                Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario);
                                Pro_Venta.Cantidad       = Convert.ToDouble(quantity);
                                Pro_Venta.Importe        = Convert.ToDouble(Importe);
                                Venta.Modificar_Venta(Pro_Venta);
                            }
                        }
                        else
                        {
                            //MessageBox.Show("txtCantidad es mayor que 1");
                            MySqlConnection conexion = Conexion.MiConexion();
                            string          query    = "SELECT * FROM Venta_Proceso WHERE Codigo ='" + this.txtProducto.Text + "' ";
                            MySqlCommand    comando  = new MySqlCommand(query, conexion);
                            MySqlDataReader leer     = comando.ExecuteReader();
                            if (leer.Read() == true)
                            {
                                Codigo         = long.Parse(leer["Codigo"].ToString());
                                Nombre         = leer["Nombre"].ToString();
                                Descripcion    = leer["Descripcion"].ToString();
                                TipoUnidad     = leer["TipoUnidad"].ToString();
                                PrecioUnitario = double.Parse(leer["PrecioUnitario"].ToString());
                                double Cant     = double.Parse(leer["Cantidad"].ToString());
                                double quantity = Cant + double.Parse(txtCantidad.Text);
                                Importe = double.Parse(PrecioUnitario.ToString()) * double.Parse(quantity.ToString());
                                ///////////////////////////////////////////////////////////////////////////
                                //Guardar productos en tabla temporal
                                Pro_Venta Pro_Venta = new Pro_Venta();
                                Pro_Venta.Codigo         = Convert.ToInt64(Codigo);
                                Pro_Venta.Nombre         = Nombre;
                                Pro_Venta.Descripcion    = Descripcion;
                                Pro_Venta.TipoUnidad     = TipoUnidad;
                                Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario);
                                Pro_Venta.Cantidad       = Convert.ToDouble(quantity);
                                Pro_Venta.Importe        = Convert.ToDouble(Importe);
                                Venta.Modificar_Venta(Pro_Venta);
                            }
                        }
                    }
                }
                //Cargar productos de tabla de venta temporal
                MySqlConnection  conexion2 = Conexion.MiConexion();
                MySqlDataAdapter Consulta  = new MySqlDataAdapter("Select * from Venta_Proceso", conexion2);
                DataTable        dt        = new DataTable();
                Consulta.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ListViewItem List;
                    List = listView1.Items.Add(dt.Rows[i][0].ToString());
                    List.SubItems.Add(dt.Rows[i][1].ToString());
                    List.SubItems.Add(dt.Rows[i][2].ToString());
                    List.SubItems.Add(dt.Rows[i][3].ToString());
                    List.SubItems.Add(dt.Rows[i][4].ToString());
                    List.SubItems.Add(dt.Rows[i][5].ToString());
                    List.SubItems.Add(dt.Rows[i][6].ToString());
                }

                double Total = 0;
                foreach (ListViewItem I in listView1.Items)
                {
                    Total += double.Parse(listView1.Items[I.Index].SubItems[6].Text);
                }
                txtTotal.Text = Total.ToString();
                txtProducto.Clear();
                txtNombre.Text   = "";
                txtCantidad.Text = "1";
                txtProducto.Focus();
            }
            else if (txtProducto.Text.Length == 0 && txtNombre.Text.Length != 0)
            {
                long   Codigo;
                string Nombre, Descripcion, TipoUnidad;
                double PrecioUnitario, Importe;
                listView1.Items.Clear();
                MySqlConnection conexion3 = Conexion.MiConexion();
                string          query2    = "Select * from Productos where concat_ws(' ',Nombre,Descripcion) LIKE '%" + this.txtNombre.Text + "%';";
                MySqlCommand    comando2  = new MySqlCommand(query2, conexion3);
                MySqlDataReader leer2     = comando2.ExecuteReader();

                if (leer2.Read() == true)
                {
                    Codigo_Nombre = long.Parse(leer2["Codigo"].ToString());
                }

                if (!Venta.Existe(Convert.ToInt64(Codigo_Nombre)) == false)
                {
                    //MessageBox.Show("Ya existe");
                    if (txtCantidad.Text == "1")
                    {
                        MySqlConnection conexion = Conexion.MiConexion();
                        string          query    = "SELECT * FROM Venta_Proceso WHERE Codigo ='" + Codigo_Nombre + "' ";
                        MySqlCommand    comando  = new MySqlCommand(query, conexion);
                        MySqlDataReader leer     = comando.ExecuteReader();
                        if (leer.Read() == true)
                        {
                            Codigo         = long.Parse(leer["Codigo"].ToString());
                            Nombre         = leer["Nombre"].ToString();
                            Descripcion    = leer["Descripcion"].ToString();
                            TipoUnidad     = leer["TipoUnidad"].ToString();
                            PrecioUnitario = double.Parse(leer["PrecioUnitario"].ToString());
                            double Cant     = double.Parse(leer["Cantidad"].ToString());
                            double quantity = Cant = Cant + 1;
                            Importe = double.Parse(PrecioUnitario.ToString()) * double.Parse(quantity.ToString());
                            ///////////////////////////////////////////////////////////////////////////
                            //Guardar productos en tabla temporal
                            Pro_Venta Pro_Venta = new Pro_Venta();
                            Pro_Venta.Codigo         = Convert.ToInt64(Codigo);
                            Pro_Venta.Nombre         = Nombre;
                            Pro_Venta.Descripcion    = Descripcion;
                            Pro_Venta.TipoUnidad     = TipoUnidad;
                            Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario);
                            Pro_Venta.Cantidad       = Convert.ToDouble(quantity);
                            Pro_Venta.Importe        = Convert.ToDouble(Importe);
                            Venta.Modificar_Venta(Pro_Venta);
                        }
                    }
                    else
                    {
                        //MessageBox.Show("txtCantidad es mayor que 1");
                        MySqlConnection conexion = Conexion.MiConexion();
                        string          query    = "SELECT * FROM Venta_Proceso WHERE Codigo ='" + Codigo_Nombre + "' ";
                        MySqlCommand    comando  = new MySqlCommand(query, conexion);
                        MySqlDataReader leer     = comando.ExecuteReader();
                        if (leer.Read() == true)
                        {
                            Codigo         = long.Parse(leer["Codigo"].ToString());
                            Nombre         = leer["Nombre"].ToString();
                            Descripcion    = leer["Descripcion"].ToString();
                            TipoUnidad     = leer["TipoUnidad"].ToString();
                            PrecioUnitario = double.Parse(leer["PrecioUnitario"].ToString());
                            double Cant     = double.Parse(leer["Cantidad"].ToString());
                            double quantity = Cant + double.Parse(txtCantidad.Text);
                            Importe = double.Parse(PrecioUnitario.ToString()) * double.Parse(quantity.ToString());
                            ///////////////////////////////////////////////////////////////////////////
                            //Guardar productos en tabla temporal
                            Pro_Venta Pro_Venta = new Pro_Venta();
                            Pro_Venta.Codigo         = Convert.ToInt64(Codigo);
                            Pro_Venta.Nombre         = Nombre;
                            Pro_Venta.Descripcion    = Descripcion;
                            Pro_Venta.TipoUnidad     = TipoUnidad;
                            Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario);
                            Pro_Venta.Cantidad       = Convert.ToDouble(quantity);
                            Pro_Venta.Importe        = Convert.ToDouble(Importe);
                            Venta.Modificar_Venta(Pro_Venta);
                        }
                    }
                }
                else
                {
                    //MessageBox.Show("No existe, bla bla");
                    long   Codigo2;
                    string Nombre2, Descripcion2, TipoUnidad2;
                    double PrecioUnitario2, Cantidad2, Importe2;
                    listView1.Items.Clear();
                    MySqlConnection conexion = Conexion.MiConexion();
                    string          query    = "Select * from Productos where concat_ws(' ',Nombre,Descripcion) LIKE '%" + this.txtNombre.Text + "%';";
                    MySqlCommand    comando  = new MySqlCommand(query, conexion);
                    MySqlDataReader leer     = comando.ExecuteReader();

                    if (leer.Read() == true)
                    {
                        Codigo2         = long.Parse(leer["Codigo"].ToString());
                        Nombre2         = leer["Nombre"].ToString();
                        Descripcion2    = leer["Descripcion"].ToString();
                        TipoUnidad2     = leer["TipoUnidad"].ToString();
                        PrecioUnitario2 = double.Parse(leer["Precio"].ToString());
                        Cantidad2       = double.Parse(txtCantidad.Text);
                        Importe2        = double.Parse(PrecioUnitario2.ToString()) * double.Parse(Cantidad2.ToString());

                        //Provisional

                        /*
                         * txtCodigo1.Text = Convert.ToString(Codigo);
                         * txtNombre1.Text = Nombre;
                         * txtDescripcion1.Text = Descripcion;
                         * txtTipoUnidad1.Text = TipoUnidad;
                         * txtPrecio1.Text = Convert.ToString(PrecioUnitario);
                         * txtCantidad1.Text = Convert.ToString(Cantidad);
                         * txtImporte1.Text = Convert.ToString(Importe);
                         */
                        ///////////////////////////////////////////////////////////////

                        //Guardar productos en tabla temporal
                        Pro_Venta Pro_Venta = new Pro_Venta();
                        Pro_Venta.Codigo         = Convert.ToInt64(Codigo2);
                        Pro_Venta.Nombre         = Nombre2;
                        Pro_Venta.Descripcion    = Descripcion2;
                        Pro_Venta.TipoUnidad     = TipoUnidad2;
                        Pro_Venta.PrecioUnitario = Convert.ToDouble(PrecioUnitario2);
                        Pro_Venta.Cantidad       = Convert.ToDouble(Cantidad2);
                        Pro_Venta.Importe        = Convert.ToDouble(Importe2);
                        Venta.AgregarVenta_Proceso(Pro_Venta);
                        //////////////////////////////////////////////////////////////
                    }
                    else
                    {
                        MessageBox.Show("Producto no encontrado");
                    }
                }

                //Cargar productos de tabla de venta temporal
                MySqlConnection  conexion2 = Conexion.MiConexion();
                MySqlDataAdapter Consulta  = new MySqlDataAdapter("Select * from Venta_Proceso", conexion2);
                DataTable        dt        = new DataTable();
                Consulta.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ListViewItem List;
                    List = listView1.Items.Add(dt.Rows[i][0].ToString());
                    List.SubItems.Add(dt.Rows[i][1].ToString());
                    List.SubItems.Add(dt.Rows[i][2].ToString());
                    List.SubItems.Add(dt.Rows[i][3].ToString());
                    List.SubItems.Add(dt.Rows[i][4].ToString());
                    List.SubItems.Add(dt.Rows[i][5].ToString());
                    List.SubItems.Add(dt.Rows[i][6].ToString());
                }

                double Total = 0;
                foreach (ListViewItem I in listView1.Items)
                {
                    Total += double.Parse(listView1.Items[I.Index].SubItems[6].Text);
                }
                txtTotal.Text = Total.ToString();
                txtProducto.Clear();
                txtNombre.Text   = "";
                txtCantidad.Text = "1";
                txtProducto.Focus();
            }
            else
            {
                MessageBox.Show("Error en campo codigo y nombre no deben estar llenos en el mismo formulario", "Campo Obligatorio, verifique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtProducto.Focus();
                return;
            }
        }
Exemplo n.º 8
0
        private void btnAgregarPago_Click(object sender, EventArgs e)
        {
            if (txtPagoCon.Text.Length == 0)
            {
                MessageBox.Show("Error en campo pagon con", "Campo Obligatorio, verifique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPagoCon.Focus();
                return;
            }
            else if (Convert.ToDouble(txtPagoCon.Text) < Convert.ToDouble(txtTotal.Text))
            {
                MessageBox.Show("El campo de pago con debe ser mayor o igual al total", "Error en campo pago con, verifique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPagoCon.Focus();
                return;
            }

            //guardar venta
            Pro_Venta Pro_Venta = new Pro_Venta();

            Pro_Venta.Cliente = txtCliente.Text;
            Pro_Venta.Total   = Convert.ToDouble(txtTotal.Text);
            Pro_Venta.PagoCon = Convert.ToDouble(txtPagoCon.Text);

            //sacar cambio
            double total = double.Parse(txtPagoCon.Text) - double.Parse(txtTotal.Text);

            txtCambio.Text   = total.ToString();
            Pro_Venta.Cambio = Convert.ToDouble(txtCambio.Text);

            int resultado = Venta.AgregarVenta(Pro_Venta);

            if (resultado > 0)
            {
                //MessageBox.Show("Datos Guardados Correctamente", "Datos Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //limpiar();
            }
            else
            {
                MessageBox.Show("No se pudieron Guardar lo datos", "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            //guardar detalle de las ventas
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                Pro_Venta.Codigo   = Convert.ToInt64(listView1.Items[i].SubItems[0].Text);
                Pro_Venta.Cantidad = Convert.ToDouble(listView1.Items[i].SubItems[5].Text);
                Pro_Venta.Precio   = Convert.ToDouble(listView1.Items[i].SubItems[4].Text);
                Venta.AgregarDetalleVenta(Pro_Venta);

                //Modificar Stock
                MySqlConnection conexion = Conexion.MiConexion();
                string          ada      = "Select Stock from Productos where Codigo='" + listView1.Items[i].SubItems[0].Text + "';";
                MySqlCommand    comando  = new MySqlCommand(ada, conexion);
                MySqlDataReader leer     = comando.ExecuteReader();
                if (leer.Read() == true)
                {
                    double        cantidad      = 0;
                    Pro_Productos Pro_Productos = new Pro_Productos();
                    double        stock         = Convert.ToDouble(leer["Stock"].ToString());
                    cantidad = Convert.ToDouble(listView1.Items[i].SubItems[5].Text);
                    double stock_control = double.Parse(stock.ToString()) - cantidad;
                    Pro_Productos.Codigo = Convert.ToInt64(listView1.Items[i].SubItems[0].Text);
                    Pro_Productos.Stock  = Convert.ToDouble(stock_control);
                    Met_Productos.Modificar_Stock(Pro_Productos);
                }
            }

            if (checkBox1.Checked)
            {
                //generar ticket

                Ticket ticket = new Ticket();
                //ticket.HeaderImage = "C:\imagen.jpg"; //esta propiedad no es obligatoria
                ticket.AddHeaderLine("Ferreteria y Materiales");
                ticket.AddHeaderLine("Del Rio");
                ticket.AddHeaderLine("Villa Toledo #2719");
                ticket.AddHeaderLine("Culiacan, Sin");
                ticket.AddHeaderLine("RFC: VILA-841113-3R4");
                //ticket.AddSubHeaderLine("Ticket # 1");
                ticket.AddSubHeaderLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());

                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    //ticket.AddItem(FormPadre.listView1.Items[4].Text, FormPadre.listView1.Items[1].Text, FormPadre.listView1.Items[5].Text);
                    ticket.AddItem(listView1.Items[i].SubItems[5].Text, listView1.Items[i].SubItems[1].Text, listView1.Items[i].SubItems[6].Text);
                }
                //ticket.AddTotal("SubTotal", txtSubTotal.Text);
                //ticket.AddTotal("IVA", txtIVA.Text);
                //Add total utiliza dos variables para poder funcionar
                ticket.AddTotal("Total", txtTotal.Text); //Ponemos un total en blanco que sirve de espacio
                ticket.AddTotal("Pago Con", txtPagoCon.Text);
                ticket.AddTotal("Cambio", txtCambio.Text);
                //ticket.AddHeaderLine("Le atendio", tssUsuarioVenta.Text);
                ticket.AddFooterLine("GRACIAS POR TU VISITA");
                //ticket.PrintTicket("Printer");
                ticket.PrintTicket("EPSON TM-U220 Receipt");
            }
        }