carga excel
This commit is contained in:
@@ -67,9 +67,17 @@
|
|||||||
<asp:Label ID="LblEncabezado" runat="server" Text=" Registro de Póliza"></asp:Label>
|
<asp:Label ID="LblEncabezado" runat="server" Text=" Registro de Póliza"></asp:Label>
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
|
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
|
||||||
<li>
|
<asp:UpdatePanel runat="server">
|
||||||
<asp:LinkButton ID="LnkComplementoPago" runat="server" Visible="false" OnClick="LnkComplementoPago_Click" Style="color: #686868;"><i class="fa fa-money" style="color:#686868;"></i> Crear Complemento de Pago</asp:LinkButton>
|
<ContentTemplate>
|
||||||
</li>
|
<li>
|
||||||
|
<asp:LinkButton ID="LnkExcel" runat="server" Visible="true" data-target="#DivCargaExcel"><i class="far fa-file-excel" style="font-weight:bold;"></i> Cargar Excel</asp:LinkButton>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<asp:LinkButton ID="LnkComplementoPago" runat="server" Visible="false" OnClick="LnkComplementoPago_Click" Style="color: #686868;"><i class="fa fa-money" style="color:#686868;"></i> Crear Complemento de Pago</asp:LinkButton>
|
||||||
|
</li>
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
|
||||||
<asp:UpdatePanel runat="server">
|
<asp:UpdatePanel runat="server">
|
||||||
<ContentTemplate>
|
<ContentTemplate>
|
||||||
<li>
|
<li>
|
||||||
@@ -779,6 +787,54 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="DivCargaExcel" class="modal ADS fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header ">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title">Agregar Excel</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-2 truncate" style="text-align: right;">Plantilla:</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<asp:DropDownList ID="DdlPlantilla2" runat="server" DataValueField="CvePlantillaPoliza" DataTextField="PlantillaPoliza" class="select2me" Width="100%"></asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h3>Arraste o haga click para subir el archivo Excel</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-11" style="margin-left: 30px; margin-right: 30px; margin-bottom: 10px;">
|
||||||
|
<asp:TextBox ID="TxtExcel" CssClass="ADSdropzone hidden" Text="" data-maxFile="1" runat="server"></asp:TextBox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3" style="text-align: left">
|
||||||
|
<asp:UpdatePanel ID="UpDescargar" runat="server" UpdateMode="Conditional">
|
||||||
|
<ContentTemplate>
|
||||||
|
<asp:Button ID="BtnDescargar" runat="server" CssClass="btn btn-warning" Text="Descargar Formato" />
|
||||||
|
</ContentTemplate>
|
||||||
|
<Triggers>
|
||||||
|
<asp:PostBackTrigger ControlID="BtnDescargar" />
|
||||||
|
</Triggers>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9" style="text-align: right">
|
||||||
|
<asp:Button ID="BtnCargaExcel" runat="server" CssClass="btn btn-success" Text="Aceptar"></asp:Button>
|
||||||
|
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="/Metronic/assets/global/plugins/dropzone/dropzone.js"></script>
|
<script src="/Metronic/assets/global/plugins/dropzone/dropzone.js"></script>
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ Imports System.Data
|
|||||||
Imports Extensiones
|
Imports Extensiones
|
||||||
Imports System.Linq
|
Imports System.Linq
|
||||||
Imports System.Web.Services
|
Imports System.Web.Services
|
||||||
|
Imports GemBox.Spreadsheet
|
||||||
|
|
||||||
Partial Class ContabilidadC_RegPrePolizaS
|
Partial Class ContabilidadC_RegPrePolizaS
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
|
|
||||||
|
|
||||||
#Region "Propiedades"
|
#Region "Propiedades"
|
||||||
Public Property ArregloMovs As ArrayList
|
Public Property ArregloMovs As ArrayList
|
||||||
Get
|
Get
|
||||||
@@ -157,9 +158,9 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
Set(value As Integer)
|
Set(value As Integer)
|
||||||
ViewState("IndiceGrid") = value
|
ViewState("IndiceGrid") = value
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
|
|
||||||
If Not Page.IsPostBack Then
|
If Not Page.IsPostBack Then
|
||||||
@@ -483,16 +484,29 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CargaPlantillas(TipoPlantilla As Integer)
|
Private Sub CargaPlantillas(TipoPlantilla As Integer)
|
||||||
|
|
||||||
'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
||||||
'GvPlantillas.DataBind()
|
'GvPlantillas.DataBind()
|
||||||
|
|
||||||
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
If UsuarioActual.CveEmpresa.Contiene(120) Then
|
||||||
DdlPlantilla.DataBind()
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
|
||||||
DdlPlantilla.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
|
||||||
End Sub
|
|
||||||
|
Else
|
||||||
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
||||||
|
DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
DdlPlantilla.DataBind()
|
||||||
|
DdlPlantilla.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
||||||
|
|
||||||
|
DdlPlantilla2.DataBind()
|
||||||
|
DdlPlantilla2.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub CargaConceptos()
|
Private Sub CargaConceptos()
|
||||||
DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
|
DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
|
||||||
DdlConceptosContables.DataBind()
|
DdlConceptosContables.DataBind()
|
||||||
@@ -543,8 +557,9 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
|
|
||||||
Private Sub CargaCuentasContables()
|
Private Sub CargaCuentasContables()
|
||||||
Dim ObjConta As New ClsContabilidad
|
Dim ObjConta As New ClsContabilidad
|
||||||
If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
|
If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
|
||||||
DdlCtaContable.DataSource = ObjConta.DtResultados
|
DdlCtaContable.DataSource = ObjConta.DtResultados
|
||||||
|
DtCuentasContables = ObjConta.DtResultados
|
||||||
End If
|
End If
|
||||||
ObjConta.Dispose()
|
ObjConta.Dispose()
|
||||||
DdlCtaContable.DataBind()
|
DdlCtaContable.DataBind()
|
||||||
@@ -1338,7 +1353,7 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
dr("IdCuenta") = DdlCtaContable.SelectedValue
|
dr("IdCuenta") = DdlCtaContable.SelectedValue
|
||||||
|
|
||||||
If DdlCtaContable.SelectedValue.ToEntero > 0 Then
|
If DdlCtaContable.SelectedValue.ToEntero > 0 Then
|
||||||
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", DdlCtaContable.SelectedValue))
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCtaContable.SelectedValue))
|
||||||
If drr IsNot Nothing Then
|
If drr IsNot Nothing Then
|
||||||
CodigoCuenta = drr("CuentaFormato").ToString()
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
||||||
NombreCuenta = drr("Nombre").ToString()
|
NombreCuenta = drr("Nombre").ToString()
|
||||||
@@ -1406,7 +1421,7 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
dr("IdCuenta") = DdlCtaContable.SelectedValue
|
dr("IdCuenta") = DdlCtaContable.SelectedValue
|
||||||
|
|
||||||
If DdlCtaContable.SelectedValue.ToEntero > 0 Then
|
If DdlCtaContable.SelectedValue.ToEntero > 0 Then
|
||||||
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", DdlCtaContable.SelectedValue))
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCtaContable.SelectedValue))
|
||||||
If drr IsNot Nothing Then
|
If drr IsNot Nothing Then
|
||||||
CodigoCuenta = drr("CuentaFormato").ToString()
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
||||||
NombreCuenta = drr("Nombre").ToString()
|
NombreCuenta = drr("Nombre").ToString()
|
||||||
@@ -1457,8 +1472,8 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
TxtAbono.Text = ""
|
TxtAbono.Text = ""
|
||||||
TxtReferencia.Text = ""
|
TxtReferencia.Text = ""
|
||||||
TxtDescripcion.Text = ""
|
TxtDescripcion.Text = ""
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
|
#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
|
||||||
Public Sub Bancos_Click(sender As Object, e As EventArgs)
|
Public Sub Bancos_Click(sender As Object, e As EventArgs)
|
||||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||||
@@ -1510,9 +1525,9 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
ObjContabilidad.Dispose()
|
ObjContabilidad.Dispose()
|
||||||
End Sub
|
End Sub
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||||
If UpPrePoliza.Visible Then
|
If UpPrePoliza.Visible Then
|
||||||
For Each Gvr As GridViewRow In GvPrePoliza.Rows
|
For Each Gvr As GridViewRow In GvPrePoliza.Rows
|
||||||
@@ -1669,11 +1684,11 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
ObjConta.Dispose()
|
ObjConta.Dispose()
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
#Region "COMPLEMENTO DE PAGO"
|
#Region "COMPLEMENTO DE PAGO"
|
||||||
|
|
||||||
Private Sub GeneraTimbre(CvePrePoliza As Integer)
|
Private Sub GeneraTimbre(CvePrePoliza As Integer)
|
||||||
Dim Str As New StringBuilder
|
Dim Str As New StringBuilder
|
||||||
Dim Banco As New ClsBancos
|
Dim Banco As New ClsBancos
|
||||||
@@ -1730,10 +1745,211 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
|
|
||||||
Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs)
|
Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs)
|
||||||
GeneraTimbre(CvePrePoliza)
|
GeneraTimbre(CvePrePoliza)
|
||||||
End Sub
|
End Sub
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Region "E X C E L"
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
|
||||||
|
RegistraScript(String.Format("$('#{0}').modal();", "DivCargaExcel"))
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
|
||||||
|
Dim NombreArchivo As String
|
||||||
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||||
|
Dim workbook As New ExcelFile()
|
||||||
|
Dim worksheet = workbook.Worksheets.Add(DdlPlantilla2.SelectedItem.Text.ToString)
|
||||||
|
|
||||||
|
Dim CvePlantilla As Integer = DdlPlantilla2.SelectedValue.ToEntero
|
||||||
|
Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden")
|
||||||
|
|
||||||
|
Dim DtExcel As DataTable = (From row As DataRow In Dt.Rows
|
||||||
|
Select New With
|
||||||
|
{
|
||||||
|
.ConceptoAdministrativo = row.Item("ConceptoContable"),
|
||||||
|
.Cuenta = row.Item("Codigo"),
|
||||||
|
.NombreCuenta = row.Item("NombreCuenta"),
|
||||||
|
.Cargo = "",
|
||||||
|
.Abono = "",
|
||||||
|
.Referencia = "",
|
||||||
|
.Concepto = "",
|
||||||
|
.SubProyecto = row.Item("SubProyecto"),
|
||||||
|
.CveConceptoContable = row.Item("CveConcepto"),
|
||||||
|
.CveSubProyecto = IIf(row.Item("CveSubProyecto").ToString.ToEntero > 0, row.Item("CveSubProyecto"), -1),
|
||||||
|
.IdCtaContable = IIf(row.Item("IdCtaContable").ToString.ToEntero > 0, row.Item("IdCtaContable"), -1),
|
||||||
|
.CveCuenta = row.Item("CveCuenta")
|
||||||
|
}).QueryToDataTable(True)
|
||||||
|
|
||||||
|
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||||
|
{
|
||||||
|
.ColumnHeaders = True,
|
||||||
|
.StartRow = 0,
|
||||||
|
.StartColumn = 0
|
||||||
|
})
|
||||||
|
|
||||||
|
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||||
|
For i = 0 To columnCount
|
||||||
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||||
|
Next
|
||||||
|
worksheet.Columns("I").Hidden = True
|
||||||
|
worksheet.Columns("J").Hidden = True
|
||||||
|
worksheet.Columns("K").Hidden = True
|
||||||
|
worksheet.Columns("L").Hidden = True
|
||||||
|
|
||||||
|
|
||||||
|
NombreArchivo = DdlPlantilla2.SelectedItem.Text.ToString
|
||||||
|
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
||||||
|
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected 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 = Server.MapPath("~") & file.patch
|
||||||
|
|
||||||
|
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
||||||
|
CargarArchivo(Directorio, file.filename, Tipo)
|
||||||
|
Else
|
||||||
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
||||||
|
Dim dt As New DataTable
|
||||||
|
' Conexion As Odbc.OdbcConnection = Nothing
|
||||||
|
Dim ErrorArchivo = False
|
||||||
|
Dim ErrorExcel = False
|
||||||
|
|
||||||
|
dt = ReadExcelFile(Ruta + FileName, True)
|
||||||
|
|
||||||
|
|
||||||
|
If Not ErrorArchivo Then
|
||||||
|
|
||||||
|
If Not dt.Columns(0).ColumnName = "ConceptoAdministrativo" Then
|
||||||
|
Alert("El nombre de la primera columna debe ser 'ConceptoAdmin'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(1).ColumnName = "Cuenta" Then
|
||||||
|
Alert("El nombre de la segunda columna debe ser 'Cuenta'.Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(2).ColumnName = "NombreCuenta" Then
|
||||||
|
Alert("El nombre de la tercera columna debe ser 'NombreCuenta'.Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(3).ColumnName = "Cargo" Then
|
||||||
|
Alert("El nombre de la cuarta columna debe ser 'Cargo'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(4).ColumnName = "Abono" Then
|
||||||
|
Alert("El nombre de la quinta columna debe ser 'Abono' .Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(5).ColumnName = "Referencia" Then
|
||||||
|
Alert("El nombre de la sexta columna debe ser 'Referencia'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(6).ColumnName = "Concepto" Then
|
||||||
|
Alert("El nombre de la séptima columna debe ser 'Concepto'.Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not dt.Columns(7).ColumnName = "SubProyecto" Then
|
||||||
|
Alert("El nombre de la octava columna debe ser 'SubProyecto'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not ErrorArchivo Then
|
||||||
|
|
||||||
|
|
||||||
|
Dim ObjConta As New ClsContabilidad()
|
||||||
|
ObjConta.IniciaTransacSQL()
|
||||||
|
Try
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
Dim ContadorUpdate As Integer = 0
|
||||||
|
Dim ContadorError As Integer = 0
|
||||||
|
Dim NombreCuenta As String = ""
|
||||||
|
Dim CvePrePoliza As Integer = 0
|
||||||
|
Dim Cuenta As String = ""
|
||||||
|
Dim Reporte As New StringBuilder
|
||||||
|
Dim TotalCargos As Integer = 0
|
||||||
|
Dim TotalAbonos As Integer = 0
|
||||||
|
|
||||||
|
|
||||||
|
CvePrePoliza = ObjConta.AddPrePolizas("Contabilidad/RegPrePolizaExcel", DdlPlantilla2.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFecha.Text.ToDate, DdlPlantilla2.SelectedItem.Text.ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=DdlTipoPolizaAdd.SelectedValue.ToEntero)
|
||||||
|
|
||||||
|
|
||||||
|
For Each Row As DataRow In dt.Rows
|
||||||
|
NombreCuenta = Row("NombreCuenta").ToString
|
||||||
|
Cuenta = Row("Cuenta").ToString
|
||||||
|
|
||||||
|
Dim Importe As Decimal = If(Row("Cargo").ToString.ToDecimal <> 0, Row("Cargo").ToString.ToDecimal, Row("Abono").ToString.ToDecimal)
|
||||||
|
Dim Concepto As String = Row("Concepto").ToString
|
||||||
|
Dim Referencia As String = Row("Referencia").ToString
|
||||||
|
Dim IdCuenta As Integer = -1
|
||||||
|
Dim CveSubProyecto As Integer = Row("CveSubProyecto").ToString.ToEntero
|
||||||
|
Dim TipoMovto As Boolean = If(Row("Cargo").ToString.ToDecimal <> 0, False, True)
|
||||||
|
Dim YaExiste As Boolean = False
|
||||||
|
Dim CveConceptoContable As Integer = Row("CveConceptoContable").ToString.ToEntero
|
||||||
|
Dim IdCtaContable As Integer = Row("IdCtaContable").ToString.ToEntero
|
||||||
|
|
||||||
|
|
||||||
|
If Importe <> 0 Then
|
||||||
|
|
||||||
|
If ObjConta.GetCuentas(-1, Cuenta.Replace("-", ""), 1, UsuarioActual.CveEmpresa) Then
|
||||||
|
If ObjConta.DtResultados.Rows.Count > 0 Then
|
||||||
|
IdCuenta = ObjConta.DtResultados().FiltroPrimeroValor("CveCuenta").ToEntero
|
||||||
|
'TipoCuenta = ObjConta.DtResultados().FiltroPrimeroValor("Tipo")
|
||||||
|
Else
|
||||||
|
Reporte.AppendLine($"{Cuenta} - {NombreCuenta} - {Importe} </br>")
|
||||||
|
TieneError = True
|
||||||
|
YaExiste = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If YaExiste = False Then
|
||||||
|
If IdCuenta > 0 Then
|
||||||
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", CveConceptoContable, Concepto, Now.ToDate, IdCtaContable, -1, ImporteMX:=Importe, CveSubProyecto:=CveSubProyecto, CveCuenta:=IdCuenta) Then
|
||||||
|
TieneError = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
IdCuenta = -2
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Next
|
||||||
|
If Not TieneError Then
|
||||||
|
ObjConta.Commit()
|
||||||
|
Alert(String.Format("<br/><br/>Prepóliza: <b><a href = ""/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}"" class=""texto"" target=""_blank"" >{1}</a></b>", CvePrePoliza, "Ver"))
|
||||||
|
|
||||||
|
Alert($"Se agregó la póliza {ObjConta.ContaFolio}")
|
||||||
|
|
||||||
|
Else
|
||||||
|
Alert($"No encontraron las siguientes cuentas: {Reporte.ToString} ", TipoMensaje.MsgError)
|
||||||
|
ObjConta.RollBack()
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
ObjConta.RollBack()
|
||||||
|
End Try
|
||||||
|
|
||||||
|
ObjConta.Dispose()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
#End Region
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user