Пример #1
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            FrmImpresiones FormImpresiones = new FrmImpresiones(this);

            FormImpresiones.IdCliente = Convert.ToInt32(this.txtIdCliente.Text);
            FormImpresiones.ShowDialog();
        }
Пример #2
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            FrmImpresiones FormImpresiones = new FrmImpresiones(this);

            FormImpresiones.Inicio    = this.DtInicio.Value;
            FormImpresiones.Fin       = this.DtFin.Value;
            FormImpresiones.IdUsuario = FormInicio.IdUsuario;
            FormImpresiones.ShowDialog();
        }
Пример #3
0
        //btnEmitir - Evento Click - Emite el comprobante de factura y registra la venta en la base de datos.
        private void btnEmitir_Click(object sender, EventArgs e)
        {
            string Respuesta = "";

            //Revisión de datos obligatorios
            if (String.IsNullOrWhiteSpace(txtIdCliente.Text))
            {
                new Configuracion().Mensaje("Debe ingresar un cliente para la factura.", "Dato Inválido",
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.errorProvider.SetError(txtIdCliente, "Ingrese un cliente.");
            }
            else if (dgvProductos.RowCount == 0)
            {
                new Configuracion().Mensaje("Debe ingresar algún producto para facturar.", "Dato Inválido",
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //Envía los datos para que sean ingresados en la base de datos.
                Respuesta = NFacturas.Facturar(Convert.ToInt32(txtIdCliente.Text), new Numalet().Convertir(lblTotal.Text, true),
                                               Convert.ToDecimal(lblTotal.Text), Convert.ToDecimal(this.lblSubTotal.Text), Convert.ToDecimal(this.lblExento.Text),
                                               this.lblNombreImpuesto1.Text.Replace(this.lblNombreImpuesto1.Text.Substring(this.lblNombreImpuesto1
                                                                                                                           .Text.Length - 6), ""), Convert.ToDecimal(this.lblBaseImpuesto1.Text), Convert.ToDecimal(this.lblImpuesto1.Text),
                                               this.lblNombreImpuesto2.Text.Replace(this.lblNombreImpuesto2.Text.Substring(this.lblNombreImpuesto2
                                                                                                                           .Text.Length - 6), ""), Convert.ToDecimal(this.lblBaseImpuesto2.Text), Convert.ToDecimal(this.lblImpuesto2.Text),
                                               Convert.ToInt32(this.cbxCondicionPago.SelectedValue), cbxDireccionEntrega.Text, IdUsuario);

                //Obtiene el número de la factura nuevamente por seguridad
                int NumFactura = Convert.ToInt32(NFacturas.ObtenerNumFactura());
                if (Respuesta == "OK")
                {
                    //Ingresa cada uno de los productos cargados en el dgv
                    for (int Fila = 0; Fila < dgvProductos.Rows.Count; Fila++)
                    {
                        string Codigo   = Convert.ToString(dgvProductos.Rows[Fila].Cells["ColumnCodigo"].Value);
                        string Cantidad = Convert.ToString(dgvProductos.Rows[Fila].Cells["ColumnCantidad"].Value);
                        string Precio   = Convert.ToString(dgvProductos.Rows[Fila].Cells["ColumnPrecio"].Value);
                        string Importe  = Convert.ToString(dgvProductos.Rows[Fila].Cells["ColumnImporte"].Value);
                        string Impuesto = Convert.ToString(dgvProductos.Rows[Fila].Cells["ColumnImpuesto"].Value);
                        Respuesta = NFacturas.FacturarProductos(NumFactura, Convert.ToInt32(Codigo), Convert.ToDecimal(Cantidad),
                                                                Convert.ToDecimal(Precio), Convert.ToDecimal(Importe), Impuesto.Replace(Impuesto.Substring(Impuesto.Length - 5), ""));
                    }
                    if (Respuesta == "OK")
                    {
                        FrmImpresiones FormImpresiones = new FrmImpresiones(this);
                        FormImpresiones.NumFactura = NumFactura - 1;
                        FormImpresiones.ShowDialog();

                        //Envía formulario de operación exitosa y descarga el form.
                        new Configuracion().Mensaje(String.Format("La factura {0} ha sido generada exitosamente.",
                                                                  Convert.ToString(NumFactura)), "Factura Generada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Dispose();
                    }
                    else
                    {
                        //Si ocurre un error muestra mensaje al usuario con la respuesta recibida.
                        new Configuracion().Mensaje(Respuesta, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    //Si ocurre un error muestra mensaje al usuario con la respuesta recibida.
                    new Configuracion().Mensaje(Respuesta, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Refresca las facturas en el control
            ctrlFacturas.Refrescar();
        }