From a6990e696ca497ee009341ecdbe0ce25122dfad2 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 12 Aug 2022 15:56:23 -0700 Subject: [PATCH] -- desaplicar pago de venta --- App_Code/ClsContabilidad.vb | 20 ++++++++++++ Contabilidad/PopUpAuxiliar.aspx | 1 + Contabilidad/PopUpAuxiliar.aspx.vb | 52 +++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index b28b1630c..0a37fc57f 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -1539,6 +1539,26 @@ Public Class ClsContabilidad Return Retorno End Function + Public Function DesAplicarPago(CvePrePoliza As Integer, CveConcepto As Integer, CveVenta As Integer, CveVentaAmortizacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_DesAplicarMovimiento") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConcepto + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaAmortizacion", SqlDbType.Int).Value = CveVentaAmortizacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al desaplicar pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + + End Try + Return Retorno + End Function + Public Function GetEncabezadoPrePoliza(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/Contabilidad/PopUpAuxiliar.aspx b/Contabilidad/PopUpAuxiliar.aspx index 50fe4092b..0a5826bef 100644 --- a/Contabilidad/PopUpAuxiliar.aspx +++ b/Contabilidad/PopUpAuxiliar.aspx @@ -148,6 +148,7 @@ + diff --git a/Contabilidad/PopUpAuxiliar.aspx.vb b/Contabilidad/PopUpAuxiliar.aspx.vb index 6f0951149..b324091bd 100644 --- a/Contabilidad/PopUpAuxiliar.aspx.vb +++ b/Contabilidad/PopUpAuxiliar.aspx.vb @@ -164,9 +164,6 @@ Partial Class PopUpAuxiliar Protected Sub GVAuxiliar_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAuxiliar.RowDataBound - - - If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.BackColor = Drawing.Color.LightGray @@ -213,6 +210,17 @@ Partial Class PopUpAuxiliar e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) End If + If e.Row.DBCampo("CveConceptoContable").Contiene("91", "251") Then 'desaplicar NC + + e.Row.FCLinkButton("LnkDesAplicar").Visible = True + e.Row.FCLinkButton("imgD").Visible = False + If e.Row.DBCampo("CveConceptoContable").Contiene("251") Then + e.Row.FCLinkButton("LnkDesAplicar").CommandArgument = String.Format("{0}|{1}|{2}", e.Row.DBCampo("CvePrePoliza"), e.Row.DBCampo("CveVenta"), e.Row.DBCampo("CveVentaAmortizacion")) + Else + e.Row.FCLinkButton("LnkDesAplicar").CommandArgument = String.Format("{0}|{1}|{2}", e.Row.DBCampo("CvePrePoliza"), e.Row.DBCampo("CveVentaAmortizacion"), e.Row.DBCampo("CveVenta")) + End If + End If + If e.Row.DBCampo("TipoReferencia").ToEntero = 1 Then e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Bancos/IE.aspx?CveIE={e.Row.DBCampo("CveReferencia").ToEntero}" 'If e.Row.DBCampo("CveReferencia").ToEntero > 0 Then @@ -418,7 +426,6 @@ Partial Class PopUpAuxiliar Alert(Str.ToString) Else ObjContabilidad.RollBack() - End If ObjContabilidad.Dispose() @@ -439,6 +446,43 @@ Partial Class PopUpAuxiliar RegistraScript(" $('#DivCancelar').modal('show'); ") End Sub + Private Sub GVAuxiliar_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GVAuxiliar.RowCommand + If e.CommandName = "DesAplicar" Then + + Dim CvePrePoliza, CveVenta, CveVentaAmortizacion As Integer + Dim TieneError = False + + Dim St As String() = e.CommandArgument.ToString.Split("|"c) + If St.Length > 0 Then + CvePrePoliza = St(0).ToEntero + CveVenta = St(1).ToEntero + CveVentaAmortizacion = St(2).ToEntero + End If + + If CvePrePoliza > 0 Then + Dim Conta As New ClsContabilidad() + Conta.IniciaTransacSQL() + + If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + TieneError = True + End If + + If Not TieneError AndAlso Not Conta.DesAplicarPago(CvePrePoliza, 251, CveVenta, CveVentaAmortizacion) Then + TieneError = True + End If + + If Not TieneError Then + Conta.Commit() + Alert("Pago Desaplicado.", TipoMensaje.ToastInformacion) + Else + Conta.RollBack() + Alert("Pago no fue desaplicado.", TipoMensaje.ToastError) + End If + End If + + End If + + End Sub End Class