This commit is contained in:
2022-09-28 11:44:36 -07:00
3 changed files with 2093 additions and 2031 deletions

View File

@@ -716,6 +716,31 @@ Public Class ClsContabilidad
Return Retorno
End Function
Public Function RemovePrePolizasDetalle(CvePrePoliza As Integer, CvePrePolizaDetalle As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Conta_PrePolizasDetalleEspecificoRemove")
With SqlAdapter.SelectCommand.Parameters
.Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza
.Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
If ex.Message.Contains("50015;") Then
OnError("No se puede eliminar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
Else
OnError("Ocurrió un error al eliminar el detalle de la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End If
End Try
Return Retorno
End Function
Public Function GetMovimientosPoliza(IdPoliza As Integer, CveEmpresa As Integer) As Integer
Dim Retorno As Integer = -1

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,15 @@ Partial Class ContabilidadC_RegPrePolizaS
ViewState("DtMovimientos") = value
End Set
End Property
Public Property DtMovimientosEliminar As DataTable
Get
Return CType(ViewState("DtMovimientosEliminar"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtMovimientosEliminar") = value
End Set
End Property
Public Property DtCuentasContables As DataTable
Get
Return CType(ViewState("DtCuentasContables"), DataTable)
@@ -269,6 +278,7 @@ Partial Class ContabilidadC_RegPrePolizaS
ViewState("CvePrePoliza") = Request("CvePrePoliza").ToEntero
CreaDT()
CreaDTEliminar()
CargaPrePoliza()
If IfNull(Request("Tipo"), "").ToString <> "NOMPROV" Then
GvPrePoliza.Columns(5).Visible = False
@@ -412,6 +422,14 @@ Partial Class ContabilidadC_RegPrePolizaS
DtMovimientos.AcceptChanges()
End Sub
Private Sub CreaDTEliminar()
DtMovimientosEliminar = New DataTable("MovimientosEliminar")
With DtMovimientosEliminar.Columns
.Add("CvePrePolizaDetalle", GetType(Integer))
End With
DtMovimientosEliminar.AcceptChanges()
End Sub
Private Sub CargaPrePoliza()
BtnEliminar.Visible = True
LblEncabezado.Text = "Edición de Póliza"
@@ -1142,7 +1160,7 @@ Partial Class ContabilidadC_RegPrePolizaS
' Alert(If(MensajeAlert.ToString = "", "Se registro con exito.", MensajeAlert.ToString), TipoMensaje.MsgInformacion, "window.location.reload()")
'End If
Alert(If(MensajeAlert.ToString = "", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")}</b>", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")} </b><br>" & MensajeAlert.ToString), TipoMensaje.MsgInformacion, $"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={CvePrePolizaInsertada}""")
Alert(If(MensajeAlert.ToString = "", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")}</b>", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")} </b><br>" & MensajeAlert.ToString), TipoMensaje.MsgInformacion, $"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={CvePrePolizaInsertada}""", ShowCloseButton:=False)
ObjIE.Commit()
@@ -1172,79 +1190,95 @@ Partial Class ContabilidadC_RegPrePolizaS
Dim ObjContabilidad As New ClsContabilidad
ObjContabilidad.IniciaTransacSQL()
ObjContabilidad.UpdatePrePoliza(MinFecha, -1, DdlTipoPoliza.SelectedValue.ToEntero, -1, CvePrePoliza, UsuarioActual.CveEmpresa, Concepto:=TxtConcepto.Text, FechaPoliza:=TxtFechaDocumento.Text.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario)
Try
ObjContabilidad.UpdatePrePoliza(MinFecha, -1, DdlTipoPoliza.SelectedValue.ToEntero, -1, CvePrePoliza, UsuarioActual.CveEmpresa, Concepto:=TxtConcepto.Text, FechaPoliza:=TxtFechaDocumento.Text.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario)
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
OcurrioError = True
End If
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
OcurrioError = True
End If
Dim CveIEAgregado As Integer = -1
For Each row As GridViewRow In GvPrePoliza.Rows
If row.DataKey("CvePrePolizaDetalle").ToEntero > 0 Then
If row.FCCheckBox("chkModificado").Checked Then
contador = contador + 1
If DtMovimientosEliminar IsNot Nothing AndAlso DtMovimientosEliminar.Rows.Count > 0 Then
For Each RowEliminar As DataRow In DtMovimientosEliminar.Rows
If Not ObjContabilidad.RemovePrePolizasDetalle(Me.CvePrePoliza, RowEliminar("CvePrePolizaDetalle").ToString().ToEntero()) Then
OcurrioError = True
Exit For
End If
Next
End If
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
If Not OcurrioError Then
Dim CveIEAgregado As Integer = -1
For Each row As GridViewRow In GvPrePoliza.Rows
If row.DataKey("CvePrePolizaDetalle").ToEntero > 0 Then
If row.FCCheckBox("chkModificado").Checked Then
contador = contador + 1
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIEAgregado < 0 Then
'MsgError = "No se pudo registrar movimiento bancario"
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIEAgregado < 0 Then
'MsgError = "No se pudo registrar movimiento bancario"
OcurrioError = True
Exit For
End If
End If
If Not ObjContabilidad.UpdatePrePolizasDetalle(row.DataKey("CvePrePolizaDetalle").ToEntero, row.FCLiteral("TxtConcepto").Text, row.DataKey("CveSubProyecto").ToEntero,
row.DataKey("IdCtaContable").ToEntero, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
CveConceptoContable:=row.DataKey("CveConceptoContable").ToEntero, CveProveedor:=row.DataKey("CveProveedor").ToEntero, CveCompra:=row.DataKey("CveCompra").ToEntero,
CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
CvePersonal:=row.DataKey("CvePersonal").ToEntero, Referencia:=row.FCLiteral("TxtRef").Text, CveCuenta:=row.DataKey("CveCuenta").ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveIE:=CveIEAgregado) Then
OcurrioError = True
Exit For
End If
End If
Else
contador = contador + 1
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIEAgregado < 0 Then
'MsgError = "No se pudo registrar movimiento bancario"
OcurrioError = True
Exit For
End If
End If
If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), row.DataKey("Referencia").ToString,
row.DataKey("CveConceptoContable").ToEntero, row.FCLiteral("TxtConcepto").Text, Now,
row.DataKey("IdCtaContable").ToEntero, 0, CveSubProyecto:=row.DataKey("CveSubProyecto").ToEntero,
CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
ImporteMX:=If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveProveedor:=row.DataKey("CveProveedor").ToEntero,
CveCompra:=row.DataKey("CveCompra").ToEntero, CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
CvePersonal:=row.DataKey("CvePersonal").ToEntero, CveCuenta:=row.DataKey("CveCuenta").ToEntero, PorcentajeImpuesto:=row.DataKey("PorcentajeImpuesto").ToDecimal, CveIE:=CveIEAgregado) Then
OcurrioError = True
Exit For
End If
End If
If Not ObjContabilidad.UpdatePrePolizasDetalle(row.DataKey("CvePrePolizaDetalle").ToEntero, row.FCLiteral("TxtConcepto").Text, row.DataKey("CveSubProyecto").ToEntero,
row.DataKey("IdCtaContable").ToEntero, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
CveConceptoContable:=row.DataKey("CveConceptoContable").ToEntero, CveProveedor:=row.DataKey("CveProveedor").ToEntero, CveCompra:=row.DataKey("CveCompra").ToEntero,
CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
CvePersonal:=row.DataKey("CvePersonal").ToEntero, Referencia:=row.FCLiteral("TxtRef").Text, CveCuenta:=row.DataKey("CveCuenta").ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveIE:=CveIEAgregado) Then
OcurrioError = True
Exit For
End If
End If
Else
contador = contador + 1
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIEAgregado < 0 Then
'MsgError = "No se pudo registrar movimiento bancario"
OcurrioError = True
Exit For
End If
End If
If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), row.DataKey("Referencia").ToString,
row.DataKey("CveConceptoContable").ToEntero, row.FCLiteral("TxtConcepto").Text, Now,
row.DataKey("IdCtaContable").ToEntero, 0, CveSubProyecto:=row.DataKey("CveSubProyecto").ToEntero,
CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
ImporteMX:=If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveProveedor:=row.DataKey("CveProveedor").ToEntero,
CveCompra:=row.DataKey("CveCompra").ToEntero, CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
CvePersonal:=row.DataKey("CvePersonal").ToEntero, CveCuenta:=row.DataKey("CveCuenta").ToEntero, PorcentajeImpuesto:=row.DataKey("PorcentajeImpuesto").ToDecimal, CveIE:=CveIEAgregado) Then
OcurrioError = True
Exit For
End If
Next
End If
Next
Catch ex As Exception
OcurrioError = True
OnError("Ocurrío un error al actualizar la PrePoliza", ex)
End Try
If Not OcurrioError Then
ObjContabilidad.Commit()
Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion)
Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:=$"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={Me.CvePrePoliza}""", ShowCloseButton:=False)
Else
ObjContabilidad.RollBack()
Alert("Ocurrio un error al actualizar la PrePoliza.", TipoMensaje.MsgError)
@@ -3057,12 +3091,19 @@ Partial Class ContabilidadC_RegPrePolizaS
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
If CvePrePoliza > 0 Then
Dim RowEliminar As DataRow = DtMovimientosEliminar.NewRow()
RowEliminar("CvePrePolizaDetalle") = GvRow.DataKey("CvePrePolizaDetalle")
DtMovimientosEliminar.Rows.Add(RowEliminar)
End If
DtMovimientos.Rows(GvRow.RowIndex).Delete()
DtMovimientos.AcceptChanges()
GvPrePoliza.DataSource = DtMovimientos
GvPrePoliza.DataBind()
TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
UpTotalCargo.Update()