Files
SIG/Bancos/RepIngresosPorComprobar.aspx.vb

313 lines
12 KiB
VB.net

Imports System.Data
Imports Extensiones
Partial Class Bancos_RepIngresosPorComprobar
Inherits ClsPaginas
Private Property DtDatos As DataTable
Get
Return CType(ViewState("DtDatos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDatos") = value
End Set
End Property
Private Property DtAnticipos As DataTable
Get
Return CType(ViewState("DtAnticipos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAnticipos") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
If EsWS Then
DdlClientes.setEsWebService(True)
Else
DdlClientes.setEsWebService(False)
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
DdlClientes.DataBind()
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
If UsuarioActual.TienePermisoProceso(91) Then
DdlUsuarioRegistro.DataSource = GlobalDTUsuarios.FiltraParametros(String.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa), "Nombre") 'GlobalDTUsuarioResponsable.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlUsuarioRegistro.DataBind()
DdlUsuarioRegistro.Items.Insert(0, New ListItem("Todos", "-1"))
Else
DdlUsuarioRegistro.DataSource = GlobalDTUsuarios(UsuarioActual.CveUsuario)
DdlUsuarioRegistro.DataBind()
End If
DdlMoneda.DataSource = GlobalDTMonedas
DdlMoneda.DataBind()
TxtFecha.Text = NowADS().ToShortDateString
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
Dim Mov As New ClsMovimientos
Dim FechaI, FechaF As String
If txtFechaI.Text <> "" Then FechaI = txtFechaI.Text Else FechaI = "-1"
If txtFechaF.Text <> "" Then FechaF = txtFechaF.Text Else FechaF = "-1"
Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero)
If Mov.GetIngresosPorComprobar(FechaI, FechaF, CveCliente, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, If(ChkSaldo.Checked, 1, 0), UsuarioActual.CveEmpresa) Then
DtDatos = Mov.DtResultados
CargaGrid("")
UPDatos.Update()
End If
If Mov.GetIngresosAnticiposPorComprobar(FechaI, FechaF, CveCliente, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, If(ChkSaldo.Checked, 1, 0), UsuarioActual.CveEmpresa) Then
DtAnticipos = Mov.DtResultados
CargaGrid("")
UpAnt.Update()
End If
Mov.Dispose()
End Sub
Protected Sub BtnCargarProveedores_Click(sender As Object, e As System.EventArgs) Handles BtnCargarClientes.Click
Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
If EsWS Then
DdlClientes.setEsWebService(True)
Else
DdlClientes.setEsWebService(False)
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
DdlClientes.DataBind()
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
'DdlClientes.CssClass += " select2me"
'DdlClientes.Items.Clear()
'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
'DdlClientes.DataBind()
'DdlClientes.Items.Insert(0, New ListItem("Todos", "-1"))
'DdlClientes.Attributes.Remove("onclick")
End Sub
Protected Sub GvIPC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIPC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveCliente") = "" Then
'e.Row.BackColor = Drawing.Color.LightGray
' e.Row.FCHyperLink("ImgAbonar").Visible = False
e.Row.FCHyperLink("Hpl").NavigateUrl = ""
e.Row.FCHyperLink("Hpl").Font.Bold = True
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
End If
If e.Row.RowIndex = 1 Then
e.Row.Cells(1).Width = Unit.Pixel(520)
e.Row.Cells(2).Width = Unit.Pixel(50)
e.Row.Cells(3).Width = Unit.Pixel(100)
e.Row.Cells(4).Width = Unit.Pixel(150)
e.Row.Cells(6).Width = Unit.Pixel(100)
End If
'Sustituido 3-5 lineas mas abajo
'If e.Row.DBCampo("FechaDocumento") = "" Then e.Row.BackColor = Drawing.Color.LightGray
'CUANDO ES SUBTITULO
If e.Row.DBCampo("CveIE") = "" Then
If e.Row.DBCampo("CveMoneda") = "" Then
e.Row.CssClass = "SubTotales2 !important"
Else
'e.Row.CssClass = "SubTotales"
e.Row.FCLiteral("LtMoneda").Visible = True
e.Row.FCHyperLink("Hpl").Visible = False
End If
End If
'LINK A IE
If e.Row.DBCampo("Folio") <> "" Then
e.Row.FCHyperLink("HLFolio").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
End If
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(1).ForeColor = Drawing.Color.Red
End If
End Sub
Protected Sub GvAnt_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAnt.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveCliente") = "" Then
'e.Row.BackColor = Drawing.Color.LightGray
' e.Row.FCHyperLink("ImgAbonar").Visible = False
e.Row.FCHyperLink("Hpl").NavigateUrl = ""
e.Row.FCHyperLink("Hpl").Font.Bold = True
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
End If
If e.Row.RowIndex = 1 Then
e.Row.Cells(1).Width = Unit.Pixel(520)
e.Row.Cells(2).Width = Unit.Pixel(50)
e.Row.Cells(3).Width = Unit.Pixel(100)
e.Row.Cells(4).Width = Unit.Pixel(150)
End If
'Sustituido 3-5 lineas mas abajo
'If e.Row.DBCampo("FechaDocumento") = "" Then e.Row.BackColor = Drawing.Color.LightGray
'CUANDO ES SUBTITULO
If e.Row.DBCampo("CveVenta") = "" Then
If e.Row.DBCampo("CveMoneda") = "" Then
e.Row.CssClass = "SubTotales2 !important"
Else
'e.Row.CssClass = "SubTotales"
e.Row.FCLiteral("LtMoneda").Visible = True
e.Row.FCHyperLink("Hpl").Visible = False
End If
End If
''LINK A IE
'If e.Row.DBCampo("Folio") <> "" Then
' e.Row.FCHyperLink("HLFolio").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
'End If
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(1).ForeColor = Drawing.Color.Red
End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CargaDatos()
End Sub
Private Sub CargaGrid(Orden As String)
GvIPC.DataSource = DtDatos.FiltraParametros("CveCliente IS NOT NULL", Orden)
GvIPC.DataBind()
GvAnt.DataSource = DtAnticipos.FiltraParametros("CveCliente IS NOT NULL", Orden)
GvAnt.DataBind()
End Sub
#Region "O R D E N A M I E N T O"
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Orden As String = ""
Dim Campo As String = ""
Dim gvi As Integer = 0
Dim Literal As Literal = Nothing
Const OrdenInicial As String = ""
Dim Arg(2) As String
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
Campo = Arg(0)
gvi = Arg(1).ToEntero
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
Campo = Campo.Substring(0, Campo.Length - 1)
If ViewState(String.Format("O{0}", Campo, gvi)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo, gvi)).ToString = String.Format("{0} DESC", Campo) Then
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
Else
ViewState(String.Format("O{0}", Campo, gvi)) = String.Format("{0} DESC", Campo)
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
End If
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo, gvi)).ToString
ViewState("Orden") = Orden
' CargaGv(Orden, gvi)
End Sub
#End Region
#Region "SALDAR"
Private Sub LnkHabilitarSaldar_Click(sender As Object, e As EventArgs) Handles LnkHabilitarSaldar.Click
For Each gr As GridViewRow In GvIPC.Rows
If gr.DataKey("CveIE") <> "" Then
gr.FCCheckBox("Chk").Visible = True
LnkSaldar.Visible = True
LnkHabilitarSaldar.Visible = False
portletBody.Attributes.Remove("style")
portletBody.Attributes.Add("style", "display: block;")
HExtensorFiltro.Attributes.Remove("class")
HExtensorFiltro.Attributes.Add("class", "collapse")
UPFiltros.Update()
UPDatos.Update()
End If
Next
DdlSubProyectoSaldar.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlSubProyectoSaldar.DataBind()
UPModalSaldar.Update()
End Sub
Protected Sub LnkSaldar_Click(sender As Object, e As EventArgs)
RegistraScript("$('#DivModalSaldar').modal();")
End Sub
#End Region
Protected Sub BtnSaldar_Click(sender As Object, e As EventArgs)
Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL()
Dim CvePrePoliza As Integer = 0
Dim MsgError As String = ""
CvePrePoliza = ObjConta.AddPrePolizas("Bancos/RepIngresosPorComprobar", 6, 0, 0, 1, TxtFecha.Text.ToDate, "Saldo de IxC", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
For Each gr As GridViewRow In GvIPC.Rows
If gr.FCCheckBox("Chk").Checked Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, gr.DataKey("Saldo").ToDecimal, gr.DataKey("Saldo").ToDecimal, 92, "", "Saldo de IxC", CveIE:=gr.DataKey("CveIE").ToEntero, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveSubProyecto:=DdlSubProyectoSaldar.SelectedValue.ToEntero) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, gr.DataKey("Saldo").ToDecimal, gr.DataKey("Saldo").ToDecimal, 78, "", "Saldo de IxC", CveIE:=gr.DataKey("CveIE").ToEntero, CveSubProyecto:=DdlSubProyectoSaldar.SelectedValue.ToEntero) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
Next
If MsgError = "" Then
ObjConta.Commit()
CargaDatos()
Alert(String.Format("Los movimientos se saldaron correctamente.</br> <br/>Póliza: <b> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}' class='Texto' target='_blank'>{1}</a><br/>", CvePrePoliza, ObjConta.ContaFolio))
Else
ObjConta.RollBack()
Alert(MsgError, TipoMensaje.MsgError)
End If
LnkSaldar.Visible = False
LnkHabilitarSaldar.Visible = True
UpAcciones.Update()
UPFiltros.Update()
ObjConta.Dispose()
RegistraScript("$('#DivModalSaldar').modal('hide');")
End Sub
End Class