protected void GeneraReporte(string opcion, int pos, bool nulo)
        {
            string ruta      = "";
            string nombredoc = "";

            Reporte_General.CXC.cxcrepregistro01 Reporte_Registro = new Reporte_General.CXC.cxcrepregistro01();

            if (nulo == false)
            {
                Reporte_Registro._Letrero_Copia = "COPIA";
            }
            else
            {
                Reporte_Registro._Letrero_Copia = "<<NULO>> COPIA";
            }

            Reporte_Registro._id = gridBase1.Rows[pos].Cells["dgvidregistro"].Value.ToString();
            Reporte_Registro.Fun_Reporte();

            if (opcion == "Imprimir")
            {
                Reporte_Registro.Show();
            }
            else if (opcion == "Enviar")
            {
                nombredoc = gridBase1.Rows[pos].Cells["dgvsecuencia"].Value.ToString() + "-" + System.DateTime.Now.ToString("yyyyMMdd");
                ruta      = Funciones_Duke4.Funciones.Fun_Exportar_aPDF(@"C:\Reporte_Duke4\Reporte_CxC\Registros_Facturas\", nombredoc + ".pdf", Reporte_Registro.reportViewer1);
                mail.Attachments.Add(new Attachment(ruta));
            }
        }
        protected override void Imprimir()
        {
            base.Imprimir();
            var Reporte_Registro = new Reporte_General.CXC.cxcrepregistro01();

            Reporte_Registro._id = _secuencia;
            if (_nulo == false)
            {
                Reporte_Registro._Letrero_Copia = "COPIA";
            }
            else
            {
                Reporte_Registro._Letrero_Copia = "<<NULO>> COPIA";
            }

            Reporte_Registro.Show();
            Reporte_Registro.Owner = this;
        }
        protected override void Salvar()
        {
            base.Salvar();
            Control[] array = { Txtregistro, Txtcodigocliente, Txtcodigovendedor, Txtregistro, Cmbmoneda, Dgv };

            if (!Funciones.Fun_Validar_Campos_Vacios(array))
            {
                string encabezado = "";
                string detalle = "";
                string cierre = "";
                string xml = "";
                double tasaitbis = 0, montoexcento = 0, montogravado16, montogravado18;
                double importe = Funciones.Fun_Convierte_String_aDecimal(Txttotal.Text) - Funciones.Fun_Convierte_String_aDecimal(Txtitbis.Text);

                encabezado = "<Registros csecuencia=\"" + Txtregistro.Text
                             + "\" dfecha=\"" + Funciones.Fun_Convertir_Fecha_FormatoyyyMMdd(Dtpfecha)
                             + "\" creferencia=\"" + Txtreferencia.Text
                             + "\" nidcliente=\"" + Funciones.Fun_Convierte_String_aEntrero(Txtcodigocliente.Text)
                             + "\" ntotal=\"" + Funciones.Fun_Convierte_String_aDecimal(Txttotal.Text)
                             + "\" nbalance=\"" + Funciones.Fun_Convierte_String_aDecimal(Txttotal.Text)
                             + "\" ntotalitbis=\"" + Funciones.Fun_Convierte_String_aDecimal(Txtitbis.Text)
                             + "\" ntotalexento=\"" + Funciones.Fun_Convierte_String_aDecimal(Txtexcento.Text)
                             + "\" ntotalgravado16=\"" + Funciones.Fun_Convierte_String_aDecimal(Txtgravado16.Text)
                             + "\" ntotalgravado18=\"" + Funciones.Fun_Convierte_String_aDecimal(Txtgravado18.Text)
                             + "\" ntotaldescuentoporciento=\"" + 0
                             + "\" ntotaldescuentomonto=\"" + 0
                             + "\" ntotalimporte=\"" + importe
                             + "\" dfechavencimiento=\"" + Funciones.Fun_Convertir_Fecha_FormatoyyyMMdd(Dtpfechavencimiento)
                             + "\" nidvendedor=\"" + Funciones.Fun_Convierte_String_aEntrero(Txtcodigovendedor.Text)
                             + "\" cncf=\"" + Mskncf.Text
                             + "\" nidcontabilidad=\"" + 0
                             + "\" nidmoneda=\"" + Cmbmoneda.SelectedValue
                             + "\" ccomentario=\"" + Txtcomentrio.Text
                             + "\" nbalancecliente =\"" + Funciones.Fun_Convierte_String_aDecimal(Txtbalancecliente.Text)
                             + "\" ntiporegistro =\"" + 1
                             + "\" ntotalcargo =\"" + 0
                             + "\" nidbanco =\"" + 0
                             + "\" nidcuentabancaria =\"" + 0
                             + "\"> <Facturas>";

                foreach (DataGridViewRow item in Dgv.Rows)
                {
                    montoexcento = montogravado16 = montogravado18 = 0;

                    tasaitbis = Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvtasaitbis"].Value));

                    if (tasaitbis == 0)
                    {
                        montoexcento = Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvmonto"].Value));
                    }
                    else if (tasaitbis == 0.16)
                    {
                        montogravado16 = Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvmonto"].Value));
                    }
                    else if (tasaitbis == 0.18)
                    {
                        montogravado18 = Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvmonto"].Value));
                    }


                    detalle = detalle + "<Factura nidconcepto=\"" + Funciones.Fun_Convierte_String_aEntrero(Convert.ToString(item.Cells["dgvid"].Value))
                              + "\" cdescripcion=\"" + item.Cells["dgvdescripcion"].Value
                              + "\" ncantidad=\"" + 1
                              + "\" nprecio=\"" + Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvmonto"].Value))
                              + "\" ndescuentomonto=\"" + 0
                              + "\" ndescuentoporciento=\"" + 0
                              + "\" nmontoitbis=\"" + Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvitbis"].Value))
                              + "\" nmontoexento=\"" + montoexcento
                              + "\" nmontogravado16=\"" + montogravado16
                              + "\" nmontogravado18=\"" + montogravado18
                              + "\" nmontoimporte=\"" + Funciones.Fun_Convierte_String_aDecimal(Convert.ToString(item.Cells["dgvtotal"].Value))
                              + "\" norden=\"" + Funciones.Fun_Convierte_String_aEntrero(Convert.ToString(item.Cells["dgvorden"].Value))
                              + "\" nmontocargo=\"" + 0
                              + "\"/>";
                }

                cierre = "</Facturas> </Registros>";
                xml    = encabezado + detalle + cierre;

                string  cmd = string.Format("exec Spr_cxc_registro '{0}','{1}','{2}','{3}'", _OpcionSQL, Properties.Settings.Default.idsesion, 1, xml); //Armo el comando
                DataSet ds  = FuncionesSQL.Fun_Sql_Ejecutar(cmd);

                if (Ckbimprimir.Checked)
                {
                    var Reporte_Registro = new Reporte_General.CXC.cxcrepregistro01();
                    if (_OpcionSQL == "Modificar")
                    {
                        Reporte_Registro._id = ds.Tables[0].Rows[0][0].ToString();
                    }
                    else
                    {
                        Reporte_Registro._id = ds.Tables[1].Rows[0][0].ToString();
                    }

                    Reporte_Registro.Show();
                    Reporte_Registro.Owner = this;
                }

                Funciones.Fun_Limpiar_Formulario(MainPanel);

                if (_OpcionSQL == "Insertar")
                {
                    Crear();
                }
                else
                {
                    Modificar();
                }

                Ckbimprimir.Checked = true;

                LblAlerta.Text = "";
            }
            else
            {
                LblAlerta.Text = Mensajes.Stg_Campos_EnBlanco;
            }
        }