1325 lines
62 KiB
VB.net
1325 lines
62 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Globalization
|
|
Imports Extensiones
|
|
Partial Class Bancos_FluctuacionCambiaria
|
|
Inherits ClsPaginas
|
|
|
|
|
|
Public ReadOnly Property FechaUltimoDiaMes() As DateTime
|
|
Get
|
|
Return New DateTime(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero(), 1).AddMonths(1).AddDays(-1)
|
|
End Get
|
|
End Property
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property LblTotal() As String
|
|
Get
|
|
Return ViewState("Total").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Total") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaFechas()
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoComprasAnt, Nothing, LblSubProyectoComprasAnt, "")
|
|
CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "")
|
|
CargarCentrosDeCosto(Nothing, DdlsubProyectoVentasAnt, Nothing, LblSubProyectoVentasAnt, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreedores, Nothing, LblSubProyectoAcreedores, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreeedoresAnt, Nothing, LblSubProyectoAcreedoresAnt, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubproyectoBancos, Nothing, LblSubProyectoBancos, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoFiliales, Nothing, LblSubProyectoFiliales, "")
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectoDeudores, Nothing, LblSubProyectoDeudores, "")
|
|
|
|
CargaUltimaFluctuacion()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGAS"
|
|
Private Sub CargaFechas()
|
|
'Año actual
|
|
DdlAnio.Items.Add(New ListItem(Now.Year.ToString(), Now.Year.ToString()))
|
|
'Año Anterior
|
|
DdlAnio.Items.Add(New ListItem(Now.AddYears(-1).Year.ToString(), Now.AddYears(-1).Year.ToString()))
|
|
|
|
For i = 1 To 12
|
|
Dim fecha = New DateTime(DdlAnio.SelectedValue.ToEntero(), i, 1)
|
|
Dim mes = fecha.ToString("MMMM", CultureInfo.GetCultureInfo("es-MX"))
|
|
Dim mesStr = Char.ToUpper(mes(0)) + mes.Substring(1)
|
|
|
|
DdlMes.Items.Add(New ListItem(mesStr, i.ToString()))
|
|
Next
|
|
|
|
Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now)
|
|
If UltimaFluctuacion IsNot Nothing Then
|
|
DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Month)
|
|
DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Year)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
CargaTipoCambio()
|
|
If T.ActiveTabIndex = 0 Then CargaDatosProveedores()
|
|
If T.ActiveTabIndex = 1 Then CargaDatosProveedoresAnticipos()
|
|
If T.ActiveTabIndex = 2 Then CargaDatosClientes()
|
|
If T.ActiveTabIndex = 3 Then CargaDatosClientesAnticipos()
|
|
If T.ActiveTabIndex = 4 Then CargaDatosAcreedores()
|
|
If T.ActiveTabIndex = 5 Then CargaDatosAcreedoresAnticipos()
|
|
If T.ActiveTabIndex = 6 Then CargaDatosCuentas()
|
|
|
|
If T.ActiveTabIndex = 7 Then CargaDatosFiliales()
|
|
If T.ActiveTabIndex = 8 Then CargaDatosDeudores()
|
|
UpTabs.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaTipoCambio()
|
|
Dim ObjGenerales As New ClsGenerales
|
|
ObjGenerales.GetTipoCambio(-1, FechaUltimoDiaMes)
|
|
If ObjGenerales.DtResultados.Rows.Count > 0 Then
|
|
LtTipoCambioActual.Text = ObjGenerales.DtResultados.Rows(0)("TipoCambio").ToString
|
|
TxtConceptoFluctuacion.Text = "Fluctuación a " & FechaUltimoDiaMes.ToShortDateString()
|
|
End If
|
|
ObjGenerales.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaUltimaFluctuacion()
|
|
|
|
|
|
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now)
|
|
|
|
If UltimaFluctuacion IsNot Nothing Then
|
|
LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", UltimaFluctuacion.FechaFluctuacion.ToShortDateString)
|
|
'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual
|
|
If UltimaFluctuacion.FechaFluctuacion >= Now.AddMonths(-1).LastDayOfMonth Then
|
|
DdlMes.SelectedValueExist(Now.Month)
|
|
DdlAnio.SelectedValueExist(Now.Year)
|
|
Else
|
|
DdlMes.SelectedValueExist(Now.AddMonths(-1).Month)
|
|
DdlAnio.SelectedValueExist(Now.AddMonths(-1).Year)
|
|
End If
|
|
End If
|
|
|
|
CargaTipoCambio()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosProveedores()
|
|
Dim ObjBancos As New ClsBancos
|
|
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 1, UsuarioActual.CveEmpresa) Then
|
|
GvProveedores.DataSource = ObjBancos.DtResultados
|
|
'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0 ")
|
|
Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ")
|
|
|
|
Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion").Abs
|
|
Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion").Abs
|
|
|
|
Dim Final As Double = GanaciaAux - PerdidaAux
|
|
HdnProveedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
|
|
|
HplProveedorLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
HplProveedorLiga.Visible = HdnProveedorCvePrePoliza.Value.ToEntero > 0
|
|
BtnProveedoresRemove.Visible = HdnProveedorCvePrePoliza.Value.ToEntero > 0
|
|
BtnGeneraCompras.Visible = Not HdnProveedorCvePrePoliza.Value.ToEntero > 0
|
|
|
|
IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
|
|
|
|
LtIndicador_ExistenciaPerdida.Text = PerdidaAux.ToString.FormatoNumero
|
|
LtIndicador_ValorPesosGanancia.Text = GanaciaAux.ToString.FormatoNumero
|
|
LtIndicador_CPPesosFinal.Text = Final.Abs.ToString.FormatoNumero
|
|
LblComprasPerdidaGanancia.Text = If(Final < 0, "Ganancia", "Pérdida")
|
|
|
|
LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvProveedores.DataBind()
|
|
UpIndicadores.Visible = True
|
|
If GvProveedores.Rows.Count > 0 Then
|
|
GvProveedores.Rows(GvProveedores.Rows.Count - 1).CssClass = "SubTotales2"
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatosProveedoresAnticipos()
|
|
Dim ObjBancos As New ClsBancos
|
|
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 2, UsuarioActual.CveEmpresa) Then
|
|
GvProveedoresAnt.DataSource = ObjBancos.DtResultados
|
|
'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ")
|
|
Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0 ")
|
|
|
|
Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion").Abs
|
|
Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion")
|
|
|
|
Dim Final As Double = GanaciaAux - PerdidaAux
|
|
HdnProveedorAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
|
BtnProveedoresAntRemove.Visible = HdnProveedorAntCvePrePoliza.Value.ToEntero > 0
|
|
HplProveedorAntLiga.Visible = HdnProveedorAntCvePrePoliza.Value.ToEntero > 0
|
|
HplProveedorAntLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
BtnGeneraComprasAnt.Visible = Not HdnProveedorAntCvePrePoliza.Value.ToEntero > 0
|
|
|
|
IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
|
|
|
|
LtIndicador_ExistenciaPerdida.Text = PerdidaAux.ToString.FormatoNumero
|
|
LtIndicador_ValorPesosGanancia.Text = GanaciaAux.ToString.FormatoNumero
|
|
LtIndicador_CPPesosFinal.Text = Final.Abs.ToString.FormatoNumero
|
|
LblComprasPerdidaGanancia.Text = If(Final > 0, "Ganancia", "Pérdida")
|
|
|
|
LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvProveedoresAnt.DataBind()
|
|
UpIndicadores.Visible = True
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatosClientes()
|
|
Dim ObjBancos As New ClsBancos
|
|
LblTotalVentas.Text = "0.00"
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 3, UsuarioActual.CveEmpresa) Then
|
|
GvVentas.DataSource = ObjBancos.DtResultados
|
|
|
|
Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0")
|
|
Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0")
|
|
|
|
Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion", "Fluctuacion > 0").Abs
|
|
Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion", "Fluctuacion < 0").Abs
|
|
|
|
Dim Final As Double = GanaciaAux - PerdidaAux
|
|
HdnClienteCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
|
|
|
HplClientesLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
HplClientesLiga.Visible = HdnClienteCvePrePoliza.Value.ToEntero > 0
|
|
BtnClientesRemove.Visible = HdnClienteCvePrePoliza.Value.ToEntero > 0
|
|
BtnGeneraVentas.Visible = Not HdnClienteCvePrePoliza.Value.ToEntero > 0
|
|
|
|
IImagenFinalVentas.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
|
|
|
|
LtIndicador_PerdidasVentas.Text = PerdidaAux.ToString.FormatoNumero
|
|
LtIndicador_GanaciaVentas.Text = GanaciaAux.ToString.FormatoNumero
|
|
LtIndicador_FinalVentas.Text = Final.ToString.FormatoNumero
|
|
LblVentasPerdidaGanancia.Text = If(Final < 0, "Pérdida", "Ganancia")
|
|
|
|
LblTotalVentas.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
|
|
UpIndicadoresVentas.Visible = True
|
|
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvVentas.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosClientesAnticipos()
|
|
Dim ObjBancos As New ClsBancos
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 4, UsuarioActual.CveEmpresa) Then
|
|
GvClientesAnt.DataSource = ObjBancos.DtResultados
|
|
|
|
Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0")
|
|
Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0")
|
|
|
|
Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion", "Fluctuacion < 0").Abs
|
|
Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion", "Fluctuacion > 0")
|
|
|
|
Dim Final As Double = GanaciaAux - PerdidaAux
|
|
HdnClienteAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
|
HplClientesAntLiga.Visible = HdnClienteAntCvePrePoliza.Value.ToEntero > 0
|
|
HplClientesAntLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
BtnClientesAntRemove.Visible = HdnClienteAntCvePrePoliza.Value.ToEntero > 0
|
|
BtnClientesAnticipos.Visible = Not HdnClienteAntCvePrePoliza.Value.ToEntero > 0
|
|
|
|
'IImagenFinalVentas.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
|
|
|
|
'LtIndicador_PerdidasVentas.Text = PerdidaAux.ToString.FormatoNumero
|
|
'LtIndicador_GanaciaVentas.Text = GanaciaAux.ToString.FormatoNumero
|
|
'LtIndicador_FinalVentas.Text = Final.ToString.FormatoNumero
|
|
'LblVentasPerdidaGanancia.Text = If(Final < 0, "Pérdida", "Ganancia")
|
|
|
|
LblTotalVentasAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
|
|
UpIndicadoresVentas.Visible = True
|
|
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvClientesAnt.DataBind()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDatosAcreedores()
|
|
Dim ObjBancos As New ClsBancos
|
|
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 5, UsuarioActual.CveEmpresa) Then
|
|
|
|
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
|
HdnAcreedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
BtnAcreedoresRemove.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0
|
|
BtnGeneraAcreedores.Visible = Not HdnAcreedorCvePrePoliza.Value.ToEntero > 0
|
|
|
|
HplAcreedorLiga.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0
|
|
HplAcreedorLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
GvAcreedores.DataSource = ObjBancos.DtResultados
|
|
LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Else
|
|
GvAcreedores.DataSource = Nothing
|
|
Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvAcreedores.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosAcreedoresAnticipos()
|
|
Dim ObjBancos As New ClsBancos
|
|
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then
|
|
HdnAcreedorAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
|
BtnAcreedoresAntRemove.Visible = HdnAcreedorAntCvePrePoliza.Value.ToEntero > 0
|
|
BtnGeneraAcreedoresAnt.Visible = Not HdnAcreedorAntCvePrePoliza.Value.ToEntero > 0
|
|
|
|
HplAcreedorAntLiga.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0
|
|
HplAcreedorAntLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
|
|
GvAcreedoresAnt.DataSource = ObjBancos.DtResultados
|
|
LblTotalAcreedoresAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Else
|
|
GvAcreedoresAnt.DataSource = Nothing
|
|
Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvAcreedoresAnt.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosCuentas()
|
|
Dim ObjBancos As New ClsBancos
|
|
LblTotalBancos.Text = "0.00"
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 7, UsuarioActual.CveEmpresa) Then
|
|
Dim DtTemp As DataTable = ObjBancos.DtResultados.Copy
|
|
Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal
|
|
Dim TotAcumulado As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
For Each Dr As DataRow In DtTemp.Rows
|
|
Dim Total As Decimal = 0
|
|
Dim CveCuentaExtranjera As Integer = Dr("CveCuentaExtranjera").ToString.ToEntero
|
|
If CveCuentaExtranjera > 0 Then
|
|
If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaExtranjera, MinFecha, FechaUltimoDiaMes, 2, -1, -1, UsuarioActual.CveEmpresa, "1") Then
|
|
If Conta.DtResultados.Rows.Count > 1 Then
|
|
Total = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal
|
|
End If
|
|
End If
|
|
End If
|
|
Dr("Saldo") = Total
|
|
Total = Total * TCCierreFluctuacion - Total
|
|
Dim SaldoActualContabilidad As Decimal = 0
|
|
Dim CveCuentaComplementaria As Integer = Dr("CveCuentaComplementaria").ToString.ToEntero
|
|
If CveCuentaComplementaria > 0 Then
|
|
If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, MinFecha, FechaUltimoDiaMes, 2, -1, -1, UsuarioActual.CveEmpresa, "1") Then
|
|
If Conta.DtResultados.Rows.Count > 1 Then
|
|
SaldoActualContabilidad = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Total = Total - SaldoActualContabilidad
|
|
TotAcumulado += Math.Round(Total, 2)
|
|
Dr("Fluctuacion") = Total
|
|
Next
|
|
DtTemp.AcceptChanges()
|
|
Conta.Dispose()
|
|
|
|
GvCuentas.DataSource = DtTemp
|
|
LblTotalBancos.Text = TotAcumulado.FormatoNumero
|
|
Else
|
|
GvCuentas.DataSource = Nothing
|
|
Alert("Ocurrio un error al cargar las cuentas", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvCuentas.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosDeudores()
|
|
Dim ObjBancos As New ClsBancos
|
|
LblTotalDeudores.Text = "0.00"
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 9, UsuarioActual.CveEmpresa) Then
|
|
GvDeudores.DataSource = ObjBancos.DtResultados
|
|
LblTotalDeudores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Else
|
|
GvDeudores.DataSource = Nothing
|
|
Alert("Ocurrio un error al cargar los deudores", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvDeudores.DataBind()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDatosFiliales()
|
|
Dim ObjBancos As New ClsBancos
|
|
LblTotalAcreedores.Text = "0.00"
|
|
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 8, UsuarioActual.CveEmpresa) Then
|
|
GvFiliales.DataSource = ObjBancos.DtResultados.FiltraParametros("Saldo > 0")
|
|
LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
|
|
Else
|
|
GvFiliales.DataSource = Nothing
|
|
Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvFiliales.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "FLUCTUACION COMPRAS"
|
|
|
|
Protected Sub BtnGeneraCompras_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
Dim idCta As Integer = 0
|
|
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim IdCtaComplementaria As Integer = 0
|
|
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Total = LblTotal.ToDecimal
|
|
If Total < 0 Then
|
|
CveConceptoContable = 64
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Proveedores Anticipos", CveConceptoContable, "Fluctuación Proveedores Anticipos", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvProveedores.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
'si es pérdida o ganancia
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString.ToEntero()
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnGeneraCompras.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnGeneraComprasAnt_Click(sender As Object, e As EventArgs)
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoComprasAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
Dim idCta As Integer = 0
|
|
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim IdCtaComplementaria As Integer = 0
|
|
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Total = LblTotal.ToDecimal
|
|
If Total > 0 Then
|
|
CveConceptoContable = 64
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras Anticipos", CveConceptoContable, "Fluctuación Proveedores Anticipos", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoComprasAnt.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 2, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvProveedoresAnt.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
'si es pérdida o ganancia
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString.ToEntero()
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 2, CveBitacora, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnGeneraComprasAnt.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "FLUCTUACION VENTAS"
|
|
|
|
Protected Sub BtnGeneraVentas_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Total As Decimal = 0
|
|
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim IdCtaComplementaria As Integer = 0
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
''
|
|
|
|
Total = LblTotalVentas.Text.ToDecimal
|
|
If Total < 0 Then
|
|
CveConceptoContable = 64
|
|
CveCuenta = CveCuentaGanancia
|
|
TipoMovto = True
|
|
idCta = IdCtaGanancia
|
|
Else
|
|
CveConceptoContable = 65
|
|
CveCuenta = CveCuentaPerdida
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
If Total = 0 Then
|
|
Alert("El Importe tiene que ser diferente a cero", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoVentas.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 3, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveConconceptoCliente As Integer = 203
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvVentas.Rows
|
|
Total = -gvr.DataKey("Fluctuacion").ToDecimal
|
|
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
|
|
|
If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then
|
|
CveConconceptoCliente = 226
|
|
Else
|
|
CveConconceptoCliente = 203
|
|
End If
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(gvr.DataKey("CveVenta").ToEntero, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnGeneraVentas.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub BtnClientesAnticipos_Click(sender As Object, e As EventArgs)
|
|
Dim Total As Decimal = 0
|
|
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim IdCtaComplementaria As Integer = 0
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
''
|
|
|
|
Total = LblTotalVentasAnt.Text.ToDecimal
|
|
If Total < 0 Then
|
|
CveConceptoContable = 64
|
|
CveCuenta = CveCuentaGanancia
|
|
TipoMovto = True
|
|
idCta = IdCtaGanancia
|
|
Else
|
|
CveConceptoContable = 65
|
|
CveCuenta = CveCuentaPerdida
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
If Total = 0 Then
|
|
Alert("El Importe tiene que ser diferente a cero", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoVentasAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentasAnt.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 4, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveConconceptoCliente As Integer = 203
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvClientesAnt.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
|
|
|
If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then
|
|
CveConconceptoCliente = 226
|
|
Else
|
|
CveConconceptoCliente = 203
|
|
End If
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(gvr.DataKey("CveVenta").ToEntero, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnClientesAnticipos.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "FLUCTUACION ACREEDORES"
|
|
|
|
Protected Sub BtnGeneraAcreedores_Click(sender As Object, e As EventArgs)
|
|
RegistraFluctuacionAcreedores()
|
|
End Sub
|
|
|
|
Private Sub RegistraFluctuacionAcreedores(Optional Anticipos As Boolean = False)
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim CveCuentaComplementaria As Integer = 55206
|
|
Dim IdCtaComplementaria As Integer = 1081
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Total = LblTotalAcreedores.Text.ToDecimal
|
|
If Total < 0 Then
|
|
CveConceptoContable = 64
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 5, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvAcreedores.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
'si es pérdida o ganancia
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnGeneraAcreedores.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnGeneraAcreedoresAnt_Click(sender As Object, e As EventArgs)
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedoresAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim CveCuentaComplementaria As Integer = 55206
|
|
Dim IdCtaComplementaria As Integer = 1081
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
|
|
Total = LblTotalAcreedoresAnt.Text.ToDecimal
|
|
If Total > 0 Then
|
|
CveConceptoContable = 64
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores Anticipos ", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreeedoresAnt.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 6, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveBitacora <= 0 Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvAcreedoresAnt.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
'si es pérdida o ganancia
|
|
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 6, CveBitacora, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
BtnGeneraAcreedoresAnt.Visible = False
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
Alert("Error al generar la fluctuación", TipoMensaje.MsgError)
|
|
End If
|
|
Conta.Dispose()
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "FLUCTUACION BANCOS"
|
|
|
|
Protected Sub BtnGeneraBancos_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Conta.IniciaTransacSQL()
|
|
Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContPaq.IniciaTransacSQL()
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim ErrorRegistrar As Boolean = False
|
|
Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal
|
|
Dim MesTCtexto As String = String.Format("{0} TC:{1}", FechaUltimoDiaMes.ToString("MMMM-yyyy"), TCCierreFluctuacion)
|
|
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
CveCuentaPerdida = 0 ' 55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
Total = LblTotalBancos.Text.ToDecimal
|
|
|
|
Dim CveConconceptoBancos As Integer = 204
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvCuentas.Rows
|
|
Dim cb As CheckBox = gvr.FCCheckBox("ChkGenerarBancos")
|
|
If cb.Checked Then
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
Dim IdCtaComplementaria As Integer = gvr.DataKey("IdCtaAfectable").ToEntero
|
|
Dim ConceptoReferencia As String = String.Format("{0} - {1} {2}", gvr.DataKey("Banco"), gvr.DataKey("NumCuenta"), MesTCtexto)
|
|
|
|
|
|
'MOVIMIENTO DE FLUCTUACION
|
|
If Total > 0 Then
|
|
CveConceptoContable = 64
|
|
CveCuenta = CveCuentaGanancia
|
|
TipoMovto = True
|
|
idCta = IdCtaGanancia
|
|
Else
|
|
CveConceptoContable = 65
|
|
CveCuenta = CveCuentaPerdida
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovto, Math.Abs(Total), ConceptoReferencia, CveConconceptoBancos, ConceptoReferencia, Now, IdCtaComplementaria, 0, TipoCambio:=TC, ImporteMX:=Math.Abs(Total), ImporteME:=Math.Abs(Total)) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoReferencia, CveConceptoContable, ConceptoReferencia, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubproyectoBancos.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Dim SeContabilizo As Boolean = False
|
|
|
|
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
|
If AutoConta Then
|
|
If Conta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
|
SeContabilizo = True
|
|
Else
|
|
ErrorRegistrar = True
|
|
Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorRegistrar And SeContabilizo Then
|
|
|
|
Conta.Commit()
|
|
ObjContPaq.Commit()
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
CargaDatosCuentas()
|
|
Else
|
|
Conta.RollBack()
|
|
ObjContPaq.Dispose()
|
|
End If
|
|
Conta.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "FLUCTUACION DEUDOR"
|
|
|
|
Protected Sub BtnGeneraDedudores_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaDD", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoDeudores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal
|
|
|
|
Total = LblTotalAcreedores.Text.ToDecimal
|
|
Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes)
|
|
|
|
Dim CveConconceptoDeudores As Integer = 256
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvDeudores.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal.RoundSQL
|
|
|
|
If gvr.DataKey("CveIE").ToEntero = 0 Then
|
|
If Total > 0 Then
|
|
CveConceptoContable = 64
|
|
CveCuenta = CveCuentaGanancia
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
CveCuenta = CveCuentaPerdida
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoFluctuacion, CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoDeudores.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
Dim IdCtaComplementaria As Integer = gvr.DataKey("IdCtaAfectable").ToEntero
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovto, Math.Abs(Total), ConceptoFluctuacion, CveConconceptoDeudores, ConceptoFluctuacion & gvr.DataKey("RazonSocial"), Now, IdCtaComplementaria, 0, TipoCambio:=TC, ImporteMX:=Math.Abs(Total), ImporteME:=Math.Abs(Total)) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
'actualizar el TC del IE, al nuevo TC de la fluctuación
|
|
Banco.UpdateBancosTipoCambioValuacion(TCCierreFluctuacion, gvr.DataKey("CveIE").ToEntero, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorRegistrar Then
|
|
Conta.Commit()
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
End If
|
|
Conta.Dispose()
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "FLUCTUACION FILIALES"
|
|
|
|
Protected Sub BtnGeneraFiliales_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Total As Decimal = 0
|
|
Dim Conta As New ClsContabilidad
|
|
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
|
Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContPaq.IniciaTransacSQL()
|
|
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim idCta As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaPerdida, CveCuentaGanancia As Integer
|
|
Dim idCtaPerdida, IdCtaGanancia As Integer
|
|
Dim TipoMovto As Boolean = False
|
|
Dim CveConceptoContable As Integer = 0
|
|
Dim CveCuentaComplementaria As Integer = 55201
|
|
Dim IdCtaComplementaria As Integer = 1274
|
|
Dim ErrorRegistrar As Boolean = False
|
|
|
|
CveCuentaPerdida = 0 '55379
|
|
CveCuentaGanancia = 0 ' 55382
|
|
idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227
|
|
IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230
|
|
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
|
|
Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal
|
|
|
|
Total = LblTotalAcreedores.Text.ToDecimal
|
|
Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes)
|
|
|
|
'saco las cuentas de pérdida y ganancia
|
|
For Each gvr As GridViewRow In GvFiliales.Rows
|
|
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
|
'si es pérdida o ganancia
|
|
|
|
'cuando es acumulado, SOLO REGISTRA
|
|
If gvr.DataKey("CveIE").ToEntero = 0 Then
|
|
If Total < 0 Then
|
|
CveConceptoContable = 64
|
|
CveCuenta = CveCuentaGanancia
|
|
idCta = IdCtaGanancia
|
|
TipoMovto = True
|
|
Else
|
|
CveConceptoContable = 65
|
|
CveCuenta = CveCuentaPerdida
|
|
idCta = idCtaPerdida
|
|
TipoMovto = False
|
|
End If
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoFluctuacion, CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoFiliales.SelectedValue.ToEntero) Then
|
|
ErrorRegistrar = True
|
|
End If
|
|
|
|
'movimiento de complementaria
|
|
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovto, Math.Abs(Total), ConceptoFluctuacion, 202, ConceptoFluctuacion & gvr.DataKey("RazonSocial"), Now, IdCtaComplementaria, 0, TipoCambio:=TC, ImporteMX:=Math.Abs(Total), ImporteME:=Math.Abs(Total), CveCuenta:=CveCuentaComplementaria) Then
|
|
ErrorRegistrar = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
'actualizar el TC del IE, al nuevo TC de la fluctuación
|
|
Banco.UpdateBancosTipoCambioValuacion(TCCierreFluctuacion, gvr.DataKey("CveIE").ToEntero, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
|
|
|
|
|
|
Next
|
|
|
|
If Not ErrorRegistrar Then
|
|
|
|
'Inicio auto conta
|
|
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
|
If AutoConta Then
|
|
|
|
If Conta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
|
Else
|
|
Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
|
|
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
|
'Fin autoconta
|
|
Conta.Commit()
|
|
|
|
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Conta.RollBack()
|
|
ObjContPaq.RollBack()
|
|
End If
|
|
Conta.Dispose()
|
|
Banco.Dispose()
|
|
ObjContPaq.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEWS"
|
|
|
|
|
|
Protected Sub GvCuentas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCuentas.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
'TipoCambio = e.Row.DBCampo("TipoCambio").ToString.ToDouble
|
|
'e.Row.FCLabel("LbTipoCambioActual").Text = TipoCambioActual.ToString
|
|
'e.Row.FCLabel("LbTipoCambio").Text = If(TipoCambio > 0, TipoCambio.ToString, "No hay TipoCambio")
|
|
'e.Row.FCLabel("LbFluctuacion").Text = If(TipoCambio > 0, ((TipoCambio - TipoCambioActual) * e.Row.DBCampo("Saldo").ToString.ToDouble).ToString, "No aplica")
|
|
|
|
If Not e.Row.DBCampo("IdCtaContable").ToString.ToEntero > 0 Then
|
|
' e.Row.FCLabel("LabelBanco").ForeColor = Drawing.Color.Red
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GvFiliales_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFiliales.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("CveIE").ToString.ToEntero = 0 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("CveIE").ToString.ToEntero = 0 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
Protected Sub BtnProveedoresRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorCvePrePoliza.Value.ToEntero, 1, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnProveedoresRemove.visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnProveedoresAntRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorAntCvePrePoliza.Value.ToEntero, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnProveedoresAntRemove.Visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnClientesRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteCvePrePoliza.Value.ToEntero, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnClientesRemove.Visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnClientesAntRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteAntCvePrePoliza.Value.ToEntero, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnClientesAntRemove.Visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnAcreedoresRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorCvePrePoliza.Value.ToEntero, 5, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnAcreedoresRemove.Visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnAcreedoresAntRemove_Click(sender As Object, e As EventArgs)
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
|
|
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorAntCvePrePoliza.Value.ToEntero, 6, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Banco.Commit()
|
|
BtnAcreedoresAntRemove.Visible = False
|
|
Alert("Flucturación eliminada.")
|
|
Else
|
|
Banco.RollBack()
|
|
End If
|
|
Banco.Dispose()
|
|
End Sub
|
|
|
|
#Region " EXPORTA EXCEL "
|
|
Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
Dim StrFiltro As New StringBuilder
|
|
'If DdlProveedor.SelectedValue.ToEntero > 0 Then
|
|
StrFiltro.AppendFormat("Filtro: ", DdlMes.SelectedItem.ToString)
|
|
StrFiltro.AppendFormat("{0} ", DdlMes.SelectedItem.ToString)
|
|
StrFiltro.AppendFormat("{0} ", DdlAnio.SelectedValue)
|
|
StrFiltro.AppendFormat("TC: {0}", LtTipoCambioActual.Text)
|
|
|
|
If (T.ActiveTabIndex = 0) Then
|
|
'GvProveedores.ExportToExcelGembox("FluctuacionCambiariaProveedores_" & Now.ToShortDateString)
|
|
GvProveedores.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Proveedores", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 1) Then
|
|
GvProveedoresAnt.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Proveedores Anticipos", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 2) Then
|
|
GvVentas.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Clientes", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 3) Then
|
|
GvClientesAnt.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Clientes Anticipos", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 4) Then
|
|
GvAcreedores.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Compras Acreedores", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 5) Then
|
|
GvAcreedoresAnt.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Acreedores Anticipos", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 6) Then
|
|
GvCuentas.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Bancos", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 7) Then
|
|
GvFiliales.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Filiales", DatosFiltros:=StrFiltro.ToString())
|
|
ElseIf (T.ActiveTabIndex = 8) Then
|
|
GvDeudores.ExportToExcelGembox("Fluctuacion." + T.ActiveTab.HeaderText + "." + DdlMes.SelectedItem.ToString + "." + DdlAnio.SelectedValue, UsuarioActual, "Fluctuación Cambiaria - Deudores", DatosFiltros:=StrFiltro.ToString())
|
|
End If
|
|
|
|
' ImprimirReportePdf("Excel")
|
|
End Sub
|
|
|
|
|
|
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|