Files
SIG/Contabilidad/RegPoliza.aspx.vb
2019-10-25 13:13:35 -07:00

1906 lines
92 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
'Imports System.Activities.Statements
'Imports msExcel = Microsoft.Office.Interop.Excel
'Imports VBIDE
Partial Class RegPoliza
Inherits ClsPaginas
Private Shared missing As Object = System.Reflection.Missing.Value
'Dim RemoveMovimientos As New ArrayList()
#Region "P R O P E R T Y"
Private Property NumRow As Integer
Private Property IDPoliza As Integer
Get
Return CType(ViewState("IDPoliza"), Integer)
End Get
Set(value As Integer)
ViewState("IDPoliza") = value
End Set
End Property
Private Property CvePrePoliza As Integer
Get
Return CType(ViewState("CvePrePoliza"), Integer)
End Get
Set(value As Integer)
ViewState("CvePrePoliza") = value
End Set
End Property
Private Property Opcion As String
Get
Return CType(ViewState("Opcion"), String)
End Get
Set(value As String)
ViewState("Opcion") = value
End Set
End Property
Private Property RemoveMovimientos As New ArrayList()
' Get
' Return CType(ViewState("RemoveMovimientos"), ArrayList())
' End Get
' Set(value As ArrayList())
' ViewState("RemoveMovimientos") = value
' End Set
'End Property
Private Property TmpDT As DataTable
Get
Return CType(ViewState("TmpDT"), DataTable)
End Get
Set(value As DataTable)
ViewState("TmpDT") = value
End Set
End Property
Private Property DTCuentas As DataTable
Get
Return CType(ViewState("DTCuentas"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTCuentas") = value
End Set
End Property
Private Property DTSegmentosNegocio As DataTable
Get
Return CType(ViewState("DTSegmentosNegocio"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTSegmentosNegocio") = value
End Set
End Property
Private Property DtDevoluciones As DataTable
Get
DtDevoluciones = DirectCast(ViewState("DtDevoluciones"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtDevoluciones") = value
End Set
End Property
Private Property DtProveedoresConta As DataTable
Get
DtProveedoresConta = DirectCast(ViewState("DtProveedoresConta"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtProveedoresConta") = value
End Set
End Property
Private Property drParametros As DataRow
Get
drParametros = If(ViewState("drParametros") IsNot Nothing AndAlso DirectCast(ViewState("drParametros"), DataTable).Rows.Count > 0, DirectCast(ViewState("drParametros"), DataTable).Rows(0), Nothing)
End Get
Set(value As DataRow)
ViewState("drParametros") = value.Table
End Set
End Property
Private Property UsaMonedaExtranjera As Boolean
Get
UsaMonedaExtranjera = CBool(ViewState("UsaMonedaExtranjera"))
End Get
Set(value As Boolean)
ViewState("UsaMonedaExtranjera") = value
End Set
End Property
Private Property FechaPolizaOld As String
Get
Return CType(ViewState("FechaPolizaOld"), String)
End Get
Set(value As String)
ViewState("FechaPolizaOld") = value
End Set
End Property
Private Property TipoPolizaOld As String
Get
Return CType(ViewState("TipoPolizaOld"), String)
End Get
Set(value As String)
ViewState("TipoPolizaOld") = value
End Set
End Property
Private Property ConceptoOld As String
Get
Return CType(ViewState("ConceptoOld"), String)
End Get
Set(value As String)
ViewState("ConceptoOld") = value
End Set
End Property
Private Property DT As DataTable
Get
Return CType(ViewState("DT"), DataTable)
End Get
Set(value As DataTable)
ViewState("DT") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.LoadComplete
If Not IsPostBack Then
ViewState("Orden0") = ""
ViewState("Orden1") = ""
CvePrePoliza = -1
Me.Form.DefaultButton = BtnConsultar.UniqueID
TxtFecha.Text = Now.ToShortDateString
TxtFechaPoliza.Text = Now.ToShortDateString
If UsuarioActual.Empresa.UsaAC Then
Else
tdPolizaComplementaria.Visible = True
End If
If UsuarioActual.Empresa.UsaContabilidad Then
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetTiposPoliza(-1, "-1") Then
DdlTipo.DataSource = ObjConta.DtResultados
DdlTipo.DataBind()
DdlTipoPoliza.DataSource = ObjConta.DtResultados
DdlTipoPoliza.DataBind()
End If
If ObjConta.GetCuentas(-1, "-1", 1) Then
DTCuentas = ObjConta.DtResultados
End If
If ObjConta.GetSegmentosNegocio(-1, "-1") Then
DTSegmentosNegocio = ObjConta.DtResultados
Dim dr As DataRow = DTSegmentosNegocio.NewRow
dr("Id") = "0"
dr("Codigo") = ""
dr("Nombre") = ""
DTSegmentosNegocio.Rows.InsertAt(dr, 0)
DdlSegNeg.DataSource = DTSegmentosNegocio
DdlSegNeg.DataBind()
End If
If ObjConta.GetParametros() Then
If ObjConta.DtResultados IsNot Nothing AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
drParametros = ObjConta.DtResultados.Rows(0)
'vienen datos agruapdos ejemplo 'SSSSSSNNNNSSSSSS, Y un digito significa una opcion
UsaMonedaExtranjera = drParametros("ParFunc").ToString.Substring(5, 1) = "S"
If UsaMonedaExtranjera Then
GvDatos.Columns(5).Visible = True
GvDatos.Columns(6).Visible = True
td1CargoME.Visible = True
td1AbonoME.Visible = True
td2CargoME.Visible = True
td2AbonoME.Visible = True
End If
End If
End If
ObjConta.Dispose()
Else
Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia)
BtnConsultar.Enabled = False
BtnGuardar.Visible = False
BtnNuevo.Visible = False
LbAgregar.Enabled = False
HlAgregarExcel.Visible = False
HLImprimir.Visible = False
LBDevIVA.Visible = False
LBCauIVA.Visible = False
End If
LblAbono.Text = "0.00"
LblCargo.Text = "0.00"
If TmpDT Is Nothing Then CreaDTRegPoliza()
If Request("IdPoliza") IsNot Nothing AndAlso Request("IdPoliza").ToEntero() > 0 Then
ChkPolizaComplementaria.Enabled = False
IDPoliza = Request("IdPoliza").ToEntero()
'CveEmpresa = Request("CveEmpresa").ToEntero()
'ViewState("Empresa") = If(Request("Empresa") IsNot Nothing, Request("Empresa"), EmpresaActual)
limpia()
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString <> "" Then
Opcion = Request("Opcion").ToString
End If
'btnImprimir.OnClientClick = "javascript:PrintPoliza('/Direccion/EdosFinancieros/PopUpImpPoliza.aspx?Empresa=" & Request("Empresa") & "&IdPoliza=" & Request("IdPoliza") & "', 900, 800); return false;"
If Opcion = "Com" Then
CargaPolizaComplementaria(IDPoliza)
Else
CargaDatos(IDPoliza, -1, -1, -1, -1)
tdPolizaComplementaria.Visible = False
End If
Else
TxtFechaPoliza.Text = Date.Now.ToShortDateString
IDPoliza = -1
End If
If UsuarioActual.Empresa.UsaAC Then
LBDevIVA.Visible = False
PnlDevIVA.Visible = False
End If
End If
End Sub
#Region "C A R G A - V A L O R E S"
Private Sub CreaDTRegPoliza()
TmpDT = New DataTable
Dim column As DataColumn = New DataColumn("IdConsec", GetType(Integer))
With column
.AutoIncrement = True
.AutoIncrementSeed = 1
.AutoIncrementStep = 1
End With
TmpDT.Columns.Add(column)
TmpDT.Columns.Add("Id", GetType(Integer))
TmpDT.Columns.Add("NumMovto", GetType(Integer))
TmpDT.Columns.Add("Referencia", GetType(String))
TmpDT.Columns.Add("IdCuenta", GetType(Integer))
TmpDT.Columns.Add("CuentaFormato", GetType(String))
TmpDT.Columns.Add("Cuenta", GetType(String))
TmpDT.Columns.Add("CtaCodigo", GetType(String))
TmpDT.Columns.Add("IdSegNeg", GetType(Integer))
TmpDT.Columns.Add("SegNeg", GetType(String))
TmpDT.Columns.Add("Concepto", GetType(String))
TmpDT.Columns.Add("Cargo", GetType(Double))
TmpDT.Columns.Add("Abono", GetType(Double))
TmpDT.Columns.Add("CargoME", GetType(Double))
TmpDT.Columns.Add("AbonoME", GetType(Double))
TmpDT.Columns.Add("Estado", GetType(String))
TmpDT.Columns.Add("Folio", GetType(Integer))
TmpDT.Columns.Add("SIGReferencia", GetType(String))
End Sub
#End Region
#Region "G R I D - V I E W"
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
GvDatos.EditIndex = -1
CargaGrid()
'upDatos.Update()
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.Cells(0).Width = Unit.Percentage(5) '.Pixel(50) 'No 43
'e.Row.Cells(1).Width = Unit.Percentage(5) '.Pixel(50) 'Referencia 90
'e.Row.Cells(2).Width = Unit.Percentage(25) '.Pixel(200) 'Cuenta 230
'e.Row.Cells(3).Width = Unit.Percentage(5) '.Pixel(50) 'SegNeg 90
'e.Row.Cells(4).Width = Unit.Percentage(20) '.Pixel(200) 'Nombre/Concepto 250
'e.Row.Cells(5).Width = Unit.Percentage(10) '.Pixel(100) 'Cargo 80
'e.Row.Cells(6).Width = Unit.Percentage(10) '.Pixel(100) 'Abono 80
'e.Row.Cells(7).Width = Unit.Percentage(10) '.Pixel(150) 'Editar 100
'e.Row.Cells(8).Width = Unit.Percentage(10) '.Pixel(50) 'Eliminar 50
If e.Row.RowIndex <= 4 Then 'mayor a cero, por si borran los primeros 3 renglones que se conserve el ancho
LblAbono.Text = TmpDT.FiltraParametros("Estado<>'D'").SUM("Abono").FormatoNumero
LblCargo.Text = TmpDT.FiltraParametros("Estado<>'D'").SUM("Cargo").FormatoNumero
LblDiferencia.Text = (LblCargo.Text.Trim.ToDouble - LblAbono.Text.Trim.ToDouble).FormatoNumero
End If
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(2).Style.Add("text-align", "left")
If e.Row.DBCampo("Cargo") = "0" AndAlso e.Row.FCLiteral("LtlCargo") IsNot Nothing Then e.Row.FCLiteral("LtlCargo").Text = ""
If e.Row.DBCampo("Abono") = "0" AndAlso e.Row.FCLiteral("LtlAbono") IsNot Nothing Then e.Row.FCLiteral("LtlAbono").Text = ""
If e.Row.DBCampo("CargoME") = "0" AndAlso e.Row.FCLiteral("LtlCargoME") IsNot Nothing Then e.Row.FCLiteral("LtlCargoME").Text = ""
If e.Row.DBCampo("AbonoME") = "0" AndAlso e.Row.FCLiteral("LtlAbonoME") IsNot Nothing Then e.Row.FCLiteral("LtlAbonoME").Text = ""
If e.Row.DBCampo("Cargo").ToDouble < 0 AndAlso e.Row.FCLiteral("LtlCargo") IsNot Nothing Then e.Row.FCLiteral("LtlCargo").Text = String.Format("<span style='color:red;'>{0}</span>", e.Row.DBCampo("Cargo").FormatoNumero())
If e.Row.DBCampo("Abono").ToDouble < 0 AndAlso e.Row.FCLiteral("LtlAbono") IsNot Nothing Then e.Row.FCLiteral("LtlAbono").Text = String.Format("<span style='color:red;'>{0}</span>", e.Row.DBCampo("Abono").FormatoNumero())
If e.Row.DBCampo("Estado").ToString.Trim = "D" Then e.Row.Visible = False
e.Row.FCLiteral("LtlNo").Text = (e.Row.RowIndex + 1).ToString ' e.Row.DBCampo("IdConsec") '
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
e.Row.FCDropDownList("DdlCuenta").DataSource = DTCuentas
e.Row.FCDropDownList("DdlCuenta").DataBind()
e.Row.FCDropDownList("DdlCuenta").SelectedValue = e.Row.DBCampo("IdCuenta")
e.Row.FCDropDownList("DdlSegNeg").DataSource = DTSegmentosNegocio
e.Row.FCDropDownList("DdlSegNeg").DataBind()
e.Row.FCDropDownList("DdlSegNeg").SelectedValue = e.Row.DBCampo("IdSegNeg")
e.Row.FCTextBox("TxtCargo").Text = e.Row.DBCampo("Cargo").ToString
e.Row.FCTextBox("TxtAbono").Text = e.Row.DBCampo("Abono").ToString
e.Row.FCTextBox("TxtCargoME").Text = e.Row.DBCampo("CargoME").ToString
e.Row.FCTextBox("TxtAbonoME").Text = e.Row.DBCampo("AbonoME").ToString
Else
e.Row.FCHyperLink("Ref").NavigateUrl = e.Row.DBCampo("SIGReferencia").ContaReferenciaLiga
End If
End If
End Sub
Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
Dim dr() As DataRow = TmpDT.Select(String.Format("IdConsec = {0}", e.Keys("IdConsec")))
'TmpDT.Rows.Remove(Dr(0))
dr(0)("Estado") = "D"
TmpDT.AcceptChanges()
BtnNuevo.OnClientClick = "return confirm('Se han hecho cambios que no fueron guardados, ¿Continuar?');"
CargaGrid()
End Sub
Protected Sub GvDatos_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing
GvDatos.EditIndex = e.NewEditIndex
CargaGrid()
End Sub
Protected Sub GvDatos_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
If (GvDatos.Rows(e.RowIndex).FCTextBox("TxtCargo").Text.Length = 0 AndAlso
GvDatos.Rows(e.RowIndex).FCTextBox("TxtAbono").Text.Length = 0) OrElse
(GvDatos.Rows(e.RowIndex).FCTextBox("TxtCargo").Text.Trim.ToDouble > 0 AndAlso
GvDatos.Rows(e.RowIndex).FCTextBox("TxtAbono").Text.Trim.ToDouble > 0) Then
Alert("Debes asignar un valor para CARGO o para ABONO", TipoMensaje.MsgAdvertencia)
Else
Dim dr() As DataRow = TmpDT.Select(String.Format("IdConsec = {0}", e.Keys("IdConsec")))
BtnNuevo.OnClientClick = "return confirm('Se han hecho cambios que no fueron guardados, ¿Continuar?');"
dr(0)("Referencia") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtReferencia").Text.Trim
dr(0)("IdCuenta") = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuenta").SelectedValue
dr(0)("CtaCodigo") = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuenta").SelectedItem.Text
dr(0)("CuentaFormato") = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuenta").SelectedItem.Text
dr(0)("IdSegNeg") = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlSegNeg").SelectedValue
dr(0)("SegNeg") = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlSegNeg").SelectedItem.Text
dr(0)("Concepto") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtNombreConcepto").Text.Trim
dr(0)("Cargo") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtCargo").Text.Trim.ToDouble
dr(0)("Abono") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtAbono").Text.Trim.ToDouble
dr(0)("CargoME") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtCargoME").Text.Trim.ToDouble
dr(0)("AbonoME") = GvDatos.Rows(e.RowIndex).FCTextBox("TxtAbonoME").Text.Trim.ToDouble
dr(0)("Estado") = "U"
TmpDT.AcceptChanges()
GvDatos.EditIndex = -1
CargaGrid()
End If
End Sub
Public Function WSCuentas() As String
Dim Str As New StringBuilder
Dim i As Integer = 0
Dim dt As DataTable = DTCuentas.FiltraParametros("Afectable = 1")
If dt IsNot Nothing Then
For Each dr As DataRow In dt.Rows
i += 1
Str.AppendFormat("{{value:""{0}"",label:""{1}""}}{2}", dr("Id"), dr("CtaCodigo").ToString.Replace("""", ""), If(i < dt.Rows.Count, ",", ""))
Next
End If
Return Str.ToString
End Function
#End Region
#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
CargaGridDevoluciones(Orden, gvi)
End Sub
Protected Sub CargaGridDevoluciones(Orden As String, gvi As Integer)
Dim DV As DataView = Nothing
'If gvi = 1 Then
DV = New DataView(DtDevoluciones, "", Orden, DataViewRowState.CurrentRows)
If Orden <> String.Empty Then
GvDevoluciones.DataSource = DV.ToTable()
Else
GvDevoluciones.DataSource = DtDevoluciones
End If
ViewState("Orden1") = Orden
'End If
GvDevoluciones.DataBind()
UpDevoluciones.Update()
DV.Dispose()
End Sub
#End Region
#Region "I M A G E - B U T T O N Y L I N K S"
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
limpia()
CargaDatos(-1, TxtFecha.Text.Trim.ToDate.Year, TxtFecha.Text.Trim.ToDate.Month, DdlTipo.SelectedValue.ToEntero, TxtNumero.Text.Trim.ToEntero)
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
If GvDatos.Rows.Count = 0 Then
Alert("Debe agregar movimientos a la póliza", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If LblCargo.Text.Trim.ToDouble <> LblAbono.Text.Trim.ToDouble Then
Alert("El total del CARGO debe coincidir con el total del ABONO", TipoMensaje.MsgAdvertencia)
'BtnGuardar.Attributes.Add("onClientClicked", "javascript:confirm('¿La suma de los CARGOS no coincide con la suma de los ABONOS, ¿Desea guardar la información?')")
Exit Sub
End If
BtnGuardar.OnClientClick = "FncVerifica();"
If ChkPolizaComplementaria.Checked Then
If IDPoliza < 0 Then
'GuardaPolizaComplementaria()
ElseIf HdnGuardar.Value = "" Or HdnGuardar.Value = "True" Then
'ActualizaPolizaComplementaria()
ElseIf HdnGuardar.Value = "False" Then
Alert("Los datos no se guardaron", TipoMensaje.MsgError)
End If
Else
If IDPoliza < 0 Then
GuardaPoliza()
ElseIf HdnGuardar.Value = "" Or HdnGuardar.Value = "True" Then
ActualizaPoliza()
ElseIf HdnGuardar.Value = "False" Then
Alert("Los datos no se guardaron", TipoMensaje.MsgError)
End If
End If
End Sub
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) Handles BtnNuevo.Click
DdlTipo.SelectedIndex = 0
TxtFecha.Text = ""
TxtNumero.Text = ""
TxtFechaPoliza.Text = ""
TxtNumeroPoliza.Text = ""
DdlTipoPoliza.SelectedIndex = 0
HdnFechaPoliza.Value = TxtFechaPoliza.Text
HdnFolioPoliza.Value = TxtNumeroPoliza.Text
HdnTipoPoliza.Value = DdlTipoPoliza.SelectedValue
BtnGuardar.OnClientClick = ""
BtnEliminar.Visible = False
IDPoliza = -1
'HdnIdPoliza.Value = ""
TxtConcepto.Text = ""
TxtReferencia.Text = ""
TxtCuenta.Text = ""
HdnCveCuenta.Value = ""
DdlSegNeg.SelectedIndex = 0
TxtNombreConcepto.Text = ""
TxtCargo.Text = ""
TxtAbono.Text = ""
LblCargo.Text = "0.00"
LblAbono.Text = "0.00"
'Llenagrid()
GvDatos.DataBind()
UpConsultar.Update()
upTitulos.Update()
upDatos.Update()
If TmpDT Is Nothing Then CreaDTRegPoliza() Else TmpDT.Rows.Clear()
limpia()
End Sub
'Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
' If TmpDT.Rows.Count = 0 Then
' Alert("Debe consultar una póliza antes de imprimir ...", TipoMensaje.MsgAdvertencia)
' Else
' 'GeneraPDF(Now, "Sin Timbrar", "Sin Timbrar", New Date(1, 1, 1), "Sin Timbrar", TmpDT, "Sin Timbrar", "Sin Timbrar", RutaCBB, If(LblSerie.Text.Trim = String.Empty, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim), "", True, False)
' GeneraPDF()
' End If
'End Sub
Protected Sub LBImprimir_Click(sender As Object, e As EventArgs)
'If TmpDT.Rows.Count = 0 Then
' Alert("Debe consultar una póliza antes de imprimir ...", TipoMensaje.MsgAdvertencia)
'Else
' 'GeneraPDF(Now, "Sin Timbrar", "Sin Timbrar", New Date(1, 1, 1), "Sin Timbrar", TmpDT, "Sin Timbrar", "Sin Timbrar", RutaCBB, If(LblSerie.Text.Trim = String.Empty, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim), "", True, False)
' GeneraPDF()
'End If
End Sub
Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
If HdnCveCuenta.Value.ToEntero <= 0 Then Alert("Debe de seleccionar la cuenta.", TipoMensaje.MsgAdvertencia) : TxtCuenta.Focus() : Exit Sub
If (TxtCargo.Text.Length = 0 And TxtAbono.Text.Length = 0) Or (TxtCargo.Text.Trim.ToDouble > 0 And TxtAbono.Text.Trim.ToDouble > 0) Then
Alert("Debes asignar un valor para CARGO o para ABONO", TipoMensaje.MsgAdvertencia)
Else
If TxtCargo.Text = "" Then TxtCargo.Text = "0"
If TxtAbono.Text = "" Then TxtAbono.Text = "0"
'AddRegPolizaDetalle(-1, TxtReferencia.Text, DdlCuenta.SelectedValue, DdlCuenta.SelectedItem.Text, DdlSegNeg.SelectedValue, DdlSegNeg.SelectedItem.Text, TxtNombreConcepto.Text, TxtCargo.Text.ToDouble, TxtAbono.Text.ToDouble)
'HdnCveCuenta
AddRegPolizaDetalle(-1, TxtReferencia.Text, HdnCveCuenta.Value.ToEntero, TxtCuenta.Text, DdlSegNeg.SelectedValue, DdlSegNeg.SelectedItem.Text, TxtNombreConcepto.Text, TxtCargo.Text.ToDouble, TxtAbono.Text.ToDouble)
CargaGrid()
upDatos.Update()
TxtReferencia.Focus()
'TxtReferencia.Text = ""
DdlSegNeg.SelectedIndex = 0
'TxtNombreConcepto.Text = ""
TxtCargo.Text = ""
TxtAbono.Text = ""
HdnCveCuenta.Value = ""
TxtCuenta.Text = ""
BtnNuevo.OnClientClick = "return confirm('Se han hecho cambios que no fueron guardados, ¿Continuar?')"
' RegistraScript(" $(function () { $(""#DdlCuenta"").combobox().parent().find(""input.ui-autocomplete-input"").css('width', '175px'); $(""#toggle"").click(function () { $(""#DdlCuenta"").toggle();});});")
End If
End Sub
#End Region
Private Sub CargaGrid()
GvDatos.DataBind()
GvDatos.DataSource = TmpDT '.FiltraParametros("Estado<>'D'")
GvDatos.DataBind()
LblAbono.Text = TmpDT.SUM("Abono", "Estado<>'D'").FormatoNumero
'LblCargo.Text = TmpDT.SUM("Cargo,Estado<>'D'").FormatoNumero
LblCargo.Text = TmpDT.SUM("Cargo", "Estado<>'D'").FormatoNumero
LblDiferencia.Text = (LblCargo.Text.Trim.ToDouble - LblAbono.Text.Trim.ToDouble).FormatoNumero
If LblDiferencia.Text.ToDouble >= 0 Then
' BtnGuardar.OnClientClick = "return confirm('La suma de los CARGOS no coincide con la suma de los ABONOS, ¿Desea guardar la información?')"
'BtnGuardar.Enabled = False
LblDiferencia.ForeColor = Drawing.Color.Black
Else
'BtnGuardar.OnClientClick = ""
BtnGuardar.Enabled = True
LblDiferencia.ForeColor = Drawing.Color.Red
End If
End Sub
'#Region "E X C E L"
' Private Function GetMacro() As String
' Dim SB As New StringBuilder
' SB.Append(" Sub AddRow(Row As String) " & vbLf)
' SB.Append(" Rows(Row & "":"" & Row).Select " & vbLf)
' SB.Append(" Selection.Copy " & vbLf)
' SB.Append(" Selection.Insert Shift:=xlDown " & vbLf)
' SB.Append(" Rows(Row+1 & "":"" & Row+1).Select " & vbLf)
' SB.Append(" Selection.ClearContents " & vbLf)
' SB.Append(" End Sub " & vbLf)
' Return SB.ToString
' End Function
' Private Sub GeneraPDF()
' Dim Msg As New StringBuilder
' Dim Excel As msExcel.Application = New msExcel.Application()
' Dim VB_Module As VBComponent = Nothing
' Excel.Visible = True
' Excel.ScreenUpdating = True
' Excel.DisplayAlerts = True
' Dim ArchivoBase As New System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza.xlsm")
' 'ArchivoBase.CopyTo(AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".xlsm", True)
' ArchivoBase.CopyTo(AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".xlsm", True)
' 'Dim ArchivoTemp As New System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".xlsm")
' Dim ArchivoTemp As New System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".xlsm")
' Dim Libro As msExcel.Workbook = Excel.Workbooks.Open(ArchivoTemp.FullName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
' Libro.Activate()
' Dim Hoja As msExcel.Worksheet = CType(Libro.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
' Hoja.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible
' Hoja.Activate()
' VB_Module = CType(Libro.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule), VBComponent)
' VB_Module.CodeModule.AddFromString(GetMacro)
' 'Encabezado
' Hoja.Range("A1:A1").Value = UsuarioActual.Empresa.Empresa.ToString.Trim
' Hoja.Range("F2:F2").Value = "Impresión de póliza del " + TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString + " al " + TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
' Hoja.Range("K2:K2").Value = TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
' 'Linea 1 datos de la poliza
' Dim CeldaI As Integer = 9
' Dim CeldaF As Integer = 9
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Value = TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Value = DdlTipoPoliza.SelectedItem.ToString.Trim
' 'Hoja.Range("E" & CeldaF & ":E" & CeldaF).Value = LtlNumeroPoliza.Text.Trim
' Hoja.Range("E" & CeldaF & ":E" & CeldaF).Value = TxtNumeroPoliza.Text.Trim
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = TxtConcepto.Text.Trim
' CeldaF = CeldaF + 1
' 'Movimientos de la poliza Debe de haceptar 36 renglones de excel
' For Each Row As DataRow In TmpDT.Rows
' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Value = Row("NumMovto").ToString.Trim
' Hoja.Range("B" & CeldaF & ":B" & CeldaF).Value = Row("Referencia").ToString.Trim
' Hoja.Range("D" & CeldaF & ":D" & CeldaF).Value = Row("CuentaFormato").ToString.Trim
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = Row("Cuenta").ToString.Trim
' If Row("Cargo").ToString.ToDouble <> 0 Then
' Hoja.Range("J" & CeldaF & ":J" & CeldaF).Value = Row("Cargo").ToString.FormatoNumero
' End If
' If Row("Abono").ToString.ToDouble <> 0 Then
' Hoja.Range("K" & CeldaF & ":K" & CeldaF).Value = Row("Abono").ToString.FormatoNumero
' End If
' CeldaF = CeldaF + 1
' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = Row("Concepto").ToString.Trim
' CeldaF = CeldaF + 1
' Next
' Hoja.Range("J" & CeldaF & ":J" & CeldaF).Value = TmpDT.SUM("Cargo").FormatoNumero
' Hoja.Range("K" & CeldaF & ":K" & CeldaF).Value = TmpDT.SUM("Abono").FormatoNumero
' 'Exportar PDF
' 'Dim pdfFileOut As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".pdf"
' Dim pdfFileOut As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".pdf"
' Dim outputFileName As Object = pdfFileOut
' Dim fileFormat As msExcel.XlFixedFormatType = msExcel.XlFixedFormatType.xlTypePDF
' Libro.ExportAsFixedFormat(fileFormat, outputFileName, missing, missing, missing, missing, missing, missing, missing)
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Hoja)
' Hoja = Nothing
' Dim saveChanges As Object = msExcel.XlSaveAction.xlDoNotSaveChanges
' CType(Libro, msExcel._Workbook).Close(saveChanges, missing, missing)
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Libro)
' Libro = Nothing
' Excel.Quit()
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
' Excel = Nothing
' GC.Collect()
' GC.WaitForPendingFinalizers()
' ArchivoTemp.Delete()
' Dim Descargas As New StringBuilder()
' 'Descargas.AppendFormat("<li><a class=""Texto"" href=""/Empresas/{0}/Formatos/Poliza_{1}.pdf"" target=""_blank"">PDF</a></li>", UsuarioActual.CveEmpresa, LtlNumeroPoliza.Text)
' Descargas.AppendFormat("<li><a class=""Texto"" href=""/Empresas/{0}/Formatos/Poliza_{1}.pdf"" target=""_blank"">PDF</a></li>", UsuarioActual.CveEmpresa, TxtNumeroPoliza.Text)
' Alert("<br />La impresión se generó correctamente.<br /><br /><br />Descargas:<ul>" & Descargas.ToString & "</ul>", TipoMensaje.MsgInformacion)
' 'RegistraScript("AbrirVentana('/Ventas/PopUpImprimir.aspx?CveVenta=" & If(EsVistaPrevia, UsuarioActual.CveUsuario.ToString, VentaFolio) & "&Ext=PDF', 700, 400, 'N', 'ImpVenta')")
' End Sub
'#End Region
#Region " P O L I Z A S - C O M P L E M E N T A R I A S "
Private Sub CargaPolizaComplementaria(tIDPoliza As Integer)
Dim ObjPoliza As New ClsContabilidad
Dim DT As DataTable = Nothing
If ObjPoliza.GetPoliza(tIDPoliza, UsuarioActual.CveEmpresa) Then
DT = ObjPoliza.DtResultados
BtnGuardar.OnClientClick = "FncVerifica();"
ChkPolizaComplementaria.Checked = True
If DT.Rows.Count = 0 Then
TxtFechaPoliza.Text = Now.ToShortDateString
TxtNumeroPoliza.Text = ""
LblCargo.Text = ""
LblAbono.Text = ""
TxtConcepto.Text = ""
Alert("No se encontró ninguna póliza, verifique los datos.", TipoMensaje.MsgAdvertencia)
'HdnIdPoliza.Value = ""
Else
'TxtFecha.Text = ""
'TxtNumero.Text = ""
'DdlTipo.SelectedIndex = 0
Dim dr As DataRow = DT.Rows(0)
TxtFechaPoliza.Text = dr("FechaPol").ToString.ToDate.ToShortDateString
HdnFechaPoliza.Value = dr("FechaPol").ToString.ToDate.ToShortDateString
'DdlTipoPoliza.SelectedValue = dr("CodigoTipoPoliza").ToString.Trim
HdnTipoPoliza.Value = DdlTipoPoliza.SelectedValue
'LtlNumeroPoliza.Text = dr("Folio")
TxtNumeroPoliza.Text = dr("Folio").ToString
'HdnIdPoliza.Value = dr("IdPoliza").ToString 'Id de la Póliza lo da automaticamente el sistema ContPAQi
HdnFolioPoliza.Value = dr("Folio").ToString 'Folio de la poliza
TxtConcepto.Text = dr("ConceptoPoliza").ToString
HdnlCargo.Value = dr("Cargos").ToString
HdnlAbono.Value = dr("Abonos").ToString
LblCargo.Text = dr("Cargos").ToString
LblAbono.Text = dr("Abonos").ToString
LblNumPoliza.ToolTip = dr("IdPoliza").ToString
'If Math.Abs(dr("Cargos").ToString.ToDecimal - DT.SUM("Cargo")) > 0.001 OrElse Math.Abs(dr("Abonos").ToString.ToDecimal - DT.SUM("Abono")) > 0.001 Then
' Dim Str As New StringBuilder
' Str.AppendFormat("Los Totales de la póliza no coinciden con los movimientos <br>Cargos en Póliza: {0} Cargos en Movimientos: {1}<br>Abonos en Póliza: {2} Abonos en Movimientos: {3}<br>", dr("Cargos").ToString, DT.SUM("Cargo").ToString, dr("Abonos").ToString, DT.SUM("Abono").ToString)
' Alert(Str.ToString, TipoMensaje.MsgError)
'End If
'TxtFechaPoliza.AutoPostBack = True
'DdlTipoPoliza.AutoPostBack = True
'TxtNumeroPoliza.AutoPostBack = True
IDPoliza = dr("IdPoliza").ToString.ToEntero
' CargaDevoluciones()
End If
End If
ObjPoliza.Dispose()
If TmpDT Is Nothing Then CreaDTRegPoliza()
TmpDT.Clear()
If DT IsNot Nothing Then TmpDT.Merge(DT)
If LblDiferencia.Text.Trim.ToDouble <> 0 Then
Alert("Verifique los cargos y abonos de los movimientos", TipoMensaje.MsgInformacion)
ElseIf HdnlCargo.Value.ToDouble <> LblCargo.Text.ToDouble Then
Alert("El cargo de la póliza " + HdnlCargo.Value + " no coincide con la sumatoria de cargos de los movimientos", TipoMensaje.MsgInformacion)
ElseIf HdnlAbono.Value.ToDouble <> LblAbono.Text.ToDouble Then
Alert("El abono de la póliza " + HdnlAbono.Value + " no coincide con la sumatoria de abonos de los movimientos", TipoMensaje.MsgInformacion)
End If
CargaGrid()
upTitulos.Update()
upDatos.Update()
If DT IsNot Nothing Then DT.Dispose()
End Sub
'Private Sub GuardaPolizaComplementaria()
' Dim OcurrioError As Boolean = False
' Dim ObjConta As New ClsContabilidad
' ObjConta.IniciaTransacSQL()
' Dim tIdPoliza As Integer
' Dim NumPoliza As String = "-1"
' Dim Tipo As String = ""
' If TxtNumeroPoliza.Text.Trim <> "" Then
' NumPoliza = TxtNumeroPoliza.Text.Trim
' Tipo = "CHQ"
' Else
' End If
' tIdPoliza = ObjConta.AddPoliza(DdlTipoPoliza.SelectedValue.ToEntero, TxtFolio.Text.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, TxtConcepto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' If tIdPoliza > 0 Then
' 'Agrega Movimientos de la poliza
' For Each Row As DataRow In TmpDT.Rows
' If Row("Cargo").ToString.ToDecimal <> 0 Then
' If Not ObjConta.AddPolizaDetalle(tIdPoliza, Row("IdCuenta").ToString.ToEntero, Row("CuentaFormato").ToString, False,
' Row("Cargo").ToString.ToDouble, Row("Referencia").ToString, Row("Concepto").ToString,
' TxtFechaPoliza.Text.Trim.ToDate) Then
' OcurrioError = True
' End If
' Else
' If Not ObjConta.AddPolizaDetalle(tIdPoliza, Row("IdCuenta").ToString.ToEntero, Row("CuentaFormato").ToString, True,
' Row("Abono").ToString.ToDouble, Row("Referencia").ToString, Row("Concepto").ToString,
' TxtFechaPoliza.Text.Trim.ToDate) Then
' OcurrioError = True
' End If
' End If
' Next
' If OcurrioError Then
' ObjConta.RollBack()
' Alert("Ocurrió un error al guardar la póliza", TipoMensaje.MsgAdvertencia)
' Else
' Alert(String.Format("La información se guardó correctamente "), TipoMensaje.MsgInformacion)
' ObjConta.Commit()
' IDPoliza = tIdPoliza
' limpia()
' CargaPolizaComplementaria(IDPoliza)
' BtnNuevo.OnClientClick = ""
' End If
' End If
' upTitulos.Update()
' upDatos.Update()
' UpConsultar.Update()
' ObjConta.Dispose()
'End Sub
'Private Sub ActualizaPolizaComplementaria()
' Dim OcurrioError As Boolean = False
' Dim ObjConta As New ClsContabilidad
' Dim Row As DataRow
' ObjConta.IniciaTransacSQL()
' If ObjConta.UpdatePoliza(DdlTipoPoliza.SelectedValue.ToEntero, TxtNumeroPoliza.Text.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, TxtConcepto.Text.Trim, UsuarioActual.CveUsuario, IDPoliza) Then
' For Each Row In TmpDT.Rows
' If Row("Estado").ToString.Trim = "D" AndAlso Row("Id").ToString.ToEntero > 0 Then
' ObjConta.RemovePolizaDetalle(Row("Id").ToString.ToEntero)
' Else
' Dim Importe As Double = If(Row("Cargo").ToString.ToDouble <> 0, Row("Cargo"), Row("Abono")).ToString.ToDouble
' Dim TipoMovto As Boolean = Not Row("Cargo").ToString.ToDouble <> 0
' If Row("Id").ToString.ToEntero <> -1 Then
' If Not ObjConta.UpdatePolizaDetalle(Row("Id").ToString.ToEntero, Row("IdCuenta").ToString.ToEntero, If(Row("CuentaFormato").ToString <> "", Row("CuentaFormato").ToString, Row("Cuenta").ToString), TipoMovto, Importe, Row("Referencia").ToString, Row("Concepto").ToString, TxtFechaPoliza.Text.Trim.ToDate) Then
' OcurrioError = True
' End If
' Else
' If Not ObjConta.AddPolizaDetalle(IDPoliza.ToString.ToEntero, Row("IdCuenta").ToString.ToEntero, Row("CuentaFormato").ToString, TipoMovto, Importe, Row("Referencia").ToString, Row("Concepto").ToString, TxtFechaPoliza.Text.Trim.ToDate) Then
' OcurrioError = True
' End If
' End If
' End If
' Next
' If OcurrioError Then
' ObjConta.RollBack()
' Alert("Ocurrió un error al actualizar los movimientos de la póliza complementaria", TipoMensaje.MsgAdvertencia)
' Else
' Alert("La póliza se actualizó correctamente.", TipoMensaje.MsgInformacion)
' ObjConta.Commit()
' HdnFechaPoliza.Value = TxtFechaPoliza.Text.ToDate.ToShortDateString
' HdnTipoPoliza.Value = DdlTipoPoliza.SelectedValue
' CargaPolizaComplementaria(IDPoliza)
' BtnNuevo.OnClientClick = ""
' End If
' Else
' ObjConta.RollBack()
' End If
' ObjConta.Dispose()
'End Sub
#End Region
#Region "P R O C E D I M I E N T O S"
Private Sub CargaDatos(tIDPoliza As Integer, Ejercicio As Integer, Periodo As Integer, TipoPoliza As Integer, Numero As Integer)
Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
Dim ObjConta As New ClsContabilidad
'Dim DT As DataTable = Nothing
If ObjPoliza.GetPoliza(tIDPoliza, Ejercicio, Periodo, TipoPoliza, Numero) Then
DT = ObjPoliza.DtResultados
BtnGuardar.OnClientClick = "FncVerifica();"
If DT.Rows.Count = 0 Then
TxtFechaPoliza.Text = Now.ToShortDateString
TxtNumeroPoliza.Text = ""
LblCargo.Text = ""
LblAbono.Text = ""
TxtConcepto.Text = ""
Alert("No se encontró ninguna Póliza, verifique los datos.", TipoMensaje.MsgAdvertencia)
'HdnIdPoliza.Value = ""
Else
'TxtFecha.Text = ""
'TxtNumero.Text = ""
'DdlTipo.SelectedIndex = 0
Dim dr As DataRow = DT.Rows(0)
HLImprimir.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta($"OP=POL&CvePoliza={dr("IdPoliza").ToString.ToEntero}"))
HLImprimir.Visible = True
TxtFechaPoliza.Text = dr("FechaPol").ToString.ToDate.ToShortDateString
HdnFechaPoliza.Value = dr("FechaPol").ToString.ToDate.ToShortDateString
DdlTipoPoliza.SelectedValue = dr("CodigoTipoPoliza").ToString.Trim
HdnTipoPoliza.Value = DdlTipoPoliza.SelectedValue
'LtlNumeroPoliza.Text = dr("Folio")
TxtNumeroPoliza.Text = dr("Folio").ToString
'HdnIdPoliza.Value = dr("IdPoliza").ToString 'Id de la Póliza lo da automaticamente el sistema ContPAQi
HdnFolioPoliza.Value = dr("Folio").ToString 'Folio de la poliza
TxtConcepto.Text = dr("ConceptoPoliza").ToString
HdnlCargo.Value = dr("Cargos").ToString
HdnlAbono.Value = dr("Abonos").ToString
LblCargo.Text = dr("Cargos").ToString
LblAbono.Text = dr("Abonos").ToString
LblNumPoliza.ToolTip = dr("IdPoliza").ToString
'Datos para bitacora
FechaPolizaOld = TxtFechaPoliza.Text
TipoPolizaOld = DdlTipoPoliza.SelectedItem.Text
ConceptoOld = TxtConcepto.Text
CargaGvBitacora(dr("IdPoliza").ToString.ToEntero)
'If dr("Cargos").ToString <> DT.SUM("Cargo").ToString Or dr("Abonos").ToString <> DT.SUM("Abono").ToString Then
' Dim Str As New StringBuilder
' Str.AppendFormat("Los Totales de la póliza no coinciden con los movimientos <br>Cargos en Póliza: {0} Cargos en Movimientos: {1}<br>Abonos en Póliza: {2} Abonos en Movimientos: {3}<br>", dr("Cargos").ToString, DT.SUM("Cargo").ToString, dr("Abonos").ToString, DT.SUM("Abono").ToString)
' Alert(Str.ToString, TipoMensaje.MsgError)
'End If
'If Math.Abs(dr("Cargos").ToString.ToDecimal - DT.SUM("Cargo")) > 0.001 OrElse Math.Abs(dr("Abonos").ToString.ToDecimal - DT.SUM("Abono")) > 0.001 Then
' Dim Str As New StringBuilder
' Str.AppendFormat("Los Totales de la póliza no coinciden con los movimientos <br>Cargos en Póliza: {0} Cargos en Movimientos: {1}<br>Abonos en Póliza: {2} Abonos en Movimientos: {3}<br>", dr("Cargos").ToString, DT.SUM("Cargo").ToString, dr("Abonos").ToString, DT.SUM("Abono").ToString)
' Alert(Str.ToString, TipoMensaje.MsgError)
'End If
'ChkPolizaComplementaria.Visible = False
'DdlTipoPoliza.AutoPostBack = True
'TxtNumeroPoliza.AutoPostBack = True
IDPoliza = dr("IdPoliza").ToString.ToEntero
If ObjConta.GetPrePoliza(-1, UsuarioActual.CveEmpresa, IDPoliza) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
CvePrePoliza = ObjConta.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero
End If
End If
If UsuarioActual.TienePermisoProceso(145) Then
BtnEliminar.Visible = True
End If
' CargaDevoluciones()
End If
End If
ObjPoliza.Dispose()
ObjConta.Dispose()
If TmpDT Is Nothing Then CreaDTRegPoliza()
TmpDT.Clear()
If DT IsNot Nothing Then TmpDT.Merge(DT)
If LblDiferencia.Text.Trim.ToDouble <> 0 Then
Alert("Verifique los cargos y abonos de los movimientos", TipoMensaje.MsgInformacion)
ElseIf HdnlCargo.Value.ToDouble <> LblCargo.Text.ToDouble Then
Alert("El cargo de la póliza " + HdnlCargo.Value + " no coincide con la sumatoria de cargos de los movimientos", TipoMensaje.MsgInformacion)
ElseIf HdnlAbono.Value.ToDouble <> LblAbono.Text.ToDouble Then
Alert("El abono de la póliza " + HdnlAbono.Value + " no coincide con la sumatoria de abonos de los movimientos", TipoMensaje.MsgInformacion)
End If
RegistraScript("PrendeGVS();") 'Aseguramos que se cargue el gridViewScroll
CargaGrid()
upTitulos.Update()
upDatos.Update()
If DT IsNot Nothing Then DT.Dispose()
End Sub
Private Sub GuardaPoliza()
Dim OcurrioError As Boolean = False
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
ObjConta.IniciaTransacSQL()
Dim tIdPoliza As Integer
Dim NumPoliza As String = "-1"
Dim Tipo As String = ""
If TxtNumeroPoliza.Text.Trim <> "" Then
NumPoliza = TxtNumeroPoliza.Text.Trim
Tipo = "CHQ"
Else
End If
tIdPoliza = ObjConta.AddPoliza(DdlTipoPoliza.SelectedValue.ToEntero, TxtConcepto.Text.Trim, LblCargo.Text.Trim.ToDouble, LblAbono.Text.Trim.ToDouble, UsuarioActual.CveUsuario, TxtFechaPoliza.Text.Trim.ToDate, NumPoliza, Tipo)
If tIdPoliza > 0 Then
'Agrega Movimientos de la poliza
For Each Row As DataRow In TmpDT.Rows
If Row("Cargo").ToString.ToDecimal <> 0 Then
If Not ObjConta.AddMovimiento(tIdPoliza, Row("IdCuenta").ToString.ToEntero, False,
Row("Cargo").ToString.ToDouble, Row("Referencia").ToString, Row("Concepto").ToString,
Row("IdSegNeg").ToString.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, "", Row("CargoME").ToString.ToDouble) Then
OcurrioError = True
End If
Else
If Not ObjConta.AddMovimiento(tIdPoliza, Row("IdCuenta").ToString.ToEntero, True,
Row("Abono").ToString.ToDouble, Row("Referencia").ToString, Row("Concepto").ToString,
Row("IdSegNeg").ToString.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, "", Row("AbonoME").ToString.ToDouble) Then
OcurrioError = True
End If
End If
Next
If DtDevoluciones IsNot Nothing AndAlso DtDevoluciones.Rows.Count > 0 Then
'Agrega Devoluciones
For Each row As DataRow In DtDevoluciones.Rows
If Not ObjConta.AddDevolucionesIVA(tIdPoliza, row("IdCuenta").ToString.ToEntero, row("IdProveedor").ToString.ToEntero, row("Tasa").ToString.ToDouble, row("ImporteBase").ToString.ToDouble,
row("ImporteIVA").ToString.ToDouble, row("RetIVA").ToString.ToDouble, row("RetISR").ToString.ToDouble, TxtFechaPoliza.Text.ToDate, row("Referencia").ToString, row("Serie").ToString, row("Folio").ToString.ToEntero, "", UsuarioActual.CveEmpresa) Then
OcurrioError = True
End If
Next
End If
If Not OcurrioError Then
If Not ObjConta.AjustaPoliza(tIdPoliza) Then
OcurrioError = True
End If
End If
If OcurrioError Then
ObjConta.RollBack()
Alert("Ocurrió un error al guardar la póliza", TipoMensaje.MsgAdvertencia)
Else
'Alert("La información se guardó correctamente con el numero de poliza " + IdPoliza.ToString + ".", TipoMensaje.MsgInformacion)
Alert(String.Format("La información se guardó correctamente con el numero de póliza: <b>{0}</b>", ObjConta.Folio), TipoMensaje.MsgInformacion)
ObjConta.Commit()
IDPoliza = tIdPoliza
'recargo la informacion, por si hacen cambios en la poliza
limpia()
CargaDatos(IDPoliza, -1, -1, -1, -1)
BtnNuevo.OnClientClick = ""
End If
End If
upTitulos.Update()
upDatos.Update()
UpConsultar.Update()
ObjConta.Dispose()
End Sub
Private Sub AddRegPolizaDetalle(IdMovimiento As Integer, Referencia As String, CveCuenta As Integer, Cuenta As String, IdSegNeg As String, SegNeg As String, NombreConcepto As String, Cargo As Double, Abono As Double)
Dim Row As DataRow = Nothing
Row = TmpDT.NewRow()
Row("Id") = IdMovimiento
Row("NumMovto") = TmpDT.Rows.Count + 1
Row("Referencia") = Referencia
Row("IdCuenta") = CveCuenta
Row("CuentaFormato") = Cuenta
Row("CtaCodigo") = Cuenta
Row("IdSegNeg") = IdSegNeg
Row("SegNeg") = SegNeg
Row("Concepto") = NombreConcepto
Row("Cargo") = Cargo
Row("Abono") = Abono
Row("Estado") = "I"
TmpDT.Rows.Add(Row)
CargaGrid()
End Sub
Private Sub ActualizaPoliza()
Dim OcurrioError As Boolean = False
Dim ObjContabilidad As New ClsContabilidad()
ObjContabilidad.IniciaTransacSQL()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
ObjConta.IniciaTransacSQL()
Dim Row As DataRow
Dim ObjGral As New ClsGenerales()
ObjGral.IniciaTransacSQL()
'ObjConta.UpdatePoliza(TxtConcepto.Text.Trim, LblCargo.Text.Trim.ToDouble, LblAbono.Text.Trim.ToDouble, UsuarioActual.CveUsuario, TxtFechaPoliza.Text.Trim.ToDate, LtlNumeroPoliza.Text.Trim.ToEntero, DdlTipoPoliza.SelectedValue.ToEntero, HdnIdPoliza.Value)
If ObjConta.UpdatePoliza(TxtConcepto.Text.Trim, LblCargo.Text.Trim.ToDouble, LblAbono.Text.Trim.ToDouble, UsuarioActual.CveUsuario, TxtFechaPoliza.Text.Trim.ToDate, TxtNumeroPoliza.Text, DdlTipoPoliza.SelectedValue.ToEntero, IDPoliza.ToString.ToEntero) Then
'Dim ResultadoTabla As New StringBuilder()
'ResultadoTabla.Append("<table>")
'For i = 0 To RemoveMovimientos.Count - 1
' 'ResultadoTabla.Append("<tr><td>" & Row("Id").ToString & "</td></tr>")
' 'ResultadoTabla.Append("<tr><td>" & RemoveMovimientos.Item(i).ToString & "</td></tr>")
'Next
'Alert(RemoveMovimientos.Count.ToString)
'Agrega a la Bitacora
If FechaPolizaOld <> TxtFechaPoliza.Text.Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, TxtFechaPoliza.Text.Trim, FechaPolizaOld, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Fecha", "Polizas", TxtNumeroPoliza.Text, DdlTipoPoliza.SelectedValue.ToEntero) Then
OcurrioError = True
End If
End If
If ConceptoOld <> TxtConcepto.Text.Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, TxtConcepto.Text.Trim, ConceptoOld, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Concepto", "Polizas", TxtNumeroPoliza.Text, DdlTipoPoliza.SelectedValue.ToEntero) Then
OcurrioError = True
End If
End If
If Not ObjContabilidad.UpdatePrePoliza(TxtFechaPoliza.Text.ToDate, TxtNumeroPoliza.Text.ToEntero, DdlTipoPoliza.SelectedValue.ToEntero, IDPoliza, CvePrePoliza, UsuarioActual.CveEmpresa, TxtConcepto.Text.Trim, TxtFechaPoliza.Text.ToDate) Then
OcurrioError = True
End If
For Each Row In TmpDT.Rows
If Row("Estado").ToString.Trim = "D" AndAlso Row("Id").ToString.ToEntero > 0 Then
ObjConta.RemoveMovimiento(Row("Id").ToString.ToEntero)
Else
Dim Importe As Double = If(Row("Cargo").ToString.ToDouble <> 0, Row("Cargo"), Row("Abono")).ToString.ToDouble
Dim ImporteME As Double = If(Row("CargoME").ToString.ToDouble <> 0, Row("CargoME"), Row("AbonoME")).ToString.ToDouble
Dim TipoMovto As Boolean = Not Row("Cargo").ToString.ToDouble <> 0
If Row("Id").ToString.ToEntero <> -1 Then
Dim Id = Row("Id").ToString
'Agrega a la Bitacora
If Row("Estado").ToString.Trim = "U" Then
If Row("Referencia").ToString.Trim <> DT.FiltroPrimeroValor("Referencia", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("Referencia").ToString, DT.FiltroPrimeroValor("Referencia", "Id =" + Id).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Referencia en Cuenta: '" + Row("CtaCodigo").ToString + "'", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
If Row("CtaCodigo").ToString.Trim <> DT.FiltroPrimeroValor("CtaCodigo", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("CtaCodigo").ToString, DT.FiltroPrimeroValor("CtaCodigo", "Id =" + Id).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Cuenta", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
If Row("SegNeg").ToString.Trim <> DT.FiltroPrimeroValor("SegNeg", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("SegNeg").ToString, DT.FiltroPrimeroValor("SegNeg", "Id =" + Id).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "SegNeg en Cuenta: '" + Row("CtaCodigo").ToString + "'", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
If Row("Concepto").ToString.Trim <> DT.FiltroPrimeroValor("Concepto", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("Concepto").ToString, DT.FiltroPrimeroValor("Concepto", "Id =" + Id).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Concepto en Cuenta: '" + Row("CtaCodigo").ToString + "'", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
If Row("Cargo").ToString.Trim <> DT.FiltroPrimeroValor("Cargo", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("Cargo").ToString.FormatoNumero(2), DT.FiltroPrimeroValor("Cargo", "Id =" + Id).FormatoNumero(2).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Cargo en Cuenta: '" + Row("CtaCodigo").ToString + "'", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
If Row("Abono").ToString.Trim <> DT.FiltroPrimeroValor("Abono", "Id =" + Id).Trim Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Row("Abono").ToString.FormatoNumero(2), DT.FiltroPrimeroValor("Abono", "Id =" + Id).FormatoNumero(2).Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Abono en Cuenta: '" + Row("CtaCodigo").ToString + "'", "Polizas", TxtNumeroPoliza.Text, IdPoliza:=IDPoliza) Then
OcurrioError = True
End If
End If
End If
If Not ObjConta.UpdateMovimiento(Row("Id").ToString.ToEntero, Row("IdCuenta").ToString.ToEntero, TipoMovto, Importe, Row("Referencia").ToString, Row("Concepto").ToString, Row("IdSegNeg").ToString.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, ImporteME) Then
OcurrioError = True
End If
Else
If Not ObjConta.AddMovimiento(IDPoliza.ToString.ToEntero, Row("IdCuenta").ToString.ToEntero, TipoMovto, Importe, Row("Referencia").ToString, Row("Concepto").ToString, Row("IdSegNeg").ToString.ToEntero, TxtFechaPoliza.Text.Trim.ToDate, "") Then
OcurrioError = True
End If
End If
End If
Next
'ResultadoTabla.Append("</table>")
If OcurrioError Then
ObjConta.RollBack()
ObjContabilidad.RollBack()
ObjGral.RollBack()
Alert("Ocurrió un error al actualizar los movimientos de la póliza", TipoMensaje.MsgAdvertencia)
Else
'Alert("La poliza se actualizó correctamente." & ResultadoTabla.ToString, TipoMensaje.MsgInformacion)
'Alert("La poliza se actualizó correctamente. - " & RemoveMovimientos.Count, TipoMensaje.MsgInformacion)
Alert("La póliza se actualizó correctamente.", TipoMensaje.MsgInformacion)
ObjConta.Commit()
ObjContabilidad.Commit()
ObjGral.Commit()
'HdnIdPoliza.Value = ""
HdnFechaPoliza.Value = TxtFechaPoliza.Text.ToDate.ToShortDateString
HdnTipoPoliza.Value = DdlTipoPoliza.SelectedValue
'TmpDT = Nothing
'CargaGrid()
CargaDatos(IDPoliza, -1, -1, -1, -1)
UpBitacora.Update()
BtnNuevo.OnClientClick = ""
End If
Else
ObjConta.RollBack()
ObjContabilidad.RollBack()
End If
ObjConta.Dispose()
ObjContabilidad.Dispose()
End Sub
#End Region
#Region "Historial de Modificacion"
Private Sub CargaGvBitacora(IdPoliza As Integer)
' COMENTADO POR IPP PARA SUBIR 5 ABRIL 2017
Dim ObjGral As New ClsGenerales()
If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, IdPoliza:=IdPoliza) Then
GvBitacora.DataSource = ObjGral.DtResultados.FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa.ToString)
End If
ObjGral.Dispose()
GvBitacora.DataBind()
End Sub
#End Region
'Protected Sub TxtNumeroPoliza_TextChanged(sender As Object, e As EventArgs) Handles TxtNumeroPoliza.TextChanged
' If HdnFolioPoliza.Value.ToEntero <> TxtNumeroPoliza.Text.Trim.ToEntero Then
' BtnGuardar.OnClientClick = "return confirm('Intenta cambiar el número de la póliza?')"
' Else
' BtnGuardar.OnClientClick = ""
' End If
' upDatos.Update()
'End Sub
'Protected Sub TxtFechaPoliza_TextChanged(sender As Object, e As EventArgs) Handles TxtFechaPoliza.TextChanged
' If HdnFechaPoliza.Value.ToDate.ToShortDateString <> TxtFechaPoliza.Text.ToDate.ToShortDateString Then
' BtnGuardar.OnClientClick = "return confirm('Intenta cambiar la fecha de la póliza?')"
' Else
' BtnGuardar.OnClientClick = ""
' End If
' upDatos.Update()
' upTitulos.Update()
'End Sub
'Protected Sub DdlTipoPoliza_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoPoliza.SelectedIndexChanged
' If HdnTipoPoliza.Value <> DdlTipoPoliza.SelectedValue Then
' BtnGuardar.OnClientClick = "return confirm('Intenta Cambiar el tipo de póliza?')"
' Else
' BtnGuardar.OnClientClick = ""
' End If
' upDatos.Update()
' upTitulos.Update()
'End Sub
'TmpDT = Nothing
'GvDatos.DataBind()
'TxtFechaPoliza.Text = ""
'TxtFecha.Text = ""
'DdlTipoPoliza.SelectedIndex = 0
'TxtNumero.Text = ""
''LtlNumeroPoliza.Text = "-"
'TxtNumeroPoliza.Text = "-"
'HdnIdPoliza.Value = ""
'TxtConcepto.Text = ""
'TxtReferencia.Text = ""
'DdlCuenta.SelectedIndex = 0
'DdlSegNeg.SelectedIndex = 0
'TxtNombreConcepto.Text = ""
'TxtCargo.Text = ""
'TxtAbono.Text = ""
'LblCargo.Text = "0.00"
'LblAbono.Text = "0.00"
Private Sub limpia()
HdnCveCuenta.Value = ""
HdnlAbono.Value = ""
HdnlCargo.Value = ""
LblDiferencia.Text = ""
DtDevoluciones = Nothing
GvDevoluciones.DataBind()
End Sub
#Region "G R I D - V I E W"
Protected Sub GvDevoluciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDevoluciones.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
e.Row.FCDropDownList("DdlProveedor").SelectedIndex = -1
e.Row.FCDropDownList("DdlProveedor").DataSource = DtProveedoresConta
e.Row.FCDropDownList("DdlProveedor").DataBind()
e.Row.FCDropDownList("DdlProveedor").SelectedValueExist(e.Row.DataKey("IdProveedor"))
e.Row.FCTextBox("TxtImporteBase").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);CalculaImporteIVA({0},{1},{2});CalculaImporteSinRet({0},{2},{3});CalculaTotalErogacion({3},{4},{5},{6});", e.Row.FCTextBox("TxtImporteBase").ClientID, e.Row.FCDropDownList("DdlTasa").ClientID, e.Row.FCTextBox("TxtImporteIVA").ClientID, e.Row.FCLabel("LbImporteSinRet").ClientID, e.Row.FCTextBox("TxtRetIVA").ClientID, e.Row.FCTextBox("TxtRetISR").ClientID, e.Row.FCLabel("LbGranTotalAdd").ClientID))
e.Row.FCTextBox("TxtImporteIVA").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);CalculaImporteSinRet({0},{2},{3});CalculaTotalErogacion({3},{4},{5},{6});", e.Row.FCTextBox("TxtImporteBase").ClientID, e.Row.FCDropDownList("DdlTasa").ClientID, e.Row.FCTextBox("TxtImporteIVA").ClientID, e.Row.FCLabel("LbImporteSinRet").ClientID, e.Row.FCTextBox("TxtRetIVA").ClientID, e.Row.FCTextBox("TxtRetISR").ClientID, e.Row.FCLabel("LbGranTotalAdd").ClientID))
e.Row.FCTextBox("TxtRetIVA").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);CalculaTotalErogacion({3},{4},{5},{6});", e.Row.FCTextBox("TxtImporteBase").ClientID, e.Row.FCDropDownList("DdlTasa").ClientID, e.Row.FCTextBox("TxtImporteIVA").ClientID, e.Row.FCLabel("LbImporteSinRet").ClientID, e.Row.FCTextBox("TxtRetIVA").ClientID, e.Row.FCTextBox("TxtRetISR").ClientID, e.Row.FCLabel("LbGranTotalAdd").ClientID))
e.Row.FCTextBox("TxtRetISR").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);CalculaTotalErogacion({3},{4},{5},{6});", e.Row.FCTextBox("TxtImporteBase").ClientID, e.Row.FCDropDownList("DdlTasa").ClientID, e.Row.FCTextBox("TxtImporteIVA").ClientID, e.Row.FCLabel("LbImporteSinRet").ClientID, e.Row.FCTextBox("TxtRetIVA").ClientID, e.Row.FCTextBox("TxtRetISR").ClientID, e.Row.FCLabel("LbGranTotalAdd").ClientID))
End If
End If
End Sub
Protected Sub GvDevoluciones_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDevoluciones.RowCancelingEdit
GvDevoluciones.EditIndex = -1
CargaGridDevoluciones("", 0)
UpDevoluciones.Update()
End Sub
Protected Sub GvDevoluciones_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDevoluciones.RowDeleting
Dim ErrorEliminar = False
If IDPoliza > 0 Then
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If Not ObjConta.RemoveDevolucionesIVA(e.Keys("Id").ToString.ToEntero) Then
ErrorEliminar = True
End If
ObjConta.Dispose()
CargaDevoluciones()
Else
DtDevoluciones.Rows().RemoveAt(e.Keys("Id").ToString.ToEntero - 1)
CargaGridDevoluciones("", 0)
End If
If Not ErrorEliminar Then
Alert("La Devolución fue eliminada correctamente.", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al eliminar la Devolución", TipoMensaje.MsgError)
End If
End Sub
Protected Sub GvDevoluciones_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDevoluciones.RowEditing
GvDevoluciones.EditIndex = e.NewEditIndex
CargaGridDevoluciones("", 0)
End Sub
Protected Sub GvDevoluciones_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDevoluciones.RowUpdating
Dim ErrorDevolucion = False
If IDPoliza > 0 Then
Dim gvr As GridViewRow = GvDevoluciones.Rows(e.RowIndex)
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.UpdateDevolucionesIVA(gvr.DataKey("Id").ToEntero, IDPoliza, DdlCuenta.SelectedValue.ToEntero,
gvr.FCDropDownList("DdlProveedor").SelectedValue.ToEntero, gvr.FCDropDownList("DdlTasa").SelectedValue.ToDouble,
gvr.FCTextBox("TxtImporteBase").Text.ToDouble, gvr.FCTextBox("TxtImporteIVA").Text.ToDouble,
gvr.FCTextBox("TxtRetIVA").Text.ToDouble, gvr.FCTextBox("TxtRetISR").Text.ToDouble, Date.Now,
gvr.FCTextBox("TxtReferenciaDevolucion").Text, gvr.FCTextBox("TxtSerie").Text, gvr.FCTextBox("TxtFolio").Text.ToEntero) Then
Alert("Devolución Actualizada con Éxito", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al Actualizar la Devolución", TipoMensaje.MsgError)
ErrorDevolucion = True
End If
ObjConta.Dispose()
If Not ErrorDevolucion Then
GvDevoluciones.EditIndex = -1
CargaDevoluciones()
End If
Else
Dim row() = DtDevoluciones.Select(String.Format("Id = {0}", e.Keys("Id")))
' row(0)("IdCuenta") = GvDevoluciones.Rows(e.RowIndex).FCDropDownList("DdlProveedor").SelectedValue
row(0)("IdProveedor") = GvDevoluciones.Rows(e.RowIndex).FCDropDownList("DdlProveedor").SelectedValue
row(0)("Tasa") = GvDevoluciones.Rows(e.RowIndex).FCDropDownList("DdlTasa").SelectedValue
row(0)("ImporteBase") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtImporteBase").Text
row(0)("ImporteIVA") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtImporteIVA").Text
row(0)("RetIVA") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtRetIVA").Text
row(0)("RetISR") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtRetISR").Text
row(0)("Referencia") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtReferenciaDevolucion").Text
row(0)("Serie") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtSerie").Text
row(0)("Folio") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtFolio").Text
row(0)("Proveedor") = GvDevoluciones.Rows(e.RowIndex).FCDropDownList("DdlProveedor").SelectedItem.Text
row(0)("ImporteAntesRet") = GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtImporteBase").Text.ToDouble + GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtImporteIVA").Text.ToDouble
row(0)("GranTotal") = row(0)("ImporteAntesRet").ToString.ToDouble - GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtRetIVA").Text.ToDouble - GvDevoluciones.Rows(e.RowIndex).FCTextBox("TxtRetISR").Text.ToDouble
GvDevoluciones.EditIndex = -1
CargaGridDevoluciones("", 0)
End If
End Sub
#End Region
#Region "D E V O L U C I O N E S - I V A"
Protected Sub LbAgregarDevolucion_Click(sender As Object, e As EventArgs)
Dim ErrorDevolucion = False
If IDPoliza > 0 Then
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.AddDevolucionesIVA(IDPoliza, DdlCuenta.SelectedValue.ToEntero, DdlProveedor.SelectedValue.ToEntero, DdlTasa.SelectedValue.ToDouble, TxtImporteBase.Text.ToDouble, TxtImporteIVA.Text.ToDouble,
TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtFechaPoliza.Text.ToDate, TxtReferenciaDevolucion.Text, TxtSerie.Text, TxtFolio.Text.ToEntero, "", UsuarioActual.CveEmpresa) Then
Alert("Devolución Agregada con Éxito", TipoMensaje.MsgInformacion)
Else
ErrorDevolucion = True
Alert("Ocurrió un error al agregar la Devolución", TipoMensaje.MsgAdvertencia)
End If
ObjConta.Dispose()
If Not ErrorDevolucion Then
CargaDevoluciones()
End If
Else
Dim row = DtDevoluciones.NewRow
row("ID") = (DtDevoluciones.Rows.Count + 1).ToString
'row("IdCuenta") = DdlProveedor.SelectedValue
row("IdProveedor") = DdlProveedor.SelectedValue
row("Tasa") = DdlTasa.SelectedValue
row("ImporteBase") = TxtImporteBase.Text
row("ImporteIVA") = TxtImporteIVA.Text
row("RetIVA") = TxtRetIVA.Text
row("RetISR") = TxtRetISR.Text
row("Referencia") = TxtReferenciaDevolucion.Text
row("Serie") = TxtSerie.Text
row("Folio") = TxtFolio.Text
row("Proveedor") = DdlProveedor.SelectedItem.Text
row("ImporteAntesRet") = TxtImporteBase.Text.ToDouble + TxtImporteIVA.Text.ToDouble
row("GranTotal") = row("ImporteAntesRet").ToString.ToDouble - TxtRetIVA.Text.ToDouble - TxtRetISR.Text.ToDouble
DtDevoluciones.Rows.Add(row)
CargaGridDevoluciones("", 0)
End If
LimpiaDevoluciones()
End Sub
Protected Sub LbAgregarCausacion_Click(sender As Object, e As EventArgs)
Dim ErrorDevolucion = False
If IDPoliza > 0 Then
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
Dim TotalTasa16 As Double = TxtImporteTotalC.Text.ToDouble
Dim BaseTasa16 As Double = TxtImporteBaseC.Text.ToDouble
Dim IVATasa16 As Double = TxtIVAC.Text.ToDouble
Dim IVATasaNoAcreditable As Double = TxtIvaNoAcreditableC.Text.ToDouble
Dim ISRRetenido As Double = TxtISRRetenidoC.Text.ToDouble
Dim IVARetenido As Double = TxtIVARetenidoC.Text.ToDouble
Dim ietu As Double = TxtIETU.Text.ToDouble
Dim cuenta As String
Dim CuentasConcatenadas As New StringBuilder
Dim importeMaximo As Double
If drParametros IsNot Nothing Then
cuenta = drParametros("CtaFlujo").ToString
ObjConta.GetCuentasCausaciones(cuenta)
For Each row As DataRow In ObjConta.DtResultados.Rows
Dim ct As String = row("IdSubCtade").ToString
CuentasConcatenadas.AppendFormat("{0},", ct)
Next
End If
importeMaximo = TmpDT.SUM("Cargo", String.Format("IdCuenta IN ( {0} )", CuentasConcatenadas.ToString.TrimEnd(","c))).ToString.ToDecimal
If LbAgregarCausacion.Text = "Agregar" And importeMaximo = TotalTasa16 Then
If ObjConta.AddCausacionesIVA(IDPoliza, TotalTasa16, BaseTasa16, IVATasa16, IVATasaNoAcreditable, ISRRetenido, IVARetenido, ChkNoCausar.Checked, IETU:=ietu) Then
Alert("El movimiento se realizó correctamente", TipoMensaje.MsgInformacion)
End If
ElseIf LbAgregarCausacion.Text = "Actualizar" And importeMaximo = TotalTasa16 Then
If ObjConta.UpdateCausacionesIVA(IDPoliza, TotalTasa16, BaseTasa16, IVATasa16, IVATasaNoAcreditable, ISRRetenido, IVARetenido, ChkNoCausar.Checked, ietu:=ietu) Then
Alert("El movimiento se realizó correctamente", TipoMensaje.MsgInformacion)
End If
Else
Alert("El importe total desglosado con coincide con el importe de la cuenta de flujo de efectivo", TipoMensaje.MsgAdvertencia)
End If
ObjConta.Dispose()
End If
CargaCausaciones()
End Sub
Private Sub LimpiaDevoluciones()
TxtSerie.Text = ""
TxtFolio.Text = ""
TxtReferenciaDevolucion.Text = ""
TxtImporteBase.Text = ""
TxtImporteIVA.Text = ""
TxtRetIVA.Text = ""
TxtRetISR.Text = ""
DdlProveedor.SelectedValue = "-1"
TxtSerie.Focus()
End Sub
'Private Sub CargaProveedoresConta()
' Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
' If ObjConta.GetProveedoresConta() Then
' DtProveedoresConta = ObjConta.DtResultados
' DdlProveedor.DataSource = DtProveedoresConta
' DdlProveedor.DataBind()
' Else
' DtProveedoresConta = Nothing
' Alert("Ocurrio un error al cargar los Proveedores. Por favor recargue la página.", TipoMensaje.MsgAdvertencia)
' End If
' ObjConta.Dispose()
' DdlProveedor.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
'End Sub
Private Sub CargaDevoluciones()
If IDPoliza > 0 Then
PnlDevIVA.Visible = True
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetDevolucionesIVA(-1, IDPoliza) Then
DtDevoluciones = ObjConta.DtResultados
Else
DtDevoluciones = Nothing
Alert("Ocurrió un error al cargar Devoluciones", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
If DtDevoluciones IsNot Nothing Then
CargaGridDevoluciones("", 0)
DdlCuenta.SelectedValueExist(DtDevoluciones.MAX("IdCuenta"))
End If
Else
'Si no tiene POLIZA
CreaDtDevoluciones()
End If
End Sub
Private Sub CargaCausaciones()
If IDPoliza > 0 Then
PnlCauIVA.Visible = True
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetCausacionesIVA(-1, IDPoliza) Then
If ObjConta.DtResultados IsNot Nothing AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
TxtImporteTotalC.Text = ObjConta.DtResultados.Rows(0)("ImporteTotal").ToString
TxtImporteBaseC.Text = ObjConta.DtResultados.Rows(0)("ImporteBase").ToString
TxtIVAC.Text = ObjConta.DtResultados.Rows(0)("IVA").ToString
TxtIvaNoAcreditableC.Text = ObjConta.DtResultados.Rows(0)("IVANoAcreditable").ToString
lblEjercicioTexto.Text = ObjConta.DtResultados.Rows(0)("Año").ToString
LblPeriodoTexto.Text = StrConv(MonthName(ObjConta.DtResultados.Rows(0)("Mes").ToString.ToEntero, False), VbStrConv.ProperCase)
TxtIVARetenidoC.Text = ObjConta.DtResultados.Rows(1)("ImporteTotal").ToString
TxtISRRetenidoC.Text = ObjConta.DtResultados.Rows(2)("ImporteTotal").ToString
LblTotalImporte.Text = ObjConta.DtResultados.Rows(3)("ImporteTotal").ToString
LblTotalBase.Text = ObjConta.DtResultados.Rows(3)("ImporteBase").ToString
LblTotalIVA.Text = ObjConta.DtResultados.Rows(3)("IVA").ToString
LblTotalIvaNoAcreditable.Text = ObjConta.DtResultados.Rows(3)("IVANoAcreditable").ToString
TxtIETU.Text = ObjConta.DtResultados.Rows(3)("ImporteBase").ToString
If ObjConta.DtResultados.Rows(0)("NoCausar").ToString = "True" Then
ChkNoCausar.Checked = True
Else
ChkNoCausar.Checked = False
End If
If TxtImporteTotalC.Text <> "" Then
LbAgregarCausacion.Text = "Actualizar"
End If
End If
Else
Alert("Ocurrió un error al cargar Causaciones", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
End If
End Sub
Private Sub CreaDtDevoluciones()
DtDevoluciones = New DataTable
'DtDevoluciones.Columns.Add("IdCuenta", GetType(String))
DtDevoluciones.Columns.Add("IdProveedor", GetType(Integer))
DtDevoluciones.Columns.Add("Tasa", GetType(String))
DtDevoluciones.Columns.Add("ImporteBase", GetType(Double))
DtDevoluciones.Columns.Add("ImporteIVA", GetType(Double))
DtDevoluciones.Columns.Add("RetIVA", GetType(Double))
DtDevoluciones.Columns.Add("RetISR", GetType(Double))
DtDevoluciones.Columns.Add("Referencia", GetType(String))
DtDevoluciones.Columns.Add("Serie", GetType(String))
DtDevoluciones.Columns.Add("Folio", GetType(String))
DtDevoluciones.Columns.Add("Id", GetType(Integer))
DtDevoluciones.Columns.Add("Proveedor", GetType(String))
DtDevoluciones.Columns.Add("ImporteAntesRet", GetType(Double))
DtDevoluciones.Columns.Add("GranTotal", GetType(Double))
End Sub
#End Region
Protected Sub LBDevIVA_Click(sender As Object, e As EventArgs)
'PnlDevIVA.Visible = True
UpDevoluciones.Update()
RegistraScript("$get('divDevIVA').style.display='';")
Dim cont As New ClsContPAQi(UsuarioActual.Empresa)
If cont.GetProveedores() Then
DtProveedoresConta = cont.DtResultados
DdlProveedor.DataSource = DtProveedoresConta
DdlProveedor.DataBind()
Else
DtProveedoresConta = Nothing
Alert("Ocurrió un error al cargar los Proveedores. Por favor recargue la página.", TipoMensaje.MsgError)
End If
cont.Dispose()
DdlCuenta.DataSource = DTCuentas
DdlCuenta.DataBind()
CargaDevoluciones()
DdlProveedor.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
End Sub
Protected Sub LBCauIVA_Click(sender As Object, e As EventArgs)
UpCausaciones.Update()
RegistraScript("$get('divCauIVA').style.display='';")
CargaCausaciones()
End Sub
Protected Sub DdlTipoPoliza_SelectedIndexChanged(sender As Object, e As EventArgs)
RegistraScript("ApagaGVS();")
SiguienteFolio()
End Sub
Private Sub SiguienteFolio()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
Dim NumPoliza = ObjConta.GetNumeroPoliza(DdlTipoPoliza.SelectedValue.ToEntero, TxtFechaPoliza.Text.ToDate.ToString("yyyy-MM-dd"))
If NumPoliza > 0 Then
TxtNumeroPoliza.Text = NumPoliza.ToString
Else
Alert("Ocurrió un error al obtener el número de póliza. Por favor recargue la página", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
upTitulos.Update()
End Sub
#Region " ELIMINAR POLIZA "
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs)
RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion"))
End Sub
Protected Sub BtnRemove_Click(sender As Object, e As EventArgs)
EliminaPoliza()
End Sub
Private Sub EliminaPoliza()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
ObjConta.IniciaTransacSQL()
Dim ObjMov As New ClsContabilidad()
Dim ObjGral As New ClsGenerales(ObjMov.IniciaTransacSQL)
Dim ErrorTrans As Boolean = False
If ObjConta.RemovePoliza(IDPoliza) Then
If ObjMov.DesvincularPrePolizaContabilizada(IDPoliza, UsuarioActual.CveEmpresa) Then
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Polizas", TxtNumeroPoliza.Text, DdlTipoPoliza.SelectedValue.ToEntero) Then
ErrorTrans = True
End If
Else
ErrorTrans = True
End If
Else
ErrorTrans = True
End If
If Not ErrorTrans Then
If Not ObjMov.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
ErrorTrans = True
End If
End If
If Not ErrorTrans Then
ObjConta.Commit()
ObjMov.Commit()
Alert("La Póliza fue eliminada correctamente.", TipoMensaje.MsgInformacion)
BtnNuevo_Click(BtnNuevo, EventArgs.Empty)
TxtDescripcion.Text = ""
RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion"))
UpDescripcion.Update()
Else
ObjConta.RollBack()
ObjMov.RollBack()
Alert("Ocurrió un error al eliminar la Póliza. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
ObjMov.Dispose()
ObjGral.Dispose()
End Sub
#End Region
#Region "DESCARGAR E IMPRIMIR LISTADO"
Public Sub DescargarFormato()
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\Formatos\FormatoRegPoliza.xlsx"
Dim Archivo As New IO.FileInfo(Directorio)
If Archivo.Exists Then
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
Response.AddHeader("Content-Length", Archivo.Length.ToString())
Response.ContentType = "text/plain"
Response.Flush()
Response.TransmitFile(Archivo.FullName)
Response.End()
End If
End Sub
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
Dim dt As New DataTable
Dim Conexion As Odbc.OdbcConnection = Nothing
Dim ErrorArchivo = False
Dim n As Integer = 0
Try
Select Case Tipo
Case "EXCEL"
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
Conexion.Open()
Dim cmd = Conexion.CreateCommand()
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select * FROM [Hoja1$]"
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
DataAdapter.Fill(dt)
Case Else
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
Exit Sub
End Select
Catch ex As Exception
ErrorArchivo = True
OnError("Ocurrio un Error al leer el archivo <br/>" & ex.Message, ex)
End Try
Conexion.Close()
If Not ErrorArchivo Then
If Not dt.Columns(0).ColumnName = "Referencia" Then
Alert("El nombre de la primera columna debe ser 'Referencia'.Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(1).ColumnName = "Código Cuenta" Then
Alert("El nombre de la segunda columna debe ser 'Código Cuenta'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(2).ColumnName = "Nombre Cuenta" Then
Alert("El nombre de la tecera columna debe ser 'Nombre Cuenta'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(3).ColumnName = "SegNeg" Then
Alert("El nombre de la cuarta columna debe ser 'SegNeg'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(4).ColumnName = "Nombre/Concepto" Then
Alert("El nombre de la quinta columna debe ser 'Nombre/Concepto'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(5).ColumnName = "Cargo" Then
Alert("El nombre de la sexta columna debe ser 'Cargo'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(6).ColumnName = "Abono" Then
Alert("El nombre de la séptima columna debe ser 'Abono'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
dt.TableName = "Datos"
If Not ErrorArchivo Then
NumRow = 0
Dim RowNoEncontrados As String = ""
Dim NumAgregados As Integer = 0
For Each Row As DataRow In dt.Rows
Dim Referencia As String = Row("Referencia").ToString
Dim Cuenta As String = Row("Código Cuenta").ToString + " - " + Row("Nombre Cuenta").ToString
Dim Cuenta2 = AgregaComilla(Cuenta) 'Agregar otra comilla simple adicional cuando contenga una
Dim CveCuenta As String = ""
If DTCuentas.FiltroPrimero("CtaCodigo = '" & Cuenta2 & "'") IsNot Nothing Then
CveCuenta = DTCuentas.FiltroPrimero("CtaCodigo = '" & Cuenta2 & "'")("Id").ToString
End If
Dim SegNeg As String = Row("SegNeg").ToString
Dim SegNeg2 = AgregaComilla(SegNeg) 'Agregar otra comilla simple adicional cuando contenga una
Dim IdSegNeg As String = ""
If DTSegmentosNegocio.FiltroPrimero("Nombre = '" & SegNeg2 & "'") IsNot Nothing Then
IdSegNeg = DTSegmentosNegocio.FiltroPrimero("Nombre = '" & SegNeg2 & "'")("Id").ToString
End If
Dim Concepto As String = Row("Nombre/Concepto").ToString
Dim Cargo As String = Row("Cargo").ToString
Dim Abono As String = Row("Abono").ToString
NumRow = NumRow + 1
If CveCuenta = "" Then RowNoEncontrados &= "&nbsp;&nbsp;&nbsp;&nbsp;- No se encontró '" & Cuenta & "' en la fila " & NumRow & ", columnas 'Código Cuenta' ó 'Nombre Cuenta'" & "<\BR>"
If IdSegNeg = "" Then RowNoEncontrados &= "&nbsp;&nbsp;&nbsp;&nbsp;- No se encontró '" & SegNeg & "' en la fila " & NumRow & ", columna 'SegNeg'" & "<\BR>"
If Concepto = "" Then RowNoEncontrados &= "&nbsp;&nbsp;&nbsp;&nbsp;- Debes asignar un valor para la columna 'Nombre/Concepto' en la fila " & NumRow & "."
If (Cargo.Length = 0 And Abono.Length = 0) Or (Cargo.Length <> 0 And Abono.Length <> 0) Then RowNoEncontrados &= "&nbsp;&nbsp;&nbsp;&nbsp;- Debes asignar un valor para CARGO o para ABONO en la fila " & NumRow & "."
If CveCuenta <> "" And IdSegNeg <> "" And Concepto <> "" And Not ((Cargo.Length = 0 And Abono.Length = 0) Or (Cargo.Length <> 0 And Abono.Length <> 0)) Then
If Cargo = "" Then Cargo = "0"
If Abono = "" Then Abono = "0"
AddRegPolizaDetalle(-1, Referencia, CveCuenta.ToEntero, Cuenta, IdSegNeg, SegNeg, Concepto, Cargo.ToDouble, Abono.ToDouble)
CargaGrid()
upDatos.Update()
NumAgregados = NumAgregados + 1
End If
Next
If RowNoEncontrados.Length > 0 Then
Alert("Se Cargaron " & NumAgregados & " Conceptos.<\BR>Los siguientes Conceptos no se encontraron en la Base de Datos o contienen errores.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia)
Else
Alert("Se Cargaron " & NumAgregados & " Conceptos correctamente.")
End If
If NumAgregados > 0 Then
BtnNuevo.OnClientClick = "return confirm('Se han hecho cambios que no fueron guardados, ¿Continuar?')"
End If
RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal")
TxtExcel.Text = "[]"
End If
End If
dt.Dispose()
End Sub
Private Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
If TxtExcel.getfiles().Archivos.Count > 0 Then
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV")
CargarArchivo(Directorio, file.filename, Tipo)
Else
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
End If
End Sub
#End Region
Protected Sub LbDescargarExcelConceptos_Click(sender As Object, e As EventArgs)
DescargarFormato()
End Sub
Private Function AgregaComilla(str As String) As String
If str.Contains("'") Then
Dim arr = Split(str, "'")
str = ""
For i = 0 To arr.Length() - 1
If i = arr.Length - 1 Then
str += arr(i)
Else
str += arr(i) + "''"
End If
Next
End If
Return str
End Function
End Class