561 lines
22 KiB
VB.net
561 lines
22 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Linq
|
|
Imports System.Web.Services
|
|
|
|
Partial Class Contabilidad_RegPrePoliza
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
|
|
|
|
Public Property ArregloMovs As ArrayList
|
|
Get
|
|
Return CType(ViewState("ArregloMovs"), ArrayList)
|
|
End Get
|
|
Set(value As ArrayList)
|
|
ViewState("ArregloMovs") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtMovimientos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtCuentasContables As DataTable
|
|
Get
|
|
Return CType(ViewState("DtCuentasContables"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtCuentasContables") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property TipoPlantilla As Integer
|
|
Get
|
|
Return CType(ViewState("TipoPlantilla"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoPlantilla") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveMoneda As Integer
|
|
Get
|
|
Return CType(ViewState("CveMoneda"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private ReadOnly Property CvePrePoliza As Integer
|
|
Get
|
|
Return ViewState("CvePrePoliza").ToString.ToEntero
|
|
End Get
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
CveMoneda = 1
|
|
ViewState("CvePrePoliza") = 0
|
|
|
|
Dim dt As DataTable = Nothing
|
|
Dim Conta As New ClsContabilidad
|
|
|
|
If Conta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
dt = Conta.DtResultados
|
|
DtCuentasContables = Conta.DtResultados
|
|
Session("DtCuentas") = Conta.DtResultados
|
|
End If
|
|
Conta.Dispose()
|
|
|
|
If Request("CvePrePoliza") IsNot Nothing AndAlso IsNumeric(Request("CvePrePoliza")) AndAlso Request("CvePrePoliza").ToEntero > 0 Then
|
|
ViewState("CvePrePoliza") = Request("CvePrePoliza").ToEntero
|
|
CargaPrePoliza()
|
|
Exit Sub
|
|
End If
|
|
|
|
TipoPlantilla = 0
|
|
If IfNull(Request("Tipo"), "").ToString = "Ing" Then
|
|
TipoPlantilla = 1
|
|
LblEncabezado.Text = "Otros Ingresos"
|
|
Else
|
|
|
|
|
|
End If
|
|
|
|
CargaPlantillas(TipoPlantilla)
|
|
|
|
If UsuarioActual.CveEmpresa = 66 Then trNotificar.Visible = True
|
|
|
|
CargaConceptos()
|
|
CargaSubProyectos()
|
|
CargaCuentasContables()
|
|
|
|
'crea tabla temporal
|
|
ArregloMovs = New ArrayList
|
|
DtMovimientos = New DataTable("Movimientos")
|
|
Dim IDMov As DataColumn = DtMovimientos.Columns.Add("IdMov", Type.GetType("System.Int32")) : IDMov.AutoIncrement = True
|
|
With DtMovimientos.Columns
|
|
.Add("IdCuenta", Type.GetType("System.Int32"))
|
|
.Add("CodigoCuenta", Type.GetType("System.String"))
|
|
.Add("Cuenta", Type.GetType("System.String"))
|
|
.Add("Referencia", Type.GetType("System.String"))
|
|
.Add("Concepto", Type.GetType("System.String"))
|
|
.Add("Cargo", Type.GetType("System.Double"))
|
|
.Add("Abono", Type.GetType("System.Double"))
|
|
.Add("TipoMovto", Type.GetType("System.Int32"))
|
|
.Add("EsComodin", Type.GetType("System.Int32"))
|
|
.Add("CveConcepto", Type.GetType("System.Int32"))
|
|
.Add("CveSubProyecto", Type.GetType("System.Int32"))
|
|
.Add("Descripcion", Type.GetType("System.String"))
|
|
.Add("CveProveedor", Type.GetType("System.Int32"))
|
|
.Add("CvePersonal", Type.GetType("System.Int32"))
|
|
End With
|
|
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaPrePoliza()
|
|
|
|
LblEncabezado.Text = "Edicion de Póliza"
|
|
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza)
|
|
|
|
GvPrePoliza.DataSource = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
GvPrePoliza.DataBind()
|
|
|
|
DivConceptoPrePoliza.Visible = False
|
|
UPMovs.Visible = False
|
|
UPMovs.Update()
|
|
UPPDocumento.Update()
|
|
UpPrePoliza.Update()
|
|
|
|
RegistraScript("comparar();")
|
|
|
|
If Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").ToEntero = 1 AndAlso UsuarioActual.CveUsuario <> 100 Then
|
|
For Each row As GridViewRow In GvPrePoliza.Rows
|
|
row.FCTextBox("TxtCargo").Enabled = False
|
|
row.FCTextBox("TxtAbono").Enabled = False
|
|
Next
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
End Sub
|
|
|
|
Private Sub GvPrePoliza_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPrePoliza.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
'Asignamos los Subproyectos
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataBind()
|
|
e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1"))
|
|
e.Row.FCDropDownList("DdlSubProyecto").SelectedValueExist(e.Row.DataKey("CveSubProyecto"))
|
|
|
|
'ASignamos las CuentasContables
|
|
e.Row.FCDropDownList("DdlCtaContable").DataSource = Session("DtCuentas")
|
|
e.Row.FCDropDownList("DdlCtaContable").DataBind()
|
|
e.Row.FCDropDownList("DdlCtaContable").Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
e.Row.FCDropDownList("DdlCtaContable").SelectedValueExist(e.Row.DataKey("IdCtaContable"))
|
|
|
|
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + e.Row.FCTextBox("TxtCargo").Text.ToDouble)
|
|
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCTextBox("TxtAbono").Text.ToDouble)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaPlantillas(TipoPlantilla As Integer)
|
|
|
|
'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
'GvPlantillas.DataBind()
|
|
|
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
DdlPlantilla.DataBind()
|
|
DdlPlantilla.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
|
End Sub
|
|
|
|
Private Sub CargaConceptos()
|
|
DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
|
|
DdlConceptosContables.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaSubProyectos()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaCuentasContables()
|
|
DdlCtaContable.DataSource = Session("DtCuentas")
|
|
DdlCtaContable.DataBind()
|
|
DdlCtaContable.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
End Sub
|
|
|
|
Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
|
|
|
|
TxtTotalAbonos.Text = ""
|
|
TxtTotalCargos.Text = ""
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Seleccione un Movimiento Válido", TipoMensaje.MsgAdvertencia)
|
|
DdlPlantilla.SelectedValue = "-1"
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada
|
|
DivAgregarConceptos.Visible = True
|
|
Else
|
|
DivAgregarConceptos.Visible = False
|
|
End If
|
|
|
|
|
|
|
|
Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
|
|
|
|
Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden")
|
|
Dim Cuenta As String = ""
|
|
Dim IdCuenta As Integer = 0
|
|
Dim CodigoCuenta As String = ""
|
|
Dim NombreCuenta As String = ""
|
|
Dim EsComodin As Integer = 0
|
|
DtMovimientos.Clear()
|
|
|
|
For Each drt As DataRow In Dt.Rows
|
|
|
|
Cuenta = drt("ConceptoContable").ToString
|
|
IdCuenta = 0
|
|
CodigoCuenta = ""
|
|
NombreCuenta = ""
|
|
If drt("IdCtaContable").ToString.ToEntero > 0 Then 'DtCuentasContables
|
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", drt("IdCtaContable").ToString))
|
|
If drr IsNot Nothing Then
|
|
IdCuenta = drt("IdCtaContable").ToString.ToEntero
|
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
|
NombreCuenta = drr("Nombre").ToString()
|
|
'Cuenta = drr("Nombre").ToString()
|
|
End If
|
|
EsComodin = 0
|
|
End If
|
|
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
dr("IdCuenta") = IdCuenta
|
|
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
|
|
dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
|
|
dr("Referencia") = If(drt("CveConcepto").ToString.Contiene("29", "130"), drt("Personal"), drt("RazonSocial"))
|
|
dr("Concepto") = TxtObservaciones.Text
|
|
dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1)
|
|
dr("EsComodin") = EsComodin
|
|
dr("CveConcepto") = drt("CveConcepto")
|
|
dr("CveSubProyecto") = drt("CveSubProyectoNegativo")
|
|
dr("Cargo") = TxtCargo.Text.ToDouble
|
|
dr("Abono") = TxtAbono.Text.ToDouble
|
|
dr("CveProveedor") = drt("CveProveedor")
|
|
dr("CvePersonal") = drt("CvePersonal")
|
|
DtMovimientos.Rows.Add(dr)
|
|
Next
|
|
|
|
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Height = Unit.Pixel(1)
|
|
e.Row.Cells(0).ToolTip = e.Row.DBCampo("IdCuenta")
|
|
If e.Row.DBCampo("TipoMovto") = "1" Then
|
|
e.Row.FCTextBox("TxtAbono").Visible = True
|
|
Else
|
|
e.Row.FCTextBox("TxtCargo").Visible = True
|
|
End If
|
|
|
|
e.Row.FCTextBox("TxtAbono").Text = If(e.Row.DBCampo("Abono") = 0, "", e.Row.DBCampo("Abono"))
|
|
e.Row.FCTextBox("TxtCargo").Text = If(e.Row.DBCampo("Cargo") = 0, "", e.Row.DBCampo("Cargo"))
|
|
e.Row.FCTextBox("TxtConcepto").Text = e.Row.DBCampo("Descripcion")
|
|
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataBind()
|
|
e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1"))
|
|
e.Row.FCDropDownList("DdlSubProyecto").SelectedValue = e.Row.DBCampo("CveSubProyecto")
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero = 53 Then
|
|
e.Row.FCDropDownList("DdlSubProyecto").Enabled = True
|
|
Else
|
|
e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
|
|
End If
|
|
|
|
'Agregamos la opcion para vincular los movimientos bancarios
|
|
If e.Row.DataKey("CveConcepto").ToEntero.Contiene(41) Then
|
|
Dim ObjMovimientos As New ClsMovimientos
|
|
Dim DdlSaldos As DropDownList = e.Row.FCDropDownList("DdlSaldos")
|
|
|
|
Select Case e.Row.DataKey("CveConcepto").ToEntero
|
|
|
|
'Acreedores
|
|
Case 41
|
|
If (ObjMovimientos.GetAcreedoresSaldosDetalles(-1,-1, UsuarioActual.CveEmpresa)) Then
|
|
DdlSaldos.Visible = True
|
|
DdlSaldos.DataSource = ObjMovimientos.DtResultados.FiltraParametros($"CveIE > 0 AND CveProveedor = {e.Row.DataKey("CveProveedor").ToEntero}")
|
|
DdlSaldos.DataBind()
|
|
DdlSaldos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
End Select
|
|
|
|
ObjMovimientos.Dispose()
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
|
|
|
|
Dim TotalCargos, TotalAbonos As Decimal
|
|
|
|
If CvePrePoliza > 0 Then
|
|
TotalCargos = TxtTotalCargos.Text.ToDouble
|
|
TotalAbonos = TxtTotalAbonos.Text.ToDouble
|
|
Else
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDecimal
|
|
TotalAbonos += Gvr.FCTextBox("TxtAbono").Text.ToDecimal
|
|
Next
|
|
End If
|
|
|
|
If TotalCargos = TotalAbonos AndAlso TotalCargos <> 0 Then
|
|
|
|
If CvePrePoliza > 0 Then
|
|
|
|
'Nuevo Modulo Charlie
|
|
ActualizarPrePoliza()
|
|
|
|
Else
|
|
Dim MensajeAlert = New StringBuilder
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
'Dim Conta As ClsContPAQi = Nothing
|
|
Dim IDPoliza As Integer = 0
|
|
Dim MsgError As String = ""
|
|
|
|
|
|
If MsgError = "" Then
|
|
|
|
|
|
Try
|
|
Dim CvePrePoliza As Integer
|
|
Dim ConceptoPoliza As String = TxtObservaciones.Text
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Contabilidad/RegPrePoliza", DdlPlantilla.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
|
|
If CvePrePoliza > 0 Then
|
|
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
|
|
Dim idCuentaContabilizacion As Long = 1
|
|
Dim Importe As Double = 0
|
|
Dim TipoMovto As Boolean = False
|
|
Dim IdCtaContable As Integer = 0
|
|
'inserto las compras que voy a pagar
|
|
For Each gvr As GridViewRow In GvMov.Rows
|
|
|
|
If gvr.DataKey("IDCuenta").ToEntero > 0 Then
|
|
IdCtaContable = gvr.DataKey("IDCuenta")
|
|
End If
|
|
|
|
If gvr.DataKey("TipoMovto").ToDouble > 0 Then
|
|
Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble
|
|
TipoMovto = True
|
|
Else
|
|
Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble
|
|
TipoMovto = False
|
|
End If
|
|
|
|
|
|
If MsgError = "" Then
|
|
|
|
If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
|
|
idCuentaContabilizacion = 0
|
|
End If
|
|
If Importe > 0 Then
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.DataKey("CveConcepto").ToEntero, gvr.FCTextBox("TxtConcepto").Text, TxtFecha.Text.ToDate, IdCtaContable, -1, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CveIE:=gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, ImporteMX:=Importe) Then
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar el detalle de la póliza2"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
'El movimiento 2 es el de Pago
|
|
If ChkAutoConta.Checked AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
|
|
If idCuentaContabilizacion > 0 Then
|
|
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
|
|
|
|
'MENSAJE PRINCIPAL
|
|
MensajeAlert.AppendFormat("<br/><br/>Folio de Salida: <b><a href = ""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"" class=""texto"" target=""_blank"" >{1}</a></b>", ObjMov.ContaIdPoliza, ObjMov.ContaFolio)
|
|
Alert(MensajeAlert.ToString, ModExtensiones.TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico")
|
|
End If
|
|
Else
|
|
Alert("No se puede contabilizar la Prepoliza debido a que una o mas cuentas son inválidas")
|
|
End If
|
|
End If
|
|
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
MsgError = "Error"
|
|
End Try
|
|
|
|
If MsgError = "" Then
|
|
ObjIE.Commit()
|
|
|
|
|
|
Alert("El movimiento se guardó correctamente.")
|
|
|
|
'If Conta IsNot Nothing Then Conta.Commit()
|
|
|
|
UPPDocumento.Update()
|
|
|
|
|
|
TxtObservaciones.Text = ""
|
|
GvMov.DataBind()
|
|
TxtFecha.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
|
|
RegistraScript("window.location.reload()")
|
|
Else
|
|
ObjIE.RollBack()
|
|
'If Conta IsNot Nothing Then Conta.RollBack()
|
|
End If
|
|
|
|
|
|
Else
|
|
'If Conta IsNot Nothing Then Conta.RollBack()
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
'If Conta IsNot Nothing Then Conta.Dispose()
|
|
End If
|
|
Else
|
|
Alert("La suma de los movimientos no son iguales", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub ActualizarPrePoliza()
|
|
|
|
Dim OcurrioError As Boolean = False
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
ObjContabilidad.IniciaTransacSQL()
|
|
|
|
For Each row As GridViewRow In GvPrePoliza.Rows
|
|
If Not ObjContabilidad.UpdatePrepolizasDetalle(row.DataKey("CvePrePolizaDetalle").ToEntero, row.FCTextBox("TxtConcepto").Text, row.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero,
|
|
row.FCDropDownList("DdlCtaContable").SelectedValue.ToEntero, If(row.FCTextBox("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCTextBox("TxtCargo").Text.ToDecimal <> 0,
|
|
row.FCTextBox("TxtCargo").Text.ToDecimal, row.FCTextBox("TxtAbono").Text.ToDecimal), CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
OcurrioError = True
|
|
End If
|
|
Next
|
|
|
|
If Not OcurrioError Then
|
|
ObjContabilidad.Commit()
|
|
Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
ObjContabilidad.RollBack()
|
|
Alert("Ocurrio un error al actualizar la PrePoliza.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub GvMov_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMov.RowDeleting
|
|
|
|
Dim idMov As Integer = GvMov.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & idMov)
|
|
If Rows.Count > 0 Then
|
|
DtMovimientos.Rows.Remove(Rows(0))
|
|
DtMovimientos.AcceptChanges()
|
|
End If
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
|
|
TxtTotalAbonos.Text = DtMovimientos.SUM("Abono").FormatoNumero
|
|
TxtTotalCargos.Text = DtMovimientos.SUM("Cargo").FormatoNumero
|
|
|
|
'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
|
|
|
|
End Sub
|
|
|
|
Private Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
Dim CodigoCuenta As String = ""
|
|
Dim NombreCuenta As String = ""
|
|
|
|
dr("IdCuenta") = DdlCtaContable.SelectedValue
|
|
|
|
If DdlCtaContable.SelectedValue.ToEntero > 0 Then
|
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", DdlCtaContable.SelectedValue))
|
|
If drr IsNot Nothing Then
|
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
|
NombreCuenta = drr("Nombre").ToString()
|
|
End If
|
|
End If
|
|
|
|
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
|
|
dr("Cuenta") = DdlConceptosContables.SelectedItem
|
|
dr("Referencia") = TxtReferencia.Text
|
|
dr("Concepto") = TxtObservaciones.Text
|
|
dr("TipoMovto") = If(TxtCargo.Text.ToDouble > 0, 0, 1)
|
|
dr("EsComodin") = 0
|
|
dr("CveConcepto") = DdlConceptosContables.SelectedValue
|
|
dr("Cargo") = TxtCargo.Text.ToDouble
|
|
dr("Abono") = TxtAbono.Text.ToDouble
|
|
dr("Descripcion") = TxtDescripcion.Text
|
|
dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
|
|
|
|
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero
|
|
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero
|
|
|
|
DtMovimientos.Rows.Add(dr)
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
|
|
TxtCargo.Text = ""
|
|
TxtAbono.Text = ""
|
|
TxtReferencia.Text = ""
|
|
TxtDescripcion.Text = ""
|
|
|
|
End Sub
|
|
|
|
End Class
|
|
|