Imports System.Data Imports Extensiones Partial Class Contabilidad_DIOTChilo Inherits Page Private Sub Contabilidad_DIOTChilo_Load(sender As Object, e As EventArgs) Handles Me.Load End Sub Private Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click Dim ObjContabilidad As New ClsContabilidad Dim ObjConta As ClsContPAQi = Nothing Dim ObjEmpres As New Empresa() ObjEmpres.Empresa = "EXPLORACIONES MINERAS DEL DESIERTO S.A DE C.V" ObjEmpres.ServerContPAQi = "192.168.0.2\COMPAC,1430" ObjEmpres.BDContPAQi = "ctEMD" ObjEmpres.UsrContPAQi = "sa" ObjEmpres.PwdContPAQi = "AsS151026r37" Dim OcurrioError = False Dim Mensaje = "" If ObjConta Is Nothing Then ObjConta = New ClsContPAQi(ObjEmpres) ObjConta.IniciaTransacSQL() End If Dim tIdPoliza As Integer Dim Fecha As Date Dim ContaFolio As Integer If ObjContabilidad.GetPrePoliza(TxtPoliza.Text.ToEntero, 13) Then tIdPoliza = ObjContabilidad.DtResultados(0)("IdPoliza").ToString.ToEntero Fecha = ObjContabilidad.DtResultados(0)("Fecha").ToString.ToDate ContaFolio = ObjContabilidad.DtResultados(0)("FolioPoliza").ToString.ToEntero End If If ObjContabilidad.GetDIOTValores(TxtPoliza.Text.ToEntero) Then If ObjContabilidad.DtResultados.Rows.Count.ToEntero > 0 Then Dim IdProveedor As Integer Dim RFC As String = "" Dim RazonSocial As String = "" Dim IdCtaContProveedores As Integer For Each dr As DataRow In ObjContabilidad.DtResultados.Rows RFC = dr("RFC").ToString RazonSocial = dr("RazonSocial").ToString IdCtaContProveedores = dr("IdCtaContProveedores").ToString.ToEntero If IdCtaContProveedores > 0 Then 'busco la clave del proveedor en la contabilidad por su cuenta contable If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then If ObjConta.DtResultados.Rows.Count > 0 Then Dim drt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drt("Id").ToString.ToEntero End If End If Else 'busco la clave del proveedor en la contabilidad por su cuenta contable If ObjConta.GetProveedores(RFC:=RFC) Then If ObjConta.DtResultados.Rows.Count > 0 Then Dim drtt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drtt("Id").ToString.ToEntero End If Else 'registro el proveedor generico Select Case 13 Case Else : IdProveedor = 0 End Select End If End If If IdProveedor <= 0 Then IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "") If IdProveedor <= 0 Then OcurrioError = True End If End If If Not OcurrioError Then If dr("Total").ToString.ToDecimal <> 0.00 Then If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero, IdProveedor, 16, dr("SubTotal").ToString.ToDecimal, dr("IvaAcreditable").ToString.ToDecimal, dr("IVARetenido").ToString.ToDecimal, dr("ISRRetenido").ToString.ToDecimal, Fecha, ContaFolio, dr("Serie").ToString.ToString, dr("Folio").ToString.StrToNum, dr("FolioFiscal").ToString, 13) Then OcurrioError = True Mensaje = "La Poliza o la Cuenta no son válidas" Exit For End If End If End If Next If OcurrioError Then ObjConta.RollBack() Else 'Alert(String.Format("{1}
", tIdPoliza, ObjConta.Folio)) ObjConta.Commit() End If End If End If End Sub End Class