This commit is contained in:
@@ -1880,7 +1880,7 @@ Partial Class ContabilidadC_RegPrePolizaS
|
||||
' Conexion As Odbc.OdbcConnection = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
Dim ErrorExcel = False
|
||||
|
||||
DdlPlantilla.SelectedValue = DdlPlantilla2.SelectedValue
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
|
||||
|
||||
@@ -1922,35 +1922,21 @@ Partial Class ContabilidadC_RegPrePolizaS
|
||||
|
||||
If Not ErrorArchivo Then
|
||||
|
||||
DtMovimientos.Clear()
|
||||
|
||||
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 CveCuenta As Integer = -1
|
||||
Dim NombreCuenta As String = Row("NombreCuenta").ToString
|
||||
Dim Cuenta As String = Row("Cuenta").ToString
|
||||
Dim ConceptoAdministrativo As String = Row("ConceptoAdministrativo").ToString
|
||||
|
||||
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
|
||||
Dim CveClasificacion As Integer = -1
|
||||
@@ -1963,56 +1949,44 @@ Partial Class ContabilidadC_RegPrePolizaS
|
||||
|
||||
If CveSubProyecto = 0 Then CveSubProyecto = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto = '{0}'", Row("SubProyecto"))).ToEntero
|
||||
|
||||
Dim dr As DataRow = DtMovimientos.NewRow
|
||||
Dim CodigoCuenta As String = ""
|
||||
|
||||
dr("IdCuenta") = IdCtaContable
|
||||
dr("CodigoCuenta") = Cuenta & "<br>" & NombreCuenta
|
||||
dr("Cuenta") = ConceptoAdministrativo
|
||||
dr("Referencia") = Row("Referencia").ToString
|
||||
dr("Concepto") = Row("Concepto").ToString
|
||||
dr("TipoMovto") = TipoMovto
|
||||
dr("EsComodin") = 0
|
||||
dr("CveConcepto") = CveConceptoContable
|
||||
dr("CveConceptoContable") = CveConceptoContable
|
||||
dr("ConceptoContable") = ""
|
||||
dr("Cargo") = Row("Cargo").ToString.ToDecimal
|
||||
dr("Abono") = Row("Abono").ToString.ToDecimal
|
||||
dr("Descripcion") = ""
|
||||
dr("CveSubProyecto") = CveSubProyecto
|
||||
dr("CveProveedor") = -1
|
||||
dr("CveCompra") = -1
|
||||
dr("CvePersonal") = -1
|
||||
dr("CveClasificacion") = CveClasificacion
|
||||
dr("CveCliente") = -1
|
||||
dr("CveVenta") = -1
|
||||
|
||||
If Importe <> 0 Then
|
||||
|
||||
If ObjConta.GetCuentas(-1, Cuenta.Replace("-", ""), 1, UsuarioActual.CveEmpresa) Then
|
||||
If ObjConta.DtResultados.Rows.Count > 0 Then
|
||||
CveCuenta = 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 CveCuenta > 0 Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", CveConceptoContable, Concepto, Now.ToDate, IdCtaContable, -1, ImporteMX:=Importe, CveSubProyecto:=CveSubProyecto, CveClasificacion:=CveClasificacion, CveCuenta:=CveCuenta) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
CveCuenta = -2
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero
|
||||
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero
|
||||
DtMovimientos.Rows.Add(dr)
|
||||
DtMovimientos.AcceptChanges()
|
||||
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
|
||||
|
||||
GvMov.DataSource = DtMovimientos
|
||||
GvMov.DataBind()
|
||||
UPMovs.Update()
|
||||
|
||||
Catch ex As Exception
|
||||
ObjConta.RollBack()
|
||||
Alert("No se pudo cargar el excel")
|
||||
End Try
|
||||
|
||||
ObjConta.Dispose()
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Reference in New Issue
Block a user