Untitled
vbnet
posted: Jan, 18th 2012 | jump to bottom
Código Exportación Electricidad Dim CadenaConexion As String Dim col As Integer Dim BNCR As String, Server1 As String Dim Server As String Dim Rs As New ADODB.Recordset, Rs2 As New ADODB.Recordset Dim Rs1 As New ADODB.Recordset Dim Sql As String Dim Sql1 As String Dim Descripcion As String, Factura As String, Monto As String Dim Factura1 As String, Monto1 As String, fecha As String, Linea As String Dim CnConectividad As New ADODB.Connection Dim Identificador As String, Nombre As String, Electricidad As String Dim LFecha As New clsFecha, x As Long LFecha.fecha = TraeFechaServer Rs.Open "select sum(d.monto)as monto,a.fchlectura,b.nombre,c.fchvence,b.codasociado,b.direccion," _ & " a.codmedsoc,a.idinterno,a.idfact" _ & " from fac_detfact as a, fac_asociados as b, fac_encfact as c,fac_detcob as d" _ & " where c.id=a.idfact and c.estado=0 and a.codsocio=b.codasociado And A.IdInterno = D.IdInterno" _ & " group by a.fchlectura,b.nombre,c.fchvence,b.codasociado,b.direccion,a.codmedsoc,a.idinterno,a.idfact", Cn 'en lugar del numero de cedula se va a enviar el codigomedidor y contrato 'tipo de identificacion es 002 'la descripcion mejor separarla por dos punto e incluir numero valorservicio 'detallar si va a afectar al sincronizador 'incluir todos los rubros Server = Servidor1 BNCR = BaseDatos1 CadenaConexion = "Provider=SQLOLEDB.1;Password=coop34LF4roRu1z;Persist Security " _ & "Info=False;User ID=sa;Initial Catalog=" & BNCR _ & ";Data Source=" & Server CnConectividad.Open CadenaConexion Barra.Value = 0 Barra.max = 7000 If Not ConsultaVacia(Rs) Then While Not FinDeTabla(Rs) Descripcion = Rs!CodAsociado & "," & Rs!Direccion x = Len(Descripcion) If x <= 60 Then Descripcion = Descripcion & String(60 - Len(Descripcion), " ") Else x = Len(Rs!CodAsociado) x = 60 - x Descripcion = Rs!CodAsociado & Mid(Rs!Direccion, 1, x) End If Identificador = Rs!CodMedSoc & String(30 - Len(Rs!CodMedSoc), " ") Nombre = Rs!Nombre & String(50 - Len(Rs!Nombre), " ") Monto = Format(Rs!Monto, "000000000000000000") Factura = Format(Rs!IdInterno, "00000000000000000000") fecha = LFecha.fecha '8 & LFecha.Hora6 Barra.Value = Barra.Value + 1 Sql = "Insert into PARRecibosServicios(codigoconvenio,valorservicio,periodorecibo,numerofacturarecibo,descripcionservicio," _ & "tipoidentificacion,identificacioncliente,nombrecliente,montototalrecibo,fechavencimientorecibo,estado, fecharegistro,estadosincronizacion)values(" _ & "'001'" & "," & "'Electricidad '" & "," & Rs!FchLectura & "," & PonerComillas(Factura) & "," & PonerComillas(Electricidad & Descripcion) & "," & "'002'" & "," & PonerComillas(Identificador) & "," & PonerComillas(Nombre) & "," & PonerComillas(Monto) & "," & Rs!FchVence & "," & 1 & "," & PonerComillas(fecha) & "," & 0 & ")" Rs2.Open Sql, CnConectividad Set Rs2 = Nothing Rs1.Open "Select b.nolinea,b.monto,c.mes,c.ano,a.idinterno" _ & " from fac_detfact as a, fac_detcob as b, fac_encfact as c" _ & " where a.idinterno=b.idinterno and c.estado=0 and " _ & " c.ID = A.IdFact and a.idinterno=" & Rs!IdInterno, Cn If Not ConsultaVacia(Rs1) Then While Not FinDeTabla(Rs1) Factura1 = Format(Rs1!IdInterno, "00000000000000000000") Monto1 = Format(Rs1!Monto, "000000000000000000") Linea = Format(Rs1!NoLinea, "0000") Sql1 = "Insert into parrubrosrecibosservicios(codigoconvenio,valorservicio,periodorecibo, numerofacturarecibo, codigorubro,montorubro)values(" _ & "'001'" & "," & "'Electricidad '" & "," & PonerComillas(Rs!FchLectura) & "," & PonerComillas(Factura1) & "," & PonerComillas(Linea) & "," & Monto1 & ")" Rs2.Open Sql1, CnConectividad Set Rs2 = Nothing Rs1.MoveNext Wend End If Rs.MoveNext Set Rs1 = Nothing Wend MsgBox "Proceso concluido. Medidores procesados: " & Barra.Value Else MsgBox "No hay datos para exportar" End If Set Rs = Nothing End Sub Código Exportación Infocomunicaciones Dim CadenaConexion As String Dim col As Integer Dim BNCR As String Dim Server As String Dim rs As New ADODB.Recordset, Rs2 As New ADODB.Recordset Dim Rs1 As New ADODB.Recordset Dim Sql As String Dim Sql1 As String Dim Descripcion As String, Factura As String, Monto As String Dim Factura1 As String, Monto1 As String, Fecha As String, Linea As String Dim CnConectividad As New ADODB.Connection Dim Identificador As String, Nombre As String, Infocomunicaciones As String Dim x As Long Dim LFecha As New clsFecha LFecha.Fecha = TraeFechaServer rs.Open "select sum(d.monto)as monto,d.fecha,b.nombre,c.fchvence,b.codasociado,b.direccion," _ & " a.codservicio,a.idinterno" _ & " from atp_factcatvdet as a, fac_asociados as b, atp_factcatvenc as c,atp_factcatvdetcob as d, atp_suscripcionescatv as e" _ & " where c.id=a.idfact and c.estado=0 and e.codsocio=b.codasociado And A.IdInterno = D.IdInterno and a.codservicio=e.id" _ & " group by d.fecha,b.nombre,c.fchvence,b.codasociado,b.direccion,a.codservicio,a.idinterno", Cn Server = Servidor1 BNCR = BaseDatos1 CadenaConexion = "Provider=SQLOLEDB.1;Password=coop34LF4roRu1z;Persist Security " _ & "Info=False;User ID=sa;Initial Catalog=" & BNCR _ & ";Data Source=" & Server CnConectividad.Open CadenaConexion Barra.Value = 0 Barra.Max = 7000 If Not ConsultaVacia(rs) Then While Not FinDeTabla(rs) Descripcion = Infocomunicaciones & "," & rs!CodAsociado & "," & rs!Direccion x = Len(Descripcion) If x <= 60 Then Descripcion = Descripcion & String(60 - Len(Descripcion), " ") Else x = Len(rs!CodAsociado) x = 60 - x Descripcion = Infocomunicaciones & rs!CodAsociado & Mid(rs!Direccion, 1, x) End If Identificador = rs!codservicio & String(30 - Len(rs!codservicio), " ") Nombre = rs!Nombre & String(50 - Len(rs!Nombre), " ") Monto = Format(rs!Monto, "000000000000000000") Factura = Format(rs!IdInterno, "00000000000000000000") Fecha = LFecha.Fecha '8 & LFecha.Hora6 Barra.Value = Barra.Value + 1 Sql = "Insert into PARRecibosServicios(codigoconvenio,valorservicio,periodorecibo,numerofacturarecibo,descripcionservicio," _ & "tipoidentificacion,identificacioncliente,nombrecliente,montototalrecibo,fechavencimientorecibo,estado, fecharegistro,estadosincronizacion)values(" _ & "'001'" & "," & "'Infocomunicaciones '" & "," & rs!Fecha & "," & PonerComillas(Factura) & "," & PonerComillas(Descripcion) & "," & "'002'" & "," & PonerComillas(Identificador) & "," & PonerComillas(Nombre) & "," _ & PonerComillas(Monto) & "," & rs!FchVence & "," & 1 & "," & PonerComillas(Fecha) & "," & 0 & ")" Rs2.Open Sql, CnConectividad Set Rs2 = Nothing Rs1.Open "Select b.nolinea,b.descripcion,b.monto,c.mes,c.ano,a.idinterno" _ & " from atp_factcatvdet as a, atp_factcatvdetcob as b, atp_factcatvenc as c" _ & " where a.idinterno=b.idinterno and c.estado=0 and a.idinterno=" & rs!IdInterno _ & " and c.ID = A.IdFact ", Cn If Not ConsultaVacia(Rs1) Then While Not FinDeTabla(Rs1) Factura1 = Format(Rs1!IdInterno, "00000000000000000000") Monto1 = Format(Rs1!Monto, "000000000000000000") Select Case Trim(Rs1!Descripcion) Case "I.Venta": Linea = "0004" Case "Multa": Linea = "0250" Case "Contenido CoopeAlfaroRuiz": Linea = "1001" Case "Costo Administrativo": Linea = "1003" Case "Infraestructura": Linea = "1004" Case "Acceso Internet": Linea = "1010" End Select 'Linea = Format(Rs1!nolinea, "1000") Sql1 = "Insert into parrubrosrecibosservicios(codigoconvenio,valorservicio,periodorecibo, numerofacturarecibo,codigorubro,montorubro)values(" _ & "'001'" & "," & "'Infocomunicaciones '" & "," & PonerComillas(rs!Fecha) & "," & PonerComillas(Factura1) & "," & PonerComillas(Linea) & "," & Monto1 & ")" Rs2.Open Sql1, CnConectividad Set Rs2 = Nothing Rs1.MoveNext Wend End If rs.MoveNext Set Rs1 = Nothing Wend MsgBox "Proceso concluido. Medidores procesados: " & Barra.Value Else MsgBox "No hay datos para exportar" End If Set rs = Nothing End Sub
24 views




