Projecte/Treball Final de Carrera
|
|
|
- Hollie Skinner
- 9 years ago
- Views:
Transcription
1 Projecte/Treball Final de Carrera Estudi: Eng. Tècn. Informàtica de Gestió. Pla 1993 Títol: Aplicació de comptabilitat Document: Annex I Codi font i script SQL server Alumne: Joan Carles Jiménez Carmona Director/Tutor: Didac Barragan Pascual Departament: Informàtica i Matemàtica Aplicada Àrea: LSI Convocatòria (mes/any): 09/2006
2 Aplicació: Comptabilitat v
3 Índex del document: ANNEX I CODI FONT USUARIOSDELEGACIONES.CLS ACRDEU.CLS APUNTES.CLS ASIENTOS.CLS AUXILIAR.CLS CARTERA.CLS CIERRE.CLS CUENTAS.CLS DELEGACIONES.CLS DIARIOS.CLS DOCUMENTOS.CLS EJERCICIOS.CLS EMPRESAS.CLS FORMASPAGO.CLS IMPUESTOS.CLS IMPUESTOSACRDEU.CLS INFORMES.CLS IRPF.CLS MENUS.CLS MENUSUSUARIOS.CLS NUMERACION.CLS PERGAN.CLS PERSONAL.CLS REGISTROIRPF.CLS REGISTROIVA.CLS REGULARIZACION.CLS SITUACION.CLS USUARIOS.CLS TEMPORALES.BAS FRMABOUT.FRM FRMACRDEU.FRM FRMAPUNTE.FRM FRMASIENTOS.FRM FRMBALANCEPYG.FRM FRMBALANCESITUACION.FRM FRMCIERRE.FRM FRMCUENTAS.FRM FRMDELEGACIONES.FRM FRMDIARIOS.FRM FRMDOCUMENTOS.FRM FRMEJERCICIOS.FRM FRMEMPRESAS.FRM FRMEXTRACTOS.FRM FRMFORMASPAGO.FRM FRMIMPUESTOS.FRM FRMINVERTIR.FRM FRMIRPF.FRM FRMLIBRODIARIO.FRM FRMLIBROIVA.FRM FRMLISTAEMPRESAS.FRM FRMLOGIN.FRM FRMLUPA.FRM FRMMAIN.FRM FRMMENU.FRM FRMMENUSUSUARIOS.FRM
4 56. FRMNUMERACION.FRM FRMOPERACIONESTERCEROS.FRM FRMPERGAN.FRM FRMPERSONAL.FRM FRMREGISTROIVA.FRM FRMREGULARIZACION.FRM FRMSELECCIONCARTERA.FRM FRMSITUACION.FRM FRMSPLASH.FRM FRMSUMASSALDOS.FRM FRMUSUARIOS.FRM FRMUSUARIOSDELEGACIONS.FRM API.BAS GLOBAL.BAS IDENTIFICACIO.BAS INIFUNC.BAS NIF.BAS PRINCIPAL.BAS SEGURIDAD.BAS ANNEX I SCRIPT SQL SERVER
5 Annex I Codi font - 4 -
6 1. UsuariosDelegaciones.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "UsuariosDelegaciones" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresUsuariosDelegaciones iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) ivalidarerror = (vbobjecterror + 5) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Update(cn As ADODB.Connection, codigo_usuario As String, codigo_empresa As String, _ codigo_delegacion As String, activo As Integer, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM UsuariosDelegaciones WHERE codigo_usuario = " & codigo_usuario _ & " AND codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("activo") = activo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM UsuariosDelegaciones" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere - 5 -
7 If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Public Function ValidarUsuario(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ usuario As String, contraseña As String) As Boolean Dim strcmd As String Dim rs As New ADODB.Recordset strcmd = "SELECT Usuarios.codigo_usuario, Usuarios.contraseña FROM Usuarios " _ & "INNER JOIN UsuariosDelegaciones ON (Usuarios.codigo_usuario = UsuariosDelegaciones.codigo_usuario) " _ & "WHERE (UsuariosDelegaciones.codigo_empresa=" & codigo_empresa & " ) AND " _ & "(UsuariosDelegaciones.codigo_delegacion=" & codigo_delegacion & ") AND " _ & "(Usuarios.codigo_usuario=" & usuario & ") AND (Usuarios.contraseña=" _ & contraseña & ") AND (UsuariosDelegaciones.activo <> 0)" On Error GoTo ValidarUsuarioError rs.open strcmd, cn, adopenstatic, adlockoptimistic ValidarUsuario = Not rs.eof Exit Function ValidarUsuarioError: Err.Raise ivalidarerror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function - 6 -
8 2. Acrdeu.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Acrdeu" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresAcrdeu iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, cuenta As String, codigo As String, _ tipo As String, nacionalidad As String, impuesto As String, forma_pago As String, primer_dia As Integer, _ descuento As Double, irpf As String, contrapartida As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Acrdeu WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("cuenta") = cuenta rs("codigo") = codigo rs("tipo") = tipo rs("nacionalidad") = nacionalidad rs("impuesto") = impuesto rs("forma_pago") = forma_pago rs("primer_dia") = primer_dia rs("descuento") = descuento rs("irpf") = irpf rs("contrapartida") = contrapartida rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, cuenta As String, codigo As String, _ - 7 -
9 tipo As String, nacionalidad As String, impuesto As String, forma_pago As String, primer_dia As Integer, _ descuento As Double, irpf As String, contrapartida As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Acrdeu WHERE codigo_empresa = " & codigo_empresa & " AND cuenta = " & cuenta _ & " AND codigo = " & codigo & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("tipo") = tipo rs("nacionalidad") = nacionalidad rs("impuesto") = impuesto rs("forma_pago") = forma_pago rs("primer_dia") = primer_dia rs("descuento") = descuento rs("irpf") = irpf rs("contrapartida") = contrapartida rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, cuenta As String, codigo As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Acrdeu WHERE codigo_empresa = " & codigo_empresa & " AND cuenta = " & cuenta _ & " AND codigo = " & codigo & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Acrdeu" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") - 8 -
10 Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function - 9 -
11 3. Apuntes.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Apuntes" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresApuntes iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, codigo_diario As String, _ fecha_apunte As String, fecha_documento As String, referencia As String, cuenta As String, _ concepto As String, debe As Double, haber As Double, tipo As String, tag As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Apuntes WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("codigo_documento") = codigo_documento rs("numero_documento") = numero_documento rs("numero_apunte") = numero_apunte rs("codigo_diario") = codigo_diario rs("fecha_apunte") = sdate(fecha_apunte) rs("fecha_documento") = sdate(fecha_documento) rs("referencia") = referencia rs("cuenta") = cuenta rs("concepto") = concepto rs("debe") = debe rs("haber") = haber rs("tipo") = tipo rs("tag") = tag rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing
12 Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, codigo_diario As String, _ fecha_apunte As String, fecha_documento As String, referencia As String, cuenta As String, _ concepto As String, debe As Double, haber As Double, tipo As String, tag As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion _ & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " & numero_documento _ & " AND numero_apunte = " & numero_apunte rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("codigo_diario") = codigo_diario rs("fecha_apunte") = sdate(fecha_apunte) rs("fecha_documento") = sdate(fecha_documento) rs("referencia") = referencia rs("cuenta") = cuenta rs("concepto") = concepto rs("debe") = debe rs("haber") = haber rs("tipo") = tipo rs("tag") = tag rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, transaccion_activa As Boolean) Dim strcmd As String On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans If numero_apunte = 0 Then strcmd = "DELETE FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & "" cn.execute strcmd strcmd = "DELETE FROM RegistroIVA WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & "" cn.execute strcmd strcmd = "DELETE FROM RegistroIRPF WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _
13 & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & "" cn.execute strcmd strcmd = "DELETE FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd strcmd = "DELETE FROM RegistroIVA WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd strcmd = "DELETE FROM RegistroIrpf WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd If Not transaccion_activa Then cn.committrans Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Apuntes" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function
14 Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
15 4. Asientos.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Asientos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresAsientos iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, codigo_diario As String, _ fecha_apunte As String, fecha_documento As String, referencia As String, cuenta As String, _ concepto As String, debe As Double, haber As Double, tipo As String, tag As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Apuntes WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("codigo_documento") = codigo_documento rs("numero_documento") = numero_documento rs("numero_apunte") = numero_apunte rs("codigo_diario") = codigo_diario rs("fecha_apunte") = sdate(fecha_apunte) rs("fecha_documento") = sdate(fecha_documento) rs("referencia") = referencia rs("cuenta") = cuenta rs("concepto") = concepto rs("debe") = debe rs("haber") = haber rs("tipo") = tipo rs("tag") = tag rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing
16 Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, codigo_diario As String, _ fecha_apunte As String, fecha_documento As String, referencia As String, cuenta As String, _ concepto As String, debe As Double, haber As Double, tipo As String, tag As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion _ & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " & numero_documento _ & " AND numero_apunte = " & numero_apunte rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("codigo_diario") = codigo_diario rs("fecha_apunte") = fecha_apunte rs("fecha_documento") = fecha_documento rs("referencia") = referencia rs("cuenta") = cuenta rs("concepto") = concepto rs("debe") = debe rs("haber") = haber rs("tipo") = tipo rs("tag") = tag rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer) Dim strcmd As String On Error GoTo DeleteError If numero_apunte = 0 Then strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub
17 Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Apuntes" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
18 5. Auxiliar.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Auxiliar" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Public Function sdate(fecha As Variant) As String If IsDate(fecha) Then sdate = Format(fecha, "yyyymmdd") sdate = "" Function Public Function ddate(yyyymmdd As Variant) As String If yyyymmdd <> "" Then ddate = Mid$(yyyymmdd, 7, 2) & "/" & Mid$(yyyymmdd, 5, 2) & "/" & Mid$(yyyymmdd, 1, 4) ddate = "" Function Public Function vbuscarcampo(tabla As String, campo As String, condicion As String, Optional default As Variant) As Variant Dim strsql As String Dim rs As ADODB.Recordset Dim cn As ADODB.Connection Dim pos As Integer Set cn = New ADODB.Connection cn.open "File name=contabilidad.udl" strsql = "SELECT " & campo & " FROM " & tabla & " WHERE " & condicion Set rs = New ADODB.Recordset pos = InStr(1, UCase(campo), " AS ") If pos > 0 Then campo = Mid(campo, pos + 4) rs.open strsql, cn, adopenstatic, adlockoptimistic vbuscarcampo = IIf(rs.EOF, default, IIf(IsNull(rs(campo)), default, rs(campo))) Set rs = Nothing Set cn = Nothing Function Public Function vbuscarcampotemporal(tabla As String, campo As String, condicion As String, Optional default As Variant) As Variant Dim strsql As String Dim rs As ADODB.Recordset Dim cn As ADODB.Connection Dim pos As Integer Set cnt = New ADODB.Connection cnt.open "File name=temporal.udl" strsql = "SELECT " & campo & " FROM " & tabla & " WHERE " & condicion Set rs = New ADODB.Recordset pos = InStr(1, UCase(campo), " AS ") If pos > 0 Then campo = Mid(campo, pos + 4)
19 rs.open strsql, cnt, adopenstatic, adlockoptimistic vbuscarcampotemporal = IIf(rs.EOF, default, IIf(IsNull(rs(campo)), default, rs(campo))) Set rs = Nothing Set cnt = Nothing Function Public Function DeleteExt(cn As ADODB.Connection, strtable As String, Optional strwhere As String) Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM " & strtable If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere Set rs = New ADODB.Recordset On Error GoTo DeleteError rs.open strcmd, cn, adopenstatic, adlockoptimistic While Not rs.eof rs.delete rs.movenext Wend rs.close Set rs = Nothing Exit Function DeleteError: Err.Raise Err.Number,, FormatError(cn, "Error en DeleteExt.") Function Public Function GetListExt(cn As ADODB.Connection, strtable As String, strfields As String, Optional strwhere As String, _ Optional strgroup As String, Optional strhaving As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT " & strfields & " FROM " & strtable If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strGroup) > 0 Then strcmd = strcmd & " GROUP BY " & strgroup If Len(strHaving) > 0 Then strcmd = strcmd & " HAVING BY " & strhaving If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetListExt = rs Exit Function GetListError: Err.Raise Err.Number,, FormatError(cn, "Error en GetListExt.") Function
20 Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
21 6. Cartera.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Cartera" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresCartera iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) isetestado = (vbobjecterror + 5) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, fecha_vto As String, tipo_acrdeu As String, codigo_personal As String, _ concepto As String, tipo As String, estado As String, importe As Double, fecha_cierre As String, _ codigo_documento_cierre As String, numero_documento_cierre As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Cartera WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("codigo_documento") = codigo_documento rs("numero_documento") = numero_documento rs("numero_apunte") = numero_apunte rs("fecha_vto") = sdate(fecha_vto) rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("concepto") = concepto rs("tipo") = tipo rs("estado") = estado rs("importe") = importe rs("fecha_cierre") = sdate(fecha_cierre) rs("codigo_documento_cierre") = codigo_documento_cierre rs("numero_documento_cierre") = numero_documento_cierre rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing
22 Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, fecha_vto As String, tipo_acrdeu As String, codigo_personal As String, _ concepto As String, tipo As String, estado As String, importe As Double, fecha_cierre As String, _ codigo_documento_cierre As String, numero_documento_cierre As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte & " AND fecha_vto = " & sdate(fecha_vto) & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("concepto") = concepto rs("tipo") = tipo rs("estado") = estado rs("importe") = importe rs("fecha_cierre") = sdate(fecha_cierre) rs("codigo_documento_cierre") = codigo_documento_cierre rs("numero_documento_cierre") = numero_documento_cierre rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, fecha_vto As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte & " AND fecha_vto = " & sdate(fecha_vto) & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Cartera"
23 If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Public Sub SetEstado(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, fecha_vto As String, estado As String, fecha_cierre As String, _ codigo_documento_cierre As String, numero_documento_cierre As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " _ & numero_documento & " AND numero_apunte = " & numero_apunte & " AND fecha_vto = " & sdate(fecha_vto) & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("estado") = estado rs("fecha_cierre") = sdate(fecha_cierre) rs("codigo_documento_cierre") = codigo_documento_cierre rs("numero_documento_cierre") = numero_documento_cierre rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
24 7. Cierre.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Cierre" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Public Enum ErroresCierre iinserterror = (vbobjecterror + 1) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Dim mapuntes As Apuntes Dim mejercicios As Ejercicios Dim mnumeracion As numeracion Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, codigo_documento_cierre As String, _ codigo_documento_apertura As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim debe As Double Dim haber As Double Dim apunte As Integer Dim rs As ADODB.Recordset Dim rsaux As ADODB.Recordset On Error GoTo InsertError apunte = 1 Set mejercicios = New Ejercicios Set rsaux = mejercicios.getlist(cn, "codigo_empresa = " & codigo_empresa & " and ejercicio = " & ejercicio) strcmd = "SELECT cuenta, SUM(debe-haber) AS saldo FROM Apuntes WHERE codigo_empresa = " & codigo_empresa _ & " AND fecha_apunte BETWEEN " & rsaux("fecha_inicial") & " AND " & rsaux("fecha_final") & " " _ & "AND cuenta >= 1 AND cuenta < 6 GROUP BY cuenta HAVING SUM(debe-haber) <> 0 ORDER BY cuenta" Set rs = New ADODB.Recordset rs.open strcmd, cn, adopenstatic, adlockoptimistic If Not rs.eof Then Set mapuntes = New Apuntes Set mauxiliar = New Auxiliar If Not transaccion_activa Then cn.begintrans While Not rs.eof If rs("saldo") > 0 Then mapuntes.insert cn, codigo_empresa, codigo_empresa, codigo_documento_cierre, String(10, "9"), Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", rs("cuenta"), "ASIENTO DE CIERRE", 0, str(rs("saldo")), "A", "", ultimo_usuario mapuntes.insert cn, codigo_empresa, codigo_empresa, codigo_documento_apertura, String(10, "0"), Format(apunte, "00000"), "00000", DateAdd("yyyy", 1, mauxiliar.ddate(rsaux("fecha_inicial"))), "", "", rs("cuenta"), "ASIENTO DE APERTURA", str(rs("saldo")), 0, "A", "", ultimo_usuario
25 mapuntes.insert cn, codigo_empresa, codigo_empresa, codigo_documento_cierre, String(10, "9"), Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", rs("cuenta"), "ASIENTO DE CIERRE", str(- rs("saldo")), 0, "A", "", ultimo_usuario mapuntes.insert cn, codigo_empresa, codigo_empresa, codigo_documento_apertura, String(10, "0"), Format(apunte, "00000"), "00000", DateAdd("yyyy", 1, mauxiliar.ddate(rsaux("fecha_inicial"))), "", "", rs("cuenta"), "ASIENTO DE APERTURA", 0, str(-rs("saldo")), "A", "", ultimo_usuario apunte = apunte + 1 rs.movenext Wend mejercicios.update cn, codigo_empresa, ejercicio, mauxiliar.ddate(rsaux("fecha_inicial")), mauxiliar.ddate(rsaux("fecha_final")), mauxiliar.ddate(rsaux("inicio_bloqueo")), mauxiliar.ddate(rsaux("final_bloqueo")), rsaux("regularizado"), "S", ultimo_usuario If mauxiliar.vbuscarcampo("ejercicios", "ejercicio", "codigo_empresa = " & codigo_empresa & " and ejercicio = " & ejercicio + 1, "#") = "#" Then mejercicios.insert cn, codigo_empresa, ejercicio + 1, DateAdd("yyyy", 1, mauxiliar.ddate(rsaux("fecha_inicial"))), DateAdd("yyyy", 1, mauxiliar.ddate(rsaux("fecha_final"))), "", "", "N", "N", ultimo_usuario, True If Not transaccion_activa Then cn.committrans Set mauxiliar = Nothing Set mapuntes = Nothing Set mejercicios = Nothing rs.close Set rs = Nothing Exit Sub InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, codigo_documento_cierre As String, _ codigo_documento_apertura As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_empresa & " AND codigo_documento = " & codigo_documento_cierre & " AND numero_documento = " _ & String(10, "9") & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_empresa & " AND codigo_documento = " & codigo_documento_apertura & " AND numero_documento = " _ & String(10, "0") & "" cn.execute strcmd Set mauxiliar = New Auxiliar Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & codigo_empresa & " and ejercicio = " & ejercicio) mejercicios.update cn, sempresa, ejercicio, mauxiliar.ddate(rs("fecha_inicial")), mauxiliar.ddate(rs("fecha_final")), mauxiliar.ddate(rs("inicio_bloqueo")), mauxiliar.ddate(rs("final_bloqueo")), rs("regularizado"), "N", ultimo_usuario Set mejercicios = Nothing
26 Set mauxiliar = Nothing If Not transaccion_activa Then cn.committrans Set rs = Nothing Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim rs As ADODB.Recordset Set mapuntes = New Apuntes Set rs = mapuntes.getlist(cn, strwhere, strorder) Set mapuntes = Nothing Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
27 8. Cuentas.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Cuentas" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresCuentas iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, cuenta As String, descripcion As String, pases As String, _ nivel As Integer, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Cuentas WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("cuenta") = cuenta rs("descripcion") = descripcion rs("pases") = pases rs("nivel") = nivel rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, cuenta As String, descripcion As String, pases As String, _ nivel As Integer, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Cuentas WHERE codigo_empresa = " & codigo_empresa & " AND cuenta = " & cuenta & ""
28 rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("descripcion") = descripcion rs("pases") = pases rs("nivel") = nivel rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, cuenta As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Cuentas WHERE codigo_empresa = " & codigo_empresa & " AND cuenta = " & cuenta & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Cuentas" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
29 9. Delegaciones.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Delegaciones" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresDelegaciones iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, nombre As String, _ direccion As String, cp As String, poblacion As String, provincia As String, pais As String, telefono As String, _ fax As String, correo As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset Dim rsaux As New ADODB.Recordset On Error GoTo InsertError If Not transaccion_activa Then cn.begintrans strcmd = "SELECT * FROM Delegaciones WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("nombre") = nombre rs("direccion") = direccion rs("cp") = cp rs("poblacion") = poblacion rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs("correo") = correo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close strcmd = "SELECT codigo_usuario FROM Usuarios GROUP BY codigo_usuario" rs.open strcmd, cn, adopenstatic, adlockoptimistic
30 If Not rs.eof Then strcmd = "SELECT * FROM UsuariosDelegaciones WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_usuario") = rs("codigo_usuario") rsaux("codigo_empresa") = codigo_empresa rsaux("codigo_delegacion") = codigo_delegacion rsaux("activo") = 0 rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close rs.close If Not transaccion_activa Then cn.committrans Set rs = Nothing Set rsaux = Nothing Exit Sub InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, nombre As String, _ direccion As String, cp As String, poblacion As String, provincia As String, pais As String, telefono As String, _ fax As String, correo As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError If Not transaccion_activa Then cn.begintrans strcmd = "SELECT * FROM Delegaciones WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("nombre") = nombre rs("direccion") = direccion rs("cp") = cp rs("poblacion") = poblacion rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs("correo") = correo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close "" If codigo_empresa = codigo_delegacion Then strcmd = "SELECT * FROM Empresas WHERE codigo_empresa = " & codigo_empresa & rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("nombre") = nombre rs("direccion") = direccion rs("cp") = cp rs("poblacion") = poblacion
31 rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs("correo") = correo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close If Not transaccion_activa Then cn.committrans Set rs = Nothing Exit Sub UpdateError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As Variant, codigo_delegacion As Variant, transaccion_activa As Boolean) Dim strcmd As String On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans strcmd = "DELETE FROM RegistroIRPF WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM RegistroIVA WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM Cartera WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM RestriccionesUsuariosMenus WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM UsuariosDelegaciones WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd strcmd = "DELETE FROM Delegaciones WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" cn.execute strcmd If Not transaccion_activa Then cn.committrans Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Delegaciones" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere
32 If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
33 10. Diarios.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Diarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresDiarios iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_diario As String, descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Diarios WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_diario") = codigo_diario rs("descripcion") = descripcion rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_diario As String, descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Diarios WHERE codigo_empresa = " & codigo_empresa & " AND codigo_diario = " _ & codigo_diario & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("descripcion") = descripcion
34 rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_diario As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Diarios WHERE codigo_empresa = " & codigo_empresa & " AND codigo_diario = " _ & codigo_diario & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Diarios" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
35 11. Documentos.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Documentos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresDocumentos iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_documento As String, descripcion As String, _ partida As String, iva As String, cartera As String, numeracion As String, identificador As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Documentos WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_documento") = codigo_documento rs("descripcion") = descripcion rs("partida") = partida rs("iva") = iva rs("cartera") = cartera rs("numeracion") = numeracion rs("identificador") = identificador rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_documento As String, descripcion As String, _ partida As String, iva As String, cartera As String, numeracion As String, identificador As String, ultimo_usuario As String) Dim strcmd As String
36 Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Documentos WHERE codigo_empresa = " & codigo_empresa _ & " AND codigo_documento = " & codigo_documento & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("descripcion") = descripcion rs("partida") = partida rs("iva") = iva rs("cartera") = cartera rs("numeracion") = numeracion rs("identificador") = identificador rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_documento As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Documentos WHERE codigo_empresa = " & codigo_empresa _ & " AND codigo_documento = " & codigo_documento & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Documentos" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf
37 For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
38 12. Ejercicios.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Ejercicios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresEjercicios iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Dim mnumeracion As numeracion Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, fecha_inicial As String, _ fecha_final As String, inicio_bloqueo As String, final_bloqueo As String, regularizado As String, cerrado As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError If Not transaccion_activa Then cn.begintrans strcmd = "SELECT * FROM Ejercicios WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("ejercicio") = ejercicio rs("fecha_inicial") = sdate(fecha_inicial) rs("fecha_final") = sdate(fecha_final) rs("inicio_bloqueo") = sdate(inicio_bloqueo) rs("final_bloqueo") = sdate(final_bloqueo) rs("regularizado") = regularizado rs("cerrado") = cerrado rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set mnumeracion = New numeracion mnumeracion.duplicarnumeracionejercicio cn, codigo_empresa, ejercicio - 1, ejercicio, susuario Set mnumeracion = Nothing If Not transaccion_activa Then cn.committrans Set rs = Nothing Exit Sub
39 InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, fecha_inicial As String, _ fecha_final As String, inicio_bloqueo As String, final_bloqueo As String, regularizado As String, cerrado As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Ejercicios WHERE codigo_empresa = " & codigo_empresa _ & " AND ejercicio = " & ejercicio rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("fecha_inicial") = sdate(fecha_inicial) rs("fecha_final") = sdate(fecha_final) rs("inicio_bloqueo") = sdate(inicio_bloqueo) rs("final_bloqueo") = sdate(final_bloqueo) rs("regularizado") = regularizado rs("cerrado") = cerrado rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, ejercicio As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset Dim fini As String, ffin As String On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans strcmd = "DELETE FROM Numeraciones WHERE codigo_empresa = " & codigo_empresa & " AND ejercicio = " & ejercicio cn.execute strcmd strcmd = "SELECT * FROM Ejercicios WHERE codigo_empresa = " & codigo_empresa & " AND ejercicio = " & ejercicio rs.open strcmd, cn, adopenstatic, adlockoptimistic If Not rs.eof Then fini = rs("fecha_inicial") ffin = rs("fecha_final") rs.delete rs.close strcmd = "DELETE RegistroIVA.* FROM Apuntes INNER JOIN RegistroIVA ON RegistroIVA.codigo_empresa = Apuntes.codigo_empresa AND RegistroIVA.codigo_delegacion = Apuntes.codigo_delegacion " _ & "AND RegistroIVA.codigo_documento = Apuntes.codigo_documento AND RegistroIVA.numero_documento = Apuntes.numero_documento AND " _ & "RegistroIVA.numero_apunte = Apuntes.numero_apunte WHERE Apuntes.codigo_empresa = " & codigo_empresa & " AND Apuntes.codigo_delegacion = " & codigo_delegacion & " " _ & "AND Apuntes.fecha_apunte >=" & fini & " AND Apuntes.fecha_apunte <= " & ffin & "" cn.execute strcmd
40 strcmd = "DELETE Cartera.* FROM Apuntes INNER JOIN Cartera ON Cartera.codigo_empresa = Apuntes.codigo_empresa AND Cartera.codigo_delegacion = Apuntes.codigo_delegacion " _ & "AND Cartera.codigo_documento = Apuntes.codigo_documento AND Cartera.numero_documento = Apuntes.numero_documento AND " _ & "Cartera.numero_apunte = Apuntes.numero_apunte WHERE Apuntes.codigo_empresa = " & codigo_empresa & " AND Apuntes.codigo_delegacion = " & codigo_delegacion & " " _ & "AND Apuntes.fecha_apunte >=" & fini & " AND Apuntes.fecha_apunte <= " & ffin & "" cn.execute strcmd strcmd = "DELETE RegistroIrpf.* FROM Apuntes INNER JOIN RegistroIrpf ON RegistroIrpf.codigo_empresa = Apuntes.codigo_empresa AND RegistroIrpf.codigo_delegacion = Apuntes.codigo_delegacion " _ & "AND RegistroIrpf.codigo_documento = Apuntes.codigo_documento AND RegistroIrpf.numero_documento = Apuntes.numero_documento AND " _ & "RegistroIrpf.numero_apunte = Apuntes.numero_apunte WHERE Apuntes.codigo_empresa = " & codigo_empresa & " AND Apuntes.codigo_delegacion = " & codigo_delegacion & " " _ & "AND Apuntes.fecha_apunte >=" & fini & " AND Apuntes.fecha_apunte <= " & ffin & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & " " _ & "AND fecha_apunte >=" & fini & " AND fecha_apunte <= " & ffin & "" cn.execute strcmd If Not transaccion_activa Then cn.committrans Set rs = Nothing Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Ejercicios" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror
41 FormatError = saux Function
42 13. Empresas.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Empresas" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresEmpresas iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Dim mdelegaciones As Delegaciones Dim mejercicios As Ejercicios Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, nif As String, nombre As String, direccion As String, _ cp As String, poblacion As String, provincia As String, pais As String, telefono As String, _ fax As String, correo As String, digitos As Integer, ultimo_usuario As String, transaccion_activa As Boolean) Dim cnsys As ADODB.Connection Dim strcmd As String Dim rs As New ADODB.Recordset Dim rsaux As New ADODB.Recordset On Error GoTo InsertError Set cnsys = New ADODB.Connection cnsys.open "File name=sistema.udl" If Not transaccion_activa Then cn.begintrans Afegeixo lempresa nova strcmd = "SELECT * FROM Empresas WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("nif") = nif rs("nombre") = nombre rs("direccion") = direccion rs("cp") = cp rs("poblacion") = poblacion rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs("correo") = correo rs("digitos") = digitos rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario
43 rs.update rs.close Afegeixo la delegació associada a lempresa i assigno els usuaris a la nova delegació Set mdelegaciones = New Delegaciones mdelegaciones.insert cn, codigo_empresa, codigo_empresa, nombre, direccion, cp, poblacion, provincia, pais, telefono, fax, correo, ultimo_usuario, True Set mdelegaciones = Nothing Creo un exercici per defecte Set mejercicios = New Ejercicios mejercicios.insert cn, codigo_empresa, Year(Date), sdate("01/01/" & Trim(str(Year(Date)))), sdate("31/12/" & Trim(str(Year(Date)))), sdate("01/01/" & Trim(str(Year(Date)))), sdate("31/12/" & Trim(str(Year(Date)))), "N", "N", ultimo_usuario, True Set mejercicios = Nothing Copio els comptes del balanç de situacio i perdues i guanys strcmd = "SELECT * FROM syspergan" rs.open strcmd, cnsys, adopenstatic, adlockoptimistic If Not rs.eof Then strcmd = "SELECT * FROM Pergan WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_empresa") = codigo_empresa rsaux("dh") = rs("dh") rsaux("nivel_1") = rs("nivel_1") rsaux("nivel_2") = rs("nivel_2") rsaux("nivel_3") = rs("nivel_3") rsaux("nivel_4") = rs("nivel_4") rsaux("titulo") = rs("titulo") rsaux("cuentas") = rs("cuentas") rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close rs.close strcmd = "SELECT * FROM syssituacion" rs.open strcmd, cnsys, adopenstatic, adlockoptimistic If Not rs.eof Then strcmd = "SELECT * FROM Situacion WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_empresa") = codigo_empresa rsaux("ap") = rs("ap") rsaux("nivel_1") = rs("nivel_1") rsaux("nivel_2") = rs("nivel_2") rsaux("nivel_3") = rs("nivel_3") rsaux("titulo") = rs("titulo") rsaux("cuentas") = rs("cuentas") rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close
44 rs.close Creo el plan comptable strcmd = "SELECT * FROM sysplancontable" rs.open strcmd, cnsys, adopenstatic, adlockoptimistic If Not rs.eof Then strcmd = "SELECT * FROM Cuentas WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_empresa") = codigo_empresa rsaux("cuenta") = rs("cuenta") rsaux("descripcion") = rs("titulo") rsaux("pases") = "N" rsaux("nivel") = rs("nivel") rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close rs.close strcmd = "SELECT * FROM sysplancontable WHERE nivel = 3" rs.open strcmd, cnsys, adopenstatic, adlockoptimistic If Not rs.eof Then strcmd = "SELECT * FROM Cuentas WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_empresa") = codigo_empresa rsaux("cuenta") = rs("cuenta") & String(digitos - 3, "0") rsaux("descripcion") = rs("titulo") rsaux("pases") = "S" rsaux("nivel") = digitos rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close rs.close If Not transaccion_activa Then cn.committrans cnsys.close Set rs = Nothing Set rsaux = Nothing Exit Sub InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, nif As String, nombre As String, direccion As String, _ cp As String, poblacion As String, provincia As String, pais As String, telefono As String, _ fax As String, correo As String, digitos As Integer, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String
45 Dim rs As New ADODB.Recordset On Error GoTo UpdateError If Not transaccion_activa Then cn.begintrans strcmd = "SELECT * FROM Empresas WHERE codigo_empresa = " & codigo_empresa & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("nif") = nif rs("nombre") = nombre rs("direccion") = direccion rs("cp") = cp rs("poblacion") = poblacion rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs("correo") = correo rs("digitos") = digitos rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set mdelegaciones = New Delegaciones mdelegaciones.update cn, codigo_empresa, codigo_empresa, nombre, direccion, cp, poblacion, provincia, pais, telefono, fax, correo, ultimo_usuario, True Set mdelegaciones = Nothing If Not transaccion_activa Then cn.committrans Exit Sub UpdateError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, transaccion_activa As Boolean) Dim strcmd As String On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans strcmd = "DELETE FROM Cartera WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM RegistroIva WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM RegistroIrpf WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM RestriccionesUsuariosMenus WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM UsuariosDelegaciones WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Delegaciones WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Numeraciones WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Ejercicios WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Documentos WHERE codigo_empresa = " & codigo_empresa & ""
46 cn.execute strcmd strcmd = "DELETE FROM Cuentas WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Acrdeu WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Personal WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Situacion WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Pergan WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Irpf WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM FormasPagos WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Impuestos WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Diarios WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd strcmd = "DELETE FROM Empresas WHERE codigo_empresa = " & codigo_empresa & "" cn.execute strcmd If Not transaccion_activa Then cn.committrans Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Empresas" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors
47 saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
48 14. FormasPago.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "FormasPago" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresFormasPago iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_pago As String, _ descripcion As String, vto1 As String, pct1 As Double, vto2 As String, pct2 As Double, _ vto3 As String, pct3 As Double, vto4 As String, pct4 As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM FormasPagos WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_pago") = codigo_pago rs("descripcion") = descripcion rs("vto1") = vto1 rs("pct1") = pct1 rs("vto2") = vto2 rs("pct2") = pct2 rs("vto3") = vto3 rs("pct3") = pct3 rs("vto4") = vto4 rs("pct4") = pct4 rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_pago As String, _
49 descripcion As String, vto1 As String, pct1 As Double, vto2 As String, pct2 As Double, _ vto3 As String, pct3 As Double, vto4 As String, pct4 As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM FormasPagos WHERE codigo_empresa = " & codigo_empresa & " AND codigo_pago = " & codigo_pago & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("descripcion") = descripcion rs("vto1") = vto1 rs("pct1") = pct1 rs("vto2") = vto2 rs("pct2") = pct2 rs("vto3") = vto3 rs("pct3") = pct3 rs("vto4") = vto4 rs("pct4") = pct4 rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_pago As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM FormasPagos WHERE codigo_empresa = " & codigo_empresa & " AND codigo_pago = " & codigo_pago & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM FormasPagos" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function
50 Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
51 15. Impuestos.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Impuestos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresImpuestos iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, impuesto As String, cta_iva As String, _ pct_iva As Double, cta_re As String, pct_re As Double, descripcion As String, tipo As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Impuestos WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("impuesto") = impuesto rs("cta_iva") = cta_iva rs("pct_iva") = pct_iva rs("pct_re") = pct_re rs("descripcion") = descripcion rs("tipo") = tipo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, impuesto As String, cta_iva As String, _ pct_iva As Double, cta_re As String, pct_re As Double, descripcion As String, tipo As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset
52 On Error GoTo UpdateError strcmd = "SELECT * FROM Impuestos WHERE codigo_empresa = " & codigo_empresa _ & " AND impuesto = " & impuesto & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("cta_iva") = cta_iva rs("pct_iva") = pct_iva rs("cta_re") = cta_re rs("pct_re") = pct_re rs("descripcion") = descripcion rs("tipo") = tipo rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, impuesto As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Impuestos WHERE codigo_empresa = " & codigo_empresa & _ " AND impuesto = " & impuesto & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Impuestos" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors
53 saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
54 16. ImpuestosAcrdeu.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "ImpuestosAcrdeu" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Private Function sdate(fecha As Variant) As String If IsDate(fecha) Then sdate = Format(fecha, "yyyymmdd") sdate = "" Function
55 17. Informes.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Informes" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresInformes ilisterror = (vbobjecterror + 4) iconnecterror = (vbobjecterror ) iexecuteerror = (vbobjecterror ) Enum Enum PRINTMODES PRINTERMODE SCREENMODE QUESTIONMODE Enum Private mvarstringconnection As String Private mvarprintmode As PRINTMODES Private mvarerrorhandlermode As Byte Private mvarmaxparam As Integer Private mvarmaxformulas As Integer Private mvarconnected As Boolean Private mvarobj As CrystalReport Public Sub Clear(Optional maxformulas As Variant, Optional maxparam As Variant) Dim inti As Integer Dim intmaxf As Integer Dim intmaxp As Integer If IsMissing(maxFormulas) Then intmaxf = mvarmaxformulas intmaxf = maxformulas If IsMissing(maxParam) Then intmaxp = mvarmaxparam intmaxp = maxparam If intmaxp > mvarmaxparam Then mvarmaxparam = maxparam If intmaxf > mvarmaxformulas Then mvarmaxformulas = maxformulas With mvarobj.reportfilename = Empty.WindowTitle = Empty.GroupSelectionFormula = Empty.SelectionFormula = Empty.SQLQuery = Empty For inti = 0 To intmaxf - 1.Formulas(intI) = Empty
56 Next For inti = 0 To intmaxp - 1.StoredProcParam(intI) = Empty Next With Sub Private Sub rptconnect() On Error GoTo ConnectError mvarobj.connect = mvarstringconnection mvarobj.logoninfo(0) = "DSN=" & App.Path & "\..\Dades\Temporales.mdb;UID=Admin" mvarconnected = True Exit Sub ConnectError: Dim strerror As String strerror = Err.Description mvarconnected = False Err.Raise iconnecterror,, FormatError("Error en rptconnect. " & strerror & ".") Sub Public Sub Execute() On Error GoTo ExecuteError If Not mvarconnected Then Call rptconnect Select Case mvarprintmode Case PRINTERMODE mvarobj.destination = crpttoprinter Case SCREENMODE mvarobj.destination = crpttowindow Case QUESTIONMODE If MsgBox(" Desea imprimir directamente el informe?", vbyesno) = vbyes Then mvarobj.destination = crpttoprinter mvarobj.destination = crpttowindow Select mvarobj.action = 1 Call Clear Exit Sub ExecuteError: Dim strerror As String strerror = Err.Description Call Clear Err.Raise iexecuteerror,, FormatError("Error en Execute. " & strerror & ".") Sub Public Sub rptformulas(paramarray paramformulas()) Dim inti As Integer If UBound(paramFormulas) + 1 > mvarmaxformulas Then mvarmaxformulas = UBound(paramFormulas) + 1 With mvarobj For inti = LBound(paramFormulas) To UBound(paramFormulas).Formulas(intI) = paramformulas(inti) Next inti With Sub Public Sub UspParam(ParamArray paramproc()) Dim inti As Integer If UBound(paramProc) + 1 > mvarmaxparam Then mvarmaxparam = UBound(paramProc)
57 With mvarobj For inti = LBound(paramProc) To UBound(paramProc).StoredProcParam(intI) = paramproc(inti) Next inti With Sub Public Sub Configure(strName As String, strdescription As String, printmode As PRINTMODES) Call Clear mvarprintmode = printmode With mvarobj.datafiles(0) = App.Path & "\..\Dades\Temporales.mdb".ReportFileName = App.Path & "\Reports\" & strname.windowtitle = strdescription With Sub Public Sub Init(strConnect As String, errormode As Byte, crtobj As CrystalReport) mvarstringconnection = strconnect mvarerrorhandlermode = errormode Set mvarobj = crtobj mvarconnected = False Sub Public Property Set obj(byval vdata As CrystalReport) Set mvarobj = vdata Property Public Property Get obj() As CrystalReport Set obj = mvarobj Property Public Property Let ErrorHandlerMode(ByVal vdata As Byte) mvarerrorhandlermode = vdata Property Public Property Get ErrorHandlerMode() As Byte ErrorHandlerMode = mvarerrorhandlermode Property Public Property Let printmode(byval vdata As PRINTMODES) mvarprintmode = vdata Property Public Property Get printmode() As PRINTMODES printmode = mvarprintmode Property Public Property Let STRCON(ByVal vdata As String) mvarstringconnection = vdata Property Public Property Get STRCON() As String STRCON = mvarstringconnection Property Private Sub Class_Terminate() Clear Set mvarobj = Nothing Sub Private Function FormatError(strError As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf FormatError = saux Function
58 - 57 -
59 18. Irpf.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Irpf" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresIrpf iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo As String, cuenta As String, pct_irpf As Double, _ descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Irpf WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo") = codigo rs("cuenta") = cuenta rs("pct_irpf") = pct_irpf rs("descripcion") = descripcion rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo As String, cuenta As String, pct_irpf As Double, _ descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError
60 strcmd = "SELECT * FROM Irpf WHERE codigo_empresa = " _ & codigo_empresa & " AND codigo = " & codigo & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("cuenta") = cuenta rs("pct_irpf") = pct_irpf rs("descripcion") = descripcion rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Irpf WHERE codigo_empresa = " & codigo_empresa & " AND codigo = " & codigo & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Irpf" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
61 19. Menus.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Menus" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresMenus ilisterror = (vbobjecterror + 4) Enum Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Menus" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
62 20. MenusUsuarios.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "MenusUsuarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresMenusGrupos iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_usuario As String, codigo_empresa As String, codigo_delegacion As String, _ item_menu As String, restricciones As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM RestriccionesUsuariosMenus WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_usuario") = codigo_usuario rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("item_menu") = item_menu rs("restricciones") = restricciones rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_usuario As String, codigo_empresa As String, codigo_delegacion As String, _ item_menu As String, restricciones As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM RestriccionesUsuariosMenus WHERE codigo_usuario = " & codigo_usuario & " " _
63 & "AND codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND item_menu = " & item_menu & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("restricciones") = restricciones rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_usuario As String, codigo_empresa As String, codigo_delegacion As String, _ item_menu As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM RestriccionesUsuariosMenus WHERE codigo_usuario = " & codigo_usuario & " " _ & "AND codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " _ & codigo_delegacion & " AND item_menu = " & item_menu & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM RestriccionesUsuariosMenus" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror
64 FormatError = saux Function
65 21. Numeracion.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Numeracion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresNumeracion iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, _ numeracion As String, longitud As Integer, numero As Long, descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Numeraciones WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("ejercicio") = ejercicio rs("numeracion") = numeracion rs("longitud") = longitud rs("numero") = numero rs("descripcion") = descripcion rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, _ numeracion As String, longitud As Integer, numero As Long, descripcion As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError
66 strcmd = "SELECT * FROM Numeraciones WHERE codigo_empresa = " & codigo_empresa _ & " AND ejercicio = " & ejercicio & " AND numeracion = " & numeracion & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("longitud") = longitud rs("numero") = numero rs("descripcion") = descripcion rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, _ numeracion As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Numeraciones WHERE codigo_empresa = " & codigo_empresa _ & " AND ejercicio = " & ejercicio & " AND numeracion = " & numeracion & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Numeraciones" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Public Function DuplicarNumeracionEjercicio(cn As ADODB.Connection, codigo_empresa As String, ejercicio_actual As Integer, nuevo_ejercicio As Integer, ultimo_usuario As String) Dim rso As ADODB.Recordset Dim rsd As ADODB.Recordset Set rso = GetList(cn, "codigo_empresa = " & codigo_empresa & " AND ejercicio = " & ejercicio_actual, "codigo_empresa, ejercicio, numeracion") Set rsd = GetList(cn, "codigo_empresa = " & codigo_empresa & " AND ejercicio = " & nuevo_ejercicio, "codigo_empresa, ejercicio, numeracion") If rsd.eof Then
67 While Not rso.eof rsd.addnew rsd("codigo_empresa") = rso("codigo_empresa") rsd("ejercicio") = nuevo_ejercicio rsd("numeracion") = rso("numeracion") rsd("longitud") = rso("longitud") rsd("numero") = 1 rsd("descripcion") = rso("descripcion") rsd("ultima_modificacion") = sdate(date) rsd("ultimo_usuario") = susuario rsd.update rso.movenext Wend While Not rso.eof rsd.filter = "numeracion = " & rso("numeracion") & "" If rsd.eof Then rsd.addnew rsd("codigo_empresa") = rso("codigo_empresa") rsd("ejercicio") = nuevo_ejercicio rsd("numeracion") = rso("numeracion") rsd("longitud") = rso("longitud") rsd("numero") = 1 rsd("descripcion") = rso("descripcion") rsd("ultima_modificacion") = sdate(date) rsd("ultimo_usuario") = susuario rsd.update rsd.filter = "" rso.movenext Wend Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
68 22. Pergan.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Pergan" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresPergan iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, dh As String, nivel_1 As Integer, _ nivel_2 As Integer, nivel_3 As Integer, nivel_4 As Integer, titulo As String, cuentas As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Pergan WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("dh") = dh rs("nivel_1") = nivel_1 rs("nivel_2") = nivel_2 rs("nivel_3") = nivel_3 rs("nivel_4") = nivel_4 rs("titulo") = titulo rs("cuentas") = cuentas rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, dh As String, nivel_1 As Integer, _ nivel_2 As Integer, nivel_3 As Integer, nivel_4 As Integer, titulo As String, cuentas As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset
69 On Error GoTo UpdateError strcmd = "SELECT * FROM Pergan WHERE codigo_empresa = " _ & codigo_empresa & " AND dh = " & dh & " AND nivel_1 = " & nivel_1 _ & " AND nivel_2 = " & nivel_2 & " AND nivel_3 = " & nivel_3 & " AND nivel_4 = " & nivel_4 rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("titulo") = titulo rs("cuentas") = cuentas rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, dh As String, _ nivel_1 As Integer, nivel_2 As Integer, nivel_3 As Integer, nivel_4 As Integer) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Pergan WHERE codigo_empresa = " _ & codigo_empresa & " AND dh = " & dh & " AND nivel_1 = " & nivel_1 _ & " AND nivel_2 = " & nivel_2 & " AND nivel_3 = " & nivel_3 & " AND nivel_3 = " & nivel_3 cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Pergan" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf
70 For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
71 23. Personal.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Personal" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresPersonal iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo As String, _ nombre As String, nif As String, direccion As String, poblacion As String, cp As String, provincia As String, _ pais As String, telefono As String, fax As String, As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Personal WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo") = codigo rs("nombre") = nombre rs("nif") = nif rs("direccion") = direccion rs("poblacion") = poblacion rs("cp") = cp rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs(" ") = rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo As String, _
72 nombre As String, nif As String, direccion As String, poblacion As String, cp As String, provincia As String, _ pais As String, telefono As String, fax As String, As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Personal WHERE codigo_empresa = " & codigo_empresa & " AND codigo = " & codigo & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("nombre") = nombre rs("nif") = nif rs("direccion") = direccion rs("poblacion") = poblacion rs("cp") = cp rs("provincia") = provincia rs("pais") = pais rs("telefono") = telefono rs("fax") = fax rs(" ") = rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo As String) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Personal WHERE codigo_empresa = " & codigo_empresa & " AND codigo = " & codigo & "" cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Personal" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function
73 Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
74 24. RegistroIrpf.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "RegistroIrpf" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresRegistroIrpf iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, tipo_acrdeu As String, _ codigo_personal As String, codigo_irpf As String, base As Double, pctirpf As Double, _ irpf As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM RegistroIrpf WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("codigo_documento") = codigo_documento rs("numero_documento") = numero_documento rs("numero_apunte") = numero_apunte rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("codigo_irpf") = codigo_irpf rs("base") = base rs("pctirpf") = pctirpf rs("irpf") = irpf rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub
75 Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer, tipo_acrdeu As String, _ codigo_personal As String, codigo_irpf As String, base As Double, pctirpf As Double, _ irpf As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM RegistroIrpf WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion _ & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " & numero_documento _ & " AND numero_apunte = " & numero_apunte rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("codigo_irpf") = codigo_irpf rs("base") = base rs("pctirpf") = pctirpf rs("irpf") = irpf rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM RegistroIrpf WHERE codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion _ & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " & numero_documento _ & " AND numero_apunte = " & numero_apunte cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM RegistroIrpf" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic
76 Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
77 25. RegistroIva.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "RegistroIva" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresRegistroIva iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, tipo As String, tipo_acrdeu As String, codigo_personal As String, _ impuesto As String, base As Double, pctiva As Double, iva As Double, pctre As Double, _ re As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM RegistroIva WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("codigo_delegacion") = codigo_delegacion rs("codigo_documento") = codigo_documento rs("numero_documento") = numero_documento rs("numero_apunte") = numero_apunte rs("tipo") = tipo rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("impuesto") = impuesto rs("base") = base rs("pctiva") = pctiva rs("iva") = iva rs("pctre") = pctre rs("re") = re rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.")
78 Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_documento As String, _ numero_documento As String, numero_apunte As Integer, tipo As String, tipo_acrdeu As String, codigo_personal As String, _ impuesto As String, base As Double, pctiva As Double, iva As Double, pctre As Double, _ re As Double, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM RegistroIva WHERE codigo_empresa = " & codigo_empresa _ & " AND codigo_delegacion = " & codigo_delegacion & " AND codigo_documento = " & codigo_documento _ & " AND numero_documento = " & numero_documento & " AND numero_apunte = " & numero_apunte rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("tipo") = tipo rs("tipo_acrdeu") = tipo_acrdeu rs("codigo_personal") = codigo_personal rs("impuesto") = impuesto rs("base") = base rs("pctiva") = pctiva rs("iva") = iva rs("pctre") = pctre rs("re") = re rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, _ codigo_documento As String, numero_documento As String, numero_apunte As Integer) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM RegistroIva WHERE codigo_empresa = " & codigo_empresa _ & " AND codigo_delegacion = " & codigo_delegacion & " AND codigo_documento = " & codigo_documento _ & " AND numero_documento = " & numero_documento & " AND numero_apunte = " & numero_apunte cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM RegistroIva" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder
79 Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
80 26. Regularizacion.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Regularizacion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Public Enum ErroresRegularizacion iinserterror = (vbobjecterror + 1) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Dim mapuntes As Apuntes Dim mejercicios As Ejercicios Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, cuenta As String, _ codigo_documento As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim debe As Double Dim haber As Double Dim apunte As Integer Dim rs As ADODB.Recordset Dim rsaux As ADODB.Recordset On Error GoTo InsertError apunte = 1 debe = 0: haber = 0 Set mejercicios = New Ejercicios Set rsaux = mejercicios.getlist(cn, "codigo_empresa = " & codigo_empresa & " and ejercicio = " & ejercicio) strcmd = "SELECT cuenta, SUM(debe-haber) AS saldo FROM Apuntes WHERE codigo_empresa = " & codigo_empresa _ & " AND fecha_apunte BETWEEN " & rsaux("fecha_inicial") & " AND " & rsaux("fecha_final") & " " _ & "AND cuenta >= 6 AND cuenta < 8 GROUP BY cuenta HAVING SUM(debe-haber) <> 0 ORDER BY cuenta" Set rs = New ADODB.Recordset rs.open strcmd, cn, adopenstatic, adlockoptimistic If Not rs.eof Then Set mapuntes = New Apuntes Set mauxiliar = New Auxiliar If Not transaccion_activa Then cn.begintrans While Not rs.eof If rs("saldo") > 0 Then mapuntes.insert cn, sempresa, sempresa, codigo_documento, String(9, "9") & 8, Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", rs("cuenta"), "ASIENTO DE REGULARIZACIÓN", 0, str(rs("saldo")), "A", "", ultimo_usuario haber = haber + rs("saldo") mapuntes.insert cn, sempresa, sempresa, codigo_documento, String(9, "9") & 8, Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", rs("cuenta"), "ASIENTO DE REGULARIZACIÓN", str(-rs("saldo")), 0, "A", "", ultimo_usuario debe = debe + Abs(rs("saldo"))
81 apunte = apunte + 1 rs.movenext Wend If debe > haber Then mapuntes.insert cn, sempresa, sempresa, codigo_documento, String(9, "9") & 8, Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", cuenta, "ASIENTO DE REGULARIZACIÓN", 0, str(debe - haber), "A", "", ultimo_usuario If haber > debe Then mapuntes.insert cn, sempresa, sempresa, codigo_documento, String(9, "9") & 8, Format(apunte, "00000"), "99999", mauxiliar.ddate(rsaux("fecha_final")), "", "", cuenta, "ASIENTO DE REGULARIZACIÓN", str(haber - debe), 0, "A", "", ultimo_usuario mejercicios.update cn, sempresa, ejercicio, mauxiliar.ddate(rsaux("fecha_inicial")), mauxiliar.ddate(rsaux("fecha_final")), mauxiliar.ddate(rsaux("inicio_bloqueo")), mauxiliar.ddate(rsaux("final_bloqueo")), "S", rsaux("cerrado"), ultimo_usuario If Not transaccion_activa Then cn.committrans Set mauxiliar = Nothing Set mapuntes = Nothing Set mejercicios = Nothing rs.close Set rs = Nothing Exit Sub InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, ejercicio As Integer, codigo_documento As String, _ ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans _ strcmd = "DELETE FROM Apuntes WHERE codigo_empresa = " & codigo_empresa _ & " AND codigo_delegacion = " & codigo_empresa & " AND codigo_documento = " & codigo_documento & " AND numero_documento = " & String(9, "9") & 8 & "" cn.execute strcmd Set mauxiliar = New Auxiliar Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & codigo_empresa & " and ejercicio = " & ejercicio) mejercicios.update cn, sempresa, iejercicio, mauxiliar.ddate(rs("fecha_inicial")), mauxiliar.ddate(rs("fecha_final")), mauxiliar.ddate(rs("inicio_bloqueo")), mauxiliar.ddate(rs("final_bloqueo")), "N", rs("cerrado"), ultimo_usuario Set mejercicios = Nothing Set mauxiliar = Nothing If Not transaccion_activa Then cn.committrans Set rs = Nothing Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub
82 Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim rs As ADODB.Recordset Set mapuntes = New Apuntes Set rs = mapuntes.getlist(cn, strwhere, strorder) Set mapuntes = Nothing Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
83 27. Situacion.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Situacion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresSituacion iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, ap As String, nivel_1 As Integer, _ nivel_2 As Integer, nivel_3 As Integer, titulo As String, cuentas As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo InsertError strcmd = "SELECT * FROM Situacion WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_empresa") = codigo_empresa rs("ap") = ap rs("nivel_1") = nivel_1 rs("nivel_2") = nivel_2 rs("nivel_3") = nivel_3 rs("titulo") = titulo rs("cuentas") = cuentas rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub InsertError: Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_empresa As String, ap As String, nivel_1 As Integer, _ nivel_2 As Integer, nivel_3 As Integer, titulo As String, cuentas As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset
84 On Error GoTo UpdateError strcmd = "SELECT * FROM Situacion WHERE codigo_empresa = " _ & codigo_empresa & " AND ap = " & ap & " AND nivel_1 = " & nivel_1 _ & " AND nivel_2 = " & nivel_2 & " AND nivel_3 = " & nivel_3 rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("titulo") = titulo rs("cuentas") = cuentas rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_empresa As String, ap As String, _ nivel_1 As Integer, nivel_2 As Integer, nivel_3 As Integer) Dim strcmd As String On Error GoTo DeleteError strcmd = "DELETE FROM Situacion WHERE codigo_empresa = " _ & codigo_empresa & " AND ap = " & ap & " AND nivel_1 = " & nivel_1 _ & " AND nivel_2 = " & nivel_2 & " AND nivel_3 = " & nivel_3 cn.execute strcmd Exit Sub DeleteError: Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Situacion" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf
85 Next eerror FormatError = saux Function
86 28. Usuarios.cls VERSION 1.0 CLASS BEGIN MultiUse = -1 True Persistable = 0 NotPersistable DataBindingBehavior = 0 vbnone DataSourceBehavior = 0 vbnone MTSTransactionMode = 0 NotAnMTSObject END Attribute VB_Name = "Usuarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = "SavedWithClassBuilder6","Yes" Attribute VB_Ext_KEY = "Top_Level","Yes" Option Explicit Public Enum ErroresUsuarios iinserterror = (vbobjecterror + 1) iupdateerror = (vbobjecterror + 2) ideleteerror = (vbobjecterror + 3) ilisterror = (vbobjecterror + 4) Enum Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Public Sub Insert(cn As ADODB.Connection, codigo_empresa As String, codigo_delegacion As String, codigo_usuario As String, _ contraseña As String, ultimo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String Dim rs As New ADODB.Recordset Dim rsaux As New ADODB.Recordset On Error GoTo InsertError If Not transaccion_activa Then cn.begintrans strcmd = "SELECT * FROM Usuarios WHERE 1 = 0" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs.addnew rs("codigo_usuario") = codigo_usuario rs("contraseña") = contraseña rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close strcmd = "SELECT codigo_empresa, codigo_delegacion, " & sdate(date) & ", " & ultimo_usuario & " " _ & "FROM Delegaciones GROUP BY " & codigo_usuario & ", " & "codigo_empresa, codigo_delegacion, 0, " & sdate(date) & ", " & ultimo_usuario & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic If Not rs.eof Then strcmd = "SELECT * FROM UsuariosDelegaciones WHERE 1 = 0" rsaux.open strcmd, cn, adopenstatic, adlockoptimistic rs.movefirst While Not rs.eof rsaux.addnew rsaux("codigo_usuario") = codigo_usuario rsaux("codigo_empresa") = rs("codigo_empresa") rsaux("codigo_delegacion") = rs("codigo_delegacion")
87 rsaux("activo") = 0 rsaux("ultima_modificacion") = sdate(date) rsaux("ultimo_usuario") = ultimo_usuario rsaux.update rs.movenext Wend rsaux.close rs.close If Not transaccion_activa Then cn.committrans Set rs = Nothing Set rsaux = Nothing Exit Sub InsertError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise iinserterror,, FormatError(cn, "Error en Insert.") Sub Public Sub Update(cn As ADODB.Connection, codigo_usuario As String, contraseña As String, ultimo_usuario As String) Dim strcmd As String Dim rs As New ADODB.Recordset On Error GoTo UpdateError strcmd = "SELECT * FROM Usuarios WHERE codigo_usuario = " & codigo_usuario & "" rs.open strcmd, cn, adopenstatic, adlockoptimistic rs("contraseña") = contraseña rs("ultima_modificacion") = sdate(date) rs("ultimo_usuario") = ultimo_usuario rs.update rs.close Set rs = Nothing Exit Sub UpdateError: Err.Raise iupdateerror,, FormatError(cn, "Error en Update.") Sub Public Sub Delete(cn As ADODB.Connection, codigo_usuario As String, transaccion_activa As Boolean) Dim strcmd As String On Error GoTo DeleteError If Not transaccion_activa Then cn.begintrans strcmd = "DELETE FROM RestriccionesUsuariosMenus WHERE codigo_usuario = " & codigo_usuario & "" cn.execute strcmd strcmd = "DELETE FROM UsuariosDelegaciones WHERE codigo_usuario = " & codigo_usuario & "" cn.execute strcmd strcmd = "DELETE FROM Usuarios WHERE codigo_usuario = " & codigo_usuario & "" cn.execute strcmd If Not transaccion_activa Then cn.committrans Exit Sub DeleteError: If Not transaccion_activa Then cn.rollbacktrans Err.Raise ideleteerror,, FormatError(cn, "Error en Delete.") Sub
88 Public Function GetList(cn As ADODB.Connection, Optional strwhere As String, Optional strorder As String) As Object Dim strcmd As String Dim rs As ADODB.Recordset strcmd = "SELECT * FROM Usuarios" If Len(strWhere) > 0 Then strcmd = strcmd & " WHERE " & strwhere If Len(strOrder) > 0 Then strcmd = strcmd & " ORDER BY " & strorder Set rs = New ADODB.Recordset On Error GoTo GetListError rs.open strcmd, cn, adopenstatic, adlockoptimistic Set GetList = rs Exit Function GetListError: Err.Raise ilisterror,, FormatError(cn, "Error en GetList.") Function Private Function FormatError(cn As ADODB.Connection, strerror As String) As String Dim eerror As ADODB.Error Dim saux As String If Len(strError) > 0 Then saux = strerror & vbcrlf For Each eerror In cn.errors saux = saux & eerror.source & " (Referencia " & eerror.number & "): " & eerror.description & vbcrlf Next eerror FormatError = saux Function
89 29. Temporales.bas Attribute VB_Name = "Temporales" Option Explicit Public Sub Limpiar_Temporal(nombre_tabla As String) Dim strsql As String strsql = "DELETE FROM " & nombre_tabla cnt.execute strsql Sub
90 30. frmabout.frm VERSION 5.00 Begin VB.Form frmabout BorderStyle = 3 Fixed Dialog Caption = "Acerca de Contabilidad" ClientHeight = 3630 ClientLeft = 45 ClientTop = 330 ClientWidth = 5865 ClipControls = 0 False LinkTopic = "frmabout" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 242 ScaleMode = 3 Pixel ScaleWidth = 391 ShowInTaskbar = 0 False Tag = "Acerca de Contabilidad" Begin VB.PictureBox picicon AutoSize = -1 True BackColor = &H00C0C0C0& ClipControls = 0 False Height = 540 Left = 240 Picture = "frmabout.frx":0000 ScaleHeight = 480 ScaleMode = 0 User ScaleWidth = 480 TabIndex = 2 TabStop = 0 False Top = 240 Width = 540 Begin VB.CommandButton cmdok Cancel = -1 True Caption = "Aceptar" Default = -1 True Height = 345 Left = 4245 TabIndex = 0 Tag = "Aceptar" Top = 2625 Width = 1467 Begin VB.CommandButton cmdsysinfo Caption = "Info. del &sistema..." Height = 345 Left = 4260 TabIndex = 1 Tag = "Info. del &sistema..." Top = 3075 Width = 1452 Begin VB.Label lbldescription Caption = "Contabilidad práctica para la pequeña y mediana empresa" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 1170 Left = 1050 TabIndex = 6 Tag = "Descripción de la aplicación" Top = 1125 Width =
91 Begin VB.Label lbltitle Caption = "Conta-Pyme" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 480 Left = 1050 TabIndex = 5 Tag = "Título de la aplicación" Top = 240 Width = 4092 Begin VB.Line Line1 BorderColor = &H & BorderStyle = 6 Inside Solid Index = 1 X1 = 15 X2 = Y1 = 162 Y2 = 162 Begin VB.Line Line1 BorderColor = &H00FFFFFF& BorderWidth = 2 Index = 0 X1 = 16 X2 = Y1 = 163 Y2 = 163 Begin VB.Label lblversion Caption = "Versión" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 225 Left = 1050 TabIndex = 4 Tag = "Versión" Top = 780 Width = 4092 Begin VB.Label lbldisclaimer Caption = "Advertencia:..." ForeColor = &H & Height = 825 Left = 255 TabIndex = 3 Tag = "Advertencia:..." Top = 2625 Width = 3870 Attribute VB_Name = "frmabout" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Opciones de seguridad de clave del Registro... Const KEY_ALL_ACCESS = &H2003F
92 Tipos ROOT de claves del Registro... Const HKEY_LOCAL_MACHINE = &H Const ERROR_SUCCESS = 0 Const REG_SZ = 1 Const REG_DWORD = 4 cadena terminada en valor nulo Unicode número de 32 bits Const gregkeysysinfoloc = "SOFTWARE\Microsoft\Shared Tools Location" Const gregvalsysinfoloc = "MSINFO" Const gregkeysysinfo = "SOFTWARE\Microsoft\Shared Tools\MSINFO" Const gregvalsysinfo = "PATH" Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpsubkey As String, ByVal uloptions As Long, ByVal samdesired As Long, ByRef phkresult As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpvaluename As String, ByVal lpreserved As Long, ByRef lptype As Long, ByVal lpdata As String, ByRef lpcbdata As Long) As Long Private Declare Function RegCloseKey Lib "advapi32" (ByVal hkey As Long) As Long Private Sub Form_Load() lblversion.caption = "Versión " & App.Major & "." & App.Minor & "." & App.Revision lbltitle.caption = App.Title Sub Private Sub cmdsysinfo_click() Call StartSysInfo Sub Private Sub cmdok_click() Unload Me Sub Public Sub StartSysInfo() On Error GoTo SysInfoErr Dim rc As Long Dim SysInfoPath As String Intentar obtener el nombre y la ruta del programa en el Registro... If GetKeyValue(HKEY_LOCAL_MACHINE, gregkeysysinfo, gregvalsysinfo, SysInfoPath) Then Intentar obtener sólo la ruta del programa en el Registro... If GetKeyValue(HKEY_LOCAL_MACHINE, gregkeysysinfoloc, gregvalsysinfoloc, SysInfoPath) Then Validar la existencia de versión conocida de 32 bits de archivo If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then SysInfoPath = SysInfoPath & "\MSINFO32.EXE" Error: no se encuentra el archivo... GoTo SysInfoErr Error: no se encuentra la entrada del Registro... GoTo SysInfoErr Call Shell(SysInfoPath, vbnormalfocus) Exit Sub SysInfoErr: MsgBox "La información del sistema no está disponible en este momento", vbokonly Sub
93 Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean Dim i As Long Contador de bucle Dim rc As Long Código de retorno Dim hkey As Long Controlador a una clave de Registro abierta Dim hdepth As Long Dim KeyValType As Long Tipo de datos de una clave del Registro Dim tmpval As String Almacenamiento temporal para un valor de clave del Registro Dim KeyValSize As Long Tamaño de variable de clave del Registro Abrir RegKey bajo KeyRoot {HKEY_LOCAL_MACHINE...} rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hkey) Abrir la clave del Registro If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError Controlar error... tmpval = String$(1024, 0) variable KeyValSize = 1024 variable Asignar espacio de Marcar tamaño de Obtener valor de clave del Registro rc = RegQueryValueEx(hKey, SubKeyRef, 0, KeyValType, tmpval, KeyValSize) Get/Create Key Value If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError Controlar errores tmpval = VBA.Left(tmpVal, InStr(tmpVal, VBA.Chr(0)) - 1) Determinar el tipo de valor de clave para conversión Select Case KeyValType Buscar tipos de datos... Case REG_SZ Tipo de datos String de clave del Registro KeyVal = tmpval Copiar valor String Case REG_DWORD Tipo de datos Double Word de clave del Registro For i = Len(tmpVal) To 1 Step -1 Convertir cada bit carácter a carácter Next Word a String Select KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) KeyVal = Format$("&h" + KeyVal) Generar valor Convertir Double GetKeyValue = True correctamente rc = RegCloseKey(hKey) Registro Exit Function Operación realizada Cerrar clave del Salir GetKeyError: Limpiar después de que se produzca un error... KeyVal = "" Establecer el valor de retonor a la cadena vacía GetKeyValue = False La operación no se ha realizado correctamente rc = RegCloseKey(hKey) Cerrar clave del Registro Function
94 31. frmacrdeu.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmacrdeu Caption = "Acreedores - Deudores" ClientHeight = 6360 ClientLeft = 60 ClientTop = 345 ClientWidth = 9585 LinkTopic = "frmacrdeu" MDIChild = -1 True ScaleHeight = 424 ScaleMode = 3 Pixel ScaleWidth = 639 Tag = "ToolbarAcrdeu" Begin MSComctlLib.ListView ListViewAcrdeu Height = 2865 Left = 0 TabIndex = 15 TabStop = 0 False Top = 450 Width = 9540 _ExtentX = _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 10 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Cuenta" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Codigo" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Tipo" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Nacionalidad" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Impuesto" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Forma de pago" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Dia de pago" Object.Width = Property BeginProperty ColumnHeader(8) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 7 Text = "Descuento" Object.Width =
95 Property BeginProperty ColumnHeader(9) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 8 Text = "IRPF" Object.Width = Property BeginProperty ColumnHeader(10) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 9 Text = "Contrapartida" Object.Width = Property Begin VB.Frame frmdatos Height = 2940 Left = 0 TabIndex = 14 Top = 3360 Width = 9540 Begin VB.TextBox txt Index = 7 Left = 5040 TabIndex = 28 Tag = "CUENTAS.cuenta" Top = 2400 Width = 1440 Begin VB.TextBox txt Index = 6 Left = 5040 TabIndex = 26 Tag = "IRPF.codigo" Top = 2040 Width = 1440 Begin VB.TextBox txt Index = 5 Left = 7920 TabIndex = 12 Top = 1680 Width = 1440 Begin VB.TextBox txt Index = 4 Left = 7920 TabIndex = 11 Top = 1320 Width = 1440 Begin VB.TextBox txt Index = 3 Left = 5040 TabIndex = 10 Tag = "FORMASPAGOS.codigo_pago" Top = 1680 Width = 1440 Begin VB.TextBox txt Index = 2 Left = 5040 TabIndex = 9 Tag = "IMPUESTOS.impuesto" Top = 1320 Width = 1440 Begin VB.Frame franacionalidad Caption = "Nacionalidad" Height = 1455 Left = 1800 TabIndex = 21 Top = 1200 Width =
96 Begin VB.OptionButton opt_nac Caption = "Extrangero" Height = 255 Index = 2 Left = 120 TabIndex = 8 Top = 840 Width = 1335 Begin VB.OptionButton opt_nac Caption = "Comunitario" Height = 255 Index = 1 Left = 120 TabIndex = 7 Top = 600 Width = 1335 Begin VB.OptionButton opt_nac Caption = "Nacional" Height = 255 Index = 0 Left = 120 TabIndex = 6 Top = 360 Value = -1 True Width = 1335 Begin VB.Frame fratipo Caption = "Tipo" Height = 1455 Left = 120 TabIndex = 20 Top = 1200 Width = 1575 Begin VB.OptionButton opt_tip Caption = "Acreedor" Height = 255 Index = 3 Left = 120 TabIndex = 5 Top = 1080 Width = 1335 Begin VB.OptionButton opt_tip Caption = "Deudor" Height = 255 Index = 2 Left = 120 TabIndex = 4 Top = 840 Width = 1335 Begin VB.OptionButton opt_tip Caption = "Proveedor" Height = 255 Index = 1 Left = 120 TabIndex = 3 Top = 600 Width = 1335 Begin VB.OptionButton opt_tip Caption = "Cliente" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 360 Value = -1 True Width = 1335 Begin VB.TextBox txt Index =
97 Left = 1065 TabIndex = 1 Tag = "PERSONAL.codigo" Top = 720 Width = 1440 Begin VB.TextBox txt Index = 0 Left = 1065 TabIndex = 0 Tag = "CUENTAS.cuenta" Top = 300 Width = 1440 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Index = 7 Left = 6600 TabIndex = 30 Top = 2400 Width = 2775 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Contrapartida:" ForeColor = &H & Index = 7 Left = 3600 TabIndex = 29 Top = 2400 Width = 1335 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "IRPF:" ForeColor = &H & Index = 6 Left = 3600 TabIndex = 27 Top = 2040 Width = 1335 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Descuento:" ForeColor = &H & Index = 5 Left = 6720 TabIndex = 25 Top = 1680 Width = 1215 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Dia de pago:" ForeColor = &H & Index = 4 Left = 6720 TabIndex = 24 Top = 1320 Width =
98 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Forma de pago:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Index = 3 Left = 3600 TabIndex = 23 Top = 1680 Width = 1335 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Impuesto:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Index = 2 Left = 3600 TabIndex = 22 Top = 1320 Width = 1335 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Index = 1 Left = 2640 TabIndex = 19 Top = 720 Width = 6735 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Index = 1 Left = 75 TabIndex = 18 Top = 720 Width =
99 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Index = 0 Left = 2640 TabIndex = 17 Top = 300 Width = 6735 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Cuenta:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Index = 0 Left = 75 TabIndex = 16 Top = 300 Width = 735 Begin MSComctlLib.ImageList ImageListAcrdeu Left = 120 Top = 6840 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarAcrdeu Align = 1 Align Top Height = 390 Left = 0 TabIndex = 13 Tag = "ToolbarAcrdeu" Top = 0 Width = 9585 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmacrdeu" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim macrdeu As acrdeu Private Sub AyudarAcrdeu() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = Format(0, "0")
100 txt(5) = Format(0, "0.00") txt(6) = "" txt(7) = "" opt_tip(0) = True opt_nac(0) = True des(0) = "" des(1) = "" des(7) = "" txt(0).setfocus Sub Private Sub chk_gotfocus(index As Integer) Me.ToolbarAcrdeu.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Sub EliminarAcrdeu() Dim rpta As Integer Dim aux As String On Error GoTo EliminarAcrdeuError If txt(0) <> "" And txt(1) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("acrdeu", "codigo", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(0) & " and codigo = " & txt(1) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar los datos " & txt(0) & "/" & txt(1) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set macrdeu = New acrdeu macrdeu.delete cn, sempresa, txt(0), txt(1) Set macrdeu = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewAcrdeu.ListItems.Remove ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index Call cancelardatos Exit Sub EliminarAcrdeuError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarAcrdeu() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cuenta = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo = " & txt(1) & "" If opt_tip(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = CLI" If opt_tip(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = PRO"
101 If opt_tip(2) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = DEU" If opt_tip(3) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = ACR" If opt_nac(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nacionalidad = NAC" If opt_nac(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nacionalidad = COM" If opt_nac(2) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nacionalidad = EXT" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "impuesto = " & txt(2) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "forma_pago = " & txt(3) & "" Call ListarAcrdeu(filtro) Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmacrdeu = Forms(i) Next Call limatges16(me.imagelistacrdeu) Set Me.ToolbarAcrdeu.ImageList = Me.ImageListAcrdeu Call cargarbotonera(me.toolbaracrdeu) Call deshabilitarbotones(me.toolbaracrdeu, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewAcrdeu For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width)
102 Next With txt(4) = Format(0, "0") txt(5) = Format(0, "0.00") Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewAcrdeu For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirAcrdeu() Sub Private Function indnac(nac As String) As Integer If nac = "NAC" Then indnac = 0 If nac = "COM" Then indnac = 1 indnac = 2 Function Private Function indtipo(tipo As String) As Integer If tipo = "CLI" Then indtipo = 0 If tipo = "PRO" Then indtipo = 1 If tipo = "DEU" Then indtipo = 2 indtipo = 3 Function Private Sub InsertarAcrdeu() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarAcrdeuError If txt(0) <> "" And txt(1) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("acrdeu", "codigo", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set macrdeu = New acrdeu macrdeu.insert cn, sempresa, txt(0), txt(1), strtipo, strnac, txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), susuario Set macrdeu = Nothing On Error Resume Next Set newitem = ListViewAcrdeu.ListItems.Add(, getkeygrid(txt(0), txt(1)), txt(0)) newitem.subitems(1) = txt(1)
103 newitem.subitems(2) = strtipo newitem.subitems(3) = strnac newitem.subitems(4) = txt(2) newitem.subitems(5) = txt(3) newitem.subitems(6) = Format(txt(4), "0") newitem.subitems(7) = Format(txt(5), "0.00") newitem.subitems(8) = txt(6) newitem.subitems(9) = txt(7) Call cancelardatos MsgBox msgerror(1017), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarAcrdeuError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarAcrdeu(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewAcrdeu.ListItems.Clear Set macrdeu = New acrdeu Set rs = macrdeu.getlist(cn, strwhere, "codigo_empresa, cuenta") Do Until rs.eof Set newitem = ListViewAcrdeu.ListItems.Add(, getkeygrid(rs("cuenta"), rs("codigo")), rs("cuenta")) newitem.subitems(1) = Nz(rs("codigo"), "") newitem.subitems(2) = Nz(rs("tipo"), "") newitem.subitems(3) = Nz(rs("nacionalidad"), "") newitem.subitems(4) = Nz(rs("impuesto"), "") newitem.subitems(5) = Nz(rs("forma_pago"), "") newitem.subitems(6) = Format(Nz(rs("primer_dia"), ""), "0") newitem.subitems(7) = Format(Nz(rs("descuento"), ""), "0.00") newitem.subitems(8) = Nz(rs("irpf"), "") newitem.subitems(9) = Nz(rs("contrapartida"), "") rs.movenext Loop Set rs = Nothing Set macrdeu = Nothing Sub Private Sub ListViewAcrdeu_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewAcrdeu.SelectedItem.Text Me.txt(1) = Me.ListViewAcrdeu.SelectedItem.SubItems(1) Call txt_lostfocus(0) Call validarglobal Sub Private Sub ModificarAcrdeu() Dim i As Integer Dim aux As String On Error GoTo ModificarAcrdeuError If txt(0) <> "" And txt(1) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("acrdeu", "codigo", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set macrdeu = New acrdeu macrdeu.update cn, sempresa, txt(0), txt(1), strtipo, strnac, txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), susuario
104 Set macrdeu = Nothing On Error Resume Next ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(1) = txt(1) ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(2) = strtipo ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(3) = strnac ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(4) = txt(2) ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(5) = txt(3) ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(6) = Format(txt(4), "0") ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(7) = Format(txt(5), "0.00") ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(8) = txt(6) ListViewAcrdeu.ListItems(ListViewAcrdeu.ListItems(getKeyGrid(txt(0), txt(1))).index).subitems(9) = txt(7) Call cancelardatos MsgBox msgerror(1018), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarAcrdeuError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub opt_nac_gotfocus(index As Integer) Me.ToolbarAcrdeu.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Sub opt_tip_gotfocus(index As Integer) Me.ToolbarAcrdeu.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Function strnac() As String If opt_nac(0) Then strnac = "NAC" If opt_nac(1) Then strnac = "COM" strnac = "EXT" Function Private Function strtipo() As String If opt_tip(0) Then strtipo = "CLI" If opt_tip(1) Then strtipo = "PRO" If opt_tip(2) Then strtipo = "DEU" strtipo = "ACR" Function Private Sub ToolbarAcrdeu_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarAcrdeu Case "modificar": If validardatos Then Call ModificarAcrdeu Case "filtrar": Call FiltrarAcrdeu Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarAcrdeu Case "listar": Call ListarAcrdeu Case "imprimir": Call ImprimirAcrdeu Case "ayudar": Call AyudarAcrdeu
105 Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarAcrdeu.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarAcrdeu.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Or Index = 1 Then If txt(0) <> "" And txt(1) <> "" Then Set macrdeu = New acrdeu Set rs = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & " and codigo = " & txt(1) & "") If Not rs.eof Then opt_tip(indtipo(nz(rs("tipo"), ""))) = True opt_nac(indnac(nz(rs("nacionalidad"), ""))) = True txt(2) = Nz(rs("impuesto"), "") txt(3) = Nz(rs("forma_pago"), "") txt(4) = Format(Nz(rs("primer_dia"), 0), "0") txt(5) = Format(Nz(rs("descuento"), 0), "0.00") txt(6) = Nz(rs("irpf"), "") txt(7) = Nz(rs("contrapartida"), "") Set rs = Nothing Set macrdeu = Nothing If Index = 4 Then txt(4) = Format(Nz(txt(4), 0), "0") If Index = 5 Then txt(5) = Format(Nz(txt(5), 0), "0.00") Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 0, 7: If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(index) & " and pases = S", "#") If aux = "#" Then msg = msgerror(1001) des(index) = aux des(index) = "" Case 1: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " and codigo = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1020) des(index) = aux
106 des(index) = "" Case 2: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("impuestos", "descripcion", "codigo_empresa = " & sempresa & " and impuesto = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1020) Case 3: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("formaspagos", "descripcion", "codigo_empresa = " & sempresa & " and codigo_pago = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1020) Case 6: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("irpf", "descripcion", "codigo_empresa = " & sempresa & " and codigo = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1020) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 7 Select Case i Case 0, 1, 2, 3: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Case 4, 5: If txt(i) <> "" Then If Not IsNumeric(txt(i)) Then msg = msgerror(1004) txt(i).setfocus Exit For txt(i) = 0 Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function Private Sub validarglobal() Dim i As Integer Dim Cancel As Boolean
107 i = 0: Cancel = False While i <= 7 And Not Cancel Call txt_validate(i, Cancel) i = i + 1 Wend Sub Private Function getkeygrid(cuenta As String, codigo As String) As String Dim mauxiliar As Auxiliar Set mauxiliar = New Auxiliar getkeygrid = "K" & Format(Trim(cuenta), String(12, "@")) & Format(Trim(codigo), String(12, "@")) Set mauxiliar = Nothing Function
108 32. frmapunte.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Begin VB.Form frmapunte Appearance = 0 Flat Caption = "Entrada de apuntes" ClientHeight = 4380 ClientLeft = 60 ClientTop = 345 ClientWidth = 9405 LinkTopic = "frmapunte" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 292 ScaleMode = 3 Pixel ScaleWidth = 627 Tag = "ToolbarApuntes" Begin VB.Frame frmasiento Height = 3315 Index = 0 Left = 120 TabIndex = 109 Top = 960 Width = 9090 Begin VB.TextBox txt Height = 315 Index = 5 Left = 1320 TabIndex = 5 Tag = "CUENTAS.cuenta" Top = 1560 Width = 1545 Begin VB.TextBox txt Height = 315 Index = 1 Left = 1320 TabIndex = 1 Tag = "DOCUMENTOS.codigo_documento" Top = 975 Width = 780 Begin VB.TextBox txt Height = 315 Index = 3 Left = 4920 TabIndex = 3 Top = 960 Width = 1065 Begin VB.TextBox txt Height = 315 Index = 4 Left = 7800 TabIndex = 4 Top = 960 Width = 1065 Begin VB.TextBox txt Height = 315 Index = 2 Left = 2175 TabIndex = 2 Top = 960 Width = 1155 Begin VB.TextBox txt Height = 315 Index =
109 Left = 1320 TabIndex = 0 Tag = "DIARIOS.codigo_diario" Top = 420 Width = 780 Begin VB.CommandButton sig Caption = ">>" Height = 315 Index = 3 Left = 8475 TabIndex = 62 TabStop = 0 False Top = 2925 Width = 540 Begin VB.TextBox txt Height = 315 Index = 6 Left = 1320 TabIndex = 6 Top = 2115 Width = 1290 Begin VB.TextBox txt Height = 315 Index = 7 Left = 3975 TabIndex = 7 Top = 2115 Width = 1590 Begin VB.TextBox txt Height = 315 Index = 8 Left = 1320 TabIndex = 8 Top = 2700 Width = 5790 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Height = 315 Index = 5 Left = 2880 TabIndex = 93 Top = 1560 Width = 5055 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Height = 315 Index = 0 Left = 2160 TabIndex = 92 Top = 420 Width = 2535 Begin VB.Label lbl Caption = "Diario:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 0 Left = 225 TabIndex = 74 Top = 450 Width =
110 Begin VB.Label lbl Caption = "Documento:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 1 Left = 225 TabIndex = 90 Top = 1005 Width = 1035 Begin VB.Label lbl Caption = "Fecha contable:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 3 Left = 3480 TabIndex = 89 Top = 1005 Width = 1455 Begin VB.Label lbl Caption = "Fecha documento:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 4 Left = 6120 TabIndex = 88 Top = 1005 Width = 1665 Begin VB.Label lbl Caption = "Cuenta:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 5 Left = 225 TabIndex = 73 Top = 1575 Width = 915 Begin VB.Label lbl Caption = "Importe:"
111 BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 6 Left = 225 TabIndex = 72 Top = 2137 Width = 915 Begin VB.Label lbl Caption = "Referencia:" Height = 240 Index = 7 Left = 3075 TabIndex = 71 Top = 2137 Width = 915 Begin VB.Label lbl Caption = "Concepto:" Height = 240 Index = 8 Left = 225 TabIndex = 70 Top = 2700 Width = 915 Begin VB.Frame frmasiento Height = 3315 Index = 3 Left = 120 TabIndex = 113 Top = 960 Width = 9090 Begin VB.TextBox txt BackColor = &H F& Index = 60 Left = 6480 Locked = -1 True TabIndex = 60 Top = 2880 Width = 1245 Begin VB.TextBox txt BackColor = &H F& Index = 59 Left = 3840 Locked = -1 True TabIndex = 59 Top = 2880 Width = 1245 Begin VB.TextBox txt BackColor = &H F& Index = 58 Left = 1200 Locked = -1 True TabIndex = 58 Top = 2880 Width = 1245 Begin VB.CommandButton ant Caption = "<<" Height = 315 Index =
112 Left = 8475 TabIndex = 67 TabStop = 0 False Top = 2925 Width = 540 Begin VB.TextBox txt Index = 56 Left = 5700 TabIndex = 56 Top = 2160 Width = 1440 Begin VB.TextBox txt Index = 55 Left = 3375 TabIndex = 55 Top = 2160 Width = 1440 Begin VB.TextBox txt Index = 57 Left = 1200 TabIndex = 57 Top = 2520 Width = 6540 Begin VB.TextBox txt Index = 54 Left = 1200 TabIndex = 54 Tag = "CUENTAS.cuenta" Top = 2160 Width = 1290 Begin MSComctlLib.ListView ListViewApunte Height = 1740 Left = 120 TabIndex = 69 TabStop = 0 False Top = 240 Width = 8895 _ExtentX = _ExtentY = 3069 View = 3 LabelEdit = 1 Sorted = -1 True LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 7 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Nº. Ap." Object.Width = 265 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Fecha" Object.Width = 265 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Subcuenta" Object.Width = 265 Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } Alignment = 1 SubItemIndex =
113 Text = "Debe" Object.Width = 265 Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } Alignment = 1 SubItemIndex = 4 Text = "Haber" Object.Width = 265 Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Concepto" Object.Width = 265 Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Tipus" Object.Width = 0 Property Begin VB.Label lbld Caption = "Saldo Asiento:" Height = 240 Index = 6 Left = 5280 TabIndex = 105 Top = 2880 Width = 1185 Begin VB.Label lbld Caption = "Haber Asiento:" Height = 240 Index = 5 Left = 2640 TabIndex = 104 Top = 2880 Width = 1185 Begin VB.Label lbld Caption = "Debe Asiento:" Height = 240 Index = 4 Left = 120 TabIndex = 103 Top = 2880 Width = 1065 Begin MSForms.CommandButton btncontrapartida Left = 7245 TabIndex = 91 Top = 2160 Width = 495 Size = "873;503" Picture = "frmapunte.frx":0000 FontName = "Arial Black" FontEffects = FontHeight = 240 FontCharSet = 0 FontPitchAndFamily= 2 ParagraphAlign = 3 FontWeight = 700 Begin VB.Label lbld Caption = "Haber:" Height = 240 Index = 3 Left = 5100 TabIndex = 87 Top = 2190 Width = 540 Begin VB.Label lbld Caption = "Debe:" Height = 240 Index =
114 Left = 2700 TabIndex = 86 Top = 2190 Width = 690 Begin VB.Label lbld Caption = "Concepto:" Height = 240 Index = 1 Left = 120 TabIndex = 85 Top = 2520 Width = 840 Begin VB.Label lbld Caption = "Subcuenta:" Height = 240 Index = 0 Left = 120 TabIndex = 84 Top = 2190 Width = 915 Begin VB.Frame frmasiento Height = 3315 Index = 2 Left = 120 TabIndex = 111 Top = 960 Width = 9090 Begin VB.TextBox txt Index = 49 Left = 1080 TabIndex = 49 Top = 1800 Width = 495 Begin VB.TextBox txt BackColor = &H F& Index = 53 Left = 1080 Locked = -1 True TabIndex = 53 Top = 2880 Width = 1335 Begin VB.TextBox txt Index = 52 Left = 1080 TabIndex = 52 Top = 2520 Width = 4215 Begin VB.CommandButton ant Caption = "<<" Height = 315 Index = 2 Left = 7950 TabIndex = 65 Top = 2925 Width = 540 Begin VB.CommandButton sig Caption = ">>" Height = 315 Index = 1 Left = 8475 TabIndex = 66 Top = 2925 Width = 540 Begin VB.TextBox txt
115 Index = 51 Left = 3960 TabIndex = 51 Top = 2160 Width = 1335 Begin VB.TextBox txt Index = 50 Left = 1080 TabIndex = 50 Top = 2160 Width = 1215 Begin MSComctlLib.ListView ListViewAltaCartera Height = 1335 Left = 120 TabIndex = 81 TabStop = 0 False Top = 240 Width = 8895 _ExtentX = _ExtentY = 2355 View = 3 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 4 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Tipo" Object.Width = 2540 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Vencimiento" Object.Width = 2540 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Importe" Object.Width = 2540 Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Descripcion" Object.Width = 2540 Property Begin MSForms.CommandButton btnaltavencimiento Left = 2520 TabIndex = 126 Top = 2880 Width = 465 Caption = "+" Size = "820;503" Picture = "frmapunte.frx":015a FontName = "Arial" FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 ParagraphAlign = 3 Begin VB.Label lblc Caption = "Tipo (C/P):" Height = 255 Index = 10 Left = 120 TabIndex = 102 Top = 1800 Width =
116 Begin VB.Label lblc Caption = "Total:" Height = 255 Index = 9 Left = 120 TabIndex = 101 Top = 2880 Width = 855 Begin VB.Label lblc Caption = "Descripción:" Height = 255 Index = 8 Left = 120 TabIndex = 100 Top = 2520 Width = 1095 Begin VB.Label lblc Caption = "Importe Vto.:" Height = 255 Index = 1 Left = 2880 TabIndex = 83 Top = 2160 Width = 1095 Begin VB.Label lblc Caption = "Fecha Vto.:" Height = 255 Index = 0 Left = 120 TabIndex = 82 Top = 2160 Width = 855 Begin VB.Frame frmasiento Height = 3315 Index = 1 Left = 120 TabIndex = 110 Top = 960 Width = 9090 Begin VB.TextBox ctairpf Index = 3 Left = TabIndex = 125 Top = 1920 Width = 1095 Begin VB.TextBox ctairpf Index = 2 Left = TabIndex = 124 Top = 1560 Width = 1095 Begin VB.TextBox ctairpf Index = 1 Left = TabIndex = 123 Top = 1200 Width = 1095 Begin VB.TextBox ctairpf Index = 0 Left = TabIndex = 122 Top = 840 Width =
117 Begin VB.TextBox ctare Index = 3 Left = TabIndex = 121 TabStop = 0 False Top = 1920 Width = 1095 Begin VB.TextBox ctare Index = 2 Left = TabIndex = 120 TabStop = 0 False Top = 1560 Width = 1095 Begin VB.TextBox ctare Index = 1 Left = TabIndex = 119 TabStop = 0 False Top = 1200 Width = 1095 Begin VB.TextBox ctare Index = 0 Left = TabIndex = 118 TabStop = 0 False Top = 840 Width = 1095 Begin VB.TextBox ctaiva Index = 3 Left = 9360 TabIndex = 117 TabStop = 0 False Top = 1920 Width = 1095 Begin VB.TextBox ctaiva Index = 2 Left = 9360 TabIndex = 116 TabStop = 0 False Top = 1560 Width = 1095 Begin VB.TextBox ctaiva Index = 1 Left = 9360 TabIndex = 115 TabStop = 0 False Top = 1200 Width = 1095 Begin VB.TextBox ctaiva Index = 0 Left = 9360 TabIndex = 114 TabStop = 0 False Top = 840 Width = 1095 Begin VB.TextBox txt BackColor = &H F& Index = 45 Left =
118 Locked = -1 True TabIndex = 45 TabStop = 0 False Top = 2400 Width = 1095 Begin VB.TextBox txt BackColor = &H F& Index = 46 Left = 3105 Locked = -1 True TabIndex = 46 TabStop = 0 False Top = 2400 Width = 1020 Begin VB.TextBox txt BackColor = &H F& Index = 47 Left = 5040 Locked = -1 True TabIndex = 47 TabStop = 0 False Top = 2400 Width = 1020 Begin VB.TextBox txt BackColor = &H F& Index = 48 Left = 7920 Locked = -1 True TabIndex = 48 TabStop = 0 False Top = 2400 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 41 Left = 5040 TabIndex = 41 Top = 1920 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 44 Left = 7920 TabIndex = 44 Top = 1920 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 43 Left = 7095 Locked = -1 True TabIndex = 43 TabStop = 0 False Top = 1920 Width = 735 Begin VB.TextBox txt Index = 36 Left = 150 TabIndex = 36 Top = 1920 Width = 1095 Begin VB.TextBox txt
119 BackColor = &H & Index = 38 Left = 2280 Locked = -1 True TabIndex = 38 TabStop = 0 False Top = 1920 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 39 Left = 3105 TabIndex = 39 Top = 1920 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 40 Left = 4215 Locked = -1 True TabIndex = 40 TabStop = 0 False Top = 1920 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 42 Left = 6150 TabIndex = 42 Tag = "IRPF.codigo" Top = 1920 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 37 Left = 1335 TabIndex = 37 Tag = "IMPUESTOS.impuesto" Top = 1920 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 32 Left = 5040 TabIndex = 32 Top = 1560 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 35 Left = 7920 TabIndex = 35 Top = 1560 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 34 Left = 7095 Locked = -1 True TabIndex = 34 TabStop = 0 False Top =
120 Width = 735 Begin VB.TextBox txt Index = 27 Left = 150 TabIndex = 27 Top = 1560 Width = 1095 Begin VB.TextBox txt BackColor = &H & Index = 29 Left = 2280 Locked = -1 True TabIndex = 29 TabStop = 0 False Top = 1560 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 30 Left = 3105 TabIndex = 30 Top = 1560 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 31 Left = 4215 Locked = -1 True TabIndex = 31 TabStop = 0 False Top = 1560 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 33 Left = 6150 TabIndex = 33 Tag = "IRPF.codigo" Top = 1560 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 28 Left = 1335 TabIndex = 28 Tag = "IMPUESTOS.impuesto" Top = 1560 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 23 Left = 5040 TabIndex = 23 Top = 1200 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 26 Left = 7920 TabIndex =
121 Top = 1200 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 25 Left = 7095 Locked = -1 True TabIndex = 25 TabStop = 0 False Top = 1200 Width = 735 Begin VB.TextBox txt Index = 18 Left = 150 TabIndex = 18 Top = 1200 Width = 1095 Begin VB.TextBox txt BackColor = &H & Index = 20 Left = 2280 Locked = -1 True TabIndex = 20 TabStop = 0 False Top = 1200 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 21 Left = 3105 TabIndex = 21 Top = 1200 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 22 Left = 4215 Locked = -1 True TabIndex = 22 TabStop = 0 False Top = 1200 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 24 Left = 6150 TabIndex = 24 Tag = "IRPF.codigo" Top = 1200 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 19 Left = 1335 TabIndex = 19 Tag = "IMPUESTOS.impuesto" Top = 1200 Width = 855 Begin VB.TextBox txt BackColor = &H & Index =
122 Left = 5040 TabIndex = 14 Top = 840 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 17 Left = 7920 TabIndex = 17 Top = 840 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 16 Left = 7095 Locked = -1 True TabIndex = 16 TabStop = 0 False Top = 840 Width = 735 Begin VB.TextBox txt BackColor = &H & Index = 10 Left = 1335 TabIndex = 10 Tag = "IMPUESTOS.impuesto" Top = 840 Width = 855 Begin VB.CommandButton ant Caption = "<<" Height = 315 Index = 1 Left = 7950 TabIndex = 63 TabStop = 0 False Top = 2925 Width = 540 Begin VB.CommandButton sig Caption = ">>" Height = 315 Index = 0 Left = 8475 TabIndex = 64 TabStop = 0 False Top = 2925 Width = 540 Begin VB.TextBox txt BackColor = &H & Index = 15 Left = 6150 TabIndex = 15 Tag = "IRPF.codigo" Top = 840 Width = 855 Begin VB.TextBox txt BackColor = &H & Index = 13 Left = 4200 Locked = -1 True TabIndex = 13 TabStop = 0 False Top = 840 Width = 735 Begin VB.TextBox txt
123 BackColor = &H & Index = 12 Left = 3105 TabIndex = 12 Top = 840 Width = 1020 Begin VB.TextBox txt BackColor = &H & Index = 11 Left = 2280 Locked = -1 True TabIndex = 11 TabStop = 0 False Top = 840 Width = 735 Begin VB.TextBox txt Index = 9 Left = 150 TabIndex = 9 Top = 840 Width = 1095 Begin VB.Line LineSumBase X1 = 150 X2 = 1170 Y1 = 2280 Y2 = 2280 Begin VB.Line LineSumIVA X1 = 3105 X2 = 4125 Y1 = 2280 Y2 = 2280 Begin VB.Line LineSumRE X1 = 5040 X2 = 6060 Y1 = 2280 Y2 = 2280 Begin VB.Line LineSumIRPF X1 = 7920 X2 = 8940 Y1 = 2280 Y2 = 2280 Begin VB.Line LineIVA X1 = 150 X2 = 8925 Y1 = 630 Y2 = 630 Begin VB.Label lblimporte Caption = "Importe IRPF" Height = 240 Left = 7920 TabIndex = 108 Top = 360 Width = 1020 Begin VB.Label lblpctirpf Caption = "Pct. IRPF" Height = 240 Left = 7080 TabIndex = 107 Top = 360 Width = 735 Begin VB.Label lblirpf Caption = "IRPF" Height = 240 Left =
124 TabIndex = 106 Top = 360 Width = 660 Begin VB.Label lblre Caption = "Importe RE" Height = 240 Left = 5040 TabIndex = 80 Top = 360 Width = 1020 Begin VB.Label lblpctre Caption = "Pct. RE" Height = 240 Left = 4200 TabIndex = 79 Top = 360 Width = 645 Begin VB.Label lbliva Caption = "Importe IVA" Height = 240 Left = 3105 TabIndex = 78 Top = 360 Width = 1020 Begin VB.Label lblpctiva Caption = "Pct. IVA" Height = 240 Left = 2280 TabIndex = 77 Top = 360 Width = 675 Begin VB.Label lblbase Caption = "Base" Height = 240 Left = 150 TabIndex = 76 Top = 360 Width = 975 Begin VB.Label lblivare Caption = "IVA/RE" Height = 240 Left = 1335 TabIndex = 75 Top = 360 Width = 915 Begin VB.Frame frmasiento Height = 3315 Index = 4 Left = 120 TabIndex = 112 Top = 960 Width = 9090 Begin VB.CommandButton cmdpendientes Caption = "Todos pendientes" Height = 300 Left = 4500 TabIndex = 128 Top = 2460 Width = 2085 Begin VB.CommandButton cmdcancelar Caption = "Todos cancelados" Height = 300 Left = 2325 TabIndex = 127 Top = 2460 Width = 2085 Begin VB.CommandButton cmdseleccion
125 Caption = "Seleccionar efectos" Height = 300 Left = 120 TabIndex = 99 Top = 2460 Width = 2085 Begin VB.TextBox txt Alignment = 1 Right Justify BackColor = &H F& Index = 61 Left = 7680 Locked = -1 True TabIndex = 97 Top = 2475 Width = 1335 Begin VB.CommandButton sig Caption = ">>" Height = 315 Index = 2 Left = 8475 TabIndex = 95 Top = 2925 Width = 540 Begin VB.CommandButton ant Caption = "<<" Height = 315 Index = 0 Left = 7950 TabIndex = 94 Top = 2925 Width = 540 Begin MSComctlLib.ListView ListViewGestionCartera Height = 2085 Left = 120 TabIndex = 96 Top = 240 Width = 8895 _ExtentX = _ExtentY = 3678 View = 3 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 7 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Estado" Object.Width = 2540 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Código Documento" Object.Width = 2540 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Documento" Object.Width = 2540 Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Vencimiento" Object.Width = 2540 Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Cuenta" Object.Width =
126 Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Importe" Object.Width = 2540 Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Concepto" Object.Width = 2540 Property Begin VB.Label lblc Caption = "Total:" Height = 255 Index = 7 Left = 7050 TabIndex = 98 Top = 2490 Width = 555 Begin VB.TextBox oculto Index = 11 Left = TabIndex = 140 TabStop = 0 False Top = 2880 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 10 Left = TabIndex = 139 TabStop = 0 False Top = 2880 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 9 Left = 9480 TabIndex = 138 TabStop = 0 False Top = 2880 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 8 Left = TabIndex = 137 TabStop = 0 False Top = 2520 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 7 Left = TabIndex = 136 TabStop = 0 False Top = 2520 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 6 Left =
127 TabIndex = 135 TabStop = 0 False Top = 2520 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 5 Left = TabIndex = 134 TabStop = 0 False Top = 2160 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 4 Left = TabIndex = 133 TabStop = 0 False Top = 2160 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 3 Left = 9480 TabIndex = 132 TabStop = 0 False Top = 2160 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 2 Left = TabIndex = 131 TabStop = 0 False Top = 1800 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 1 Left = TabIndex = 130 TabStop = 0 False Top = 1800 Visible = 0 False Width = 1095 Begin VB.TextBox oculto Index = 0 Left = 9480 TabIndex = 129 TabStop = 0 False Top = 1800 Visible = 0 False Width = 1095 Begin MSComctlLib.Toolbar ToolbarApuntes Align = 1 Align Top Height = 420 Left = 0 TabIndex = 61 Tag = "ToolbarApuntes" Top = 0 Width =
128 _ExtentX = _ExtentY = 741 ButtonWidth = 609 ButtonHeight = 582 Appearance = 1 ImageList = "ImageListApuntes" _Version = Begin MSComctlLib.TabStrip TabStripApuntes Height = 3840 Left = 0 TabIndex = 68 TabStop = 0 False Top = 525 Width = 9375 _ExtentX = _ExtentY = 6773 TabWidthStyle = 2 HotTracking = -1 True _Version = BeginProperty Tabs {1EFB C-11D1-B16A-00C0F } NumTabs = 4 BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F } Caption = "Apunte" ImageVarType = 2 Property BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F } Caption = "IVA" ImageVarType = 2 Property BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F } Caption = "Cartera" ImageVarType = 2 Property BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F } Caption = "Contrapartida" ImageVarType = 2 Property Property Begin MSComctlLib.ImageList ImageListApuntes Left = 0 Top = 4650 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmapunte" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mapuntes As Apuntes Dim partida As String Dim numeracion As String Dim cartera As String Dim identificador As String Dim contrapartida As String Dim PrevTab As Object Dim TabState(1 To 4) As Integer Dim FakeNext As Integer Dim mapunte As Apuntes Dim mcartera As cartera Dim mimpuestos As Impuestos Dim mirpf As irpf Dim macrdeu As acrdeu Dim mregistroiva As RegistroIva Dim mregistroirpf As RegistroIrpf Dim mformaspago As FormasPago
129 Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Dim maux As New Auxiliar sdate = maux.sdate(fecha) Set maux = Nothing Function Private Function ddate(fecha As Variant) As String Dim maux As New Auxiliar ddate = maux.ddate(fecha) Set maux = Nothing Function Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Name) Then Set frmapunte = Forms(i) Next Call limatges16(imagelistapuntes) Set ToolbarApuntes.ImageList = ImageListApuntes Call cargarbotonera(toolbarapuntes) Call deshabilitarbotones(toolbarapuntes, "modificar", "filtrar", "lupa", "listar", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Left = sgetini(fini, Name, "Left", Left) Top = sgetini(fini, Name, "Top", Top) Width = sgetini(fini, Name, "Width", ScaleWidth) Height = sgetini(fini, Name, "Height", ScaleHeight) Configuración de las listas With ListViewApunte For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Name, "Grid_AC" & Format(i, "00"),.ColumnHeaders(i).Width) Next With With ListViewAltaCartera For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Name, "Grid_BC" & Format(i, "00"),.ColumnHeaders(i).Width) Next With With ListViewGestionCartera For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Name, "Grid_CC" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Deshabilito todas las pestañas excepto la primera TabState(1) = True TabState(2) = False TabState(3) = False TabState(4) = False Guardo una referencia a la primera pestaña Set PrevTab = TabStripApuntes.Tabs(1) FakeNext = False txt(3).text = Date txt(4).text = Date Sub
130 Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If WindowState <> vbminimized Then writeini fini, Name, "Left", Left writeini fini, Name, "Top", Top writeini fini, Name, "Width", Width writeini fini, Name, "Height", Height With ListViewApunte For i = 1 To.ColumnHeaders.Count writeini fini, Name, "Grid_AC" & Format(i, "00"),.ColumnHeaders(i).Width Next With With ListViewAltaCartera For i = 1 To.ColumnHeaders.Count writeini fini, Name, "Grid_BC" & Format(i, "00"),.ColumnHeaders(i).Width Next With With ListViewGestionCartera For i = 1 To.ColumnHeaders.Count writeini fini, Name, "Grid_CC" & Format(i, "00"),.ColumnHeaders(i).Width Next With Si hemos dejado la selección de cartera abierta, la cerramos Unload frmseleccioncartera Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub ant_click(index As Integer) Dim i As Integer Dim trobat As Boolean i = TabStripApuntes.SelectedItem.Index - 1 trobat = False While i >= 1 And Not trobat If TabState(i) Then trobat = True i = i - 1 Wend If trobat Then TabStripApuntes.Tabs(i).Selected = True Sub Private Sub sig_click(index As Integer) Dim i As Integer Dim trobat As Boolean i = TabStripApuntes.SelectedItem.Index + 1 trobat = False While i <= 4 And Not trobat If TabState(i) Then trobat = True i = i + 1 Wend If trobat Then TabStripApuntes.Tabs(i).Selected = True
131 Sub Private Sub mostrarframe(nframe As Integer) Dim i As Integer For i = 0 To 4 frmasiento(i).visible = False Next frmasiento(nframe).top = frmasiento(0).top frmasiento(nframe).left = frmasiento(0).left frmasiento(nframe).visible = True Select Case nframe Case 0: If Me.frmAsiento(nFrame).Enabled Then txt(0).setfocus Case 1: If Me.frmAsiento(nFrame).Enabled Then txt(9).setfocus Case 2: If Me.frmAsiento(nFrame).Enabled Then txt(49).setfocus Case 3: If Me.frmAsiento(nFrame).Enabled Then txt(54).setfocus Case 4: If Me.frmAsiento(nFrame).Enabled Then cmdseleccion.setfocus Select Sub Private Sub txt_dblclick(index As Integer) If ToolbarApuntes.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) ToolbarApuntes.Buttons(7).Enabled = (ActiveControl.tag <> "") txt(index).selstart = 0: txt(index).sellength = Len(txt(Index)) If Index = 54 Then Call insertartmpcontrapartida Sub Private Sub validarpartida(index As Integer, Cancel As Boolean, msg As String) Dim aux As String Dim iaux As Integer Set mauxiliar = New Auxiliar Select Case Index Case 0: Codigo de diario If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("diarios", "descripcion", "codigo_empresa = " & sempresa & " AND codigo_diario = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1002) des(index) = aux Case 1: Codigo de documento If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("documentos, Numeraciones", "Documentos.codigo_documento AS codigo_documento", "Documentos.codigo_empresa = " & sempresa & " AND Documentos.codigo_documento = " & txt(index) & " AND Numeraciones.ejercicio = " & iejercicio & " AND Documentos.codigo_empresa = Numeraciones.codigo_empresa AND Documentos.numeracion = Numeraciones.numeracion", "#") If aux = "#" Then msg = msgerror(1003) Case 2: Numero de documento If txt(index) <> "" Then txt(index) = UCase(txt(Index)) If txt(index) = "0" Then Si entramos un 0, calcula el siguiente numero txt(index) = identificador & siguientenumero(sempresa, iejercicio, numeracion) aux = mauxiliar.vbuscarcampo("documentos", "identificador", "codigo_empresa = " & sempresa & " AND codigo_documento = " & txt(1) & "", "#") If aux <> Left(txt(Index), Len(aux)) Then Compruebo que el identificador entrado se corresponde con el documento msg = msgerror(1026)
132 iaux = mauxiliar.vbuscarcampo("documentos, Numeraciones", "Numeraciones.longitud AS longitud", "Documentos.codigo_empresa = Numeraciones.codigo_empresa AND Documentos.Numeracion = Numeraciones.numeracion AND Numeraciones.codigo_empresa = " & sempresa & " AND Numeraciones.ejercicio = " & iejercicio & " AND Documentos.codigo_documento = " & txt(1) & "", "0") If iaux + Len(aux) <> Len(txt(Index)) Then msg = msgerror(1026) Case 3, 4: Fecha apunte y fecha documento If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Case 5: Cuenta contable If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(index) & " and pases = S", "#") If aux = "#" Then msg = msgerror(1001) If Index = 5 Then des(index) = aux Case 6: Importe If txt(index) <> "" Then txt(index) = Format(Replace(txt(Index), ".", ","), "0.00") If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Select Set mauxiliar = Nothing Sub Private Sub validariva(index As Integer, Cancel As Boolean, msg As String) Dim aux As String Set mauxiliar = New Auxiliar Select Case Index Case 9, 12, 14, 17, 18, 21, 23, 26, 27, 30, 32, 35, 36, 39, 41, 44: Importes base, iva, re y irpf If txt(index) <> "" Then txt(index) = Format(Replace(txt(Index), ".", ","), "0.00") If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Case 10, 19, 28, 37: Tipos de Iva If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("impuestos", "impuesto", "codigo_empresa = " & sempresa & " AND impuesto = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1003) Case 15, 24, 33, 42: Tipos de Irpf If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("irpf", "codigo", "codigo_empresa = " & sempresa & " AND codigo = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1003) Select Set mauxiliar = Nothing Sub
133 Private Sub validaraltacartera(index As Integer, Cancel As Boolean, msg As String) Dim aux As String Set mauxiliar = New Auxiliar Select Case Index Case 49: Tipo de documento If txt(index) <> "" Then txt(index) = UCase(txt(Index)) If txt(index) <> "C" And txt(index) <> "P" Then msg = msgerror(1005) Case 50: Fecha vencimiento If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Case 51: Importe vencimiento If txt(index) <> "" Then txt(index) = Format(Replace(txt(Index), ".", ","), "0.00") If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Select Set mauxiliar = Nothing Sub Private Sub validarcontrapartida(index As Integer, Cancel As Boolean, msg As String) Dim aux As String Set mauxiliar = New Auxiliar Select Case Index Case 54: Cuenta contable If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(index) & " and pases = S", "#") If aux = "#" Then msg = msgerror(1001) If Index = 5 Then des(index) = aux Case 55, 56: Importe If txt(index) <> "" Then txt(index) = Format(Replace(txt(Index), ".", ","), "0.00") If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Select Set mauxiliar = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Cancel = False If Index >= 0 And Index <= 8 Then Call validarpartida(index, Cancel, msg) If Index >= 9 And Index <= 48 Then Call validariva(index, Cancel, msg) If Index >= 49 And Index <= 53 Then Call validaraltacartera(index, Cancel, msg) If Index >= 54 And Index <= 60 Then Call validarcontrapartida(index, Cancel, msg) If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub
134 Private Sub cancelardatos() Dim i As Integer Call desbloquearcontroles For i = 0 To 61: txt(i) = "": Next For i = 0 To 11: oculto(i) = "": Next txt(3) = Date txt(4) = Date des(0) = "" des(5) = "" ListViewApunte.ListItems.Clear ListViewAltaCartera.ListItems.Clear ListViewGestionCartera.ListItems.Clear For i = TabStripApuntes.SelectedItem.Index - 1 To 1 Step -1 TabStripApuntes.Tabs(i).Selected = True Next Call habilitarbotones(toolbarapuntes, "insertar") txt(0).setfocus Sub Private Sub actualizarsaldosasiento() Dim i As Integer Dim maxi As Integer Dim debe As Double Dim haber As Double debe = 0 haber = 0 maxi = ListViewApunte.ListItems.Count For i = 1 To maxi If ListViewApunte.ListItems(i).SubItems(3) <> "" Then debe = debe + ListViewApunte.ListItems(i).SubItems(3) If ListViewApunte.ListItems(i).SubItems(4) <> "" Then haber = haber + ListViewApunte.ListItems(i).SubItems(4) Next txt(58) = debe txt(59) = haber txt(60) = debe - haber Sub Private Sub actualizarsumairpf() Dim i As Integer Dim sumirpf As Double sumirpf = 0 For i = 1 To 4 sumirpf = sumirpf + IIf(IsNumeric(txt(9 * i + 8)), txt(9 * i + 8), 0) Next txt(48) = Format(sumIRPF, "0.00") Sub Private Sub actualizarsumabase() Dim i As Integer Dim sumbase As Double sumbase = 0 For i = 1 To 4 sumbase = sumbase + IIf(IsNumeric(txt(9 * i)), txt(9 * i), 0) Next txt(45) = Format(sumBase, "0.00") Sub Private Sub actualizarsumaiva()
135 Dim i As Integer Dim sumiva As Double sumiva = 0 For i = 1 To 4 sumiva = sumiva + IIf(IsNumeric(txt(9 * i + 3)), txt(9 * i + 3), 0) Next txt(46) = Format(sumIVA, "0.00") Sub Private Sub actualizarsumare() Dim i As Integer Dim sumre As Double sumre = 0 For i = 1 To 4 sumre = sumre + IIf(IsNumeric(txt(9 * i + 5)), txt(9 * i + 5), 0) Next txt(47) = Format(sumRE, "0.00") Sub Private Sub ayudarapuntes() Sub Private Sub btncontrapartida_click() If txt(54) <> "" Then If IsNumeric(txt(55)) Or IsNumeric(txt(56)) Then If Nz(txt(55), 0) <> 0 Or Nz(txt(56), 0) <> 0 Then If Nz(txt(55), 0) = 0 Then Call insertargridapunte(0, txt(3), txt(54), 0, txt(56), txt(57), "CP") Call insertargridapunte(0, txt(3), txt(54), txt(55), 0, txt(57), "CP") txt(54) = "": txt(55) = "": txt(56) = "": txt(57) = "" txt(54).setfocus Sub Private Sub btnaltavencimiento_click() Dim pos As Integer Dim newitem As ListItem On Error Resume Next pos = ListViewAltaCartera.ListItems("K" & txt(49) & sdate(txt(50))).index If pos = 0 Then Set newitem = ListViewAltaCartera.ListItems.Add(, "K" & txt(49) & sdate(txt(50)), txt(49)) newitem.subitems(1) = txt(50) newitem.subitems(2) = txt(51) newitem.subitems(3) = txt(52) txt(53) = CDbl(txt(53)) + CDbl(txt(51)) txt(49) = "" txt(50) = "" txt(51) = "" txt(52) = "" MsgBox msgerror(9999), vbcritical, App.Title Sub Private Sub cambiarbase(index As Integer) Dim i As Integer
136 If txt(index) <> "" Then If IsNumeric(txt(Index)) Then txt(index) = Format(CDbl(txt(Index)), "0.00") If IsNumeric(txt(Index + 2)) Then txt(index + 3) = Format(CDbl(txt(Index)) * CDbl(txt(Index + 2)) / 100, "0.00") IVA If IsNumeric(txt(Index + 4)) Then txt(index + 5) = Format(CDbl(txt(Index)) * CDbl(txt(Index + 4)) / 100, "0.00") RE If IsNumeric(txt(Index + 7)) Then txt(index + 8) = Format(CDbl(txt(Index)) * CDbl(txt(Index + 7)) / 100, "0.00") IRPF Call actualizarsumabase Call actualizarsumaiva Call actualizarsumare Call actualizarsumairpf txt(index + 1) = "" txt(index + 2) = "" txt(index + 3) = "" txt(index + 4) = "" txt(index + 5) = "" txt(index + 6) = "" txt(index + 7) = "" txt(index + 8) = "" Sub Private Sub cambiarirpf(index) Dim i As Integer Dim sumirpf As Double Dim rs As ADODB.Recordset Set mirpf = New irpf Set rs = mirpf.getlist(cn, "codigo_empresa = " & sempresa & " and codigo = " & txt(index) & "") Set mirpf = Nothing If rs.eof Then txt(index + 1) = "" txt(index + 2) = "" ctairpf(((index - 6) / 9) - 1) = "" txt(index + 1) = Nz(rs("pct_irpf"), "") If IsNumeric(txt(Index + 1)) Then txt(index + 2) = Format(txt(Index - 6) * txt(index + 1) / 100, "0.00") IVA ctairpf(((index - 6) / 9) - 1) = Nz(rs("cuenta"), "") sumirpf = 0 For i = 1 To 4 sumirpf = sumirpf + IIf(IsNumeric(txt(9 * i + 8)), txt(9 * i + 8), 0) Next txt(48) = Format(sumIRPF, "0.00") Sub Private Sub cambiarivare(index) Dim i As Integer Dim sumiva As Double Dim sumre As Double Dim rs As ADODB.Recordset Set mimpuestos = New Impuestos Set rs = mimpuestos.getlist(cn, "codigo_empresa = " & sempresa & " and impuesto = " & txt(index) & "") Set mimpuestos = Nothing If rs.eof Then txt(index + 1) = "" txt(index + 2) = "" txt(index + 3) = ""
137 txt(index + 4) = "" ctaiva(((index - 1) / 9) - 1) = "" ctare(((index - 1) / 9) - 1) = "" txt(index + 1) = Nz(rs("pct_iva"), "") txt(index + 3) = Nz(rs("pct_re"), "") If IsNumeric(txt(Index - 1)) Then If IsNumeric(txt(Index + 1)) Then txt(index + 2) = Format(txt(Index - 1) * txt(index + 1) / 100, "0.00") IVA If IsNumeric(txt(Index + 3)) Then txt(index + 4) = Format(txt(Index - 1) * txt(index + 3) / 100, "0.00") RE ctaiva(((index - 1) / 9) - 1) = Nz(rs("cta_iva"), "") ctare(((index - 1) / 9) - 1) = Nz(rs("cta_re"), "") sumiva = 0 sumre = 0 For i = 1 To 4 sumiva = sumiva + IIf(IsNumeric(txt(9 * i + 3)), txt(9 * i + 3), 0) sumre = sumre + IIf(IsNumeric(txt(9 * i + 5)), txt(9 * i + 5), 0) Next txt(46) = Format(sumIVA, "0.00") txt(47) = Format(sumRE, "0.00") Sub Private Sub cargarinformacioncuenta() Dim rsacrdeu As ADODB.Recordset Dim i As Integer If TabState(2) Or TabState(3) Then Dim parametro As String Dim rsimpuesto As ADODB.Recordset Dim rsirpf As ADODB.Recordset Obengo la informacion del acrdeu Set macrdeu = New acrdeu Set rsacrdeu = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") Set macrdeu = Nothing If Not rsacrdeu.eof Then contrapartida = Nz(rsAcrdeu("contrapartida"), "") If TabState(2) Then Elimino todas las entradas del IVA For i = 9 To 48: txt(i) = "": Next If Not rsacrdeu.eof Then txt(10) = Nz(rsAcrdeu("impuesto"), "") txt(15) = Nz(rsAcrdeu("irpf"), "") Set mimpuestos = New Impuestos Set rsimpuesto = mimpuestos.getlist(cn, "codigo_empresa = " & sempresa & " and impuesto = " & txt(10) & "") Set mimpuestos = Nothing Set mirpf = New irpf Set rsirpf = mirpf.getlist(cn, "codigo_empresa = " & sempresa & " and codigo = " & txt(15) & "") Set mirpf = Nothing If Not rsimpuesto.eof Then txt(11) = Format(Nz(rsImpuesto("pct_iva"), ""), "0.00") txt(13) = Format(Nz(rsImpuesto("pct_re"), ""), "0.00") ctaiva(0) = Nz(rsImpuesto("cta_iva"), "") ctare(0) = Nz(rsImpuesto("cta_re"), "")
138 If Not rsirpf.eof Then txt(16) = Format(Nz(rsIrpf("pct_irpf"), ""), "0.00") ctairpf(0) = Nz(rsIrpf("cuenta"), "") Dim divisor As Double divisor = 100 If IsNumeric(txt(11)) Then divisor = divisor + txt(11) If IsNumeric(txt(13)) Then divisor = divisor + txt(13) If IsNumeric(txt(16)) Then divisor = divisor - txt(16) Base IVA RE IRPF txt(9) = Format(100 * txt(6) / divisor, "0.00") If IsNumeric(txt(11)) Then txt(12) = Format(txt(9) * txt(11) / 100, "0.00") If IsNumeric(txt(13)) Then txt(14) = Format(txt(9) * txt(13) / 100, "0.00") If IsNumeric(txt(16)) Then txt(17) = Format(txt(9) * txt(16) / 100, "0.00") txt(45) = txt(9) txt(46) = txt(12) txt(47) = txt(14) txt(48) = txt(17) If Not rsacrdeu.eof Then If TabState(3) Then Dim rsformaspago As ADODB.Recordset Dim vencimiento As Date Dim importe As Double Dim acumulado As Double Dim auxvto As String Dim auxpct As String Dim newitem As ListItem Elimino todas las entradas de los vencimientos ListViewAltaCartera.ListItems.Clear For i = 49 To 53: txt(i) = "": Next Set mformaspago = New FormasPago Set rsformaspago = mformaspago.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_pago = " & Nz(rsAcrdeu("forma_pago"), "") & "") Set mformaspago = Nothing acumulado = 0 For i = 1 To 4 auxvto = "vto" & Trim(str(i)) auxpct = "pct" & Trim(str(i)) If Nz(rsFormasPago(auxVto), "") <> "" Then Calculo la fecha del vencimiento vencimiento = DateAdd("d", rsformaspago(auxvto), txt(4)) If Nz(rsAcrdeu("primer_dia"), "") <> "" Then If Day(vencimiento) < rsacrdeu("primer_dia") Then vencimiento = DateAdd("d", rsacrdeu("primer_dia") - Day(vencimiento), vencimiento) vencimiento = DateAdd("d", Day(vencimiento) - rsacrdeu("primer_dia"), vencimiento) vencimiento = DateAdd("m", 1, vencimiento) Calculo los importes de los vencimientos importe = Format(txt(6) * (rsformaspago(auxpct) / 100), "0.00") acumulado = acumulado + importe If importe <> 0 Then Guardo los vencimientos en la lista Set newitem = ListViewAltaCartera.ListItems.Add(, "K" & IIf(partida = "D", "C", "P") & sdate(cstr(vencimiento)), IIf(partida = "D", "C", "P")) newitem.subitems(1) = vencimiento newitem.subitems(2) = importe newitem.subitems(3) = "Vto. " & Trim(str(i)) & ". " & txt(2)
139 txt(53) = acumulado Next Sub Private Sub configurarentradaasientos() Dim rs As ADODB.Recordset Dim mdocumentos As Documentos Set mdocumentos = New Documentos Set rs = mdocumentos.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(1) & "") Set mdocumentos = Nothing If Not rs.eof Then partida = Trim(rs("partida")) numeracion = Trim(rs("numeracion")) cartera = Trim(rs("cartera")) identificador = Trim(rs("identificador")) TabState(2) = (rs("iva") <> "N") TabState(3) = (rs("cartera") <> "N") TabState(4) = True TabState(2) = False TabState(3) = False TabState(4) = False Set rs = Nothing Sub Private Function datosobligatorios(index As Integer) As String Dim i As Integer datosobligatorios = "" Select Case Index Case 0: For i = 0 To 6 If txt(i) = "" Then datosobligatorios = msgerror(1000) txt(i).setfocus Exit Function Next Select Function Private Sub eliminarapunte() Dim aux As String Dim rpta As Integer On Error GoTo EliminarEmpresaError If txt(1) <> "" And txt(2) <> "" Then rpta = MsgBox(" Desea eliminar el asiento " & txt(1) & "/" & txt(2) & "? (Los datos relacionados con el asiento también se eliminarán)", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mapunte = New Apuntes mapunte.delete cn, sempresa, sdelegacion, txt(1), txt(2), 0, False Set mapunte = Nothing Call cancelardatos Exit Sub EliminarEmpresaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub
140 Private Sub eliminargridapunte(apunte As Integer) Dim i As Integer Dim maxitem As Integer Dim newitem As ListItem Dim np As Integer Dim parametro As String On Error Resume Next maxitem = ListViewApunte.ListItems.Count If apunte > 0 And apunte <= maxitem Then For i = apunte To maxitem - 1 ListViewApunte.ListItems(i).Text = Mid(ListViewApunte.ListItems(i).Key, 2) ListViewApunte.ListItems(i).SubItems(1) = ListViewApunte.ListItems(i + 1).SubItems(1) ListViewApunte.ListItems(i).SubItems(2) = ListViewApunte.ListItems(i + 1).SubItems(2) ListViewApunte.ListItems(i).SubItems(3) = ListViewApunte.ListItems(i + 1).SubItems(3) ListViewApunte.ListItems(i).SubItems(4) = ListViewApunte.ListItems(i + 1).SubItems(4) ListViewApunte.ListItems(i).SubItems(5) = ListViewApunte.ListItems(i + 1).SubItems(5) ListViewApunte.ListItems(i).SubItems(6) = ListViewApunte.ListItems(i + 1).SubItems(6) Next ListViewApunte.ListItems.Remove (maxitem) ListViewApunte.Refresh Sub Private Sub filtrarapunte() Sub Private Sub cmdcancelar_click() Dim i As Integer Dim maxi As Integer txt(61).text = 0 maxi = ListViewGestionCartera.ListItems.Count For i = 1 To maxi ListViewGestionCartera.ListItems(i).Selected = True ListViewGestionCartera.SelectedItem = "C" txt(61).text = CDbl(txt(61).Text) + CDbl(ListViewGestionCartera.SelectedItem.ListSubItems(5).Text) Next Sub Private Sub cmdpendientes_click() Dim i As Integer Dim maxi As Integer txt(61).text = 0 maxi = ListViewGestionCartera.ListItems.Count For i = 1 To maxi ListViewGestionCartera.ListItems(i).Selected = True ListViewGestionCartera.SelectedItem = "P" Next Sub Private Sub cmdseleccion_click() frmseleccioncartera.show frmseleccioncartera.lbltipoefectos = IIf(partida = "D", "Cobro", "Pago") Sub Private Sub imprimirapuntes() Sub Private Sub insertarapunte()
141 Dim i As Integer Set mapunte = New Apuntes For i = 1 To ListViewApunte.ListItems.Count ListViewApunte.ListItems(i).SubItems(3) = Replace(ListViewApunte.ListItems(i).SubItems(3), ",", ".") ListViewApunte.ListItems(i).SubItems(4) = Replace(ListViewApunte.ListItems(i).SubItems(4), ",", ".") If ListViewApunte.ListItems(i).SubItems(6) = "P" Then Inserto el apunte de la partida mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "P", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "IVA" Then Inserto el apunte del iva mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "IVA", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "RE" Then Inserto el apunte del re mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "RE", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "IRPF" Then Inserto el apunte del irpf mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "IRPF", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "CP" Then Inserto el apunte de la contrapartida mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "CP", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "GC" Then Inserto el apunte de gestio de cartera mapunte.insert cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "GC", "", susuario ListViewApunte.ListItems(i).SubItems(3) = Replace(ListViewApunte.ListItems(i).SubItems(3), ".", ",") ListViewApunte.ListItems(i).SubItems(4) = Replace(ListViewApunte.ListItems(i).SubItems(4), ".", ",") Next Set mapunte = Nothing Sub Private Sub insertarcartera() Dim i As Integer Dim tipo As String Dim acrdeu As String Dim rs As ADODB.Recordset Set macrdeu = New acrdeu
142 Set rs = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") Set macrdeu = Nothing If Not rs.eof Then tipo = rs("tipo") acrdeu = rs("codigo") Set mcartera = New cartera For i = 1 To ListViewAltaCartera.ListItems.Count ListViewAltaCartera.ListItems(i).SubItems(2) = Replace(ListViewAltaCartera.ListItems(i).SubItems(2), ",", ".") mcartera.insert cn, sempresa, sdelegacion, txt(1), txt(2), 1, ListViewAltaCartera.ListItems(i).SubItems(1), _ tipo, acrdeu, ListViewAltaCartera.ListItems(i).SubItems(3), ListViewAltaCartera.ListItems(i).Text, "P", _ ListViewAltaCartera.ListItems(i).SubItems(2), "", "", "", susuario ListViewAltaCartera.ListItems(i).SubItems(2) = Replace(ListViewAltaCartera.ListItems(i).SubItems(2), ".", ",") Next Set mcartera = Nothing Sub Private Sub cancelarefectos() Dim i As Integer Dim tipo As String Dim acrdeu As String Dim rs As ADODB.Recordset Set macrdeu = New acrdeu Set rs = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") Set macrdeu = Nothing If Not rs.eof Then tipo = rs("tipo") acrdeu = rs("codigo") Set mcartera = New cartera For i = 1 To ListViewGestionCartera.ListItems.Count If ListViewGestionCartera.ListItems(i) = "C" Then ListViewGestionCartera.ListItems(i).SubItems(5) = Replace(ListViewGestionCartera.ListItems(i).SubItems(5), ",", ".") mcartera.setestado cn, sempresa, sdelegacion, ListViewGestionCartera.ListItems(i).SubItems(1), ListViewGestionCartera.ListItems(i).SubItems(2), _ 1, ListViewGestionCartera.ListItems(i).SubItems(3), "C", txt(3), txt(1), txt(2), susuario ListViewGestionCartera.ListItems(i).SubItems(5) = Replace(ListViewGestionCartera.ListItems(i).SubItems(5), ".", ",") Next Set mcartera = Nothing Sub Private Sub insertariva() Dim i As Integer Dim j As Integer Dim k As Integer Dim parametro As String Dim tipo_acrdeu As String Dim acrdeu As String Dim tipo As String Dim rs As ADODB.Recordset Set mregistroiva = New RegistroIva Set mregistroirpf = New RegistroIrpf Set mauxiliar = New Auxiliar Set macrdeu = New acrdeu
143 Set rs = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") Set macrdeu = Nothing If Not rs.eof Then tipo_acrdeu = rs("tipo") acrdeu = rs("codigo") i = 9 While i <= 36 If txt(i) <> "" Then For j = i To i + 8 If txt(j) = "" Then txt(j) = "null" txt(j) = Replace(txt(j), ",", ".") Next k = 3 * (i / 9-1) If txt(i + 1) <> "" Then tipo = mauxiliar.vbuscarcampo("impuestos", "tipo", "codigo_empresa = " & sempresa & " and impuesto = " & txt(i + 1) & "") mregistroiva.insert cn, sempresa, sdelegacion, txt(1), txt(2), oculto(k), tipo, tipo_acrdeu, _ acrdeu, txt(i + 1), txt(i), txt(i + 2), txt(i + 3), txt(i + 4), txt(i + 5), susuario If txt(i + 6) <> "" Then mregistroirpf.insert cn, sempresa, sdelegacion, txt(1), txt(2), oculto(k + 2), tipo_acrdeu, _ acrdeu, txt(i + 6), txt(i), txt(i + 7), txt(i + 8), susuario i = i + 9 Wend For j = i To i + 8 If txt(j) = "null" Then txt(j) = "" txt(j) = Replace(txt(j), ".", ",") Next Set mauxiliar = Nothing Set mregistroiva = Nothing Set mregistroirpf = Nothing Sub Private Sub modificariva() Dim i As Integer Dim j As Integer Dim k As Integer Dim parametro As String Dim tipo_acrdeu As String Dim acrdeu As String Dim tipo As String Dim rs As ADODB.Recordset Set mregistroiva = New RegistroIva Set mregistroirpf = New RegistroIrpf Set mauxiliar = New Auxiliar Set macrdeu = New acrdeu Set rs = macrdeu.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") Set macrdeu = Nothing If Not rs.eof Then tipo_acrdeu = rs("tipo")
144 acrdeu = rs("codigo") i = 9 While i <= 36 If txt(i) <> "" Then For j = i To i + 8 If txt(j) = "" Then txt(j) = "null" txt(j) = Replace(txt(j), ",", ".") Next k = 3 * (i / 9-1) If CDbl(txt(i + 1)) <> 0 Then tipo = mauxiliar.vbuscarcampo("impuestos", "tipo", "codigo_empresa = " & sempresa & " and impuesto = " & txt(i + 1) & "") mregistroiva.update cn, sempresa, sdelegacion, txt(1), txt(2), oculto(k), tipo, tipo_acrdeu, _ acrdeu, txt(i + 1), txt(i), txt(i + 2), txt(i + 3), txt(i + 4), txt(i + 5), susuario If CDbl(txt(i + 6)) <> 0 Then mregistroirpf.update cn, sempresa, sdelegacion, txt(1), txt(2), oculto(k + 2), tipo_acrdeu, _ acrdeu, txt(i + 6), txt(i), txt(i + 7), txt(i + 8), susuario For j = i To i + 8 If txt(j) = "null" Then txt(j) = "" txt(j) = Replace(txt(j), ".", ",") Next i = i + 9 Wend Set mauxiliar = Nothing Set mregistroiva = Nothing Set mregistroirpf = Nothing Sub Private Function insertargridapunte(apunte As Integer, fecha As String, subcuenta As String, debe As Double, haber As Double, concepto As String, tipo As String) As Integer Dim i As Integer Dim j As Integer Dim maxitem As Integer Dim newitem As ListItem maxitem = ListViewApunte.ListItems.Count If apunte = 0 Then j = primerapuntedisponible If apunte > maxitem Then j = maxitem + 1 j = apunte Set newitem = ListViewApunte.ListItems.Add(, "K" & Format(j, " "), Format(j, " ")) newitem.subitems(1) = fecha newitem.subitems(2) = subcuenta newitem.subitems(3) = debe newitem.subitems(4) = haber newitem.subitems(5) = concepto newitem.subitems(6) = tipo
145 While i <= maxitem If Format(i, " ") <= Format(Mid(ListViewApunte.ListItems(i).Key, 2), " ") Then apunteaux = Format(primerApunteDisponible, " ") fechaaux = ListViewApunte.ListItems(i).SubItems(1) subcuentaaux = ListViewApunte.ListItems(i).SubItems(2) debeaux = ListViewApunte.ListItems(i).SubItems(3) haberaux = ListViewApunte.ListItems(i).SubItems(4) conceptoaux = ListViewApunte.ListItems(i).SubItems(5) tipoaux = ListViewApunte.ListItems(i).SubItems(6) ListViewApunte.ListItems.Remove (i) Set newitem = ListViewApunte.ListItems.Add(, "K" & apunteaux, apunteaux) newitem.subitems(1) = fechaaux newitem.subitems(2) = subcuentaaux newitem.subitems(3) = debeaux newitem.subitems(4) = haberaux newitem.subitems(5) = conceptoaux newitem.subitems(6) = tipoaux i = i + 1 Wend Set newitem = ListViewApunte.ListItems.Add(, "K" & Format(j, " "), Format(j, " ")) newitem.subitems(1) = fecha newitem.subitems(2) = subcuenta newitem.subitems(3) = debe newitem.subitems(4) = haber newitem.subitems(5) = concepto newitem.subitems(6) = tipo Call actualizarsaldosasiento ListViewApunte.Refresh insertargridapunte = j Function Private Sub insertartmpapunte() Call eliminargridtipo("p") If partida = "D" Then Call insertargridapunte(0, txt(3), txt(5), txt(6), 0, txt(8), "P") Call insertargridapunte(0, txt(3), txt(5), 0, txt(6), txt(8), "P") Sub Private Sub insertartmpcartera() Dim i As Integer Dim maxi As Integer Dim apunte As Integer Dim parametro As String maxi = ListViewGestionCartera.ListItems.Count If maxi > 0 Then Call eliminargridtipo("gc") For i = 1 To maxi If ListViewGestionCartera.ListItems(i).Text = "C" Then If partida = "D" Then parametro = insertargridapunte(0, txt(3), ListViewGestionCartera.ListItems(i).ListSubItems(4), 0, ListViewGestionCartera.ListItems(i).ListSubItems(5), ListViewGestionCartera.ListItems(i).ListSubItems(6), "GC") parametro = insertargridapunte(0, txt(3), ListViewGestionCartera.ListItems(i).ListSubItems(4), ListViewGestionCartera.ListItems(i).ListSubItems(5), 0, ListViewGestionCartera.ListItems(i).ListSubItems(6), "GC")
146 Next Sub Private Sub insertartmpcontrapartida() If contrapartida <> "" And Val(txt(60)) <> 0 And TabStripApuntes.SelectedItem.Caption = "Contrapartida" Then txt(54) = contrapartida If txt(60) > 0 Then txt(56) = txt(60) txt(55) = -txt(60) txt(57) = txt(8) Call btncontrapartida_click contrapartida = "" Sub Private Sub insertartmpiva() Dim apunte As Integer Dim parametro As String Dim i As Integer Call eliminargridtipo("iva") Call eliminargridtipo("re") Call eliminargridtipo("irpf") For i = 1 To 4 If txt(9 * i + 1) <> "" Then If partida = "D" Then If ctaiva(i - 1) <> "" Then Apunte del IVA oculto(3 * (i - 1)) = insertargridapunte(val(oculto(3 * (i - 1))), txt(3), ctaiva(i - 1), 0, txt(9 * i + 3), txt(8), "IVA") If ctare(i - 1) <> "" Then Apunte RE oculto(3 * (i - 1) + 1) = insertargridapunte(val(oculto(3 * (i - 1) + 1)), txt(3), ctare(i - 1), 0, txt(9 * i + 5), txt(8), "RE") If ctairpf(i - 1) <> "" Then Apunte del IRPF oculto(3 * (i - 1) + 2) = insertargridapunte(val(oculto(3 * (i - 1) + 2)), txt(3), ctairpf(i - 1), txt(9 * i + 8), 0, txt(8), "IRPF") If ctaiva(i - 1) <> "" Then Apunte del IVA oculto(3 * (i - 1)) = insertargridapunte(val(oculto(3 * (i - 1))), txt(3), ctaiva(i - 1), txt(9 * i + 3), 0, txt(8), "IVA") If ctare(i - 1) <> "" Then Apunte del RE oculto(3 * (i - 1) + 1) = insertargridapunte(val(oculto(3 * (i - 1) + 1)), txt(3), ctare(i - 1), txt(9 * i + 5), 0, txt(8), "RE") If ctairpf(i - 1) <> "" Then Apunte del IRPF oculto(3 * (i - 1) + 2) = insertargridapunte(val(oculto(3 * (i - 1) + 2)), txt(3), ctairpf(i - 1), 0, txt(9 * i + 8), txt(8), "IRPF") Next Sub Private Sub ListViewAltaCartera_DblClick() txt(49) = ListViewAltaCartera.SelectedItem.Text
147 txt(50) = ListViewAltaCartera.SelectedItem.SubItems(1) txt(51) = ListViewAltaCartera.SelectedItem.SubItems(2) txt(52) = ListViewAltaCartera.SelectedItem.SubItems(3) txt(53) = txt(53) - txt(51) ListViewAltaCartera.ListItems.Remove ListViewAltaCartera.SelectedItem.Index Sub Private Sub ListViewApunte_DblClick() Dim i As Integer Dim maxi As Integer Dim tipo As String tipo = ListViewApunte.SelectedItem.SubItems(6) If tipo = "P" Then For i = Me.TabStripApuntes.SelectedItem.Index To 1 Step -1 TabStripApuntes.Tabs(i).Selected = True Next If tipo = "IVA" Or tipo = "RE" Or tipo = "IRPF" Then For i = Me.TabStripApuntes.SelectedItem.Index To 2 Step -1 TabStripApuntes.Tabs(i).Selected = True Next If tipo = "GC" Then For i = Me.TabStripApuntes.SelectedItem.Index To 3 Step -1 TabStripApuntes.Tabs(i).Selected = True Next If tipo = "CP" Then txt(54) = ListViewApunte.SelectedItem.SubItems(2) txt(55) = ListViewApunte.SelectedItem.SubItems(3) txt(56) = ListViewApunte.SelectedItem.SubItems(4) txt(57) = ListViewApunte.SelectedItem.SubItems(5) ListViewApunte.ListItems.Remove (ListViewApunte.SelectedItem.Index) Call actualizarsaldosasiento Sub Private Sub modificargridapunte(apunte As Integer, fecha As String, subcuenta As String, debe As Double, haber As Double, concepto As String, tipo As String) Dim newitem As ListItem On Error Resume Next If apunte > 0 And apunte <= ListViewApunte.ListItems.Count Then ListViewApunte.ListItems(apunte).SubItems(1) = fecha ListViewApunte.ListItems(apunte).SubItems(2) = subcuenta ListViewApunte.ListItems(apunte).SubItems(3) = debe ListViewApunte.ListItems(apunte).SubItems(4) = haber ListViewApunte.ListItems(apunte).SubItems(5) = concepto ListViewApunte.ListItems(apunte).SubItems(6) = tipo Call actualizarsaldosasiento ListViewApunte.Refresh Sub Private Sub ListViewGestionCartera_DblClick() If ListViewGestionCartera.ListItems.Count > 0 Then If txt(61).text = "" Then txt(61).text = 0 If ListViewGestionCartera.SelectedItem = "P" Then ListViewGestionCartera.SelectedItem = "C" txt(61).text = CDbl(txt(61).Text) + CDbl(ListViewGestionCartera.SelectedItem.ListSubItems(5).Text) If ListViewGestionCartera.SelectedItem = "C" Then ListViewGestionCartera.SelectedItem = "D" txt(61).text = CDbl(txt(61).Text) + CDbl(ListViewGestionCartera.SelectedItem.ListSubItems(5).Text)
148 If ListViewGestionCartera.SelectedItem = "D" Then ListViewGestionCartera.SelectedItem = "P" txt(61).text = CDbl(txt(61).Text) - CDbl(ListViewGestionCartera.SelectedItem.ListSubItems(5).Text) If txt(6) = 0 Then txt(6).text = txt(61).text ListViewApunte.ListItems(1).SubItems(IIf(partida = "D", 4, 5)) = txt(61).text Sub Private Sub TabStripApuntes_Click() Dim i As Integer Dim msg As String Dim frame As Integer Dim nexttab As Integer Dim previoustab As Integer If FakeNext Then FakeNext = False nexttab = -1 previoustab = -1 For i = PrevTab.Index + 1 To 4 If nexttab < 0 And TabState(i) Then nexttab = i Next For i = PrevTab.Index - 1 To 1 Step -1 If previoustab < 0 And TabState(i) Then previoustab = i Next For i = 2 To 4 If (TabStripApuntes.Tabs(i).Selected And Not TabState(i)) Or (TabStripApuntes.SelectedItem.Index <> nexttab And TabStripApuntes.SelectedItem.Index <> previoustab) Then Si no podemos abrir la pestaña, volvemos a la posicion inicial FakeNext = True TabStripApuntes.SelectedItem = PrevTab Exit Sub Next i msg = datosobligatorios(prevtab.index - 1) Select Case PrevTab.Index - 1 Case 0: If msg = "" Then Call insertartmpapunte Case 1: If msg = "" Then Call insertartmpiva Case 2: If msg = "" Then Call insertartmpcartera Select If msg <> "" Then FakeNext = True TabStripApuntes.SelectedItem = PrevTab MsgBox msg, vbcritical, App.Title frame = TabStripApuntes.SelectedItem.Index - 1 If frame = 2 And (cartera = "P" Or cartera = "C") Then frame = 4 Call mostrarframe(frame) Set PrevTab = TabStripApuntes.SelectedItem Sub Private Sub ToolbarApuntes_ButtonClick(ByVal Button As MSComctlLib.Button) If Me.TabStripApuntes.SelectedItem.Index = 4 Then Select Case Button.Key Case "insertar": If validardatos Then Call insertarasiento Case "modificar": If validardatos Then Call modificarasiento
149 Select If Button.Key = "insertar" Or Button.Key = "modificar" Then MsgBox msgerror(1039), vbcritical, App.Title Select Case Button.Key Case "cancelar": Call cancelardatos Case "filtrar": Call filtrarapunte Case "lupa": Call mostrarlupa(me) Case "borrar": Call eliminarapunte Case "imprimir": Call imprimirapuntes Case "ayudar": Call ayudarapuntes Select Sub Private Sub insertarasiento() Dim ultimo_asiento As Integer ultimo_asiento = 0 Call insertarapunte Call insertariva If cartera <> "N" Then If cartera = "A" Then Call insertarcartera Call cancelarefectos Call cancelardatos Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 123 And Shift = 0 Then sig_click (0) F12 If KeyCode = 122 And Shift = 0 Then ant_click (0) F11 If KeyCode = 121 And Shift = 0 And ToolbarApuntes.Buttons(7).Enabled Then Call mostrarlupa(me) F10 Sub Private Sub txt_lostfocus(index As Integer) Select Case Index Case 1: Call configurarentradaasientos Case 1, 2: If txt(1) <> "" And txt(2) <> "" Then Call cargarasiento Case 5: If txt(5) <> "" And txt(6) <> "" Then Call cargarinformacioncuenta Case 5, 6: If txt(5) <> "" And txt(6) <> "" Then Call cargarinformacioncuenta Case 9, 18, 27, 36: If TabStripApuntes.SelectedItem.Index = 2 Then Call cambiarbase(index) Case 10, 19, 28, 37: If TabStripApuntes.SelectedItem.Index = 2 Then Call cambiarivare(index) Case 15, 24, 33, 42: If TabStripApuntes.SelectedItem.Index = 2 Then Call cambiarirpf(index) Case 12, 21, 30, 39: If TabStripApuntes.SelectedItem.Index = 2 Then Call actualizarsumaiva Case 14, 23, 32, 41: If TabStripApuntes.SelectedItem.Index = 2 Then Call actualizarsumare Case 17, 26, 35, 44: If TabStripApuntes.SelectedItem.Index = 2 Then Call actualizarsumairpf Select Sub Private Sub cargarasiento() Dim pos_iva As Integer Dim pos_irpf As Integer Dim rsapun As Recordset Dim rsiva As Recordset Dim rsirpf As Recordset Dim rscartera As Recordset Dim newitem As ListItem Dim contador_iva As Integer Dim contador_irpf As Integer Dim sumavtos As Double Dim existe As Boolean existe = False
150 pos_iva = 1 pos_irpf = 1 contador_iva = 0 contador_irpf = 0 Set mapuntes = New Apuntes Set rsapun = mapuntes.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(1) & " and numero_documento = " & txt(2) & "", "codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte") Set mauxiliar = New Auxiliar While Not rsapun.eof existe = True If rsapun("tipo") = "P" Then txt(0) = rsapun("codigo_diario"): des(0) = mauxiliar.vbuscarcampo("diarios", "descripcion", "codigo_empresa = " & sempresa & " and codigo_diario = " & txt(0) & "") txt(3) = ddate(rsapun("fecha_apunte")) txt(4) = ddate(rsapun("fecha_documento")) txt(5) = rsapun("cuenta"): des(5) = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " and cuenta = " & txt(5) & "") txt(6) = IIf(partida = "D", rsapun("debe"), rsapun("haber")) txt(7) = Nz(rsApun("referencia"), "") txt(8) = Nz(rsApun("concepto"), "") If rsapun("debe") <> 0 Then Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), rsapun("debe"), 0, Nz(rsApun("concepto"), ""), rsapun("tipo")) Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), 0, rsapun("haber"), Nz(rsApun("concepto"), ""), rsapun("tipo")) If rsapun("tipo") = "IVA" Or rsapun("tipo") = "RE" Or rsapun("tipo") = "IRPF" Then If rsapun("tipo") = "IVA" Then Set mregistroiva = New RegistroIva Set rsiva = mregistroiva.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(1) & " and numero_documento = " & txt(2) & " and numero_apunte = " & rsapun("numero_apunte"), "codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte") If Not rsiva.eof Then txt(3 * pos_iva + 6) = rsiva("base") txt(3 * pos_iva + 7) = rsiva("impuesto") txt(3 * pos_iva + 8) = rsiva("pctiva") txt(3 * pos_iva + 9) = rsiva("iva") txt(3 * pos_iva + 10) = rsiva("pctre") txt(3 * pos_iva + 11) = rsiva("re") If txt(3 * pos_iva + 8) > 0 Then oculto(3 * (contador_iva)) = rsapun("numero_apunte") If txt(3 * pos_iva + 10) > 0 Then oculto(3 * (contador_iva) + 1) = rsapun("numero_apunte") + 1 Call cambiarivare(10 + (9 * contador_iva)) contador_iva = contador_iva + 1 pos_iva = pos_iva + 1 Set mregistroiva = Nothing If rsapun("tipo") = "IRPF" Then Set mregistroirpf = New RegistroIrpf Set rsirpf = mregistroirpf.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(1) & " and numero_documento = " & txt(2) & " and numero_apunte = " & rsapun("numero_apunte"), "codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte") If Not rsirpf.eof Then txt(3 * pos_irpf + 6) = rsirpf("base")
151 txt(3 * pos_irpf + 12) = rsirpf("codigo_irpf") txt(3 * pos_irpf + 13) = rsirpf("pctirpf") txt(3 * pos_irpf + 14) = rsirpf("irpf") If txt(3 * pos_irpf + 13) > 0 Then oculto(3 * (contador_irpf) + 2) = rsapun("numero_apunte") Call cambiarirpf(15 + (9 * contador_iva)) contador_irpf = contador_irpf + 1 pos_irpf = pos_irpf + 1 Set mregistroirpf = Nothing If rsapun("debe") <> 0 Then Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), rsapun("debe"), 0, Nz(rsApun("concepto"), ""), rsapun("tipo")) Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), 0, rsapun("haber"), Nz(rsApun("concepto"), ""), rsapun("tipo")) If rsapun("tipo") = "CP" Then If rsapun("debe") <> 0 Then Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), rsapun("debe"), 0, Nz(rsApun("concepto"), ""), rsapun("tipo")) Call insertargridapunte(rsapun("numero_apunte"), ddate(rsapun("fecha_apunte")), rsapun("cuenta"), 0, rsapun("haber"), Nz(rsApun("concepto"), ""), rsapun("tipo")) rsapun.movenext Wend Set mauxiliar = New Auxiliar Set mapuntes = Nothing Set mregistroiva = Nothing Set mregistroirpf = Nothing If cartera <> "N" Then Set mcartera = New cartera Set rscartera = mcartera.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(1) & " and numero_documento = " & txt(2) & "", "codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, fecha_vto") If cartera = "A" Then While Not rscartera.eof Set newitem = ListViewAltaCartera.ListItems.Add(, "K" & rscartera("tipo") & rscartera("fecha_vto"), rscartera("tipo")) newitem.subitems(1) = ddate(rscartera("fecha_vto")) newitem.subitems(2) = rscartera("importe") newitem.subitems(3) = rscartera("concepto") sumavtos = sumavtos + rscartera("importe") rscartera.movenext Wend txt(53) = Format(sumaVtos, "0.00") If cartera = "C" Or cartera = "P" Then Set mcartera = Nothing Call actualizarsumabase Call actualizarsumaiva Call actualizarsumare
152 Call actualizarsumairpf If existe Then Call bloquearcontroles Call deshabilitarbotones(toolbarapuntes, "insertar") Sub Private Sub bloquearcontroles() Dim i As Integer For i = 0 To 4 Me.frmAsiento(i).Enabled = False Next For i = 0 To 3 Me.ant(i).Enabled = True Me.sig(i).Enabled = True Next Sub Private Sub desbloquearcontroles() Dim i As Integer For i = 0 To 4 Me.frmAsiento(i).Enabled = True Next Sub Private Function validardatos() As Boolean Dim msg As String msg = "" validardatos = True If sdate(txt(3)) < sinicioejercicio Or sdate(txt(3)) > sfinalejercicio Then Compruebo que la fecha esta entre los limites del ejercicio msg = msgerror(1027) If (sdate(txt(3)) < siniciobloqueo Or sdate(txt(3)) > sfinalbloqueo) And siniciobloqueo <> "" And sfinalbloqueo <> "" Then Compruebo que la fecha esta entre los limites del bloqueo msg = msgerror(1029) If Nz(txt(60), 0) <> 0 Then Compruebo si el asiento esta cuadrado msg = msgerror(1028) If msg <> "" Then MsgBox msg, vbcritical, App.Title validardatos = False Function Private Function primerapuntedisponible() As Integer Dim i As Integer Dim maxi As Integer Dim trobat As Boolean Dim clau As String i = 1 trobat = False maxi = ListViewApunte.ListItems.Count If maxi = 0 Then primerapuntedisponible = 1 On Error Resume Next While i <= maxi And Not trobat clau = ListViewApunte.ListItems("K" & Format(i, " ")).Key If Err.Number = Then trobat = True i = i + 1 Wend
153 primerapuntedisponible = i Function Private Sub eliminargridtipo(tipo As String) Dim i As Integer Dim maxitem As Integer maxitem = ListViewApunte.ListItems.Count For i = maxitem To 1 Step -1 If ListViewApunte.ListItems(i).SubItems(6) = tipo Then ListViewApunte.ListItems.Remove (i) Next Sub Private Sub modificarasiento() Call modificarapunte MsgBox "Si es necesario, debe modificar la cartera i el registro de IVA manualmente.", vbinformation + vbokonly, App.Title Call cancelardatos Sub Private Sub modificarapunte() Dim i As Integer Set mapunte = New Apuntes For i = 1 To ListViewApunte.ListItems.Count ListViewApunte.ListItems(i).SubItems(3) = Replace(ListViewApunte.ListItems(i).SubItems(3), ",", ".") ListViewApunte.ListItems(i).SubItems(4) = Replace(ListViewApunte.ListItems(i).SubItems(4), ",", ".") If ListViewApunte.ListItems(i).SubItems(6) = "P" Then Modifico el apunte de la partida mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "P", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "IVA" Then Modifico el apunte del iva mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "IVA", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "RE" Then Modifico el apunte del re mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "RE", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "IRPF" Then Modifico el apunte del irpf mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "IRPF", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "CP" Then Modifico el apunte de la contrapartida mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "CP", "", susuario If ListViewApunte.ListItems(i).SubItems(6) = "GC" Then Modifico el apunte de gestio de cartera
154 mapunte.update cn, sempresa, sdelegacion, txt(1), txt(2), ListViewApunte.ListItems(i).Text, txt(0), _ txt(3), txt(4), txt(7), ListViewApunte.ListItems(i).SubItems(2), ListViewApunte.ListItems(i).SubItems(5), _ ListViewApunte.ListItems(i).SubItems(3), ListViewApunte.ListItems(i).SubItems(4), "GC", "", susuario ListViewApunte.ListItems(i).SubItems(3) = Replace(ListViewApunte.ListItems(i).SubItems(3), ".", ",") ListViewApunte.ListItems(i).SubItems(4) = Replace(ListViewApunte.ListItems(i).SubItems(4), ".", ",") Next Set mapunte = Nothing Sub
155 33. frmasientos.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx" Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" Begin VB.Form frmasientos Caption = "Asientos" ClientHeight = 4845 ClientLeft = 60 ClientTop = 345 ClientWidth = LinkTopic = "frmasientos" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 323 ScaleMode = 3 Pixel ScaleWidth = 822 Tag = "ToolbarAsientos" Begin MSDataGridLib.DataGrid DataGridApuntes Bindings = "frmasientos.frx":0000 Height = 495 Left = 0 TabIndex = 12 Top = 3000 Width = _ExtentX = _ExtentY = 873 _Version = AllowUpdate = -1 True AllowArrows = -1 True ColumnHeaders = 0 False HeadLines = 1 RowHeight = 15 TabAction = 1 WrapCellPointer = -1 True RowDividerStyle = 1 FormatLocked = -1 True AllowAddNew = -1 True AllowDelete = -1 True BeginProperty HeadFont {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ColumnCount = 11 BeginProperty Column00 DataField = "codigo_documento" Caption = "codigo_documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column
156 DataField = "numero_documento" Caption = "numero_documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column02 DataField = "numero_apunte" Caption = "numero_apunte" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "0" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column03 DataField = "codigo_diario" Caption = "codigo_diario" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column04 DataField = "fecha_apunte" Caption = "fecha_apunte" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "dd/mm/yyyy" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column05 DataField = "fecha_documento" Caption = "fecha_documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "dd/mm/yyyy" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column06 DataField = "referencia" Caption = "referencia" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property
157 BeginProperty Column07 DataField = "cuenta" Caption = "cuenta" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column08 DataField = "concepto" Caption = "concepto" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column09 DataField = "debe" Caption = "debe" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "#.##0,00" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column10 DataField = "haber" Caption = "haber" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "#.##0,00" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property SplitCount = 1 BeginProperty Split0 BeginProperty Column00 ColumnWidth = 96,983 Property BeginProperty Column01 ColumnWidth = 98,003 Property BeginProperty Column02 ColumnWidth = 74,986 Property BeginProperty Column03 ColumnWidth = 63,987 Property BeginProperty Column04 ColumnWidth = 85,984 Property BeginProperty Column05 ColumnWidth = 87,005 Property BeginProperty Column06 ColumnWidth = 115,994 Property BeginProperty Column07 ColumnWidth = 85,
158 Property BeginProperty Column08 ColumnWidth = 115,994 Property BeginProperty Column09 ColumnWidth = 115,994 Property BeginProperty Column10 ColumnWidth = 115,994 Property Property Begin MSDataGridLib.DataGrid DataGridAsientos Bindings = "frmasientos.frx":001b Height = 2775 Left = 0 TabIndex = 1 TabStop = 0 False Top = 480 Width = _ExtentX = _ExtentY = 4895 _Version = AllowUpdate = 0 False AllowArrows = -1 True HeadLines = 1 RowHeight = 15 TabAcrossSplits = -1 True TabAction = 2 WrapCellPointer = -1 True RowDividerStyle = 1 FormatLocked = -1 True AllowDelete = -1 True BeginProperty HeadFont {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ColumnCount = 11 BeginProperty Column00 DataField = "codigo_documento" Caption = "Código Documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column01 DataField = "numero_documento" Caption = "Número Documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType =
159 Property Property BeginProperty Column02 DataField = "numero_apunte" Caption = "Apunte" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "0" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 1 Property Property BeginProperty Column03 DataField = "codigo_diario" Caption = "Diario" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "0" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 1 Property Property BeginProperty Column04 DataField = "fecha_apunte" Caption = "Fecha Apunte" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "dd/mm/yyyy" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 3 Property Property BeginProperty Column05 DataField = "fecha_documento" Caption = "Fecha Documento" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "dd/mm/yyyy" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 3 Property Property BeginProperty Column06 DataField = "referencia" Caption = "Referencia" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column07 DataField = "cuenta" Caption = "Cuenta" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID =
160 SubFormatType = 0 Property Property BeginProperty Column08 DataField = "concepto" Caption = "Concepto" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 0 Format = "" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 0 Property Property BeginProperty Column09 DataField = "debe" Caption = "Debe" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "#.##0,00" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 1 Property Property BeginProperty Column10 DataField = "haber" Caption = "Haber" BeginProperty DataFormat {6D B-11D A0C91110ED} Type = 1 Format = "#.##0,00" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 3082 SubFormatType = 1 Property Property SplitCount = 1 BeginProperty Split0 BeginProperty Column00 ColumnWidth = 96 Property BeginProperty Column01 ColumnWidth = 100,006 Property BeginProperty Column02 ColumnWidth = 74,986 Property BeginProperty Column03 ColumnWidth = 63,987 Property BeginProperty Column04 ColumnWidth = 84,019 Property BeginProperty Column05 ColumnWidth = 87,005 Property BeginProperty Column06 ColumnWidth = 115,994 Property BeginProperty Column07 ColumnWidth = 85,984 Property BeginProperty Column08 ColumnWidth = 115,994 Property BeginProperty Column09 Alignment = 1 ColumnWidth = 115,994 Property BeginProperty Column10 Alignment =
161 ColumnWidth = 115,994 Property Property Begin MSAdodcLib.Adodc AdodcAsientos Height = 375 Left = 0 Top = 2880 Width = _ExtentX = _ExtentY = 661 ConnectMode = 0 CursorLocation = 3 IsolationLevel = -1 ConnectionTimeout= 15 CommandTimeout = 30 CursorType = 3 LockType = 3 CommandType = 2 CursorOptions = 0 CacheSize = 50 MaxRecords = 0 BOFAction = 0 EOFAction = 0 ConnectStringType= 2 Appearance = 1 BackColor = ForeColor = Orientation = 0 Enabled = -1 Connect = "FILE NAME=D:\Projecte\Font\Temporal.udl" OLEDBString = "" OLEDBFile = "D:\Projecte\Font\Temporal.udl" DataSourceName = "" OtherAttributes = "" UserName = "" Password = "" RecordSource = "Asientos" Caption = "" BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property _Version = Begin MSComctlLib.ImageList ImageListAsientos Left = 75 Top = 7560 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarAsientos Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarAsientos" Top = 0 Width = _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSAdodcLib.Adodc AdodcApuntes Height = 375 Left = 0 Top =
162 Width = _ExtentX = _ExtentY = 661 ConnectMode = 0 CursorLocation = 3 IsolationLevel = -1 ConnectionTimeout= 15 CommandTimeout = 30 CursorType = 3 LockType = 3 CommandType = 2 CursorOptions = 0 CacheSize = 50 MaxRecords = 0 BOFAction = 0 EOFAction = 0 ConnectStringType= 2 Appearance = 1 BackColor = ForeColor = Orientation = 0 Enabled = -1 Connect = "FILE NAME=D:\Projecte\Font\Temporal.udl" OLEDBString = "" OLEDBFile = "D:\Projecte\Font\Temporal.udl" DataSourceName = "" OtherAttributes = "" UserName = "" Password = "" RecordSource = "Apuntes" Caption = "" BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property _Version = Begin VB.Label des Alignment = 1 Right Justify BorderStyle = 1 Fixed Single Index = 4 Left = TabIndex = 11 Top = 4440 Width = 1575 Begin VB.Label des Alignment = 1 Right Justify BorderStyle = 1 Fixed Single Index = 3 Left = TabIndex = 10 Top = 4080 Width = 1575 Begin VB.Label des Alignment = 1 Right Justify BorderStyle = 1 Fixed Single Index = 2 Left = TabIndex = 9 Top = 3720 Width = 1575 Begin VB.Label des Alignment = 1 Right Justify BorderStyle = 1 Fixed Single Index =
163 Left = 1440 TabIndex = 8 Top = 4080 Width = 1575 Begin VB.Label des BorderStyle = 1 Fixed Single Index = 0 Left = 1440 TabIndex = 7 Top = 3720 Width = 7575 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Saldo acumulado:" Height = 255 Index = 1 Left = 0 TabIndex = 6 Top = 4080 Width = 1335 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Saldo:" Height = 255 Index = 4 Left = 9600 TabIndex = 5 Top = 4440 Width = 975 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Suma Haber:" Height = 255 Index = 3 Left = 9600 TabIndex = 4 Top = 4080 Width = 975 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Título cuenta:" Height = 255 Index = 0 Left = 0 TabIndex = 3 Top = 3720 Width = 1335 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Suma Debe:" Height = 255 Index = 2 Left = 9600 TabIndex = 2 Top = 3720 Width = 975 Attribute VB_Name = "frmasientos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim ultimo_codigo_documento As String Dim ultimo_numero_documento As String Dim ultimo_numero_apunte As Integer Dim ultimo_codigo_diario As Integer Dim ultima_fecha_apunte As Date
164 Dim ultima_fecha_documento As Date Dim ultima_cuenta As String Dim ultimo_concepto As String Dim CurrentCol As Integer Dim CurrentRow As Integer Dim mauxiliar As Auxiliar Dim masientos As Asientos Dim mnumeracion As numeracion Private Sub Copia_Recordset(rsO As Recordset, rsd As Recordset) Dim i As Integer While Not rso.eof rsd.addnew For i = 1 To rso.fields.count rsd.fields(i - 1).Value = rso.fields(i - 1).Value Next rsd.update Wend Sub Private Sub Borra_Recordset(rs As Recordset) If Not rs.eof Then rs.movefirst While Not rs.eof rs.delete rs.movenext Wend Sub Private Sub AyudarAsientos() Sub Private Sub cancelardatos() Sub Call Borra_Recordset(Me.AdodcAsientos.Recordset) Call Borra_Recordset(Me.AdodcApuntes.Recordset) Me.DataGridAsientos.Refresh Me.DataGridApuntes.Refresh Private Sub EliminarAsiento() Dim rpta As Integer Dim aux As String On Error GoTo EliminarAsientoError If ultimo_codigo_documento <> "" And ultimo_numero_documento <> "" Then rpta = MsgBox(" Desea eliminar el asiento " & ultimo_numero_documento & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set masientos = New Asientos masientos.delete cn, sempresa, sempresa, sdelegacion, ultimo_codigo_documento, 0 Set masientos = Nothing Call cancelardatos Call cancelardatos Exit Sub EliminarAsientoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarAsiento() Sub Private Sub DataGridApuntes_AfterInsert()
165 Me.DataGridApuntes.Refresh Me.DataGridAsientos.Refresh Sub Private Sub DataGridApuntes_RowColChange(LastRow As Variant, ByVal LastCol As Integer) Call DataGridApuntes_Scroll(False) Sub Private Sub DataGridApuntes_Scroll(Cancel As Integer) DataGridAsientos.LeftCol = DataGridApuntes.LeftCol Sub Private Sub DataGridAsientos_AfterDelete() Call Actualizar_saldos_asiento Sub Private Sub DataGridAsientos_AfterInsert() Call Actualizar_saldos_asiento Sub Private Sub DataGridAsientos_AfterUpdate() Call Actualizar_saldos_asiento Sub Private Sub DataGridAsientos_ColResize(ByVal ColIndex As Integer, Cancel As Integer) DataGridApuntes.Columns(ColIndex).Width = DataGridAsientos.Columns(ColIndex).Width Sub Private Sub DataGridAsientos_GotFocus() If CurrentCol < 0 Then Exit Sub With Me.DataGridApuntes Activamos la lupa si la columna la tiene activada cuando cargamos un asiento Select Case.Columns(CurrentCol).DataField Case "codigo_documento":.tag = "DOCUMENTOS.codigo_documento" Case "codigo_diario":.tag = "DIARIOS.codigo_diario" Case "cuenta":.tag = "CUENTAS.cuenta" Case :.tag = "" Select Me.ToolbarAsientos.Buttons(7).Enabled = (.tag <> "") With Sub Private Sub DataGridAsientos_Scroll(Cancel As Integer) DataGridApuntes.LeftCol = DataGridAsientos.LeftCol Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmasientos = Forms(i) Next Call limatges16(me.imagelistasientos) Set Me.ToolbarAsientos.ImageList = Me.ImageListAsientos Call cargarbotonera(me.toolbarasientos) Call deshabilitarbotones(me.toolbarasientos, "filtrar", "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini"
166 Configuración de los controles Me.AdodcAsientos.ConnectionString = cnt.connectionstring Me.AdodcAsientos.RecordSource = "SELECT * FROM Asientos" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.DataGridAsientos For i = 1 To.Columns.Count.Columns(i - 1).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.Columns(i - 1).Width) Next With Call DataGridApuntes_Format Sub Private Sub DataGridApuntes_Format() Dim i As Integer For i = 1 To DataGridAsientos.Columns.Count DataGridApuntes.Columns(i - 1).Width = DataGridAsientos.Columns(i - 1).Width Next Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.DataGridAsientos For i = 1 To.Columns.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.Columns(i - 1).Width Next With Sub Private Sub ImprimirAsientos() Sub Private Sub insertarasiento() Sub Private Sub ListarAsientos(Optional strwhere As String) Sub Private Sub modificarasiento() Sub Private Sub ToolbarAsientos_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call insertarasiento Case "modificar": If validardatos Then Call modificarasiento Case "filtrar": Call FiltrarAsiento Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarAsiento Case "listar": Call ListarAsientos Case "imprimir": Call ImprimirAsientos
167 Case "ayudar": Call AyudarAsientos Select Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function Private Sub DataGridAsientos_OnAddNew() Contador de apuntes ultimo_numero_apunte = ultimo_numero_apunte + 1 Sub Private Sub DataGridAsientos_RowColChange(LastRow As Variant, ByVal LastCol As Integer) Columna y fila actual CurrentCol = Me.DataGridAsientos.col CurrentRow = Me.DataGridAsientos.Row Sub Controlo cuando entramos en una celda del datagrid Call Control_de_Entrada(CurrentCol) Controlo cuando salimos de una celda del datagrid Call Control_de_Salida(LastCol) Private Sub Control_de_Entrada(columna As Integer) If columna < 0 Then Exit Sub On Error Resume Next With Me.DataGridApuntes If.Columns(columna).Text = "" Then If.Columns.Count > 1 Then Select Case.Columns(columna).DataField Case "codigo_documento":.columns(columna).text = ultimo_codigo_documento Case "numero_documento":.columns(columna).text = ultimo_numero_documento Case "numero_apunte":.columns(columna).text = ultimo_numero_apunte Case "codigo_diario":.columns(columna).text = ultimo_codigo_diario Case "fecha_apunte":.columns(columna).text = ultima_fecha_apunte Case "fecha_documento":.columns(columna).text = ultima_fecha_documento Case "referencia":.columns(columna).text = "" Case "cuenta":.columns(columna).text = "" Case "concepto":.columns(columna).text = ultimo_concepto Case "debe": If CDbl(Nz(des(4).Caption, 0)) > 0 Then.Columns(columna).Text = 0.Columns(columna).Text = CDbl(Nz(des(4).Caption, 0)) Case "haber" If CDbl(Nz(des(4).Caption, 0)) > 0 Then.Columns(columna).Text = CDbl(Nz(des(4).Caption, 0)).Columns(columna).Text = 0 Select Select Case.Columns(columna).DataField Case "codigo_documento":
168 .Columns(columna).Text = "" Case "numero_documento":.columns(columna).text = "" Case "numero_apunte":.columns(columna).text = ultimo_numero_apunte Case "codigo_diario":.columns(columna).text = "" Case "fecha_apunte":.columns(columna).text = Date Case "fecha_documento":.columns(columna).text = Date Case "referencia":.columns(columna).text = "" Case "cuenta":.columns(columna).text = "" Case "concepto":.columns(columna).text = "" Case "debe":.columns(columna).text = 0 Case "haber".columns(columna).text = 0 Select Activamos la lupa si la columna la tiene activada Select Case.Columns(CurrentCol).DataField Case "codigo_documento":.tag = "DOCUMENTOS.codigo_documento" Case "codigo_diario":.tag = "DIARIOS.codigo_diario" Case "cuenta":.tag = "CUENTAS.cuenta" Case :.tag = "" Select Me.ToolbarAsientos.Buttons(7).Enabled = (.tag <> "") With Sub Private Sub Control_de_Salida(columna As Integer) If columna < 0 Then Exit Sub On Error Resume Next With Me.DataGridApuntes If.Columns(columna).Text = "" Then Select Case.Columns(columna).DataField Case "codigo_documento":.columns(columna).text = ultimo_codigo_documento Case "numero_documento":.columns(columna).text = ultimo_numero_documento Case "numero_apunte":.columns(columna).text = ultimo_numero_apunte Case "codigo_diario":.columns(columna).text = ultimo_codigo_diario Case "fecha_apunte":.columns(columna).text = ultima_fecha_apunte Case "fecha_documento":.columns(columna).text = ultima_fecha_documento Case "referencia":.columns(columna).text = "" Case "cuenta":.columns(columna).text = "" Case "concepto":.columns(columna).text = ultimo_concepto Case "debe": If CDbl(Nz(des(4).Caption, 0)) > 0 Then.Columns(columna).Text = 0.Columns(columna).Text = CDbl(des(4).Caption) Case "haber" If CDbl(Nz(des(4).Caption, 0)) > 0 Then.Columns(columna).Text = CDbl(des(4).Caption)
169 .Columns(columna).Text = 0 Select Select Case.Columns(columna).DataField Case "codigo_documento": ultimo_codigo_documento =.Columns(columna).Text Case "numero_documento": ultimo_numero_documento =.Columns(columna).Text Case "numero_apunte": ultimo_numero_apunte =.Columns(columna).Text Case "codigo_diario": ultimo_codigo_diario =.Columns(columna).Text Case "fecha_apunte": ultima_fecha_apunte =.Columns(columna).Text Case "fecha_documento": ultima_fecha_documento =.Columns(columna).Text Case "cuenta":.columns(columna).text = transformarcuenta(.columns(columna).text, icuenta) If ultima_cuenta <>.Columns(columna).Text Then Call Mostrar_datos_cuenta(.Columns(columna).Text) ultima_cuenta =.Columns(columna).Text Case "concepto": ultimo_concepto =.Columns(columna).Text Select With Sub Private Sub Mostrar_datos_cuenta(cuenta As String) Set mauxiliar = New Auxiliar des(0).caption = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & cuenta & "") des(1).caption = Format(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)-SUM(haber) AS saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND cuenta = " & cuenta & "", 0), "#,##0.00") Set mauxiliar = Nothing Sub Private Sub Actualizar_saldos_asiento() Set mauxiliar = New Auxiliar des(2).caption = Format(mAuxiliar.vBuscarCampoTemporal("Apuntes", "SUM(debe) AS debe", "1 = 1", 0), "#,##0.00") des(3).caption = Format(mAuxiliar.vBuscarCampoTemporal("Apuntes", "SUM(haber) AS haber", "1 = 1", 0), "#,##0.00") des(4).caption = Format(CDbl(Nz(des(2).Caption, 0)) - CDbl(Nz(des(3).Caption, 0)), "#,##0.00") Set mauxiliar = Nothing Sub
170 34. frmbalancepyg.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmbalancepyg Caption = "Balance de Pérdidas y Ganáncias" ClientHeight = 1515 ClientLeft = 60 ClientTop = 450 ClientWidth = 6150 LinkTopic = "frmbalancepyg" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 1515 ScaleWidth = 6150 Tag = "ToolbarBalancePyG" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 675 Left = 0 TabIndex = 0 Top = 360 Width = 6135 Begin VB.TextBox txt Index = 1 Left = 4515 TabIndex = 4 Top = 240 Width = 1500 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 3 Top = 225 Width = 1500 Begin VB.Label lbl Caption = "Fecha final:" Height = 255 Index = 1 Left = 3195 TabIndex = 5 Top = 240 Width = 1125 Begin VB.Label lbl Caption = "Fecha inicial:" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 1125 Begin MSComctlLib.Toolbar ToolbarBalancePyG Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCuentas"
171 Top = 0 Width = 6150 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListBalancePyG Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 0 TabIndex = 6 Top = 1080 Width = 6135 _ExtentX = _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Attribute VB_Name = "frmbalancepyg" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim mpergan As Pergan Dim a_act(1 To 6) As Double Dim a_ant(1 To 6) As Double Dim b_act(1 To 6) As Double Dim b_ant(1 To 6) As Double Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudarbalancepyg() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load()
172 Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmbalancepyg = Forms(i) Next Call limatges16(me.imagelistbalancepyg) Set Me.ToolbarBalancePyG.ImageList = Me.ImageListBalancePyG Call cargarbotonera(me.toolbarbalancepyg) Call deshabilitarbotones(me.toolbarbalancepyg, "insertar", "modificar", "lupa", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarBalancePyG_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirbalancepyg Case "ayudar": Call ayudarbalancepyg Select Sub Private Function obtenerdatos() As Object Dim rs As ADODB.Recordset Set mpergan = New Pergan Set rs = mpergan.getlist(cn, "codigo_empresa = " & sempresa & "") Set mpergan = Nothing Set obtenerdatos = rs Function Private Sub imprimirbalancepyg() Dim rs As ADODB.Recordset Set rs = obtenerdatos() If Not rs.eof Then Call guardartemporalbalancepyg(rs) Call obtenersaldosgruposbalancepyg Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Sub guardartemporalbalancepyg(rs As ADODB.Recordset) Dim fini As String Dim ffin As String Dim finiant As String
173 Dim ffinant As String Dim rst As ADODB.Recordset If txt(0) = "" Then fini = sinicioejercicio ffin = sfinalejercicio fini = sdate(txt(0)) ffin = sdate(txt(1)) finiant = sdate(dateadd("yyyy", -1, ddate(fini))) ffinant = sdate(dateadd("yyyy", -1, ddate(ffin))) Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.execute "DELETE FROM BalancePyG" Set rst = New ADODB.Recordset rst.open "SELECT * FROM BalancePyG", cnt, adopenstatic, adlockoptimistic cnt.begintrans Set mauxiliar = New Auxiliar While Not rs.eof rst.addnew rst("dh") = rs("dh") rst("nivel_1") = rs("nivel_1") rst("nivel_2") = rs("nivel_2") rst("nivel_3") = rs("nivel_3") rst("nivel_4") = rs("nivel_4") rst("titulo") = rs("titulo") If Nz(rs("cuentas"), "") <> "" Then rst("cuentas") = cuentasgrupo((rs("cuentas"))) rst("saldo") = saldocuentas(rs("dh"), rs("cuentas"), fini, ffin) rst("saldo_ant") = saldocuentas(rs("dh"), rs("cuentas"), finiant, ffinant) rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend Set mauxiliar = Nothing rst.close cnt.committrans Set rst = Nothing Sub Private Sub obtenersaldosgruposbalancepyg() Dim i As Integer Dim rst As ADODB.Recordset For i = 1 To 6 a_act(i) = 0 a_ant(i) = 0 b_act(i) = 0 b_ant(i) = 0 Next Set rst = New ADODB.Recordset rst.open "SELECT * FROM BalancePyG", cnt, adopenstatic, adlockoptimistic While Not rst.eof If rst("dh") = "D" Then If rst("nivel_1") = 1 Then If rst("nivel_2") = 0 Then a_act(1) = a_act(1) - rst("saldo") a_ant(1) = a_ant(1) - rst("saldo_ant") b_act(1) = b_act(1) + rst("saldo") b_ant(1) = b_ant(1) + rst("saldo_ant")
174 If rst("nivel_2") = 1 Then a_act(2) = a_act(2) - rst("saldo") a_ant(2) = a_ant(2) - rst("saldo_ant") b_act(2) = b_act(2) + rst("saldo") b_ant(2) = b_ant(2) + rst("saldo_ant") If rst("nivel_2") = 3 Then a_act(4) = a_act(4) - rst("saldo") a_ant(4) = a_ant(4) - rst("saldo_ant") b_act(4) = b_act(4) + rst("saldo") b_ant(4) = b_ant(4) + rst("saldo_ant") If rst("nivel_2") = 5 Then a_act(6) = a_act(6) - rst("saldo") a_ant(6) = a_ant(6) - rst("saldo_ant") If rst("nivel_1") = 1 Then If rst("nivel_2") = 0 Then a_act(1) = a_act(1) + rst("saldo") a_ant(1) = a_ant(1) + rst("saldo_ant") b_act(1) = b_act(1) - rst("saldo") b_ant(1) = b_ant(1) - rst("saldo_ant") If rst("nivel_2") = 1 Then a_act(2) = a_act(2) + rst("saldo") a_ant(2) = a_ant(2) + rst("saldo_ant") b_act(2) = b_act(2) - rst("saldo") b_ant(2) = b_ant(2) - rst("saldo_ant") If rst("nivel_2") = 3 Then a_act(4) = a_act(4) + rst("saldo") a_ant(4) = a_ant(4) + rst("saldo_ant") b_act(4) = b_act(4) - rst("saldo") b_ant(4) = b_ant(4) - rst("saldo_ant") If rst("nivel_2") = 4 Then b_act(5) = b_act(5) - rst("saldo") b_ant(5) = b_ant(5) - rst("saldo_ant") If rst("nivel_2") = 5 Then b_act(6) = b_act(6) - rst("saldo") b_ant(6) = b_ant(6) - rst("saldo_ant") rst.movenext Wend rst.close Set rst = Nothing If a_act(1) < 0 Then a_act(1) = 0 If a_act(2) < 0 Then a_act(2) = 0 If a_act(4) < 0 Then a_act(4) = 0 If b_act(1) < 0 Then b_act(1) = 0 If b_act(2) < 0 Then b_act(2) = 0 If b_act(4) < 0 Then b_act(4) = 0 a_act(3) = a_act(1) + a_act(2) - b_act(1) - b_act(2) a_ant(3) = a_ant(1) + a_ant(2) - b_ant(1) - b_ant(2) b_act(3) = b_act(1) + b_act(2) - a_act(1) - a_act(2) b_ant(3) = b_ant(1) + b_ant(2) - a_ant(1) - a_ant(2) If a_act(3) < 0 Then a_act(3) = 0 If b_act(3) < 0 Then b_act(3) = 0 a_act(5) = a_act(3) + a_act(4) - b_act(3) - b_act(4) a_ant(5) = a_ant(3) + a_ant(4) - b_ant(3) - b_ant(4) b_act(5) = b_act(3) + b_act(4) - a_act(3) - a_act(4) b_ant(5) = b_ant(3) + b_ant(4) - a_ant(3) - a_ant(4) If a_act(5) < 0 Then a_act(5) = 0 If b_act(5) < 0 Then a_act(5) = 0 b_act(6) = b_act(5) - a_act(6) b_ant(6) = b_ant(5) - a_ant(6) a_act(6) = a_act(5) + a_act(6) a_ant(6) = a_ant(5) + a_ant(6)
175 If b_act(6) < 0 Then b_act(6) = 0 If b_act(6) < 0 Then b_act(6) = 0 Sub Private Sub imprimir() Dim periodo As String Dim empresa As String periodo = "del " & IIf(txt(0) <> "", txt(0), ddate(sinicioejercicio)) & " al " & IIf(txt(1) <> "", txt(1), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("balancepygabreviado.rpt", "Balance de pérdidas y ganancias abreviado", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "", _ "A1=" & a_act(1), "A2=" & a_act(2), "A3=" & a_act(3), "A4=" & a_act(4), "A5=" & a_act(5), "A6=" & a_act(6), _ "AA1=" & a_ant(1), "AA2=" & a_ant(2), "AA3=" & a_ant(3), "AA4=" & a_ant(4), "AA5=" & a_ant(5), "AA6=" & a_ant(6), _ "B1=" & b_act(1), "B2=" & b_act(2), "B3=" & b_act(3), "B4=" & b_act(4), "B5=" & b_act(5), "B6=" & b_act(6), _ "BB1=" & b_ant(1), "BB2=" & b_ant(2), "BB3=" & b_ant(3), "BB4=" & b_ant(4), "BB5=" & b_ant(5), "BB6=" & b_ant(6)) minformes.obj.sqlquery = "SELECT * FROM BalancePyG ORDER BY dh, nivel_1, nivel_2, nivel_3, nivel_4" Call minformes.execute Set minformes = Nothing Sub Private Function cuentasgrupo(byval cuentas As String) Dim cuenta As String Dim pos As Integer Dim aux As String aux = "" While Len(cuentas) > 0 pos = InStr(1, cuentas, ",") - 1 If pos > 0 Then cuenta = Trim(Left(cuentas, pos)) cuentas = Mid(cuentas, InStr(1, cuentas, ",") + 1) cuenta = cuentas cuentas = "" If Left(cuenta, 1) = "?" Then cuenta = Mid(cuenta, 2) aux = aux & cuenta & ", " Wend cuentasgrupo = Left(aux, Len(aux) - 2) Function Private Function saldocuentas(byval dh As String, ByVal cuentas As String, ByVal fini As String, ByVal ffin As String) As Double Dim pos As Integer Dim cuenta As String Dim cuentaaux As String Dim strwhere As String Dim saldo As Double Dim saldoac As Double
176 saldo = 0 strwhere = "" saldoac = 0 While Len(cuentas) > 0 pos = InStr(1, cuentas, ",") - 1 If pos > 0 Then cuenta = Trim(Left(cuentas, pos)) cuentas = Mid(cuentas, InStr(1, cuentas, ",") + 1) cuenta = cuentas cuentas = "" If Left(cuenta, 1) <> "?" And Left(cuenta, 1) <> "(" Then strwhere = strwhere & "cuenta LIKE " & cuenta & "% OR " If Left(cuenta, 1) = "?" Then Cuenta que esta en Activo y Pasivo cuentaaux = Mid(cuenta, 2) Set mauxiliar = New Auxiliar saldo = CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)-SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND cuenta LIKE " & cuentaaux & "%", 0)) Set mauxiliar = Nothing If (saldo > 0 And dh = "H") Or (saldo < 0 And dh = "D") Then saldo = 0 Cuenta con signo cambiado cuentaaux = Mid(cuenta, 2, Len(cuenta) - 2) Set mauxiliar = New Auxiliar saldo = CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)-SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND cuenta LIKE " & cuentaaux & "%", 0)) Set mauxiliar = Nothing saldo = -saldo saldoac = saldoac + saldo Wend If strwhere <> "" Then strwhere = "(" & Left(strWhere, Len(strWhere) - 4) & ")" Set mauxiliar = New Auxiliar saldocuentas = saldoac + CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)- SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND " & strwhere, 0)) Set mauxiliar = Nothing saldocuentas = saldoac Function Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 0, 1: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) If sdate(txt(index)) < sinicioejercicio Or sdate(txt(index)) > sfinalejercicio Then msg = msgerror(1027) Select
177 Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
178 35. frmbalancesituacion.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmbalancesituacion Caption = "Balance de Situación" ClientHeight = 1515 ClientLeft = 60 ClientTop = 450 ClientWidth = 6150 LinkTopic = "frmbalancesituacion" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 1515 ScaleWidth = 6150 Tag = "ToolbarBalanceSituacion" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 675 Left = 0 TabIndex = 0 Top = 360 Width = 6135 Begin VB.TextBox txt Index = 1 Left = 4515 TabIndex = 4 Top = 240 Width = 1500 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 3 Top = 225 Width = 1500 Begin VB.Label lbl Caption = "Fecha final:" Height = 255 Index = 1 Left = 3195 TabIndex = 5 Top = 240 Width = 1125 Begin VB.Label lbl Caption = "Fecha inicial:" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 1125 Begin MSComctlLib.Toolbar ToolbarBalanceSituacion Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCuentas" Top =
179 Width = 6150 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListBalanceSituacion Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 0 TabIndex = 6 Top = 1080 Width = 6135 _ExtentX = _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Attribute VB_Name = "frmbalancesituacion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim msituacion As Situacion Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudarbalancesituacion() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmbalancesituacion = Forms(i)
180 Next Call limatges16(me.imagelistbalancesituacion) Set Me.ToolbarBalanceSituacion.ImageList = Me.ImageListBalanceSituacion Call cargarbotonera(me.toolbarbalancesituacion) Call deshabilitarbotones(me.toolbarbalancesituacion, "insertar", "modificar", "lupa", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarBalanceSituacion_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirbalancesituacion Case "ayudar": Call ayudarbalancesituacion Select Sub Private Function obtenerdatos() As Object Dim rs As ADODB.Recordset Set msituacion = New Situacion Set rs = msituacion.getlist(cn, "codigo_empresa = " & sempresa & "") Set msituacion = Nothing Set obtenerdatos = rs Function Private Sub imprimirbalancesituacion() Dim rs As ADODB.Recordset Set rs = obtenerdatos() If Not rs.eof Then Call guardartemporalbalancesituacion(rs) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Sub guardartemporalbalancesituacion(rs As ADODB.Recordset) Dim fini As String Dim ffin As String Dim finiant As String Dim ffinant As String Dim rst As ADODB.Recordset If txt(0) = "" Then fini = sinicioejercicio ffin = sfinalejercicio
181 fini = sdate(txt(0)) ffin = sdate(txt(1)) finiant = sdate(dateadd("yyyy", -1, ddate(fini))) ffinant = sdate(dateadd("yyyy", -1, ddate(ffin))) Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.execute "DELETE FROM BalanceSituacion" Set rst = New ADODB.Recordset rst.open "SELECT * FROM BalanceSituacion", cnt, adopenstatic, adlockoptimistic cnt.begintrans Set mauxiliar = New Auxiliar While Not rs.eof rst.addnew rst("ap") = rs("ap") rst("nivel_1") = rs("nivel_1") rst("nivel_2") = rs("nivel_2") rst("nivel_3") = rs("nivel_3") rst("titulo") = rs("titulo") If Nz(rs("cuentas"), "") <> "" Then rst("cuentas") = cuentasgrupo((rs("cuentas"))) rst("saldo") = saldocuentas(rs("ap"), rs("cuentas"), fini, ffin) rst("saldo_ant") = saldocuentas(rs("ap"), rs("cuentas"), finiant, ffinant) rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend Set mauxiliar = Nothing rst.close cnt.committrans Set rst = Nothing Sub Private Sub imprimir() Dim periodo As String Dim empresa As String periodo = "del " & IIf(txt(0) <> "", txt(0), ddate(sinicioejercicio)) & " al " & IIf(txt(1) <> "", txt(1), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("balancesituacionabreviado.rpt", "Balance de situacion abreviado", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM BalanceSituacion ORDER BY ap, nivel_1, nivel_2, nivel_3" Call minformes.execute Set minformes = Nothing Sub Private Function cuentasgrupo(byval cuentas As String) Dim cuenta As String Dim pos As Integer
182 Dim aux As String aux = "" While Len(cuentas) > 0 pos = InStr(1, cuentas, ",") - 1 If pos > 0 Then cuenta = Trim(Left(cuentas, pos)) cuentas = Mid(cuentas, InStr(1, cuentas, ",") + 1) cuenta = cuentas cuentas = "" If Left(cuenta, 1) = "?" Then cuenta = Mid(cuenta, 2) aux = aux & cuenta & ", " Wend cuentasgrupo = Left(aux, Len(aux) - 2) Function Private Function saldocuentas(byval ap As String, ByVal cuentas As String, ByVal fini As String, ByVal ffin As String) As Double Dim pos As Integer Dim cuenta As String Dim cuentaaux As String Dim strwhere As String Dim saldo As Double Dim saldoac As Double saldo = 0 strwhere = "" saldoac = 0 While Len(cuentas) > 0 pos = InStr(1, cuentas, ",") - 1 If pos > 0 Then cuenta = Trim(Left(cuentas, pos)) cuentas = Mid(cuentas, InStr(1, cuentas, ",") + 1) cuenta = cuentas cuentas = "" If Left(cuenta, 1) <> "?" And Left(cuenta, 1) <> "(" Then strwhere = strwhere & "cuenta LIKE " & cuenta & "% OR " If Left(cuenta, 1) = "?" Then Cuenta que esta en Activo y Pasivo cuentaaux = Mid(cuenta, 2) Set mauxiliar = New Auxiliar saldo = CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)-SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND cuenta LIKE " & cuentaaux & "%", 0)) Set mauxiliar = Nothing If (saldo > 0 And ap = "P") Or (saldo < 0 And ap = "A") Then saldo = 0 Cuenta con signo cambiado cuentaaux = Mid(cuenta, 2, Len(cuenta) - 2) Set mauxiliar = New Auxiliar saldo = CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)-SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND cuenta LIKE " & cuentaaux & "%", 0)) Set mauxiliar = Nothing saldo = -saldo saldoac = saldoac + saldo Wend If strwhere <> "" Then
183 strwhere = "(" & Left(strWhere, Len(strWhere) - 4) & ")" Set mauxiliar = New Auxiliar If ap = "A" Then saldocuentas = saldoac + CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(debe)- SUM(haber) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND " & strwhere, 0)) saldocuentas = saldoac + CDbl(mAuxiliar.vBuscarCampo("Apuntes", "SUM(haber)- SUM(debe) AS Saldo", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & sdelegacion & " AND fecha_apunte BETWEEN " & fini & " AND " & ffin & " AND " & strwhere, 0)) Set mauxiliar = Nothing If ap = "A" Then saldocuentas = saldoac saldocuentas = -saldoac Function Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 0, 1: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) If sdate(txt(index)) < sinicioejercicio Or sdate(txt(index)) > sfinalejercicio Then msg = msgerror(1027) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
184 VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmcartera Caption = "Cartera" ClientHeight = 6330 ClientLeft = 60 ClientTop = 345 ClientWidth = 7920 LinkTopic = "frmcartera" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 422 ScaleMode = 3 Pixel ScaleWidth = 528 Tag = "ToolbarCartera" Begin MSComctlLib.ListView ListViewCartera Height = 2865 Left = 0 TabIndex = 15 Top = 450 Width = 7905 _ExtentX = _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 11 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Documento" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Número" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Fecha Vto." Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Concepto" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Importe" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Acre/Deu" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Estado" Object.Width = Property BeginProperty ColumnHeader(8) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 7 Text = "Tipo documento" Object.Width = Property BeginProperty ColumnHeader(9) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 8 Text = "Fecha cierre"
185 Object.Width = Property BeginProperty ColumnHeader(10) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 9 Text = "Documento cierre" Object.Width = Property BeginProperty ColumnHeader(11) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 10 Text = "Número cierre" Object.Width = Property Begin VB.Frame frmdatos Height = 2940 Left = 0 TabIndex = 14 Top = 3360 Width = 7905 Begin VB.TextBox txt Index = 6 Left = 1155 TabIndex = 25 Top = 2520 Width = 1125 Begin VB.TextBox txt Index = 7 Left = 4080 TabIndex = 24 Tag = "DOCUMENTOS.codigo_documento" Top = 2520 Width = 975 Begin VB.TextBox txt Index = 8 Left = 6525 TabIndex = 23 Top = 2520 Width = 1275 Begin VB.TextBox txt Index = 1 Left = 3900 TabIndex = 2 Top = 1305 Width = 1275 Begin VB.TextBox txt Index = 0 Left = 1560 TabIndex = 1 Tag = "DOCUMENTOS.codigo_documento" Top = 1305 Width = 975 Begin VB.TextBox txt Index = 2 Left = 6675 TabIndex = 3 Top = 1305 Width = 1125 Begin VB.TextBox des BackColor = &H & Enabled = 0 False Index = 5 Left = 3120 TabIndex = 19 Top =
186 Width = 4680 Begin VB.TextBox txt Index = 5 Left = 1560 TabIndex = 6 Tag = "PERSONAL.codigo" Top = 2115 Width = 1410 Begin VB.TextBox txt Index = 4 Left = 6675 TabIndex = 5 Text = "0,00" Top = 1710 Width = 1125 Begin VB.Frame frmtipo Caption = "Tipo documento" Height = 840 Left = 4440 TabIndex = 13 Top = 240 Width = 2175 Begin VB.OptionButton opt_tipo Caption = "Pago" Height = 315 Index = 1 Left = 1320 TabIndex = 11 Top = 360 Width = 825 Begin VB.OptionButton opt_tipo Caption = "Cobro" Height = 315 Index = 0 Left = 120 TabIndex = 10 Top = 360 Value = -1 True Width = 1065 Begin VB.TextBox txt Index = 3 Left = 1560 TabIndex = 4 Top = 1710 Width = 3675 Begin VB.Frame frmestado Caption = "Estado" Height = 840 Left = 120 TabIndex = 12 Top = 240 Width = 4110 Begin VB.OptionButton opt_estado Caption = "Pendiente" Height = 315 Index = 0 Left = 150 TabIndex = 7 Top = 360 Value = -1 True Width = 1065 Begin VB.OptionButton opt_estado Caption = "Devuelto" Height = 315 Index = 2 Left =
187 TabIndex = 9 Top = 360 Width = 1065 Begin VB.OptionButton opt_estado Caption = "Cancelado" Height = 315 Index = 1 Left = 1560 TabIndex = 8 Top = 360 Width = 1065 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Fecha cierre:" Height = 255 Index = 6 Left = 120 TabIndex = 28 Top = 2535 Width = 975 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Documento cierre:" ForeColor = &H & Height = 255 Index = 7 Left = 2640 TabIndex = 27 Top = 2535 Width = 1455 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Número cierre:" ForeColor = &H & Height = 255 Index = 8 Left = 5400 TabIndex = 26 Top = 2520 Width = 1110 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Número:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 3075 TabIndex = 22 Top = 1320 Width = 750 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Documento:"
188 BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 21 Top = 1320 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Fecha Vto:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 5670 TabIndex = 20 Top = 1320 Width = 975 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Acreedor/Deudor:" ForeColor = &H & Height = 255 Index = 5 Left = 120 TabIndex = 18 Top = 2130 Width = 1335 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Importe:" Height = 255 Index = 4 Left = 5700 TabIndex = 17 Top = 1725 Width = 675 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Concepto:" Height = 255 Index = 3 Left = 120 TabIndex = 16 Top = 1725 Width = 975 Begin MSComctlLib.ImageList ImageListCartera Left = 0 Top = 7650 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor =
189 _Version = Begin MSComctlLib.Toolbar ToolbarCartera Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarCartera" Top = 0 Width = 7920 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmcartera" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mcartera As cartera Dim mnumeracion As numeracion Dim mauxiliar As Auxiliar Private Sub AyudarCartera() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = Format(0, "0.00") txt(5) = "" txt(6) = "" txt(7) = "" txt(8) = "" des(5) = "" opt_estado(0) = 1 opt_estado(1) = 0 opt_estado(2) = 0 opt_tipo(0) = 1 opt_tipo(1) = 0 txt(0).enabled = True txt(1).enabled = True txt(2).enabled = True txt(0).setfocus Sub Private Sub EliminarCartera() Dim rpta As Integer Dim aux As String On Error GoTo EliminarCarteraError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cartera", "codigo_documento", "codigo_empresa = " & sempresa _ & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) _ & " and numero_documento = " & txt(1) & " and numero_apunte = and fecha_vto = " _ & mauxiliar.sdate(txt(2)) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then
190 rpta = MsgBox(" Desea eliminar el vencimiento " & txt(2) & " del documento " & txt(1) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mcartera = New cartera mcartera.delete cn, sempresa, sdelegacion, txt(0), txt(1), " ", txt(2) Set mcartera = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewCartera.ListItems.Remove ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).index Set mauxiliar = Nothing Call cancelardatos Exit Sub EliminarCarteraError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarCartera() Dim filtro As String Dim mauxiliar As Auxiliar filtro = "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_documento = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numero_documento = " & txt(1) & "" If txt(2) <> "" Then Set mauxiliar = New Auxiliar If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fecha_vto = " & mauxiliar.sdate(txt(2)) & "" Set mauxiliar = Nothing If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "concepto = " & txt(3) & "" If IsNumeric(txt(4)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "importe = " & Replace(txt(4), ",", ".") If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_personal = " & txt(5) & "" If txt(6) <> "" Then Set mauxiliar = New Auxiliar If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fecha_cierre = " & mauxiliar.sdate(txt(6)) & "" Set mauxiliar = Nothing If txt(7) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_documento_cierre = " & txt(7) & " "
191 If txt(8) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numero_documento_cierre = " & txt(8) & "" If opt_estado(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "estado = P" If opt_estado(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "estado = C" If opt_estado(2) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "estado = D" If opt_tipo(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = C" If opt_tipo(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = P" Call ListarCartera(filtro) Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmcartera = Forms(i) Next Call limatges16(me.imagelistcartera) Set Me.ToolbarCartera.ImageList = Me.ImageListCartera Call cargarbotonera(me.toolbarcartera) Call deshabilitarbotones(me.toolbarcartera, "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewCartera For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top
192 writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewCartera For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirCartera() Sub Private Sub insertarcartera() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarCarteraError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cartera", "codigo_documento", "codigo_empresa = " & sempresa _ & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) _ & " and numero_documento = " & txt(1) & " and numero_apunte = 1 and fecha_vto = " _ & mauxiliar.sdate(txt(2)) & "", "#") If aux = "#" Then Busco el tipo de acreedor/deudor Dim tipo As String tipo = mauxiliar.vbuscarcampo("acrdeu, Apuntes", "Acrdeu.tipo AS tipo", "Acrdeu.codigo_empresa = Apuntes.codigo_empresa " _ & " and Acrdeu.cuenta = Apuntes.cuenta and Apuntes.codigo_empresa = " & sempresa & " and Apuntes.codigo_delegacion = " _ & sdelegacion & " and Apuntes.codigo_documento = " & txt(0) & " and Apuntes.numero_documento = " & txt(1) & _ " and Apuntes.numero_apunte = 1 and Acrdeu.codigo = " & txt(5) & "", "#") If tipo = "#" Then MsgBox msgerror(1034), vbcritical, App.Title Si no existe, lo inserto Set mcartera = New cartera mcartera.insert cn, sempresa, sdelegacion, txt(0), txt(1), 1, txt(2), tipo, txt(5), txt(3), IIf(opt_estado(0), "P", IIf(opt_estado(1), "C", "D")), IIf(opt_tipo(0), "C", "P"), txt(4), txt(6), txt(7), txt(8), susuario Set mcartera = Nothing On Error Resume Next Set newitem = ListViewCartera.ListItems.Add(, getkeygrid(txt(0), txt(1), txt(2)), txt(0)) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(3) = txt(3) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(4) = Format(txt(4), "0.00") ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(5) = txt(5) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(6) = IIf(opt_estado(0), "P", IIf(opt_estado(1), "C", "D")) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(7) = IIf(opt_tipo(0), "C", "P") ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(8) = txt(6) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(9) = txt(7) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(10) = txt(8)
193 Call cancelardatos MsgBox msgerror(1045), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarCarteraError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarCartera(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & "" Elimino los datos de la lista ListViewCartera.ListItems.Clear Set mauxiliar = New Auxiliar Set mcartera = New cartera Set rs = mcartera.getlist(cn, strwhere) Do Until rs.eof Set newitem = ListViewCartera.ListItems.Add(, getkeygrid(rs("codigo_documento"), rs("numero_documento"), mauxiliar.ddate(rs("fecha_vto"))), rs!codigo_documento) newitem.subitems(1) = Nz(rs!numero_documento, "") newitem.subitems(2) = mauxiliar.ddate(nz(rs!fecha_vto, "")) newitem.subitems(3) = Nz(rs!concepto, "") newitem.subitems(4) = Format(Nz(rs!importe, ""), "0.00") newitem.subitems(5) = Nz(rs!codigo_personal, "") newitem.subitems(6) = Nz(rs!estado, "") newitem.subitems(7) = Nz(rs!tipo, "") newitem.subitems(8) = mauxiliar.ddate(nz(rs!fecha_cierre, "")) newitem.subitems(9) = Nz(rs!codigo_documento_cierre, "") newitem.subitems(10) = Nz(rs!numero_documento_cierre, "") rs.movenext Loop Set rs = Nothing Set mcartera = Nothing Set mauxiliar = Nothing Sub Private Sub ListViewCartera_DblClick() On Error Resume Next txt(0) = Me.ListViewCartera.SelectedItem.Text: txt(0).enabled = False txt(1) = Me.ListViewCartera.SelectedItem.SubItems(1): txt(1).enabled = False txt(2) = Me.ListViewCartera.SelectedItem.SubItems(2): txt(2).enabled = False Call txt_lostfocus(0) Sub Private Sub modificarcartera() Dim i As Integer Dim aux As String On Error GoTo ModificarCarteraError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cartera", "codigo_documento", "codigo_empresa = " & sempresa _ & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) _ & " and numero_documento = " & txt(1) & " and numero_apunte = 1 and fecha_vto = " _ & mauxiliar.sdate(txt(2)) & "", "#") If aux <> "#" Then
194 Busco el tipo de acreedor/deudor Dim tipo As String tipo = mauxiliar.vbuscarcampo("acrdeu, Apuntes", "Acrdeu.tipo AS tipo", "Acrdeu.codigo_empresa = Apuntes.codigo_empresa " _ & " and Acrdeu.cuenta = Apuntes.cuenta and Apuntes.codigo_empresa = " & sempresa & " and Apuntes.codigo_delegacion = " _ & sdelegacion & " and Apuntes.codigo_documento = " & txt(0) & " and Apuntes.numero_documento = " & txt(1) & _ " and Apuntes.numero_apunte = 1 and Acrdeu.codigo = " & txt(5) & "", "#") If tipo = "#" Then MsgBox msgerror(1034), vbcritical, App.Title Si existe, lo modifico Set mcartera = New cartera mcartera.update cn, sempresa, sdelegacion, txt(0), txt(1), 1, txt(2), tipo, txt(5), txt(3), IIf(opt_estado(0), "P", IIf(opt_estado(1), "C", "D")), IIf(opt_tipo(0), "C", "P"), txt(4), txt(6), txt(7), txt(8), susuario Set mcartera = Nothing On Error Resume Next ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(3) = txt(3) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(4) = Format(txt(4), "0.00") ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(5) = txt(5) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(6) = IIf(opt_estado(0), "P", IIf(opt_estado(1), "C", "D")) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(7) = IIf(opt_tipo(0), "C", "P") ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(8) = txt(6) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(9) = txt(7) ListViewCartera.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(10) = txt(8) Call cancelardatos MsgBox msgerror(1046), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarCarteraError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub opt_estado_gotfocus(index As Integer) Me.ToolbarCartera.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Sub opt_tipo_gotfocus(index As Integer) Me.ToolbarCartera.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Sub ToolbarCartera_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call insertarcartera Case "modificar": If validardatos Then Call modificarcartera Case "filtrar": Call FiltrarCartera Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarCartera Case "listar": Call ListarCartera Case "imprimir": Call ImprimirCartera Case "ayudar": Call AyudarCartera Select Sub Private Sub txt_dblclick(index As Integer)
195 If Me.ToolbarCartera.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarCartera.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Si no informo un campo, le assigno un valor por defecto Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Or Index = 1 Or Index = 2 Then If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar Set mcartera = New cartera Set rs = mcartera.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " and numero_documento = " & txt(1) & " and fecha_vto = " & mauxiliar.sdate(txt(2)) & "") If Not rs.eof Then txt(3) = Nz(rs!concepto, "") txt(4) = Format(Nz(rs!importe, 0), "0.00") txt(5) = Nz(rs!codigo_personal, "") txt(6) = mauxiliar.ddate(nz(rs!fecha_cierre, "")) txt(7) = Nz(rs!codigo_documento_cierre, "") txt(8) = Nz(rs!numero_documento_cierre, "") If txt(5) <> "" Then des(5) = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " and codigo = " & txt(5) & "", "") des(5) = "" opt_estado(0) = (Nz(rs!estado, "") = "P") opt_estado(1) = (Nz(rs!estado, "") = "C") opt_estado(2) = (Nz(rs!estado, "") = "D") opt_tipo(0) = (Nz(rs!tipo, "") = "C") opt_tipo(1) = (Nz(rs!tipo, "") = "P") Set rs = Nothing Set mcartera = Nothing Set mauxiliar = Nothing If Index = 4 Then txt(4) = Format(Nz(txt(4), 0), "0.00") Sub Compruebo que el dato que informo (si lo informo) es correcto. Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String Cancel = False msg = "" Set mauxiliar = New Auxiliar Select Case Index Case 4: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Case 5: If txt(index) <> "" Then aux = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " and codigo = " & txt(5) & "", "#") If aux = "#" Then msg = msgerror(9999)
196 des(index) = aux Case 2, 6: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Case 7: If txt(index) <> "" Then aux = mauxiliar.vbuscarcampo("documentos", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(7) & "", "#") If aux = "#" Then msg = msgerror(9999) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Compruebo que los campos obligatorios estan informados Private Function validardatos() As Boolean Dim msg As String Dim i As Integer Dim total_documento As Double Dim total_vencimientos As Double validardatos = True For i = 0 To 8 Select Case i Case 0, 1, 2: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Case 4: If txt(i) <> "" Then If Not IsNumeric(txt(i)) Then msg = msgerror(1004) txt(i).setfocus Exit For txt(i) = Format(0, "0.00") Select Next If msg = "" Then Set mauxiliar = New Auxiliar total_vencimientos = mauxiliar.vbuscarcampo("cartera", "SUM(importe) AS importe", "codigo_empresa = " _ & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " " _ & " and numero_documento = " & txt(1) & " and numero_apunte = 1 and fecha_vto <> " & mauxiliar.sdate(txt(2)) & "", 0) total_documento = mauxiliar.vbuscarcampo("apuntes", "debe+haber AS importe", "codigo_empresa = " _ & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " " _ & " and numero_documento = " & txt(1) & " and numero_apunte = 1", 0) Set mauxiliar = Nothing If total_documento <> total_vencimientos + txt(4) Then msg = msgerror(1044) txt(4).setfocus
197 If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function Private Function getkeygrid(codigo_documento As String, numero_documento As String, fecha_vto As Date) As String Dim mauxiliar As Auxiliar Set mauxiliar = New Auxiliar getkeygrid = "K" & Format(Trim(codigo_documento), String(15, "@")) & Format(Trim(numero_documento), String(10, "@")) & mauxiliar.sdate(fecha_vto) Set mauxiliar = Nothing Function
198 36. frmcierre.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmcierre Caption = "Cierre" ClientHeight = 1575 ClientLeft = 60 ClientTop = 450 ClientWidth = 7200 LinkTopic = "frmcierre" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 105 ScaleMode = 3 Pixel ScaleWidth = 480 Tag = "ToolbarCierre" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 1125 Left = 0 TabIndex = 0 Top = 360 Width = 7065 Begin VB.TextBox txt Enabled = 0 False Index = 1 Left = 5475 TabIndex = 5 Top = 240 Width = 1500 Begin VB.TextBox txt Enabled = 0 False Index = 0 Left = 1800 TabIndex = 3 Top = 225 Width = 1500 Begin VB.Label lbl Caption = "Documento de apertura:" Height = 255 Index = 1 Left = 3675 TabIndex = 6 Top = 240 Width = 1755 Begin MSForms.CheckBox chkverasiento Height = 315 Left = 4920 TabIndex = 4 Top = 720 Width = 2040 VariousPropertyBits= BackColor = ForeColor = DisplayStyle = 4 Size = "3598;556" Value = "0" Caption = "Ver asientos generados"
199 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label lbl Caption = "Documento de cierre:" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 1605 Begin MSComctlLib.Toolbar ToolbarCierre Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCierre" Top = 0 Width = 7200 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListCierre Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmcierre" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim mcierre As Cierre Private Sub ayudarcierre() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" chkverasiento = 0 txt(0).setfocus Sub Private Sub insertarcierre() Dim rpta As Integer Dim cerrado As String Dim regularizado As String Set mauxiliar = New Auxiliar cerrado = mauxiliar.vbuscarcampo("ejercicios", "cerrado", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio, "#") Set mauxiliar = Nothing If cerrado = "S" Then rpta = MsgBox("El ejercicio ya ha sido cerrado. Desea ver los asientos?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Call imprimircierre Set mauxiliar = New Auxiliar
200 regularizado = mauxiliar.vbuscarcampo("ejercicios", "regularizado", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio, "#") Set mauxiliar = Nothing If regularizado = "S" Then Set mcierre = New Cierre mcierre.insert cn, sempresa, iejercicio, txt(0), txt(1), susuario, False Set mcierre = Nothing If chkverasiento Then Call imprimircierre MsgBox msgerror(1047), vbcritical, App.Title Sub Private Sub imprimircierre() Dim rs As ADODB.Recordset Dim strwherereport As String strwherereport = "codigo_empresa = " & sempresa & " and codigo_delegacion = " _ & sempresa & " and (codigo_documento = " & txt(0) & " or codigo_documento = " & txt(1) & ")" Set rs = obtenerdatos(strwherereport) If Not rs.eof Then Call guardartemporalcierre(rs) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Sub guardartemporalcierre(rs As ADODB.Recordset) Dim rst As ADODB.Recordset Dim contador As Integer cnt.execute "DELETE FROM LibroDiario" Set rst = New ADODB.Recordset rst.open "SELECT * FROM LibroDiario", cnt, adopenstatic, adlockoptimistic Set mauxiliar = New Auxiliar cnt.begintrans While Not rs.eof rst.addnew rst("fecha_apunte") = rs("fecha_apunte") rst("numero_documento") = rs("numero_documento") rst("numero_apunte") = rs("numero_apunte") rst("cuenta") = rs("cuenta") rst("titulo") = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & rs("cuenta") & "", "") rst("concepto") = rs("concepto") rst("debe") = rs("debe") rst("haber") = rs("haber") rst.update rs.movenext Wend rst.close cnt.committrans Set mauxiliar = Nothing Set rst = Nothing Sub Private Sub imprimir() Dim empresa As String Dim delegación As String Dim ordenacion As String Set mauxiliar = New Auxiliar
201 empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("cierre.rpt", "Asiento de cierre", SCREENMODE) Call minformes.rptformulas("empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM LibroDiario ORDER BY fecha_apunte, numero_documento, numero_apunte" Call minformes.execute Set minformes = Nothing Sub Private Function obtenerdatos(strwherereport As String) As Object Dim rs As ADODB.Recordset Set mcierre = New Cierre Set rs = mcierre.getlist(cn, strwherereport, "cuenta") Set mcierre = Nothing Set obtenerdatos = rs Function Private Function validarcierre() As String validarcierre = msgerror(9999) Function Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmcierre = Forms(i) Next Call limatges16(me.imagelistcierre) Set Me.ToolbarCierre.ImageList = Me.ImageListCierre Call cargarbotonera(me.toolbarcierre) Call deshabilitarbotones(me.toolbarcierre, "cancelar", "lupa", "imprimir", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Documento asociado a la regularización txt(0) = "CIER" & Trim(str(iEjercicio)) txt(1) = "APER" & Trim(str(iEjercicio + 1)) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then
202 writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarCierre_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": Call insertarcierre Case "ayudar": Call ayudarcierre Select Sub Private Sub txt_change(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
203 37. frmcuentas.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmcuentas Caption = "Cuentas" ClientHeight = 4440 ClientLeft = 60 ClientTop = 345 ClientWidth = 4770 LinkTopic = "frmcuentas" MDIChild = -1 True ScaleHeight = 296 ScaleMode = 3 Pixel ScaleWidth = 318 Tag = "ToolbarCuentas" Begin MSComctlLib.ListView ListViewCuentas Height = 2865 Left = 0 TabIndex = 6 Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 3 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Cuenta" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Descripción" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Pases" Object.Width = Property Begin VB.Frame frmdatos Height = 1140 Left = 0 TabIndex = 3 Top = 3300 Width = 4740 Begin VB.CheckBox chk Alignment = 1 Right Justify Caption = "Pases contables" Height = 240 Index = 0 Left = 3075 TabIndex = 7 Top = 300 Width = 1515 Begin VB.TextBox txt Index = 0 Left = 1200 TabIndex = 1 Top = 300 Width =
204 Begin VB.TextBox txt Index = 1 Left = 1185 TabIndex = 2 Top = 660 Width = 3420 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Cuenta:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 75 TabIndex = 5 Top = 300 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 1 Left = 75 TabIndex = 4 Top = 660 Width = 1080 Begin MSComctlLib.ImageList ImageListCuentas Left = 120 Top = 4920 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarCuentas Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarCuentas" Top = 0 Width = 4770 _ExtentX = 8414 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmcuentas" Attribute VB_GlobalNameSpace = False
205 Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mcuentas As cuentas Private Sub AyudarCuentas() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" chk(0) = 0 txt(0).setfocus Sub Private Sub Eliminarcuenta() Dim rpta As Integer Dim aux As String Dim rs As ADODB.Recordset On Error GoTo EliminarcuentaError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cuentas", "cuenta", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Dim mauxiliarapuntes As New Auxiliar Set rs = mauxiliar.getlistext(cn, "Apuntes", "cuenta", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "cuenta") Set mauxiliarapuntes = Nothing If Not rs.eof Then Si ya existe alguna entrada con esta cuenta, cancelamos la eliminacion MsgBox msgerror(1035), vbcritical, App.Title rpta = MsgBox(" Desea eliminar la cuenta " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mcuentas = New cuentas mcuentas.delete cn, sempresa, txt(0) Set mcuentas = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewCuentas.ListItems.Remove ListViewCuentas.ListItems(getKeyGrid(txt(0))).Index Call cancelardatos Exit Sub EliminarcuentaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub Filtrarcuenta() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cuenta = " & txt(0) & "" If txt(1) <> "" Then
206 If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion = " & txt(1) & "" Call ListarCuentas(filtro) Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmcuentas = Forms(i) Next Call limatges16(me.imagelistcuentas) Set Me.ToolbarCuentas.ImageList = Me.ImageListCuentas Call cargarbotonera(me.toolbarcuentas) Call deshabilitarbotones(me.toolbarcuentas, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewCuentas For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewCuentas For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirCuentas() Sub Private Sub InsertarCuenta() Dim i As Integer Dim aux As String Dim newitem As ListItem
207 On Error GoTo InsertarCuentaError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cuentas", "cuenta", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mcuentas = New cuentas mcuentas.insert cn, sempresa, txt(0), txt(1), IIf(chk(0), "S", "N"), Len(txt(0)), susuario Set mcuentas = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewCuentas.ListItems.Add(, getkeygrid(txt(0)), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = IIf(chk(0), "S", "N") Call cancelardatos For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1017), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarCuentaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarCuentas(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewCuentas.ListItems.Clear Set mcuentas = New cuentas Set rs = mcuentas.getlist(cn, strwhere, "codigo_empresa, cuenta") Do Until rs.eof Set newitem = ListViewCuentas.ListItems.Add(, getkeygrid(rs("cuenta")), rs("cuenta")) newitem.subitems(1) = Nz(rs("descripcion"), "") newitem.subitems(2) = Nz(rs("pases"), "N") rs.movenext Loop Set rs = Nothing Set mcuentas = Nothing Sub Private Sub ListViewCuentas_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewCuentas.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarCuenta() Dim i As Integer Dim aux As String On Error GoTo ModificarcuentaError
208 If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("cuentas", "cuenta", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mcuentas = New cuentas mcuentas.update cn, sempresa, txt(0), txt(1), IIf(chk(0), "S", "N"), Len(txt(0)), susuario Set mcuentas = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next ListViewCuentas.ListItems(ListViewCuentas.ListItems(getKeyGrid(txt(0))).Index).SubItems( 1) = txt(1) ListViewCuentas.ListItems(ListViewCuentas.ListItems(getKeyGrid(txt(0))).Index).SubItems( 2) = IIf(chk(0), "S", "N") Call cancelardatos For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1018), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarcuentaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarCuentas_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarCuenta Case "modificar": If validardatos Then Call ModificarCuenta Case "filtrar": Call Filtrarcuenta Case "lupa": Call mostrarlupa(me) Case "borrar": Call Eliminarcuenta Case "listar": Call ListarCuentas Case "imprimir": Call ImprimirCuentas Case "ayudar": Call AyudarCuentas Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarCuentas.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarCuentas.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then txt(0) = transformarcuenta(me.txt(0), icuenta) Set mcuentas = New cuentas Set rs = mcuentas.getlist(cn, "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "") If Not rs.eof Then
209 txt(1) = Nz(rs("descripcion"), "") chk(0) = IIf(Nz(rs("pases"), "N") = "N", 0, 1) If Len(txt(0)) = icuenta Then chk(0).value = 1 Set rs = Nothing Set mcuentas = Nothing Sub Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 1 Select Case i Case 0, 1: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function Private Function getkeygrid(cuenta As String) As String Dim mauxiliar As Auxiliar Set mauxiliar = New Auxiliar getkeygrid = "K" & Format(Trim(cuenta), String(12, "@")) Set mauxiliar = Nothing Function
210 38. frmdelegaciones.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmdelegaciones Caption = "Delegaciones" ClientHeight = 6300 ClientLeft = 60 ClientTop = 345 ClientWidth = 4740 LinkTopic = "frmdelegaciones" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 420 ScaleMode = 3 Pixel ScaleWidth = 316 Tag = "ToolbarDelegaciones" Begin MSComctlLib.ListView ListViewDelegaciones Height = 2865 Left = 0 TabIndex = 22 Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Nombre" Object.Width = 6967 Property Begin VB.Frame frmdatos Height = 2985 Left = 0 TabIndex = 11 Top = 3300 Width = 4740 Begin VB.TextBox txt Index = 0 Left = 915 TabIndex = 1 Top = 300 Width = 975 Begin VB.TextBox txt Index = 1 Left = 915 TabIndex = 2 Top = 660 Width = 3690 Begin VB.TextBox txt Index = 2 Left = 915 TabIndex =
211 Top = 1020 Width = 3690 Begin VB.TextBox txt Index = 3 Left = 915 TabIndex = 4 Top = 1380 Width = 735 Begin VB.TextBox txt Index = 4 Left = 2715 TabIndex = 5 Top = 1380 Width = 1890 Begin VB.TextBox txt Index = 5 Left = 915 TabIndex = 6 Top = 1740 Width = 1455 Begin VB.TextBox txt Index = 6 Left = 3075 TabIndex = 7 Top = 1740 Width = 1530 Begin VB.TextBox txt Index = 7 Left = 915 TabIndex = 8 Top = 2100 Width = 1455 Begin VB.TextBox txt Index = 8 Left = 3075 TabIndex = 9 Top = 2100 Width = 1530 Begin VB.TextBox txt Index = 9 Left = 915 TabIndex = 10 Top = 2460 Width = 3690 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left =
212 TabIndex = 21 Top = 300 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Nombre:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 75 TabIndex = 20 Top = 660 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Dirección:" Height = 255 Index = 3 Left = 75 TabIndex = 19 Top = 1020 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "C.P.:" Height = 255 Index = 4 Left = 75 TabIndex = 18 Top = 1380 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Población:" Height = 255 Index = 5 Left = 1755 TabIndex = 17 Top = 1380 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Provincia:" Height = 255 Index = 6 Left = 75 TabIndex = 16 Top = 1740 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "País:" Height = 255 Index = 7 Left = 2475 TabIndex = 15 Top = 1740 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Teléfono:" Height =
213 Index = 8 Left = 75 TabIndex = 14 Top = 2100 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "FAX:" Height = 255 Index = 9 Left = 2475 TabIndex = 13 Top = 2100 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = " " Height = 255 Index = 10 Left = 75 TabIndex = 12 Top = 2460 Width = 735 Begin MSComctlLib.ImageList ImageListDelegaciones Left = 0 Top = 6840 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarDelegaciones Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarDelegaciones" Top = 0 Width = 4740 _ExtentX = 8361 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmdelegaciones" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mdelegaciones As Delegaciones Private Sub AyudarDelegaciones() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(6) = "" txt(7) = "" txt(8) = "" txt(9) = "" txt(0).setfocus
214 Sub Private Sub EliminarDelegacion() Dim rpta As Integer Dim aux As String On Error GoTo EliminarDelegacionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("delegaciones", "codigo_delegacion", "codigo_empresa = " & sempresa & " AND codigo_delegacion = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then If aux = sdelegacion Then MsgBox msgerror(1037), vbcritical, App.Title rpta = MsgBox(" Desea eliminar la delegación " & txt(0) & "? (Los datos relacionados con la delegación tambien se eliminarán)", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mdelegaciones = New Delegaciones mdelegaciones.delete cn, sempresa, txt(0), False Set mdelegaciones = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewDelegaciones.ListItems.Remove ListViewDelegaciones.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarDelegacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarDelegacion() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_delegacion = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nombre = " & txt(1) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "direccion = " & txt(2) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cp = " & txt(3) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "poblacion = " & txt(4) & "" If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "provincia = " & txt(5) & "" If txt(6) <> "" Then
215 If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pais = " & txt(6) & "" If txt(7) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "telefono = " & txt(7) & "" If txt(8) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fax = " & txt(8) & "" If txt(9) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "correo = " & txt(9) & "" Call ListarDelegaciones(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmdelegaciones = Forms(i) Next Call limatges16(me.imagelistdelegaciones) Set Me.ToolbarDelegaciones.ImageList = Me.ImageListDelegaciones Call cargarbotonera(me.toolbardelegaciones) Call deshabilitarbotones(me.toolbardelegaciones, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewDelegaciones For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewDelegaciones
216 For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirDelegaciones() Sub Private Sub InsertarDelegacion() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarDelegacionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("delegaciones", "codigo_delegacion", "codigo_empresa = " & sempresa & " and codigo_delegacion = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux = "#" Then Si no existe, lo inserto Set mdelegaciones = New Delegaciones mdelegaciones.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), susuario, False Set mdelegaciones = Nothing On Error Resume Next For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewDelegaciones.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) Call cancelardatos For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1015), vbcritical, App.Title Exit Sub InsertarDelegacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarDelegaciones(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewDelegaciones.ListItems.Clear Set mdelegaciones = New Delegaciones Set rs = mdelegaciones.getlist(cn, strwhere, "codigo_empresa, codigo_delegacion") Do Until rs.eof Set newitem = ListViewDelegaciones.ListItems.Add(, "K" & rs("codigo_delegacion"), rs("codigo_delegacion")) newitem.subitems(1) = Nz(rs("nombre"), "") rs.movenext Loop Set rs = Nothing Set mdelegaciones = Nothing Sub
217 Private Sub ListViewDelegaciones_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewDelegaciones.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarDelegacion() Dim i As Integer Dim aux As String On Error GoTo ModificarDelegacionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("delegaciones", "codigo_delegacion", "codigo_empresa = " & sempresa & " and codigo_delegacion = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Si existe, lo modifico Set mdelegaciones = New Delegaciones mdelegaciones.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), susuario, False Set mdelegaciones = Nothing On Error Resume Next For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next ListViewDelegaciones.ListItems(ListViewDelegaciones.ListItems("K" & txt(0)).index).subitems(1) = txt(1) Call cancelardatos For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1016), vbcritical, App.Title Exit Sub ModificarDelegacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarDelegaciones_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarDelegacion Case "modificar": If validardatos Then Call ModificarDelegacion Case "filtrar": Call FiltrarDelegacion Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarDelegacion Case "listar": Call ListarDelegaciones Case "imprimir": Call ImprimirDelegaciones Case "ayudar": Call AyudarDelegaciones Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarDelegaciones.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarDelegaciones.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then
218 Set mdelegaciones = New Delegaciones Set rs = mdelegaciones.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("nombre"), "") txt(2) = Nz(rs("direccion"), "") txt(3) = Nz(rs("cp"), "") txt(4) = Nz(rs("poblacion"), "") txt(5) = Nz(rs("provincia"), "") txt(6) = Nz(rs("pais"), "") txt(7) = Nz(rs("telefono"), "") txt(8) = Nz(rs("fax"), "") txt(9) = Nz(rs("correo"), "") Set rs = Nothing Set mdelegaciones = Nothing Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 9 Select Case i Case 0, 1: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
219 39. frmdiarios.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmdiarios Caption = "Diarios" ClientHeight = 4500 ClientLeft = 60 ClientTop = 345 ClientWidth = 4980 LinkTopic = "frmdiarios" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 300 ScaleMode = 3 Pixel ScaleWidth = 332 Tag = "ToolbarDiarios" Begin MSComctlLib.ListView ListViewDiarios Height = 2865 Left = 0 TabIndex = 6 Top = 450 Width = 4980 _ExtentX = 8784 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Diario" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Descripción" Object.Width = 6967 Property Begin VB.Frame frmdatos Height = 1140 Left = 0 TabIndex = 3 Top = 3300 Width = 4980 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 1 Top = 285 Width = 825 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 2 Top = 645 Width = 3450 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent
220 Caption = "Diario:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 5 Top = 285 Width = 855 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 4 Top = 645 Width = 1095 Begin MSComctlLib.ImageList ImageListDiarios Left = 120 Top = 5640 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarDiarios Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarDiarios" Top = 0 Width = 4980 _ExtentX = 8784 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmdiarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mdiarios As Diarios Private Sub AyudarDiarios()
221 Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(0).setfocus Sub Private Sub EliminarDiario() Dim rpta As Integer Dim aux As String On Error GoTo EliminarDiarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("diarios", "codigo_diario", "codigo_empresa = " & sempresa & " AND codigo_diario = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el diario " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mdiarios = New Diarios mdiarios.delete cn, sempresa, txt(0) Set mdiarios = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewDiarios.ListItems.Remove ListViewDiarios.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarDiarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarDiario() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_diario = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion= " & txt(1) & "" Call ListarDiarios(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmdiarios = Forms(i) Next
222 Call limatges16(me.imagelistdiarios) Set Me.ToolbarDiarios.ImageList = Me.ImageListDiarios Call cargarbotonera(me.toolbardiarios) Call deshabilitarbotones(me.toolbardiarios, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewDiarios For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewDiarios For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirDiarios() Sub Private Sub InsertarDiario() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarDiarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("diarios", "codigo_diario", "codigo_empresa = " & sempresa & " and codigo_diario = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mdiarios = New Diarios mdiarios.insert cn, sempresa, txt(0), txt(1), susuario Set mdiarios = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewDiarios.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) Call cancelardatos
223 For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarDiarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarDiarios(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewDiarios.ListItems.Clear Set mdiarios = New Diarios Set rs = mdiarios.getlist(cn, strwhere, "codigo_empresa, codigo_diario") Do Until rs.eof Set newitem = ListViewDiarios.ListItems.Add(, "K" & rs("codigo_diario"), rs("codigo_diario")) newitem.subitems(1) = Nz(rs("descripcion"), "") rs.movenext Loop Set rs = Nothing Set mdiarios = Nothing Sub Private Sub ListViewDiarios_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewDiarios.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarDiario() Dim i As Integer Dim aux As String On Error GoTo ModificarDiarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("diarios", "codigo_diario", "codigo_empresa = " & sempresa & " and codigo_diario = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mdiarios = New Diarios mdiarios.update cn, sempresa, txt(0), txt(1), susuario Set mdiarios = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next True ListViewDiarios.ListItems(ListViewDiarios.FindItem(txt(0)).Index).Selected = ListViewDiarios.SelectedItem.SubItems(1) = txt(1) Call cancelardatos For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next
224 MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarDiarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarDiarios_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarDiario Case "modificar": If validardatos Then Call ModificarDiario Case "filtrar": Call FiltrarDiario Case "borrar": Call EliminarDiario Case "listar": Call ListarDiarios Case "imprimir": Call ImprimirDiarios Case "ayudar": Call AyudarDiarios Select Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then Set mdiarios = New Diarios Set rs = mdiarios.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_diario = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("descripcion"), "") Set rs = Nothing Set mdiarios = Nothing Sub Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 1 Select Case i Case 0, 1: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
225 40. frmdocumentos.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmdocumentos Caption = "Documentos" ClientHeight = 6105 ClientLeft = 60 ClientTop = 345 ClientWidth = 4980 LinkTopic = "frmdocumentos" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 407 ScaleMode = 3 Pixel ScaleWidth = 332 Tag = "ToolbarDocumentos" Begin MSComctlLib.ListView ListViewDocumentos Height = 2865 Left = 0 TabIndex = 7 Top = 450 Width = 4980 _ExtentX = 8784 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 7 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Documento" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Descripción" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Partida" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "IVA" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Cartera" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Numeración" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Identificador" Object.Width = Property Begin VB.Frame frmdatos Height =
226 Left = 0 TabIndex = 5 Top = 3300 Width = 4980 Begin VB.TextBox txt Index = 3 Left = 3795 TabIndex = 4 Top = 1125 Width = 975 Begin VB.TextBox txt Index = 2 Left = 1440 TabIndex = 3 Tag = "NUMERACIONES.numeracion" Top = 1095 Width = 1155 Begin VB.TextBox txt Index = 0 Left = 1440 TabIndex = 1 Top = 345 Width = 975 Begin VB.OptionButton opt Alignment = 1 Right Justify Caption = "Debe" Height = 315 Index = 0 Left = 3075 TabIndex = 16 Top = 360 Value = -1 True Width = 765 Begin VB.OptionButton opt Alignment = 1 Right Justify Caption = "Haber" Height = 315 Index = 1 Left = 3975 TabIndex = 15 Top = 360 Width = 765 Begin VB.Frame frmcartera Height = 1215 Left = 75 TabIndex = 9 Top = 1500 Width = 4815 Begin VB.CheckBox chk Alignment = 1 Right Justify Caption = "Gest. Carte." Height = 240 Index = 2 Left = 300 TabIndex = 14 Top = 825 Width = 1140 Begin VB.CheckBox chk Alignment = 1 Right Justify Caption = "Alta Cartera" Height = 255 Index = 1 Left = 300 TabIndex = 13 Top = 525 Width =
227 Begin VB.CheckBox chk Alignment = 1 Right Justify Caption = "IVA" Height = 255 Index = 0 Left = 300 TabIndex = 12 Top = 225 Width = 1140 Begin VB.OptionButton opt Alignment = 1 Right Justify Caption = "Pagos" Height = 240 Index = 3 Left = 3675 TabIndex = 11 Top = 825 Visible = 0 False Width = 765 Begin VB.OptionButton opt Alignment = 1 Right Justify Caption = "Cobros" Height = 240 Index = 2 Left = 2625 TabIndex = 10 Top = 825 Visible = 0 False Width = 840 Begin VB.TextBox txt Index = 1 Left = 1440 TabIndex = 2 Top = 720 Width = 3330 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Identificador:" Height = 255 Index = 2 Left = 2700 TabIndex = 18 Top = 1140 Width = 975 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Documento:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 17 Top = 360 Width = 1215 Begin VB.Label lbl BackStyle = 0 Transparent
228 Caption = "Numeración:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 4 Left = 120 TabIndex = 8 Top = 1110 Width = 1215 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 6 Top = 735 Width = 1215 Begin MSComctlLib.ImageList ImageListDocumentos Left = 75 Top = 6375 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarDocumentos Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarDocumentos" Top = 0 Width = 4980 _ExtentX = 8784 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmdocumentos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mdocumentos As Documentos Dim mnumeracion As numeracion Private Sub AyudarDocumentos()
229 Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" opt(0) = 1 opt(1) = 0 txt(2) = "" txt(3) = "" chk(0) = 0 chk(1) = 0 chk(2) = 0 opt(2) = 0: Me.opt(2).Visible = False opt(3) = 0: Me.opt(3).Visible = False txt(0).setfocus Sub Private Sub chk_click(index As Integer) Select Case Index Case 1: If Me.chk(1) Then Me.chk(2) = 0 Case 2: Me.opt(2) = 1 Me.opt(2).Visible = Me.chk(2) Me.opt(3).Visible = Me.chk(2) If Me.chk(2) Then Me.chk(1) = 0 Select Sub Private Sub EliminarDocumento() Dim rpta As Integer Dim aux As String On Error GoTo EliminarDocumentoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("documentos", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el documento " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mdocumentos = New Documentos mdocumentos.delete cn, sempresa, txt(0) Set mdocumentos = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewDocumentos.ListItems.Remove ListViewDocumentos.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarDocumentoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarDocumento() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_documento = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion = " & txt(1) & ""
230 If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numeracion = " & txt(2) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "identificador = " & txt(3) & "" Call ListarDocumentos(filtro) Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmdocumentos = Forms(i) Next Call limatges16(me.imagelistdocumentos) Set Me.ToolbarDocumentos.ImageList = Me.ImageListDocumentos Call cargarbotonera(me.toolbardocumentos) Call deshabilitarbotones(me.toolbardocumentos, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewDocumentos For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewDocumentos For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirDocumentos()
231 Sub Private Sub InsertarDocumento() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarDocumentoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("documentos", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mdocumentos = New Documentos mdocumentos.insert cn, sempresa, txt(0), txt(1), IIf(opt(0), "D", "H"), IIf(chk(0), "S", "N"), IIf(chk(1), "A", IIf(chk(2), IIf(opt(2), "C", "P"), "N")), txt(2), txt(3), susuario Set mdocumentos = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next "N")) Set newitem = ListViewDocumentos.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = IIf(opt(0), "D", "H") newitem.subitems(3) = IIf(chk(0), "S", "N") newitem.subitems(4) = IIf(chk(1), "A", IIf(chk(2), IIf(opt(2), "C", "P"), newitem.subitems(5) = txt(2) newitem.subitems(6) = txt(3) Call cancelardatos For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarDocumentoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarDocumentos(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewDocumentos.ListItems.Clear Set mdocumentos = New Documentos Set rs = mdocumentos.getlist(cn, strwhere, "codigo_empresa, codigo_documento") Do Until rs.eof Set newitem = ListViewDocumentos.ListItems.Add(, "K" & Trim(rs("codigo_documento")), rs("codigo_documento")) newitem.subitems(1) = Nz(rs("descripcion"), "") newitem.subitems(2) = Nz(rs("partida"), "D") newitem.subitems(3) = Nz(rs("iva"), "N") newitem.subitems(4) = Nz(rs("cartera"), "N") newitem.subitems(5) = Nz(rs("numeracion"), "") newitem.subitems(6) = Nz(rs("identificador"), "")
232 rs.movenext Loop Set rs = Nothing Set mdocumentos = Nothing Sub Private Sub ListViewDocumentos_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewDocumentos.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarDocumento() Dim i As Integer Dim aux As String On Error GoTo ModificarDocumentoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("documentos", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mdocumentos = New Documentos mdocumentos.update cn, sempresa, txt(0), txt(1), IIf(opt(0), "D", "H"), IIf(chk(0), "S", "N"), IIf(chk(1), "A", IIf(chk(2), IIf(opt(2), "C", "P"), "N")), txt(2), txt(3), susuario Set mdocumentos = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next ListViewDocumentos.ListItems("K" & txt(0)).subitems(1) = txt(1) ListViewDocumentos.ListItems("K" & txt(0)).subitems(2) = IIf(opt(0), "D", "H") ListViewDocumentos.ListItems("K" & txt(0)).subitems(3) = IIf(chk(0), "S", "N") ListViewDocumentos.ListItems("K" & txt(0)).subitems(4) = IIf(chk(1), "A", IIf(chk(2), IIf(opt(2), "C", "P"), "N")) ListViewDocumentos.ListItems("K" & txt(0)).subitems(5) = txt(2) ListViewDocumentos.ListItems("K" & txt(0)).subitems(6) = txt(3) Call cancelardatos For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarDocumentoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarDocumentos_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarDocumento Case "modificar": If validardatos Then Call ModificarDocumento Case "filtrar": Call FiltrarDocumento Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarDocumento Case "listar": Call ListarDocumentos Case "imprimir": Call ImprimirDocumentos Case "ayudar": Call AyudarDocumentos Select
233 Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarDocumentos.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarDocumentos.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset Me.ToolbarDocumentos.Buttons(7).Enabled = False If Index = 0 Then If txt(0) <> "" Then txt(0) = UCase(txt(0)) Set mdocumentos = New Documentos Set rs = mdocumentos.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_documento = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("descripcion"), "") txt(2) = Nz(rs("numeracion"), "") txt(3) = Nz(rs("identificador"), "") opt(0) = IIf(Nz(rs("partida"), "D") <> "D", 0, 1) opt(1) = IIf(Nz(rs("partida"), "D") <> "D", 1, 0) chk(0) = IIf((Nz(rs("iva"), "N") = "N"), 0, 1) chk(1) = IIf((Nz(rs("cartera"), "A") = "A"), 1, 0) chk(2) = IIf((Nz(rs("cartera"), "C") = "C" Or Nz(rs("cartera"), "P") = "P"), 1, 0) opt(2) = IIf(Nz(rs("cartera"), "C") = "C", 1, 0) opt(3) = IIf(Nz(rs("cartera"), "P") = "P", 1, 0) Set rs = Nothing Set mdocumentos = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String Dim max As Integer msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 2: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) aux = mauxiliar.vbuscarcampo("numeraciones", "descripcion", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio & " and numeracion = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(9999) Case 3: If txt(index) <> "" Then max = mauxiliar.vbuscarcampo("numeraciones", "longitud", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio & " and numeracion = " & txt(index) & "", 0) If max + Len(txt(Index)) > 10 Then msg = msgerror(9999) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title
234 Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 3 Select Case i Case 0, 1, 2: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
235 41. frmejercicios.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmejercicios Caption = "Ejercicios" ClientHeight = 4935 ClientLeft = 60 ClientTop = 345 ClientWidth = 4980 LinkTopic = "frmejercicios" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 329 ScaleMode = 3 Pixel ScaleWidth = 332 Tag = "ToolbarEjercicios" Begin MSComctlLib.ListView ListViewEjercicios Height = 2865 Left = 0 TabIndex = 12 Top = 450 Width = 4980 _ExtentX = 8784 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 6 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Ejercicio" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Fecha inicial" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Fecha final" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Inicio bloqueo" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Final bloqueo" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } Alignment = 2 SubItemIndex = 5 Text = "Cerrado" Object.Width = Property Begin VB.Frame frmdatos Height = 1635 Left = 0 TabIndex = 6 Top = 3300 Width =
236 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 2 Top = 720 Width = 1050 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 1 Top = 360 Width = 1050 Begin VB.CheckBox chk Alignment = 1 Right Justify Caption = "Cerrado:" Enabled = 0 False Height = 240 Index = 0 Left = 3780 TabIndex = 13 Top = 375 Width = 990 Begin VB.TextBox txt Index = 2 Left = 3720 TabIndex = 3 Top = 720 Width = 1050 Begin VB.TextBox txt Index = 3 Left = 1320 TabIndex = 4 Top = 1080 Width = 1050 Begin VB.TextBox txt Index = 4 Left = 3720 TabIndex = 5 Top = 1080 Width = 1050 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Ejercicio:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 11 Top = 360 Width = 855 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent
237 Caption = "Fecha inicial:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 10 Top = 720 Width = 1215 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Fecha final:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 2520 TabIndex = 9 Top = 720 Width = 1215 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Inicio bloqueo:" Height = 255 Index = 3 Left = 120 TabIndex = 8 Top = 1080 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Final bloqueo:" Height = 255 Index = 4 Left = 2520 TabIndex = 7 Top = 1080 Width = 1095 Begin MSComctlLib.ImageList ImageListEjercicios Left = 0 Top = 5520 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarEjercicios Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarEjercicios" Top = 0 Width = 4980 _ExtentX = 8784 _ExtentY =
238 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmejercicios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mejercicios As Ejercicios Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub AyudarEjercicios() Sub Private Sub cancelardatos() txt(0) = Year(Date) txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" chk(0) = 0 txt(0).setfocus Sub Private Sub EliminarEjercicio() Dim rpta As Integer Dim aux As String Dim msg As String On Error GoTo EliminarEjercicioError If txt(0) <> "" Then If iejercicio = CInt(txt(0)) Then MsgBox msgerror(1030), vbcritical, App.Title Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("ejercicios", "ejercicio", "codigo_empresa = " & sempresa & " and ejercicio = " & txt(0), "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el ejercicio " & txt(0) & "? (Los datos relacionados con el ejercicio se eliminarán)", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mejercicios = New Ejercicios mejercicios.delete cn, sempresa, sdelegacion, txt(0), False Set mejercicios = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewEjercicios.ListItems.Remove ListViewEjercicios.ListItems("K" & txt(0)).index MsgBox msgerror(1031), vbcritical, App.Title Call cancelardatos
239 Exit Sub EliminarEjercicioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarEjercicio() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "ejercicio = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fecha_inicial = " & sdate(txt(1)) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fecha_final = " & sdate(txt(2)) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "inicio_bloqueo = " & sdate(txt(3)) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "final_bloqueo = " & sdate(txt(4)) & "" Call ListarEjercicios(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmejercicios = Forms(i) Next Call limatges16(me.imagelistejercicios) Set Me.ToolbarEjercicios.ImageList = Me.ImageListEjercicios Call cargarbotonera(me.toolbarejercicios) Call deshabilitarbotones(me.toolbarejercicios, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewEjercicios For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next
240 With txt(0) = Year(Date) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewEjercicios For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirEjercicios() Sub Private Sub InsertarEjercicio() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarEjercicioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("ejercicios", "ejercicio", "codigo_empresa = " & sempresa & " and ejercicio = " & txt(0), "#") Set mauxiliar = Nothing If aux = "#" Then Si no existe, lo inserto Set mejercicios = New Ejercicios mejercicios.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), IIf(chk(0), "S", "N"), IIf(chk(0), "S", "N"), susuario, False Set mejercicios = Nothing On Error Resume Next For i = 0 To 4 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewEjercicios.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) newitem.subitems(4) = txt(4) newitem.subitems(5) = IIf(Me.chk(0), "S", "N") Call cancelardatos For i = 0 To 4 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1031), vbcritical, App.Title Exit Sub InsertarEjercicioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub
241 Private Sub ListarEjercicios(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewEjercicios.ListItems.Clear Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, strwhere, "codigo_empresa, ejercicio") Do Until rs.eof Set newitem = ListViewEjercicios.ListItems.Add(, "K" & rs("ejercicio"), rs("ejercicio")) newitem.subitems(1) = ddate(nz(rs("fecha_inicial"), "")) newitem.subitems(2) = ddate(nz(rs("fecha_final"), "")) newitem.subitems(3) = ddate(nz(rs("inicio_bloqueo"), "")) newitem.subitems(4) = ddate(nz(rs("final_bloqueo"), "")) newitem.subitems(5) = Nz(rs("cerrado"), "N") rs.movenext Loop Set rs = Nothing Set mejercicios = Nothing Sub Private Sub ListViewEjercicios_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewEjercicios.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarEjercicio() Dim i As Integer Dim aux As String On Error GoTo ModificarEjercicioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("ejercicios", "ejercicio", "codigo_empresa = " & sempresa & " and ejercicio = " & txt(0), "#") Set mauxiliar = Nothing If aux <> "#" Then Si existe, lo modifico Set mejercicios = New Ejercicios mejercicios.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), IIf(chk(0), "S", "N"), IIf(chk(0), "S", "N"), susuario Set mejercicios = Nothing On Error Resume Next For i = 0 To 4 If txt(i) = "null" Then txt(i) = "" Next If iejercicio = CInt(txt(0)) Then sinicioejercicio = ddate(nz(txt(1), "")) sfinalejercicio = ddate(nz(txt(2), "")) siniciobloqueo = ddate(nz(txt(3), "")) sfinalbloqueo = ddate(nz(txt(4), "")) "N") ListViewEjercicios.ListItems("K" & txt(0)).subitems(1) = txt(1) ListViewEjercicios.ListItems("K" & txt(0)).subitems(2) = txt(2) ListViewEjercicios.ListItems("K" & txt(0)).subitems(3) = txt(3) ListViewEjercicios.ListItems("K" & txt(0)).subitems(4) = txt(4) ListViewEjercicios.ListItems("K" & txt(0)).subitems(5) = IIf(chk(0), "S", Call cancelardatos For i = 0 To 4 If txt(i) = "null" Then txt(i) = ""
242 Next MsgBox msgerror(1032), vbcritical, App.Title Exit Sub ModificarEjercicioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarEjercicios_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarEjercicio Case "modificar": If validardatos Then Call ModificarEjercicio Case "filtrar": Call FiltrarEjercicio Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarEjercicio Case "listar": Call ListarEjercicios Case "imprimir": Call ImprimirEjercicios Case "ayudar": Call AyudarEjercicios Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarEjercicios.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarEjercicios.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & sempresa & " and ejercicio = " & txt(0)) If Not rs.eof Then txt(1) = ddate(nz(rs("fecha_inicial"), "")) txt(2) = ddate(nz(rs("fecha_final"), "")) txt(3) = ddate(nz(rs("inicio_bloqueo"), "")) txt(4) = ddate(nz(rs("final_bloqueo"), "")) chk(0) = IIf((Nz(rs("cerrado"), "N") = "N"), 0, 1) Set rs = Nothing Set mejercicios = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Cancel = False Si un campo se informa, compruebo que sea correcto Select Case Index Case 0 If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(9999) Case 1, 2, 3, 4: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Select
243 If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer msg = "" validardatos = True Compruebo que los datos obligatorios se han informado For i = 0 To 4 Select Case i Case 0, 1, 2: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next Compruebo que no hay solapamientos de fechas Dim rs As ADODB.Recordset Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & sempresa & " ") If Not rs.eof Then rs.movefirst While Not rs.eof And msg = "" If (sdate(txt(1)) >= rs("fecha_inicial") And sdate(txt(1)) <= rs("fecha_final")) Or (sdate(txt(2)) >= rs("fecha_inicial") And sdate(txt(2)) <= rs("fecha_final")) Then If CInt(txt(0)) <> CInt(rs("ejercicio")) Then msg = msgerror(1033) rs.movenext Wend Set rs = Nothing Set mejercicios = Nothing If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
244 42. frmempresas.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmempresas Caption = "Empresas" ClientHeight = 6945 ClientLeft = 60 ClientTop = 345 ClientWidth = 4740 LinkTopic = "frmempresas" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 463 ScaleMode = 3 Pixel ScaleWidth = 316 Tag = "ToolbarEmpresas" Begin MSComctlLib.ListView ListViewEmpresas Height = 2865 Left = 0 TabIndex = 25 TabStop = 0 False Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Nombre" Object.Width = 6967 Property Begin VB.Frame frmdatos Height = 3615 Left = 0 TabIndex = 13 Top = 3300 Width = 4740 Begin VB.TextBox txt Index = 11 Left = 2355 TabIndex = 12 Top = 3120 Width = 2250 Begin VB.TextBox txt Index = 0 Left = 915 TabIndex = 1 Top = 300 Width = 975 Begin VB.TextBox txt Index = 1 Left =
245 TabIndex = 2 Top = 300 Width = 1170 Begin VB.TextBox txt Index = 2 Left = 915 TabIndex = 3 Top = 660 Width = 3690 Begin VB.TextBox txt Index = 3 Left = 915 TabIndex = 4 Top = 1020 Width = 3690 Begin VB.TextBox txt Index = 4 Left = 915 TabIndex = 5 Top = 1380 Width = 735 Begin VB.TextBox txt Index = 5 Left = 2715 TabIndex = 6 Top = 1380 Width = 1890 Begin VB.TextBox txt Index = 6 Left = 915 TabIndex = 7 Top = 1740 Width = 1455 Begin VB.TextBox txt Index = 7 Left = 3075 TabIndex = 8 Top = 1740 Width = 1530 Begin VB.TextBox txt Index = 8 Left = 915 TabIndex = 9 Top = 2100 Width = 1455 Begin VB.TextBox txt Index = 9 Left = 3075 TabIndex = 10 Top = 2100 Width = 1530 Begin VB.TextBox txt Index = 10 Left = 915 TabIndex = 11 Top = 2460 Width =
246 Begin VB.Line Line1 X1 = 75 X2 = 4600 Y1 = 2895 Y2 = 2895 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Longitud de las cuentas:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 11 Left = 75 TabIndex = 26 Top = 3135 Width = 2175 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 75 TabIndex = 24 Top = 300 Width = 735 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "NIF:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 2955 TabIndex = 23 Top = 300 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Nombre:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight =
247 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 75 TabIndex = 22 Top = 660 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Dirección:" Height = 255 Index = 3 Left = 75 TabIndex = 21 Top = 1020 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "C.P.:" Height = 255 Index = 4 Left = 75 TabIndex = 20 Top = 1380 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Población:" Height = 255 Index = 5 Left = 1755 TabIndex = 19 Top = 1380 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Provincia:" Height = 255 Index = 6 Left = 75 TabIndex = 18 Top = 1740 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "País:" Height = 255 Index = 7 Left = 2475 TabIndex = 17 Top = 1740 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Teléfono:" Height = 255 Index = 8 Left = 75 TabIndex = 16 Top = 2100 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "FAX:" Height = 255 Index = 9 Left =
248 TabIndex = 15 Top = 2100 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = " " Height = 255 Index = 10 Left = 75 TabIndex = 14 Top = 2460 Width = 735 Begin MSComctlLib.ImageList ImageListEmpresas Left = 120 Top = 7320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarEmpresas Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Top = 0 Width = 4740 _ExtentX = 8361 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmempresas" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mempresas As Empresas Private Sub AyudarEmpresas() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(6) = "" txt(7) = "" txt(8) = "" txt(9) = "" txt(10) = "" txt(11) = "" txt(0).setfocus Sub Private Sub EliminarEmpresa() Dim aux As String Dim rpta As Integer On Error GoTo EliminarEmpresaError If txt(0) <> "" Then Set mauxiliar = New Auxiliar
249 aux = mauxiliar.vbuscarcampo("empresas", "codigo_empresa", "codigo_empresa = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then If aux = sempresa Then MsgBox msgerror(1036), vbcritical, App.Title rpta = MsgBox(" Desea eliminar el empresa " & txt(0) & "? (Los datos relacionados con la empresa tambien se eliminarán)", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mempresas = New Empresas mempresas.delete cn, txt(0), False Set mempresas = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewEmpresas.ListItems.Remove ListViewEmpresas.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarEmpresaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarEmpresa() Dim filtro As String If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_empresa = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nif = " & txt(1) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nombre = " & txt(2) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "direccion = " & txt(3) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cp = " & txt(4) & "" If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "poblacion = " & txt(5) & "" If txt(6) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "provincia = " & txt(6) & "" If txt(7) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pais = " & txt(7) & "" If txt(8) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "telefono = " & txt(8) & ""
250 If txt(9) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fax = " & txt(9) & "" If txt(10) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "correo = " & txt(10) & "" Call ListarEmpresas(filtro) Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmempresas = Forms(i) Next Call limatges16(me.imagelistempresas) Set Me.ToolbarEmpresas.ImageList = Me.ImageListEmpresas Call cargarbotonera(me.toolbarempresas) Call deshabilitarbotones(me.toolbarempresas, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewEmpresas For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String Sub fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewEmpresas For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Private Sub ImprimirEmpresas() Sub Private Sub InsertarEmpresa() Dim i As Integer
251 Dim aux As String Dim newitem As ListItem On Error GoTo InsertarEmpresaError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("empresas", "codigo_empresa", "codigo_empresa = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux = "#" Then Si no existe, lo inserto Set mempresas = New Empresas mempresas.insert cn, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), txt(10), txt(11), susuario, False Set mempresas = Nothing On Error Resume Next For i = 0 To 11 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewEmpresas.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(2) Call cancelardatos For i = 0 To 11 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1011), vbcritical, App.Title Exit Sub InsertarEmpresaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarEmpresas(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem Elimino los datos de la lista ListViewEmpresas.ListItems.Clear Set mempresas = New Empresas Set rs = mempresas.getlist(cn, strwhere, "codigo_empresa") Do Until rs.eof Set newitem = ListViewEmpresas.ListItems.Add(, "K" & rs("codigo_empresa"), rs("codigo_empresa")) newitem.subitems(1) = Nz(rs("nombre"), "") rs.movenext Loop Set rs = Nothing Set mempresas = Nothing Sub Private Sub ListViewEmpresas_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewEmpresas.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarEmpresa() Dim i As Integer Dim aux As String On Error GoTo ModificarEmpresaError If txt(0) <> "" Then Set mauxiliar = New Auxiliar
252 aux = mauxiliar.vbuscarcampo("empresas", "codigo_empresa", "codigo_empresa = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Si existe, lo modifico Set mempresas = New Empresas mempresas.update cn, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), txt(10), txt(11), susuario, False Set mempresas = Nothing On Error Resume Next For i = 0 To 11 If txt(i) = "null" Then txt(i) = "" Next ListViewEmpresas.ListItems(ListViewEmpresas.ListItems("K" & txt(0)).index).subitems(1) = txt(2) Call cancelardatos For i = 0 To 11 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1011), vbcritical, App.Title Exit Sub ModificarEmpresaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarEmpresas_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarEmpresa Case "modificar": If validardatos Then Call ModificarEmpresa Case "filtrar": Call FiltrarEmpresa Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarEmpresa Case "listar": Call ListarEmpresas Case "imprimir": Call ImprimirEmpresas Case "ayudar": Call AyudarEmpresas Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarEmpresas.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarEmpresas.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset Me.ToolbarEmpresas.Buttons(7).Enabled = False If Index = 0 Then If txt(0) <> "" Then Set mempresas = New Empresas Set rs = mempresas.getlist(cn, "codigo_empresa = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("nif"), "") txt(2) = Nz(rs("nombre"), "") txt(3) = Nz(rs("direccion"), "") txt(4) = Nz(rs("cp"), "") txt(5) = Nz(rs("poblacion"), "") txt(6) = Nz(rs("provincia"), "") txt(7) = Nz(rs("pais"), "") txt(8) = Nz(rs("telefono"), "")
253 txt(9) = Nz(rs("fax"), "") txt(10) = Nz(rs("correo"), "") txt(11) = Nz(rs("digitos"), "") No permito cambiar la longitud del plan de cuentas txt(11).locked = Not rs.eof Set rs = Nothing Set mempresas = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Cancel = False msg = "" Select Case Index Case 1: If txt(index) <> "" Then If Not (validarnifnie(txt(index)) Or validarcif(txt(index))) Then msg = msgerror(1006) Case 11: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1007) txt(index).setfocus txt(index) = Replace(txt(Index), ".", ",") If txt(index) < 1 Or txt(index) > 12 Or Int(txt(Index)) <> txt(index) Then msg = msgerror(1007) txt(index).setfocus Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 11 Select Case i Case 0, 1, 2, 11: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 11 Select Case i Case 11: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".")
254 Select Next Function
255 43. frmextractos.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmextractos Caption = "Extracto de cuentas" ClientHeight = 3675 ClientLeft = 60 ClientTop = 450 ClientWidth = 4470 LinkTopic = "frmextractos" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 245 ScaleMode = 3 Pixel ScaleWidth = 298 Tag = "ToolbarExtractos" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 3270 Left = 0 TabIndex = 7 Top = 360 Width = 4455 Begin VB.TextBox txt Index = 5 Left = 1440 Locked = -1 True TabIndex = 13 Tag = "DELEGACIONES.codigo_delegacion" Top = 1425 Width = 1335 Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 120 TabIndex = 11 Top = 2700 Width = 4215 _ExtentX = 7435 _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Begin VB.OptionButton optfecha Caption = "Ordenación por fecha" Height = 255 Left = 975 TabIndex = 6 Top = 2250 Width = 2535 Begin VB.OptionButton optdiario Caption = "Ordenación por diarios y fecha" Height = 255 Left = 960 TabIndex = 5 Top = 1950 Value = -1 True Width =
256 Begin VB.TextBox txt Index = 3 Left = 1440 TabIndex = 3 Top = 1080 Width = 1335 Begin VB.TextBox txt Index = 4 Left = 3000 TabIndex = 4 Top = 1080 Width = 1335 Begin VB.TextBox txt Index = 1 Left = 1440 TabIndex = 1 Tag = "CUENTAS.cuenta" Top = 720 Width = 1335 Begin VB.TextBox txt Index = 0 Left = 1440 TabIndex = 0 Tag = "DIARIOS.codigo_diario" Top = 360 Width = 1335 Begin VB.TextBox txt Index = 2 Left = 3000 TabIndex = 2 Tag = "CUENTAS.cuenta" Top = 720 Width = 1335 Begin VB.Label lbl Caption = "Delegación:" Height = 255 Index = 4 Left = 120 TabIndex = 14 Top = 1425 Width = 1095 Begin VB.Label lbl Caption = "Fecha:" Height = 255 Index = 2 Left = 120 TabIndex = 10 Top = 1080 Width = 1455 Begin VB.Label lbl Caption = "Cuenta:" Height = 255 Index = 1 Left = 120 TabIndex = 9 Top = 720 Width = 1455 Begin VB.Label lbl Caption = "Diario:" Height = 255 Index = 0 Left = 120 TabIndex = 8 Top =
257 Width = 1455 Begin MSComctlLib.Toolbar ToolbarExtractos Align = 1 Align Top Height = 390 Left = 0 TabIndex = 12 Tag = "ToolbarCuentas" Top = 0 Width = 4470 _ExtentX = 7885 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListExtractos Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmextractos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim minformes As Informes Dim mapuntes As Apuntes Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudarextractos() Sub Private Sub cancelardatos() txt(0) = "": txt(1) = "": txt(2) = "": txt(3) = "": txt(4) = "": txt(5) = "" barrainformes.min = 0: barrainformes.value = 0 txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmextractos = Forms(i) Next Call limatges16(me.imagelistextractos)
258 Set Me.ToolbarExtractos.ImageList = Me.ImageListExtractos Call cargarbotonera(me.toolbarextractos) Call deshabilitarbotones(me.toolbarextractos, "insertar", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) If sempresa <> sdelegacion Then txt(5) = sdelegacion txt(5).enabled = False Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub guardartemporalextractos(rs As ADODB.Recordset, strwheresaldoanterior) Dim cuenta As String Dim titulo As String Dim saldo_anterior As Double Dim rst As ADODB.Recordset Dim contador As Integer Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.begintrans cnt.execute "DELETE FROM Extractos" Set rst = New ADODB.Recordset rst.open "SELECT * FROM Extractos", cnt, adopenstatic, adlockoptimistic Set mauxiliar = New Auxiliar While Not rs.eof rst.addnew rst("cuenta") = rs("cuenta") rst("codigo_diario") = rs("codigo_diario") rst("fecha_apunte") = rs("fecha_apunte") rst("numero_documento") = rs("numero_documento") rst("numero_apunte") = rs("numero_apunte") rst("concepto") = rs("concepto") rst("debe") = rs("debe") rst("haber") = rs("haber") If cuenta <> rs("cuenta") Then cuenta = rs("cuenta") saldo_anterior = mauxiliar.vbuscarcampo("apuntes", "SUM(debe-haber) AS saldo_anterior", strwheresaldoanterior & " AND cuenta = " & rs("cuenta") & "", 0) titulo = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & rs("cuenta") & "", "") rst("saldo_anterior") = saldo_anterior
259 rst("titulo") = titulo rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend Set mauxiliar = Nothing rst.close cnt.committrans Set rst = Nothing Sub Private Sub imprimir() Dim periodo As String Dim empresa As String Dim delegación As String Dim ordenacion As String periodo = "del " & IIf(txt(3) <> "", txt(3), ddate(sinicioejercicio)) & " al " & IIf(txt(4) <> "", txt(4), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing empresa = empresa & IIf(txt(5) <> "", " // Delegaciones: " & txt(5), "") If Me.optDiario Then ordenacion = "Por diario y fecha contable" If Me.optFecha Then ordenacion = "Por fecha contable" Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("extracto.rpt", "Extractos", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "", "ordenacion = " & ordenacion & "") If optdiario Then minformes.obj.sqlquery = "SELECT * FROM Extractos ORDER BY cuenta, codigo_diario, fecha_apunte" minformes.obj.sqlquery = "SELECT * FROM Extractos ORDER BY cuenta, fecha_apunte" Call minformes.execute Set minformes = Nothing Sub Private Sub imprimirextractos() Dim rs As ADODB.Recordset Dim strwherereport As String Dim strwheresaldoanterior As String Call obtenerwhere(strwherereport, strwheresaldoanterior) Set rs = obtenerdatos(strwherereport) If Not rs.eof Then Call guardartemporalextractos(rs, strwheresaldoanterior) Call imprimir MsgBox msgerror(9999), vbcritical, App.Title Sub Private Function obtenerdatos(strwherereport As String) As Object Dim rs As ADODB.Recordset Set mapuntes = New Apuntes Set rs = mapuntes.getlist(cn, strwherereport, "cuenta")
260 Set mapuntes = Nothing Set obtenerdatos = rs Function Private Sub obtenerwhere(strwherereport As String, strwheresaldoanterior As String) Dim aux As String strwherereport = "codigo_empresa = " & sempresa & " " If txt(5) <> "" Then If sempresa <> sdelegacion Then strwherereport = strwherereport & " and codigo_delegacion = " & sdelegacion & " " aux = "" & txt(5) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwherereport = strwherereport & "and codigo_delegacion in (" & aux & ") " If txt(0) <> "" Then aux = "" & txt(0) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwherereport = strwherereport & "and codigo_diario in (" & aux & ") " strwheresaldoanterior = strwherereport If txt(1) <> "" Then strwherereport = strwherereport & "and cuenta >= " & txt(1) & " " If txt(2) <> "" Then strwherereport = strwherereport & "and cuenta <= " & txt(2) & " " If txt(3) <> "" Then strwherereport = strwherereport & "and fecha_apunte >= " & sdate(txt(3)) & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sdate(txt(3)) & " " strwherereport = strwherereport & "and fecha_apunte >= " & sinicioejercicio & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sinicioejercicio & " " If txt(4) <> "" Then strwherereport = strwherereport & "and fecha_apunte <= " & sdate(txt(4)) & " " strwherereport = strwherereport & "and fecha_apunte <= " & sfinalejercicio & " " Sub Private Sub ToolbarExtractos_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirextractos Case "ayudar": Call ayudarextractos Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarExtractos.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarExtractos.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 121 And Shift = 0 And Me.ToolbarExtractos.Buttons(7).Enabled Then Call mostrarlupa(me) F10 Sub Private Sub txt_lostfocus(index As Integer) Select Case Index
261 Case 1, 2: txt(index) = transformarcuenta(txt(index), icuenta) Select Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Select Case Index Case 3, 4: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub
262 44. frmformaspago.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmformaspago Caption = "Formas de Pago" ClientHeight = 5985 ClientLeft = 60 ClientTop = 345 ClientWidth = 4980 LinkTopic = "frmformaspago" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 399 ScaleMode = 3 Pixel ScaleWidth = 332 Tag = "ToolbarFormasPago" Begin MSComctlLib.ListView ListViewFormasPago Height = 2865 Left = 0 TabIndex = 14 TabStop = 0 False Top = 450 Width = 4980 _ExtentX = 8784 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Descripción" Object.Width = 6967 Property Begin VB.Frame frmdatos Height = 2700 Index = 3 Left = 0 TabIndex = 11 Top = 3300 Width = 4980 Begin VB.TextBox txt Index = 9 Left = 3960 TabIndex = 10 Top = 2160 Width = 800 Begin VB.TextBox txt Index = 8 Left = 1320 TabIndex = 9 Top = 2160 Width = 800 Begin VB.TextBox txt
263 Index = 7 Left = 3960 TabIndex = 8 Top = 1800 Width = 800 Begin VB.TextBox txt Index = 6 Left = 1320 TabIndex = 7 Top = 1800 Width = 800 Begin VB.TextBox txt Index = 5 Left = 3960 TabIndex = 6 Top = 1440 Width = 800 Begin VB.TextBox txt Index = 4 Left = 1320 TabIndex = 5 Top = 1440 Width = 800 Begin VB.TextBox txt Index = 3 Left = 3960 TabIndex = 4 Top = 1080 Width = 800 Begin VB.TextBox txt Index = 2 Left = 1320 TabIndex = 3 Top = 1080 Width = 800 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 1 Top = 285 Width = 825 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 2 Top = 645 Width = 3450 Begin VB.Label lblpct Alignment = 2 Center Caption = "Porcentaje" Height = 240 Index = 5 Left = 2880 TabIndex = 26 Top = 2175 Width = 915 Begin VB.Label lblpct Alignment = 2 Center Caption = "Porcentaje" Height = 240 Index =
264 Left = 2880 TabIndex = 25 Top = 1815 Width = 915 Begin VB.Label lblpct Alignment = 2 Center Caption = "Porcentaje" Height = 240 Index = 3 Left = 2880 TabIndex = 24 Top = 1455 Width = 915 Begin VB.Label lbldias Caption = "días" Height = 240 Index = 5 Left = 2160 TabIndex = 23 Top = 2182 Width = 555 Begin VB.Label lbldias Caption = "días" Height = 240 Index = 4 Left = 2160 TabIndex = 22 Top = 1822 Width = 555 Begin VB.Label lbldias Caption = "días" Height = 240 Index = 3 Left = 2160 TabIndex = 21 Top = 1462 Width = 555 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "4to. vto a" ForeColor = &H & Height = 255 Index = 5 Left = 120 TabIndex = 20 Top = 2175 Width = 1095 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "3er. vto a" ForeColor = &H & Height = 255 Index = 4 Left = 120 TabIndex = 19 Top = 1815 Width = 1095 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "2do. vto a" ForeColor = &H & Height = 255 Index = 3 Left =
265 TabIndex = 18 Top = 1455 Width = 1095 Begin VB.Label lblpct Alignment = 2 Center Caption = "Porcentaje" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 2 Left = 2880 TabIndex = 17 Top = 1095 Width = 915 Begin VB.Label lbldias Caption = "días" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 240 Index = 2 Left = 2160 TabIndex = 16 Top = 1102 Width = 555 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "1er. vto a" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 2 Left = 120 TabIndex = 15 Top = 1095 Width = 1095 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property
266 ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 13 Top = 285 Width = 855 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 12 Top = 645 Width = 1095 Begin MSComctlLib.ImageList ImageListFormasPago Left = 75 Top = 6450 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarFormasPago Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarFormasPago" Top = 0 Width = 4980 _ExtentX = 8784 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmformaspago" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mformaspago As FormasPago Private Sub AyudarFormasPago() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = ""
267 txt(6) = "" txt(7) = "" txt(8) = "" txt(9) = "" txt(0).setfocus Sub Private Sub EliminarFormasPago() Dim rpta As Integer Dim aux As String On Error GoTo EliminarDiarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("formaspagos", "codigo_pago", "codigo_empresa = " & sempresa & " and codigo_pago = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar la forma de pago " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mformaspago = New FormasPago mformaspago.delete cn, sempresa, txt(0) Set mformaspago = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewFormasPago.ListItems.Remove ListViewFormasPago.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarDiarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarFormasPago() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_pago = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion= " & txt(1) & "" Call ListarFormasPago(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmformaspago = Forms(i) Next Call limatges16(me.imagelistformaspago)
268 Set Me.ToolbarFormasPago.ImageList = Me.ImageListFormasPago Call cargarbotonera(me.toolbarformaspago) Call deshabilitarbotones(me.toolbarformaspago, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewFormasPago For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewFormasPago For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirFormasPago() Sub Private Sub InsertarFormasPago() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarFormasPagoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("formaspagos", "codigo_pago", "codigo_empresa = " & sempresa & " and codigo_pago = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mformaspago = New FormasPago mformaspago.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), susuario Set mformaspago = Nothing On Error Resume Next For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewFormasPago.ListItems.Add(, "K" & Trim(txt(0)), txt(0)) newitem.subitems(1) = txt(1) Call cancelardatos
269 For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1013), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarFormasPagoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarFormasPago(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewFormasPago.ListItems.Clear Set mformaspago = New FormasPago Set rs = mformaspago.getlist(cn, strwhere, "codigo_empresa, codigo_pago") Do Until rs.eof Set newitem = ListViewFormasPago.ListItems.Add(, "K" & Trim(rs("codigo_pago")), rs("codigo_pago")) newitem.subitems(1) = Nz(rs("descripcion"), "") rs.movenext Loop Set rs = Nothing Set mformaspago = Nothing Sub Private Sub ListViewFormasPago_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewFormasPago.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarFormasPago() Dim i As Integer Dim aux As String On Error GoTo ModificarFormasPagoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("formaspagos", "codigo_pago", "codigo_empresa = " & sempresa & " and codigo_pago = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mformaspago = New FormasPago mformaspago.update cn, sempresa, txt(0), txt(1), txt(2), CDbl(txt(3)), txt(4), CDbl(txt(5)), txt(6), CDbl(txt(7)), txt(8), CDbl(txt(9)), susuario Set mformaspago = Nothing On Error Resume Next For i = 0 To 9 If txt(i) = "null" Then txt(i) = "" Next ListViewFormasPago.ListItems(ListViewFormasPago.FindItem(txt(0)).Index).Selected = True ListViewFormasPago.SelectedItem.SubItems(1) = txt(1) Call cancelardatos For i = 0 To 9 If txt(i) = "null" Then txt(i) = ""
270 Next MsgBox msgerror(1014), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarFormasPagoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarFormasPago_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then InsertarFormasPago Case "modificar": If validardatos Then ModificarFormasPago Case "filtrar": Call FiltrarFormasPago Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarFormasPago Case "listar": Call ListarFormasPago Case "imprimir": Call ImprimirFormasPago Case "ayudar": Call AyudarFormasPago Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarFormasPago.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarFormasPago.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then Set mformaspago = New FormasPago Set rs = mformaspago.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_pago = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("descripcion"), "") txt(2) = Nz(rs("vto1"), "") txt(3) = Nz(rs("pct1"), "") txt(4) = Nz(rs("vto2"), "") txt(5) = Nz(rs("pct2"), "") txt(6) = Nz(rs("vto3"), "") txt(7) = Nz(rs("pct3"), "") txt(8) = Nz(rs("vto4"), "") txt(9) = Nz(rs("pct4"), "") Set rs = Nothing Set mformaspago = Nothing Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer Dim sumapct As Double sumapct = 0 validardatos = True For i = 0 To 9 Select Case i Case 0, 1, 2, 3: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For
271 Case 2, 4, 6, 8: If txt(i) <> "" And txt(i + 1) = "" Then msg = msgerror(1008) txt(i + 1).SetFocus Exit For Select Select Case i Case 3, 5, 7, 9: If txt(i) <> "" And txt(i - 1) = "" Then msg = msgerror(1009) txt(i + 1).SetFocus Exit For txt(i) = Replace(txt(i), ".", ",") If txt(i) <> "" Then sumapct = sumapct + txt(i) Select Next If sumapct <> 100 And msg = "" Then msg = msgerror(1010) If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 9 Select Case i Case 2, 3, 4, 5, 6, 7, 8, 9: Controlo que los valores numéricos tengan valor y formato correcto If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
272 45. frmimpuestos.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmimpuestos Caption = "Impuestos" ClientHeight = 5670 ClientLeft = 60 ClientTop = 345 ClientWidth = 4980 LinkTopic = "frmimpuestos" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 378 ScaleMode = 3 Pixel ScaleWidth = 332 Tag = "ToolbarImpuestos" Begin MSComctlLib.ListView ListViewImpuestos Height = 2865 Left = 0 TabIndex = 16 TabStop = 0 False Top = 450 Width = 4980 _ExtentX = 8784 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 7 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Impuesto" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Cuenta IVA" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Pct. IVA" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Cuenta RE" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Pct. RE" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Tipo" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Descripción" Object.Width = Property Begin VB.Frame frmdatos
273 Height = 2355 Left = 0 TabIndex = 10 Top = 3300 Width = 4980 Begin VB.TextBox txt Index = 5 Left = 1320 TabIndex = 6 Top = 1440 Width = 3525 Begin VB.Frame frmtipo BorderStyle = 0 None Height = 240 Left = 1725 TabIndex = 17 Top = 1890 Width = 2940 Begin VB.OptionButton opt Caption = "Inversión" Height = 240 Index = 2 Left = 1950 TabIndex = 9 Top = 0 Width = 990 Begin VB.OptionButton opt Caption = "Venta" Height = 240 Index = 1 Left = 1050 TabIndex = 8 Top = 0 Width = 840 Begin VB.OptionButton opt Caption = "Compra" Height = 240 Index = 0 Left = 75 TabIndex = 7 Top = 0 Value = -1 True Width = 915 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 1 Top = 360 Width = 825 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 2 Tag = "CUENTAS.cuenta" Top = 720 Width = 1170 Begin VB.TextBox txt Index = 2 Left = 3675 TabIndex = 3 Top = 720 Width = 1170 Begin VB.TextBox txt
274 Index = 3 Left = 1320 TabIndex = 4 Tag = "CUENTAS.cuenta" Top = 1080 Width = 1170 Begin VB.TextBox txt Index = 4 Left = 3675 TabIndex = 5 Top = 1080 Width = 1170 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 6 Left = 120 TabIndex = 19 Top = 1440 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Tipo de impuesto:" Height = 255 Index = 5 Left = 300 TabIndex = 18 Top = 1890 Width = 1320 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Impuesto:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 15 Top = 360 Width = 855 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Cuenta IVA:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight =
275 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 14 Top = 720 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Pct. IVA:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 2760 TabIndex = 13 Top = 720 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Cuenta RE:" Height = 255 Index = 3 Left = 120 TabIndex = 12 Top = 1080 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Pct. RE:" Height = 255 Index = 4 Left = 2760 TabIndex = 11 Top = 1080 Width = 840 Begin MSComctlLib.ImageList ImageListImpuestos Left = 120 Top = 6000 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarImpuestos Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarImpuestos" Top = 0 Width = 4980 _ExtentX = 8784 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmimpuestos"
276 Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mimpuestos As Impuestos Private Sub AyudarImpuestos() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" opt(0) = True txt(0).setfocus Sub Private Sub EliminarImpuesto() Dim rpta As Integer Dim aux As String Dim rs As ADODB.Recordset On Error GoTo EliminarImpuestoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("impuestos", "impuesto", "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Dim mauxiliariva As New Auxiliar Set rs = mauxiliar.getlistext(cn, "RegistroIVA", "impuesto", "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "", "impuesto") Set mauxiliariva = Nothing If Not rs.eof Then Si ya existe alguna entrada con este impuesto, cancelamos la eliminacion MsgBox msgerror(1035), vbcritical, App.Title rpta = MsgBox(" Desea eliminar el impuesto " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mimpuestos = New Impuestos mimpuestos.delete cn, sempresa, txt(0) Set mimpuestos = Nothing txt(0)).index Call cancelardatos En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewImpuestos.ListItems.Remove ListViewImpuestos.ListItems("K" & Exit Sub EliminarImpuestoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarImpuesto() Dim filtro As String filtro = "codigo_empresa = " & sempresa & ""
277 If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "impuesto = " & txt(0) & " " If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cta_iva = " & txt(1) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pct_iva = " & str(txt(2)) & " " If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cta_re = " & txt(3) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pct_re = " & str(txt(4)) & " " If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion = " & txt(5) & " " Call ListarImpuestos(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmimpuestos = Forms(i) Next Call limatges16(me.imagelistimpuestos) Set Me.ToolbarImpuestos.ImageList = Me.ImageListImpuestos Call cargarbotonera(me.toolbarimpuestos) Call deshabilitarbotones(me.toolbarimpuestos, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewImpuestos For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer
278 Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewImpuestos For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirImpuestos() Sub Private Sub InsertarImpuesto() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarImpuestoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("impuestos", "impuesto", "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mimpuestos = New Impuestos mimpuestos.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), IIf(opt(0), "C", IIf(opt(1), "V", "I")), susuario Set mimpuestos = Nothing On Error Resume Next For i = 0 To 5 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewImpuestos.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) newitem.subitems(4) = txt(4) newitem.subitems(5) = IIf(opt(0), "C", IIf(opt(1), "V", "I")) newitem.subitems(6) = txt(5) Call cancelardatos For i = 0 To 5 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarImpuestoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarImpuestos(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & ""
279 Elimino los datos de la lista ListViewImpuestos.ListItems.Clear Set mimpuestos = New Impuestos Set rs = mimpuestos.getlist(cn, strwhere, "codigo_empresa, impuesto") Do Until rs.eof Set newitem = ListViewImpuestos.ListItems.Add(, "K" & rs("impuesto"), rs("impuesto")) newitem.subitems(1) = Nz(rs("cta_iva"), "") newitem.subitems(2) = Nz(rs("pct_iva"), "") newitem.subitems(3) = Nz(rs("cta_re"), "") newitem.subitems(4) = Nz(rs("pct_re"), "") newitem.subitems(5) = Nz(rs("tipo"), "") newitem.subitems(6) = Nz(rs("descripcion"), "") rs.movenext Loop Set rs = Nothing Set mimpuestos = Nothing Sub Private Sub ListViewImpuestos_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewImpuestos.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarImpuesto() Dim i As Integer Dim aux As String Dim rs As ADODB.Recordset On Error GoTo ModificarImpuestoError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("impuestos", "impuesto", "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "", "#") If aux <> "#" Then Dim mauxiliariva As New Auxiliar Set rs = mauxiliar.getlistext(cn, "RegistroIVA", "impuesto", "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "", "impuesto") Set mauxiliariva = Nothing If Not rs.eof Then Si ya existe alguna entrada con este impuesto, cancelamos la modificación MsgBox msgerror(1035), vbcritical, App.Title Si existe, lo modifico Set mimpuestos = New Impuestos mimpuestos.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), IIf(opt(0), "C", IIf(opt(1), "V", "I")), susuario Set mimpuestos = Nothing On Error Resume Next For i = 0 To 5 If txt(i) = "null" Then txt(i) = "" Next ListViewImpuestos.ListItems(ListViewImpuestos.FindItem(txt(0)).Index).Selected = True ListViewImpuestos.SelectedItem.SubItems(1) = txt(1) ListViewImpuestos.SelectedItem.SubItems(2) = txt(2) ListViewImpuestos.SelectedItem.SubItems(3) = txt(3) ListViewImpuestos.SelectedItem.SubItems(4) = txt(4) ListViewImpuestos.SelectedItem.SubItems(5) = IIf(opt(0), "C", IIf(opt(1), "V", "I")) ListViewImpuestos.SelectedItem.SubItems(6) = txt(5) Set rs = Nothing
280 Call cancelardatos For i = 0 To 5 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarImpuestoError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub opt_gotfocus(index As Integer) Me.ToolbarImpuestos.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Sub Private Sub ToolbarImpuestos_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarImpuesto Case "modificar": If validardatos Then Call ModificarImpuesto Case "filtrar": Call FiltrarImpuesto Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarImpuesto Case "listar": Call ListarImpuestos Case "imprimir": Call ImprimirImpuestos Case "ayudar": Call AyudarImpuestos Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarImpuestos.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarImpuestos.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then Set mimpuestos = New Impuestos Set rs = mimpuestos.getlist(cn, "codigo_empresa = " & sempresa & " and impuesto = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("cta_iva"), "") txt(2) = Nz(rs("pct_iva"), "") txt(3) = Nz(rs("cta_re"), "") txt(4) = Nz(rs("pct_re"), "") txt(5) = Nz(rs("descripcion"), "") opt(0) = (Nz(rs("tipo"), "") = "C") opt(1) = (Nz(rs("tipo"), "") = "V") opt(2) = (Nz(rs("tipo"), "") = "I") Set rs = Nothing Set mimpuestos = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String msg = "" Cancel = False Set mauxiliar = New Auxiliar
281 Select Case Index Case 1, 3: If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " and cuenta = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1001) Case 2, 4: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1024) txt(index) = Replace(txt(Index), ".", ",") Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 5 Select Case i Case 0, 1, 2, 5: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Case 3: If txt(i) <> "" And txt(i + 1) = "" Then msg = msgerror(1008) txt(i) = "" Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 5 Select Case i Case 2, 4: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
282 46. frminvertir.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frminvertir Caption = "Invertir cierre" ClientHeight = 1575 ClientLeft = 60 ClientTop = 450 ClientWidth = 7200 LinkTopic = "frminvertir" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 105 ScaleMode = 3 Pixel ScaleWidth = 480 Tag = "ToolbarInvertir" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 1125 Left = 0 TabIndex = 0 Top = 360 Width = 7065 Begin VB.Label lbl Alignment = 2 Center Caption = "Esta operación invertirá el cierre del ejercicio 2000" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 735 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 6765 Begin MSComctlLib.Toolbar ToolbarInvertir Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCuentas" Top = 0 Width = 7200 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListInvertir Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor =
283 _Version = Attribute VB_Name = "frminvertir" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mcierre As Cierre Dim mregularizacion As Regularizacion Private Sub ayudarinvertir() Sub Private Sub deshacercierre() Dim cerrado As String Set mauxiliar = New Auxiliar cerrado = mauxiliar.vbuscarcampo("ejercicios", "cerrado", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio + 1, "#") Set mauxiliar = Nothing If cerrado = "S" Then MsgBox msgerror(1048), vbcritical, App.Title Set mregularizacion = New Regularizacion mregularizacion.delete cn, sempresa, iejercicio, "REGU" & Trim(str(iEjercicio)), susuario, False Set mregularizacion = Nothing Set mcierre = New Cierre mcierre.delete cn, sempresa, iejercicio, "CIER" & Trim(str(iEjercicio)), "APER" & Trim(str(iEjercicio + 1)), susuario, False Set mcierre = Nothing MsgBox "Operación finalizada.", vbinformation, App.Title Unload Me Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frminvertir = Forms(i) Next Call limatges16(me.imagelistinvertir) Set Me.ToolbarInvertir.ImageList = Me.ImageListInvertir Call cargarbotonera(me.toolbarinvertir) Call deshabilitarbotones(me.toolbarinvertir, "cancelar", "lupa", "imprimir", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight)
284 lbl(0) = "Esta operación invertirá el cierre del ejercicio " & Trim(str(iEjercicio)) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarInvertir_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "insertar": Call deshacercierre Case "ayudar": Call ayudarinvertir Select Sub
285 47. frmirpf.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmirpf Caption = "Irpf" ClientHeight = 4845 ClientLeft = 60 ClientTop = 345 ClientWidth = 4740 LinkTopic = "frmirpf" MDIChild = -1 True ScaleHeight = 323 ScaleMode = 3 Pixel ScaleWidth = 316 Tag = "ToolbarIrpf" Begin MSComctlLib.ListView ListViewIrpf Height = 2865 Left = 0 TabIndex = 8 TabStop = 0 False Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 4 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Cuenta" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Pct. Irpf" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Descripción" Object.Width = Property Begin VB.Frame frmdatos Height = 1515 Left = 0 TabIndex = 5 Top = 3300 Width = 4740 Begin VB.TextBox txt Index = 3 Left = 1260 TabIndex = 3 Top = 1050 Width = 3345 Begin VB.TextBox txt Index = 2 Left =
286 TabIndex = 2 Top = 675 Width = 975 Begin VB.TextBox txt Index = 0 Left = 1260 TabIndex = 0 Top = 300 Width = 1200 Begin VB.TextBox txt Index = 1 Left = 1260 TabIndex = 1 Tag = "CUENTAS.cuenta" Top = 660 Width = 1215 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 3 Left = 75 TabIndex = 10 Top = 1050 Width = 1080 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Pct IRPF:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 2640 TabIndex = 9 Top = 675 Width = 960 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left =
287 TabIndex = 7 Top = 300 Width = 735 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Cuenta:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 1 Left = 75 TabIndex = 6 Top = 660 Width = 960 Begin MSComctlLib.ImageList ImageListIrpf Left = 0 Top = 6300 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarIrpf Align = 1 Align Top Height = 390 Left = 0 TabIndex = 4 Tag = "ToolbarIrpf" Top = 0 Width = 4740 _ExtentX = 8361 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmirpf" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mirpf As irpf Private Sub AyudarIrpf() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(0).setfocus Sub Private Sub EliminarIrpf() Dim rpta As Integer Dim aux As String On Error GoTo EliminarIrpfError
288 If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("irpf", "codigo", "codigo_empresa = " & sempresa & " AND codigo = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el Irpf " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mirpf = New irpf mirpf.delete cn, sempresa, txt(0) Set mirpf = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewIrpf.ListItems.Remove ListViewIrpf.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarIrpfError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarIrpf() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cuenta = " & txt(1) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pct_irpf = " & str(txt(2)) & " " If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion = " & txt(3) & "" Call ListarIrpf(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmirpf = Forms(i) Next Call limatges16(me.imagelistirpf) Set Me.ToolbarIrpf.ImageList = Me.ImageListIrpf Call cargarbotonera(me.toolbarirpf) Call deshabilitarbotones(me.toolbarirpf, "lupa", "imprimir")
289 Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewIrpf For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewIrpf For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirIrpf() Sub Private Sub InsertarIrpf() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarIrpfError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("irpf", "codigo", "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mirpf = New irpf mirpf.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), susuario Set mirpf = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewIrpf.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) Call cancelardatos For i = 0 To
290 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarIrpfError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarIrpf(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewIrpf.ListItems.Clear Set mirpf = New irpf Set rs = mirpf.getlist(cn, strwhere, "codigo_empresa, codigo") Do Until rs.eof Set newitem = ListViewIrpf.ListItems.Add(, "K" & rs("codigo"), rs("codigo")) newitem.subitems(1) = Nz(rs("cuenta"), "") newitem.subitems(2) = Nz(rs("pct_irpf"), "") newitem.subitems(3) = Nz(rs("descripcion"), "") rs.movenext Loop Set rs = Nothing Set mirpf = Nothing Sub Private Sub ListViewIrpf_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewIrpf.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarIrpf() Dim i As Integer Dim aux As String On Error GoTo ModificarIrpfError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("irpf", "codigo", "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mirpf = New irpf mirpf.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), susuario Set mirpf = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next ListViewIrpf.ListItems(ListViewIrpf.ListItems("K" & txt(0)).index).subitems(1) = txt(1) ListViewIrpf.ListItems(ListViewIrpf.ListItems("K" & txt(0)).index).subitems(2) = txt(2) ListViewIrpf.ListItems(ListViewIrpf.ListItems("K" & txt(0)).index).subitems(3) = txt(3) Call cancelardatos For i = 0 To
291 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarIrpfError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarIrpf_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarIrpf Case "modificar": If validardatos Then Call ModificarIrpf Case "filtrar": Call FiltrarIrpf Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarIrpf Case "listar": Call ListarIrpf Case "imprimir": Call ImprimirIrpf Case "ayudar": Call AyudarIrpf Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarIrpf.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarIrpf.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then Set mirpf = New irpf Set rs = mirpf.getlist(cn, "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("cuenta"), "") txt(2) = Nz(rs("pct_irpf"), "") txt(3) = Nz(rs("descripcion"), "") Set rs = Nothing Set mirpf = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 1: If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " and cuenta = " & txt(index) & " and pases = S", "#") If aux = "#" Then msg = msgerror(1001) Case 2:
292 If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1024) txt(index) = Replace(txt(Index), ".", ",") Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 3 Select Case i Case 0, 1, 2, 3: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 3 Select Case i Case 2: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
293 48. frmlibrodiario.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmlibrodiario Caption = "Libro Diario" ClientHeight = 3195 ClientLeft = 60 ClientTop = 450 ClientWidth = 4470 LinkTopic = "frmlibrodiario" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 213 ScaleMode = 3 Pixel ScaleWidth = 298 Tag = "ToolbarLibroDiario" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 2835 Left = 0 TabIndex = 3 Top = 360 Width = 4455 Begin VB.TextBox txt Index = 6 Left = 1350 TabIndex = 13 Tag = "DELEGACIONES.codigo_delegacion" Top = 1725 Width = 1335 Begin VB.TextBox txt Index = 5 Left = 2925 TabIndex = 12 Top = 1350 Width = 1335 Begin VB.TextBox txt Index = 4 Left = 1350 TabIndex = 11 Top = 1350 Width = 1335 Begin VB.TextBox txt Index = 3 Left = 1350 TabIndex = 9 Tag = "DOCUMENTOS.codigo_documento" Top = 975 Width = 1335 Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 75 TabIndex = 6 Top = 2250 Width = 4215 _ExtentX =
294 _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Begin VB.TextBox txt Index = 1 Left = 1350 TabIndex = 1 Top = 600 Width = 1335 Begin VB.TextBox txt Index = 2 Left = 2925 TabIndex = 2 Top = 600 Width = 1335 Begin VB.TextBox txt Index = 0 Left = 1350 TabIndex = 0 Tag = "DIARIOS.codigo_diario" Top = 225 Width = 1335 Begin VB.Label lbl Caption = "Delegación:" Height = 255 Index = 4 Left = 75 TabIndex = 14 Top = 1725 Width = 1305 Begin VB.Label lbl Caption = "Documentos:" Height = 255 Index = 3 Left = 75 TabIndex = 10 Top = 1350 Width = 1305 Begin VB.Label lbl Caption = "Tipo documento:" Height = 255 Index = 2 Left = 75 TabIndex = 8 Top = 975 Width = 1305 Begin VB.Label lbl Caption = "Fecha:" Height = 255 Index = 1 Left = 75 TabIndex = 5 Top = 600 Width = 1305 Begin VB.Label lbl Caption = "Diario:" Height = 255 Index = 0 Left = 75 TabIndex = 4 Top = 225 Width =
295 Begin MSComctlLib.Toolbar ToolbarLibroDiario Align = 1 Align Top Height = 390 Left = 0 TabIndex = 7 Tag = "ToolbarCuentas" Top = 0 Width = 4470 _ExtentX = 7885 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListLibroDiario Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmlibrodiario" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim minformes As Informes Dim mapuntes As Apuntes Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudarlibrodiario() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(6) = IIf(sEmpresa = sdelegacion, "", txt(6)) barrainformes.min = 0: barrainformes.value = 0 txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmlibrodiario = Forms(i)
296 Next Call limatges16(me.imagelistlibrodiario) Set Me.ToolbarLibroDiario.ImageList = Me.ImageListLibroDiario Call cargarbotonera(me.toolbarlibrodiario) Call deshabilitarbotones(me.toolbarlibrodiario, "insertar", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) If sempresa <> sdelegacion Then txt(6) = sdelegacion txt(6).enabled = False Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub guardartemporallibrodiario(rs As ADODB.Recordset, strwheresaldoanterior) Dim rst As ADODB.Recordset Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.begintrans cnt.execute "DELETE FROM LibroDiario" Set rst = New ADODB.Recordset rst.open "SELECT * FROM LibroDiario", cnt, adopenstatic, adlockoptimistic Set mauxiliar = New Auxiliar While Not rs.eof rst.addnew rst("fecha_apunte") = rs("fecha_apunte") rst("numero_documento") = rs("numero_documento") rst("numero_apunte") = rs("numero_apunte") rst("cuenta") = rs("cuenta") rst("titulo") = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & rs("cuenta") & "", "") rst("concepto") = rs("concepto") rst("debe") = rs("debe") rst("haber") = rs("haber") rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend Set mauxiliar = Nothing rst.close
297 cnt.committrans Set rst = Nothing Sub Private Sub imprimir() Dim periodo As String Dim empresa As String Dim delegación As String Dim ordenacion As String periodo = "del " & IIf(txt(1) <> "", txt(1), ddate(sinicioejercicio)) & " al " & IIf(txt(2) <> "", txt(2), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") & IIf(txt(6) <> "", " // Delegación: " & txt(6), "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("librodiario.rpt", "Libro Diario", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM LibroDiario ORDER BY fecha_apunte, numero_documento, numero_apunte" Call minformes.execute Set minformes = Nothing Sub Private Sub imprimirlibrodiario() Dim rs As ADODB.Recordset Dim strwherereport As String Dim strwheresaldoanterior As String Call obtenerwhere(strwherereport, strwheresaldoanterior) Set rs = obtenerdatos(strwherereport) If Not rs.eof Then Call guardartemporallibrodiario(rs, strwheresaldoanterior) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Function obtenerdatos(strwherereport As String) As Object Dim rs As ADODB.Recordset Set mapuntes = New Apuntes Set rs = mapuntes.getlist(cn, strwherereport, "cuenta") Set mapuntes = Nothing Set obtenerdatos = rs Function Private Sub obtenerwhere(strwherereport As String, strwheresaldoanterior As String) Dim aux As String strwherereport = "codigo_empresa = " & sempresa & " " " If txt(6) <> "" Then If sempresa <> sdelegacion Then strwherereport = strwherereport & "and codigo_delegacion = " & txt(6) & " aux = "" & txt(6) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwherereport = strwherereport & "and codigo_delegacion in (" & aux & ") "
298 If txt(0) <> "" Then aux = "" & txt(0) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwherereport = strwherereport & "and codigo_diario in (" & aux & ") " If txt(3) <> "" Then strwherereport = strwherereport & "and codigo_documento like " & txt(3) & "% " If txt(4) <> "" Then strwherereport = strwherereport & "and numero_documento >= " & txt(4) & " " If txt(5) <> "" Then strwherereport = strwherereport & "and numero_documento <= " & txt(5) & " " strwheresaldoanterior = strwherereport If txt(1) <> "" Then strwherereport = strwherereport & "and fecha_apunte >= " & sdate(txt(1)) & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sdate(txt(1)) & " " strwherereport = strwherereport & "and fecha_apunte >= " & sinicioejercicio & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sinicioejercicio & " " If txt(2) <> "" Then strwherereport = strwherereport & "and fecha_apunte <= " & sdate(txt(2)) & " " strwherereport = strwherereport & "and fecha_apunte <= " & sfinalejercicio & " " strwherereport = strwherereport & "and (debe <> 0 or haber <> 0) " Sub Private Sub ToolbarLibroDiario_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirlibrodiario Case "ayudar": Call ayudarlibrodiario Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarLibroDiario.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarLibroDiario.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 121 And Shift = 0 And Me.ToolbarLibroDiario.Buttons(7).Enabled Then Call mostrarlupa(me) F10 Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Select Case Index Case 1, 2: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub
299 49. frmlibroiva.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmlibroiva Caption = "Libro de IVA" ClientHeight = 1515 ClientLeft = 60 ClientTop = 450 ClientWidth = 6150 LinkTopic = "frmlibroiva" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 1515 ScaleWidth = 6150 Tag = "ToolbarLibroIva" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 675 Left = 0 TabIndex = 0 Top = 360 Width = 6135 Begin VB.TextBox txt Index = 1 Left = 4515 TabIndex = 4 Top = 240 Width = 1500 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 3 Top = 225 Width = 1500 Begin VB.Label lbl Caption = "Fecha final:" Height = 255 Index = 1 Left = 3195 TabIndex = 5 Top = 240 Width = 1125 Begin VB.Label lbl Caption = "Fecha inicial:" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 1125 Begin MSComctlLib.Toolbar ToolbarLibroIva Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCuentas" Top =
300 Width = 6150 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListLibroIva Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 0 TabIndex = 6 Top = 1080 Width = 6135 _ExtentX = _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Attribute VB_Name = "frmlibroiva" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim msituacion As Situacion Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudarlibroiva() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmlibroiva = Forms(i)
301 Next Call limatges16(me.imagelistlibroiva) Set Me.ToolbarLibroIva.ImageList = Me.ImageListLibroIva Call cargarbotonera(me.toolbarlibroiva) Call deshabilitarbotones(me.toolbarlibroiva, "insertar", "modificar", "lupa", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarLibroIva_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirlibroiva Case "ayudar": Call ayudarlibroiva Select Sub Private Sub guardartemporallibroiva(rs As ADODB.Recordset) Dim rst As ADODB.Recordset Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.execute "DELETE FROM LibroIva" Set rst = New ADODB.Recordset rst.open "SELECT * FROM LibroIva", cnt, adopenstatic, adlockoptimistic cnt.begintrans Set mauxiliar = New Auxiliar While Not rs.eof rst.addnew rst("tipo") = rs("tipo") rst("numero_documento") = rs("numero_documento") rst("fecha_documento") = ddate(rs("fecha_documento")) rst("nif") = rs("nif") rst("nombre") = rs("nombre") rst("base") = rs("base") rst("pctiva") = rs("pctiva") rst("iva") = rs("iva") rst("pctre") = rs("pctre") rst("re") = rs("re") rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend
302 Set mauxiliar = Nothing rst.close cnt.committrans Set rst = Nothing Sub Private Sub imprimirlibroiva() Dim rs As ADODB.Recordset Set rs = obtenerdatos() If Not rs.eof Then Call guardartemporallibroiva(rs) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Function obtenerdatos() As Object Dim fini As String Dim ffin As String Dim rs As ADODB.Recordset If txt(0) = "" Then fini = sinicioejercicio ffin = sfinalejercicio fini = sdate(txt(0)) ffin = sdate(txt(1)) Set rs = New ADODB.Recordset rs.open "SELECT RegistroIva.tipo, RegistroIva.numero_documento, Apuntes.fecha_documento, Personal.nif, Personal.nombre, RegistroIva.base, RegistroIva.pctiva, RegistroIva.iva, RegistroIva.pctre, RegistroIva.re " _ & "FROM RegistroIva, Apuntes, Personal WHERE Apuntes.codigo_empresa = RegistroIva.codigo_empresa AND Apuntes.codigo_delegacion = RegistroIva.codigo_delegacion AND Apuntes.codigo_documento = RegistroIva.codigo_documento AND Apuntes.numero_documento = RegistroIva.numero_documento AND Apuntes.numero_apunte = RegistroIva.numero_apunte " _ & "AND Personal.codigo_empresa = RegistroIva.codigo_empresa AND Personal.codigo = RegistroIva.codigo_personal " _ & "AND RegistroIva.codigo_empresa = " & sempresa & " AND RegistroIva.codigo_delegacion = " & sdelegacion & " AND Apuntes.fecha_documento >= " & fini & " AND Apuntes.fecha_documento <= " & ffin & " ", cn, adopenstatic, adlockoptimistic Set obtenerdatos = rs Function Private Sub imprimir() Dim periodo As String Dim empresa As String periodo = "del " & IIf(txt(0) <> "", txt(0), ddate(sinicioejercicio)) & " al " & IIf(txt(1) <> "", txt(1), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Imprime el desglose de IVA Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("libroiva.rpt", "Libro de IVA", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM LibroIva ORDER BY tipo, numero_documento" Call minformes.execute
303 Set minformes = Nothing Imprime el resumen de IVA Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("resumeniva.rpt", "Resumen de IVA", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM LibroIva ORDER BY tipo, pctiva" Call minformes.execute Set minformes = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 0, 1: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) If sdate(txt(index)) < sinicioejercicio Or sdate(txt(index)) > sfinalejercicio Then msg = msgerror(1027) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
304 50. frmlistaempresas.frm VERSION 5.00 Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" Object = "{DEF7CADD-83C0-11D0-A0F1-00A }#7.0#0"; "todg7.ocx" Begin VB.Form frmlistaempresas BorderStyle = 1 Fixed Single Caption = "Empresas disponibles" ClientHeight = 3735 ClientLeft = 45 ClientTop = 330 ClientWidth = 5025 LinkTopic = "Listas" MaxButton = 0 False MinButton = 0 False ScaleHeight = 3735 ScaleWidth = 5025 StartUpPosition = 3 Windows Default Begin MSAdodcLib.Adodc AdodcLista Height = 375 Left = 120 Top = 3240 Width = 4815 _ExtentX = 8493 _ExtentY = 661 ConnectMode = 0 CursorLocation = 3 IsolationLevel = -1 ConnectionTimeout= 15 CommandTimeout = 30 CursorType = 3 LockType = 3 CommandType = 8 CursorOptions = 0 CacheSize = 50 MaxRecords = 0 BOFAction = 0 EOFAction = 0 ConnectStringType= 1 Appearance = 1 BackColor = ForeColor = Orientation = 0 Enabled = -1 Connect = "" OLEDBString = "" OLEDBFile = "" DataSourceName = "" OtherAttributes = "" UserName = "" Password = "" RecordSource = "" Caption = "" BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property _Version = Begin TrueOleDBGrid70.TDBGrid TDBGridLista Bindings = "frmlistaempresas.frx":0000 Height = 3015 Left = 120 TabIndex = 0 Top = 120 Width = 4815 _ExtentX = 8493 _ExtentY = 5318 _LayoutType =
305 _RowHeight = _WasPersistedAsPixels= 0 Columns(0)._VlistStyle= 0 Columns(0)._MaxComboItems= 5 Columns(0).Caption= "Código" Columns(0).DataField= "codigo_empresa_fiscal" Columns(0)._PropDict= "_MaxComboItems,516,2;_VlistStyle,514,3" Columns(1)._VlistStyle= 0 Columns(1)._MaxComboItems= 5 Columns(1).Caption= "Nombre" Columns(1).DataField= "nombre" Columns(1)._PropDict= "_MaxComboItems,516,2;_VlistStyle,514,3" Columns.Count = 2 Splits(0)._UserFlags= 0 Splits(0).RecordSelectorWidth= 688 Splits(0)._SavedRecordSelectors= 0 False Splits(0).AllowColSelect= 0 False Splits(0).DividerColor= Splits(0).SpringMode= 0 False Splits(0)._PropDict= "_ColumnProps,515,0;_UserFlags,518,3" Splits(0)._ColumnProps(0)= "Columns.Count=2" Splits(0)._ColumnProps(1)= "Column(0).Width=1402" Splits(0)._ColumnProps(2)= "Column(0).DividerColor=0" Splits(0)._ColumnProps(3)= "Column(0)._WidthInPix=1323" Splits(0)._ColumnProps(4)= "Column(0)._ColStyle=0" Splits(0)._ColumnProps(5)= "Column(0).Order=1" Splits(0)._ColumnProps(6)= "Column(1).Width=6271" Splits(0)._ColumnProps(7)= "Column(1).DividerColor=0" Splits(0)._ColumnProps(8)= "Column(1)._WidthInPix=6191" Splits(0)._ColumnProps(9)= "Column(1)._ColStyle=0" Splits(0)._ColumnProps(10)= "Column(1).Order=2" Splits.Count = 1 PrintInfos(0)._StateFlags= 3 PrintInfos(0).Name= "piinternal 0" PrintInfos(0).PageHeaderFont= "Size=8.25,Charset=0,Weight=400,Underline=0,Italic=0,Strikethrough=0,Name=MS Sans Serif" PrintInfos(0).PageFooterFont= "Size=8.25,Charset=0,Weight=400,Underline=0,Italic=0,Strikethrough=0,Name=MS Sans Serif" PrintInfos(0).PageHeaderHeight= 0 PrintInfos(0).PageFooterHeight= 0 PrintInfos.Count= 1 DefColWidth = 0 HeadLines = 1 FootLines = 1 MultipleLines = 0 CellTipsWidth = 0 DeadAreaBackColor= RowDividerColor = RowSubDividerColor= DirectionAfterEnter= 1 MaxRows = ViewColumnCaptionWidth= 0 ViewColumnWidth = 0 _PropDict = "_ExtentX,2003,3;_ExtentY,2004,3;_LayoutType,512,2;_RowHeight,16,3;_StyleDefs,513,0;_Was PersistedAsPixels,516,2" _StyleDefs(0) = "_StyleRoot:id=0,.parent=- 1,.alignment=3,.valignment=0,.bgcolor=&H &" _StyleDefs(1) = ":id=0,.fgcolor=&h &,.wraptext=0,.locked=0,.transparentbmp=0" _StyleDefs(2) = ":id=0,.fgpicposition=0,.bgpicmode=0,.appearance=0,.bordersize=0,.ellipsis=0" _StyleDefs(3) = ":id=0,.bordercolor=&h &,.bordertype=0,.bold=0,.fontsize=825,.italic=0" _StyleDefs(4) = ":id=0,.underline=0,.strikethrough=0,.charset=0" _StyleDefs(5) = ":id=0,.fontname=ms Sans Serif" _StyleDefs(6) = "Style:id=1,.parent=0,.namedParent=33,.bold=0,.fontsize=825,.italic=0" _StyleDefs(7) = ":id=1,.underline=0,.strikethrough=0,.charset=0" _StyleDefs(8) = ":id=1,.fontname=ms Sans Serif" _StyleDefs(9) = "CaptionStyle:id=4,.parent=2,.namedParent=37" _StyleDefs(10) = "HeadingStyle:id=2,.parent=1,.namedParent=34,.bold=0,.fontsize=825,.italic=0" _StyleDefs(11) = ":id=2,.underline=0,.strikethrough=0,.charset=0" _StyleDefs(12) = ":id=2,.fontname=ms Sans Serif" _StyleDefs(13) = "FooterStyle:id=3,.parent=1,.namedParent=35,.bold=0,.fontsize=825,.italic=0"
306 _StyleDefs(14) = ":id=3,.underline=0,.strikethrough=0,.charset=0" _StyleDefs(15) = ":id=3,.fontname=ms Sans Serif" _StyleDefs(16) = "InactiveStyle:id=5,.parent=2,.bgcolor=&H F&,.fgcolor=&H &" _StyleDefs(17) = "SelectedStyle:id=6,.parent=1,.namedParent=36" _StyleDefs(18) = "EditorStyle:id=7,.parent=1" _StyleDefs(19) = "HighlightRowStyle:id=8,.parent=1,.namedParent=38" _StyleDefs(20) = "EvenRowStyle:id=9,.parent=1,.namedParent=39" _StyleDefs(21) = "OddRowStyle:id=10,.parent=1,.namedParent=40" _StyleDefs(22) = "RecordSelectorStyle:id=11,.parent=2,.namedParent=41" _StyleDefs(23) = "FilterBarStyle:id=12,.parent=1,.namedParent=42" _StyleDefs(24) = "Splits(0).Style:id=13,.parent=1" _StyleDefs(25) = "Splits(0).CaptionStyle:id=22,.parent=4" _StyleDefs(26) = "Splits(0).HeadingStyle:id=14,.parent=2" _StyleDefs(27) = "Splits(0).FooterStyle:id=15,.parent=3" _StyleDefs(28) = "Splits(0).InactiveStyle:id=16,.parent=5" _StyleDefs(29) = "Splits(0).SelectedStyle:id=18,.parent=6" _StyleDefs(30) = "Splits(0).EditorStyle:id=17,.parent=7" _StyleDefs(31) = "Splits(0).HighlightRowStyle:id=19,.parent=8" _StyleDefs(32) = "Splits(0).EvenRowStyle:id=20,.parent=9" _StyleDefs(33) = "Splits(0).OddRowStyle:id=21,.parent=10" _StyleDefs(34) = "Splits(0).RecordSelectorStyle:id=23,.parent=11" _StyleDefs(35) = "Splits(0).FilterBarStyle:id=24,.parent=12" _StyleDefs(36) = "Splits(0).Columns(0).Style:id=28,.parent=13,.alignment=0,.bgcolor=&H &" _StyleDefs(37) = "Splits(0).Columns(0).HeadingStyle:id=25,.parent=14" _StyleDefs(38) = "Splits(0).Columns(0).FooterStyle:id=26,.parent=15" _StyleDefs(39) = "Splits(0).Columns(0).EditorStyle:id=27,.parent=17" _StyleDefs(40) = "Splits(0).Columns(1).Style:id=32,.parent=13,.alignment=0" _StyleDefs(41) = "Splits(0).Columns(1).HeadingStyle:id=29,.parent=14" _StyleDefs(42) = "Splits(0).Columns(1).FooterStyle:id=30,.parent=15" _StyleDefs(43) = "Splits(0).Columns(1).EditorStyle:id=31,.parent=17" _StyleDefs(44) = "Named:id=33:Normal" _StyleDefs(45) = ":id=33,.parent=0" _StyleDefs(46) = "Named:id=34:Heading" _StyleDefs(47) = ":id=34,.parent=33,.valignment=2,.bgcolor=&h f&,.fgcolor=&h &" _StyleDefs(48) = ":id=34,.wraptext=-1" _StyleDefs(49) = "Named:id=35:Footing" _StyleDefs(50) = ":id=35,.parent=33,.valignment=2,.bgcolor=&h f&,.fgcolor=&h &" _StyleDefs(51) = "Named:id=36:Selected" _StyleDefs(52) = ":id=36,.parent=33,.bgcolor=&h d&,.fgcolor=&h e&" _StyleDefs(53) = "Named:id=37:Caption" _StyleDefs(54) = ":id=37,.parent=34,.alignment=2" _StyleDefs(55) = "Named:id=38:HighlightRow" _StyleDefs(56) = ":id=38,.parent=33,.bgcolor=&h d&,.fgcolor=&h e&" _StyleDefs(57) = "Named:id=39:EvenRow" _StyleDefs(58) = ":id=39,.parent=33,.bgcolor=&hffff00&" _StyleDefs(59) = "Named:id=40:OddRow" _StyleDefs(60) = ":id=40,.parent=33" _StyleDefs(61) = "Named:id=41:RecordSelector" _StyleDefs(62) = ":id=41,.parent=34" _StyleDefs(63) = "Named:id=42:FilterBar" _StyleDefs(64) = ":id=42,.parent=33" Attribute VB_Name = "frmlistaempresas" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub TDBGridLista_DblClick() If frmempresas.toolbarempresas.buttons(2).value = tbrpressed Then frmempresas.txt(0) = Me.TDBGridLista.Columns(0).Value frmempresas.actualitzaformulario Unload Me Sub Private Sub Form_Load()
307 Configuro el control ADO Me.AdodcLista.ConnectionString = cadenaconexion Me.AdodcLista.CommandType = adcmdtext Me.AdodcLista.RecordSource = "select codigo_empresa_fiscal, nombre from empresasfiscales order by codigo_empresa_fiscal" Me.AdodcLista.Refresh Sub
308 51. frmlogin.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Begin VB.Form frmlogin BorderStyle = 3 Fixed Dialog Caption = "Inicio de sesión" ClientHeight = 3240 ClientLeft = 45 ClientTop = 330 ClientWidth = 3900 LinkTopic = "frmlogin" MaxButton = 0 False MinButton = 0 False ScaleHeight = 216 ScaleMode = 3 Pixel ScaleWidth = 260 ShowInTaskbar = 0 False StartUpPosition = 2 CenterScreen Tag = "Inicio de sesión" Begin MSComctlLib.ListView ListViewLogin Height = 1335 Left = 120 TabIndex = 5 Top = 1200 Width = 3675 _ExtentX = 6482 _ExtentY = 2355 View = 3 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Ejercicio" Object.Width = Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Cerrado" Object.Width = Property Begin VB.CommandButton cmdcancel Cancel = -1 True Caption = "Cancelar" Height = 360 Left = 2160 TabIndex = 7 Tag = "Cancelar" Top = 2760 Width = 1140 Begin VB.CommandButton cmdok Caption = "Aceptar" Default = -1 True Enabled = 0 False Height = 360 Left = 600 TabIndex = 6 Tag = "Aceptar" Top = 2760 Width = 1140 Begin VB.TextBox txt IMEMode = 3 DISABLE Index =
309 Left = 1920 PasswordChar = "*" TabIndex = 4 Top = 825 Width = 1875 Begin VB.TextBox txt Index = 0 Left = 1920 TabIndex = 3 Top = 465 Width = 1875 Begin MSForms.ComboBox cmb Height = 315 Index = 1 Left = 2865 TabIndex = 2 Top = 120 Width = 930 VariousPropertyBits= DisplayStyle = 3 Size = "1640;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin MSForms.ComboBox cmb Height = 315 Index = 0 Left = 1920 TabIndex = 0 Top = 120 Width = 930 VariousPropertyBits= DisplayStyle = 3 Size = "1640;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label lbllabels Caption = "&Empresa/Delegación:" Height = 255 Index = 2 Left = 120 TabIndex = 9 Tag = "&Contraseña:" Top = 120 Width = 1680 Begin VB.Label lbllabels Caption = "&Contraseña:" Height = 255 Index = 1 Left = 120 TabIndex = 1 Tag = "&Contraseña:" Top = 840 Width = 1605 Begin VB.Label lbllabels Caption = "Usuari&o:" Height = 255 Index = 0 Left = 120 TabIndex = 8 Tag = "Usuari&o:" Top = 465 Width =
310 Attribute VB_Name = "frmlogin" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Public Ok As Boolean Dim mauxiliar As Auxiliar Dim mejercicios As Ejercicios Dim musuariosdelegaciones As UsuariosDelegaciones Private Sub cmb_gotfocus(index As Integer) If Index = 1 Then Call cargarcombodelegaciones(me.cmb(1), Me.cmb(0)) Sub Private Sub cmb_lostfocus(index As Integer) Me.cmb(Index) = UCase(Me.cmb(Index)) Call verejercicios Sub Private Sub Form_Load() Dim i As Integer Call cargarcomboempresas(me.cmb(0)) Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewLogin For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub cmdcancel_click() Ok = False Me.Hide Sub Private Sub cmdok_click() Guardo lusuari susuario = Me.txt(0) Lusuari SUPERUSER té un tractament especial If susuario <> sadministrador Then sempresa = Me.cmb(0) sdelegacion = Me.cmb(1) iejercicio = Me.ListViewLogin.SelectedItem Set mauxiliar = New Auxiliar icuenta = mauxiliar.vbuscarcampo("empresas", "digitos", "codigo_empresa = " & sempresa & "") Set mauxiliar = Nothing Dim rs As ADODB.Recordset Dim mejercicios As Ejercicios Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio) sinicioejercicio = rs("fecha_inicial") sfinalejercicio = rs("fecha_final") siniciobloqueo = rs("inicio_bloqueo")
311 sfinalbloqueo = rs("final_bloqueo") Set rs = Nothing Set mejercicios = Nothing Ok = True Me.Hide Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewLogin For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub cargarejercicios() Dim rs As ADODB.Recordset Dim newitem As ListItem Me.ListViewLogin.ListItems.Clear Set mejercicios = New Ejercicios Set rs = mejercicios.getlist(cn, "codigo_empresa = " & Me.cmb(0) & "") If Not rs.eof Then While Not rs.eof Set newitem = Me.ListViewLogin.ListItems.Add(, "K" & Trim(str(rs("ejercicio"))), rs("ejercicio")) newitem.subitems(1) = Nz(rs("cerrado"), "") rs.movenext Wend Me.cmdOK.Enabled = True Me.ListViewLogin.ListItems(1).Selected = True Set rs = Nothing Set mejercicios = Nothing Sub Private Sub verejercicios() If Me.cmb(0) <> "" And Me.cmb(1) <> "" And Me.txt(0) <> "" And Me.txt(1) <> "" Then Set musuariosdelegaciones = New UsuariosDelegaciones If musuariosdelegaciones.validarusuario(cn, Me.cmb(0), Me.cmb(1), Me.txt(0), Me.txt(1)) Then Call cargarejercicios Set musuariosdelegaciones = Nothing Sub Private Sub ListViewLogin_DblClick() If Me.ListViewLogin.ListItems.Count > 0 Then Call cmdok_click Sub Private Sub txt_change(index As Integer) Me.ListViewLogin.ListItems.Clear Me.cmdOK.Enabled = (txt(0) = sadministrador And txt(1) = spasswordadm) Sub Private Sub txt_gotfocus(index As Integer)
312 Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Me.txt(Index) = UCase(Me.txt(Index)) If txt(0) <> sadministrador Or txt(1) <> spasswordadm Then Call verejercicios Sub
313 52. frmlupa.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmlupa Caption = "Consulta" ClientHeight = 3030 ClientLeft = 60 ClientTop = 345 ClientWidth = 5340 LinkTopic = "frmlupa" MDIChild = -1 True ScaleHeight = 202 ScaleMode = 3 Pixel ScaleWidth = 356 Begin MSComctlLib.ListView ListViewLupa Height = 2250 Left = 0 TabIndex = 0 TabStop = 0 False Top = 0 Width = 4823 _ExtentX = 8520 _ExtentY = 3969 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 0 Begin VB.Label parametros BackColor = &H & Height = 240 Left = 0 TabIndex = 1 Top = 2325 Visible = 0 False Width = 4815 Attribute VB_Name = "frmlupa" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim param As String Dim campo As String Dim tabla As String Dim icampo As Integer Private Sub parametros_change() Dim i As Integer Dim fini As String Dim strsql As String, straux As String Dim strauxheader As String, paramheader As String Dim strauxfields As String, paramfields As String Dim namefield As String, widthfield As String Dim strauxwhere As String, strauxorder As String Dim strauxwherelocal As String Dim strauxtablejoin As String Dim strauxwherejoin As String Dim salir As Boolean If Me.ListViewLupa.ListItems.Count = 0 Then param = obtenerparametro(parametros, 3) tabla = Mid(obtenerParametro(param, 1, ";"), 1, InStr(1, param, ".") - 1)
314 campo = Mid(obtenerParametro(param, 1, ";"), InStr(1, param, ".") + 1) fini = App.Path & "\Listas.ini" Configuración del formulario straux = sgetini(fini, tabla, "Form", "") If straux = "" Then Unload Me MsgBox "No existe una lista asociada.", vbcritical, App.Title Me.Left = obtenerparametro(straux, 1) Me.Top = obtenerparametro(straux, 2) Me.Width = obtenerparametro(straux, 3) Me.Height = obtenerparametro(straux, 4) Configuración de la lista strauxheader = sgetini(fini, tabla, "Header", "") strauxfields = sgetini(fini, tabla, "Fields", "") i = 1 icampo = -1 salir = False strsql = "SELECT " While Not salir paramheader = obtenerparametro(strauxheader, i) paramfields = obtenerparametro(strauxfields, i) If paramheader = "" Or paramfields = "" Then salir = True namefield = obtenerparametro(paramfields, 1, ";") If UCase(nameField) = UCase(campo) Or UCase(nameField) = UCase(tabla & "." & campo) Then icampo = i - 1 widthfield = obtenerparametro(paramfields, 2, ";") If widthfield = "" Then widthfield = 100 Me.ListViewLupa.ColumnHeaders.Add i, namefield, paramheader Me.ListViewLupa.ColumnHeaders(i).Width = widthfield strsql = strsql & namefield & ", " i = i + 1 Wend strauxwhere = sgetini(fini, tabla, "Where", "") If strauxwhere <> "" Then strauxwhere = Replace(strAuxWhere, "{@empresa}", sempresa) strauxwhere = Replace(strAuxWhere, "{@delegacion}", sdelegacion) strauxwhere = Replace(strAuxWhere, "{@ejercicio}", iejercicio) strauxwherelocal = obtenerparametro(parametros, 4) If strauxwherelocal <> "" Then If strauxwhere <> "" Then strauxwhere = strauxwhere & " AND " & strauxwherelocal strauxwhere = strauxwherelocal strauxorder = sgetini(fini, tabla, "Order", "") strsql = Mid(strSQL, 1, Len(strSQL) - 2) strsql = strsql & " FROM " & tabla strauxtablejoin = sgetini(fini, tabla, "TableJoin", "") If strauxtablejoin <> "" And tabla <> "" Then strsql = strsql & "," & strauxtablejoin If strauxwhere <> "" Then strsql = strsql & " WHERE " & strauxwhere strauxwherejoin = sgetini(fini, tabla, "WhereJoin", "") If strauxwherejoin <> "" And strauxwhere <> "" Then strsql = strsql & " AND " & strauxwherejoin
315 If strauxorder <> "" Then strsql = strsql & " ORDER BY " & strauxorder Call cargargrid(strsql) Sub Private Sub cargargrid(strsql As String) Dim cnaux As New ADODB.Connection Dim rsaux As New ADODB.Recordset Dim col As Integer Dim maxcol As Integer Dim fila As Integer cnaux.open cn.connectionstring rsaux.open strsql, cnaux, adopenstatic, adlockoptimistic maxcol = rsaux.fields.count - 1 fila = 0 Do Until rsaux.eof Me.ListViewLupa.ListItems.Add fila + 1, "K" & Trim(str(fila + 1)), rsaux.fields(0) "") For col = 1 To maxcol Me.ListViewLupa.ListItems(fila + 1).SubItems(col) = Nz(rsAux.Fields(col), Next fila = fila + 1 rsaux.movenext Loop If fila > 1 Then SendKeys "{TAB}" cnaux.close Set rsaux = Nothing Set cnaux = Nothing Sub Private Sub Form_Resize() Me.ListViewLupa.Width = Me.ScaleWidth Me.ListViewLupa.Height = Me.ScaleHeight Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String Dim straux As String Dim strauxfields As String, paramfields As String fini = App.Path & "\Listas.ini" straux = "" If Me.WindowState <> vbminimized Then straux = guardarparametro(straux, Me.Left, 1) straux = guardarparametro(straux, Me.Top, 2) straux = guardarparametro(straux, Me.Width, 3) straux = guardarparametro(straux, Me.Height, 4) writeini fini, tabla, "Form", straux strauxfields = "" For i = 1 To Me.ListViewLupa.ColumnHeaders.Count paramfields = "" paramfields = guardarparametro(paramfields, Me.ListViewLupa.ColumnHeaders(i).Key, 1, ";") paramfields = guardarparametro(paramfields, Me.ListViewLupa.ColumnHeaders(i).Width, 2, ";") strauxfields = guardarparametro(strauxfields, paramfields, i, " ") Next writeini fini, tabla, "Fields", strauxfields Sub
316 Private Sub ListViewLupa_DblClick() Dim i As Integer Dim j As Integer Dim maxi As Integer Dim maxj As Integer Dim trobat As Boolean Dim hndfrm As Long Dim hndctr As Long Dim retorno As String On Error Resume Next If icampo >= 0 Then If icampo = 0 Then retorno = Me.ListViewLupa.SelectedItem.Text retorno = Me.ListViewLupa.SelectedItem.SubItems(icampo) hndfrm = CLng(obtenerParametro(parametros, 1)) hndctr = CLng(obtenerParametro(parametros, 2)) i = 0 maxi = Forms.Count trobat = False While i < maxi And Not trobat If Forms(i).hwnd = hndfrm Then j = 0 maxj = Forms(i).Controls.Count trobat = False While j < maxj And Not trobat If TypeOf Forms(i).Controls(j) Is TextBox Then If Forms(i).Controls(j).hwnd = hndctr Then CallByName Forms(i).Controls(j), "Text", VbLet, retorno trobat = True j = j + 1 j = j + 1 Wend trobat = True i = i + 1 Wend Unload Me Sub Private Sub ListViewLupa_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 And Shift = 0 Then Call ListViewLupa_DblClick Sub
317 53. frmmain.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.MDIForm frmmain BackColor = &H C& Caption = "Contabilidad" ClientHeight = 3195 ClientLeft = 5355 ClientTop = 3885 ClientWidth = 4680 LinkTopic = "frmmain" Begin MSComctlLib.Toolbar ToolbarMain Align = 1 Align Top Height = 330 Left = 0 TabIndex = 1 Top = 0 Width = 4680 _ExtentX = 8255 _ExtentY = 582 ButtonWidth = 609 ButtonHeight = 582 Style = 1 _Version = BeginProperty Buttons {66833FE D1-B16A-00C0F } NumButtons = 1 BeginProperty Button1 {66833FEA D1-B16A-00C0F } Object.Visible = 0 False Style = 3 Object.Width = 1e-4 Property Property Begin VB.CommandButton cmdsalir Caption = "Salir" Height = 240 Left = 1875 TabIndex = 3 Top = 0 Width = 1890 Begin VB.CommandButton cmdreiniciar Caption = "Cambio de empresa/ejercicio" Height = 240 Left = 0 TabIndex = 2 Top = 0 Width = 1890 Begin MSComctlLib.StatusBar sbstatusbar Align = 2 Align Bottom Height = 270 Left = 0 TabIndex = 0 Top = 2925 Width = 4680 _ExtentX = 8255 _ExtentY = 476 _Version = BeginProperty Panels {8E3867A D1-B16A-00C0F } NumPanels = 10 BeginProperty Panel1 {8E3867AB D1-B16A-00C0F } Alignment = 1 AutoSize = 1 Text = "Estado" TextSave = "Estado" Property BeginProperty Panel2 {8E3867AB D1-B16A-00C0F } Alignment = 1 Object.Width = 3528 MinWidth = 3528 Property BeginProperty Panel3 {8E3867AB D1-B16A-00C0F }
318 Alignment = 1 Property BeginProperty Panel4 {8E3867AB D1-B16A-00C0F } Alignment = 1 Property BeginProperty Panel5 {8E3867AB D1-B16A-00C0F } Alignment = 1 Property BeginProperty Panel6 {8E3867AB D1-B16A-00C0F } Style = 6 Alignment = 1 AutoSize = 2 TextSave = "23/07/2005" Property BeginProperty Panel7 {8E3867AB D1-B16A-00C0F } Style = 5 Alignment = 1 AutoSize = 2 Object.Width = 1588 MinWidth = 1587 TextSave = "12:35" Property BeginProperty Panel8 {8E3867AB D1-B16A-00C0F } Style = 1 Alignment = 1 AutoSize = 2 Enabled = 0 False Object.Width = 1588 MinWidth = 1587 TextSave = "MAYÚS" Property BeginProperty Panel9 {8E3867AB D1-B16A-00C0F } Style = 2 Alignment = 1 AutoSize = 2 Object.Width = 1588 MinWidth = 1587 TextSave = "NÚM" Property BeginProperty Panel10 {8E3867AB D1-B16A-00C0F } Style = 3 Alignment = 1 AutoSize = 2 Object.Width = 1588 MinWidth = 1587 TextSave = "INS" Property Property Attribute VB_Name = "frmmain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub cmdreiniciar_click() Dim rpt As Integer rpt = MsgBox(" Realmente desea cambiar de empresa " & App.Title & "?", vbquestion + vbyesno, App.Title) If rpt = vbyes Then cambiarempresa Sub Private Sub cmdsalir_click() Dim rpt As Integer rpt = MsgBox(" Realmente quiere salir de " & App.Title & "?", vbquestion + vbyesno, App.Title) If rpt = vbyes Then Sub Private Sub MDIForm_Load() Dim fini As String On Error Resume Next
319 Me.cmdReiniciar.Left = 0 Me.cmdReiniciar.Width = Screen.Width / 2 Me.cmdReiniciar.Height = Me.ToolbarMain.Height Me.cmdSalir.Left = Screen.Width / 2 Me.cmdSalir.Width = Screen.Width / 2 Me.cmdSalir.Height = Me.ToolbarMain.Height fini = App.Path & "\Contabilidad.ini" Me.Left = sgetini(fini, Me.Name, "Left", 1000) Me.Top = sgetini(fini, Me.Name, "Top", 1000) Me.Width = sgetini(fini, Me.Name, "Width", 6500) Me.Height = sgetini(fini, Me.Name, "Height", 6500) Sub Private Sub MDIForm_Unload(Cancel As Integer) Dim fini As String On Error Resume Next cn.close Set cn = Nothing cnt.close Set cnt = Nothing fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Set fmainmenu = Nothing Set fmainform = Nothing Sub
320 54. frmmenu.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmmenu Appearance = 0 Flat BackColor = &H & BorderStyle = 5 Sizable ToolWindow ClientHeight = 7575 ClientLeft = 60 ClientTop = -120 ClientWidth = 2550 ControlBox = 0 False LinkTopic = "frmmenu" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False Moveable = 0 False ScaleHeight = 505 ScaleMode = 3 Pixel ScaleWidth = 170 ShowInTaskbar = 0 False Begin MSComctlLib.ImageList ImageListMenu Left = 2640 Top = 0 _ExtentX = 1005 _ExtentY = 1005 BackColor = ImageWidth = 16 ImageHeight = 16 MaskColor = _Version = BeginProperty Images {2C247F D1-B16A-00C0F } NumListImages = 3 BeginProperty ListImage1 {2C247F D1-B16A-00C0F } Picture = "frmmenu.frx":0000 Key = "" Property BeginProperty ListImage2 {2C247F D1-B16A-00C0F } Picture = "frmmenu.frx":059c Key = "" Property BeginProperty ListImage3 {2C247F D1-B16A-00C0F } Picture = "frmmenu.frx":0b38 Key = "" Property Property Begin MSComctlLib.TreeView TreeViewMenu Height = 7575 Left = 0 TabIndex = 0 Top = 0 Width = 2535 _ExtentX = 4471 _ExtentY = _Version = Indentation = 441 LabelEdit = 1 LineStyle = 1 Style = 7 SingleSel = -1 True ImageList = "ImageListMenu" Appearance = 0 BeginProperty Font {0BE F91-11CE-9DE3-00AA004BB851} Name = "Verdana" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property
321 Attribute VB_Name = "frmmenu" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mmenus As Menus Dim aitems() As String Dim apares() As String Dim adesc() As String Dim aforms() As String Dim asegur() As String Private Sub Form_Load() Defino la unidad de trabajo fmainmenu.scalemode = vbpixels Situacion del menu fmainmenu.left = 0 fmainmenu.top = 0 Call cargarmenus(aitems(), apares(), adesc(), aforms(), asegur()) Call mostrarmenus(aitems(), apares(), adesc(), aforms(), asegur()) Sub Private Sub Form_Resize() Adapto el menu al formulario fmainmenu.treeviewmenu.width = fmainmenu.scalewidth fmainmenu.treeviewmenu.height = fmainmenu.scaleheight Sub Private Sub TreeViewMenu_DblClick() Dim i As Integer i = Indice(aItems(), Me.TreeViewMenu.SelectedItem.Key) If i > 0 Then Call abrirformulario(aforms(i)) Sub Private Sub abrirformulario(strfrm As String) Dim i As Integer Dim maxi As Integer Dim frm As Form Dim trobat As Boolean If strfrm = "" Then Exit Sub i = 0 maxi = Forms.Count trobat = False While i < maxi And Not trobat If UCase(Forms(i).Name) = UCase(strfrm) Then trobat = True i = i + 1 Wend If trobat Then Set frm = Forms(i) Set frm = Forms.Add(CVar(Trim(strfrm))) frm.show frm.zorder 0 frm.setfocus Call AplicarSeguridadBotonera(frm, asegur(indice(aforms(), strfrm))) Set frm = Nothing Sub
322 Private Sub cargarmenus(aitems() As String, apares() As String, adesc() As String, aforms() As String, asegur() As String) Dim i As Integer Dim maxi As Integer Dim rs As ADODB.Recordset Set mmenus = New Menus If susuario <> sadministrador Then Set rs = mmenus.getlist(cn, "activo <> 0", "item_menu") Set rs = mmenus.getlist(cn, "administrador <> 0", "item_menu") i = 0 rs.movefirst maxi = rs.recordcount ReDim aitems(maxi) ReDim apares(maxi) ReDim adesc(maxi) ReDim aforms(maxi) ReDim asegur(maxi) Guardo la tabla en memoria para evitar accesos a la base de datos Do Until rs.eof i = i + 1 aitems(i) = Nz(rs("item_menu"), "") apares(i) = Nz(rs("item_padre"), "") adesc(i) = Nz(rs("descripcion"), "") aforms(i) = Nz(rs("formulario"), "") asegur(i) = "" rs.movenext Loop If susuario <> sadministrador Then Call SeguridadUsuario(cn, sempresa, sdelegacion, susuario, aitems(), asegur()) Set mmenus = Nothing Sub Private Sub mostrarmenus(aitems() As String, apares() As String, adesc() As String, aforms() As String, asegur() As String) Dim i As Integer Dim nodx As Node Dim maxi As Integer maxi = UBound(aItems) For i = 1 To maxi If susuario = "Superusuario" Then If apares(i) = " " Then Set nodx = Me.TreeViewMenu.Nodes.Add(,, aitems(i), adesc(i), 2, 1) If aforms(i) = "" Then Set nodx = Me.TreeViewMenu.Nodes.Add(aPares(i), tvwchild, aitems(i), adesc(i), 2, 1) Set nodx = Me.TreeViewMenu.Nodes.Add(aPares(i), tvwchild, aitems(i), adesc(i), 3, 3) If InStr(1, asegur(indice(aitems(), aitems(i))), "V") = 0 Then If apares(i) = " " Then Set nodx = Me.TreeViewMenu.Nodes.Add(,, aitems(i), adesc(i), 2, 1) If aforms(i) = "" Then Set nodx = Me.TreeViewMenu.Nodes.Add(aPares(i), tvwchild, aitems(i), adesc(i), 2, 1) Set nodx = Me.TreeViewMenu.Nodes.Add(aPares(i), tvwchild, aitems(i), adesc(i), 3, 3) Next Sub
323 55. frmmenususuarios.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Begin VB.Form frmmenususuarios Caption = "Menus/Usuarios" ClientHeight = 5145 ClientLeft = 60 ClientTop = 345 ClientWidth = 5055 LinkTopic = "frmmenusgrupos" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 343 ScaleMode = 3 Pixel ScaleWidth = 337 Begin MSComctlLib.ImageList ImageListMenu Left = 2250 Top = 5490 _ExtentX = 1005 _ExtentY = 1005 BackColor = ImageWidth = 16 ImageHeight = 16 MaskColor = _Version = BeginProperty Images {2C247F D1-B16A-00C0F } NumListImages = 3 BeginProperty ListImage1 {2C247F D1-B16A-00C0F } Picture = "frmmenususuarios.frx":0000 Key = "" Property BeginProperty ListImage2 {2C247F D1-B16A-00C0F } Picture = "frmmenususuarios.frx":059c Key = "" Property BeginProperty ListImage3 {2C247F D1-B16A-00C0F } Picture = "frmmenususuarios.frx":0b38 Key = "" Property Property Begin VB.CommandButton cmdvalidar Caption = "Validar cambios" Height = 390 Left = 1425 TabIndex = 9 Top = 4620 Width = 2340 Begin VB.Frame FramePermisos Height = 2640 Left = 2625 TabIndex = 12 Top = 1845 Width = 2340 Begin VB.CheckBox chk_opcion Caption = "Listados" Height = 315 Index = 4 Left = 150 TabIndex = 8 Top = 2175 Width = 2040 Begin VB.CheckBox chk_opcion Caption = "Eliminación" Height = 315 Index = 3 Left = 150 TabIndex = 7 Top =
324 Width = 2040 Begin VB.CheckBox chk_opcion Caption = "Edición" Height = 315 Index = 2 Left = 150 TabIndex = 6 Top = 1325 Width = 2040 Begin VB.CheckBox chk_opcion Caption = "Inserción" Height = 315 Index = 1 Left = 150 TabIndex = 5 Top = 900 Width = 2040 Begin VB.CheckBox chk_opcion Caption = "Visibilidad" Height = 315 Index = 0 Left = 150 TabIndex = 4 Top = 300 Width = 2040 Begin VB.Line Line1 BorderColor = &H & X1 = 0 X2 = 2325 Y1 = 750 Y2 = 750 Begin MSComctlLib.TreeView TreeViewMenu Height = 2565 Left = 75 TabIndex = 3 Top = 1920 Width = 2415 _ExtentX = 4260 _ExtentY = 4524 _Version = HideSelection = 0 False Indentation = 441 Style = 5 ImageList = "ImageListMenu" Appearance = 1 Begin MSForms.ComboBox cmbusuarios Height = 315 Left = 75 TabIndex = 15 Top = 1080 Width = 4875 VariousPropertyBits= DisplayStyle = 3 Size = "8599;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Empresa:" Height = 240 Index = 4 Left = 75 TabIndex = 14 Top = 120 Width =
325 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Delegación:" Height = 240 Index = 3 Left = 2565 TabIndex = 13 Top = 120 Width = 1065 Begin MSForms.ComboBox cmbempresas Height = 315 Left = 75 TabIndex = 1 Top = 420 Width = 2400 VariousPropertyBits= DisplayStyle = 3 Size = "4233;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin MSForms.ComboBox cmbdelegaciones Height = 315 Left = 2565 TabIndex = 2 Top = 420 Width = 2400 VariousPropertyBits= DisplayStyle = 3 Size = "4233;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label lbl Alignment = 2 Center Caption = "Denegar" Height = 240 Index = 2 Left = 2700 TabIndex = 11 Top = 1620 Width = 2190 Begin VB.Label lbl Alignment = 2 Center Caption = "Opció de menú" Height = 240 Index = 1 Left = 75 TabIndex = 10 Top = 1620 Width = 2415 Begin VB.Label lbl Caption = "Usuarios:" Height = 240 Index = 0 Left = 75 TabIndex = 0 Top = 840 Width = 1140 Attribute VB_Name = "frmmenususuarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit
326 Dim mmenus As Menus Dim mmenususuarios As MenusUsuarios Dim aitems() As String Dim asegur() As String Private Sub cargarrestriccionesusuario() Dim rs As ADODB.Recordset Dim strwhere As String Dim i As Integer Dim maxi As Integer Inicializo el array maxi = UBound(aSegur) For i = 1 To maxi asegur(i) = "" Next Filtro por el grupo strwhere = "codigo_usuario = " & Me.cmbUsuarios & " AND codigo_empresa = " & Me.cmbEmpresas _ & " AND codigo_delegacion = " & Me.cmbDelegaciones & "" Set mmenususuarios = New MenusUsuarios Set rs = mmenususuarios.getlist(cn, strwhere) Obtengo las restricciones para los items del menu While Not rs.eof i = Indice(aItems(), rs("item_menu")) If i > 0 Then asegur(i) = rs("restricciones") rs.movenext Wend Set mmenususuarios = Nothing Sub Private Sub chk_opcion_click(index As Integer) If Index = 0 Then If Me.chk_opcion(0).Value = 0 Then Me.chk_opcion(1).Enabled = True Me.chk_opcion(2).Enabled = True Me.chk_opcion(3).Enabled = True Me.chk_opcion(4).Enabled = True Me.chk_opcion(1).Value = 0 Me.chk_opcion(2).Value = 0 Me.chk_opcion(3).Value = 0 Me.chk_opcion(4).Value = 0 Me.chk_opcion(1).Enabled = False Me.chk_opcion(2).Enabled = False Me.chk_opcion(3).Enabled = False Me.chk_opcion(4).Enabled = False Me.cmdValidar.Enabled = True Sub Private Sub cmbdelegaciones_click() Call cargarcombousuariosactivos(me.cmbusuarios, Me.cmbEmpresas, Me.cmbDelegaciones) Sub Private Sub cmbempresas_click() Call cargarcombodelegaciones(me.cmbdelegaciones, Me.cmbEmpresas) Call cargarcombousuariosactivos(me.cmbusuarios, Me.cmbEmpresas, Me.cmbDelegaciones) Sub Private Sub cmbusuarios_click() Obtengo las restricciones aplicadas al grupo Call cargarrestriccionesusuario Call mostrarrestriccionitem Me.cmdValidar.Enabled = True Sub
327 Private Sub cmdvalidar_click() Dim i As Integer Dim maxi As Integer Dim restricciones As String Dim rpta As Integer Dim nivel As String If Me.cmbUsuarios = "" Then MsgBox "No se ha especificado el usuario.", vbexclamation, App.Title Me.cmbUsuarios.SetFocus If Me.TreeViewMenu.SelectedItem.Key = "" Then MsgBox "No se ha especificado la opción de menú", vbexclamation, App.Title Me.TreeViewMenu.SetFocus restricciones = "" If Me.chk_opcion(0) Then restricciones = "V" If Me.chk_opcion(1) Then restricciones = restricciones & "I" If Me.chk_opcion(2) Then restricciones = restricciones & "E" If Me.chk_opcion(3) Then restricciones = restricciones & "B" If Me.chk_opcion(4) Then restricciones = restricciones & "L" maxi = Me.TreeViewMenu.Nodes.Count Set mmenususuarios = New MenusUsuarios For i = 1 To maxi If restricciones = "" Then If espadre(me.treeviewmenu.nodes(i).key, Me.TreeViewMenu.SelectedItem.Key) Then Asigno la seguridad al nodo Call mmenususuarios.delete(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key) If restricciones <> "" Then Call mmenususuarios.insert(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key, restricciones, susuario) asegur(indice(aitems(), Me.TreeViewMenu.Nodes(i).Key)) = restricciones If eshijo(me.treeviewmenu.nodes(i).key, Me.TreeViewMenu.SelectedItem.Key) Then If restricciones = "V" Or restricciones = "" Then Asigno la seguridad al nodo Call mmenususuarios.delete(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key) If restricciones <> "" Then Call mmenususuarios.insert(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key, restricciones, susuario) asegur(indice(aitems(), Me.TreeViewMenu.Nodes(i).Key)) = restricciones Als nodes pares només els afecta les restriccions de visibilitat If Me.TreeViewMenu.Nodes(i).Children = 0 Then Call mmenususuarios.delete(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key) If restricciones <> "" Then Call mmenususuarios.insert(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key, restricciones, susuario) asegur(indice(aitems(), Me.TreeViewMenu.Nodes(i).Key)) = restricciones Next maxi = Me.TreeViewMenu.SelectedItem.Index - 1 Una vez assignada la seguridad, compruebo que no queden carpetas visibles sin opciones visibles en el menú For i = maxi To 1 Step
328 If (Me.TreeViewMenu.Nodes(i).Children > 0) And (Left(Me.TreeViewMenu.Nodes(i).Key, 3) = Left(Me.TreeViewMenu.SelectedItem.Key, 3)) Then If Not tienehijosvisibles(me.treeviewmenu.nodes(i).key) Then Call mmenususuarios.delete(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key) If restricciones <> "" Then Call mmenususuarios.insert(cn, Me.cmbUsuarios, Me.cmbEmpresas, Me.cmbDelegaciones, Me.TreeViewMenu.Nodes(i).Key, restricciones, susuario) asegur(indice(aitems(), Me.TreeViewMenu.Nodes(i).Key)) = restricciones Next Set mmenususuarios = Nothing Me.cmdValidar.Enabled = False Sub Private Function tienehijosvisibles(item As String) As Boolean Dim i As Integer Dim maxi As Integer Dim nivel As Integer Dim trobat As Boolean nivel = 1 While Right(item, 3 * nivel) = 0 nivel = nivel + 1 Wend nivel = nivel - 1 i = Indice(aItems(), item) + 1 maxi = Me.TreeViewMenu.Nodes.Count trobat = False While i <= maxi And Not trobat If (Left(item, 3 * (4 - nivel)) = Left(Me.TreeViewMenu.Nodes(i).Key, 3 * (4 - nivel))) Then trobat = asegur(indice(aitems(), Me.TreeViewMenu.Nodes(i).Key)) <> "V" i = i + 1 Wend tienehijosvisibles = trobat Function Private Function espadre(item1 As String, item2 As String) As Boolean Dim nivel As Integer nivel = 1 While Right(item1, 3 * nivel) = 0 nivel = nivel + 1 Wend nivel = nivel - 1 espadre = (Left(item1, (4 - nivel) * 3) = Left(item2, (4 - nivel) * 3)) Function Private Function eshijo(item1 As String, item2 As String) As Boolean Dim nivel As Integer nivel = 1 While Right(item2, 3 * nivel) = 0 nivel = nivel + 1 Wend nivel = nivel - 1 eshijo = (Left(item2, (4 - nivel) * 3) = Left(item1, (4 - nivel) * 3)) Function Private Sub Form_Load() Dim i As Integer Dim fini As String For i = 0 To Forms.Count
329 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmmenususuarios = Forms(i) Next Call cargarcomboempresas(me.cmbempresas) Call cargararbolmenu Me.TreeViewMenu.Nodes(1).Selected = True fini = App.Path & "\Contabilidad.ini" Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub cargararbolmenu() Dim rs As ADODB.Recordset Dim nodx As Node Dim i As Integer Set mmenus = New Menus Set rs = mmenus.getlist(cn, "activo <> 0", "item_menu, item_padre") If Not rs.eof Then ReDim aitems(rs.recordcount) ReDim asegur(rs.recordcount) i = 0 Do Until rs.eof If rs("item_padre") = " " Then Set nodx = Me.TreeViewMenu.Nodes.Add(,, rs("item_menu"), rs("descripcion"), 2, 1) If Nz(rs("formulario"), "") = "" Then Set nodx = Me.TreeViewMenu.Nodes.Add(Trim(rs("item_padre")), tvwchild, rs("item_menu"), rs("descripcion"), 2, 1) Set nodx = Me.TreeViewMenu.Nodes.Add(Trim(rs("item_padre")), tvwchild, rs("item_menu"), rs("descripcion"), 3, 3) i = i + 1 aitems(i) = rs("item_menu") rs.movenext Loop Set mmenus = Nothing Sub Private Sub TreeViewMenu_NodeClick(ByVal Node As MSComctlLib.Node) Call mostrarrestriccionitem Me.cmdValidar.Enabled = True Sub Private Sub mostrarrestriccionitem() Dim restriccion As String On Error Resume Next
330 restriccion = asegur(indice(aitems(), Me.TreeViewMenu.SelectedItem.Key)) Me.chk_opcion(0) = IIf((InStr(1, restriccion, "V") > 0), 1, 0) Me.chk_opcion(1) = IIf((InStr(1, restriccion, "I") > 0), 1, 0) Me.chk_opcion(2) = IIf((InStr(1, restriccion, "E") > 0), 1, 0) Me.chk_opcion(3) = IIf((InStr(1, restriccion, "B") > 0), 1, 0) Me.chk_opcion(4) = IIf((InStr(1, restriccion, "L") > 0), 1, 0) Sub
331 56. frmnumeracion.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmnumeracion Caption = "Numeración" ClientHeight = 4845 ClientLeft = 60 ClientTop = 345 ClientWidth = 4740 LinkTopic = "frmnumeracion" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 323 ScaleMode = 3 Pixel ScaleWidth = 316 Tag = "ToolbarNumeracion" Begin MSComctlLib.ListView ListViewNumeracion Height = 2865 Left = 0 TabIndex = 5 Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 4 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Numeración" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Longitud" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Número" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Descripción" Object.Width = Property Begin VB.Frame frmdatos Height = 1515 Left = 0 TabIndex = 6 Top = 3300 Width = 4740 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 1 Top = 705 Width = 1125 Begin VB.TextBox txt Index =
332 Left = 3540 TabIndex = 2 Top = 705 Width = 1050 Begin VB.TextBox txt Index = 3 Left = 1320 TabIndex = 3 Top = 1125 Width = 3270 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 0 Top = 300 Width = 825 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Longitud:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 75 TabIndex = 10 Top = 720 Width = 1140 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Número:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 2640 TabIndex = 9 Top = 720 Width = 780 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Descripción:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index =
333 Left = 75 TabIndex = 8 Top = 1140 Width = 1200 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Numeración:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 75 TabIndex = 7 Top = 300 Width = 1155 Begin MSComctlLib.ImageList ImageListNumeracion Left = 150 Top = 5250 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarNumeracion Align = 1 Align Top Height = 390 Left = 0 TabIndex = 4 Tag = "ToolbarNumeracion" Top = 0 Width = 4740 _ExtentX = 8361 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmnumeracion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mnumeracion As numeracion Private Sub AyudarNumeracion() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(0).setfocus Sub Private Sub EliminarNumeracion() Dim rpta As Integer Dim aux As String
334 On Error GoTo EliminarNumeracionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("numeraciones", "numeracion", "codigo_empresa = " & sempresa _ & " and ejercicio = " & iejercicio & " and numeracion = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar la numeración " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mnumeracion = New numeracion mnumeracion.delete cn, sempresa, iejercicio, txt(0) Set mnumeracion = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewNumeracion.ListItems.Remove ListViewNumeracion.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarNumeracionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarNumeracion() Dim filtro As String filtro = "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numeracion = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "longitud = " & txt(1) If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numero = " & txt(2) If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "descripcion = " & txt(3) & "" Call ListarNumeracion(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmnumeracion = Forms(i) Next
335 Call limatges16(me.imagelistnumeracion) Set Me.ToolbarNumeracion.ImageList = Me.ImageListNumeracion Call cargarbotonera(me.toolbarnumeracion) Call deshabilitarbotones(me.toolbarnumeracion, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewNumeracion For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewNumeracion For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirNumeracion() Sub Private Sub InsertarNumeracion() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarNumeracionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("numeraciones", "numeracion", "codigo_empresa = " & sempresa _ & " and ejercicio = " & iejercicio & " and numeracion = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mnumeracion = New numeracion mnumeracion.insert cn, sempresa, iejercicio, txt(0), txt(1), txt(2), txt(3), susuario Set mnumeracion = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewNumeracion.ListItems.Add(, "K" & txt(0), txt(0))
336 newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) Call cancelardatos For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarNumeracionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarNumeracion(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio Elimino los datos de la lista ListViewNumeracion.ListItems.Clear Set mnumeracion = New numeracion Set rs = mnumeracion.getlist(cn, strwhere, "codigo_empresa, numeracion") Do Until rs.eof Set newitem = ListViewNumeracion.ListItems.Add(, "K" & rs("numeracion"), rs("numeracion")) newitem.subitems(1) = Nz(rs("longitud"), "") newitem.subitems(2) = Nz(rs("numero"), "") newitem.subitems(3) = Nz(rs("descripcion"), "") rs.movenext Loop Set rs = Nothing Set mnumeracion = Nothing Sub Private Sub ListViewNumeracion_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewNumeracion.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarNumeracion() Dim i As Integer Dim aux As String On Error GoTo ModificarNumeracionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("numeraciones", "numeracion", "codigo_empresa = " & sempresa & _ " and ejercicio = " & iejercicio & " and numeracion = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mnumeracion = New numeracion mnumeracion.update cn, sempresa, iejercicio, txt(0), txt(1), txt(2), txt(3), susuario Set mnumeracion = Nothing On Error Resume Next For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next
337 ListViewNumeracion.ListItems(ListViewNumeracion.ListItems("K" & txt(0)).index).subitems(1) = txt(1) ListViewNumeracion.ListItems(ListViewNumeracion.ListItems("K" & txt(0)).index).subitems(2) = txt(2) ListViewNumeracion.ListItems(ListViewNumeracion.ListItems("K" & txt(0)).index).subitems(3) = txt(3) Call cancelardatos For i = 0 To 3 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarNumeracionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarNumeracion_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarNumeracion Case "modificar": If validardatos Then Call ModificarNumeracion Case "filtrar": Call FiltrarNumeracion Case "borrar": Call EliminarNumeracion Case "listar": Call ListarNumeracion Case "imprimir": Call ImprimirNumeracion Case "ayudar": Call AyudarNumeracion Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarNumeracion.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarNumeracion.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Then If txt(0) <> "" Then txt(0) = UCase(txt(0)) "") Set mnumeracion = New numeracion Set rs = mnumeracion.getlist(cn, "codigo_empresa = " & sempresa & _ " and ejercicio = " & iejercicio & " and numeracion = " & txt(0) & If Not rs.eof Then txt(1) = Nz(rs("longitud"), "") txt(2) = Nz(rs("numero"), "") txt(3) = Nz(rs("descripcion"), "") Set rs = Nothing Set mnumeracion = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String msg = ""
338 Cancel = False Select Case Index Case 1, 2: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1026) txt(index) = Replace(txt(Index), ".", ",") If txt(index) <> Int(txt(Index)) Then msg = msgerror(1026) If txt(index) < 1 Then msg = msgerror(1038) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 3 Select Case i Case 0, 1, 2, 3: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 3 Select Case i Case 1, 2: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
339 57. frmoperacionesterceros.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmoperacionesterceros Caption = "Operaciones con terceros" ClientHeight = 1860 ClientLeft = 60 ClientTop = 450 ClientWidth = 6150 LinkTopic = "frmoperacionesterceros" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 1860 ScaleWidth = 6150 Tag = "ToolbarOperacionesTerceros" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 1035 Left = 0 TabIndex = 0 Top = 360 Width = 6135 Begin VB.TextBox txt Index = 2 Left = 1320 TabIndex = 7 Top = 600 Width = 1500 Begin VB.TextBox txt Index = 1 Left = 4515 TabIndex = 4 Top = 240 Width = 1500 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 3 Top = 225 Width = 1500 Begin VB.Label lbl Caption = "Cantidad:" Height = 255 Index = 2 Left = 120 TabIndex = 8 Top = 615 Width = 1125 Begin VB.Label lbl Caption = "Fecha final:" Height = 255 Index = 1 Left = 3195 TabIndex = 5 Top = 240 Width =
340 Begin VB.Label lbl Caption = "Fecha inicial:" Height = 255 Index = 0 Left = 120 TabIndex = 2 Top = 240 Width = 1125 Begin MSComctlLib.Toolbar ToolbarOperacionesTerceros Align = 1 Align Top Height = 390 Left = 0 TabIndex = 1 Tag = "ToolbarCuentas" Top = 0 Width = 6150 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListOperacionesTerceros Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 0 TabIndex = 6 Top = 1440 Width = 6135 _ExtentX = _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Attribute VB_Name = "frmoperacionesterceros" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim msituacion As Situacion Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub ayudaroperacionesterceros() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = ""
341 txt(2) = "" txt(0).setfocus Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmoperacionesterceros = Forms(i) Next Call limatges16(me.imagelistoperacionesterceros) Set Me.ToolbarOperacionesTerceros.ImageList = Me.ImageListOperacionesTerceros Call cargarbotonera(me.toolbaroperacionesterceros) Call deshabilitarbotones(me.toolbaroperacionesterceros, "insertar", "modificar", "lupa", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarOperacionesTerceros_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimiroperacionesterceros Case "ayudar": Call ayudaroperacionesterceros Select Sub Private Sub guardartemporaloperacionesterceros(rs As ADODB.Recordset) Dim rst As ADODB.Recordset Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount cnt.execute "DELETE FROM OperacionesTerceros" Set rst = New ADODB.Recordset rst.open "SELECT * FROM OperacionesTerceros", cnt, adopenstatic, adlockoptimistic cnt.begintrans Set mauxiliar = New Auxiliar
342 While Not rs.eof rst.addnew rst("tipo") = rs("tipo") rst("nif") = rs("nif") rst("nombre") = rs("nombre") rst("direccion") = rs("direccion") rst("poblacion") = rs("poblacion") rst("cp") = rs("cp") rst("importe") = rs("importe") rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend Set mauxiliar = Nothing rst.close cnt.committrans Set rst = Nothing Sub Private Sub imprimiroperacionesterceros() Dim rs As ADODB.Recordset Set rs = obtenerdatos() If Not rs.eof Then Call guardartemporaloperacionesterceros(rs) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Function obtenerdatos() As Object Dim fini As String Dim ffin As String Dim vmin As String Dim rs As ADODB.Recordset If txt(0) = "" Then fini = sinicioejercicio fini = sdate(txt(0)) If txt(1) = "" Then ffin = sfinalejercicio ffin = sdate(txt(1)) If txt(2) = "" Then vmin = " " vmin = Replace(txt(2), ",", ".") Set rs = New ADODB.Recordset rs.open "SELECT RegistroIva.Tipo, Personal.nif, Personal.nombre, Personal.direccion, Personal.poblacion, Personal.cp, Sum(RegistroIva.re+RegistroIva.iva+RegistroIva.base) AS importe " _ & "FROM Apuntes, RegistroIva, Personal WHERE RegistroIVA.codigo_empresa = Personal.codigo_empresa AND RegistroIVA.codigo_personal = Personal.codigo " _ & "AND Apuntes.numero_apunte = RegistroIVA.numero_apunte AND Apuntes.numero_documento = RegistroIVA.numero_documento AND Apuntes.codigo_documento = RegistroIVA.codigo_documento " _ & "AND Apuntes.codigo_delegacion = RegistroIVA.codigo_delegacion AND Apuntes.codigo_empresa = RegistroIVA.codigo_empresa AND RegistroIva.codigo_empresa = " & sempresa & " " _ & "AND RegistroIva.codigo_delegacion = " & sdelegacion & " AND Apuntes.fecha_documento >= " & fini & " AND Apuntes.fecha_documento <= " & ffin & " " _
343 & "GROUP BY RegistroIva.Tipo, Personal.nif, Personal.nombre, Personal.direccion, Personal.poblacion, Personal.cp " _ & "HAVING Sum(RegistroIva.re+RegistroIva.iva+RegistroIva.base) >= " & vmin, cn, adopenstatic, adlockoptimistic Set obtenerdatos = rs Function Private Sub imprimir() Dim periodo As String Dim empresa As String periodo = "del " & IIf(txt(0) <> "", txt(0), ddate(sinicioejercicio)) & " al " & IIf(txt(1) <> "", txt(1), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("operacionesterceros.rpt", "Operaciones con terceros", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM OperacionesTerceros ORDER BY tipo, nif" Call minformes.execute Set minformes = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Cancel = False Set mauxiliar = New Auxiliar Select Case Index Case 0, 1: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) If sdate(txt(index)) < sinicioejercicio Or sdate(txt(index)) > sfinalejercicio Then msg = msgerror(1027) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
344 58. frmpergan.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmpergan Caption = "Balance de Pérdidas y Ganáncias" ClientHeight = 5730 ClientLeft = 60 ClientTop = 345 ClientWidth = 4755 LinkTopic = "frmpergan" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 382 ScaleMode = 3 Pixel ScaleWidth = 317 Tag = "ToolbarPergan" Begin MSComctlLib.ListView ListViewPergan Height = 2865 Left = 0 TabIndex = 9 TabStop = 0 False Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 7 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "D/H" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Nivel 1" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Nivel 2" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Nivel 3" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Nivel 4" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Título" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Cuentas" Object.Width = Property
345 Begin VB.Frame frmdatos Height = 2415 Left = 0 TabIndex = 4 Top = 3300 Width = 4740 Begin VB.TextBox txt Index = 4 Left = 3885 TabIndex = 7 Top = 675 Width = 705 Begin VB.TextBox txt Index = 3 Left = 3030 TabIndex = 3 Top = 675 Width = 705 Begin VB.TextBox txt Index = 2 Left = 2175 TabIndex = 2 Top = 675 Width = 705 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 1 Top = 675 Width = 705 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 0 Top = 300 Width = 705 Begin VB.TextBox txt Index = 5 Left = 1320 TabIndex = 5 Top = 1050 Width = 3270 Begin VB.TextBox txt Height = 810 Index = 6 Left = 1320 MultiLine = -1 True ScrollBars = 2 Vertical TabIndex = 6 Top = 1425 Width = 3270 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Nivel:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height =
346 Index = 1 Left = 75 TabIndex = 13 Top = 675 Width = 660 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "D/H:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 0 Left = 75 TabIndex = 12 Top = 300 Width = 960 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Título:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 75 TabIndex = 11 Top = 1050 Width = 660 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Cuentas:" Height = 255 Index = 3 Left = 75 TabIndex = 10 Top = 1425 Width = 1200 Begin MSComctlLib.ImageList ImageListPergan Left = 75 Top = 5100 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarPergan Align = 1 Align Top Height = 390 Left = 0 TabIndex = 8 Tag = "ToolbarPergan" Top = 0 Width = 4755 _ExtentX = 8387 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version =
347 Attribute VB_Name = "frmpergan" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mpergan As Pergan Private Sub AyudarPergan() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(6) = "" txt(0).setfocus Sub Private Sub EliminarPergan() Dim rpta As Integer Dim aux As String On Error GoTo EliminarPerganError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("pergan", "dh", "codigo_empresa = " & sempresa _ & " and dh = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3) & " and nivel_4 = " & txt(4), "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar la entrada " & txt(5) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mpergan = New Pergan mpergan.delete cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4) Set mpergan = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewPergan.ListItems.Remove ListViewPergan.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3) & txt(4)).index Call cancelardatos Exit Sub EliminarPerganError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarPergan() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "dh = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and "
348 filtro = filtro & "nivel_1 = " & txt(1) If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_2 = " & txt(2) If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_3 = " & txt(3) If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_4 = " & txt(4) If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "titulo = " & txt(5) & "" If txt(6) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cuentas = " & txt(6) & "" Call ListarPergan(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmpergan = Forms(i) Next Call limatges16(me.imagelistpergan) Set Me.ToolbarPergan.ImageList = Me.ImageListPergan Call cargarbotonera(me.toolbarpergan) Call deshabilitarbotones(me.toolbarpergan, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewPergan For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini"
349 If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewPergan For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirPergan() Sub Private Sub InsertarPergan() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarPerganError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("pergan", "dh", "codigo_empresa = " & sempresa _ & " and dh = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3) & " and nivel_4 = " & txt(4), "#") If aux = "#" Then Si no existe, lo inserto Set mpergan = New Pergan mpergan.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), susuario Set mpergan = Nothing On Error Resume Next For i = 0 To 6 If txt(i) = Null Then txt(i) = "" Next Set newitem = ListViewPergan.ListItems.Add(, "K" & txt(0) & txt(1) & txt(2) & txt(3) & txt(4), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) newitem.subitems(4) = txt(4) newitem.subitems(5) = txt(5) newitem.subitems(6) = txt(6) Call cancelardatos For i = 0 To 6 If txt(i) = Null Then txt(i) = "" Next MsgBox msgerror(1021), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarPerganError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarPergan(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem
350 If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewPergan.ListItems.Clear Set mpergan = New Pergan Set rs = mpergan.getlist(cn, strwhere, "codigo_empresa, dh, nivel_1, nivel_2, nivel_3, nivel_4") Do Until rs.eof Set newitem = ListViewPergan.ListItems.Add(, "K" & rs("dh") & rs("nivel_1") & rs("nivel_2") & rs("nivel_3") & rs("nivel_4"), rs("dh")) newitem.subitems(1) = Nz(rs("nivel_1"), "") newitem.subitems(2) = Nz(rs("nivel_2"), "") newitem.subitems(3) = Nz(rs("nivel_3"), "") newitem.subitems(4) = Nz(rs("nivel_4"), "") newitem.subitems(5) = Nz(rs("titulo"), "") newitem.subitems(6) = Nz(rs("cuentas"), "") rs.movenext Loop Set rs = Nothing Set mpergan = Nothing Sub Private Sub ListViewPergan_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewPergan.SelectedItem.Text Me.txt(1) = Me.ListViewPergan.SelectedItem.SubItems(1) Me.txt(2) = Me.ListViewPergan.SelectedItem.SubItems(2) Me.txt(3) = Me.ListViewPergan.SelectedItem.SubItems(3) Me.txt(4) = Me.ListViewPergan.SelectedItem.SubItems(4) Call txt_lostfocus(0) Sub Private Sub ModificarPergan() Dim i As Integer Dim aux As String On Error GoTo ModificarPerganError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" And txt(3) <> "" And txt(4) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("pergan", "dh", "codigo_empresa = " & sempresa _ & " and dh = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3) & " and nivel_4 = " & txt(4), "#") If aux <> "#" Then Si existe, lo modifico Set mpergan = New Pergan mpergan.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), susuario Set mpergan = Nothing On Error Resume Next For i = 0 To 6 If txt(i) = Null Then txt(i) = "" Next ListViewPergan.ListItems(ListViewPergan.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3) & txt(4)).index).subitems(5) = txt(5) ListViewPergan.ListItems(ListViewPergan.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3) & txt(4)).index).subitems(6) = txt(6) Call cancelardatos For i = 0 To 5 If txt(i) = Null Then txt(i) = "" Next MsgBox msgerror(1022), vbcritical, App.Title
351 Set mauxiliar = Nothing Exit Sub ModificarPerganError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarPergan_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarPergan Case "modificar": If validardatos Then Call ModificarPergan Case "filtrar": Call FiltrarPergan Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarPergan Case "listar": Call ListarPergan Case "imprimir": Call ImprimirPergan Case "ayudar": Call AyudarPergan Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarPergan.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarPergan.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Or Index = 1 Or Index = 2 Or Index = 3 Or Index = 4 Then If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" And txt(3) <> "" And txt(4) <> "" Then Set mpergan = New Pergan Set rs = mpergan.getlist(cn, "codigo_empresa = " & sempresa _ & " and dh = " & txt(0) & " and nivel_1 = " & txt(1) _ & " and nivel_2 = " & txt(2) & " and nivel_3 = " & txt(3) & " and nivel_4 = " & txt(4)) If Not rs.eof Then txt(5) = Nz(rs("titulo"), "") txt(6) = Nz(rs("cuentas"), "") Set rs = Nothing Set mpergan = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Cancel = False Select Case Index Case 0: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) If txt(index) <> "D" And txt(index) <> "H" Then msg = msgerror(1025) Case 1, 2, 3, 4: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1024) txt(index) = Replace(txt(Index), ".", ",") If txt(index) <> Int(txt(Index)) Then msg = msgerror(1024)
352 Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 5 Select Case i Case 0, 1, 2, 3, 4, 5: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 6 Select Case i Case 1, 2, 3, 4: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
353 59. frmpersonal.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmpersonal Caption = "Datos personales" ClientHeight = 4350 ClientLeft = 60 ClientTop = 345 ClientWidth = 8940 LinkTopic = "frmpersonal" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 290 ScaleMode = 3 Pixel ScaleWidth = 596 Tag = "ToolbarPersonal" Begin MSComctlLib.ListView ListViewPersonal Height = 1545 Left = 0 TabIndex = 12 Top = 450 Width = 8940 _ExtentX = _ExtentY = 2725 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 3 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Nombre" Object.Width = Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "NIF" Object.Width = Property Begin VB.Frame frmdatos Height = 2355 Left = 0 TabIndex = 13 Top = 1980 Width = 8940 Begin VB.TextBox txt Index = 2 Left = 6840 TabIndex = 2 Top = 735 Width = 1650 Begin VB.TextBox txt Index = 6 Left = 1050 TabIndex = 6 Top = 1455 Width =
354 Begin VB.TextBox txt Index = 7 Left = 3045 TabIndex = 7 Top = 1455 Width = 1290 Begin VB.TextBox txt Index = 8 Left = 1050 TabIndex = 8 Top = 1815 Width = 1290 Begin VB.TextBox txt Index = 9 Left = 3045 TabIndex = 9 Top = 1815 Width = 1290 Begin VB.TextBox txt Index = 10 Left = 5400 TabIndex = 10 Top = 1815 Width = 3090 Begin VB.TextBox txt Index = 5 Left = 7680 TabIndex = 5 Top = 1095 Width = 810 Begin VB.TextBox txt Index = 1 Left = 1050 TabIndex = 1 Top = 720 Width = 4965 Begin VB.TextBox txt Index = 4 Left = 5400 TabIndex = 4 Top = 1095 Width = 1530 Begin VB.TextBox txt Index = 3 Left = 1050 TabIndex = 3 Top = 1095 Width = 3255 Begin VB.TextBox txt Index = 0 Left = 1050 TabIndex = 0 Top = 345 Width = 825 Begin VB.Label lbl BackStyle = 0 Transparent Caption = " " Height = 255 Index =
355 Left = 4560 TabIndex = 24 Top = 1815 Width = 540 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "FAX:" Height = 255 Index = 11 Left = 2520 TabIndex = 23 Top = 1815 Width = 465 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Teléfono:" Height = 255 Index = 10 Left = 120 TabIndex = 22 Top = 1815 Width = 780 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "NIF:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 8 Left = 6240 TabIndex = 21 Top = 735 Width = 540 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "País:" Height = 255 Index = 7 Left = 2520 TabIndex = 20 Top = 1455 Width = 420 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Provincia:" Height = 255 Index = 6 Left = 120 TabIndex = 19 Top = 1455 Width = 780 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Nombre:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False
356 Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 18 Top = 735 Width = 795 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Población:" Height = 255 Index = 2 Left = 4560 TabIndex = 17 Top = 1095 Width = 780 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Direccion:" Height = 255 Index = 3 Left = 120 TabIndex = 16 Top = 1095 Width = 960 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "C.P.:" Height = 255 Index = 5 Left = 7080 TabIndex = 15 Top = 1095 Width = 420 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Codigo:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 14 Top = 360 Width = 900 Begin MSComctlLib.ImageList ImageListPersonal Left = 120 Top = 4680 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarPersonal Align = 1 Align Top Height = 390 Left = 0 TabIndex = 11 Tag = "ToolbarPersonal"
357 Top = 0 Width = 8940 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmpersonal" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim mpersonal As Personal Private Sub AyudarPersonal() Sub Private Sub cancelardatos() txt(0) = "": txt(1) = "": txt(2) = "": txt(3) = "": txt(4) = "" txt(5) = "": txt(6) = "": txt(7) = "": txt(8) = "": txt(9) = "" txt(10) = "" txt(0).setfocus Sub Private Sub EliminarPersonal() Dim rpta As Integer Dim aux As String Dim rs As ADODB.Recordset On Error GoTo EliminarPersonalError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("personal", "codigo", "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Dim mauxiliariva As New Auxiliar Set rs = mauxiliar.getlistext(cn, "RegistroIVA", "codigo_personal", "codigo_empresa = " & sempresa & " and codigo_personal = " & txt(0) & "", "codigo_personal") Set mauxiliariva = Nothing If Not rs.eof Then Si ya existe alguna entrada con este impuesto, cancelamos la eliminacion MsgBox msgerror(1035), vbcritical, App.Title rpta = MsgBox(" Desea eliminar el codigo " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mpersonal = New Personal mpersonal.delete cn, sempresa, txt(0) Set mpersonal = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewPersonal.ListItems.Remove ListViewPersonal.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarPersonalError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub
358 Private Sub FiltrarPersonal() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nombre = " & txt(1) & "" If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nif = " & txt(2) & "" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "direccion = " & txt(3) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "poblacion = " & txt(4) & "" If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cp = " & txt(5) & "" If txt(6) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "provincia = " & txt(6) & "" If txt(7) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pais = " & txt(7) & "" If txt(8) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "telefono = " & txt(8) & "" If txt(9) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "fax = " & txt(9) & "" If txt(10) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & " = " & txt(10) & "" Call ListarPersonal(filtro) Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Then MsgBox "No se ha especificado la empresa o delegación.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then
359 Set frmpersonal = Forms(i) Next Call limatges16(me.imagelistpersonal) Set Me.ToolbarPersonal.ImageList = Me.ImageListPersonal Call cargarbotonera(me.toolbarpersonal) Call deshabilitarbotones(me.toolbarpersonal, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewPersonal For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewPersonal For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirPersonal() Sub Private Sub InsertarPersonal() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarPersonalError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("personal", "codigo", "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "", "#") If aux = "#" Then Si no existe, lo inserto Set mpersonal = New Personal mpersonal.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), txt(10), susuario Set mpersonal = Nothing On Error Resume Next For i = 0 To 10 If txt(i) = "null" Then txt(i) = "" Next
360 Set newitem = ListViewPersonal.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) Call cancelardatos For i = 0 To 10 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1019), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarPersonalError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarPersonal(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewPersonal.ListItems.Clear Set mpersonal = New Personal Set rs = mpersonal.getlist(cn, strwhere, "codigo_empresa, codigo") Do Until rs.eof Set newitem = ListViewPersonal.ListItems.Add(, "K" & rs("codigo"), rs("codigo")) newitem.subitems(1) = Nz(rs("nombre"), "") newitem.subitems(2) = Nz(rs("nif"), "") rs.movenext Loop Set rs = Nothing Set mpersonal = Nothing Sub Private Sub ListViewPersonal_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewPersonal.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarPersonal() Dim i As Integer Dim aux As String On Error GoTo ModificarPersonalError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("personal", "codigo", "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "", "#") If aux <> "#" Then Si existe, lo modifico Set mpersonal = New Personal mpersonal.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), txt(10), susuario Set mpersonal = Nothing On Error Resume Next For i = 0 To 10 If txt(i) = "null" Then txt(i) = "" Next ListViewPersonal.ListItems(ListViewPersonal.FindItem(txt(0)).Index).SubItems(1) = txt(1)
361 ListViewPersonal.ListItems(ListViewPersonal.FindItem(txt(0)).Index).SubItems(2) = txt(2) Call cancelardatos For i = 0 To 10 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1020), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarPersonalError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarPersonal_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarPersonal Case "modificar": If validardatos Then Call ModificarPersonal Case "filtrar": Call FiltrarPersonal Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarPersonal Case "listar": Call ListarPersonal Case "imprimir": Call ImprimirPersonal Case "ayudar": Call AyudarPersonal Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarPersonal.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarPersonal.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset Me.ToolbarPersonal.Buttons(7).Enabled = False If Index = 0 Then If txt(0) <> "" Then Set mpersonal = New Personal Set rs = mpersonal.getlist(cn, "codigo_empresa = " & sempresa & " and codigo = " & txt(0) & "") If Not rs.eof Then txt(1) = Nz(rs("nombre"), "") txt(2) = Nz(rs("nif"), "") txt(3) = Nz(rs("direccion"), "") txt(4) = Nz(rs("poblacion"), "") txt(5) = Nz(rs("cp"), "") txt(6) = Nz(rs("provincia"), "") txt(7) = Nz(rs("pais"), "") txt(8) = Nz(rs("telefono"), "") txt(9) = Nz(rs("fax"), "") txt(10) = Nz(rs(" "), "") Set rs = Nothing Set mpersonal = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Cancel = False
362 Select Case Index Case 2: If txt(index) <> "" Then If Not (validarnifnie(txt(index)) Or validarcif(txt(index))) Then msg = msgerror(1006) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 10 Select Case i Case 0, 1, 2: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
363 60. frmregistroiva.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmregistroiva Caption = "Registro de IVA" ClientHeight = 6600 ClientLeft = 60 ClientTop = 345 ClientWidth = 7905 LinkTopic = "frmregistroiva" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 440 ScaleMode = 3 Pixel ScaleWidth = 527 Tag = "ToolbarRegistroIva" Begin MSComctlLib.ListView ListViewRegistroIva Height = 2865 Left = 0 TabIndex = 5 Top = 450 Width = 7905 _ExtentX = _ExtentY = 5054 SortKey = 1 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 12 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Documento" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Número" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Apunte" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Tipo Documento" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Acre/Deu" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Id. Acr/Deu" Object.Width = Property BeginProperty ColumnHeader(7) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 6 Text = "Impuesto" Object.Width = Property BeginProperty ColumnHeader(8) {BDD1F B-11D1-B16A-00C0F } SubItemIndex =
364 Text = "Base" Object.Width = Property BeginProperty ColumnHeader(9) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 8 Text = "%IVA" Object.Width = Property BeginProperty ColumnHeader(10) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 9 Text = "IVA" Object.Width = Property BeginProperty ColumnHeader(11) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 10 Text = "%RE" Object.Width = Property BeginProperty ColumnHeader(12) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 11 Text = "Rec." Object.Width = Property Begin VB.Frame frmdatos Height = 3210 Left = 0 TabIndex = 4 Top = 3360 Width = 7905 Begin VB.TextBox txt Index = 9 Left = 6240 TabIndex = 29 Top = 2760 Width = 1005 Begin VB.TextBox txt Index = 7 Left = 4200 TabIndex = 27 Top = 2760 Width = 1005 Begin VB.TextBox txt Index = 8 Left = 6240 Locked = -1 True TabIndex = 28 Top = 2400 Width = 525 Begin VB.TextBox txt Index = 6 Left = 4200 Locked = -1 True TabIndex = 26 Top = 2400 Width = 525 Begin VB.TextBox txt Index = 5 Left = 2640 TabIndex = 25 Top = 2520 Width = 885 Begin VB.TextBox txt Index = 4 Left = 2640 TabIndex =
365 Tag = "IMPUESTOS.impuesto" Top = 1920 Width = 1005 Begin VB.TextBox txt Index = 3 Left = 2640 TabIndex = 19 Tag = "PERSONAL.codigo" Top = 1440 Width = 525 Begin VB.Frame frmtipo BorderStyle = 0 None Enabled = 0 False Height = 240 Left = 1560 TabIndex = 15 Top = 840 Width = 2940 Begin VB.OptionButton opt Caption = "Compra" Height = 240 Index = 0 Left = 75 TabIndex = 18 Top = 0 Value = -1 True Width = 915 Begin VB.OptionButton opt Caption = "Venta" Height = 240 Index = 1 Left = 1080 TabIndex = 17 Top = 0 Width = 840 Begin VB.OptionButton opt Caption = "Inversión" Height = 240 Index = 2 Left = 1950 TabIndex = 16 Top = 0 Width = 990 Begin VB.Frame fratipo Caption = "Tipo" Height = 1455 Left = 120 TabIndex = 9 Top = 1320 Width = 1575 Begin VB.OptionButton opt_tip Caption = "Cliente" Height = 255 Index = 0 Left = 120 TabIndex = 13 Top = 360 Value = -1 True Width = 1335 Begin VB.OptionButton opt_tip Caption = "Proveedor" Height = 255 Index = 1 Left = 120 TabIndex = 12 Top = 600 Width = 1335 Begin VB.OptionButton opt_tip
366 Caption = "Deudor" Height = 255 Index = 2 Left = 120 TabIndex = 11 Top = 840 Width = 1335 Begin VB.OptionButton opt_tip Caption = "Acreedor" Height = 255 Index = 3 Left = 120 TabIndex = 10 Top = 1080 Width = 1335 Begin VB.TextBox txt Index = 1 Left = 3720 TabIndex = 2 Top = 345 Width = 1395 Begin VB.TextBox txt Index = 0 Left = 1200 TabIndex = 1 Tag = "DOCUMENTOS.codigo_documento" Top = 345 Width = 855 Begin VB.TextBox txt Index = 2 Left = 6930 TabIndex = 3 Top = 345 Width = 885 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Recargo:" Height = 255 Index = 10 Left = 5400 TabIndex = 34 Top = 2775 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "IVA:" Height = 255 Index = 9 Left = 3720 TabIndex = 33 Top = 2775 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "%Recargo:" Height = 255 Index = 8 Left = 5400 TabIndex = 32 Top = 2415 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "%IVA:" Height =
367 Index = 7 Left = 3720 TabIndex = 31 Top = 2415 Width = 495 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Base:" Height = 255 Index = 6 Left = 1800 TabIndex = 30 Top = 2520 Width = 855 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Index = 4 Left = 3720 TabIndex = 24 Top = 1920 Width = 4095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Impuesto:" Height = 255 Index = 4 Left = 1800 TabIndex = 23 Top = 1935 Width = 855 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Index = 3 Left = 3240 TabIndex = 21 Top = 1440 Width = 4575 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Nombre:" Height = 255 Index = 3 Left = 1800 TabIndex = 20 Top = 1455 Width = 855 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Tipo de impuesto:" Height = 255 Index = 5 Left = 120 TabIndex = 14 Top = 840 Width = 1320 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Número:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False
368 Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 2880 TabIndex = 8 Top = 360 Width = 750 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Documento:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 7 Top = 360 Width = 1095 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Apunte:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 6120 TabIndex = 6 Top = 360 Width = 735 Begin MSComctlLib.ImageList ImageListRegistroIva Left = 0 Top = 6840 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarRegistroIva Align = 1 Align Top Height = 390 Left = 0 TabIndex = 0 Tag = "ToolbarRegistroIva" Top = 0 Width = 7905 _ExtentX = _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version =
369 Attribute VB_Name = "frmregistroiva" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mregistroiva As RegistroIva Dim mnumeracion As numeracion Dim mauxiliar As Auxiliar Private Sub AyudarRegistroIva() Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(6) = "" txt(7) = "" txt(8) = "" txt(9) = "" des(3) = "" des(4) = "" opt(0) = 1 opt(1) = 0 opt(2) = 0 opt_tip(0) = 1 opt_tip(1) = 0 opt_tip(2) = 0 opt_tip(3) = 0 txt(0).enabled = True txt(1).enabled = True txt(2).enabled = True txt(0).setfocus Sub Private Sub EliminarRegistroIva() Dim rpta As Integer Dim aux As String On Error GoTo EliminarRegistroIvaError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("registroiva", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " and numero_documento = " & txt(1) & " and numero_apunte = " & txt(2), "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el registro del documento " & txt(0) & "/" & txt(1) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set mregistroiva = New RegistroIva mregistroiva.delete cn, sempresa, sdelegacion, txt(0), txt(1), txt(2) Set mregistroiva = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewRegistroIva.ListItems.Remove ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).index Set mauxiliar = Nothing
370 Call cancelardatos Exit Sub EliminarRegistroIvaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarRegistroIva() Dim filtro As String Dim mauxiliar As Auxiliar filtro = "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_documento = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numero_documento = " & txt(1) & "" If IsNumeric(txt(2)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "numero_apunte = " & txt(2) If opt(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = C" If opt(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = V" If opt(2) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo = I" If opt_tip(0) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo_acrdeu = CLI" If opt_tip(1) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo_acrdeu = PRO" If opt_tip(2) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo_acrdeu = DEU" If opt_tip(3) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "tipo_acrdeu = ACR" If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "codigo_personal = " & txt(3) & "" If txt(4) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "impuesto = " & txt(4) & ""
371 If IsNumeric(txt(5)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "base = " & Replace(txt(5), ",", ".") If IsNumeric(txt(6)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "pctiva = " & Replace(txt(6), ",", ".") If IsNumeric(txt(7)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "iva = " & Replace(txt(7), ",", ".") If IsNumeric(txt(8)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "re = " & Replace(txt(8), ",", ".") If IsNumeric(txt(9)) Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "re = " & Replace(txt(9), ",", ".") Call ListarRegistroIva(filtro) Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmregistroiva = Forms(i) Next Call limatges16(me.imagelistregistroiva) Set Me.ToolbarRegistroIva.ImageList = Me.ImageListRegistroIva Call cargarbotonera(me.toolbarregistroiva) Call deshabilitarbotones(me.toolbarregistroiva, "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewRegistroIva For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewRegistroIva For i = 1 To.ColumnHeaders.Count
372 writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirRegistroIva() Sub Private Function strtipo() As String If opt_tip(0) Then strtipo = "CLI" If opt_tip(1) Then strtipo = "PRO" If opt_tip(2) Then strtipo = "DEU" strtipo = "ACR" Function Private Function strdocumento() As String If opt(0) Then strdocumento = "C" If opt(1) Then strdocumento = "V" strdocumento = "I" Function Private Sub insertarregistroiva() Dim i As Integer Dim aux As String Dim newitem As ListItem Dim tipo As String On Error GoTo InsertarRegistroIvaError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("registroiva", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " and numero_documento = " & txt(1) & " and numero_apunte = " & txt(2), "#") If aux = "#" Then Compruebo la relacion entre el registro de iva y el asiento aux = mauxiliar.vbuscarcampo("impuestos, Apuntes", "Apuntes.cuenta AS cuenta", "Apuntes.codigo_empresa = Impuestos.codigo_empresa and Apuntes.cuenta = Impuestos.cta_iva and Apuntes.codigo_empresa = " & sempresa & " " _ & "and Apuntes.codigo_delegacion = " & sdelegacion & " and Apuntes.codigo_documento = " & txt(0) & " and Apuntes.numero_documento = " & txt(1) & " and numero_apunte = " & txt(2), "#") If aux = "#" Then MsgBox msgerror(1043), vbcritical, App.Title Inserto el registro Set mregistroiva = New RegistroIva mregistroiva.insert cn, sempresa, sdelegacion, txt(0), txt(1), txt(2), strdocumento, strtipo, txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), susuario Set mregistroiva = Nothing On Error Resume Next For i = 0 To 7 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewRegistroIva.ListItems.Add(, getkeygrid(txt(0), txt(1), txt(2)), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = strdocumento newitem.subitems(4) = strtipo newitem.subitems(5) = txt(3)
373 newitem.subitems(6) = txt(4) newitem.subitems(7) = Format(txt(5), "0.00") newitem.subitems(8) = txt(6) newitem.subitems(9) = Format(txt(7), "0.00") newitem.subitems(10) = txt(8) newitem.subitems(11) = Format(txt(9), "0.00") Call cancelardatos For i = 0 To 7 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1041), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarRegistroIvaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarRegistroIva(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & "" Elimino los datos de la lista ListViewRegistroIva.ListItems.Clear Set mauxiliar = New Auxiliar Set mregistroiva = New RegistroIva Set rs = mregistroiva.getlist(cn, strwhere) Do Until rs.eof Set newitem = ListViewRegistroIva.ListItems.Add(, getkeygrid(rs!codigo_documento, rs!numero_documento, rs!numero_apunte), rs!codigo_documento) newitem.subitems(1) = Nz(rs!numero_documento, "") newitem.subitems(2) = Nz(rs!numero_apunte, "") newitem.subitems(3) = Nz(rs!tipo, "") newitem.subitems(4) = Nz(rs!tipo_acrdeu, "") newitem.subitems(5) = Nz(rs!codigo_personal, "") newitem.subitems(6) = Nz(rs!impuesto, "") newitem.subitems(7) = Format(Nz(rs!base, ""), "0.00") newitem.subitems(8) = Nz(rs!pctiva, "") newitem.subitems(9) = Format(Nz(rs!iva, ""), "0.00") newitem.subitems(10) = Nz(rs!pctre, "") newitem.subitems(11) = Format(Nz(rs!re, ""), "0.00") rs.movenext Loop Set rs = Nothing Set mregistroiva = Nothing Set mauxiliar = Nothing Sub Private Sub ListViewRegistroIva_DblClick() On Error Resume Next txt(0) = Me.ListViewRegistroIva.SelectedItem.Text: txt(0).enabled = False txt(1) = Me.ListViewRegistroIva.SelectedItem.SubItems(1): txt(1).enabled = False txt(2) = Me.ListViewRegistroIva.SelectedItem.SubItems(2): txt(2).enabled = False Call txt_lostfocus(0) Sub Private Sub modificarregistroiva() Dim i As Integer Dim aux As String On Error GoTo ModificarRegistroIvaError If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then
374 Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("registroiva", "codigo_documento", "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " and numero_documento = " & txt(1) & " and numero_apunte = " & txt(2), "#") If aux <> "#" Then Si existe, lo modifico Set mregistroiva = New RegistroIva mregistroiva.update cn, sempresa, sdelegacion, txt(0), txt(1), txt(2), strdocumento, strtipo, txt(3), txt(4), txt(5), txt(6), txt(7), txt(8), txt(9), susuario Set mregistroiva = Nothing On Error Resume Next For i = 0 To 7 If txt(i) = "null" Then txt(i) = "" Next ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(3) = strdocumento ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(4) = strtipo ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(5) = txt(3) ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(6) = txt(4) ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(7) = Format(txt(5), "0.00") ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(8) = txt(6) ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(9) = Format(txt(7), "0.00") ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(10) = txt(8) ListViewRegistroIva.ListItems(getKeyGrid(txt(0), txt(1), txt(2))).subitems(11) = Format(txt(9), "0.00") Call cancelardatos For i = 0 To 7 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(1042), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarRegistroIvaError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarRegistroIva_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call insertarregistroiva Case "modificar": If validardatos Then Call modificarregistroiva Case "filtrar": Call FiltrarRegistroIva Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarRegistroIva Case "listar": Call ListarRegistroIva Case "imprimir": Call ImprimirRegistroIva Case "ayudar": Call AyudarRegistroIva Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarRegistroIva.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarRegistroIva.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub
375 Private Function indtipo(tipo As String) As Integer If tipo = "CLI" Then indtipo = 0 If tipo = "PRO" Then indtipo = 1 If tipo = "DEU" Then indtipo = 2 indtipo = 3 Function Private Function inddocumento(tipo As String) As Integer If tipo = "C" Then inddocumento = 0 If tipo = "V" Then inddocumento = 1 inddocumento = 3 Function Private Sub txt_lostfocus(index As Integer) Select Case Index Case 0, 1, 2: Call cargarregistroiva Case 4: Call actualizartipoimpuesto Case 5, 6, 7, 8, 9: Call calcularimportes Select Sub Private Sub actualizartipoimpuesto() Dim aux As String Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("impuestos", "tipo", "codigo_empresa = " & sempresa & " and impuesto = " & txt(4) & "", "") Set mauxiliar = Nothing opt(inddocumento(aux)) = 1 Sub Private Sub cargarregistroiva() Dim rs As ADODB.Recordset If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" Then Set mauxiliar = New Auxiliar Set mregistroiva = New RegistroIva Set rs = mregistroiva.getlist(cn, "codigo_empresa = " & sempresa & " and codigo_delegacion = " & sdelegacion & " and codigo_documento = " & txt(0) & " and numero_documento = " & txt(1) & " and numero_apunte = " & txt(2)) If Not rs.eof Then txt(3) = Nz(rs!codigo_personal, "") txt(4) = Nz(rs!impuesto, "") txt(5) = Format(Nz(rs!base, ""), "0.00") txt(6) = Nz(rs!pctiva, "") txt(7) = Format(Nz(rs!iva, ""), "0.00") txt(8) = Nz(rs!pctre, "") txt(9) = Format(Nz(rs!re, ""), "0.00") opt_tip(indtipo(nz(rs!tipo_acrdeu, ""))) = 1 opt(inddocumento(nz(rs!tipo, ""))) = 1 If txt(3) <> "" Then des(3) = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " and codigo = " & txt(3) & "", "") If txt(4) <> "" Then des(4) = mauxiliar.vbuscarcampo("impuestos", "descripcion", "codigo_empresa = " & sempresa & " and impuesto = " & txt(4) & "", "") Set rs = Nothing Set mregistroiva = Nothing Set mauxiliar = Nothing Sub Private Sub calcularimportes() If IsNumeric(txt(5)) Then
376 If IsNumeric(txt(6)) Then txt(7) = Format(txt(5) * txt(6) / 100, "0.00") If IsNumeric(txt(8)) Then txt(9) = Format(txt(5) * txt(8) / 100, "0.00") Sub Compruebo que el dato que informo (si lo informo) es correcto. Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String Cancel = False msg = "" Set mauxiliar = New Auxiliar Select Case Index Case 3: If txt(index) <> "" Then aux = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " and codigo = " & txt(3) & "", "#") If aux = "#" Then msg = msgerror(9999) des(index) = aux Case 4: If txt(index) <> "" Then aux = mauxiliar.vbuscarcampo("impuestos", "descripcion", "codigo_empresa = " & sempresa & " and impuesto = " & txt(4) & "", "#") If aux = "#" Then msg = msgerror(9999) des(index) = aux Case 5, 6, 7, 8, 9: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 9 Select Case i Case 0, 1, 2: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 9 Select Case i
377 Case 5, 6, 7, 8, 9: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function Private Function getkeygrid(codigo_documento As String, numero_documento As String, numero_apunte As Integer) As String Dim mauxiliar As Auxiliar Set mauxiliar = New Auxiliar getkeygrid = "K" & Trim(codigo_documento) & Trim(numero_documento) & Trim(numero_apunte) Set mauxiliar = Nothing Function
378 61. frmregularizacion.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmregularizacion Caption = "Regularización" ClientHeight = 1425 ClientLeft = 60 ClientTop = 450 ClientWidth = 5520 LinkTopic = "frmregularizacion" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 95 ScaleMode = 3 Pixel ScaleWidth = 368 Tag = "ToolbarRegularizacion" Begin Crystal.CrystalReport informe Left = 120 Top = 4320 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 1035 Left = 0 TabIndex = 1 Top = 360 Width = 5505 Begin VB.TextBox txt Enabled = 0 False Index = 1 Left = 1350 TabIndex = 5 Top = 600 Width = 1335 Begin VB.TextBox txt Index = 0 Left = 1350 TabIndex = 0 Tag = "CUENTAS.cuenta" Top = 225 Width = 1335 Begin MSForms.CheckBox chkverasiento Height = 315 Left = 3480 TabIndex = 7 Top = 600 Width = 1890 VariousPropertyBits= BackColor = ForeColor = DisplayStyle = 4 Size = "3334;556" Value = "0" Caption = "Ver asiento generado" FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label des BackColor = &H A& BorderStyle = 1 Fixed Single Height = 315 Index =
379 Left = 2775 TabIndex = 6 Top = 225 Width = 2610 Begin VB.Label lbl Caption = "Tipo documento:" Height = 255 Index = 1 Left = 75 TabIndex = 4 Top = 600 Width = 1305 Begin VB.Label lbl Caption = "Cuenta:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 0 Left = 75 TabIndex = 2 Top = 225 Width = 1305 Begin MSComctlLib.Toolbar ToolbarRegularizacion Align = 1 Align Top Height = 390 Left = 0 TabIndex = 3 Tag = "ToolbarRegularizacion" Top = 0 Width = 5520 _ExtentX = 9737 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListRegularizacion Left = 840 Top = 4320 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmregularizacion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim minformes As Informes Dim mregularizacion As Regularizacion Private Sub ayudarregularizacion() Sub Private Sub cancelardatos() txt(0) = "": des(0) = "" txt(1) = "": chkverasiento = 0 txt(0).setfocus Sub
380 Private Sub insertarregularizacion() Dim rpta As Integer Dim regularizado As String Set mauxiliar = New Auxiliar regularizado = mauxiliar.vbuscarcampo("ejercicios", "regularizado", "codigo_empresa = " & sempresa & " and ejercicio = " & iejercicio, "#") Set mauxiliar = Nothing If regularizado = "S" Then rpta = MsgBox("El ejercicio ya ha sido regularizado. Desea ver el asiento?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Call imprimirregularizacion Set mregularizacion = New Regularizacion mregularizacion.insert cn, sempresa, iejercicio, txt(0), txt(1), susuario, False Set mregularizacion = Nothing If chkverasiento Then Call imprimirregularizacion Sub Private Sub imprimirregularizacion() Dim rs As ADODB.Recordset Dim strwherereport As String strwherereport = "codigo_empresa = " & sempresa & " and codigo_delegacion = " _ & sempresa & " and codigo_documento = " & txt(1) & "" Set rs = obtenerdatos(strwherereport) If Not rs.eof Then Call guardartemporalregularizacion(rs) Call imprimir MsgBox msgerror(9000), vbcritical, App.Title Sub Private Sub guardartemporalregularizacion(rs As ADODB.Recordset) Dim rst As ADODB.Recordset Dim contador As Integer cnt.execute "DELETE FROM LibroDiario" Set rst = New ADODB.Recordset rst.open "SELECT * FROM LibroDiario", cnt, adopenstatic, adlockoptimistic Set mauxiliar = New Auxiliar cnt.begintrans While Not rs.eof rst.addnew rst("fecha_apunte") = rs("fecha_apunte") rst("numero_documento") = rs("numero_documento") rst("numero_apunte") = rs("numero_apunte") rst("cuenta") = rs("cuenta") rst("titulo") = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & rs("cuenta") & "", "") rst("concepto") = rs("concepto") rst("debe") = rs("debe") rst("haber") = rs("haber") rst.update rs.movenext Wend rst.close cnt.committrans Set mauxiliar = Nothing Set rst = Nothing Sub
381 Private Sub imprimir() Dim empresa As String Dim delegación As String Dim ordenacion As String Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("regularizacion.rpt", "Asiento de regularización", SCREENMODE) Call minformes.rptformulas("empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM LibroDiario ORDER BY fecha_apunte, numero_documento, numero_apunte" Call minformes.execute Set minformes = Nothing Sub Private Function obtenerdatos(strwherereport As String) As Object Dim rs As ADODB.Recordset Set mregularizacion = New Regularizacion Set rs = mregularizacion.getlist(cn, strwherereport, "cuenta") Set mregularizacion = Nothing Set obtenerdatos = rs Function Private Function validarregularizacion() As String validarregularizacion = msgerror(9999) Function Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmregularizacion = Forms(i) Next Call limatges16(me.imagelistregularizacion) Set Me.ToolbarRegularizacion.ImageList = Me.ImageListRegularizacion Call cargarbotonera(me.toolbarregularizacion) Call deshabilitarbotones(me.toolbarregularizacion, "cancelar", "imprimir", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Documento asociado a la regularización txt(1) = "REGU" & Trim(str(iEjercicio)) Sub
382 Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub ToolbarRegularizacion_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call insertarregularizacion Case "lupa": Call mostrarlupa(me) Case "ayudar": Call ayudarregularizacion Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarRegularizacion.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarRegularizacion.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 121 And Shift = 0 And Me.ToolbarRegularizacion.Buttons(7).Enabled Then Call mostrarlupa(me) F10 Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String Dim aux As String msg = "" Set mauxiliar = New Auxiliar Select Case Index Case 0: If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "", "#") If aux = "#" Then msg = msgerror(9999) des(index) = aux Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 1 Select Case i Case 0: If txt(i) = "" Then
383 msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
384 62. frmseleccioncartera.frm VERSION 5.00 Begin VB.Form frmseleccioncartera Caption = "Selección de efectos" ClientHeight = 3720 ClientLeft = 60 ClientTop = 450 ClientWidth = 7845 LinkTopic = "frmseleccioncartera" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 248 ScaleMode = 3 Pixel ScaleWidth = 523 Begin VB.Frame fradatos Height = 3705 Left = 0 TabIndex = 11 Top = 0 Width = 7815 Begin VB.TextBox txt Index = 1 Left = 2475 TabIndex = 18 Tag = "CUENTAS.cuenta" Top = 637 Width = 1335 Begin VB.CommandButton cmdaceptar Caption = "Aceptar" Height = 375 Left = 4425 TabIndex = 9 Top = 3150 Width = 1575 Begin VB.CommandButton cmdcancelar Caption = "Cancelar" Height = 375 Left = 6075 TabIndex = 10 Top = 3150 Width = 1575 Begin VB.TextBox txt Index = 8 Left = 2475 TabIndex = 7 Top = 2475 Width = 1335 Begin VB.TextBox txt Index = 9 Left = 6330 TabIndex = 8 Top = 2475 Width = 1335 Begin VB.TextBox txt Index = 6 Left = 2475 TabIndex = 5 Top = 2105 Width = 1335 Begin VB.TextBox txt Index = 7 Left =
385 TabIndex = 6 Top = 2105 Width = 1335 Begin VB.TextBox txt Index = 0 Left = 2475 TabIndex = 0 Tag = "CUENTAS.cuenta" Top = 270 Width = 1335 Begin VB.TextBox txt Index = 5 Left = 6330 TabIndex = 4 Top = 1738 Width = 1335 Begin VB.TextBox txt Index = 4 Left = 2475 TabIndex = 3 Top = 1738 Width = 1335 Begin VB.TextBox txt Index = 3 Left = 2475 TabIndex = 2 Tag = "PERSONAL.codigo" Top = 1371 Width = 1335 Begin VB.TextBox txt Index = 2 Left = 2475 TabIndex = 1 Tag = "PERSONAL.codigo" Top = 1004 Width = 1335 Begin VB.Label lbltipoefectos BackColor = &H & Caption = "Cobro" Height = 255 Left = 150 TabIndex = 28 Top = 2880 Visible = 0 False Width = 1335 Begin VB.Label lbl Caption = "Fecha vto máxima:" Height = 255 Index = 10 Left = 3975 TabIndex = 27 Top = 2490 Width = 1455 Begin VB.Label lbl Caption = "Importe máximo" Height = 255 Index = 7 Left = 3975 TabIndex = 25 Top = 2120 Width = 1455 Begin VB.Label lbl
386 Caption = "Documento final:" Height = 255 Index = 5 Left = 3975 TabIndex = 24 Top = 1753 Width = 1455 Begin VB.Label des BorderStyle = 1 Fixed Single Index = 3 Left = 3900 TabIndex = 23 Top = 1371 Width = 3765 Begin VB.Label lbl Caption = "Acreedor/Deudor final:" Height = 255 Index = 3 Left = 150 TabIndex = 22 Top = 1386 Width = 1905 Begin VB.Label des BorderStyle = 1 Fixed Single Index = 2 Left = 3900 TabIndex = 21 Top = 1004 Width = 3765 Begin VB.Label lbl Caption = "Cuenta final:" Height = 255 Index = 1 Left = 150 TabIndex = 20 Top = 652 Width = 1455 Begin VB.Label des BorderStyle = 1 Fixed Single Index = 1 Left = 3900 TabIndex = 19 Top = 637 Width = 3765 Begin VB.Label des BorderStyle = 1 Fixed Single Index = 0 Left = 3900 TabIndex = 17 Top = 270 Width = 3765 Begin VB.Label lbl Caption = "Fecha vto mínima:" Height = 255 Index = 8 Left = 150 TabIndex = 16 Top = 2490 Width = 1455 Begin VB.Label lbl Caption = "Importe mínimo:" Height = 255 Index = 6 Left = 150 TabIndex =
387 Top = 2120 Width = 1455 Begin VB.Label lbl Caption = "Cuenta inicial:" Height = 255 Index = 0 Left = 150 TabIndex = 14 Top = 285 Width = 1455 Begin VB.Label lbl Caption = "Documento inicial:" Height = 255 Index = 4 Left = 150 TabIndex = 13 Top = 1753 Width = 1455 Begin VB.Label lbl Caption = "Acreedor/Deudor inicial:" Height = 255 Index = 2 Left = 150 TabIndex = 12 Top = 1019 Width = 1905 Begin VB.Label lbl Caption = "Fecha vto mínima:" Height = 255 Index = 9 Left = 0 TabIndex = 26 Top = 0 Width = 1455 Attribute VB_Name = "frmseleccioncartera" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mcartera As cartera Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha) Set mauxiliar = Nothing Function Private Sub cmdaceptar_click() Dim acrdeu As String Dim strwhere As String Dim newitem As ListItem Dim rs As ADODB.Recordset frmapunte.listviewgestioncartera.listitems.clear strwhere = "Cartera.codigo_empresa = " & sempresa & " and Cartera.codigo_delegacion = " & sdelegacion & " " strwhere = strwhere & "and Cartera.tipo = " & IIf(lblTipoEfectos.Caption = "Cobro", "C", "P") & " "
388 strwhere = strwhere & "and Cartera.estado = P " If txt(0) <> "" Then Set mauxiliar = New Auxiliar acrdeu = mauxiliar.vbuscarcampo("acrdeu", "codigo", "codigo_empresa = " & sempresa & " and cuenta = " & txt(0) & "") Set mauxiliar = Nothing strwhere = strwhere & "and Cartera.codigo_personal >= " & acrdeu & " " des(0).caption = "" If txt(1) <> "" Then Set mauxiliar = New Auxiliar acrdeu = mauxiliar.vbuscarcampo("acrdeu", "codigo", "codigo_empresa = " & sempresa & " and cuenta = " & txt(1) & "") Set mauxiliar = Nothing strwhere = strwhere & "and Cartera.codigo_personal <= " & acrdeu & " " des(1).caption = "" If txt(2) <> "" Then strwhere = strwhere & "and Cartera.codigo_personal >= " & txt(2) & " " If txt(3) <> "" Then strwhere = strwhere & "and Cartera.codigo_personal <= " & txt(3) & " " If txt(4) <> "" Then strwhere = strwhere & "and Cartera.numero_documento >= " & txt(4) & " " If txt(5) <> "" Then strwhere = strwhere & "and Cartera.numero_documento <= " & txt(5) & " " If txt(6) <> "" Then strwhere = strwhere & "and Cartera.importe >= " & txt(6) & " " If txt(7) <> "" Then strwhere = strwhere & "and Cartera.importe <= " & txt(7) & " " If txt(8) <> "" Then strwhere = strwhere & "and Cartera.fecha_vto >= " & sdate(txt(8)) & " " If txt(9) <> "" Then strwhere = strwhere & "and Cartera.fecha_vto <= " & sdate(txt(9)) & " " strwhere = strwhere & " and Cartera.codigo_empresa = Acrdeu.codigo_empresa and Cartera.codigo_personal = Acrdeu.codigo and Cartera.tipo_acrdeu = Acrdeu.tipo " Set mauxiliar = New Auxiliar Set rs = mauxiliar.getlistext(cn, "Cartera, Acrdeu", "Cartera.codigo_empresa, Cartera.codigo_delegacion, Cartera.codigo_documento, Cartera.numero_documento, Cartera.fecha_vto, Cartera.estado, Cartera.importe, Cartera.concepto, Acrdeu.cuenta", strwhere) Set mauxiliar = Nothing While Not rs.eof Set newitem = frmapunte.listviewgestioncartera.listitems.add(, "K" & rs("codigo_documento") & rs("numero_documento") & rs("fecha_vto"), rs("estado")) newitem.subitems(1) = rs("codigo_documento") newitem.subitems(2) = rs("numero_documento") newitem.subitems(3) = ddate(rs("fecha_vto")) newitem.subitems(4) = rs("cuenta") newitem.subitems(5) = rs("importe") newitem.subitems(6) = rs("concepto") rs.movenext Wend Unload Me Sub Private Sub cmdcancelar_click() Unload Me Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub
389 Private Sub Form_Load() Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Select Case Index Case 0, 1: txt(index) = transformarcuenta(txt(index), icuenta) Case 4, 5: txt(index) = UCase(txt(Index)) Select Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim aux As String Dim msg As String msg = "" Set mauxiliar = New Auxiliar Select Case Index Case 0, 1: If txt(index) <> "" Then txt(index) = transformarcuenta(txt(index), icuenta) aux = mauxiliar.vbuscarcampo("cuentas", "descripcion", "codigo_empresa = " & sempresa & " AND cuenta = " & txt(index) & " and pases = S", "#") If aux = "#" Then msg = msgerror(1001) des(index) = aux des(index) = "" Case 2, 3: If txt(index) <> "" Then aux = mauxiliar.vbuscarcampo("personal", "nombre", "codigo_empresa = " & sempresa & " AND codigo = " & txt(index) & "", "#") If aux = "#" Then msg = msgerror(1001) des(index) = aux des(index) = "" Case 6, 7: If txt(index) <> "" Then txt(index) = Format(Replace(txt(Index), ".", ","), "0.00")
390 Sub If Not IsNumeric(txt(Index)) Then msg = msgerror(1004) Case 8, 9: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Select Set mauxiliar = Nothing If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Private Sub txt_dblclick(index As Integer) If txt(index).tag <> "" Then Call mostrarlupa(me) Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 121 And Shift = 0 And txt(index).tag <> "" Then Call mostrarlupa(me) F10 Sub
391 63. frmsituacion.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmsituacion Caption = "Balance de Situación" ClientHeight = 5730 ClientLeft = 60 ClientTop = 345 ClientWidth = 4755 LinkTopic = "frmsituacion" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 382 ScaleMode = 3 Pixel ScaleWidth = 317 Tag = "ToolbarSituacion" Begin MSComctlLib.ListView ListViewSituacion Height = 2865 Left = 0 TabIndex = 7 TabStop = 0 False Top = 450 Width = 4740 _ExtentX = 8361 _ExtentY = 5054 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 6 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "A/P" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Nivel 1" Object.Width = 6967 Property BeginProperty ColumnHeader(3) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 2 Text = "Nivel 2" Object.Width = Property BeginProperty ColumnHeader(4) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 3 Text = "Nivel 3" Object.Width = Property BeginProperty ColumnHeader(5) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 4 Text = "Título" Object.Width = Property BeginProperty ColumnHeader(6) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 5 Text = "Cuentas" Object.Width = Property Begin VB.Frame frmdatos Height = 2415 Left = 0 TabIndex = 8 Top = 3300 Width =
392 Begin VB.TextBox txt Index = 3 Left = 3150 TabIndex = 3 Top = 675 Width = 825 Begin VB.TextBox txt Index = 2 Left = 2250 TabIndex = 2 Top = 675 Width = 825 Begin VB.TextBox txt Index = 1 Left = 1320 TabIndex = 1 Top = 675 Width = 825 Begin VB.TextBox txt Index = 0 Left = 1320 TabIndex = 0 Top = 300 Width = 825 Begin VB.TextBox txt Index = 4 Left = 1320 TabIndex = 4 Top = 1050 Width = 3270 Begin VB.TextBox txt Height = 810 Index = 5 Left = 1320 MultiLine = -1 True ScrollBars = 2 Vertical TabIndex = 5 Top = 1440 Width = 3270 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Nivel:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 1 Left = 75 TabIndex = 12 Top = 675 Width = 660 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "A/P:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset =
393 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 0 Left = 75 TabIndex = 11 Top = 300 Width = 1080 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Título:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 255 Index = 2 Left = 75 TabIndex = 10 Top = 1050 Width = 660 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Cuentas:" Height = 255 Index = 3 Left = 75 TabIndex = 9 Top = 1425 Width = 1080 Begin MSComctlLib.ImageList ImageListSituacion Left = 75 Top = 5100 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarSituacion Align = 1 Align Top Height = 390 Left = 0 TabIndex = 6 Tag = "ToolbarSituacion" Top = 0 Width = 4755 _ExtentX = 8387 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Attribute VB_Name = "frmsituacion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim msituacion As Situacion Private Sub AyudarSituacion()
394 Sub Private Sub cancelardatos() txt(0) = "" txt(1) = "" txt(2) = "" txt(3) = "" txt(4) = "" txt(5) = "" txt(0).setfocus Sub Private Sub EliminarSituacion() Dim rpta As Integer Dim aux As String On Error GoTo EliminarSituacionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("situacion", "ap", "codigo_empresa = " & sempresa _ & " and ap = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3), "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar la entrada " & txt(4) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set msituacion = New Situacion msituacion.delete cn, sempresa, txt(0), txt(1), txt(2), txt(3) Set msituacion = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewSituacion.ListItems.Remove ListViewSituacion.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3)).index Call cancelardatos Exit Sub EliminarSituacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarSituacion() Dim filtro As String filtro = "codigo_empresa = " & sempresa & "" If txt(0) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "ap = " & txt(0) & "" If txt(1) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_1 = " & txt(1) If txt(2) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_2 = " & txt(2) If txt(3) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "nivel_3 = " & txt(3) If txt(4) <> "" Then
395 If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "titulo = " & txt(4) & "" If txt(5) <> "" Then If filtro <> "" Then filtro = filtro & " and " filtro = filtro & "cuentas = " & txt(5) & "" Call ListarSituacion(filtro) Sub Private Sub Form_Activate() If sempresa = "" Then MsgBox "No se ha especificado la empresa.", vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmsituacion = Forms(i) Next Call limatges16(me.imagelistsituacion) Set Me.ToolbarSituacion.ImageList = Me.ImageListSituacion Call cargarbotonera(me.toolbarsituacion) Call deshabilitarbotones(me.toolbarsituacion, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewSituacion For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewSituacion For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirSituacion() Sub
396 Private Sub InsertarSituacion() Dim i As Integer Dim aux As String Dim newitem As ListItem On Error GoTo InsertarSituacionError _ If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("situacion", "ap", "codigo_empresa = " & sempresa & " and ap = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3), "#") If aux = "#" Then Si no existe, lo inserto Set msituacion = New Situacion msituacion.insert cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), susuario Set msituacion = Nothing On Error Resume Next For i = 0 To 5 If txt(i) = Null Then txt(i) = "" Next Set newitem = ListViewSituacion.ListItems.Add(, "K" & txt(0) & txt(1) & txt(2) & txt(3), txt(0)) newitem.subitems(1) = txt(1) newitem.subitems(2) = txt(2) newitem.subitems(3) = txt(3) newitem.subitems(4) = txt(4) newitem.subitems(5) = txt(5) Call cancelardatos For i = 0 To 5 If txt(i) = Null Then txt(i) = "" Next MsgBox msgerror(1021), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub InsertarSituacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarSituacion(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem If strwhere = "" Then strwhere = "codigo_empresa = " & sempresa & "" Elimino los datos de la lista ListViewSituacion.ListItems.Clear Set msituacion = New Situacion Set rs = msituacion.getlist(cn, strwhere, "codigo_empresa, ap, nivel_1, nivel_2, nivel_3") Do Until rs.eof Set newitem = ListViewSituacion.ListItems.Add(, "K" & rs("ap") & rs("nivel_1") & rs("nivel_2") & rs("nivel_3"), rs("ap")) newitem.subitems(1) = Nz(rs("nivel_1"), "") newitem.subitems(2) = Nz(rs("nivel_2"), "") newitem.subitems(3) = Nz(rs("nivel_3"), "") newitem.subitems(4) = Nz(rs("titulo"), "") newitem.subitems(5) = Nz(rs("cuentas"), "") rs.movenext Loop
397 Set rs = Nothing Set msituacion = Nothing Sub Private Sub ListViewSituacion_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewSituacion.SelectedItem.Text Me.txt(1) = Me.ListViewSituacion.SelectedItem.SubItems(1) Me.txt(2) = Me.ListViewSituacion.SelectedItem.SubItems(2) Me.txt(3) = Me.ListViewSituacion.SelectedItem.SubItems(3) Call txt_lostfocus(0) Sub Private Sub ModificarSituacion() Dim i As Integer Dim aux As String On Error GoTo ModificarSituacionError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("situacion", "ap", "codigo_empresa = " & sempresa _ & " and ap = " & txt(0) & " and nivel_1 = " & txt(1) & " and nivel_2 = " & txt(2) _ & " and nivel_3 = " & txt(3), "#") If aux <> "#" Then Si existe, lo modifico Set msituacion = New Situacion msituacion.update cn, sempresa, txt(0), txt(1), txt(2), txt(3), txt(4), txt(5), susuario Set msituacion = Nothing On Error Resume Next For i = 0 To 5 If txt(i) = Null Then txt(i) = "" Next ListViewSituacion.ListItems(ListViewSituacion.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3)).index).subitems(4) = txt(4) ListViewSituacion.ListItems(ListViewSituacion.ListItems("K" & txt(0) & txt(1) & txt(2) & txt(3)).index).subitems(5) = txt(5) Call cancelardatos For i = 0 To 5 If txt(i) = Null Then txt(i) = "" Next MsgBox msgerror(1021), vbcritical, App.Title Set mauxiliar = Nothing Exit Sub ModificarSituacionError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarSituacion_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarSituacion Case "modificar": If validardatos Then Call ModificarSituacion Case "filtrar": Call FiltrarSituacion Case "lupa": Call mostrarlupa(me) Case "borrar": Call EliminarSituacion Case "listar": Call ListarSituacion Case "imprimir": Call ImprimirSituacion Case "ayudar": Call AyudarSituacion Select Sub
398 Private Sub txt_dblclick(index As Integer) If Me.ToolbarSituacion.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarSituacion.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) Dim rs As ADODB.Recordset If Index = 0 Or Index = 1 Or Index = 2 Or Index = 3 Then If txt(0) <> "" And txt(1) <> "" And txt(2) <> "" And txt(3) <> "" Then Set msituacion = New Situacion Set rs = msituacion.getlist(cn, "codigo_empresa = " & sempresa _ & " and ap = " & txt(0) & " and nivel_1 = " & txt(1) _ & " and nivel_2 = " & txt(2) & " and nivel_3 = " & txt(3)) If Not rs.eof Then txt(4) = Nz(rs("titulo"), "") txt(5) = Nz(rs("cuentas"), "") Set rs = Nothing Set msituacion = Nothing Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Cancel = False Select Case Index Case 0: If txt(index) <> "" Then txt(index) = UCase(txt(Index)) If txt(index) <> "A" And txt(index) <> "P" Then msg = msgerror(1023) Case 1, 2, 3: If txt(index) <> "" Then If Not IsNumeric(txt(Index)) Then msg = msgerror(1024) txt(index) = Replace(txt(Index), ".", ",") If txt(index) <> Int(txt(Index)) Then msg = msgerror(1024) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub Private Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 5 Select Case i Case 0, 1, 2, 3, 4: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select
399 Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title For i = 0 To 5 Select Case i Case 1, 2, 3: If txt(i) = "" Then txt(i) = 0 txt(i) = Replace(txt(i), ",", ".") Select Next Function
400 64. frmsplash.frm VERSION 5.00 Begin VB.Form frmsplash BorderStyle = 3 Fixed Dialog ClientHeight = 4710 ClientLeft = 45 ClientTop = 45 ClientWidth = 7455 ControlBox = 0 False LinkTopic = "frmsplash" MaxButton = 0 False MinButton = 0 False ScaleHeight = 314 ScaleMode = 3 Pixel ScaleWidth = 497 ShowInTaskbar = 0 False Visible = 0 False Begin VB.Frame framainframe Height = 4590 Left = 45 TabIndex = 0 Top = -15 Width = 7380 Begin VB.PictureBox piclogo Height = 2385 Left = 510 Picture = "frmsplash.frx":0000 ScaleHeight = 2325 ScaleWidth = 1755 TabIndex = 2 Top = 855 Width = 1815 Begin VB.Label lbllicenseto Alignment = 1 Right Justify Caption = "LicenciaA" Height = 255 Left = 270 TabIndex = 1 Tag = "LicenciaA" Top = 300 Width = 6855 Begin VB.Label lblproductname AutoSize = -1 True Caption = "Conta-Pyme" BeginProperty Font Name = "Arial" Size = Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 675 Left = 2670 TabIndex = 9 Tag = "Producto" Top = 1200 Width = 3420 Begin VB.Label lblcompanyproduct AutoSize = -1 True Caption = "Universitat de Girona" BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False
401 Property Height = 435 Left = 2505 TabIndex = 8 Tag = "ProductoOrganización" Top = 765 Width = 3690 Begin VB.Label lblplatform Alignment = 1 Right Justify AutoSize = -1 True Caption = "Windows 98" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 360 Left = 5295 TabIndex = 7 Tag = "Plataforma" Top = 2400 Width = 1710 Begin VB.Label lblversion Alignment = 1 Right Justify AutoSize = -1 True Caption = "Versión 1.0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property Height = 300 Left = 5625 TabIndex = 6 Tag = "Versión" Top = 2760 Width = 1380 Begin VB.Label lblwarning Caption = "Advertencia" Height = 195 Left = 300 TabIndex = 3 Tag = "Advertencia" Top = 3720 Width = 6855 Begin VB.Label lblcompany Caption = "Organización" Height = 255 Left = 4710 TabIndex = 5 Tag = "Organización" Top = 3330 Width = 2415 Begin VB.Label lblcopyright Caption = "Copyright" Height = 255 Left = 4710 TabIndex = 4 Tag = "Copyright" Top = 3120 Width =
402 Attribute VB_Name = "frmsplash" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub Form_Load() lblversion.caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision lblproductname.caption = App.Title Sub
403 65. frmsumassaldos.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{ C }#5.2#0"; "Crystl32.OCX" Begin VB.Form frmsumassaldos Caption = "Balance de sumas y saldos" ClientHeight = 4995 ClientLeft = 60 ClientTop = 450 ClientWidth = 4470 LinkTopic = "frmsumassaldos" MaxButton = 0 False MDIChild = -1 True ScaleHeight = 333 ScaleMode = 3 Pixel ScaleWidth = 298 Tag = "ToolbarSumasSaldos" Begin Crystal.CrystalReport informe Left = 120 Top = 6840 _ExtentX = 741 _ExtentY = 741 _Version = WindowState = 2 PrintFileLinesPerPage= 60 Begin VB.Frame fradatos Height = 4635 Left = 0 TabIndex = 5 Top = 360 Width = 4455 Begin VB.CheckBox chkmovimientos Caption = "Incluir cuentas sin movimientos" Height = 255 Left = 120 TabIndex = 26 Top = 1875 Width = 3135 Begin VB.Frame franiveles Caption = "Niveles de balance" Height = 1455 Left = 120 TabIndex = 13 Top = 2325 Width = 4215 Begin VB.CheckBox chknivel Caption = "Nivel 12" Height = 255 Index = 11 Left = 3120 TabIndex = 25 Top = 1080 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 11" Height = 255 Index = 10 Left = 3120 TabIndex = 24 Top = 720 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 10" Height = 255 Index = 9 Left = 3120 TabIndex = 23 Top = 360 Width =
404 Begin VB.CheckBox chknivel Caption = "Nivel 9" Height = 255 Index = 8 Left = 2160 TabIndex = 22 Top = 1080 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 8" Height = 255 Index = 7 Left = 2160 TabIndex = 21 Top = 720 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 7" Height = 255 Index = 6 Left = 2160 TabIndex = 20 Top = 360 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 6" Height = 255 Index = 5 Left = 1200 TabIndex = 19 Top = 1080 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 5" Height = 255 Index = 4 Left = 1200 TabIndex = 18 Top = 720 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 4" Height = 255 Index = 3 Left = 1200 TabIndex = 17 Top = 360 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 3" Height = 255 Index = 2 Left = 240 TabIndex = 16 Top = 1080 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 2" Height = 255 Index = 1 Left = 240 TabIndex = 15 Top = 720 Width = 975 Begin VB.CheckBox chknivel Caption = "Nivel 1" Height = 255 Index =
405 Left = 240 TabIndex = 14 Top = 360 Width = 975 Begin VB.TextBox txt Index = 5 Left = 1440 Locked = -1 True TabIndex = 11 Tag = "DELEGACIONES.codigo_delegacion" Top = 1425 Width = 1335 Begin MSComctlLib.ProgressBar barrainformes Height = 375 Left = 120 TabIndex = 9 Top = 4050 Width = 4215 _ExtentX = 7435 _ExtentY = 661 _Version = Appearance = 1 Min = 1e-4 Scrolling = 1 Begin VB.TextBox txt Index = 3 Left = 1440 TabIndex = 3 Top = 1080 Width = 1335 Begin VB.TextBox txt Index = 4 Left = 3000 TabIndex = 4 Top = 1080 Width = 1335 Begin VB.TextBox txt Index = 1 Left = 1440 TabIndex = 1 Tag = "CUENTAS.cuenta" Top = 720 Width = 1335 Begin VB.TextBox txt Index = 0 Left = 1440 TabIndex = 0 Tag = "DIARIOS.codigo_diario" Top = 360 Width = 1335 Begin VB.TextBox txt Index = 2 Left = 3000 TabIndex = 2 Tag = "CUENTAS.cuenta" Top = 720 Width = 1335 Begin VB.Label lbl Caption = "Delegación:" Height = 255 Index = 4 Left =
406 TabIndex = 12 Top = 1425 Width = 1095 Begin VB.Label lbl Caption = "Fecha:" Height = 255 Index = 2 Left = 120 TabIndex = 8 Top = 1080 Width = 1455 Begin VB.Label lbl Caption = "Cuenta:" Height = 255 Index = 1 Left = 120 TabIndex = 7 Top = 720 Width = 1455 Begin VB.Label lbl Caption = "Diario:" Height = 255 Index = 0 Left = 120 TabIndex = 6 Top = 360 Width = 1455 Begin MSComctlLib.Toolbar ToolbarSumasSaldos Align = 1 Align Top Height = 390 Left = 0 TabIndex = 10 Tag = "ToolbarCuentas" Top = 0 Width = 4470 _ExtentX = 7885 _ExtentY = 688 ButtonWidth = 609 ButtonHeight = 582 _Version = Begin MSComctlLib.ImageList ImageListSumasSaldos Left = 600 Top = 6840 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Attribute VB_Name = "frmsumassaldos" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim minformes As Informes Dim mapuntes As Apuntes Dim mcuentas As cuentas Dim mauxiliar As Auxiliar Private Function sdate(fecha As Variant) As String Set mauxiliar = New Auxiliar sdate = mauxiliar.sdate(fecha) Set mauxiliar = Nothing Function Private Function ddate(fecha As Variant) As String Set mauxiliar = New Auxiliar ddate = mauxiliar.ddate(fecha)
407 Set mauxiliar = Nothing Function Private Sub ayudarsumassaldos() Sub Private Sub cancelardatos() txt(0) = "": txt(1) = "": txt(2) = "": txt(3) = "": txt(4) = "": txt(5) = "" barrainformes.min = 0: barrainformes.value = 0 txt(0).setfocus Sub Private Sub chknivel_click(index As Integer) Dim i As Integer Dim trobat As Boolean If Not chknivel(index) Then i = 0 trobat = False While i < 12 And Not trobat If chknivel(i) Then trobat = True i = i + 1 Wend If Not trobat Then chknivel(index) = 1 Sub Private Sub Form_Activate() If sempresa = "" Or sdelegacion = "" Or iejercicio = 0 Then MsgBox msgerror(1040), vbcritical, App.Title Unload Me Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmsumassaldos = Forms(i) Next Call limatges16(me.imagelistsumassaldos) Set Me.ToolbarSumasSaldos.ImageList = Me.ImageListSumasSaldos Call cargarbotonera(me.toolbarsumassaldos) Call deshabilitarbotones(me.toolbarsumassaldos, "insertar", "modificar", "filtrar", "borrar", "listar") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Me.chkNivel(iCuenta - 1) = 1 For i = icuenta To 11 Me.chkNivel(i).Enabled = 0 Next If sempresa <> sdelegacion Then txt(5) = sdelegacion txt(5).enabled = False Sub
408 Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub imprimir() Dim i As Integer Dim periodo As String Dim empresa As String Dim delegación As String Dim nivel As Integer nivel = 0 While chknivel(nivel) = 0 nivel = nivel + 1 Wend nivel = nivel + 1 periodo = "del " & IIf(txt(3) <> "", txt(3), ddate(sinicioejercicio)) & " al " & IIf(txt(4) <> "", txt(4), ddate(sfinalejercicio)) Set mauxiliar = New Auxiliar empresa = sempresa & " " & mauxiliar.vbuscarcampo("empresas", "nombre", "codigo_empresa = " & sempresa & "", "") & IIf(txt(5) <> "", " // Delegaciones: " & txt(5), "") Set mauxiliar = Nothing Set minformes = New Informes Call minformes.init(cnt.connectionstring, 1, informe) Call minformes.configure("sumassaldos.rpt", "Balance de sumas y saldos", SCREENMODE) Call minformes.rptformulas("periodo=" & periodo & "", "niveles = " & nivel, "empresa=" & empresa & "") minformes.obj.sqlquery = "SELECT * FROM SumasSaldos ORDER BY cuenta" Call minformes.execute Set minformes = Nothing Sub Private Sub imprimirsumassaldos() Call obtenercuentasbalance Call obtenersaldoscuentas Call obtenersaldosniveles Call imprimir Sub Private Sub obtenercuentasbalance() Dim i As Integer Dim rs As ADODB.Recordset Dim rst As ADODB.Recordset Dim strwhere1 As String Dim strwhere2 As String Dim cuenta_ini As String Dim cuenta_fin As String Dim strwherereport As String cnt.begintrans cuenta_ini = IIf(txt(1) <> "", txt(1), String(iCuenta, "0")) cuenta_fin = IIf(txt(2) <> "", txt(2), String(iCuenta, "9")) strwhere1 = "codigo_empresa = " & sempresa & " " strwhere2 = "" For i = 0 To
409 If chknivel(i) Or i = icuenta - 1 Then strwhere2 = strwhere2 & "OR (cuenta >= " & Left(cuenta_ini, i + 1) & " AND cuenta <= " & Left(cuenta_fin, i + 1) & " AND Nivel = " & i + 1 & ") " Next strwherereport = strwhere1 & IIf(strWhere2 = "", "", "AND (" & Mid(strWhere2, 4) & ")") cnt.execute "DELETE FROM SumasSaldos" Set rst = New ADODB.Recordset rst.open "SELECT * FROM SumasSaldos", cnt, adopenstatic, adlockoptimistic Set mcuentas = New cuentas Set rs = mcuentas.getlist(cn, strwherereport, "cuenta") Set mcuentas = Nothing If Not rs.eof Then Me.barraInformes.Min = 0 Me.barraInformes.Value = 0 Me.barraInformes.max = rs.recordcount While Not rs.eof rst.addnew rst("cuenta") = rs("cuenta") rst("debe") = 0 rst("haber") = 0 rst("saldo_anterior") = 0 rst("titulo") = rs("descripcion") rst("nivel") = rs("nivel") rst("mostrar") = "N" rst.update Me.barraInformes.Value = Me.barraInformes.Value + 1 rs.movenext Wend rst.close Set rst = Nothing cnt.committrans Sub Private Sub obtenersaldoscuentas() Dim rs As ADODB.Recordset Dim rst As ADODB.Recordset Dim strwheresaldo As String Dim strwheresaldoanterior As String cnt.begintrans Call obtenerwheresaldoscuentas(strwheresaldo, strwheresaldoanterior) Obtengo el saldo anterior de las cuentas Set mauxiliar = New Auxiliar Set rs = mauxiliar.getlistext(cn, "Apuntes", "cuenta, SUM(debe-haber) as saldo_anterior", strwheresaldoanterior, "cuenta",, "cuenta") Set mapuntes = Nothing Set rst = New ADODB.Recordset Guardo el saldo anterior While Not rs.eof rst.open "SELECT * FROM SumasSaldos WHERE cuenta = " & rs("cuenta") & "", cnt, adopenstatic, adlockoptimistic If Not rst.eof Then rst("saldo_anterior") = rs("saldo_anterior") rst.update rst.close rs.movenext Wend Obtengo el saldo del periodo Set mauxiliar = New Auxiliar Set rs = mauxiliar.getlistext(cn, "Apuntes", "cuenta, SUM(debe) as debe, SUM(haber) as haber", strwheresaldo, "cuenta",, "cuenta")
410 Set mauxiliar = Nothing Guardo el saldo del periodo While Not rs.eof rst.open "SELECT * FROM SumasSaldos WHERE cuenta = " & rs("cuenta") & "", cnt, adopenstatic, adlockoptimistic If Not rst.eof Then rst("debe") = rs("debe") rst("haber") = rs("haber") rst.update rst.close rs.movenext Wend Set rst = Nothing cnt.committrans Elimino las cuentas sin movimientos If chkmovimientos = 0 Then cnt.execute "DELETE FROM SumasSaldos WHERE saldo_anterior = 0 and debe = 0 and haber = 0 and nivel = " & icuenta Sub Private Sub obtenersaldosniveles() Dim i As Integer Dim rst As ADODB.Recordset Dim rsu As ADODB.Recordset Set rst = New ADODB.Recordset Set rsu = New ADODB.Recordset cnt.begintrans For i = icuenta - 1 To 1 Step -1 If chknivel(i - 1) Then rst.open "SELECT LEFT(cuenta," & i & ") as cuenta, SUM(saldo_anterior) as saldo_anterior, SUM(debe) as debe, SUM(haber) as haber FROM SumasSaldos WHERE (saldo_anterior <> 0 OR debe <> 0 or haber <> 0) AND Nivel = " & icuenta & " GROUP BY LEFT(cuenta," & i & ")", cnt, adopenstatic, adlockoptimistic While Not rst.eof rsu.open "SELECT * FROM SumasSaldos WHERE cuenta = " & rst("cuenta") & "", cnt, adopenstatic, adlockoptimistic While Not rsu.eof rsu("saldo_anterior") = rst("saldo_anterior") rsu("debe") = rst("debe") rsu("haber") = rst("haber") rsu("mostrar") = "S" rsu.update rsu.movenext Wend rsu.close rst.movenext Wend rst.close Next Set rst = Nothing Set rsu = Nothing cnt.committrans cnt.begintrans Elimino las cuentas sin movimientos If chknivel(icuenta - 1) = 0 Then cnt.execute "DELETE FROM SumasSaldos WHERE nivel = " & icuenta If chkmovimientos = 0 Then cnt.execute "DELETE FROM SumasSaldos WHERE nivel <> " & icuenta & " and mostrar = N" cnt.committrans
411 Sub Private Sub obtenerwheresaldoscuentas(strwheresaldo As String, strwheresaldoanterior As String) Dim aux As String strwheresaldo = "codigo_empresa = " & sempresa & " " If txt(5) <> "" Then If sempresa <> sdelegacion Then strwheresaldo = strwheresaldo & " and codigo_delegacion = " & sdelegacion & " " aux = "" & txt(5) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwheresaldo = strwheresaldo & "and codigo_delegacion in (" & aux & ") " If txt(0) <> "" Then aux = "" & txt(0) & "" aux = Replace(aux, " ", "") aux = Replace(aux, ",", ",") strwheresaldo = strwheresaldo & "and codigo_diario in (" & aux & ") " " " If txt(1) <> "" Then strwheresaldo = strwheresaldo & "and cuenta >= " & txt(1) & " If txt(2) <> "" Then strwheresaldo = strwheresaldo & "and cuenta <= " & txt(2) & " strwheresaldoanterior = strwheresaldo If txt(3) <> "" Then strwheresaldo = strwheresaldo & "and fecha_apunte >= " & sdate(txt(3)) & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sdate(txt(3)) & " " strwheresaldo = strwheresaldo & "and fecha_apunte >= " & sinicioejercicio & " " strwheresaldoanterior = strwheresaldoanterior & "and fecha_apunte < " & sinicioejercicio & " " If txt(4) <> "" Then strwheresaldo = strwheresaldo & "and fecha_apunte <= " & sdate(txt(4)) & " " strwheresaldo = strwheresaldo & "and fecha_apunte <= " & sfinalejercicio & " " Sub Private Sub ToolbarSumasSaldos_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "lupa": Call mostrarlupa(me) Case "imprimir": Call imprimirsumassaldos Case "ayudar": Call ayudarsumassaldos Select Sub Private Sub txt_dblclick(index As Integer) If Me.ToolbarSumasSaldos.Buttons(7).Enabled Then Call mostrarlupa(me) Sub Private Sub txt_gotfocus(index As Integer) Me.ToolbarSumasSaldos.Buttons(7).Enabled = (Me.ActiveControl.tag <> "") Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_keydown(index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = 121 And Shift = 0 And Me.ToolbarSumasSaldos.Buttons(7).Enabled Then Call mostrarlupa(me) F10 Sub Private Sub txt_lostfocus(index As Integer) Select Case Index Case 1, 2: txt(index) = transformarcuenta(txt(index), icuenta)
412 Select Sub Private Sub txt_validate(index As Integer, Cancel As Boolean) Dim msg As String msg = "" Select Case Index Case 3, 4: If txt(index) <> "" Then If Not IsDate(txt(Index)) Then msg = msgerror(1004) Select If msg <> "" Then MsgBox msg, vbcritical, App.Title Cancel = True Sub
413 66. frmusuarios.frm VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmusuarios Caption = "Usuarios" ClientHeight = 3960 ClientLeft = 6585 ClientTop = 5310 ClientWidth = 4920 LinkTopic = "frmusuarios" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 264 ScaleMode = 3 Pixel ScaleWidth = 328 Begin MSComctlLib.ImageList ImageListUsuarios Left = 0 Top = 4080 _ExtentX = 1005 _ExtentY = 1005 BackColor = MaskColor = _Version = Begin MSComctlLib.Toolbar ToolbarUsuarios Align = 1 Align Top Height = 330 Left = 0 Negotiate = -1 True TabIndex = 1 Top = 0 Width = 4920 _ExtentX = 8678 _ExtentY = 582 ButtonWidth = 609 ButtonHeight = 582 Style = 1 _Version = Begin MSComctlLib.ListView ListViewUsuarios Height = 2415 Left = 0 TabIndex = 0 TabStop = 0 False Top = 375 Width = 4950 _ExtentX = 8731 _ExtentY = 4260 View = 3 LabelEdit = 1 LabelWrap = -1 True HideSelection = -1 True FullRowSelect = -1 True GridLines = -1 True _Version = ForeColor = BackColor = Appearance = 0 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F B-11D1-B16A-00C0F } Text = "Código" Object.Width = 1764 Property BeginProperty ColumnHeader(2) {BDD1F B-11D1-B16A-00C0F } SubItemIndex = 1 Text = "Contraseña" Object.Width = 6967 Property Begin VB.Frame frmdatos Height = 1095 Left =
414 TabIndex = 2 Top = 2850 Width = 4950 Begin VB.TextBox txt BackColor = &H00FFFFFF& Index = 1 Left = 1320 TabIndex = 6 Top = 720 Width = 3495 Begin VB.TextBox txt BackColor = &H00FFFFFF& Index = 0 Left = 1320 TabIndex = 5 Top = 360 Width = 975 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Contraseña:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 1 Left = 120 TabIndex = 4 Top = 720 Width = 1095 Begin VB.Label lbl Appearance = 0 Flat BackColor = &H & BackStyle = 0 Transparent Caption = "Código:" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 False Italic = 0 False Strikethrough = 0 False Property ForeColor = &H & Height = 255 Index = 0 Left = 120 TabIndex = 3 Top = 360 Width = 975 Attribute VB_Name = "frmusuarios" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mauxiliar As Auxiliar Dim musuarios As Usuarios
415 Private Sub AyudarUsuarios() Sub Private Sub cancelardatos() txt(0) = "": txt(1) = "" txt(0).setfocus Sub Private Sub EliminarUsuario() Dim rpta As Integer Dim aux As String On Error GoTo EliminarUsuarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("usuarios", "codigo_usuario", "codigo_usuario = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then rpta = MsgBox(" Desea eliminar el usuario " & txt(0) & "?", vbquestion + vbyesno, App.Title) If rpta = vbyes Then Set musuarios = New Usuarios musuarios.delete cn, txt(0), False Set musuarios = Nothing En el caso de que la lista no este visible, ignoro el error On Error Resume Next ListViewUsuarios.ListItems.Remove ListViewUsuarios.ListItems("K" & txt(0)).index Call cancelardatos Exit Sub EliminarUsuarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub FiltrarUsuario() Dim filtro As String filtro = "" If txt(0) <> "" Then If filtro = "" Then filtro = filtro & "codigo_usuario = " & txt(0) & "" filtro = filtro & " and codigo_usuario = " & txt(0) & "" If txt(1) <> "" Then If filtro = "" Then filtro = filtro & "contraseña = " & txt(1) & "" filtro = filtro & " and contraseña = " & txt(1) & "" Call ListarUsuarios(filtro) Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmusuarios = Forms(i) Next
416 Call limatges16(me.imagelistusuarios) Set Me.ToolbarUsuarios.ImageList = Me.ImageListUsuarios Call cargarbotonera(me.toolbarusuarios) Call deshabilitarbotones(me.toolbarusuarios, "lupa", "imprimir") Dim fini As String fini = App.Path & "\Contabilidad.ini" Configuración del formulario Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Configuración de la lista With Me.ListViewUsuarios For i = 1 To.ColumnHeaders.Count.ColumnHeaders(i).Width = sgetini(fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width) Next With Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height With Me.ListViewUsuarios For i = 1 To.ColumnHeaders.Count writeini fini, Me.Name, "Grid_C" & Format(i, "00"),.ColumnHeaders(i).Width Next With Sub Private Sub ImprimirUsuarios() Sub Private Sub InsertarUsuario() Dim i As Integer Dim newitem As ListItem Dim aux As String On Error GoTo InsertarUsuarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("usuarios", "codigo_usuario", "codigo_usuario = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux = "#" Then Si no existe, lo inserto Set musuarios = New Usuarios musuarios.insert cn, sempresa, sdelegacion, txt(0), txt(1), susuario, False Set musuarios = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next Set newitem = ListViewUsuarios.ListItems.Add(, "K" & txt(0), txt(0)) newitem.subitems(1) = txt(1)
417 Call cancelardatos For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title Exit Sub InsertarUsuarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ListarUsuarios(Optional strwhere As String) Dim rs As ADODB.Recordset Dim newitem As ListItem Elimino los datos de la lista ListViewUsuarios.ListItems.Clear Set musuarios = New Usuarios Set rs = musuarios.getlist(cn,, "codigo_usuario") Do Until rs.eof Set newitem = ListViewUsuarios.ListItems.Add(, "K" & rs("codigo_usuario"), rs("codigo_usuario")) newitem.subitems(1) = Nz(rs("contraseña"), "") rs.movenext Loop Set rs = Nothing Set musuarios = Nothing Sub Private Sub ListViewUsuarios_DblClick() On Error Resume Next Me.txt(0) = Me.ListViewUsuarios.SelectedItem.Text Call txt_lostfocus(0) Sub Private Sub ModificarUsuario() Dim i As Integer Dim aux As String On Error GoTo ModificarUsuarioError If txt(0) <> "" Then Set mauxiliar = New Auxiliar aux = mauxiliar.vbuscarcampo("usuarios", "codigo_usuario", "codigo_usuario = " & txt(0) & "", "#") Set mauxiliar = Nothing If aux <> "#" Then Si existe, lo modifico Set musuarios = New Usuarios musuarios.update cn, txt(0), txt(1), susuario Set musuarios = Nothing On Error Resume Next For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next ListViewUsuarios.ListItems(ListViewUsuarios.ListItems("K" & txt(0)).index).subitems(1) = txt(1) Call cancelardatos For i = 0 To 1 If txt(i) = "null" Then txt(i) = "" Next MsgBox msgerror(9999), vbcritical, App.Title
418 Exit Sub ModificarUsuarioError: MsgBox Err.Number & " - " & Err.Description, vbcritical, App.Title Sub Private Sub ToolbarUsuarios_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "cancelar": Call cancelardatos Case "insertar": If validardatos Then Call InsertarUsuario Case "modificar": If validardatos Then Call ModificarUsuario Case "filtrar": Call FiltrarUsuario Case "borrar": Call EliminarUsuario Case "listar": Call ListarUsuarios Case "imprimir": Call ImprimirUsuarios Case "ayudar": Call AyudarUsuarios Select Sub Private Sub txt_gotfocus(index As Integer) Me.txt(Index).SelStart = 0: Me.txt(Index).SelLength = Len(txt(Index)) Sub Private Sub txt_lostfocus(index As Integer) If Index = 0 Then If txt(0) <> "" Then Set mauxiliar = New Auxiliar txt(1) = mauxiliar.vbuscarcampo("usuarios", "contraseña", "codigo_usuario = " & txt(0) & "", "") Set mauxiliar = Nothing Sub Function validardatos() As Boolean Dim msg As String Dim i As Integer validardatos = True For i = 0 To 1 Select Case i Case 0, 1: If txt(i) = "" Then msg = msgerror(1000) txt(i).setfocus Exit For Select Next If msg <> "" Then validardatos = False MsgBox msg, vbcritical, App.Title Function
419 67. frmusuariosdelegacions.frm VERSION 5.00 Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL" Begin VB.Form frmusuariosdelegaciones Caption = "Grupos de usuarios" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 5565 LinkTopic = "frmusuariosdelegaciones" MaxButton = 0 False MDIChild = -1 True MinButton = 0 False ScaleHeight = 206 ScaleMode = 3 Pixel ScaleWidth = 371 Begin VB.CommandButton btndescartartodos Caption = "<<" Height = 315 Left = 2325 TabIndex = 9 Top = 2550 Width = 915 Begin VB.CommandButton btnañadirtodos Caption = ">>" Height = 315 Left = 2325 TabIndex = 8 Top = 1350 Width = 915 Begin VB.ListBox lstpermitidos Appearance = 0 Flat Height = 1785 Left = 3300 TabIndex = 7 Top = 1200 Width = 2190 Begin VB.ListBox lstdisponibles Appearance = 0 Flat Height = 1785 Left = 75 TabIndex = 6 Top = 1200 Width = 2190 Begin VB.CommandButton btndescartar Caption = "<" Height = 315 Left = 2325 TabIndex = 5 Top = 2175 Width = 915 Begin VB.CommandButton btnañadir Caption = ">" Height = 315 Left = 2325 TabIndex = 4 Top = 1725 Width = 915 Begin MSForms.ComboBox cmbdelegaciones Height = 315 Left = 2850 TabIndex = 11 Top = 450 Width = 2640 VariousPropertyBits= DisplayStyle = 3 Size = "4657;556"
420 MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin MSForms.ComboBox cmbempresas Height = 315 Left = 75 TabIndex = 1 Top = 450 Width = 2640 VariousPropertyBits= DisplayStyle = 3 Size = "4657;556" MatchEntry = 1 ShowDropButtonWhen= 2 FontHeight = 165 FontCharSet = 0 FontPitchAndFamily= 2 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Delegación:" Height = 240 Index = 3 Left = 2850 TabIndex = 10 Top = 150 Width = 1065 Begin VB.Label lbl Alignment = 2 Center BackColor = &H & BackStyle = 0 Transparent Caption = "Usuarios con acceso" Height = 240 Index = 2 Left = 3300 TabIndex = 3 Top = 900 Width = 2190 Begin VB.Label lbl Alignment = 2 Center BackColor = &H & BackStyle = 0 Transparent Caption = "Usuarios disponibles" Height = 240 Index = 1 Left = 75 TabIndex = 2 Top = 900 Width = 2190 Begin VB.Label lbl BackStyle = 0 Transparent Caption = "Empresa:" Height = 240 Index = 0 Left = 75 TabIndex = 0 Top = 150 Width = 1065 Attribute VB_Name = "frmusuariosdelegaciones" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim musuariosdelegaciones As UsuariosDelegaciones Private Sub btnañadir_click() Call lstdisponibles_dblclick
421 Sub Private Sub btnañadirtodos_click() Dim i As Integer For i = 1 To Me.lstDisponibles.ListCount Me.lstDisponibles.Selected(Me.lstDisponibles.ListCount - 1) = True Call lstdisponibles_dblclick Me.lstDisponibles.Refresh Next Sub Private Sub btndescartar_click() Call lstgrupo_dblclick Sub Private Sub btndescartartodos_click() Dim i As Integer For i = 1 To Me.lstPermitidos.ListCount Me.lstPermitidos.Selected(Me.lstPermitidos.ListCount - 1) = True Call lstgrupo_dblclick Me.lstPermitidos.Refresh Next Sub Private Sub cmbdelegaciones_click() Dim rs As ADODB.Recordset Dim strwhere As String strwhere = "codigo_empresa = " & Me.cmbEmpresas & " AND codigo_delegacion = " & Me.cmbDelegaciones & "" Elimino los datos de las listas Me.lstDisponibles.Clear Me.lstPermitidos.Clear Set musuariosdelegaciones = New UsuariosDelegaciones Set rs = musuariosdelegaciones.getlist(cn, strwhere) Do Until rs.eof If rs("activo") Then Me.lstPermitidos.AddItem rs("codigo_usuario") Me.lstDisponibles.AddItem rs("codigo_usuario") rs.movenext Loop Set rs = Nothing Set musuariosdelegaciones = Nothing Sub Private Sub cmbempresas_click() Call cargarcombodelegaciones(me.cmbdelegaciones, Me.cmbEmpresas) Sub Private Sub Form_Load() Dim i As Integer Dim fini As String For i = 0 To Forms.Count - 1 If UCase(Forms(i).Name) = UCase(Me.Name) Then Set frmusuariosdelegaciones = Forms(i) Next Call cargarcomboempresas(me.cmbempresas) fini = App.Path & "\Contabilidad.ini" Me.Left = sgetini(fini, Me.Name, "Left", Me.Left) Me.Top = sgetini(fini, Me.Name, "Top", Me.Top) Me.Width = sgetini(fini, Me.Name, "Width", Me.ScaleWidth) Me.Height = sgetini(fini, Me.Name, "Height", Me.ScaleHeight) Sub
422 Private Sub Form_Unload(Cancel As Integer) Dim fini As String fini = App.Path & "\Contabilidad.ini" If Me.WindowState <> vbminimized Then writeini fini, Me.Name, "Left", Me.Left writeini fini, Me.Name, "Top", Me.Top writeini fini, Me.Name, "Width", Me.Width writeini fini, Me.Name, "Height", Me.Height Sub Private Sub lstdisponibles_dblclick() If Me.lstDisponibles.ListIndex >= 0 Then Set musuariosdelegaciones = New UsuariosDelegaciones Call musuariosdelegaciones.update(cn, Me.lstDisponibles, Me.cmbEmpresas, Me.cmbDelegaciones, True, susuario) Me.lstPermitidos.AddItem Me.lstDisponibles.Text Me.lstDisponibles.RemoveItem Me.lstDisponibles.ListIndex Set musuariosdelegaciones = Nothing Sub Private Sub lstgrupo_dblclick() If Me.lstPermitidos.ListIndex >= 0 Then Set musuariosdelegaciones = New UsuariosDelegaciones Call musuariosdelegaciones.update(cn, Me.lstPermitidos, Me.cmbEmpresas, Me.cmbDelegaciones, False, susuario) Me.lstDisponibles.AddItem Me.lstPermitidos.Text Me.lstPermitidos.RemoveItem Me.lstPermitidos.ListIndex Set musuariosdelegaciones = Nothing Sub
423 68. Api.bas Attribute VB_Name = "API" Option Explicit Public Const ICC_LISTVIEW_CLASSES As Long = &H1 Public Const LVM_FIRST = &H1000 Public Const LVM_GETHEADER = (LVM_FIRST + 31) Public Type NMHDR hwndfrom As Long idfrom As Long code As Long Type Public Type HD_ITEM mask As Long cxy As Long psztext As String hbm As Long cchtextmax As Long fmt As Long lparam As Long iimage As Long iorder As Long Type Public Type NMHEADER hdr As NMHDR iitem As Long ibutton As Long hbm As Long HDI As HD_ITEM Type Public Type POINTAPI X As Long Y As Long Type Public Type HD_HITTESTINFO pt As POINTAPI flags As Long iitem As Long Type Public Type taginitcommoncontrolsex dwsize As Long dwicc As Long Type HitTest positions Public Const HHT_NOWHERE = &H1 Public Const HHT_ONHEADER = &H2 Public Const HHT_ONDIVIDER = &H4 Public Const HHT_ONDIVOPEN = &H8 Public Const HHT_ABOVE = &H100 Public Const HHT_BELOW = &H200 Public Const HHT_TORIGHT = &H400 Public Const HHT_TOLEFT = &H800 header class ids Public Const HEADER32_CLASS Public Const HEADER_CLASS header info Public Const HDI_WIDTH Public Const HDI_HEIGHT Public Const HDI_TEXT Public Const HDI_FORMAT Public Const HDI_LPARAM Public Const HDI_BITMAP Public Const HDI_IMAGE Public Const HDI_DI_SETITEM As String = "SysHeader32" As String = "SysHeader" As Long = &H1 As Long = HDI_WIDTH As Long = &H2 As Long = &H4 As Long = &H8 As Long = &H10 As Long = &H20 As Long = &H
424 Public Const HDI_ORDER As Long = &H80 header formats Public Const HDF_LEFT As Long = 0 Public Const HDF_RIGHT As Long = 1 Public Const HDF_CENTER As Long = 2 Public Const HDF_JUSTIFYMASK As Long = &H3 Public Const HDF_RTLREADING As Long = 4 Public Const HDF_IMAGE As Long = &H800 Public Const HDF_OWNERDRAW As Long = &H8000& Public Const HDF_STRING As Long = &H4000 Public Const HDF_BITMAP As Long = &H2000 Public Const HDF_BITMAP_ON_RIGHT As Long = &H1000 header styles Public Const HDS_HORZ Public Const HDS_BUTTONS Public Const HDS_HOTTRACK Public Const HDS_HIDDEN Public Const HDS_DRAGDROP Public Const HDS_FULLDRAG As Long = &H0 As Long = &H2 As Long = &H4 As Long = &H8 As Long = &H40 As Long = &H80 header messages Public Const HDM_FIRST As Long = &H1200 Public Const HDM_GETITEMCOUNT As Long = (HDM_FIRST + 0) Public Const HDM_INSERTITEM As Long = (HDM_FIRST + 1) Public Const HDM_DELETEITEM As Long = (HDM_FIRST + 2) Public Const HDM_GETITEM As Long = (HDM_FIRST + 3) Public Const HDM_SETITEM As Long = (HDM_FIRST + 4) Public Const HDM_LAYOUT As Long = (HDM_FIRST + 5) Public Const HDM_HITTEST As Long = (HDM_FIRST + 6) Public Const HDM_GETITEMRECT As Long = (HDM_FIRST + 7) Public Const HDM_SETIMAGELIST As Long = (HDM_FIRST + 8) Public Const HDM_GETIMAGELIST As Long = (HDM_FIRST + 9) Public Const HDM_ORDERTOINDEX As Long = (HDM_FIRST + 15) notify messages Public Const HDN_FIRST As Long = -300& Public Const HDN_ITEMCLICK = (HDN_FIRST - 2) Public Const HDN_DIVIDERDBLCLICK = (HDN_FIRST - 5) Public Const HDN_BEGINTRACK = (HDN_FIRST - 6) Public Const HDN_ENDTRACK = (HDN_FIRST - 7) Public Const HDN_TRACK = (HDN_FIRST - 8) Public Const HDN_GETDISPINFO = (HDN_FIRST - 9) Public Const HDN_BEGINDRAG = (HDN_FIRST - 10) Public Const HDN_ENDDRAG = (HDN_FIRST - 11) Public Const HDN_ITEMCHANGING As Long = (HDN_FIRST - 0) Public Const HDN_ITEMDBLCLICK As Long = (HDN_FIRST - 3) Public Const NM_FIRST As Long = &H0 Public Const NM_RCLICK As Long = (NM_FIRST - 5) windows constants Public Const GWL_STYLE As Long = (-16) Public Const WM_USER As Long = &H400 Public Const WM_SIZE As Long = &H5 Public Const WM_NOTIFY As Long = &H4E& Public Declare Function GetComputerName Lib "kernel32" Alias _ "GetComputerNameA" (ByVal lpbuffer As String, nsize As Long) As Long Public Declare Function GetPrivateProfileString Lib "kernel32" Alias _ "GetPrivateProfileStringA" (ByVal lpapplicationname As String, ByVal lpkeyname As Any, ByVal lpdefault As String, ByVal lpreturnedstring As String, ByVal nsize As Long, ByVal lpfilename As String) As Long Public Declare Function WritePrivateProfileString Lib "kernel32" Alias _ "WritePrivateProfileStringA" (ByVal lpapplicationname As String, ByVal lpkeyname As Any, ByVal lpstring As Any, ByVal lpfilename As String) As Long Public Declare Function CallWindowProc Lib "user32" Alias _ "CallWindowProcA" (ByVal lpprevwndfunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wparam As Long, ByVal lparam As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hwnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long
425 Public Declare Function GetProp Lib "user32" Alias _ "GetPropA" (ByVal hwnd As Long, ByVal lpstring As String) As Long Public Declare Function SetProp Lib "user32" Alias _ "SetPropA" (ByVal hwnd As Long, ByVal lpstring As String, ByVal hdata As Long) As Long Public Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nindex As Long) As Long Public Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wmsg As Long, ByVal wparam As Any, lparam As Any) As Long Public Declare Function GetCursorPos Lib "user32" _ (lppoint As POINTAPI) As Long Public Declare Function ScreenToClient Lib "user32" _ (ByVal hwnd As Long, lppoint As POINTAPI) As Long Public Declare Function InitCommonControlsEx Lib "comctl32" _ (lpinitctrls As taginitcommoncontrolsex) As Boolean Public Declare Sub InitCommonControls Lib "comctl32" ()
426 69. Global.bas Attribute VB_Name = "global" Option Explicit Global cn As ADODB.Connection Global cnt As ADODB.Connection Global sempresa As String Global sdelegacion As String Global susuario As String Global iejercicio As Integer Global icuenta As Integer Global sinicioejercicio As String Global sfinalejercicio As String Global siniciobloqueo As String Global sfinalbloqueo As String Public Sub cambiarempresa() Dim frm As Form Dim flogin As New frmlogin Tanco totes els formularis excepte el principal For Each frm In Forms If frm.name <> "frmmain" Then Unload frm Next flogin.show vbmodal If Not flogin.ok Then Error dinici de sessió Exit Sub Unload flogin Set fmainmenu = New frmmenu Defineixo el tammany inicial del menú fmainmenu.width = fmainform.scalewidth * 0.2 fmainmenu.height = fmainform.scaleheight fmainform.sbstatusbar.panels(2).text = "PC: " & scomputername fmainform.sbstatusbar.panels(3).text = "Empresa: " & sempresa fmainform.sbstatusbar.panels(4).text = "Delegación: " & sdelegacion fmainform.sbstatusbar.panels(5).text = "Ejercicio: " & iejercicio fmainmenu.show Exit Sub ErrorConexion: MsgBox "Error al abrir la conexión.", vbcritical, App.Title Sub Public Sub cargarbotonera(tbl As Toolbar) Call tbl.buttons.add(1, "cancelar",, tbrdefault, "cancelar") Call tbl.buttons.add(2,,, tbrseparator) Call tbl.buttons.add(3, "insertar",, tbrdefault, "insertar") Call tbl.buttons.add(4, "modificar",, tbrdefault, "modificar") Call tbl.buttons.add(5, "filtrar",, tbrdefault, "filtrar") Call tbl.buttons.add(6,,, tbrseparator) Call tbl.buttons.add(7, "lupa",, tbrdefault, "lupa") Call tbl.buttons.add(8,,, tbrseparator) Call tbl.buttons.add(9, "borrar",, tbrdefault, "borrar") Call tbl.buttons.add(10, "listar",, tbrdefault, "listar") Call tbl.buttons.add(11, "imprimir",, tbrdefault, "imprimir") Call tbl.buttons.add(12, "ayudar",, tbrdefault, "ayudar") Sub Public Sub cargarcombocuentasconpases(combo As MSForms.ComboBox, empresa As String) Dim mcuentas As cuentas Dim rs As ADODB.Recordset Dim i As Integer combo.clear
427 Set mcuentas = New cuentas Set rs = mcuentas.getlist(cn, "codigo_empresa = " & empresa & " and pases = S") If Not rs.eof Then i = 0 Do Until rs.eof combo.additem Nz(rs("cuenta"), "") combo.list(i, 1) = Nz(rs("descripcion"), "") rs.movenext i = i + 1 Loop combo.columnheads = False combo.columnwidths = "75 pt;200 pt" combo.listwidth = 200 Set rs = Nothing Set mcuentas = Nothing Sub Public Sub cargarcombodelegaciones(combo As MSForms.ComboBox, empresa As String) Dim mdelegaciones As Delegaciones Dim rs As ADODB.Recordset combo.clear Set mdelegaciones = New Delegaciones Set rs = mdelegaciones.getlist(cn, "codigo_empresa = " & empresa & "", "codigo_empresa, codigo_delegacion") Do Until rs.eof combo.additem Nz(rs("codigo_delegacion"), "") rs.movenext Loop Set rs = Nothing Set mdelegaciones = Nothing Sub Public Sub cargarcombodiarios(combo As MSForms.ComboBox, empresa As String, delegacion As String) Dim mdiario As Diarios Dim rs As ADODB.Recordset Dim i As Integer combo.clear Set mdiario = New Diarios Set rs = mdiario.getlist(cn, "codigo_empresa = " & empresa & " and codigo_delegacion = " & delegacion & "") If Not rs.eof Then i = 0 Do Until rs.eof combo.additem Nz(rs("codigo_diario"), "") combo.list(i, 1) = Nz(rs("descripcion"), "") rs.movenext i = i + 1 Loop Set rs = Nothing Set mdiario = Nothing Sub Public Sub cargarcombodocumentos(combo As MSForms.ComboBox, empresa As String, delegacion As String) Dim mdocumentos As Documentos Dim rs As ADODB.Recordset Dim i As Integer combo.clear Set mdocumentos = New Documentos Set rs = mdocumentos.getlist(cn, "codigo_empresa = " & empresa & "")
428 If Not rs.eof Then i = 0 Do Until rs.eof combo.additem Nz(rs("codigo_documento"), "") combo.list(i, 1) = Nz(rs("descripcion"), "") rs.movenext i = i + 1 Loop Set rs = Nothing Set mdocumentos = Nothing Sub Public Sub cargarcomboempresas(combo As MSForms.ComboBox) Dim mempresas As Empresas Dim rs As ADODB.Recordset combo.clear Set mempresas = New Empresas Set rs = mempresas.getlist(cn,, "codigo_empresa") Do Until rs.eof combo.additem Nz(rs("codigo_empresa"), "") rs.movenext Loop Set rs = Nothing Set mempresas = Nothing Sub Public Sub cargarcomboformaspago(combo As MSForms.ComboBox, empresa As String, delegacion As String) Dim mformaspago As FormasPago Dim rs As ADODB.Recordset Dim i As Integer combo.clear Set mformaspago = New FormasPago Set rs = mformaspago.getlist(cn, "codigo_empresa = " & empresa & " and codigo_delegacion = " & delegacion & "") If Not rs.eof Then i = 0 Do Until rs.eof combo.additem Nz(rs("codigo_pago"), "") combo.list(i, 1) = Nz(rs("descripcion"), "") rs.movenext i = i + 1 Loop combo.columnheads = False combo.columnwidths = "75 pt;200 pt" combo.listwidth = 200 Set rs = Nothing Set mformaspago = Nothing Sub Public Sub cargarcomboimpuestos(combo As MSForms.ComboBox, empresa As String, delegacion As String) Dim mimpuestos As Impuestos Dim rs As ADODB.Recordset Dim i As Integer combo.clear Set mimpuestos = New Impuestos Set rs = mimpuestos.getlist(cn, "codigo_empresa = " & empresa & " and codigo_delegacion = " & delegacion & "") If Not rs.eof Then i =
429 Do Until rs.eof combo.additem Nz(rs("impuesto"), "") combo.list(i, 1) = Nz(rs("cta_iva"), "") combo.list(i, 2) = Nz(rs("pct_iva"), "") combo.list(i, 3) = Nz(rs("cta_re"), "") combo.list(i, 4) = Nz(rs("pct_re"), "") rs.movenext i = i + 1 Loop combo.columnheads = False combo.columnwidths = "50 pt;75 pt;50 pt;75 pt;50 pt" combo.listwidth = 250 Set rs = Nothing Set mimpuestos = Nothing Sub Public Sub cargarcombousuarios(combo As MSForms.ComboBox) Dim musuarios As Usuarios Dim rs As ADODB.Recordset combo.clear Set musuarios = New Usuarios Set rs = musuarios.getlist(cn) Do Until rs.eof combo.additem Nz(rs("codigo_usuario"), "") rs.movenext Loop Set rs = Nothing Set musuarios = Nothing Sub Public Sub cargarcombousuariosactivos(combo As MSForms.ComboBox, codigo_empresa As String, codigo_delegacion As String) Dim musuariosdelegaciones As UsuariosDelegaciones Dim rs As ADODB.Recordset combo.clear Set musuariosdelegaciones = New UsuariosDelegaciones Set rs = musuariosdelegaciones.getlist(cn, "codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & " AND activo <> 0") Do Until rs.eof combo.additem Nz(rs("codigo_usuario"), "") rs.movenext Loop Set rs = Nothing Set musuariosdelegaciones = Nothing Sub Public Sub deshabilitarbotones(tbl As Toolbar, ParamArray lista()) Dim i As Integer Dim maxi As Integer maxi = UBound(lista) For i = 0 To maxi tbl.buttons(lista(i)).enabled = False Next Sub Public Sub habilitarbotones(tbl As Toolbar, ParamArray lista()) Dim i As Integer Dim maxi As Integer maxi = UBound(lista) For i = 0 To maxi tbl.buttons(lista(i)).enabled = True
430 Next Sub Public Function guardarparametro(cad As String, parametro As String, n As Integer, Optional separador As String) As String Dim pos1 As Integer Dim pos2 As Integer Dim nparametro As Integer Dim cadaux As String If separador = "" Then separador = " " If cad = "" Then guardarparametro = String(n - 1, separador) & parametro & separador pos1 = 0 pos2 = InStr(1, cad, separador) nparametro = 0 cadaux = "" Do nparametro = nparametro + 1 If nparametro = n Then If pos1 = 0 Then Afegeixo a linici cadaux = parametro & Mid(cad, pos2) If pos1 <> 0 And pos2 = 0 Then Afegeixo al final cadaux = cad & parametro & separador Afegeixo al centre cadaux = Left(cad, pos1) & parametro & Mid(cad, pos2) pos1 = pos2 pos2 = InStr(pos2 + 1, cad, separador) If pos2 < pos1 Then cadaux = cad & String(n - nparametro - 1, separador) & parametro & separador Loop Until nparametro = n Or pos2 < pos1 guardarparametro = cadaux Function Public Function Indice(aArray() As String, valor As String) As Integer Dim i As Integer Dim maxi As Integer Dim ind As Integer i = 1 maxi = UBound(aArray) While (aarray(i) <> valor) And (i < maxi) i = i + 1 Wend ind = -1 If aarray(i) = valor Then ind = i Indice = ind Function Public Sub limatges16(imglist As ImageList) Dim spath As String spath = App.Path Call imglist.listimages.add(1, "validar", LoadPicture(sPath & "\icons16\validar.ico")) Call imglist.listimages.add(2, "borrar", LoadPicture(sPath & "\icons16\borrar.ico")) Call imglist.listimages.add(3, "buscar", LoadPicture(sPath & "\icons16\buscar.ico")) Call imglist.listimages.add(4, "cancelar", LoadPicture(sPath & "\icons16\cancelar.ico")) Call imglist.listimages.add(5, "imprimir", LoadPicture(sPath & "\icons16\imprimir.ico"))
431 Call imglist.listimages.add(6, "listar", LoadPicture(sPath & "\icons16\listar.ico")) Call imglist.listimages.add(7, "modificar", LoadPicture(sPath & "\icons16\modificar.ico")) Call imglist.listimages.add(8, "filtrar", LoadPicture(sPath & "\icons16\filtrar.ico")) Call imglist.listimages.add(9, "ayudar", LoadPicture(sPath & "\icons16\ayudar.ico")) Call imglist.listimages.add(10, "insertar", LoadPicture(sPath & "\icons16\insertar.ico")) Call imglist.listimages.add(11, "lupa", LoadPicture(sPath & "\icons16\lupa.ico")) Sub Public Sub mostrarlupa(frm As Form) Dim frmaux As Form Dim param As String param = "" param = guardarparametro(param, frm.hwnd, 1) param = guardarparametro(param, frm.activecontrol.hwnd, 2) param = guardarparametro(param, frm.activecontrol.tag, 3) If frm.activecontrol <> "" Then param = guardarparametro(param, "LEFT(" & frm.activecontrol.tag & ", " & Trim(str(Len(frm.ActiveControl))) & ") = " & Nz(frm.ActiveControl, "") & "", 4) param = guardarparametro(param, "", 4) Set frmaux = New frmlupa frmaux.parametros = param frmaux.show Set frmaux = Nothing Sub Public Function msgerror(codigo As Integer) As String Select Case codigo Case 1000: msgerror = "El campo es obligatorio." Case 1001: msgerror = "Cuenta contable inexistente." Case 1002: msgerror = "Código de diario inexistente." Case 1003: msgerror = "Código de documento inexistente." Case 1004: msgerror = "El formato no es valido." Case 1005: msgerror = "El valor debe ser C o P." Case 1006: msgerror = "El NIF/NIE/CIF no es valido." Case 1007: msgerror = "Se esperaba un valor numérico entero comprendido entre 1 y 12." Case 1008: msgerror = "No se ha especificado el porcentage." Case 1009: msgerror = "No se ha especificado los dias de vencimiento." Case 1010: msgerror = "El desglose de los vencimientos no devuelve el 100% del importe." Case 1011: msgerror = "La empresa ya existe." Case 1012: msgerror = "La empresa no existe." Case 1013: msgerror = "La forma de pago ya existe." Case 1014: msgerror = "La forma de pago no existe." Case 1015: msgerror = "La delegación ya existe." Case 1016: msgerror = "La delegación no existe." Case 1017: msgerror = "La cuenta ya existe." Case 1018: msgerror = "La cuenta no existe." Case 1019: msgerror = "El código ya existe." Case 1020: msgerror = "El código no existe." Case 1021: msgerror = "El grupo ya existe." Case 1022: msgerror = "El grupo no existe." Case 1023: msgerror = "El valor debe ser A o P." Case 1024: msgerror = "Se espera un valor numérico entero." Case 1025: msgerror = "El valor debe ser D o H." Case 1026: msgerror = "El formato de la numeración no es correcto." Case 1027: msgerror = "Fecha fuera de ejercicio." Case 1028: msgerror = "Es asiento no está cuadrado." Case 1029: msgerror = "Periodo bloqueado." Case 1030: msgerror = "No se puede eliminar el ejercicio activo." Case 1031: msgerror = "El ejercicio ya existe." Case 1032: msgerror = "El ejercicio no existe." Case 1033: msgerror = "Existe solapamiento de fechas con otros ejercicios." Case 1034: msgerror = "No se han encontrado los datos del acreedor/deudor pertenecientes a la cuenta contable." Case 1035: msgerror = "Ya existen documentos vinculados. Modificación cancelada." Case 1036: msgerror = "No se puede borrar la empresa activa."
432 Case 1037: msgerror = "No se puede borrar la delegación activa." Case 1038: msgerror = "El valor debe ser superior o igual a 1." Case 1039: msgerror = "Operación sólo realizable desde la pantalla de contrapartidas." Case 1040: msgerror = "No se ha especificado la empresa, la delegación o el ejercicio." Case 1041: msgerror = "El registro ya existe." Case 1042: msgerror = "El registro no existe." Case 1043: msgerror = "El apunte no se corresponde con una linea de IVA." Case 1044: msgerror = "La suma de los importes de los vencimientos no coincide con el de la partida." Case 1045: msgerror = "El vencimiento ya existe." Case 1046: msgerror = "El vencimiento no existe." Case 1047: msgerror = "El ejercicio no ha sido regularizado." Case 1048: msgerror = "No se puede abrir un ejercicio si el siguiente está cerrado." Case 9000: msgerror = "No hay datos que cumplan los criterios de selección para imprimir." Case : msgerror = "Error no definido." Select Function Public Function numeroparametros(str As String, Optional separador As String) As Integer Dim i As Integer Dim lenstr As Integer Dim np As Integer If separador = "" Then separador = " " np = 0 lenstr = Len(str) For i = 1 To lenstr If Mid(str, i, 1) = separador Then np = np + 1 Next numeroparametros = np Function Public Function Nz(variable As Variant, defecto As Variant) As Variant If IsNull(variable) Then Nz = defecto If variable = "" Then Nz = defecto Nz = variable Function Public Function obtenerparametro(cad As String, n As Integer, Optional separador As String) As String Dim i As Integer Dim pos As Integer Dim posant As Integer If separador = "" Then separador = " " If Len(cad) = 0 Or n = 0 Then obtenerparametro = "" i = 1 posant = 0 pos = InStr(1, cad, separador) If pos = 0 Then pos = Len(cad) + 1 While i < n posant = pos pos = InStr(posant + 1, cad, separador) If pos = 0 Then pos = Len(cad) + 1 i = i + 1 Wend If pos - posant - 1 > 0 Then obtenerparametro = Trim(Mid(cad, posant + 1, pos - posant - 1)) obtenerparametro = ""
433 Function Public Function posicionparametro(str As String, par As String, Optional separador As String) As Integer Dim c As String Dim i As Integer Dim maxi As String Dim paraux As String Dim pos As Integer If separador = "" Then separador = " " i = 1 maxi = Len(str) paraux = "" pos = 1 While i < maxi And paraux <> par c = Mid(str, i, 1) If c <> separador Then paraux = paraux & c paraux = "" pos = pos + 1 i = i + 1 Wend If paraux = par Then posicionparametro = pos posicionparametro = 0 Function Public Function scomputername() As String Dim strstring As String strstring = String(255, Chr$(0)) GetComputerName strstring, 255 strstring = Left$(strString, InStr(1, strstring, Chr$(0)) - 1) scomputername = strstring Function Public Function siguientenumero(empresa As String, ejercicio As Integer, serie As String) As String Dim mnumeracion As numeracion Dim rs As ADODB.Recordset Dim numstr As String numstr = "" Set mnumeracion = New numeracion Set rs = mnumeracion.getlist(cn, "codigo_empresa = " & empresa & " and ejercicio = " & ejercicio & " and numeracion = " & serie & "") If Not rs.eof Then numstr = Format(rs("numero"), String(rs("longitud"), "0")) Call mnumeracion.update(cn, empresa, ejercicio, serie, rs("longitud"), rs("numero") + 1, rs("descripcion"), susuario) siguientenumero = numstr Set rs = Nothing Set mnumeracion = Nothing Function Public Function transformarcuenta(cuenta As String, longitud As Integer) As String Dim aux As String
434 If Len(cuenta) - 1 < longitud And Len(cuenta) > 1 Then aux = Replace(cuenta, ".", String(longitud - Len(cuenta) + 1, "0")) If Len(aux) <> longitud Then aux = cuenta aux = cuenta transformarcuenta = aux Function Public Sub cargarmenuaplicacion() Dim cnsys As ADODB.Connection Dim rs As ADODB.Recordset Dim rssys As ADODB.Recordset On Error GoTo ErrorConexion Set rs = New ADODB.Recordset rs.open "SELECT COUNT(*) FROM Menus", cn, adopenstatic, adlockoptimistic If rs(0) = 0 Then rs.close Set cnsys = New ADODB.Connection cnsys.open "File name=sistema.udl" Set rssys = New ADODB.Recordset rssys.open "SELECT * FROM sysmenus ORDER BY item_menu", cnsys, adopenstatic, adlockoptimistic rs.open "SELECT * FROM Menus", cn, adopenstatic, adlockoptimistic While Not rssys.eof rs.addnew rs("item_menu") = rssys("item_menu") rs("item_padre") = rssys("item_padre") rs("descripcion") = rssys("descripcion") rs("formulario") = rssys("formulario") rs("administrador") = rssys("administrador") rs("activo") = 1 rs.update rssys.movenext Wend rssys.close Set rssys = Nothing Set cnsys = Nothing rs.close Set rs = Nothing Exit Sub ErrorConexion: MsgBox "Error al abrir la conexión.", vbcritical, App.Title Sub
435 70. Identificacio.bas Attribute VB_Name = "identificacio" Public Function codificar(byval cadena As String) As String Dim i As Integer Dim max_i As Integer Dim cad_cod As String max_i = Len(cadena) For i = 1 To max_i cad_cod = cad_cod + Chr(Asc(Mid$(cadena, i, 1)) + i) Next codificar = cad_cod Function Public Function decodificar(byval cadena As String) As String Dim i As Integer Dim max_i As Integer Dim cad_cod As String max_i = Len(cadena) For i = 1 To max_i cad_cod = cad_cod + Chr(Asc(Mid$(cadena, i, 1)) - i) Next decodificar = cad_cod Function
436 71. Inifunc.bas Attribute VB_Name = "inifunc" Public Function sgetini(sinifile As String, ssection As String, skey As String, sdefault As String) As String Dim stemp As String * 256 Dim nlength As Integer stemp = Space$(256) nlength = GetPrivateProfileString(sSection, skey, sdefault, stemp, 255, sinifile) sgetini = Left$(sTemp, nlength) Function Public Sub writeini(sinifile As String, ssection As String, skey As String, svalue As String) Dim n As Integer Dim stemp As String " " stemp = svalue Substituim CR/LF per espais For n = 1 To Len(sValue) If Mid$(sValue, n, 1) = vbvr Or Mid$(sValue, n, 1) = vblf Then Mid$(sValue, n) = Next n n = WritePrivateProfileString(sSection, skey, stemp, sinifile) Sub
437 72. Nif.bas Attribute VB_Name = "nif" Option Explicit Public Function letranifnie(byval strnifnie As String) As String Dim lnifnie As Integer Dim auxstr As String Dim auxchr As String Dim i As Integer auxstr = "" letranifnie = "" lnifnie = Len(strNIFNIE) For i = 1 To lnifnie auxchr = Mid$(strNIFNIE, i, 1) If Not (auxchr = "-" Or auxchr = "/" Or auxchr = " ") Then auxstr = auxstr & auxchr Next i If IsNumeric(Mid(auxStr, 1, 1)) Then letranifnie = DigitoNIF(CLng(Val(auxStr))) If UCase(Mid(auxStr, 1, 1)) = "X" Then letranifnie = DigitoNIF(CLng(Val(Mid(auxStr, 2)))) Function Public Function validarcif(byval strcif As String) As Boolean Dim lcif As Integer Dim auxstr As String Dim auxchr As String Dim i As Integer auxstr = "" lcif = Len(strCIF) For i = 1 To lcif auxchr = Mid$(strCIF, i, 1) If Not (auxchr = "-" Or auxchr = "/" Or auxchr = " ") Then auxstr = auxstr & auxchr Next i validarcif = ((InStr(1, "ABCDEFGHKLMNPQS", Left(auxStr, 1)) > 0) And (lcif > 8)) Function Public Function validarnifnie(strnifnie As String) As Boolean If IsNumeric(Mid(strNIFNIE, 1, 1)) Or UCase(Mid(strNIFNIE, 1, 1)) = "X" Then If IsNumeric(Right(strNIFNIE, 1)) Then strnifnie = strnifnie & letranifnie(strnifnie) validarnifnie = True validarnifnie = (letranifnie(strnifnie) = Right(strNIFNIE, 1)) validarnifnie = False Function Private Function DigitoNIF(ByVal lngdni As Long) As String DigitoNIF = Mid$("TRWAGMYFPDXBNJZSQVHLCKE", (lngdni Mod 23) + 1, 1) Function Private Function DigitoCIF(ByVal strcif As String) As String Const convalores As String = " " Dim i As Long, lngtemp As Long DigitoCIF = "" lngtemp = 0 For i = 2 To 6 Step 2 lngtemp = lngtemp + Val(Mid$(conValores, Val(Mid$(strCIF, i, 1)) + 1, 1))
438 lngtemp = lngtemp + Val(Mid$(strCIF, i + 1, 1)) Next i lngtemp = lngtemp + Val(Mid$(conValores, Val(Mid$(strCIF, 8, 1)) + 1, 1)) lngtemp = 10 - (lngtemp Mod 10) If lngtemp = 10 Then DigitoCIF = "J" DigitoCIF = Chr(lngTemp + 64) Function
439 73. Principal.bas Attribute VB_Name = "Principal" Option Explicit Public sadministrador As String Public spasswordadm As String Public fmainform As frmmain Public fmainmenu As frmmenu Sub Main() Dim flogin As New frmlogin sadministrador = "SUPERUSER" spasswordadm = "SUPERUSER" On Error GoTo ErrorConexion Set cn = New ADODB.Connection cn.open "File name=contabilidad.udl" Set cnt = New ADODB.Connection cnt.open "File name=temporal.udl" Call cargarmenuaplicacion flogin.show vbmodal If Not flogin.ok Then Fallo al iniciar la sesión, se sale de la aplicación Unload flogin frmsplash.top = 200 frmsplash.left = 200 frmsplash.show frmsplash.refresh Set fmainform = New frmmain Set fmainmenu = New frmmenu Load fmainform Load fmainmenu Unload frmsplash Defino el tamaño inicial del menu fmainmenu.width = fmainform.scalewidth * 0.2 fmainmenu.height = fmainform.scaleheight fmainform.sbstatusbar.panels(2).text = "PC: " & scomputername fmainform.sbstatusbar.panels(3).text = "Empresa: " & sempresa fmainform.sbstatusbar.panels(4).text = "Delegación: " & sdelegacion fmainform.sbstatusbar.panels(5).text = "Ejercicio: " & iejercicio fmainform.show fmainmenu.show Exit Sub ErrorConexion: MsgBox "Error al abrir la conexión.", vbcritical, App.Title Sub
440 74. Seguridad.bas Attribute VB_Name = "seguridad" Option Explicit Public Sub SeguridadUsuario(cn As ADODB.Connection, codigo_empresa As String, _ codigo_delegacion As String, usuario As String, aitems() As String, asegur() As String) Dim strcmd As String Dim rs As ADODB.Recordset Dim i As Integer Set rs = New ADODB.Recordset strcmd = "SELECT item_menu, restricciones FROM RestriccionesUsuariosMenus WHERE codigo_usuario = " _ & usuario & " AND codigo_empresa = " & codigo_empresa & " AND codigo_delegacion = " & codigo_delegacion & "" rs.open strcmd, cn, adopenstatic, adlockreadonly While Not rs.eof i = Indice(aItems(), rs("item_menu")) If i > 0 Then asegur(i) = asegur(i) & rs("restricciones") rs.movenext Wend rs.close Set rs = Nothing Sub Public Sub AplicarSeguridadBotonera(frm As Form, restricciones As String) Dim i As Integer En el tag del formulario, guardo el nombre de la botonera If frm.tag <> "" Then For i = 0 To frm.controls.count - 1 If (frm.controls(i).name = frm.tag) And (TypeOf frm.controls(i) Is Toolbar) Then If InStr(1, restricciones, "I") > 0 Then frm.controls(i).buttons("insertar").enabled = False If InStr(1, restricciones, "E") > 0 Then frm.controls(i).buttons("modificar").enabled = False If InStr(1, restricciones, "B") > 0 Then frm.controls(i).buttons("borrar").enabled = False If InStr(1, restricciones, "L") > 0 Then frm.controls(i).buttons("listar").enabled = False frm.controls(i).buttons("imprimir").enabled = False Next Sub
441 Annex I Script SQL Server
442 /*==============================================================*/ /* DBMS name: Microsoft SQL Server 2000 */ /* Created on: 01/08/ :04:03 */ /*==============================================================*/ /*==============================================================*/ /* Table: acrdeu */ /*==============================================================*/ create table acrdeu ( codigo_empresa char(10) not null, codigo char(12) not null, cuenta char(12) not null, tipo char(5) null, nacionalidad char(5) null, impuesto char(5) null, forma_pago char(5) null, primer_dia smallint null, descuento double precision null, irpf char(5) null, contrapartida char(12) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_acrdeu primary key (codigo_empresa, codigo, cuenta) /*==============================================================*/ /* Table: apuntes */ /*==============================================================*/ create table apuntes ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_documento char(15) not null, numero_documento char(10) not null, numero_apunte smallint not null, codigo_diario char(5) null, fecha_apunte char(8) null, fecha_documento char(8) null, referencia char(25) null, cuenta char(12) null, concepto char(100) null, debe double precision null, haber double precision null, tipo char(5) null, tag char(50) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_apuntes primary key (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte) ) go /*==============================================================*/ /* Table: cartera */ /*==============================================================*/ create table cartera ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_documento char(15) not null, numero_documento char(10) not null, numero_apunte smallint not null, fecha_vto char(8) not null, tipo_acrdeu char(5) null, codigo_personal char(12) null, concepto char(50) null, tipo char(1) null, estado char(1) null, importe double precision null, fecha_cierre char(8) null, codigo_documento_cierre char(15) null, numero_documento_cierre char(10) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_cartera primary key (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte, fecha_vto) )
443 go /*==============================================================*/ /* Table: cuentas */ /*==============================================================*/ create table cuentas ( codigo_empresa char(10) not null, cuenta char(12) not null, descripcion char(75) null, pases char(1) null, nivel smallint null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_cuentas primary key (codigo_empresa, cuenta) /*==============================================================*/ /* Table: delegaciones */ /*==============================================================*/ create table delegaciones ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, nombre char(75) null, direccion char(50) null, cp char(5) null, poblacion char(45) null, provincia char(35) null, pais char(25) null, telefono char(11) null, fax char(11) null, correo char(75) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_delegaciones primary key (codigo_empresa, codigo_delegacion) /*==============================================================*/ /* Table: diarios */ /*==============================================================*/ create table diarios ( codigo_empresa char(10) not null, codigo_diario char(5) not null, descripcion char(50) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_diarios primary key (codigo_empresa, codigo_diario) /*==============================================================*/ /* Table: documentos */ /*==============================================================*/ create table documentos ( codigo_empresa char(10) not null, codigo_documento char(15) not null, descripcion char(50) null, partida char(1) null, iva char(1) null, cartera char(1) null, numeracion char(4) null, identificador char(4) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_documentos primary key (codigo_empresa, codigo_documento) /*==============================================================*/ /* Table: ejercicios */ /*==============================================================*/ create table ejercicios ( codigo_empresa char(10) not null, ejercicio smallint not null, fecha_inicial nchar(1) null, fecha_final char(8) null,
444 ) go inicio_bloqueo char(8) null, final_bloqueo char(8) null, regularizado char(1) null, cerrado char(1) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_ejercicios primary key (codigo_empresa, ejercicio) /*==============================================================*/ /* Table: empresas */ /*==============================================================*/ create table empresas ( codigo_empresa char(10) not null, nif char(10) null, nombre char(75) null, direccion char(50) null, cp char(5) null, poblacion char(45) null, provincia char(35) null, pais char(25) null, telefono char(11) null, fax char(11) null, correo char(75) null, digitos smallint null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_empresas primary key (codigo_empresa) /*==============================================================*/ /* Table: formaspagos */ /*==============================================================*/ create table formaspagos ( codigo_empresa char(10) not null, codigo_pago char(5) not null, descripcion char(50) null, vto1 smallint null, pct1 double precision null, vto2 smallint null, pct2 double precision null, vto3 smallint null, pct3 double precision null, vto4 smallint null, pct4 double precision null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_formaspagos primary key (codigo_empresa, codigo_pago) /*==============================================================*/ /* Table: impuestos */ /*==============================================================*/ create table impuestos ( codigo_empresa char(10) not null, impuesto char(5) not null, cta_iva char(12) null, pct_iva double precision null, cta_re char(12) null, pct_re double precision null, tipo char(1) null, descripcion char(50) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_impuestos primary key (codigo_empresa, impuesto) /*==============================================================*/ /* Table: irpf */ /*==============================================================*/ create table irpf ( codigo_empresa char(10) not null, codigo char(5) not null,
445 ) go cuenta char(12) null, pct_irpf double precision null, descripcion char(50) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_irpf primary key (codigo_empresa, codigo) /*==============================================================*/ /* Table: menus */ /*==============================================================*/ create table menus ( item_menu char(12) not null, item_padre char(12) null, descripcion char(50) null, formulario char(50) null, activo bit not null, administrador bit not null, constraint pk_menus primary key (item_menu) ) go /*==============================================================*/ /* Table: numeraciones */ /*==============================================================*/ create table numeraciones ( codigo_empresa char(10) not null, ejercicio smallint not null, numeracion char(4) not null, longitud tinyint null, numero int null, descripcion char(75) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_numeraciones primary key (codigo_empresa, ejercicio, numeracion) /*==============================================================*/ /* Table: pergan */ /*==============================================================*/ create table pergan ( codigo_empresa char(10) not null, dh char(1) not null, nivel_1 smallint not null, nivel_2 smallint not null, nivel_3 smallint not null, nivel_4 smallint not null, titulo char(100) null, cuentas char(200) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_pergan primary key (codigo_empresa, dh, nivel_1, nivel_2, nivel_3, nivel_4) ) go /*==============================================================*/ /* Table: personal */ /*==============================================================*/ create table personal ( codigo_empresa char(10) not null, codigo char(12) not null, nombre char(75) null, nif char(15) null, direccion char(75) null, poblacion char(30) null, cp char(5) null, provincia char(25) null, pais char(20) null, telefono char(15) null, fax char(15) null, char(50) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_personal primary key (codigo_empresa, codigo)
446 ) go /*==============================================================*/ /* Table: registroirpf */ /*==============================================================*/ create table registroirpf ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_documento char(15) not null, numero_documento char(10) not null, numero_apunte smallint not null, tipo_acrdeu char(5) null, codigo_personal char(12) null, codigo_irpf char(5) null, base double precision null, pctirpf double precision null, irpf double precision null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_registroirpf primary key (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte) ) go /*==============================================================*/ /* Table: registroiva */ /*==============================================================*/ create table registroiva ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_documento char(15) not null, numero_documento char(10) not null, numero_apunte smallint not null, tipo char(1) null, tipo_acrdeu char(5) null, codigo_personal char(12) null, impuesto char(5) null, base double precision null, pctiva double precision null, iva double precision null, pctre double precision null, re double precision null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_registroiva primary key (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte) ) go /*==============================================================*/ /* Table: restriccionesusuariosmenus */ /*==============================================================*/ create table restriccionesusuariosmenus ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_usuario char(15) not null, item_menu char(20) not null, men_item_menu char(12) null, restricciones char(20) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_restriccionesusuariosmenus primary key (codigo_empresa, codigo_delegacion, codigo_usuario, item_menu) ) go /*==============================================================*/ /* Table: situacion */ /*==============================================================*/ create table situacion ( codigo_empresa char(10) not null, ap char(1) not null, nivel_1 smallint not null, nivel_2 smallint not null, nivel_3 smallint not null, titulo char(100) null,
447 cuentas char(200) null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_situacion primary key (codigo_empresa, ap, nivel_1, nivel_2, nivel_3) ) go /*==============================================================*/ /* Table: usuarios */ /*==============================================================*/ create table usuarios ( codigo_usuario char(15) not null, contrasena char(15) null, ) go ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_usuarios primary key (codigo_usuario) /*==============================================================*/ /* Table: usuariosdelegaciones */ /*==============================================================*/ create table usuariosdelegaciones ( codigo_empresa char(10) not null, codigo_delegacion char(10) not null, codigo_usuario char(15) not null, activo bit not null, ultima_modificacion char(8) null, ultimo_usuario char(15) null, constraint pk_usuariosdelegaciones primary key (codigo_empresa, codigo_delegacion, codigo_usuario) ) go alter table acrdeu add constraint fk_acrdeu_reference_personal foreign key (codigo_empresa, codigo) references personal (codigo_empresa, codigo) go alter table apuntes add constraint fk_apuntes_reference_delegaci foreign key (codigo_empresa, codigo_delegacion) references delegaciones (codigo_empresa, codigo_delegacion) go alter table cartera add constraint fk_cartera_reference_apuntes foreign key (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte) references apuntes (codigo_empresa, codigo_delegacion, codigo_documento, numero_documento, numero_apunte) go alter table cuentas add constraint fk_cuentas_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table delegaciones add constraint fk_delegaci_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table diarios add constraint fk_diarios_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table documentos add constraint fk_document_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table ejercicios add constraint fk_ejercici_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go
448 alter table formaspagos add constraint fk_formaspa_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table impuestos add constraint fk_impuesto_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table irpf add constraint fk_irpf_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table numeraciones add constraint fk_numeraci_reference_ejercici foreign key (codigo_empresa, ejercicio) references ejercicios (codigo_empresa, ejercicio) go alter table pergan add constraint fk_pergan_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table personal add constraint fk_personal_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table restriccionesusuariosmenus add constraint fk_restricc_reference_usuarios foreign key (codigo_empresa, codigo_delegacion, codigo_usuario) references usuariosdelegaciones (codigo_empresa, codigo_delegacion, codigo_usuario) go alter table restriccionesusuariosmenus add constraint fk_restricc_reference_menus foreign key (men_item_menu) references menus (item_menu) go alter table situacion add constraint fk_situacio_reference_empresas foreign key (codigo_empresa) references empresas (codigo_empresa) go alter table usuariosdelegaciones add constraint fk_usuarios_reference_delegaci foreign key (codigo_empresa, codigo_delegacion) references delegaciones (codigo_empresa, codigo_delegacion) go alter table usuariosdelegaciones add constraint fk_usuarios_reference_usuarios foreign key (codigo_usuario) references usuarios (codigo_usuario) go
Connecting to an Excel Workbook with ADO
Connecting to an Excel Workbook with ADO Using the Microsoft Jet provider ADO can connect to an Excel workbook. Data can be read from the workbook and written to it although, unlike writing data to multi-user
Connect to an Oracle Database from Visual Basic 6 (Part 2)
Connect to an Oracle Database from Visual Basic 6 (Part 2) Preface This is Part 2 in a 2 part series on using Visual Basic 6 to connect to an Oracle database. In Part 1, I showed you how to use an ADO
Changing the Display Frequency During Scanning Within an ImageControls 3 Application
Changing the Display Frequency During Scanning Within an ImageControls 3 Date November 2008 Applies To Kofax ImageControls 2x, 3x Summary This application note contains example code for changing he display
Estructura de aplicación en PHP para System i
Estructura de aplicación en PHP para System i La aplicación esta diseñada para IBM DB2 en System i, UNIX y Windows. Se trata de la gestión de una entidad deportiva. A modo de ejemplo de como está desarrollada
How-To Guide. SigCard1 (With Microsoft Access) Demo. Copyright Topaz Systems Inc. All rights reserved.
How-To Guide SigCard1 (With Microsoft Access) Demo Copyright Topaz Systems Inc. All rights reserved. For Topaz Systems, Inc. trademarks and patents, visit www.topazsystems.com/legal. Table of Contents
ASP (Active Server Pages)
ASP (Active Server Pages) 1 Prerequisites Knowledge of Hyper Text Markup Language (HTML). Knowledge of life cycle of web page from request to response. Knowledge of Scripting language like vbscript, javascript,
e-mail: [email protected] Ejercicio 1 Dim saludo As String * 10
Ejercicio 1 Dim saludo As String * 10 Private Sub Command1_Click() Dim Nombre As String * 10 Nombre = "Joaquim" saludo = "HOLA" Print saludo; y; Nombre Private Sub Command2_Click() saludo = "ADIOS" Print
Create an Access Database from within Visual Basic 6.
Create an Access Database from within Visual Basic 6. If you ve been following along with my books and articles, by now you know that you use ADO to retrieve information from a database, but did you know
VBScript Database Tutorial Part 1
VBScript Part 1 Probably the most popular use for ASP scripting is connections to databases. It's incredibly useful and surprisingly easy to do. The first thing you need is the database, of course. A variety
Add an Audit Trail to your Access Database
Add an to your Access Database Published: 22 April 2013 Author: Martin Green Screenshots: Access 2010, Windows 7 For Access Versions: 2003, 2007, 2010 About This Tutorial My Access tutorials are designed
Loading pictures with ActiveX and VBScript Copyright InduSoft Systems LLC 2006
Dynamically Loading Pictures on a Screen Using an ActiveX Control and VBScript Category Software Equipment Software Demo Application Implementation Specifications or Requirements Item IWS Version: 6.1
A Comparison of SAS versus Microsoft Excel and Access s Inbuilt VBA Functionality Jozef Tarrant, Amadeus Software Ltd., Oxford, UK
ABSTRACT There are a great variety of business situations where it is necessary to automatically export data from a large number of similar Microsoft Excel spreadsheets (perhaps reports, forms etc.) into
STUDENTS ATTENDANCE MANAGEMENT SYSTEM MINI PROJECT REPORT. Submitted by. KALAISANKARAN B Roll No: 11MCA020
STUDENTS ATTENDANCE MANAGEMENT SYSTEM MINI PROJECT REPORT Submitted by KALAISANKARAN B Roll No: 11MCA020 in partial fulfillment of the requirements For the award of the degree of MASTER OF COMPUTER APPLICATIONS
Abstract. Introduction. System Requirement. GUI Design. Paper AD17-2011
Paper AD17-2011 Application for Survival Analysis through Microsoft Access GUI Zhong Yan, i3, Indianapolis, IN Jie Li, i3, Austin, Texas Jiazheng (Steven) He, i3, San Francisco, California Abstract This
Providing Password Protection to Excel Reports for Distribution in Emails
Providing Password Protection to Excel Reports for Distribution in Emails Applies to: BusinessObjects Enterprise XI 3.1 SP2. For more information, visit the Business Objects homepage. Summary This paper
Government Girls Polytechnic, Bilaspur
Government Girls Polytechnic, Bilaspur Name of the Lab: Internet & Web Technology Lab Title of the Practical : Dynamic Web Page Design Lab Class: CSE 6 th Semester Teachers Assessment:20 End Semester Examination:50
ProficyTM. HMI/SCADA - ifix U SING SQL
ProficyTM HMI/SCADA - ifix U SING SQL Version 4.0 December 2005 All rights reserved. No part of this publication may be reproduced in any form or by any electronic or mechanical means, including photocopying
IVI Configuration Store
Agilent Developer Network White Paper Stephen J. Greer Agilent Technologies, Inc. The holds information about IVI drivers installed on the computer and configuration information for an instrument system.
PULSE Automation programming in Visual Basic. From BK training lectures arranged by Jiří Tůma & Radovan Zadražil
PULSE Automation programming in Visual Basic From BK training lectures arranged by Jiří Tůma & Radovan Zadražil OLE Automation, general principles Bruno S. Larsen PULSE Software Development Agenda Overview
Program to solve first and second degree equations
Fundamentals of Computer Science 010-011 Laboratory 4 Conditional structures () Objectives: Design the flowchart of programs with conditional sentences Implement VB programs with conditional sentences
Professional Services. Plant Applications SDK Guidelines GE FANUC AUTOMATION. Prepared by. Donna Lui Professional Services
GE FANUC AUTOMATION Professional Services Plant Applications SDK Guidelines Prepared by Donna Lui Professional Services GE Fanuc Automation SDK Guidelines Page 1 of 22 All rights reserved. No part of this
MS-Access Database Programming
Database Systems - Lecture Notes Victor. Matos CIS Department Cleveland State University MS-Access Database Programming MS-Access uses Visual-Basic for Applications (VBA) as its native programming language.
Lenguaje VHDL. Diseño de sistemas digitales secuenciales
Lenguaje VHDL Diseño de sistemas digitales secuenciales Flip-Flop D 1 entity d_ff is clk: in std_logic; d: in std_logic; q: out std_logic 2 end d_ff; P3 P1 5 Q D Q Q(t+1) 0 0 0 0 1 0 1 0 1 1 1 1 architecture
PROGRAMA DE GRAFICACIÓN DE VELOCIDADES EN VENTANAS DE MAPINFO
PROGRAMA DE GRAFICACIÓN DE VELOCIDADES EN VENTANAS DE MAPINFO Module Description: MapBasic program draw polylines using a tab file containing the data about the initial coordinate, azimuth and velocity
Extending the Data Warehouse: An Introduction to OLE DB
Extending the Data Warehouse: An Introduction to OLE DB 7Â(EZMHÂ6MFEÂ.%()Â8IGLÂ-RGÂ'PIEV[EXIVÂ*0 ABSTRACT Now that you have your data warehoused, how do you share that information with others who need
Visual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
Visual Basic and Databases
1-1 1. Introducing Preview In this first chapter, we will do a quick overview of what the course entails. We will discuss what you need to complete the course. We ll take a brief look at what databases
PharmaSUG 2014 - Paper PO01
ABSTRACT PharmaSUG 2014 - Paper PO01 A User Friendly Tool to Facilitate the Data Integration Process Yang Wang, Seattle Genetics, Inc., Bothell, WA Boxun Zhang, Seattle Genetics, Inc., Bothell, WA For
National Database System (NDS-32) Macro Programming Standards For Microsoft Word Annex - 8
National Database System () Macro Programming Standards For Microsoft Word Annex - 8 02/28/2000 /10:23 AM ver.1.0.0 Doc. Id: RNMSWS softcopy : word page : 1/6 Objectives A well-defined system needs to
InternetVista Web scenario documentation
InternetVista Web scenario documentation Version 1.2 1 Contents 1. Change History... 3 2. Introduction to Web Scenario... 4 3. XML scenario description... 5 3.1. General scenario structure... 5 3.2. Steps
Windows Desktop Administration
tm realtimepublishers.com tm The Definitive Guide To Windows Desktop Administration Bob Kelly Chapter 7: Scripting Custom Solutions...159 Should You Script It?...159 Choosing a Scripting Language...162
NORTH AMERICAN LANGUAGE AND CULTURE ASSISTANTS IN SPAIN
2015-2016 School Year How to register online your application NORTH AMERICAN LANGUAGE AND CULTURE ASSISTANTS IN SPAIN Updated: December 17, 2014 North American Language and Culture Assistants in Spain
Webapps Vulnerability Report
Tuesday, May 1, 2012 Webapps Vulnerability Report Introduction This report provides detailed information of every vulnerability that was found and successfully exploited by CORE Impact Professional during
Systems Programming & Scripting
Systems Programming & Scripting Lecture 14 - Shell Scripting: Control Structures, Functions Syst Prog & Scripting - Heriot Watt University 1 Control Structures Shell scripting supports creating more complex
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
MAPINFO GRID ENGINE. MapBasic scripts. MIGRID.DLL functions. using. Jacques Paris
MAPINFO GRID ENGINE MapBasic scripts using MIGRID.DLL functions Jacques Paris September 2001 This document contains 4 MapBasic code listings showing how to use calls to the MiGrid library. These examples
Visual Basic Cheat Sheet
thecodingguys 2013 Visual Basic Cheat Sheet 12/24/2013 A cheat sheet to the Visual Basic language, ideal for newcomers to the language for more visit http://www.thecodingguys.net KEEP IN TOUCH TABLE OF
PL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
Continuous Integration Part 2
1 Continuous Integration Part 2 This blog post is a follow up to my blog post Continuous Integration (CI), in which I described how to execute test cases in Code Tester (CT) in a CI environment. What I
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
When replying please quote: Ref.: NT-N1.17.2 EMX0943 20 October 2015
When replying please quote: Ref.: NT-N1.17.2 EMX0943 20 October 2015 To: States, Territories and International Organizations Subject: Invitation Twelfth Information Analysis Team Meeting (IAT/12) and Twenty-
VBA Microsoft Access 2007 Macros to Import Formats and Labels to SAS
WUSS 2011 VBA Microsoft Access 2007 Macros to Import Formats and Labels to SAS Maria S. Melguizo Castro, Jerry R Stalnaker, and Christopher J. Swearingen Biostatistics Program, Department of Pediatrics
CardSwipe Integration
CardSwipe Integration CardSwipe is an app that passes data from a Mag Stripe Reader to your application. No data is stored in CardSwipe making it PCI Compliant. Communication between CardSwipe and your
Laboratory Instructions & Incubator Guide
PROJECT: RO/03/B/P/PP175006 TITLE: New Forms of Learning & Basic Skills for Advanced, inclusive Lifelong evet in Internet Generated Occupations Laboratory Instructions & Incubator Guide ecommerce/ ebusiness
Curso SQL Server 2008 for Developers
Curso SQL Server 2008 for Developers Objetivos: Aprenderás a crear joins interiores y exteriores complejos, consultas agrupadas, y subconsultas Aprenderás a manejar los diferentes tipos de datos y sabrás
Building Applications with FME Objects
Building Applications with FME Objects E-mail: [email protected] Web: www.safe.com Safe Software Inc. makes no warranty either expressed or implied, including, but not limited to, any implied warranties of
Chapter 7 Event Log. Click the [Alarm (Event Log)] icon, and [Event Log] dialog appears as below:
Chapter 7 Event Log Event log is used to identify the content of an event and the conditions triggering this event. In addition, the triggered event (sometimes it is called alarm) and the processing procedure
1. Create SQL Database in Visual Studio
1. Create SQL Database in Visual Studio 1. Select Create New SQL Server Database in Server Explorer. 2. Select your server name, and input the new database name, then press OK. Copyright 2011 Lo Chi Wing
Package sjdbc. R topics documented: February 20, 2015
Package sjdbc February 20, 2015 Version 1.5.0-71 Title JDBC Driver Interface Author TIBCO Software Inc. Maintainer Stephen Kaluzny Provides a database-independent JDBC interface. License
Using Loops to Repeat Code
Using s to Repeat Code Why You Need s The macro recording tools in Microsoft Word and Microsoft Excel make easy work of creating simple coding tasks, but running a recorded macro is just that you do a
Managed App Configuration for App Developers. February 22, 2016
Managed App Configuration for App Developers February 22, 2016 Contents Chapter 1 Managed App Configuration Overview...5 Benefits of managed app configuration...6 Managed app configuration flow...7 Configuration
SIGESPro - Sistema de Gestión y Seguimiento de Proyectos de Software
1 - Sistema de Gestión y Seguimiento de Proyectos de Software Lomas Almeida Edison Patricio. [email protected] Universidad Técnica del Norte Summary This document describes the implementation of a
PIC 10A. Lecture 7: Graphics II and intro to the if statement
PIC 10A Lecture 7: Graphics II and intro to the if statement Setting up a coordinate system By default the viewing window has a coordinate system already set up for you 10-10 10-10 The origin is in the
Introduction. Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications
Introduction Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications 1 Computer Software Architecture Application macros and scripting - AML,
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
High-Performance Oracle: Proven Methods for Achieving Optimum Performance and Availability
About the Author Geoff Ingram (mailto:[email protected]) is a UK-based ex-oracle product developer who has worked as an independent Oracle consultant since leaving Oracle Corporation in the mid-nineties.
Integrating Web & DBMS
Integrating Web & DBMS Gianluca Ramunno < [email protected] > english version created by Marco D. Aime < [email protected] > Politecnico di Torino Dip. Automatica e Informatica Open Database Connectivity
Websense SQL Queries. David Buyer June 2009 [email protected]
Websense SQL Queries David Buyer June 2009 [email protected] Introduction The SQL queries that are listed here I have been using for a number of years now. I use them almost exclusively as an alternative to
Hi, processing. Code of the vb.net version. Imports System.Data Imports System.Data.SqlClient
Hi, I m looking for someone with knowledge in ASP.net or (PHP?). I represent a nonprofit organization that named Ateljee (http://www.uwkringwinkel.be). We have a small application we use for registration
Getting Started with STATISTICA Enterprise Programming
Getting Started with STATISTICA Enterprise Programming 2300 East 14th Street Tulsa, OK 74104 Phone: (918) 749 1119 Fax: (918) 749 2217 E mail: mailto:[email protected] Web: www.statsoft.com
Documentation to use the Elia Infeed web services
Documentation to use the Elia Infeed web services Elia Version 1.0 2013-10-03 Printed on 3/10/13 10:22 Page 1 of 20 Table of Contents Chapter 1. Introduction... 4 1.1. Elia Infeed web page... 4 1.2. Elia
JobScheduler Events Definition and Processing
JobScheduler - Job Execution and Scheduling System JobScheduler Events Definition and Processing Reference March 2015 March 2015 JobScheduler Events page: 1 JobScheduler Events - Contact Information Contact
Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2
Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................
High Performance Websites: ADO versus MSXML
High Performance Websites: ADO versus MSXML Timothy M. Chester, PhD, MCSD Senior Systems Analyst & Project Manager Computing & Information Services, Texas A&M University Summary: Tools Required: Further
Hands-On Lab. Client Workflow. Lab version: 1.0.0 Last updated: 2/23/2011
Hands-On Lab Client Workflow Lab version: 1.0.0 Last updated: 2/23/2011 CONTENTS OVERVIEW... 3 EXERCISE 1: DEFINING A PROCESS IN VISIO 2010... 4 Task 1 Define the Timesheet Approval process... 4 Task 2
Classes para Manipulação de BDs 5
Classes para Manipulação de BDs 5 Ambiienttes de Desenvollviimentto Avançados Engenharia Informática Instituto Superior de Engenharia do Porto Alexandre Bragança 1998/99 Baseada em Documentos da Microsoft
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA)
13 November 2007 22:30 Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA) By: http://www.alberton.info/firebird_sql_meta_info.html The SQL 2003 Standard introduced a new schema
ClientAce WPF Project Example
Technical Note ClientAce WPF Project Example 1. Introduction Traditional Windows forms are being replaced by Windows Presentation Foundation 1 (WPF) forms. WPF forms are fundamentally different and designed
UltraLog HSPI User s Guide
UltraLog HSPI User s Guide A HomeSeer HS2 plug-in to store and retrieve HomeSeer and syslog events Copyright 2013 [email protected] Revised 01/27/2013 This document contains proprietary and copyrighted
ASP.NET Dynamic Data
30 ASP.NET Dynamic Data WHAT S IN THIS CHAPTER? Building an ASP.NET Dynamic Data application Using dynamic data routes Handling your application s display ASP.NET offers a feature that enables you to dynamically
Chapter 9 Java and SQL. Wang Yang [email protected]
Chapter 9 Java and SQL Wang Yang [email protected] Outline Concern Data - File & IO vs. Database &SQL Database & SQL How Connect Java to SQL - Java Model for Database Java Database Connectivity (JDBC)
Security Awareness For Website Administrators. State of Illinois Central Management Services Security and Compliance Solutions
Security Awareness For Website Administrators State of Illinois Central Management Services Security and Compliance Solutions Common Myths Myths I m a small target My data is not important enough We ve
New Server Installation. Revisión: 13/10/2014
Revisión: 13/10/2014 I Contenido Parte I Introduction 1 Parte II Opening Ports 3 1 Access to the... 3 Advanced Security Firewall 2 Opening ports... 5 Parte III Create & Share Repositorio folder 8 1 Create
Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD. Introduction to Pig
Introduction to Pig Agenda What is Pig? Key Features of Pig The Anatomy of Pig Pig on Hadoop Pig Philosophy Pig Latin Overview Pig Latin Statements Pig Latin: Identifiers Pig Latin: Comments Data Types
UnifiedPOS (UPOS) Controls Combined JavaPOS and OPOS Controls. Programmer s Guide
UnifiedPOS (UPOS) Controls Combined JavaPOS and OPOS Controls Programmer s Guide Disclaimer Hand Held Products, Inc. d/b/a Hand Held Products ( Hand Held Products ) reserves the right to make changes in
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
Changing the Tufts University Moon Site. Needed:
Changing the Tufts University Moon Site Needed: ASPUpload (Download a free trial version from www.aspupload.com) Microsoft Access The VI for running VIs (Rover-server, talk to Phil Lau at [email protected])
Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11
Siemens Applied Automation Page 1 Maxum ODBC 3.11 Table of Contents Installing the Polyhedra ODBC driver... 2 Using ODBC with the Maxum Database... 2 Microsoft Access 2000 Example... 2 Access Example (Prior
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
A Microsoft Access Based System, Using SAS as a Background Number Cruncher David Kiasi, Applications Alternatives, Upper Marlboro, MD
AD006 A Microsoft Access Based System, Using SAS as a Background Number Cruncher David Kiasi, Applications Alternatives, Upper Marlboro, MD ABSTRACT In Access based systems, using Visual Basic for Applications
Connecting your MAC. Connecting to the IT wireless Service network with Mac OS
Connecting your MAC Connecting to the IT wireless Service network with Mac OS 1 To be able to use ESADE s WiFi (or wireless ) network, be sure to follow the instructions as follows. Step 7: Go to the TCP/IP
Prof. Edwar Saliba Júnior
package Conexao; 2 3 /** 4 * 5 * @author Cynthia Lopes 6 * @author Edwar Saliba Júnior 7 */ 8 import java.io.filenotfoundexception; 9 import java.io.ioexception; 10 import java.sql.sqlexception; 11 import
A table is a collection of related data entries and it consists of columns and rows.
CST 250 MySQL Notes (Source: www.w3schools.com) MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables.
Brazil + JDBC Juin 2001, [email protected] http://jfod.cnam.fr/tp_cdi/douin/
Brazil + JDBC Juin 2001, [email protected] http://jfod.cnam.fr/tp_cdi/douin/ version du 26 Mai 2003 : JDBC-SQL et Brazil pré-requis : lecture de Tutorial JDBC de Sun Bibliographie Brazil [Bra00]www.sun.com/research/brazil
Extending the Data Warehouse: An Introduction to OLE DB
Extending the Data Warehouse: An Introduction to OLE DB S David Rlba, JADE Tech Inc CleaNlater, FL INTRODUCTION ABSTRACT Now that you have your data warehoused, how do you share that infonnation with others
Stored Procedures for SQL Server The Basics Copyright 2001 Business & Computers, Inc.
BUSINESS & COMPUTERS, Inc. 13839 Mur-Len Rd, Suite M OLATHE, KANSAS 66062 SQL_StoredProcBasics Updated 10/05/2001 We Translate Business Processes from the Mind to the Computer to the Bottom Line. Phone:
SAP CCMS Monitors Microsoft Windows Eventlog
MSCTSC Collaboration Brief November 2004 SAP CCMS Monitors Microsoft Windows Eventlog Christian Klink Member of CTSC Focus Group SAP Technology Consultant SAP Technology Consulting II SAP Deutschland AG
Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query
Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query Objectives The objective of this lab is to learn the query language of SQL. Outcomes After completing this Lab,
PL/SQL Overview. Basic Structure and Syntax of PL/SQL
PL/SQL Overview PL/SQL is Procedural Language extension to SQL. It is loosely based on Ada (a variant of Pascal developed for the US Dept of Defense). PL/SQL was first released in ١٩٩٢ as an optional extension
OMEGA SOFT WF RISKEVAL
OMEGA SOFT WF RISKEVAL Quick Start Guide I. PROGRAM DOWNLOAD AND INSTALLATION... 2 II. CONNECTION AND PASSWORD CHANGE... 3 III. LIST OF WIND FARMS / PREVENTION TECHNICIANS... 4 IV. ADD A NEW WIND FARM...
