Beispiel #1
0
        private void Mostrar()
        {
            DataTable info = CEmpresa.Mostrar();

            if (info.Rows.Count > 0)
            {
                tb_nombre.Text      = info.Rows[0]["nombre"].ToString();
                tb_nit.Text         = info.Rows[0]["nit"].ToString();
                tb_propietario.Text = info.Rows[0]["nomPropietario"].ToString();
                tb_sigla.Text       = info.Rows[0]["sigla"].ToString();
                tb_direccion.Text   = info.Rows[0]["direccion"].ToString();
                tb_telefono.Text    = info.Rows[0]["telefono"].ToString();
                id = int.Parse(info.Rows[0]["id"].ToString());
                Image c = Image.FromFile(@"" + Application.StartupPath + info.Rows[0]["logo"].ToString());
                pb_empresa.Image    = newImagen(c, 250, 250);
                btn_editar.Enabled  = true;
                btn_guardar.Enabled = false;
                habilitar(false);
            }
            else
            {
                btn_guardar.Enabled = true;
                btn_editar.Enabled  = false;
                habilitar(true);
            }
        }
Beispiel #2
0
        private void NewVentaExecuted(object sender, EventArgs e)
        {
            DataTable empresa = CEmpresa.Mostrar();

            if (empresa.Rows.Count == 0)
            {
                MessageBox.Show("No existe Empresa Registrada, Primero registre una empresa");
                return;
            }
            DataTable cla = CCodigo.ultimo();

            if (cla.Rows.Count == 0)
            {
                MessageBox.Show("Ingrese una llave de dosificacion");
                return;
            }
            Debug.Assert(venta == null);
            _Commands.VentaCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            venta          = new VVentas(Datos);
            venta.Commands = _Commands;
            this.ShowModalPanel(venta, DevComponents.DotNetBar.Controls.eSlideSide.Top);
            if (!_StartControl.Visible)
            {
                _StartControl.SlideOutButtonVisible = false;
            }
        }
Beispiel #3
0
 private void btn_pedido_Click(object sender, EventArgs e)
 {
     if (id_now != 0)
     {
         try
         {
             LocalReport rdlc = new LocalReport();
             rdlc.ReportPath             = @"..\..\Vistas\Report1.rdlc";
             rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
             DataTable customer = CDetalleVenta.Mostrar((int)id_now);
             rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));
             DataTable       venta2     = CVenta.MostrarID(id_now);
             DataTable       infomacion = CEmpresa.Mostrar();
             DataTable       cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
             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", venta2.Rows[0]["numero"].ToString());
             rdlc.SetParameters(new ReportParameter[] { nombre, fecha, numero });
             Impresor imp = new Impresor();
             imp.Imprime(rdlc);
         }catch (Exception err) {
             Mostrar(string.Empty);
             MessageBox.Show("Upp!, algo ha salido mal, por favor vuelva a seleccionar la venta e intentelo de nuevo");
         }
     }
 }
Beispiel #4
0
        private void empresa_cargar()
        {
            DataTable info = CEmpresa.Mostrar();

            if (info.Rows.Count > 0)
            {
                lb_nombreEmpresa.Text = info.Rows[0]["nombre"].ToString();
                //lb_autorizacion.Text = info.Rows[0]["numAutorizacion"].ToString();
                lb_nit.Text = info.Rows[0]["nit"].ToString();
                Image c = Image.FromFile(@"" + Application.StartupPath + info.Rows[0]["logo"].ToString());
                pictureBox1.Image = newImagen(c, 350, 350);
            }
        }
Beispiel #5
0
        public VVentas(DataTable Datos)
        {
            InitializeComponent();
            DataTable info = CEmpresa.Mostrar();

            if (info.Rows.Count > 0)
            {
                lb_nombreEmpresa.Text = info.Rows[0]["nombre"].ToString();
                //lb_autorizacion.Text = info.Rows[0]["numAutorizacion"].ToString();
                lb_nit.Text = info.Rows[0]["nit"].ToString();
                Image c = Image.FromFile(@"" + Application.StartupPath + info.Rows[0]["logo"].ToString());
                pb_imagen_empresa.Image = newImagen(c, 350, 350);
            }
            DataTable nro = CVenta.Mostrar();

            if (nro.Rows.Count > 0)
            {
                lb_numero.Text = nro.Rows[0]["id"].ToString();
            }
            else
            {
                lb_numero.Text = "0";
            }
            DataTable product = CProducto.Mostrar();

            mClientesBindingSource.DataSource = CCliente.mostrar();
            mProductoBindingSource.DataSource = product;
            if (product.Rows.Count > 0)
            {
                tb_extra.Text = product.Rows[0]["nombre"].ToString();
            }
            else
            {
                btn_añadir.Enabled = false;
            }
            tb_nombreAp.Enabled = false;
            btn_guardar.Enabled = false;
            lista.MouseClick   += new MouseEventHandler(lista_productos_mouseclick);
            DataTable ult = CVenta.ultimofecha();

            if (ult.Rows.Count == 0)
            {
                numero_next = 1;
            }
            else
            {
                numero_next = Int32.Parse(ult.Rows[0]["numero"].ToString());
                numero_next++;
            }
            this.Datos = Datos;
        }
Beispiel #6
0
 private void btn_nota_Click(object sender, EventArgs e)
 {
     if (id_now != 0)
     {
         try{
             LocalReport rdlc = new LocalReport();
             rdlc.ReportPath             = @"..\..\Vistas\Report2.rdlc";
             rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report2.rdlc";
             rdlc.EnableExternalImages   = true;
             DataTable venta      = CVenta.MostrarID(id_now);
             DataTable infomacion = CEmpresa.Mostrar();
             DataTable cliente    = CCliente.MostrarID(venta.Rows[0]["idCliente"].ToString());
             DataTable customer   = CDetalleVenta.Mostrar((int)id_now);
             rdlc.DataSources.Add(new ReportDataSource("DataSet1", 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());
             rdlc.SetParameters(parameters);
             Impresor imp = new Impresor();
             imp.Imprime(rdlc);
         }
         catch (Exception err)
         {
             Mostrar(string.Empty);
             MessageBox.Show("Upp!, algo ha salido mal, por favor vuelva a seleccionar la venta e intentelo de nuevo");
         }
     }
 }
Beispiel #7
0
        MetroBillCommands _Commands = null; // All application commands
        public MainForm()
        {
            InitializeComponent();

            DataTable info = CEmpresa.Mostrar();

            if (info.Rows.Count > 0)
            {
                Image c = Image.FromFile(@"" + Application.StartupPath + info.Rows[0]["logo"].ToString());
                pictureBox1.Image = c;
            }



            // Prepare commands
            _Commands = new MetroBillCommands();

            _Commands.ToggleStartControl           = new Command(components);
            _Commands.ToggleStartControl.Executed += new EventHandler(ToggleStartControlExecuted);


            // Initialize Client related commands
            _Commands.EmpresaCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.EmpresaCommands.New.Executed    += NewEmpresaExecuted;
            _Commands.EmpresaCommands.Cancel           = new Command(components);
            _Commands.EmpresaCommands.Cancel.Executed += CancelEmpresaExecuted;

            // Initialize Client related commands
            _Commands.VentaCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.VentaCommands.New.Executed    += NewVentaExecuted;
            _Commands.VentaCommands.Cancel           = new Command(components);
            _Commands.VentaCommands.Cancel.Executed += CancelVentaExecuted;

            // Initialize Client related commands
            _Commands.ProductoCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ProductoCommands.New.Executed    += NewProductoExecuted;
            _Commands.ProductoCommands.Cancel           = new Command(components);
            _Commands.ProductoCommands.Cancel.Executed += CancelProductoExecuted;


            // Initialize Codigo related commands
            _Commands.CodigoCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.CodigoCommands.New.Executed    += NewCodigoExecuted;
            _Commands.CodigoCommands.Cancel           = new Command(components);
            _Commands.CodigoCommands.Cancel.Executed += CancelCodigoExecuted;


            // Initialize Codigo related commands
            _Commands.ClienteCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ClienteCommands.New.Executed    += NewClienteExecuted;
            _Commands.ClienteCommands.Cancel           = new Command(components);
            _Commands.ClienteCommands.Cancel.Executed += CancelClienteExecuted;

            // Initialize Codigo related commands
            _Commands.UsuarioCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.UsuarioCommands.New.Executed    += NewUsuarioExecuted;
            _Commands.UsuarioCommands.Cancel           = new Command(components);
            _Commands.UsuarioCommands.Cancel.Executed += CancelUsuarioExecuted;

            // Initialize Codigo related commands
            _Commands.ListaVentaCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ListaVentaCommands.New.Executed    += NewListaVentaExecuted;
            _Commands.ListaVentaCommands.Cancel           = new Command(components);
            _Commands.ListaVentaCommands.Cancel.Executed += CancelListaVentaExecuted;

            // Initialize Codigo related commands
            _Commands.ReporteCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ReporteCommands.New.Executed    += NewReporteExecuted;
            _Commands.ReporteCommands.Cancel           = new Command(components);
            _Commands.ReporteCommands.Cancel.Executed += CancelReporteExecuted;


            // Initialize Codigo related commands
            _Commands.FacturaCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.FacturaCommands.New.Executed    += NewfacturaExecuted;
            _Commands.FacturaCommands.Cancel           = new Command(components);
            _Commands.FacturaCommands.Cancel.Executed += CancelFacturaExecuted;


            // General commands
            _Commands.ChangeMetroTheme      = new Command(components, new EventHandler(ChangeMetroThemeExecuted));
            _Commands.NotImplemented        = new Command(components, new EventHandler(NotImplementedExecuted));
            _Commands.DevComponents         = new Command(components, new EventHandler(DevComponentsExecuted));
            _Commands.GettingStartedCommand = new Command(components, new EventHandler(GettingStartedExecuted));

            this.SuspendLayout();
            _StartControl          = new StartControl();
            _StartControl.Commands = _Commands;
            this.Controls.Add(_StartControl);
            _StartControl.BringToFront();
            _StartControl.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;
            _StartControl.Click    += new EventHandler(StartControl_Click);
            this.ResumeLayout(false);

            // Assign commands to toolbar buttons

            // Add metro color themes
            MetroColorGeneratorParameters[] metroThemes = MetroColorGeneratorParameters.GetAllPredefinedThemes();
            foreach (MetroColorGeneratorParameters mt in metroThemes)
            {
                ButtonItem theme = new ButtonItem(mt.ThemeName, mt.ThemeName);
                theme.Command          = _Commands.ChangeMetroTheme;
                theme.CommandParameter = mt;
                colorThemeButton.SubItems.Add(theme);
            }
        }
 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 #9
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 #10
0
        private void btn_cobrar_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 Cobrar el monto de " + lb_total_importe.Text + ".", "COBRAR PEDIDO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                aux = CCliente.BuscarCI(cb_ci_nit.Text.ToString());
                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), "pedido", "cancelado", numero_next);
                    long       id_now      = CVenta.Insertar(venta, this);
                    if (id_now != (-1))
                    {
                        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));
                            if (CDetalleVenta.Insertar(det, this))
                            {
                            }
                        }

                        try
                        {
                            LocalReport rdlc = new LocalReport();
                            rdlc.ReportPath             = @"..\..\Vistas\Report1.rdlc";
                            rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
                            DataTable customer = CDetalleVenta.Mostrar((int)id_now);
                            rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));
                            DataTable       venta2     = CVenta.MostrarID(id_now);
                            DataTable       infomacion = CEmpresa.Mostrar();
                            DataTable       cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                            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());
                            rdlc.SetParameters(new ReportParameter[] { nombre, fecha, numero });
                            Impresor imp = new Impresor();
                            imp.Imprime(rdlc);
                            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??", "ERROR AL FACTURAR!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                LocalReport rdlc = new LocalReport();
                                rdlc.ReportPath             = @"..\..\Vistas\Report1.rdlc";
                                rdlc.ReportEmbeddedResource = "facturacion.Vistas.Report1.rdlc";
                                DataTable customer = CDetalleVenta.Mostrar((int)id_now);
                                rdlc.DataSources.Add(new ReportDataSource("DataSet1", customer));
                                DataTable       venta2     = CVenta.MostrarID(id_now);
                                DataTable       infomacion = CEmpresa.Mostrar();
                                DataTable       cliente    = CCliente.MostrarID(venta2.Rows[0]["idCliente"].ToString());
                                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());
                                rdlc.SetParameters(new ReportParameter[] { nombre, fecha, numero });
                                Impresor imp = new Impresor();
                                imp.Imprime(rdlc);
                                limpiar();
                            }
                        }
                        numero_next++;
                    }
                }
                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 #11
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");
            }
        }