Exemplo n.º 1
0
        public override global::System.Data.DataSet Clone()
        {
            dsReporte cln = ((dsReporte)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        //Función para crear el reporte de transferencias
        public void crearReporteTransferencias()
        {
            try
            {
                sSql = "Select m.Fecha,m.Cg_Empresa,m.ID_BODEGA,m.CG_TIPO_MOVIMIENTO,m.ID_LOCALIDAD, " +
                       "m.Cg_Moneda_Base,m.Referencia_Externa,m.Nota_pedido,m.FACTURA,m.Nota_entrega,m.Observacion, " +
                       "m.cg_motivo_movimiento_bodega,m.Id_Auxiliar, m.Id_Persona, m.Porcentaje_IVA,m.Porcentaje_descuento,  " +
                       "m.id_c_movimiento, m.estado_replica, m.estado from cv402_cabecera_movimientos m left outer join  " +
                       "cv404_auxiliares_contables a " +
                       "on m.id_auxiliar =a.id_auxiliar  Where m.Id_Movimiento_Bodega=" + iIdMovimientoBodega;

                dtConsulta = new DataTable();
                dtConsulta.Clear();
                brespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql);
                if (brespuesta == true)
                {
                    if (dtConsulta.Rows.Count > 0)
                    {
                        ds = new dsReporte();                                                                                    //Creo una variable de tipo dsReporte
                        dt = ds.Tables["dtTrasnferencias"];                                                                      // intancio el dataset dtIngresos
                        dt.Clear();                                                                                              // limpio el datatable
                        DataRow dr;                                                                                              //creo una varible de tipo datarow para aumentar lineas a mi reporte

                        for (int i = 0; i < dtConsulta.Rows.Count; i++)                                                          // recorro todo el datatable de la consulta sql
                        {
                            dr = dt.NewRow();                                                                                    // instancio una nuevo fila a mi datatable
                            dr["nombreEmpresa"]    = "RIVAS PAOLA 5";                                                            // se llena el nombre de la empresa (por el momento se ingresa manualmente)
                            dr["numeroMovimiento"] = sNumeroMovimiento;                                                          // se llena con el número de movimiento
                            dr["fecha"]            = dtConsulta.Rows[i].ItemArray[0].ToString();                                 // se llena con la fecha
                            dr["bodegaOrigen"]     = buscarBodega(iIdBodegaOrigen);                                              // me manda a una función que me retorna el nombre de la bodega
                            dr["bodegaDestino"]    = buscarBodega(iIdBodegaDestino);                                             // me manda a una función que me retorna el nombre de la bodega
                            dr["observacion"]      = dtConsulta.Rows[i].ItemArray[10].ToString();
                            dr["motivo"]           = buscarMotivo(Convert.ToInt32(dtConsulta.Rows[i].ItemArray[11].ToString())); //Función que me devuelve el nombre del motivo

                            dt.Rows.Add(dr);
                        }

                        Reportes.reporteTrasnferenciaBodega reporte = new Reportes.reporteTrasnferenciaBodega();

                        reporte.SetDataSource(dt);
                        //ESTA LINEA PERMITE VISUALIZAR EL REPORTE ANTES DE IMPRIMIR
                        this.crystalReportViewer1.ReportSource = reporte;
                        crystalReportViewer1.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Ocurrió un problema al crear el reporte", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Reportes", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            dsReporte ds = new dsReporte();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Exemplo n.º 4
0
        //FUNCION PARA LLENAR EL DATATABLE
        private void llenarDataTable()
        {
            try
            {
                dsReporte ds = new dsReporte();
                dt = ds.Tables["dtReceta"];
                dt.Clear();

                DataRow dr;

                for (int i = 0; i < dtConsulta.Rows.Count; i++)
                {
                    dr = dt.NewRow();

                    dr["descripcion_receta"] = dtConsulta.Rows[i]["descripcion_receta"];
                    dr["descripcion_clasificacion_receta"] = dtConsulta.Rows[i]["descripcion_clasificacion_receta"];
                    dr["descripcion_tipo_receta"]          = dtConsulta.Rows[i]["descripcion_tipo_receta"];
                    dr["descripcion_origen_receta"]        = dtConsulta.Rows[i]["descripcion_origen_receta"];
                    dr["rendimiento_receta"] = dtConsulta.Rows[i]["rendimiento_receta"];
                    dr["num_porciones"]      = dtConsulta.Rows[i]["num_porciones"];
                    dr["descripcion_temperatura_de_servicio"] = dtConsulta.Rows[i]["descripcion_temperatura_de_servicio"];
                    dr["precio_de_venta"]       = dtConsulta.Rows[i]["precio_de_venta"];
                    dr["costo_unitario_receta"] = dtConsulta.Rows[i]["costo_unitario_receta"];
                    dr["porcentaje_costo"]      = dtConsulta.Rows[i]["porcentaje_costo"];
                    dr["porcentaje_utilidad"]   = dtConsulta.Rows[i]["porcentaje_utilidad"];
                    dr["utilidad_de_servicios"] = dtConsulta.Rows[i]["utilidad_de_servicios"];
                    dr["utilidad_de_ganancias"] = dtConsulta.Rows[i]["utilidad_de_ganancias"];
                    dr["costo_total"]           = dtConsulta.Rows[i]["costo_total"];
                    dr["nombre_producto"]       = dtConsulta.Rows[i]["nombre_producto"];
                    dr["cantidad_bruta"]        = dtConsulta.Rows[i]["cantidad_bruta"];
                    dr["cantidad_neta"]         = dtConsulta.Rows[i]["cantidad_neta"];
                    dr["descripcion_unidad"]    = dtConsulta.Rows[i]["descripcion_unidad"];
                    dr["descripcion_porcion"]   = dtConsulta.Rows[i]["descripcion_porcion"];
                    dr["costo_unitario"]        = dtConsulta.Rows[i]["costo_unitario"];
                    dr["rendimiento"]           = dtConsulta.Rows[i]["rendimiento"];
                    dr["importe"]               = dtConsulta.Rows[i]["importe"];
                    dr["id_pos_receta"]         = dtConsulta.Rows[i]["id_pos_receta"];
                    dr["id_pos_detalle_receta"] = dtConsulta.Rows[i]["id_pos_detalle_receta"];

                    dt.Rows.Add(dr);
                }

                Receta.frmReporteListadoReceta reporte = new frmReporteListadoReceta(dt);
                reporte.ShowDialog();
            }

            catch (Exception ex)
            {
                catchMensaje.LblMensaje.Text = ex.ToString();
                catchMensaje.ShowDialog();
            }
        }
Exemplo n.º 5
0
        //FUNCION PARA CREAR EL REPORTE
        private void crearReporte()
        {
            try
            {
                sSql  = "";
                sSql += "select consumo_alimentos" + Environment.NewLine;
                sSql += "from pos_vw_factura" + Environment.NewLine;
                sSql += "where id_factura = " + iIdFactura;

                dtConsulta = new DataTable();
                dtConsulta.Clear();

                bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql);

                if (bRespuesta == false)
                {
                    catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql;
                    catchMensaje.ShowDialog();
                }

                if (dtConsulta.Rows[0]["consumo_alimentos"].ToString() == "1")
                {
                    if (llenarFacturaConsumoAlimentos() == false)
                    {
                        ok.LblMensaje.Text = "Error el generar el reporte electrónico.";
                        ok.ShowDialog();
                    }
                }

                else
                {
                    dsReporte ds = new dsReporte();
                    DataTable dt = ds.Tables["dtRIDE"];
                    dt.Clear();

                    sNumeroRUC            = dtDatos.Rows[0]["numeroruc"].ToString();
                    sRazonSocial          = dtDatos.Rows[0]["razonsocial"].ToString();
                    sNombreComercial      = dtDatos.Rows[0]["nombrecomercial"].ToString();
                    sDireccionMatriz      = dtDatos.Rows[0]["direccionmatriz"].ToString();
                    sDireccionSucursal    = dtDatos.Rows[0]["direccionsucursal"].ToString();
                    sNumeroResolucion     = dtDatos.Rows[0]["numeroresolucioncontribuyenteespecial"].ToString();
                    sObligadoContabilidad = dtDatos.Rows[0]["obligadollevarcontabilidad"].ToString();
                    sClaveAcceso          = dtDatos.Rows[0]["clave_acceso"].ToString();
                    sFechaAutorizacion    = dtDatos.Rows[0]["fecha_autorizacion"].ToString();
                    sHoraAutorizacion     = dtDatos.Rows[0]["hora_autorizacion"].ToString();

                    if (sHoraAutorizacion.Trim() == "")
                    {
                        sHoraAutorizacion = DateTime.Now.ToString();
                    }

                    sAmbiente          = dtDatos.Rows[0]["ambiente"].ToString();
                    sEmision           = dtDatos.Rows[0]["emision"].ToString();
                    sFechaFactura      = dtDatos.Rows[0]["fecha_factura"].ToString();
                    sIdentificacion    = dtDatos.Rows[0]["identificacion"].ToString();
                    sDireccion         = dtDatos.Rows[0]["direccion_factura"].ToString();
                    sTelefono          = dtDatos.Rows[0]["telefono_factura"].ToString();
                    sCorreoElectronico = dtDatos.Rows[0]["email_factura"].ToString();
                    sTipoOrden         = dtDatos.Rows[0]["tipo_orden"].ToString();
                    sNumeroOrden       = dtDatos.Rows[0]["numero_orden"].ToString();
                    sNumeroCuenta      = dtDatos.Rows[0]["numero_cuenta"].ToString();
                    sCajero            = dtDatos.Rows[0]["cajero"].ToString();
                    sFormaPagoSRI      = dtDatos.Rows[0]["descripcion_sri_forma_pago"].ToString();
                    sNumeroFactura     = dtDatos.Rows[0]["estab"].ToString() + "-" + dtDatos.Rows[0]["ptoemi"].ToString() + "-" + dtDatos.Rows[0]["numero_factura"].ToString().PadLeft(9, '0');
                    sNombreCliente     = (dtDatos.Rows[0]["nombres"].ToString() + " " + dtDatos.Rows[0]["apellidos"].ToString()).Trim();

                    dbPorcentajeIVA = Convert.ToDecimal(dtDatos.Rows[0]["porcentaje_iva"].ToString());
                    dbPropina       = Convert.ToDecimal(dtDatos.Rows[0]["propina"].ToString());

                    Logo = barcode(sClaveAcceso);

                    dbSumaIVA        = 0;
                    dbSumaICE        = 0;
                    dbSumaDescuento  = 0;
                    dbTotal          = 0;
                    dbSubtotalSinIva = 0;
                    dbSubtotalConIva = 0;
                    dbSubtotal       = 0;

                    for (int i = 0; i < dtDatos.Rows.Count; i++)
                    {
                        sCodigo         = dtDatos.Rows[i]["codigo"].ToString();
                        sNombreProducto = dtDatos.Rows[i]["nombre"].ToString();

                        iPagaIVA = Convert.ToInt32(dtDatos.Rows[i]["paga_iva"].ToString());
                        iPagaICE = Convert.ToInt32(dtDatos.Rows[i]["paga_ice"].ToString());

                        dbCantidad       = Convert.ToDecimal(dtDatos.Rows[i]["cantidad"].ToString());
                        dbPrecioUnitario = Convert.ToDecimal(dtDatos.Rows[i]["precio_unitario"].ToString());
                        dbValorDescuento = Convert.ToDecimal(dtDatos.Rows[i]["valor_dscto"].ToString());
                        dbValorIVA       = Convert.ToDecimal(dtDatos.Rows[i]["valor_iva"].ToString());
                        dbValorICE       = Convert.ToDecimal(dtDatos.Rows[i]["valor_ice"].ToString());

                        dbSumaDescuento  += dbCantidad * dbValorDescuento;
                        dbPrecioItemTotal = dbCantidad * (dbPrecioUnitario - dbValorDescuento);

                        if (iPagaIVA == 1)
                        {
                            dbSumaIVA        += dbCantidad * dbValorIVA;
                            dbSubtotalConIva += dbPrecioItemTotal;
                        }

                        else
                        {
                            dbSubtotalSinIva += dbPrecioItemTotal;
                        }

                        if (iPagaICE == 1)
                        {
                            dbSumaICE += dbCantidad * dbValorICE;
                        }

                        dt.Rows.Add();
                        dt.Rows[i]["cantidad"]          = dbCantidad;
                        dt.Rows[i]["precio_unitario"]   = dbPrecioUnitario;
                        dt.Rows[i]["valor_dscto"]       = dbValorDescuento;
                        dt.Rows[i]["porcentaje_IVA"]    = dbPorcentajeIVA;
                        dt.Rows[i]["valor_IVA"]         = dbValorIVA;
                        dt.Rows[i]["Paga_IVA"]          = iPagaIVA;
                        dt.Rows[i]["valor_ICE"]         = dbValorICE;
                        dt.Rows[i]["Paga_ICE"]          = iPagaICE;
                        dt.Rows[i]["propina"]           = dbPropina;
                        dt.Rows[i]["codigo"]            = sCodigo;
                        dt.Rows[i]["numeroruc"]         = sNumeroRUC;
                        dt.Rows[i]["razonsocial"]       = sRazonSocial;
                        dt.Rows[i]["nombrecomercial"]   = sNombreComercial;
                        dt.Rows[i]["direccionmatriz"]   = sDireccionMatriz;
                        dt.Rows[i]["direccionsucursal"] = sDireccionSucursal;
                        dt.Rows[i]["numeroresolucioncontribuyenteespecial"] = sNumeroResolucion;
                        dt.Rows[i]["obligadollevarcontabilidad"]            = sObligadoContabilidad;
                        dt.Rows[i]["clave_acceso"]               = sClaveAcceso;
                        dt.Rows[i]["fecha_autorizacion"]         = sFechaAutorizacion;
                        dt.Rows[i]["hora_autorizacion"]          = sHoraAutorizacion;
                        dt.Rows[i]["ambiente"]                   = sAmbiente;
                        dt.Rows[i]["emision"]                    = sEmision;
                        dt.Rows[i]["fecha_factura"]              = sFechaFactura;
                        dt.Rows[i]["identificacion"]             = sIdentificacion;
                        dt.Rows[i]["direccion_factura"]          = sDireccion;
                        dt.Rows[i]["telefono_factura"]           = sTelefono;
                        dt.Rows[i]["email_factura"]              = sCorreoElectronico;
                        dt.Rows[i]["tipo_orden"]                 = sTipoOrden;
                        dt.Rows[i]["numero_orden"]               = sNumeroOrden;
                        dt.Rows[i]["numero_cuenta"]              = sNumeroCuenta;
                        dt.Rows[i]["cajero"]                     = sCajero;
                        dt.Rows[i]["descripcion_sri_forma_pago"] = sFormaPagoSRI;
                        dt.Rows[i]["numero_factura"]             = sNumeroFactura;
                        dt.Rows[i]["nombre_cliente"]             = sNombreCliente;
                        dt.Rows[i]["precio_total"]               = dbPrecioItemTotal;
                        dt.Rows[i]["suma_iva"]                   = 0;
                        dt.Rows[i]["suma_ice"]                   = 0;
                        dt.Rows[i]["suma_descuento"]             = 0;
                        dt.Rows[i]["total"]              = 0;
                        dt.Rows[i]["nombre"]             = sNombreProducto;
                        dt.Rows[i]["subtotal_con_iva"]   = 0;
                        dt.Rows[i]["subtotal_sin_iva"]   = 0;
                        dt.Rows[i]["suma_sin_impuestos"] = 0;
                        dt.Rows[i]["clave_acceso_barra"] = Logo;
                        dt.Rows[i]["logo_factura"]       = Logo_Factura;
                    }

                    dbTotal = dbSubtotalConIva + dbSubtotalSinIva + dbSumaICE + dbSumaIVA;

                    dt.Rows[0]["suma_iva"]           = dbSumaIVA;
                    dt.Rows[0]["suma_ice"]           = dbSumaICE;
                    dt.Rows[0]["suma_descuento"]     = dbSumaDescuento;
                    dt.Rows[0]["total"]              = dbTotal;
                    dt.Rows[0]["subtotal_con_iva"]   = dbSubtotalConIva;
                    dt.Rows[0]["subtotal_sin_iva"]   = dbSubtotalSinIva;
                    dt.Rows[0]["suma_sin_impuestos"] = dbSubtotalConIva + dbSubtotalSinIva;

                    //rptFacturaEletronica reporte = ProcessingMode.Local;
                    rptVisor.LocalReport.ReportEmbeddedResource = "Palatium.Facturacion_Electronica.rptRIDE.rdlc";
                    //rptVisor.LocalReport.ReportPath =
                    ReportDataSource reporte = new ReportDataSource("dsRide", dt);
                    rptVisor.LocalReport.DataSources.Clear();
                    rptVisor.LocalReport.DataSources.Add(reporte);
                    rptVisor.LocalReport.Refresh();
                    rptVisor.RefreshReport();
                }
            }

            catch (Exception)
            {
            }
        }
Exemplo n.º 6
0
        //FUNCION PARA CREAR EL RIDE DE CONSUMO DE ALIMENTOA
        private bool llenarFacturaConsumoAlimentos()
        {
            try
            {
                dsReporte ds = new dsReporte();
                DataTable dt = ds.Tables["dtRIDE"];
                dt.Clear();

                sNumeroRUC            = dtDatos.Rows[0]["numeroruc"].ToString();
                sRazonSocial          = dtDatos.Rows[0]["razonsocial"].ToString();
                sNombreComercial      = dtDatos.Rows[0]["nombrecomercial"].ToString();
                sDireccionMatriz      = dtDatos.Rows[0]["direccionmatriz"].ToString();
                sDireccionSucursal    = dtDatos.Rows[0]["direccionsucursal"].ToString();
                sNumeroResolucion     = dtDatos.Rows[0]["numeroresolucioncontribuyenteespecial"].ToString();
                sObligadoContabilidad = dtDatos.Rows[0]["obligadollevarcontabilidad"].ToString();
                sClaveAcceso          = dtDatos.Rows[0]["clave_acceso"].ToString();
                sFechaAutorizacion    = dtDatos.Rows[0]["fecha_autorizacion"].ToString();
                sHoraAutorizacion     = dtDatos.Rows[0]["hora_autorizacion"].ToString();

                if (sHoraAutorizacion.Trim() == "")
                {
                    sHoraAutorizacion = DateTime.Now.ToString();
                }

                sAmbiente          = dtDatos.Rows[0]["ambiente"].ToString();
                sEmision           = dtDatos.Rows[0]["emision"].ToString();
                sFechaFactura      = dtDatos.Rows[0]["fecha_factura"].ToString();
                sIdentificacion    = dtDatos.Rows[0]["identificacion"].ToString();
                sDireccion         = dtDatos.Rows[0]["direccion_factura"].ToString();
                sTelefono          = dtDatos.Rows[0]["telefono_factura"].ToString();
                sCorreoElectronico = dtDatos.Rows[0]["email_factura"].ToString();
                sTipoOrden         = dtDatos.Rows[0]["tipo_orden"].ToString();
                sNumeroOrden       = dtDatos.Rows[0]["numero_orden"].ToString();
                sNumeroCuenta      = dtDatos.Rows[0]["numero_cuenta"].ToString();
                sCajero            = dtDatos.Rows[0]["cajero"].ToString();
                sFormaPagoSRI      = dtDatos.Rows[0]["descripcion_sri_forma_pago"].ToString();
                sNumeroFactura     = dtDatos.Rows[0]["estab"].ToString() + "-" + dtDatos.Rows[0]["ptoemi"].ToString() + "-" + dtDatos.Rows[0]["numero_factura"].ToString().PadLeft(9, '0');
                sNombreCliente     = (dtDatos.Rows[0]["nombres"].ToString() + " " + dtDatos.Rows[0]["apellidos"].ToString()).Trim();

                dbPorcentajeIVA = Convert.ToDecimal(dtDatos.Rows[0]["porcentaje_iva"].ToString());
                dbPropina       = Convert.ToDecimal(dtDatos.Rows[0]["propina"].ToString());

                Logo = barcode(sClaveAcceso);

                sCodigo         = "CONSALI";
                sNombreProducto = "CONSUMO ALIMENTOS";

                dbSumaIVA        = 0;
                dbSumaICE        = 0;
                dbSumaDescuento  = 0;
                dbTotal          = 0;
                dbSubtotalSinIva = 0;
                dbSubtotalConIva = 0;
                dbSubtotal       = 0;

                for (int i = 0; i < dtDatos.Rows.Count; i++)
                {
                    iPagaIVA = Convert.ToInt32(dtDatos.Rows[i]["paga_iva"].ToString());
                    iPagaICE = Convert.ToInt32(dtDatos.Rows[i]["paga_ice"].ToString());

                    dbCantidad       = Convert.ToDecimal(dtDatos.Rows[i]["cantidad"].ToString());
                    dbPrecioUnitario = Convert.ToDecimal(dtDatos.Rows[i]["precio_unitario"].ToString());
                    dbValorDescuento = Convert.ToDecimal(dtDatos.Rows[i]["valor_dscto"].ToString());
                    dbValorIVA       = Convert.ToDecimal(dtDatos.Rows[i]["valor_iva"].ToString());
                    dbValorICE       = Convert.ToDecimal(dtDatos.Rows[i]["valor_ice"].ToString());

                    dbSumaDescuento  += dbCantidad * dbValorDescuento;
                    dbPrecioItemTotal = dbCantidad * (dbPrecioUnitario - dbValorDescuento);

                    if (iPagaIVA == 1)
                    {
                        dbSumaIVA        += dbCantidad * dbValorIVA;
                        dbSubtotalConIva += dbPrecioItemTotal;
                    }

                    else
                    {
                        dbSubtotalSinIva += dbPrecioItemTotal;
                    }

                    if (iPagaICE == 1)
                    {
                        dbSumaICE += dbCantidad * dbValorICE;
                    }
                }

                dt.Rows.Add();
                dt.Rows[0]["cantidad"]          = "1";
                dt.Rows[0]["precio_unitario"]   = dbSubtotalConIva + dbSubtotalSinIva;
                dt.Rows[0]["valor_dscto"]       = dbValorDescuento;
                dt.Rows[0]["porcentaje_IVA"]    = dbPorcentajeIVA;
                dt.Rows[0]["valor_IVA"]         = dbValorIVA;
                dt.Rows[0]["Paga_IVA"]          = iPagaIVA;
                dt.Rows[0]["valor_ICE"]         = dbValorICE;
                dt.Rows[0]["Paga_ICE"]          = iPagaICE;
                dt.Rows[0]["propina"]           = dbPropina;
                dt.Rows[0]["codigo"]            = sCodigo;
                dt.Rows[0]["numeroruc"]         = sNumeroRUC;
                dt.Rows[0]["razonsocial"]       = sRazonSocial;
                dt.Rows[0]["nombrecomercial"]   = sNombreComercial;
                dt.Rows[0]["direccionmatriz"]   = sDireccionMatriz;
                dt.Rows[0]["direccionsucursal"] = sDireccionSucursal;
                dt.Rows[0]["numeroresolucioncontribuyenteespecial"] = sNumeroResolucion;
                dt.Rows[0]["obligadollevarcontabilidad"]            = sObligadoContabilidad;
                dt.Rows[0]["clave_acceso"]               = sClaveAcceso;
                dt.Rows[0]["fecha_autorizacion"]         = sFechaAutorizacion;
                dt.Rows[0]["hora_autorizacion"]          = sHoraAutorizacion;
                dt.Rows[0]["ambiente"]                   = sAmbiente;
                dt.Rows[0]["emision"]                    = sEmision;
                dt.Rows[0]["fecha_factura"]              = sFechaFactura;
                dt.Rows[0]["identificacion"]             = sIdentificacion;
                dt.Rows[0]["direccion_factura"]          = sDireccion;
                dt.Rows[0]["telefono_factura"]           = sTelefono;
                dt.Rows[0]["email_factura"]              = sCorreoElectronico;
                dt.Rows[0]["tipo_orden"]                 = sTipoOrden;
                dt.Rows[0]["numero_orden"]               = sNumeroOrden;
                dt.Rows[0]["numero_cuenta"]              = sNumeroCuenta;
                dt.Rows[0]["cajero"]                     = sCajero;
                dt.Rows[0]["descripcion_sri_forma_pago"] = sFormaPagoSRI;
                dt.Rows[0]["numero_factura"]             = sNumeroFactura;
                dt.Rows[0]["nombre_cliente"]             = sNombreCliente;
                dt.Rows[0]["precio_total"]               = dbSubtotalConIva + dbSubtotalSinIva;
                dt.Rows[0]["suma_iva"]                   = 0;
                dt.Rows[0]["suma_ice"]                   = 0;
                dt.Rows[0]["suma_descuento"]             = 0;
                dt.Rows[0]["total"]              = 0;
                dt.Rows[0]["nombre"]             = sNombreProducto;
                dt.Rows[0]["subtotal_con_iva"]   = 0;
                dt.Rows[0]["subtotal_sin_iva"]   = 0;
                dt.Rows[0]["suma_sin_impuestos"] = 0;
                dt.Rows[0]["clave_acceso_barra"] = Logo;
                dt.Rows[0]["logo_factura"]       = Logo_Factura;

                dbTotal = dbSubtotalConIva + dbSubtotalSinIva + dbSumaICE + dbSumaIVA;

                dt.Rows[0]["suma_iva"]           = dbSumaIVA;
                dt.Rows[0]["suma_ice"]           = dbSumaICE;
                dt.Rows[0]["suma_descuento"]     = dbSumaDescuento;
                dt.Rows[0]["total"]              = dbTotal;
                dt.Rows[0]["subtotal_con_iva"]   = dbSubtotalConIva;
                dt.Rows[0]["subtotal_sin_iva"]   = dbSubtotalSinIva;
                dt.Rows[0]["suma_sin_impuestos"] = dbSubtotalConIva + dbSubtotalSinIva;

                //rptFacturaEletronica reporte = ProcessingMode.Local;
                rptVisor.LocalReport.ReportEmbeddedResource = "Palatium.Facturacion_Electronica.rptRIDE.rdlc";
                //rptVisor.LocalReport.ReportPath =
                ReportDataSource reporte = new ReportDataSource("dsRide", dt);
                rptVisor.LocalReport.DataSources.Clear();
                rptVisor.LocalReport.DataSources.Add(reporte);
                rptVisor.LocalReport.Refresh();
                rptVisor.RefreshReport();


                return(true);
            }

            catch (Exception)
            {
                return(false);
            }
        }
        //Función para crear el reporte
        public void crearReporte()
        {
            try
            {
                sSql  = "";
                sSql += "Select m.Fecha, m.Cg_Empresa, m.ID_BODEGA, m.CG_TIPO_MOVIMIENTO," + Environment.NewLine;
                sSql += "m.ID_LOCALIDAD, m.Cg_Moneda_Base, m.Referencia_Externa, m.Nota_pedido," + Environment.NewLine;
                sSql += "m.FACTURA, m.Nota_entrega, m.Observacion, m.cg_motivo_movimiento_bodega," + Environment.NewLine;
                sSql += "m.Id_Auxiliar, m.Id_Persona, m.Porcentaje_IVA,m.Porcentaje_descuento," + Environment.NewLine;
                sSql += "m.id_c_movimiento, m.estado_replica, m.estado" + Environment.NewLine;
                sSql += "from cv402_cabecera_movimientos m left outer join" + Environment.NewLine;
                sSql += "cv404_auxiliares_contables a on m.id_auxiliar = a.id_auxiliar" + Environment.NewLine;
                sSql += "where m.Id_Movimiento_Bodega=" + iIdMovimientoBodega;

                dtConsulta = new DataTable();
                dtConsulta.Clear();
                brespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql);

                if (brespuesta == true)
                {
                    if (dtConsulta.Rows.Count > 0)
                    {
                        ds = new dsReporte();                                                                                          //Creo una variable de tipo dsReporte
                        dt = ds.Tables["dtIngresos"];                                                                                  // intancio el dataset dtIngresos
                        dt.Clear();                                                                                                    // limpio el datatable
                        DataRow dr;                                                                                                    //creo una varible de tipo datarow para aumentar lineas a mi reporte

                        for (int i = 0; i < dtConsulta.Rows.Count; i++)                                                                // recorro todo el datatable de la consulta sql
                        {
                            dr = dt.NewRow();                                                                                          // instancio una nuevo fila a mi datatable
                            dr["nombreEmpresa"] = "RIVAS PAOLA";                                                                       // se llena el nombre de la empresa (por el momento se ingresa manualmente)
                            dr["numeroIngreso"] = sNumeroMovimiento;                                                                   // se llena con el numero de movimiento
                            dr["fechaIngreso"]  = dtConsulta.Rows[i].ItemArray[0].ToString();                                          // se llena con la fecha
                            int iIdBodega = Convert.ToInt32(dtConsulta.Rows[i].ItemArray[2].ToString());
                            dr["nombreBodega"]  = buscarBodega(iIdBodega);                                                             // me manda a una función que me retorna el nombre de la bodega
                            dr["referencia"]    = dtConsulta.Rows[i].ItemArray[6].ToString();                                          // me devuelve el número de referencia
                            dr["proveedor"]     = buscarNombreProveedor(Convert.ToInt32(dtConsulta.Rows[i].ItemArray[12].ToString())); // función que me retorna el nombre del proovedor
                            dr["Iva"]           = dtConsulta.Rows[i].ItemArray[14].ToString();                                         // Me devuelve el porcentaje del iva
                            dr["numeroFactura"] = dtConsulta.Rows[i].ItemArray[8].ToString();                                          //Me devuelve el número de factura que está almacenado en la base de datos
                            dr["horaIngreso"]   = "10:49";                                                                             //la hora está puesta manualmente hasta el momento
                            dr["motivo"]        = buscarMotivo(Convert.ToInt32(dtConsulta.Rows[i].ItemArray[11].ToString()));          //Función que me devuelve el nombre del motivo
                            dr["descuento"]     = dtConsulta.Rows[i].ItemArray[15].ToString();                                         // me devuelve el porcentaje de descuento
                            dr["observacion"]   = dtConsulta.Rows[i].ItemArray[10].ToString();                                         // me devuelve la observación
                            dr["notaEntrega"]   = dtConsulta.Rows[i].ItemArray[9].ToString();

                            dt.Rows.Add(dr);
                        }

                        sSql  = "";
                        sSql += "SELECT MB.CORRELATIVO, P.codigo codigo_producto, N.nombre producto, MB.Id_Producto," + Environment.NewLine;
                        sSql += "MB.especificacion, U.codigo unidad, MB.cg_unidad_compra cg_unidad_compra, MB.CANTIDAD," + Environment.NewLine;
                        sSql += conexion.GFun_St_esnulo() + "(MB.Valor_Unitario, 0) Valor_unitario," + Environment.NewLine;
                        sSql += conexion.GFun_St_esnulo() + "(round(100*MB.Valor_Dscto/MB.valor_Unitario,2), 0) Pct_Dscto," + Environment.NewLine;
                        sSql += conexion.GFun_St_esnulo() + "(MB.Valor_Iva, 0) Valor_Iva, " + conexion.GFun_St_esnulo() + "(MB.VALOR_DSCTO, 0) valor_dscto," + Environment.NewLine;
                        sSql += "Case when P.Paga_Iva = 1 Then 1 Else 0 End Paga_Iva" + Environment.NewLine;
                        sSql += "from cv402_movimientos_bodega MB, cv401_productos P," + Environment.NewLine;
                        sSql += "tp_codigos U, cv401_nombre_productos N" + Environment.NewLine;
                        sSql += "where MB.Id_Producto = P.Id_Producto" + Environment.NewLine;
                        sSql += "and P.Id_Producto = N.Id_Producto" + Environment.NewLine;
                        sSql += "and N.Nombre_Interno = 1" + Environment.NewLine;
                        sSql += "and N.Estado = 'A'" + Environment.NewLine;
                        sSql += "and MB.CG_UNIDAD_COMPRA = U.Correlativo " + Environment.NewLine;
                        sSql += "and MB.Id_Movimiento_Bodega = " + iIdMovimientoBodega + Environment.NewLine;
                        sSql += "and MB.Estado = 'A'" + Environment.NewLine;
                        sSql += "order By MB.Correlativo";

                        DataTable dtConsulta1 = new DataTable();
                        dtDetalle = ds.Tables["dtDetalleIngresos"];
                        dtConsulta1.Clear();
                        DataRow drDetalle;
                        brespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta1, sSql);

                        if (brespuesta == true)
                        {
                            if (dtConsulta1.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtConsulta1.Rows.Count; i++)
                                {
                                    drDetalle                      = dtDetalle.NewRow();
                                    drDetalle["item"]              = i + 1;
                                    drDetalle["codigo"]            = dtConsulta1.Rows[i].ItemArray[1].ToString();
                                    drDetalle["producto"]          = dtConsulta1.Rows[i].ItemArray[2].ToString();
                                    drDetalle["cantidad"]          = dtConsulta1.Rows[i].ItemArray[7].ToString();
                                    drDetalle["precio"]            = dtConsulta1.Rows[i].ItemArray[8].ToString();
                                    drDetalle["descuentoProducto"] = dtConsulta1.Rows[i].ItemArray[11].ToString();
                                    double dbCantidad  = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[7].ToString());
                                    double dbDescuento = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[11].ToString());
                                    double dbPrecio    = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[8].ToString());
                                    double dbIva       = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[10].ToString());
                                    double dbTotal     = (dbCantidad * (dbPrecio + dbIva - dbDescuento));
                                    drDetalle["total"] = dbTotal;

                                    dtDetalle.Rows.Add(drDetalle);
                                }
                            }
                        }


                        // llenarDetalle();

                        Reportes.reporteIngresoBodega reporte = new Reportes.reporteIngresoBodega();

                        reporte.SetDataSource(dt);
                        reporte.Subreports[0].SetDataSource(dtDetalle);
                        //ESTA LINEA PERMITE VISUALIZAR EL REPORTE ANTES DE IMPRIMIR
                        this.crystalReportViewer1.ReportSource = reporte;
                        crystalReportViewer1.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Ocurrió un problema al crear el reporte", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrió un problema al crear el reporte", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 8
0
        public bool generarRide(DataTable dtDatos_R, string filename, long iIdFactura)
        {
            try
            {
                this.dtDatos  = dtDatos_R;
                this.filename = filename;

                dsReporte ds = new dsReporte();
                DataTable dt = ds.Tables["dtRIDE"];
                dt.Clear();

                sNumeroRUC            = dtDatos.Rows[0]["numeroruc"].ToString();
                sRazonSocial          = dtDatos.Rows[0]["razonsocial"].ToString();
                sNombreComercial      = dtDatos.Rows[0]["nombrecomercial"].ToString();
                sDireccionMatriz      = dtDatos.Rows[0]["direccionmatriz"].ToString();
                sDireccionSucursal    = dtDatos.Rows[0]["direccionsucursal"].ToString();
                sNumeroResolucion     = dtDatos.Rows[0]["numeroresolucioncontribuyenteespecial"].ToString();
                sObligadoContabilidad = dtDatos.Rows[0]["obligadollevarcontabilidad"].ToString();

                sClaveAcceso       = dtDatos.Rows[0]["clave_acceso"].ToString();
                sFechaAutorizacion = dtDatos.Rows[0]["fecha_autorizacion"].ToString();
                sHoraAutorizacion  = dtDatos.Rows[0]["hora_autorizacion"].ToString();

                if (sHoraAutorizacion.Trim() == "")
                {
                    sHoraAutorizacion = DateTime.Now.ToString();
                }

                sAmbiente          = dtDatos.Rows[0]["ambiente"].ToString().ToUpper();
                sEmision           = dtDatos.Rows[0]["emision"].ToString().ToUpper();
                sFechaFactura      = dtDatos.Rows[0]["fecha_factura"].ToString();
                sIdentificacion    = dtDatos.Rows[0]["identificacion"].ToString();
                sDireccion         = dtDatos.Rows[0]["direccion_factura"].ToString();
                sTelefono          = dtDatos.Rows[0]["telefono_factura"].ToString();
                sCorreoElectronico = dtDatos.Rows[0]["email_factura"].ToString();
                sTipoOrden         = dtDatos.Rows[0]["tipo_orden"].ToString();
                sNumeroOrden       = dtDatos.Rows[0]["numero_orden"].ToString();
                sNumeroCuenta      = dtDatos.Rows[0]["numero_cuenta"].ToString();
                sCajero            = dtDatos.Rows[0]["cajero"].ToString();
                sFormaPagoSRI      = dtDatos.Rows[0]["descripcion_sri_forma_pago"].ToString();
                sNumeroFactura     = dtDatos.Rows[0]["estab"].ToString() + "-" + dtDatos.Rows[0]["ptoemi"].ToString() + "-" + dtDatos.Rows[0]["numero_factura"].ToString().PadLeft(9, '0');
                sNombreCliente     = (dtDatos.Rows[0]["nombres"].ToString() + " " + dtDatos.Rows[0]["apellidos"].ToString()).Trim();

                dbPorcentajeIVA = Convert.ToDecimal(dtDatos.Rows[0]["porcentaje_iva"].ToString());
                dbPropina       = Convert.ToDecimal(dtDatos.Rows[0]["propina"].ToString());

                dbSumaIVA        = 0;
                dbSumaICE        = 0;
                dbSumaDescuento  = 0;
                dbTotal          = 0;
                dbSubtotalSinIva = 0;
                dbSubtotalConIva = 0;
                dbSubtotal       = 0;

                for (int i = 0; i < dtDatos.Rows.Count; i++)
                {
                    sCodigo         = dtDatos.Rows[i]["codigo"].ToString();
                    sNombreProducto = dtDatos.Rows[i]["nombre"].ToString();
                    iPagaIVA        = Convert.ToInt32(dtDatos.Rows[i]["paga_iva"].ToString());
                    iPagaICE        = Convert.ToInt32(dtDatos.Rows[i]["paga_ice"].ToString());

                    dbCantidad       = Convert.ToDecimal(dtDatos.Rows[i]["cantidad"].ToString());
                    dbPrecioUnitario = Convert.ToDecimal(dtDatos.Rows[i]["precio_unitario"].ToString());
                    dbValorDescuento = Convert.ToDecimal(dtDatos.Rows[i]["valor_dscto"].ToString());
                    dbValorIVA       = Convert.ToDecimal(dtDatos.Rows[i]["valor_iva"].ToString());
                    dbValorICE       = Convert.ToDecimal(dtDatos.Rows[i]["valor_ice"].ToString());

                    dbSumaDescuento  += dbCantidad * dbValorDescuento;
                    dbPrecioItemTotal = dbCantidad * (dbPrecioUnitario - dbValorDescuento);

                    if (iPagaIVA == 1)
                    {
                        dbSumaIVA        += dbCantidad * dbValorIVA;
                        dbSubtotalConIva += dbPrecioItemTotal;
                    }

                    else
                    {
                        dbSubtotalSinIva += dbPrecioItemTotal;
                    }

                    if (iPagaICE == 1)
                    {
                        dbSumaICE += dbCantidad * dbValorICE;
                    }

                    dt.Rows.Add();
                    dt.Rows[i]["cantidad"]          = dbCantidad;
                    dt.Rows[i]["precio_unitario"]   = dbPrecioUnitario;
                    dt.Rows[i]["valor_dscto"]       = dbValorDescuento;
                    dt.Rows[i]["porcentaje_IVA"]    = dbPorcentajeIVA;
                    dt.Rows[i]["valor_IVA"]         = dbValorIVA;
                    dt.Rows[i]["Paga_IVA"]          = iPagaIVA;
                    dt.Rows[i]["valor_ICE"]         = dbValorICE;
                    dt.Rows[i]["Paga_ICE"]          = iPagaICE;
                    dt.Rows[i]["propina"]           = dbPropina;
                    dt.Rows[i]["codigo"]            = sCodigo;
                    dt.Rows[i]["numeroruc"]         = sNumeroRUC;
                    dt.Rows[i]["razonsocial"]       = sRazonSocial;
                    dt.Rows[i]["nombrecomercial"]   = sNombreComercial;
                    dt.Rows[i]["direccionmatriz"]   = sDireccionMatriz;
                    dt.Rows[i]["direccionsucursal"] = sDireccionSucursal;
                    dt.Rows[i]["numeroresolucioncontribuyenteespecial"] = sNumeroResolucion;
                    dt.Rows[i]["obligadollevarcontabilidad"]            = sObligadoContabilidad;
                    dt.Rows[i]["clave_acceso"]               = sClaveAcceso;
                    dt.Rows[i]["fecha_autorizacion"]         = sFechaAutorizacion;
                    dt.Rows[i]["hora_autorizacion"]          = sHoraAutorizacion;
                    dt.Rows[i]["ambiente"]                   = sAmbiente;
                    dt.Rows[i]["emision"]                    = sEmision;
                    dt.Rows[i]["fecha_factura"]              = sFechaFactura;
                    dt.Rows[i]["identificacion"]             = sIdentificacion;
                    dt.Rows[i]["direccion_factura"]          = sDireccion;
                    dt.Rows[i]["telefono_factura"]           = sTelefono;
                    dt.Rows[i]["email_factura"]              = sCorreoElectronico;
                    dt.Rows[i]["tipo_orden"]                 = sTipoOrden;
                    dt.Rows[i]["numero_orden"]               = sNumeroOrden;
                    dt.Rows[i]["numero_cuenta"]              = sNumeroCuenta;
                    dt.Rows[i]["cajero"]                     = sCajero;
                    dt.Rows[i]["descripcion_sri_forma_pago"] = sFormaPagoSRI;
                    dt.Rows[i]["numero_factura"]             = sNumeroFactura;
                    dt.Rows[i]["nombre_cliente"]             = sNombreCliente;
                    dt.Rows[i]["precio_total"]               = dbPrecioItemTotal;
                    dt.Rows[i]["suma_iva"]                   = 0;
                    dt.Rows[i]["suma_ice"]                   = 0;
                    dt.Rows[i]["suma_descuento"]             = 0;
                    dt.Rows[i]["total"]              = 0;
                    dt.Rows[i]["nombre"]             = sNombreProducto;
                    dt.Rows[i]["subtotal_con_iva"]   = 0;
                    dt.Rows[i]["subtotal_sin_iva"]   = 0;
                    dt.Rows[i]["suma_sin_impuestos"] = 0;
                }

                dbTotal = dbSubtotalConIva + dbSubtotalSinIva + dbSumaICE + dbSumaIVA;

                dt.Rows[0]["suma_iva"]           = dbSumaIVA;
                dt.Rows[0]["suma_ice"]           = dbSumaICE;
                dt.Rows[0]["suma_descuento"]     = dbSumaDescuento;
                dt.Rows[0]["total"]              = dbTotal;
                dt.Rows[0]["subtotal_con_iva"]   = dbSubtotalConIva;
                dt.Rows[0]["subtotal_sin_iva"]   = dbSubtotalSinIva;
                dt.Rows[0]["suma_sin_impuestos"] = dbSubtotalConIva + dbSubtotalSinIva;

                ReportViewer reporte = new ReportViewer();
                LocalReport  objeto  = new LocalReport();
                reporte.LocalReport.ReportEmbeddedResource = "Palatium.Facturacion_Electronica.rptRIDE.rdlc";
                ReportDataSource reporteSource = new ReportDataSource("dsRide", dt);
                reporte.LocalReport.DataSources.Clear();
                reporte.LocalReport.DataSources.Add(reporteSource);
                reporte.LocalReport.Refresh();
                reporte.RefreshReport();

                File.WriteAllBytes(filename, reporte.LocalReport.Render("PDF"));

                //byte[] bytes = reporte.LocalReport.Render("PDF");

                //reporte.ReportExport

                return(true);
            }

            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 9
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                dsReporte ds = new dsReporte();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "DataTable1DataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }