Commit inicial Ventas Productivo
This commit is contained in:
297
AC/RegIngresosModificaciones.aspx.vb
Normal file
297
AC/RegIngresosModificaciones.aspx.vb
Normal file
@@ -0,0 +1,297 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.Activities.Statements
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class AC_RegIngresosModificaciones
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "PROPIEDADES"
|
||||
Private Property DtPresupuestos As DataTable
|
||||
Get
|
||||
DtPresupuestos = DirectCast(ViewState("DtPresupuestos"), DataTable)
|
||||
End Get
|
||||
|
||||
Set(ByVal value As DataTable)
|
||||
ViewState("DtPresupuestos") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property DtDetalle As DataTable
|
||||
Get
|
||||
DtDetalle = DirectCast(ViewState("DtDetalle"), DataTable)
|
||||
End Get
|
||||
|
||||
Set(ByVal value As DataTable)
|
||||
ViewState("DtDetalle") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property pSaldo As String
|
||||
Get
|
||||
Return CType(ViewState("pSaldo"), String)
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("pSaldo") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property pAmpliacion As String
|
||||
Get
|
||||
Return CType(ViewState("pAmpliacion"), String)
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("pAmpliacion") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property pSaldoFinal As String
|
||||
Get
|
||||
Return CType(ViewState("pSaldoFinal"), String)
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("pSaldoFinal") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
GvD.Columns(5).Visible = False
|
||||
CreaDTDetalles()
|
||||
CargaPresupuestos()
|
||||
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
|
||||
LtEjercicio.Text = UsuarioActual.Empresa.EjercicioActual.ToString
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Private Sub CargaPresupuestos()
|
||||
Dim AC As New ClsAC
|
||||
If AC.GetPresupuestoIngresos(-1, UsuarioActual.Empresa.EjercicioActual, True, UsuarioActual.CveEmpresa) Then
|
||||
DtPresupuestos = AC.DtResultados.Copy
|
||||
Else
|
||||
Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la pagina", TipoMensaje.MsgError)
|
||||
End If
|
||||
AC.Dispose()
|
||||
LlenaDtDetalles()
|
||||
End Sub
|
||||
Private Sub CreaDTDetalles()
|
||||
DtDetalle = New DataTable
|
||||
DtDetalle.Columns.Add("FuenteRecaudacion", GetType(String))
|
||||
DtDetalle.Columns.Add("CodigoRubroIngreso", GetType(String))
|
||||
DtDetalle.Columns.Add("RubroIngreso", GetType(String))
|
||||
DtDetalle.Columns.Add("Saldo", GetType(Double))
|
||||
|
||||
DtDetalle.Columns.Add("IdCuentaPorEjecutar", GetType(Integer))
|
||||
DtDetalle.Columns.Add("IdCuentaModificado", GetType(Integer))
|
||||
|
||||
End Sub
|
||||
Private Sub LlenaDtDetalles()
|
||||
Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
DtDetalle.Rows.Clear()
|
||||
Dim totalsaldo As Double
|
||||
For Each drp As DataRow In DtPresupuestos.Rows
|
||||
Dim drt As DataRow = DtDetalle.NewRow
|
||||
drt("FuenteRecaudacion") = drp("FuenteRecaudacion")
|
||||
drt("CodigoRubroIngreso") = drp("CodigoRubroIngreso")
|
||||
drt("RubroIngreso") = drp("RubroIngreso")
|
||||
drt("Saldo") = ContPaq.GetSaldoCuenta(drp("IdCuentaPorEjecutar").ToString.ToEntero, 1, UsuarioActual.Empresa.EjercicioActual)
|
||||
|
||||
drt("IdCuentaPorEjecutar") = drp("IdCuentaPorEjecutar")
|
||||
drt("IdCuentaModificado") = drp("IdCuentaModificado")
|
||||
totalsaldo += drt("saldo").ToString.ToDouble
|
||||
|
||||
DtDetalle.Rows.Add(drt)
|
||||
Next
|
||||
|
||||
LbTotalSaldo.Text = totalsaldo.ToString.FormatoNumero
|
||||
pSaldo = totalsaldo.ToString.FormatoNumero
|
||||
ContPaq.Dispose()
|
||||
CargaDatosDetalles()
|
||||
End Sub
|
||||
Protected Sub CargaDatosDetalles()
|
||||
GvD.DataSource = DtDetalle.FiltraParametros("", "", {"FuenteRecaudacion", "CodigoRubroIngreso", "RubroIngreso", "Saldo", "IdCuentaPorEjecutar", "IdCuentaModificado"})
|
||||
GvD.DataBind()
|
||||
UPPDetalle.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuardar_click(sender As Object, e As EventArgs)
|
||||
Dim Total As Double = 0
|
||||
Dim Accion As Integer = DdlAccion.SelectedValue.ToString.ToEntero
|
||||
Dim IDPoliza As Integer
|
||||
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
Dim TieneError As Boolean = False
|
||||
Dim NoHaceNada As Boolean = False
|
||||
Dim TransferenciaError As Boolean = False
|
||||
'Dim Concepto As String
|
||||
Dim ampliacion As Double
|
||||
Dim reduccion As Double
|
||||
Conta.IniciaTransacSQL()
|
||||
Dim Fecha As Date = Now
|
||||
|
||||
If Accion = 0 Then
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
If Accion = -1 Then Total += gvr.FCTextBox("TxtReduccion").Text.ToDouble Else Total += gvr.FCTextBox("TxtAmpliacion").Text.ToDouble
|
||||
ampliacion += gvr.FCTextBox("TxtAmpliacion").Text.ToDouble
|
||||
reduccion += gvr.FCTextBox("TxtReduccion").Text.ToDouble
|
||||
Next
|
||||
pAmpliacion = ampliacion.ToString
|
||||
If ampliacion <> reduccion Then Total = -1
|
||||
Else
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
If Accion = -1 Then Total += gvr.FCTextBox("TxtReduccion").Text.ToDouble Else Total += gvr.FCTextBox("TxtAmpliacion").Text.ToDouble
|
||||
Next
|
||||
End If
|
||||
|
||||
If Total > 0 Then
|
||||
'Select Case Accion
|
||||
' Case 1
|
||||
' Concepto = "Modificado - Ampliación"
|
||||
' Case -1
|
||||
' Concepto = "Modificado - Reduccción" : Total = 0
|
||||
' Case Else
|
||||
' Concepto = "Modificado - Transferencia"
|
||||
'End Select
|
||||
Total = If(Accion = -1, 0, Total)
|
||||
Fecha = TxtFecha.Text.ToDate
|
||||
IDPoliza = Conta.AddPoliza(4, TxtConcepto.Text, Total, Total, UsuarioActual.CveUsuario, Fecha)
|
||||
|
||||
Dim Importe As Double
|
||||
If IDPoliza > 0 Then
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
|
||||
If DdlAccion.SelectedValue = "0" Then
|
||||
If gvr.FCTextBox("TxtReduccion").Text.ToDouble > 0 Then
|
||||
Importe = gvr.FCTextBox("TxtReduccion").Text.ToDouble
|
||||
Accion = -1
|
||||
Else
|
||||
Importe = gvr.FCTextBox("TxtAmpliacion").Text.ToDouble
|
||||
Accion = 1
|
||||
End If
|
||||
Else
|
||||
If Accion = -1 Then Importe = gvr.FCTextBox("TxtReduccion").Text.ToDouble() Else Importe = gvr.FCTextBox("TxtAmpliacion").Text.ToDouble()
|
||||
End If
|
||||
|
||||
If Importe > 0 Then
|
||||
If Conta.AddMovimiento(IDPoliza, gvr.DataKey("IdCuentaPorEjecutar").ToString.ToEntero, True, Importe * Accion, "", "", 0, Fecha, "") Then
|
||||
'actualizo el idcuenta del presupuesto
|
||||
If Not Conta.AddMovimiento(IDPoliza, gvr.DataKey("IdCuentaModificado").ToString.ToEntero, False, Importe * Accion, "", "", 0, Fecha, "") Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
NoHaceNada = True
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
Conta.AjustaPoliza(IDPoliza)
|
||||
Conta.Commit()
|
||||
LbTotalAmpliacion.Text = "0.00"
|
||||
LbTotalReduccion.Text = "0.00"
|
||||
LbTotalSaldoFinal.Text = "0.00"
|
||||
TxtConcepto.Text = ""
|
||||
TxtFecha.Text = "__/__/____"
|
||||
GvD.DataBind()
|
||||
CargaPresupuestos()
|
||||
UPPDetalle.Update()
|
||||
UPTotales.Update()
|
||||
Alert(String.Format("Registros agregados con exito<br/><br/><a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}'>Ver Poliza</a>", IDPoliza), TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
Conta.RollBack()
|
||||
If Total = -1 Then
|
||||
Alert("El total de ampliaciones y reducciones debe ser igual.", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Alert(If(NoHaceNada, "No se encontraron registros", "Error poliza"), TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
Conta.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub TipoModificacion(sender As Object, e As EventArgs)
|
||||
If DdlAccion.SelectedValue = "0" Then 'TRANSFERENCIA
|
||||
GvD.Columns(4).Visible = True 'TxtAmpliacion
|
||||
GvD.Columns(5).Visible = True 'TxtReduccion
|
||||
TdAmpliacion.Visible = True
|
||||
LbTotalAmpliacion.Visible = True
|
||||
TdReduccion.Visible = True
|
||||
LbTotalReduccion.Visible = True
|
||||
ElseIf DdlAccion.SelectedValue = "-1" Then 'REDUCCION
|
||||
GvD.Columns(4).Visible = False 'TxtAmpliacion
|
||||
GvD.Columns(5).Visible = True 'TxtReduccion
|
||||
TdAmpliacion.Visible = False
|
||||
LbTotalAmpliacion.Visible = False
|
||||
TdReduccion.Visible = True
|
||||
LbTotalReduccion.Visible = True
|
||||
Else 'AMPLIACION
|
||||
GvD.Columns(4).Visible = True 'TxtAmpliacion
|
||||
GvD.Columns(5).Visible = False 'TxtReduccion
|
||||
TdAmpliacion.Visible = True
|
||||
LbTotalAmpliacion.Visible = True
|
||||
TdReduccion.Visible = False
|
||||
LbTotalReduccion.Visible = False
|
||||
End If
|
||||
|
||||
CargaPresupuestos()
|
||||
|
||||
UPFiltros.Update()
|
||||
UPPDetalle.Update()
|
||||
UPTotales.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub GvD_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvD.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
Select Case DdlAccion.SelectedValue
|
||||
Case "1"
|
||||
e.Row.FCTextBox("TxtAmpliacion").Attributes.Add("onkeyup", String.Format("CalculaSaldo({0},this,'{1}','A','');", e.Row.DBCampo("Saldo"), e.Row.FCLabel("LBSF").ClientID))
|
||||
Case "-1"
|
||||
e.Row.FCTextBox("TxtReduccion").Attributes.Add("onkeyup", String.Format("CalculaSaldo({0},this,'{1}','R','');", e.Row.DBCampo("Saldo"), e.Row.FCLabel("LBSF").ClientID))
|
||||
Case "0"
|
||||
e.Row.FCTextBox("TxtAmpliacion").Attributes.Add("onkeyup", String.Format("CalculaSaldo({0},this,'{1}','A','{2}');", e.Row.DBCampo("Saldo"), e.Row.FCLabel("LBSF").ClientID, e.Row.FCTextBox("TxtReduccion").ClientID))
|
||||
e.Row.FCTextBox("TxtReduccion").Attributes.Add("onkeyup", String.Format("CalculaSaldo({0},this,'{1}','R','{2}');", e.Row.DBCampo("Saldo"), e.Row.FCLabel("LBSF").ClientID, e.Row.FCTextBox("TxtAmpliacion").ClientID))
|
||||
'e.Row.FCRangeValidator("RV").MaximumValue = e.Row.DBCampo("Saldo").ToDouble.ToString
|
||||
e.Row.FCRangeValidator("RV").Enabled = True
|
||||
'rv
|
||||
'MaximumValue='<%# Eval("Saldo") %>'
|
||||
End Select
|
||||
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#Region "I M P R I M I R "
|
||||
|
||||
Protected Sub BtnImprimir_Click(sender As Object, e As ImageClickEventArgs)
|
||||
ImprimirReporte()
|
||||
End Sub
|
||||
|
||||
Protected Sub ImprimirReporte()
|
||||
'nombre del archivo a generar
|
||||
Dim fileName As String = "ReporteModificacionesPresupuestosIngresos"
|
||||
'ubicacion del rdlc
|
||||
Dim reportpath As String = "AC/Reportes/RepModificacionesPresupuestosIngresos.rdlc"
|
||||
|
||||
'parametros a enviar al reporte
|
||||
Dim params As New List(Of ReportParameter)
|
||||
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri))
|
||||
params.Add(New ReportParameter("pEjercicio", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("pSaldo", pSaldo))
|
||||
params.Add(New ReportParameter("pAmpliacion", pAmpliacion))
|
||||
params.Add(New ReportParameter("pSaldoFinal", pSaldoFinal))
|
||||
ImprimirPDF(reportpath, DtPresupuestos, params, fileName)
|
||||
End Sub
|
||||
#End Region
|
||||
End Class
|
||||
Reference in New Issue
Block a user