186 lines
7.0 KiB
VB.net
186 lines
7.0 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class Bancos_RepProgramaciones
|
|
Inherits ClsPaginas
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos()
|
|
Dim ObjCompras As New ClsCompras
|
|
|
|
If ObjCompras.GetComprasCrediProveedores(UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjCompras.DtResultados
|
|
End If
|
|
|
|
ObjCompras.Dispose()
|
|
|
|
GvDatos.DataBind()
|
|
' DtDatos = DtDatos.FiltraParametros("CveTipoPagoProgramo = 3 AND EstatusPortal = 0")
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " ACTUALIZAR "
|
|
Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ObjCredito As New ClsBancos(ObjCompras.IniciaTransacSQL())
|
|
Dim ErrorCompra = False
|
|
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("ChkAccion").Checked Then
|
|
If Not ObjCompras.UpdateCompraEstatusPortal(Gvr.DataKey("CveCompra").ToEntero) Then
|
|
ErrorCompra = True
|
|
End If
|
|
'inserto el movimiento en creditos
|
|
Dim CveCuenta As Integer
|
|
Dim drBC As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveTipoCuenta = 7")
|
|
If drBC IsNot Nothing Then CveCuenta = drBC("CveCuenta").ToString.ToEntero
|
|
|
|
Dim CveCredito As Integer = ObjCredito.AddCreditos(1, Gvr.DataKey("Folio"), "", CveCuenta, Gvr.DataKey("CveCompra").ToEntero, -1, 1, Now, Now, 0, 0, 0.16, 0, -1, Gvr.DataKey("Total").ToDouble, 0, 0, -1, Gvr.DataKey("CveProveedor").ToEntero, 1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CveCredito > 0 Then
|
|
If Not ObjCredito.AddCreditosDetalle(CveCredito, Now,
|
|
Gvr.DataKey("Total").ToDouble, 0, 0.0, 0, 0.0, 0.0, 101) Then
|
|
ErrorCompra = True
|
|
End If
|
|
Else
|
|
ErrorCompra = True
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
If ErrorCompra Then
|
|
ObjCompras.RollBack()
|
|
Alert("Ocurrio un error al actualizar.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
ObjCompras.Commit()
|
|
CargaDatos()
|
|
Alert("Los registros se actualizaron correctamente.")
|
|
End If
|
|
|
|
ObjCompras.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnRegistrar_Click(sender As Object, e As EventArgs)
|
|
'Dim Chk As CheckBox = CType(sender, CheckBox)
|
|
Dim Btn As Button = CType(sender, Button)
|
|
Dim Gvr As GridViewRow = CType(Btn.BindingContainer, GridViewRow)
|
|
|
|
If 1 = 1 Then
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ObjCredito As New ClsBancos(ObjCompras.IniciaTransacSQL())
|
|
Dim RegistraCredito = True
|
|
'Cambia estatus de la compra
|
|
Dim ErrorCompra = Not ObjCompras.UpdateCompraEstatusPortal(Gvr.DataKey("CveCompra").ToEntero)
|
|
|
|
'Comprobamos si ya existe el registro en creditos
|
|
If ObjCredito.GetCreditos(-1, Gvr.DataKey("CveCompra").ToEntero, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
RegistraCredito = If(ObjCredito.DtResultados.Rows.Count > 0, False, True)
|
|
Else
|
|
ErrorCompra = True
|
|
End If
|
|
|
|
If Not ErrorCompra And RegistraCredito Then
|
|
|
|
'inserto el movimiento en creditos
|
|
Dim CveCuenta As Integer
|
|
Dim drBC As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveTipoCuenta = 7")
|
|
If drBC IsNot Nothing Then CveCuenta = drBC("CveCuenta").ToString.ToEntero
|
|
|
|
Dim CveCredito As Integer = ObjCredito.AddCreditos(1, Gvr.DataKey("Folio"), "", CveCuenta, Gvr.DataKey("CveCompra").ToEntero, -1, 1, Now, Now, 0, 0, 0.16, 0,
|
|
-1, Gvr.DataKey("Total").ToDouble, 0, 0, -1, Gvr.DataKey("CveProveedor").ToEntero, 1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CveCredito > 0 Then
|
|
If Not ObjCredito.AddCreditosDetalle(CveCredito, Now,
|
|
Gvr.DataKey("Total").ToDouble, 0, 0.0, 0, 0.0, 0.0, 101) Then
|
|
ErrorCompra = True
|
|
End If
|
|
Else
|
|
ErrorCompra = True
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If ErrorCompra Then
|
|
ObjCompras.RollBack()
|
|
Alert("Ocurrio un error al actualizar. Por favor vuelta a intentar", TipoMensaje.MsgError)
|
|
Else
|
|
ObjCompras.Commit()
|
|
CargaDatos()
|
|
Alert("Los registros se actualizaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjCompras.Dispose()
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
|
|
Protected Sub ChkAccion_CheckedChanged(sender As Object, e As EventArgs)
|
|
'Dim Chk As CheckBox = CType(sender, CheckBox)
|
|
Dim Btn As Button = CType(sender, Button)
|
|
Dim Gvr As GridViewRow = CType(Btn.BindingContainer, GridViewRow)
|
|
|
|
If 1 = 1 Then
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ObjCredito As New ClsBancos(ObjCompras.IniciaTransacSQL())
|
|
Dim ErrorCompra As Boolean = False
|
|
|
|
|
|
If Not ObjCompras.UpdateCompraEstatusPortal(Gvr.DataKey("CveCompra").ToEntero) Then
|
|
ErrorCompra = True
|
|
End If
|
|
'inserto el movimiento en creditos
|
|
Dim CveCuenta As Integer
|
|
Dim drBC As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveTipoCuenta = 7")
|
|
If drBC IsNot Nothing Then CveCuenta = drBC("CveCuenta").ToString.ToEntero
|
|
|
|
Dim CveCredito As Integer = ObjCredito.AddCreditos(1, Gvr.DataKey("Folio"), "", CveCuenta, Gvr.DataKey("CveCompra").ToEntero, -1, 1, Now, Now, 0, 0, 0.16, 0,
|
|
-1, Gvr.DataKey("Total").ToDouble, 0, 0, -1, Gvr.DataKey("CveProveedor").ToEntero, 1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CveCredito > 0 Then
|
|
If Not ObjCredito.AddCreditosDetalle(CveCredito, Now,
|
|
Gvr.DataKey("Total").ToDouble, 0, 0.0, 0, 0.0, 0.0, 101) Then
|
|
ErrorCompra = True
|
|
End If
|
|
Else
|
|
ErrorCompra = True
|
|
End If
|
|
|
|
|
|
If ErrorCompra Then
|
|
ObjCompras.RollBack()
|
|
Alert("Ocurrio un error al actualizar.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
ObjCompras.Commit()
|
|
CargaDatos()
|
|
Alert("Los registros se actualizaron correctamente.")
|
|
End If
|
|
|
|
ObjCompras.Dispose()
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
End Class
|