Esempio n. 1
0
        public static int Registrar_Comprobante(BE_Comprobante pBE_comprobante)
        {
            int intValor = 0;

            try
            {
                intValor = DA_Comprobante.Registrar_Comprobante(pBE_comprobante);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(intValor);
        }
Esempio n. 2
0
        private void btnImprimirVenta_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtIDCliente.Text))
                {
                    MessageBox.Show("Error: Debe seleccionar un cliente.");
                    return;
                }

                decimal ventaSoles = decimal.Parse((string.IsNullOrEmpty(this.txtVentaSoles.Text) ? "0.00" : this.txtVentaSoles.Text));
                decimal pagoSoles  = decimal.Parse((string.IsNullOrEmpty(this.txtPagoSoles.Text) ? "0.00" : this.txtPagoSoles.Text));

                if (ventaSoles > pagoSoles)
                {
                    MessageBox.Show("Monto pago es insuficiente.");
                }
                else
                {
                    var documento = new DocumentoElectronico
                    {
                        Emisor   = CrearEmisor(),
                        Receptor = new Contribuyente
                        {
                            NroDocumento  = "20100039207",
                            TipoDocumento = "6",
                            NombreLegal   = "RANSA COMERCIAL S.A.",
                            Email         = "*****@*****.**"
                        },
                        IdDocumento       = "",
                        FechaEmision      = dtpFechaHora.Value.ToShortDateString(),
                        Moneda            = "PEN",
                        MontoEnLetras     = enletras(txtVentaSoles.Text), //"SON CIENTO DIECIOCHO SOLES CON 0/100",
                        CalculoIgv        = 0.18m,
                        CalculoIsc        = 0.10m,
                        CalculoDetraccion = 0.04m,
                        TipoDocumento     = cboFacturaBoleta.SelectedValue.ToString(),
                        TotalIgv          = 18,
                        TotalVenta        = 118,
                        Gravadas          = 100
                    };

                    foreach (DataGridViewRow row in grvDetalleVenta.Rows)
                    {
                        documento.Items.Add(new DetalleDocumento
                        {
                            IdDocumento       = documento.IdDocumento, //+ i.ToString().PadLeft(8, char.Parse("0")),
                            Id                = row.Index + 1,
                            Cantidad          = decimal.Parse(row.Cells["Cantidad"].Value.ToString()),
                            PrecioReferencial = decimal.Parse(row.Cells["PUnit"].Value.ToString()),
                            PrecioUnitario    = decimal.Parse(row.Cells["PUnit"].Value.ToString()),
                            TipoPrecio        = "01",
                            CodigoItem        = row.Cells["CodProd"].Value.ToString(),
                            Descripcion       = row.Cells["Descripcion"].Value.ToString(),
                            UnidadMedida      = row.Cells["UnidMed"].Value.ToString(),
                            Impuesto          = 18,
                            TipoImpuesto      = (row.Cells["FlgAfectoIGV"].Value.ToString() == "1") ? "10" : "30",// Gravada
                            TotalVenta        = decimal.Parse(row.Cells["TotaItem"].Value.ToString()),
                            Suma              = decimal.Parse(row.Cells["TotaItem"].Value.ToString()),
                        });
                    }

                    FirmadoResponse response = FirmadoCPE.Generar(documento);

                    var resumentFirma = response.ResumenFirma;
                    var firma         = response.ValorFirma;
                    var mensajeError  = response.MensajeError;

                    BE_Comprobante pBE_ComprobanteTMP = new BE_Comprobante()
                    {
                        ID = 0,
                        Str_Tipo_Comprobante             = documento.TipoDocumento,
                        Str_Serie_Comprobante            = "",
                        Str_Numero_Comprobante           = "",
                        Str_Num_Documento_Cliente        = documento.Receptor.NroDocumento,
                        Str_Fecha_Hora_Comprobante       = documento.FechaEmision,
                        Str_Placa_Comprobante            = txtPlaca.Text,
                        Str_Linea_Cred_Soles_Comprobante = txtLineaCredSoles.Text,
                        Str_Cod_Operador = this.txtCodOperador.Text,
                        Str_Cod_Turno    = this.txtCodTurno.Text,
                        Str_Tarjeta_Soles_Comprobante = this.txtTarjetaSoles.Text,
                        Str_Linea_Cred_Comprobante    = this.txtUsarLineaCred.Text,
                        //Dec_Total_Gravado_Comprobante = decimal.Parse(txtSTGravado.Text),
                        Dec_Total_Gravado_Comprobante  = decimal.Parse((string.IsNullOrEmpty(this.txtSTGravado.Text) ? "0.00" : this.txtSTGravado.Text)),
                        Dec_Total_Gratuito_Comprobante = 0,
                        //Dec_Total_Inafecto_Comprobante = decimal.Parse(txtSTInafecto.Text),
                        Dec_Total_Inafecto_Comprobante  = decimal.Parse((string.IsNullOrEmpty(this.txtSTInafecto.Text) ? "0.00" : this.txtSTInafecto.Text)),
                        Dec_Total_Exonerado_Comprobante = 0,
                        Dec_Dscnto_Global_Comprobante   = 0,
                        //Dec_Total_Venta_Soles_Comprobante = decimal.Parse(txtVentaSoles.Text),
                        Dec_Total_Venta_Soles_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtVentaSoles.Text) ? "0.00" : this.txtVentaSoles.Text)),
                        Dec_Total_Igv_Soles_Comprobante   = 0,
                        Dec_Total_Isc_Soles_Comprobante   = 0,
                        //Dec_Efectivo_Soles_Comprobante = decimal.Parse(txtEfectivoSoles.Text),
                        Dec_Efectivo_Soles_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtEfectivoSoles.Text) ? "0.00" : this.txtEfectivoSoles.Text)),
                        //Dec_Tipo_Cambio_Comprobante = decimal.Parse(txtTipoCambio.Text),
                        Dec_Tipo_Cambio_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtTipoCambio.Text) ? "0.00" : this.txtTipoCambio.Text)),
                        //Dec_Efectivo_Dolares_Comprobante = decimal.Parse(txtEfectivoDolares.Text),
                        Dec_Efectivo_Dolares_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtEfectivoDolares.Text) ? "0.00" : this.txtEfectivoDolares.Text)),
                        //Dec_Pago_Comprobante = decimal.Parse(txtPagoSoles.Text),
                        Dec_Pago_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtPagoSoles.Text) ? "0.00" : this.txtPagoSoles.Text)),
                        //Dec_Vuelto_Comprobante = decimal.Parse(txtVueltoSoles.Text),
                        Dec_Vuelto_Comprobante       = decimal.Parse((string.IsNullOrEmpty(this.txtVueltoSoles.Text) ? "0.00" : this.txtVueltoSoles.Text)),
                        Str_Monto_Letras_Comprobante = documento.MontoEnLetras,
                        Str_Hash_Comprobante         = resumentFirma,
                        Str_MsjRpta_Comprobante      = mensajeError,
                        IDUsuarioCreacion            = VariablesGlobales.operador_actual.ID
                    };

                    pBE_ComprobanteTMP.Listado_Detalle = new List <BE_Comprobante_Detalle>();

                    foreach (DataGridViewRow row in grvDetalleVenta.Rows)
                    {
                        pBE_ComprobanteTMP.Listado_Detalle.Add(new BE_Comprobante_Detalle()
                        {
                            Str_Cod_Isla     = row.Cells["Isla"].Value.ToString(),
                            Str_Cod_Surtidor = row.Cells["Surtidor"].Value.ToString(),
                            Str_Cod_Lados    = row.Cells["Cara"].Value.ToString(),
                            Str_Cod_Manguera = row.Cells["Manguera"].Value.ToString(),
                            Str_Cod_Producto = row.Cells["Cara"].Value.ToString(),
                            Dec_Precio_Unitario_DComprobante    = decimal.Parse(row.Cells["PUnit"].Value.ToString()),
                            Dec_Cantidad_DComprobante           = decimal.Parse(row.Cells["Cantidad"].Value.ToString()),
                            Dec_SubTotal_Gravado_DComprobante   = decimal.Parse(row.Cells["STGravado"].Value.ToString()),
                            Dec_SubTotal_Inafecto_DComprobante  = decimal.Parse(row.Cells["STInafecto"].Value.ToString()),
                            Dec_SubTotal_Gratuito_DComprobante  = 0,
                            Dec_SubTotal_Exonerado_DComprobante = 0,
                            Dec_SubTotal_Item_DComprobante      = decimal.Parse(row.Cells["TotaItem"].Value.ToString()),
                            Int_Flg_Agecto_IGV        = int.Parse(row.Cells["FlgAfectoIGV"].Value.ToString()),
                            Dec_IGV_Item_DComprobante = decimal.Parse(row.Cells["IGVUnit"].Value.ToString()),
                            Int_Flg_Agecto_ISC        = int.Parse(row.Cells["FlgAfectoISC"].Value.ToString()),
                            Dec_ISC_Item_DComprobante = decimal.Parse(row.Cells["ISCUnit"].Value.ToString()),
                            IDUsuarioCreacion         = VariablesGlobales.operador_actual.ID
                        });
                    }

                    int id = BL_Comprobante.Registrar_Comprobante(pBE_ComprobanteTMP);

                    if (id > 0)
                    {
                        if (string.IsNullOrEmpty(GestionCombustibles.Properties.Settings.Default.PrinterPath))
                        {
                            MessageBox.Show("No hay una impresora configurada.");
                        }
                        else
                        {
                            string xNumComprobante = txtSerieNumero.Text;
                            string xFecha          = dtpFechaHora.Value.Day.ToString().PadLeft(2, char.Parse("0")) + "-" + dtpFechaHora.Value.Month.ToString().PadLeft(2, char.Parse("0")) + "-" + dtpFechaHora.Value.Year.ToString().PadLeft(2, char.Parse("0")) + " " + dtpFechaHora.Value.Hour.ToString().PadLeft(2, char.Parse("0")) + ":" + dtpFechaHora.Value.Minute.ToString().PadLeft(2, char.Parse("0")) + ":" + dtpFechaHora.Value.Second.ToString().PadLeft(2, char.Parse("0"));
                            string xSurtidor       = cboSurtidor.SelectedValue.ToString();
                            string xLado           = cboCara.SelectedValue.ToString();
                            string xCodHash        = txtCodHash.Text;
                            string xPlaca          = txtPlaca.Text;

                            //
                            decimal xTotal           = Convert.ToDecimal("00");
                            decimal xTotal_gravado   = Convert.ToDecimal("00");
                            decimal xTotal_inafecto  = Convert.ToDecimal("00");
                            decimal xTotal_igv       = Convert.ToDecimal("00");
                            decimal xTotal_exonerado = Convert.ToDecimal("00");
                            decimal xTotal_isc       = Convert.ToDecimal("00");
                            //
                            List <string> xHeader = new List <string>();
                            xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_nom_empresa) ? "" : VariablesGlobales.empresa.Str_nom_empresa) + "\n");
                            xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_direccion_empresa) ? "" : VariablesGlobales.empresa.Str_direccion_empresa));
                            xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Distrito) ? "" : VariablesGlobales.empresa.Str_Nom_Distrito) + ", " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Provincia) ? "" : VariablesGlobales.empresa.Str_Nom_Provincia) + ", " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Departamento) ? "" : VariablesGlobales.empresa.Str_Nom_Departamento) + "\n");
                            xHeader.Add("RUC " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_num_documento) ? "" : VariablesGlobales.empresa.Str_num_documento) + "\n");
                            xHeader.Add("----------------------------------------\n");
                            xHeader.Add("BOLETA DE VENTA ELECTRONICA\n");
                            xHeader.Add(" " + xNumComprobante + "\n");
                            xHeader.Add(" " + xFecha + "\n");
                            xHeader.Add("----------------------------------------\n");
                            xHeader.Add("POS  :" + xSurtidor + "                       LADO: " + xLado + "\n");
                            xHeader.Add("----------------------------------------\n");

                            List <string> xFooter = new List <string>();
                            xFooter.Add("----------------------------------------\n");
                            xFooter.Add("Placa del Vehiculo: " + xPlaca + "\n");
                            xFooter.Add("Cod Has: " + xCodHash + "\n");
                            xFooter.Add("Autorizado mediante\n");
                            xFooter.Add("Resolucion Nro.034-005-0006616/SUNAT \n");
                            xFooter.Add("RUC 20519069262 BOLETA de Venta\n");
                            xFooter.Add("Electronica, para consultar el\n");
                            xFooter.Add("documento ingrese a www.facturas.com.pe\n");
                            xFooter.Add("----------------------------------------\n");
                            xFooter.Add("*** GRACIAS POR SU COMPRA ***\n");

                            //
                            List <string> xCodigo   = new List <string>();
                            List <string> xProducto = new List <string>();
                            List <string> xValor    = new List <string>();
                            List <string> xCant     = new List <string>();
                            List <string> xUM       = new List <string>();

                            ////////// cargar los datos de los productos a facturar
                            ////////xCodigo.Add("GH90");
                            ////////xProducto.Add("GASOLINA90");
                            ////////xCant.Add("1.925");
                            ////////xUM.Add("GLN");
                            ////////xValor.Add("20.00");
                            //////////
                            ////////// cargar los datos de los productos a facturar
                            ////////xCodigo.Add("AG01");
                            ////////xProducto.Add("CIELO 250ML");
                            ////////xCant.Add("1");
                            ////////xUM.Add("UND");
                            ////////xValor.Add("1.50");
                            //////////

                            foreach (DataGridViewRow row in grvDetalleVenta.Rows)
                            {
                                xCodigo.Add(row.Cells[5].Value.ToString());
                                xProducto.Add(row.Cells[6].Value.ToString());
                                xCant.Add(row.Cells[8].Value.ToString());
                                xUM.Add("GLN");
                                xValor.Add(row.Cells[9].Value.ToString());
                            }

                            PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson();

                            var BytesValue = Encoding.ASCII.GetBytes(string.Empty);
                            BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center());
                            //
                            // IMPRIMIENDO ENCABEZADO //
                            for (int i = 0; i < xHeader.Count; i++)
                            {
                                BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(xHeader[i]));
                            }
                            BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl());
                            // IMPRIMIENDO DETALLES //
                            for (int i = 0; i < xCodigo.Count; i++)
                            {
                                string xC = xCodigo[i];
                                string xP = xProducto[i];
                                string xQ = xCant[i];
                                string xU = xUM[i];
                                string xV = xValor[i];
                                xTotal = xTotal + Convert.ToDecimal(xV);
                                string linea = Der(xC, 8) + Der(xP, 12) + Izq(xQ, 8) + Der(xU, 4) + Izq(xV, 8) + "\n";
                                BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(linea));
                            }
                            BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl());
                            BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("----------------------------------------\n"));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{1,10}{2,10:N2}\n", "TOTAL", "", xTotal));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.GRAVADA", "", "", xTotal_gravado));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.INAFECTA", "", "", xTotal_inafecto));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "IGV (18.00%)", "", "", xTotal_igv));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.EXONERADA", "", "", xTotal_exonerado));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "I.S.C.", "", "", xTotal_isc));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "IMPORTE TOTAL", "", "", xTotal));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Conserve su comprobante\n"));
                            // IMPRESION DE PIE DE COMPROBANTE //
                            for (int i = 0; i < xFooter.Count; i++)
                            {
                                BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(xFooter[i]));
                            }
                            BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n"));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, VariablesGlobales.empresa.Str_texto);
                            BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n"));
                            BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage());
                            PrinterUtility.PrintExtensions.Print(BytesValue, GestionCombustibles.Properties.Settings.Default.PrinterPath);

                            // COMO HABILITAR LA IMPRESORA:
                            // configurar una impresora Generic/Txt apuntando a puerto FILE, renombrarla y compartirla como TMU220
                            // en Settings: crear una clave PrinterPath \\\\<nombre de esta pc>\\TMU220
                            // ejemplo : \\\\DEVELOPER_01\\TMU220
                            //
                            // FIN DE IMPRESION
                        }

                        Descartar();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrió un error al registrar la operación.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR:" + ex.ToString());
            }
        }
Esempio n. 3
0
        public static int Registrar_Comprobante(BE_Comprobante pBE_comprobante)
        {
            int intIDInsercion = 0;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    using (SqlCommand cmd = (SqlCommand)db.GetStoredProcCommand("USP_INS_COMPROBANTE"))
                    {
                        cmd.CommandTimeout = Convert.ToInt32(DuracionConexion.corta);
                        db.AddOutParameter(cmd, "@id_comprobante", DbType.Int32, 0);
                        db.AddInParameter(cmd, "@v_tipo_comprobante", DbType.String, pBE_comprobante.Str_Tipo_Comprobante);
                        db.AddInParameter(cmd, "@v_serie_comprobante", DbType.String, pBE_comprobante.Str_Serie_Comprobante);
                        db.AddInParameter(cmd, "@v_numero_comprobante", DbType.String, pBE_comprobante.Str_Numero_Comprobante);
                        db.AddInParameter(cmd, "@v_num_documento_cliente", DbType.String, pBE_comprobante.Str_Num_Documento_Cliente);
                        db.AddInParameter(cmd, "@v_fecha_hora_comprobante", DbType.String, pBE_comprobante.Str_Fecha_Hora_Comprobante);
                        db.AddInParameter(cmd, "@v_placa_comprobante", DbType.String, pBE_comprobante.Str_Placa_Comprobante);
                        db.AddInParameter(cmd, "@v_linea_cred_soles_comprobante", DbType.String, pBE_comprobante.Str_Linea_Cred_Soles_Comprobante);
                        db.AddInParameter(cmd, "@v_cod_operador", DbType.String, pBE_comprobante.Str_Cod_Operador);
                        db.AddInParameter(cmd, "@v_cod_turno", DbType.String, pBE_comprobante.Str_Cod_Turno);
                        db.AddInParameter(cmd, "@v_tarjeta_soles_comprobante", DbType.String, pBE_comprobante.Str_Tarjeta_Soles_Comprobante);
                        db.AddInParameter(cmd, "@v_linea_cred_comprobante", DbType.String, pBE_comprobante.Str_Linea_Cred_Comprobante);
                        db.AddInParameter(cmd, "@d_total_gravado_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Gravado_Comprobante);
                        db.AddInParameter(cmd, "@d_total_gratuito_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Gratuito_Comprobante);
                        db.AddInParameter(cmd, "@d_total_inafecto_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Inafecto_Comprobante);
                        db.AddInParameter(cmd, "@d_total_exonerado_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Exonerado_Comprobante);
                        db.AddInParameter(cmd, "@d_dscnto_global_comprobante", DbType.Decimal, pBE_comprobante.Dec_Dscnto_Global_Comprobante);
                        db.AddInParameter(cmd, "@d_total_venta_soles_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Venta_Soles_Comprobante);
                        db.AddInParameter(cmd, "@d_total_igv_soles_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Igv_Soles_Comprobante);
                        db.AddInParameter(cmd, "@d_total_isc_soles_comprobante", DbType.Decimal, pBE_comprobante.Dec_Total_Isc_Soles_Comprobante);
                        db.AddInParameter(cmd, "@d_efectivo_soles_comprobante", DbType.Decimal, pBE_comprobante.Dec_Efectivo_Soles_Comprobante);
                        db.AddInParameter(cmd, "@d_tipo_cambio_comprobante", DbType.Decimal, pBE_comprobante.Dec_Tipo_Cambio_Comprobante);
                        db.AddInParameter(cmd, "@d_efectivo_dolares_comprobante", DbType.Decimal, pBE_comprobante.Dec_Efectivo_Dolares_Comprobante);
                        db.AddInParameter(cmd, "@d_pago_comprobante", DbType.Decimal, pBE_comprobante.Dec_Pago_Comprobante);
                        db.AddInParameter(cmd, "@d_vuelto_comprobante", DbType.Decimal, pBE_comprobante.Dec_Vuelto_Comprobante);
                        db.AddInParameter(cmd, "@v_monto_letras_comprobante", DbType.String, pBE_comprobante.Str_Monto_Letras_Comprobante);
                        db.AddInParameter(cmd, "@v_hash_comprobante", DbType.String, pBE_comprobante.Str_Hash_Comprobante);
                        db.AddInParameter(cmd, "@v_msjrpta_comprobante", DbType.String, pBE_comprobante.Str_MsjRpta_Comprobante);
                        db.AddInParameter(cmd, "@id_usuario_creacion", DbType.Int32, pBE_comprobante.IDUsuarioCreacion);
                        db.ExecuteNonQuery(cmd);
                        intIDInsercion     = Convert.ToInt32(db.GetParameterValue(cmd, "@id_comprobante"));
                        pBE_comprobante.ID = intIDInsercion;
                    }

                    foreach (var item in pBE_comprobante.Listado_Detalle)
                    {
                        int intIDDetalleInsercion = 0;
                        using (SqlCommand cmdDetalle = (SqlCommand)db.GetStoredProcCommand("USP_INS_COMPROBANTE_DETALLE"))
                        {
                            cmdDetalle.CommandTimeout = Convert.ToInt32(DuracionConexion.corta);
                            db.AddOutParameter(cmdDetalle, "@id_item_comprobante", DbType.Int32, 0);
                            db.AddInParameter(cmdDetalle, "@id_comprobante", DbType.Int32, intIDInsercion);
                            db.AddInParameter(cmdDetalle, "@v_cod_isla", DbType.String, item.Str_Cod_Isla);
                            db.AddInParameter(cmdDetalle, "@v_cod_surtidor", DbType.String, item.Str_Cod_Surtidor);
                            db.AddInParameter(cmdDetalle, "@v_cod_lados", DbType.String, item.Str_Cod_Lados);
                            db.AddInParameter(cmdDetalle, "@v_cod_manguera", DbType.String, item.Str_Cod_Manguera);
                            db.AddInParameter(cmdDetalle, "@v_cod_producto", DbType.String, item.Str_Cod_Producto);
                            db.AddInParameter(cmdDetalle, "@d_precio_unitario_dcomprobante", DbType.Decimal, item.Dec_Precio_Unitario_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_cantidad_dcomprobante", DbType.Decimal, item.Dec_Cantidad_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_subtotal_gravado_comprobante", DbType.Decimal, item.Dec_SubTotal_Gravado_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_subtotal_gratuito_comprobante", DbType.Decimal, item.Dec_SubTotal_Gratuito_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_subtotal_inafecto_comprobante", DbType.Decimal, item.Dec_SubTotal_Inafecto_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_subtotal_exonerado_comprobante", DbType.Decimal, item.Dec_SubTotal_Exonerado_DComprobante);
                            db.AddInParameter(cmdDetalle, "@d_subtotal_item_comprobante", DbType.Decimal, item.Dec_SubTotal_Item_DComprobante);
                            db.AddInParameter(cmdDetalle, "@i_flg_afecto_igv", DbType.Int32, item.Int_Flg_Agecto_IGV);
                            db.AddInParameter(cmdDetalle, "@d_igv_item_dcomprobante", DbType.Decimal, item.Dec_IGV_Item_DComprobante);
                            db.AddInParameter(cmdDetalle, "@i_flg_afecto_isc", DbType.Int32, item.Int_Flg_Agecto_ISC);
                            db.AddInParameter(cmdDetalle, "@d_isc_item_dcomprobante", DbType.Decimal, item.Dec_ISC_Item_DComprobante);
                            db.AddInParameter(cmdDetalle, "@id_usuario_creacion", DbType.Int32, item.IDUsuarioCreacion);
                            db.ExecuteNonQuery(cmdDetalle);

                            intIDDetalleInsercion = Convert.ToInt32(db.GetParameterValue(cmdDetalle, "@id_item_comprobante"));
                        }
                    }

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(intIDInsercion);
        }