Beispiel #1
0
 private void btnFacturar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtClienteID.Text))
     {
         MessageBox.Show("No se ha asociado un cliente.", "Productos Para Mascotas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (dgFactura.Rows.Count <= 0)
     {
         MessageBox.Show("No hay productos a facturar.", "Productos Para Mascotas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DataTable factura = CFactura.InsertarFactura(int.Parse(txtClienteID.Text), txtVendedorNombre.Text);
         if (factura is not null)
         {
             int res       = 0;
             int idFactura = int.Parse(factura.Rows[0]["IDFactura"].ToString());
             foreach (DataGridViewRow fila in dgFactura.Rows)
             {
                 fila.Cells["TotalParcial"].Value.ToString();
                 int    idProducto = int.Parse(fila.Cells["ID"].Value.ToString());
                 double precio     = double.Parse(fila.Cells["Precio"].Value.ToString());
                 int    cantidad   = int.Parse(fila.Cells["Cantidad"].Value.ToString());
                 res = CFactura.InsertarDetalleFactura(idFactura, idProducto, precio, cantidad);
             }
             if (res > 0)
             {
                 MessageBox.Show("Datos ingresados con exito.", "Productos Para Mascotas", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 btnCancelar.PerformClick();
             }
         }
     }
 }
        private void facturaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CFactura abrir = new CFactura();

            abrir.MdiParent = this;
            abrir.Show();
        }
Beispiel #3
0
 public int Agregar(CFactura fac)
 {
     context.insertFactura(
         fac.venta,
         fac.raz_soc,
         fac.ruc,
         fac.pretotal,
         fac.igv,
         fac.total
         );
     return(context.SaveChanges());
 }
Beispiel #4
0
 public int Editar(CFactura fac)
 {
     context.updateFactura(
         fac.codigo,
         fac.venta,
         fac.raz_soc,
         fac.ruc,
         fac.pretotal,
         fac.igv,
         fac.total
         );
     return(context.SaveChanges());
 }
        public ActionResult CrearE(CFactura factura)
        {
            if (can("crear", "Factura"))
            {
                int success = BLLinstance.AgregarBLL(
                    factura.venta,
                    factura.raz_soc,
                    factura.ruc,
                    factura.pretotal,
                    factura.igv,
                    factura.total);

                return(View("ListadoE", GetListado()));
            }
            else
            {
                return(IndexE());
            }
        }
Beispiel #6
0
        public int AgregarBLL(int venta,
                              String raz_soc,
                              String ruc,
                              float pretotal,
                              float igv,
                              float total)
        {
            CFactura nuevo = new CFactura
            {
                venta    = venta,
                raz_soc  = raz_soc,
                ruc      = ruc,
                pretotal = pretotal,
                igv      = igv,
                total    = total
            };

            return(fac.Agregar(nuevo));
        }
        public ActionResult Editar(CFactura factura)
        {
            if (can("editar", "Factura"))
            {
                int success = BLLinstance.EditarBLL(
                    factura.venta,
                    factura.codigo,
                    factura.raz_soc,
                    factura.ruc,
                    factura.pretotal,
                    factura.igv,
                    factura.total);

                return(View("Listado", GetListado()));
            }
            else
            {
                return(Index());
            }
        }
        public ActionResult FormularioE(int codigo)
        {
            if (Auth())
            {
                if (codigo == 0)
                {
                    return(View());
                }
                else
                {
                    CFactura factura = BLLinstance.GetBLL(codigo);

                    return((can("listar", "Factura")) ?
                           View(factura) : Index());
                }
            }
            else
            {
                return(View("../Usuario/LogInForm"));
            }
        }
Beispiel #9
0
        public int EditarBLL(int codigo,
                             int venta,
                             String raz_soc,
                             String ruc,
                             float pretotal,
                             float igv,
                             float total)
        {
            CFactura editado = new CFactura
            {
                codigo   = codigo,
                venta    = venta,
                raz_soc  = raz_soc,
                ruc      = ruc,
                pretotal = pretotal,
                igv      = igv,
                total    = total
            };

            return(fac.Editar(editado));
        }
Beispiel #10
0
        private void consultaDeFacturaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CFactura abrir = new CFactura();

            abrir.Show();
        }
 private void FormFactura_Load(object sender, EventArgs e)
 {
     if (tipo.CompareTo("factura") == 0)
     {
         this.reportViewer1.LocalReport.ReportEmbeddedResource = "facturacion.Vistas.Report3.rdlc";
         DataTable factura    = CFactura.MostrarID(id_venta);
         DataTable venta      = CVenta.MostrarID(id_venta);
         DataTable infomacion = CEmpresa.Mostrar();
         DataTable codigo     = CCodigo.ultimoID(int.Parse(factura.Rows[0]["idCodigo"].ToString()));
         DataTable cliente    = CCliente.MostrarID(venta.Rows[0]["idCliente"].ToString());
         DataTable customer   = CDetalleVenta.Mostrar((int)id_venta);
         this.MDetalleVentaBindingSource.DataSource = customer;
         ReportParameter[] parameters = new ReportParameter[16];
         string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
         string            pathqr     = "file:\\" + Application.StartupPath + factura.Rows[0]["QR"].ToString();
         parameters[15] = new ReportParameter("Path", @path, true);
         parameters[0]  = new ReportParameter("PathQr", @pathqr, true);
         parameters[1]  = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
         parameters[2]  = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
         parameters[3]  = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
         parameters[4]  = new ReportParameter("nit", infomacion.Rows[0]["nit"].ToString());
         parameters[5]  = new ReportParameter("nro", factura.Rows[0]["numFactura"].ToString());
         parameters[6]  = new ReportParameter("autorizacion", codigo.Rows[0]["autorizacion"].ToString());
         parameters[7]  = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
         parameters[8]  = new ReportParameter("literal", "Son: " + venta.Rows[0]["montoLiteral"].ToString());
         parameters[9]  = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
         parameters[10] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
         parameters[11] = new ReportParameter("fecha", venta.Rows[0]["fecVenta"].ToString());
         parameters[12] = new ReportParameter("total", venta.Rows[0]["montoTotal"].ToString());
         parameters[13] = new ReportParameter("codigo_control", factura.Rows[0]["codControl"].ToString());
         parameters[14] = new ReportParameter("fecha_limite", codigo.Rows[0]["fecFinal"].ToString());
         this.reportViewer1.LocalReport.SetParameters(parameters);
         this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
         this.reportViewer1.RefreshReport();
     }
     else
     {
         if (tipo.CompareTo("pedido") == 0)
         {
             this.reportViewer1.LocalReport.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
             DataTable venta      = CVenta.MostrarID(id_venta);
             DataTable infomacion = CEmpresa.Mostrar();
             DataTable cliente    = CCliente.MostrarID(venta.Rows[0]["idCliente"].ToString());
             DataTable customer   = CDetalleVenta.Mostrar((int)id_venta);
             this.MDetalleVentaBindingSource.DataSource = customer;
             ReportParameter[] parameters = new ReportParameter[2];
             string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
             parameters[0] = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
             parameters[1] = new ReportParameter("fecha", venta.Rows[0]["fecVenta"].ToString());
             this.reportViewer1.LocalReport.SetParameters(parameters);
             this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
             this.reportViewer1.RefreshReport();
         }
         else
         {
             this.reportViewer1.LocalReport.ReportEmbeddedResource = "facturacion.Vistas.Report2.rdlc";
             DataTable venta      = CVenta.MostrarID(id_venta);
             DataTable infomacion = CEmpresa.Mostrar();
             DataTable cliente    = CCliente.MostrarID(venta.Rows[0]["idCliente"].ToString());
             DataTable customer   = CDetalleVenta.Mostrar((int)id_venta);
             this.MDetalleVentaBindingSource.DataSource = customer;
             ReportParameter[] parameters = new ReportParameter[10];
             string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
             parameters[0] = new ReportParameter("Path", @path, true);
             parameters[1] = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
             parameters[2] = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
             parameters[3] = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
             parameters[4] = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
             parameters[5] = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
             parameters[6] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
             parameters[7] = new ReportParameter("fecha", venta.Rows[0]["fecVenta"].ToString());
             parameters[8] = new ReportParameter("total", venta.Rows[0]["montoTotal"].ToString());
             parameters[9] = new ReportParameter("literal", "Son: " + venta.Rows[0]["montoLiteral"].ToString());
             this.reportViewer1.LocalReport.SetParameters(parameters);
             this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
             this.reportViewer1.RefreshReport();
         }
     }
 }
Beispiel #12
0
        private void btn_facturar_Click(object sender, EventArgs e)
        {
            if (lista.Rows.Count == 0)
            {
                ToastNotification.Show(this, "Añade un producto antes de cobrar.", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight));
                return;
            }

            if (MessageBox.Show("Esta Apunto de Facturar el monto de " + lb_total_importe.Text + ".", "COBRAR PEDIDO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                aux = CCliente.BuscarCI(cb_ci_nit.Text.ToString());
                string ccodigo;
                if (aux.Rows.Count >= 1 && lista.Rows.Count > 0)
                {
                    DataRow    row_cliente = aux.Rows[0];
                    Numeracion num         = new Numeracion();
                    MVentas    venta       = new MVentas(0, int.Parse(row_cliente["id"].ToString()), int.Parse(Datos.Rows[0]["id"].ToString()), DateTime.Now, Double.Parse(lb_total_importe.Text), num.Convertir(lb_total_importe.Text, true), "factura", "cancelado", numero_next);
                    long       id_now      = CVenta.Insertar(venta, this);
                    if (id_now != -1)
                    {
                        DataTable cla = CCodigo.ultimo();

                        DataTable fa          = CFactura.ultimo();
                        int       id_fac_last = 0;
                        if (fa.Rows.Count != 0)
                        {
                            id_fac_last = int.Parse(fa.Rows[0]["id"].ToString());
                        }
                        id_fac_last++;
                        string        clave  = cla.Rows[0]["clave"].ToString();
                        Hashid.Hashid hashid = new Hashid.Hashid();
                        string[]      f      = lb_fecActual.Text.Split('/');
                        ccodigo       = (String)hashid.calcular(cla.Rows[0]["autorizacion"].ToString(), id_fac_last.ToString(), cb_ci_nit.Text.ToString(), f[2] + f[1] + f[0], lb_total_importe.Text, clave);
                        qr_image.Text = lb_nit.Text + "|" + id_fac_last.ToString() + "|" + cla.Rows[0]["autorizacion"].ToString() + "|" + lb_fecActual.Text + "|" + lb_total_importe.Text + "|" + lb_total_importe.Text + "|" + ccodigo + "|" + cb_ci_nit.Text.ToString() + "|0|0|0|0|";
                        string dir = "/img/qrs/" + ccodigo + ".jpg";
                        qr_image.Image.Save(@"" + Application.StartupPath + dir, ImageFormat.Jpeg);

                        MFactura fact = new MFactura(0, (int)id_now, int.Parse(cla.Rows[0]["id"].ToString()), ccodigo, dir, id_fac_last.ToString(), DateTime.Now);
                        if (!CFactura.Insertar(fact, this))
                        {
                            MessageBox.Show("no se pudo crear al factura");
                        }

                        foreach (DataGridViewRow r in lista.Rows)
                        {
                            string precio_total = r.Cells["total"].Value.ToString();
                            string cantidad     = r.Cells["cantidad"].Value.ToString();
                            string unitario     = r.Cells["precio"].Value.ToString();
                            string descripcion  = r.Cells["descripcion"].Value.ToString();
                            int    id           = Convert.ToInt32(r.Cells["id"].Value);

                            MDetalleVenta det = new MDetalleVenta(0, id, double.Parse(cantidad), (int)id_now, Double.Parse(precio_total), descripcion, Double.Parse(unitario));

                            CDetalleVenta.Insertar(det, this);
                        }


                        try
                        {
                            LocalReport rdlc = new LocalReport();
                            rdlc.ReportPath             = @"..\..\Vistas\Report3.rdlc";
                            rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report3.rdlc";
                            rdlc.EnableExternalImages   = true;
                            DataTable factura    = CFactura.MostrarID(id_now);
                            DataTable venta2     = CVenta.MostrarID(id_now);
                            DataTable infomacion = CEmpresa.Mostrar();
                            DataTable codigo     = CCodigo.ultimoID(int.Parse(factura.Rows[0]["idCodigo"].ToString()));
                            DataTable cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                            DataTable customer   = CDetalleVenta.Mostrar((int)id_now);
                            rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));
                            ReportParameter[] parameters = new ReportParameter[16];
                            string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
                            string            pathqr     = "file:\\" + Application.StartupPath + factura.Rows[0]["QR"].ToString();
                            parameters[15] = new ReportParameter("Path", @path, true);
                            parameters[0]  = new ReportParameter("PathQr", @pathqr, true);
                            parameters[1]  = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
                            parameters[2]  = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
                            parameters[3]  = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
                            parameters[4]  = new ReportParameter("nit", infomacion.Rows[0]["nit"].ToString());
                            parameters[5]  = new ReportParameter("nro", factura.Rows[0]["numFactura"].ToString());
                            parameters[6]  = new ReportParameter("autorizacion", codigo.Rows[0]["autorizacion"].ToString());
                            parameters[7]  = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
                            parameters[8]  = new ReportParameter("literal", "Son: " + venta2.Rows[0]["montoLiteral"].ToString());
                            parameters[9]  = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                            parameters[10] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
                            parameters[11] = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                            parameters[12] = new ReportParameter("total", venta2.Rows[0]["montoTotal"].ToString());
                            parameters[13] = new ReportParameter("codigo_control", factura.Rows[0]["codControl"].ToString());
                            parameters[14] = new ReportParameter("fecha_limite", codigo.Rows[0]["fecFinal"].ToString());
                            rdlc.SetParameters(parameters);
                            Impresor imp = new Impresor();
                            imp.Imprime(rdlc);
                            LocalReport rdlc2 = new LocalReport();
                            rdlc2.ReportPath             = @"..\..\Vistas\Report1.rdlc";
                            rdlc2.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
                            rdlc2.DataSources.Add(new ReportDataSource("DataSet1", customer));
                            ReportParameter nombre = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                            ReportParameter fecha  = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                            ReportParameter numero = new ReportParameter("numero", numero_next.ToString());
                            rdlc2.SetParameters(new ReportParameter[] { nombre, fecha, numero });
                            imp.Imprime(rdlc2);
                            limpiar();
                        }
                        catch (Exception exp)
                        {
                            ToastNotification.Show(this, exp.Message, global::facturacion.Properties.Resources.Warning_sign, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight));
                            if (MessageBox.Show("Ha ocurrido un error al imprimir, Desea Volver a imprimir el pedido/factura??", "ERROR AL FACTURAR!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                LocalReport rdlc = new LocalReport();
                                rdlc.ReportPath             = @"..\..\Vistas\Report3.rdlc";
                                rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report3.rdlc";
                                rdlc.EnableExternalImages   = true;
                                DataTable factura    = CFactura.MostrarID(id_now);
                                DataTable venta2     = CVenta.MostrarID(id_now);
                                DataTable infomacion = CEmpresa.Mostrar();
                                DataTable codigo     = CCodigo.ultimoID(int.Parse(factura.Rows[0]["idCodigo"].ToString()));
                                DataTable cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                                DataTable customer   = CDetalleVenta.Mostrar((int)id_now);
                                rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));
                                ReportParameter[] parameters = new ReportParameter[16];
                                string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
                                string            pathqr     = "file:\\" + Application.StartupPath + factura.Rows[0]["QR"].ToString();
                                parameters[15] = new ReportParameter("Path", @path, true);
                                parameters[0]  = new ReportParameter("PathQr", @pathqr, true);
                                parameters[1]  = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
                                parameters[2]  = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
                                parameters[3]  = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
                                parameters[4]  = new ReportParameter("nit", infomacion.Rows[0]["nit"].ToString());
                                parameters[5]  = new ReportParameter("nro", factura.Rows[0]["numFactura"].ToString());
                                parameters[6]  = new ReportParameter("autorizacion", codigo.Rows[0]["autorizacion"].ToString());
                                parameters[7]  = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
                                parameters[8]  = new ReportParameter("literal", "Son: " + venta2.Rows[0]["montoLiteral"].ToString());
                                parameters[9]  = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                                parameters[10] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
                                parameters[11] = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                                parameters[12] = new ReportParameter("total", venta2.Rows[0]["montoTotal"].ToString());
                                parameters[13] = new ReportParameter("codigo_control", factura.Rows[0]["codControl"].ToString());
                                parameters[14] = new ReportParameter("fecha_limite", codigo.Rows[0]["fecFinal"].ToString());
                                rdlc.SetParameters(parameters);
                                Impresor imp = new Impresor();
                                imp.Imprime(rdlc);
                                LocalReport rdlc2 = new LocalReport();
                                rdlc2.ReportPath             = @"..\..\Vistas\Report1.rdlc";
                                rdlc2.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
                                rdlc2.DataSources.Add(new ReportDataSource("DataSet1", customer));
                                ReportParameter nombre = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                                ReportParameter fecha  = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                                ReportParameter numero = new ReportParameter("numero", numero_next.ToString());
                                rdlc2.SetParameters(new ReportParameter[] { nombre, fecha, numero });
                                imp.Imprime(rdlc2);
                                limpiar();
                            }
                            limpiar();
                        }
                        numero_next++;
                        //retornar el reporte
                    }
                }
                else
                {
                    MessageBox.Show("El CI/Nit no esta registrado.\n Registre el Nombre y guardelo.");
                    btn_guardar.BackColor = System.Drawing.Color.Blue;
                    btn_guardar.Enabled   = true;
                    tb_nombreAp.Text      = "";
                    tb_nombreAp.Enabled   = true;
                    tb_nombreAp.Focus();
                }
            }
        }
Beispiel #13
0
        private void btn_facturar_Click(object sender, EventArgs e)
        {
            if (id_now != 0)
            {
                try
                {
                    if (this.lista_ventas.CurrentRow.Cells["tipo"].Value.ToString() == "factura")
                    {
                        LocalReport rdlc = new LocalReport();
                        rdlc.ReportPath             = @"..\..\Vistas\Report3.rdlc";
                        rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report3.rdlc";
                        rdlc.EnableExternalImages   = true;

                        DataTable factura    = CFactura.MostrarID(id_now);
                        DataTable venta2     = CVenta.MostrarID(id_now);
                        DataTable infomacion = CEmpresa.Mostrar();
                        DataTable codigo     = CCodigo.ultimoID(int.Parse(factura.Rows[0]["idCodigo"].ToString()));
                        DataTable cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                        DataTable customer   = CDetalleVenta.Mostrar((int)id_now);
                        rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));


                        ReportParameter[] parameters = new ReportParameter[16];
                        string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
                        string            pathqr     = "file:\\" + Application.StartupPath + factura.Rows[0]["QR"].ToString();
                        parameters[15] = new ReportParameter("Path", @path, true);
                        parameters[0]  = new ReportParameter("PathQr", @pathqr, true);
                        parameters[1]  = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
                        parameters[2]  = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
                        parameters[3]  = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
                        parameters[4]  = new ReportParameter("nit", infomacion.Rows[0]["nit"].ToString());
                        parameters[5]  = new ReportParameter("nro", factura.Rows[0]["numFactura"].ToString());
                        parameters[6]  = new ReportParameter("autorizacion", codigo.Rows[0]["autorizacion"].ToString());
                        parameters[7]  = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
                        parameters[8]  = new ReportParameter("literal", "Son: " + venta2.Rows[0]["montoLiteral"].ToString());
                        parameters[9]  = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                        parameters[10] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
                        parameters[11] = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                        parameters[12] = new ReportParameter("total", venta2.Rows[0]["montoTotal"].ToString());
                        parameters[13] = new ReportParameter("codigo_control", factura.Rows[0]["codControl"].ToString());
                        parameters[14] = new ReportParameter("fecha_limite", codigo.Rows[0]["fecFinal"].ToString());
                        rdlc.SetParameters(parameters);
                        Impresor imp = new Impresor();
                        imp.Imprime(rdlc);
                    }
                    else
                    {
                        if (MessageBox.Show("Esta Apunto de Facturar el monto de " + lb_importeTotal.Text + ".", "FACTURAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            DataTable aux = CCliente.Buscar("ci", lb_ciNit.Text.ToString());
                            string    ccodigo;
                            if (aux.Rows.Count == 1)
                            {
                                DataRow    row_cliente = aux.Rows[0];
                                Numeracion num         = new Numeracion();
                                MVentas    venta       = new MVentas(0, int.Parse(row_cliente["id"].ToString()), 1, DateTime.Now, Double.Parse(lb_importeTotal.Text), num.Convertir(lb_importeTotal.Text, true), "factura", "cancelado", 0);
                                CVenta.Editar(int.Parse(id_now.ToString()), venta, this);
                                DataTable cla = CCodigo.ultimo();

                                DataTable fa          = CFactura.ultimo();
                                int       id_fac_last = 0;
                                if (fa.Rows.Count != 0)
                                {
                                    id_fac_last = int.Parse(fa.Rows[0]["id"].ToString());
                                }
                                id_fac_last++;
                                string        clave  = cla.Rows[0]["clave"].ToString();
                                Hashid.Hashid hashid = new Hashid.Hashid();
                                string[]      ff     = lb_fecVenta.Text.Split(' ');
                                string[]      f      = ff[0].Split('/');
                                ccodigo  = (String)hashid.calcular(cla.Rows[0]["autorizacion"].ToString(), id_fac_last.ToString(), lb_ciNit.Text.ToString(), f[2] + f[1] + f[0], lb_importeTotal.Text, clave);
                                qr_image = new Gma.QrCodeNet.Encoding.Windows.Forms.QrCodeImgControl();
                                qr_image.QuietZoneModule = Gma.QrCodeNet.Encoding.Windows.Render.QuietZoneModules.Two;
                                qr_image.Size            = new System.Drawing.Size(108, 95);
                                qr_image.Text            = lb_nit.Text + "|" + id_fac_last.ToString() + "|" + cla.Rows[0]["autorizacion"].ToString() + "|" + ff[0] + "|" + lb_importeTotal.Text + "|" + lb_importeTotal.Text + "|" + ccodigo + "|" + lb_ciNit.Text.ToString() + "|0|0|0|0|";
                                string dir = "/img/qrs/" + ccodigo + ".jpg";
                                qr_image.Image.Save(@"" + Application.StartupPath + dir, ImageFormat.Jpeg);

                                MFactura fact = new MFactura(0, (int)id_now, int.Parse(cla.Rows[0]["id"].ToString()), ccodigo, dir, id_fac_last.ToString(), DateTime.Now);
                                CFactura.Insertar(fact, this);
                                Mostrar(tb_cliente.Text.ToString());

                                LocalReport rdlc = new LocalReport();
                                rdlc.ReportPath             = @"..\..\Vistas\Report3.rdlc";
                                rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report3.rdlc";
                                rdlc.EnableExternalImages   = true;

                                DataTable factura    = CFactura.MostrarID(id_now);
                                DataTable venta2     = CVenta.MostrarID(id_now);
                                DataTable infomacion = CEmpresa.Mostrar();
                                DataTable codigo     = CCodigo.ultimoID(int.Parse(factura.Rows[0]["idCodigo"].ToString()));
                                DataTable cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                                DataTable customer   = CDetalleVenta.Mostrar((int)id_now);
                                rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));


                                ReportParameter[] parameters = new ReportParameter[16];
                                string            path       = "file:\\" + Application.StartupPath + infomacion.Rows[0]["logo"];
                                string            pathqr     = "file:\\" + Application.StartupPath + factura.Rows[0]["QR"].ToString();
                                parameters[15] = new ReportParameter("Path", @path, true);
                                parameters[0]  = new ReportParameter("PathQr", @pathqr, true);
                                parameters[1]  = new ReportParameter("empresa", infomacion.Rows[0]["nombre"].ToString());
                                parameters[2]  = new ReportParameter("propietario", infomacion.Rows[0]["nomPropietario"].ToString());
                                parameters[3]  = new ReportParameter("direccion", infomacion.Rows[0]["direccion"].ToString());
                                parameters[4]  = new ReportParameter("nit", infomacion.Rows[0]["nit"].ToString());
                                parameters[5]  = new ReportParameter("nro", factura.Rows[0]["numFactura"].ToString());
                                parameters[6]  = new ReportParameter("autorizacion", codigo.Rows[0]["autorizacion"].ToString());
                                parameters[7]  = new ReportParameter("telefono", infomacion.Rows[0]["telefono"].ToString());
                                parameters[8]  = new ReportParameter("literal", "Son: " + venta2.Rows[0]["montoLiteral"].ToString());
                                parameters[9]  = new ReportParameter("nombre_cliente", cliente.Rows[0]["nombre"].ToString());
                                parameters[10] = new ReportParameter("ci", cliente.Rows[0]["ci"].ToString());
                                parameters[11] = new ReportParameter("fecha", venta2.Rows[0]["fecVenta"].ToString());
                                parameters[12] = new ReportParameter("total", venta2.Rows[0]["montoTotal"].ToString());
                                parameters[13] = new ReportParameter("codigo_control", factura.Rows[0]["codControl"].ToString());
                                parameters[14] = new ReportParameter("fecha_limite", codigo.Rows[0]["fecFinal"].ToString());
                                rdlc.SetParameters(parameters);
                                Impresor imp = new Impresor();
                                imp.Imprime(rdlc);
                            }
                            else
                            {
                                MessageBox.Show("El CI/Nit no esta registrado.\n Registre el Nombre y guardelo.");
                            }
                        }
                    }
                }catch (Exception err) {
                    Mostrar(string.Empty);
                    MessageBox.Show("Upp!, algo ha salido mal, por favor vuelva a seleccionar la venta e intentelo de nuevo");
                }
            }
            else
            {
                MessageBox.Show("Seleccione una venta");
            }
        }