From eb11e065ec584237dc484a4188f7da17ea89ccd0 Mon Sep 17 00:00:00 2001 From: rrene Date: Sun, 10 Jan 2021 21:18:43 -0700 Subject: [PATCH 01/13] clasificacion en concepto 51 --- Contabilidad/RegPrePoliza.aspx | 1 + Contabilidad/RegPrePoliza.aspx.vb | 2833 ++++++++++++++-------------- Contabilidad/RegPrePolizaS.aspx | 1 + Contabilidad/RegPrePolizaS.aspx.vb | 13 + 4 files changed, 1437 insertions(+), 1411 deletions(-) diff --git a/Contabilidad/RegPrePoliza.aspx b/Contabilidad/RegPrePoliza.aspx index 1cb80a307..56e6c5379 100644 --- a/Contabilidad/RegPrePoliza.aspx +++ b/Contabilidad/RegPrePoliza.aspx @@ -194,6 +194,7 @@

+ diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb index 6215cdbce..197c8bf07 100644 --- a/Contabilidad/RegPrePoliza.aspx.vb +++ b/Contabilidad/RegPrePoliza.aspx.vb @@ -1,195 +1,195 @@ - - -Imports System.Data -Imports Extensiones -Imports System.Linq -Imports System.Web.Services - -Partial Class ContabilidadC_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 - - 'PARA CREAR IE - Private Property CveConcepto As Integer - Get - Return ViewState("CveConcepto").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveConcepto") = value - End Set - End Property - Private Property CveTipoTransaccion As Integer - Get - Return ViewState("CveTipoTransaccion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveTipoTransaccion") = value - End Set - End Property - Private Property CveCuenta As Integer - Get - Return ViewState("CveCuenta").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuenta") = value - End Set - End Property - Private Property Folio As String - Get - Return ViewState("Folio").ToString - End Get - Set(value As String) - ViewState("Folio") = value - End Set - End Property - Private Property ImporteDocumento As Decimal - Get - Return ViewState("ImporteDocumento").ToString.ToDecimal - End Get - Set(value As Decimal) - ViewState("ImporteDocumento") = value - End Set - End Property - Private Property Observaciones As String - Get - Return ViewState("Observaciones").ToString - End Get - Set(value As String) - ViewState("Observaciones") = value - End Set - End Property - Private Property Beneficiario As String - Get - Return ViewState("Beneficiario").ToString - End Get - Set(value As String) - ViewState("Beneficiario") = value - End Set - End Property - Private Property RowIndex As Integer - Get - Return ViewState("RowIndex").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("RowIndex") = value - End Set - End Property - Private Property Actualizar As Boolean - Get - Return CBool(ViewState("Actualizar").ToString) - End Get - Set(value As Boolean) - ViewState("Actualizar") = value - End Set - End Property - - Private ReadOnly Property CvePeriodo As Integer - Get - Return CType(ViewState("CvePeriodo"), Integer) - End Get - End Property - Private ReadOnly Property CveProyecto As Integer - Get - Return CType(ViewState("CveProyecto"), Integer) - End Get - End Property - Private ReadOnly Property CveSubProyecto As Integer - Get - Return CType(ViewState("CveSubProyecto"), Integer) - End Get - End Property - Private ReadOnly Property CveTurno As Integer - Get - Return CType(ViewState("CveTurno"), Integer) - End Get - End Property - Public Property IndiceGrid As Integer - Get - Return CType(ViewState("IndiceGrid"), Integer) - End Get - Set(value As Integer) - ViewState("IndiceGrid") = value - End Set - End Property - Public Property IdPoliza As Integer - Get - Return CType(ViewState("IdPoliza"), Integer) - End Get - Set(value As Integer) - ViewState("IdPoliza") = value - End Set - End Property -#End Region + - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - - If Not Page.IsPostBack Then +Imports System.Data +Imports Extensiones +Imports System.Linq +Imports System.Web.Services + +Partial Class ContabilidadC_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 + + 'PARA CREAR IE + Private Property CveConcepto As Integer + Get + Return ViewState("CveConcepto").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveConcepto") = value + End Set + End Property + Private Property CveTipoTransaccion As Integer + Get + Return ViewState("CveTipoTransaccion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveTipoTransaccion") = value + End Set + End Property + Private Property CveCuenta As Integer + Get + Return ViewState("CveCuenta").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuenta") = value + End Set + End Property + Private Property Folio As String + Get + Return ViewState("Folio").ToString + End Get + Set(value As String) + ViewState("Folio") = value + End Set + End Property + Private Property ImporteDocumento As Decimal + Get + Return ViewState("ImporteDocumento").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("ImporteDocumento") = value + End Set + End Property + Private Property Observaciones As String + Get + Return ViewState("Observaciones").ToString + End Get + Set(value As String) + ViewState("Observaciones") = value + End Set + End Property + Private Property Beneficiario As String + Get + Return ViewState("Beneficiario").ToString + End Get + Set(value As String) + ViewState("Beneficiario") = value + End Set + End Property + Private Property RowIndex As Integer + Get + Return ViewState("RowIndex").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("RowIndex") = value + End Set + End Property + Private Property Actualizar As Boolean + Get + Return CBool(ViewState("Actualizar").ToString) + End Get + Set(value As Boolean) + ViewState("Actualizar") = value + End Set + End Property + + Private ReadOnly Property CvePeriodo As Integer + Get + Return CType(ViewState("CvePeriodo"), Integer) + End Get + End Property + Private ReadOnly Property CveProyecto As Integer + Get + Return CType(ViewState("CveProyecto"), Integer) + End Get + End Property + Private ReadOnly Property CveSubProyecto As Integer + Get + Return CType(ViewState("CveSubProyecto"), Integer) + End Get + End Property + Private ReadOnly Property CveTurno As Integer + Get + Return CType(ViewState("CveTurno"), Integer) + End Get + End Property + Public Property IndiceGrid As Integer + Get + Return CType(ViewState("IndiceGrid"), Integer) + End Get + Set(value As Integer) + ViewState("IndiceGrid") = value + End Set + End Property + Public Property IdPoliza As Integer + Get + Return CType(ViewState("IdPoliza"), Integer) + End Get + Set(value As Integer) + ViewState("IdPoliza") = value + End Set + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + + If Not Page.IsPostBack Then If UsuarioActual.Empresa.TipoContabilizacion = 1 Then Response.Redirect(Request.Url.PathAndQuery.Replace("RegPrePoliza", "RegPrePolizaS")) - End If - - CveMoneda = 1 - ViewState("CvePrePoliza") = 0 - ViewState("CvePeriodo") = "0" - CveConcepto = -1 - CveTipoTransaccion = -1 - CveCuenta = -1 - Folio = "-1" - ImporteDocumento = -1 - Observaciones = "-1" - Beneficiario = "-1" - Actualizar = False - IdPoliza = -1 - - Dim dt As DataTable = Nothing - ' If UsuarioActual.Empresa.UsaContabilidad Then + End If + + CveMoneda = 1 + ViewState("CvePrePoliza") = 0 + ViewState("CvePeriodo") = "0" + CveConcepto = -1 + CveTipoTransaccion = -1 + CveCuenta = -1 + Folio = "-1" + ImporteDocumento = -1 + Observaciones = "-1" + Beneficiario = "-1" + Actualizar = False + IdPoliza = -1 + + Dim dt As DataTable = Nothing + ' If UsuarioActual.Empresa.UsaContabilidad Then If UsuarioActual.Empresa.TipoContabilidad = 2 Then Dim Conta As New ClsContPAQi(UsuarioActual.Empresa) @@ -277,254 +277,254 @@ Partial Class ContabilidadC_RegPrePoliza GvPrePoliza.Columns(3).Visible = False GvConcepto.Columns(3).Visible = False GvMov.Columns(4).Visible = False - End If - - 'Else - ' Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia) - ' BtnIEGuardar.Enabled = False - ' BtnEliminar.Visible = False - ' LbAgregar.Enabled = False - 'End If - - End If - - End Sub - - - Private Sub CreaDT() - 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.Decimal")) - .Add("Abono", Type.GetType("System.Decimal")) - .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")) - .Add("CveCompra", Type.GetType("System.Int32")) - .Add("CveCliente", Type.GetType("System.Int32")) - .Add("CveVenta", Type.GetType("System.Int32")) - .Add("CveClasificacion", Type.GetType("System.Int32")) - .Add("MultipleSubProyecto", Type.GetType("System.Boolean")) - .Add("CveTipoGasto", Type.GetType("System.Int32")) - .Add("CvePrePolizaDetalle", Type.GetType("System.Int32")) - .Add("CveConceptoContable", Type.GetType("System.Int32")) - .Add("IdCtaContable", Type.GetType("System.Int32")) - .Add("CveOC", Type.GetType("System.Int32")) - .Add("ConceptoContable", Type.GetType("System.String")) - .Add("TC", Type.GetType("System.Decimal")) - .Add("PorcentajeImpuesto", Type.GetType("System.Decimal")) - .Add("CveCuenta", Type.GetType("System.Int32")) - End With - End Sub - - Private Sub CargaNomina() - Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero - Dim ObjNomina As New ClsNominas - Dim ObjConta As New ClsContabilidad - - Dim Dt As DataTable = Nothing - Dim Cuenta As String = "" - Dim Concepto As String = "" - Dim IdCuenta As Integer = 0 - Dim TipoMovto As Integer - Dim CveConcepto As Integer - Dim CodigoCuenta As String = "" - Dim NombreCuenta As String = "" - Dim Referencia As String = "" - Dim EsComodin As Integer = 0 - DtMovimientos.Clear() - - If ObjNomina.GetProvisionNomina(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, UsuarioActual.CveEmpresa) Then - Dt = ObjNomina.DtResultados - - For Each drt As DataRow In Dt.Rows - Dim dr As DataRow = DtMovimientos.NewRow - - If drt("NombreCompleto").ToString = "" AndAlso ObjConta.GetRetCuenta(31, UsuarioActual.CveEmpresa) Then - CveConcepto = 98 - Cuenta = "Nominas por Pagar" - IdCuenta = ObjConta.DtResultados(0)("IdCtaContable").ToString.ToEntero - Concepto = "Pago Nomina" - Referencia = "Pago Nomina" - Else - Concepto = drt("NombreCompleto") - Referencia = "" - CveConcepto = drt("CveConceptoContable").ToString.ToEntero - Cuenta = drt("ConceptoContable").ToString - IdCuenta = drt("IdCtaContable").ToString.ToEntero - End If - - Dim drr As DataRow = DtCuentasContables.FiltroPrimero($"Id={IdCuenta}") - CodigoCuenta = If(drr IsNot Nothing, drr("CuentaFormato").ToString(), "") - NombreCuenta = If(drr IsNot Nothing, drr("Nombre").ToString(), "") - - TipoMovto = drt("TipoMovto") - - If TipoMovto = 0 Then - dr("Cargo") = Math.Abs(drt("Importe").ToString.ToDecimal) - dr("Abono") = 0 - Else - dr("Cargo") = 0 - dr("Abono") = Math.Abs(drt("Importe").ToString.ToDecimal) - End If - - dr("IdCuenta") = IdCuenta - dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta - dr("Cuenta") = Cuenta - dr("Concepto") = Concepto - dr("Descripcion") = Concepto - dr("Referencia") = Referencia - dr("TipoMovto") = TipoMovto - dr("EsComodin") = EsComodin - dr("CveConcepto") = CveConcepto - dr("CveProveedor") = "-1" - dr("CveSubProyecto") = drt("CveSubProyecto") - dr("CvePersonal") = drt("CvePersonal") - dr("CveClasificacion") = drt("CveClasificacion") - dr("CveTipoGasto") = drt("CveTipoGasto") - - DtMovimientos.Rows.Add(dr) - Next - - GvMov.DataSource = DtMovimientos - GvMov.DataBind() - UPMovs.Update() - End If - - End Sub - - Private Sub CargaPrePoliza() - BtnEliminar.Visible = True - LblEncabezado.Text = "Edición de Póliza" - - Dim ObjContabilidad As New ClsContabilidad - If ObjContabilidad.GetPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa) Then - Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("") - If dr IsNot Nothing Then - DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza") - TxtFechaDocumento.Text = dr("Fecha") - TxtConcepto.Text = dr("Concepto") - DivDatosPoliza.Visible = True - - If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then - DivAgregarConceptos.Visible = True - CargaConceptos() - CargaSubProyectos() - CargaCuentasContables() - End If - - ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza) - - DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") - GvPrePoliza.DataSource = DtMovimientos - GvPrePoliza.DataBind() - - If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17)").Rows.Count > 0 Then - LnkComplementoPago.Visible = True - End If - - IdPoliza = dr("IdPoliza").ToString.ToEntero - If dr("IdPoliza").ToString.ToEntero > 0 Then - HplContabilizada.NavigateUrl = String.Format("RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) - divContabilziada.Visible = True - BtnEliminar.Visible = False - If UsuarioActual.CveUsuario = 100 Then - BtnContabilizar.Visible = True - BtnContabilizar.Text = "Actualizar Poliza" - End If - ElseIf TxtTotalCargos.Text.ToDouble = TxtTotalAbonos.Text.ToDouble Then - 'sino está contabilizada, se activa el botón - BtnContabilizar.Visible = True - End If - - divDatosPrincipales.Visible = False - divObservaciones.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 - - Else - Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia) - BtnEliminar.Visible = False - End If - - End If - CargaGvBitacora() - ObjContabilidad.Dispose() - UpPoliza.Update() - UpBitacora.Update() - 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 los Tipos de Gasto - e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlTipoGasto").DataBind() - e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) - e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto")) - - '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).ToString.FormatoNumero - TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCTextBox("TxtAbono").Text.ToDouble).ToString.FormatoNumero - - Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero - - If CveConceptoContable.Contiene(1, 2, 12, 13, 38, 207, 203, 39, 61, 62, 63, 150, 251, 226) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta")) - If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 205, 225, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra")) - If CveConceptoContable.Contiene(176) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/OC/OC.aspx?CveOrdenCompra={0}", e.Row.DataKey("CveOC")) - If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) - If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) - - - 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable - - End If - - If e.Row.RowType = DataControlRowType.Header Then - e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind() - e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1")) - End If - - End Sub - - Private Sub CargaPlantillas(TipoPlantilla As Integer) - - 'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla) - 'GvPlantillas.DataBind() - + End If + + 'Else + ' Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia) + ' BtnIEGuardar.Enabled = False + ' BtnEliminar.Visible = False + ' LbAgregar.Enabled = False + 'End If + + End If + + End Sub + + + Private Sub CreaDT() + 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.Decimal")) + .Add("Abono", Type.GetType("System.Decimal")) + .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")) + .Add("CveCompra", Type.GetType("System.Int32")) + .Add("CveCliente", Type.GetType("System.Int32")) + .Add("CveVenta", Type.GetType("System.Int32")) + .Add("CveClasificacion", Type.GetType("System.Int32")) + .Add("MultipleSubProyecto", Type.GetType("System.Boolean")) + .Add("CveTipoGasto", Type.GetType("System.Int32")) + .Add("CvePrePolizaDetalle", Type.GetType("System.Int32")) + .Add("CveConceptoContable", Type.GetType("System.Int32")) + .Add("IdCtaContable", Type.GetType("System.Int32")) + .Add("CveOC", Type.GetType("System.Int32")) + .Add("ConceptoContable", Type.GetType("System.String")) + .Add("TC", Type.GetType("System.Decimal")) + .Add("PorcentajeImpuesto", Type.GetType("System.Decimal")) + .Add("CveCuenta", Type.GetType("System.Int32")) + End With + End Sub + + Private Sub CargaNomina() + Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero + Dim ObjNomina As New ClsNominas + Dim ObjConta As New ClsContabilidad + + Dim Dt As DataTable = Nothing + Dim Cuenta As String = "" + Dim Concepto As String = "" + Dim IdCuenta As Integer = 0 + Dim TipoMovto As Integer + Dim CveConcepto As Integer + Dim CodigoCuenta As String = "" + Dim NombreCuenta As String = "" + Dim Referencia As String = "" + Dim EsComodin As Integer = 0 + DtMovimientos.Clear() + + If ObjNomina.GetProvisionNomina(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, UsuarioActual.CveEmpresa) Then + Dt = ObjNomina.DtResultados + + For Each drt As DataRow In Dt.Rows + Dim dr As DataRow = DtMovimientos.NewRow + + If drt("NombreCompleto").ToString = "" AndAlso ObjConta.GetRetCuenta(31, UsuarioActual.CveEmpresa) Then + CveConcepto = 98 + Cuenta = "Nominas por Pagar" + IdCuenta = ObjConta.DtResultados(0)("IdCtaContable").ToString.ToEntero + Concepto = "Pago Nomina" + Referencia = "Pago Nomina" + Else + Concepto = drt("NombreCompleto") + Referencia = "" + CveConcepto = drt("CveConceptoContable").ToString.ToEntero + Cuenta = drt("ConceptoContable").ToString + IdCuenta = drt("IdCtaContable").ToString.ToEntero + End If + + Dim drr As DataRow = DtCuentasContables.FiltroPrimero($"Id={IdCuenta}") + CodigoCuenta = If(drr IsNot Nothing, drr("CuentaFormato").ToString(), "") + NombreCuenta = If(drr IsNot Nothing, drr("Nombre").ToString(), "") + + TipoMovto = drt("TipoMovto") + + If TipoMovto = 0 Then + dr("Cargo") = Math.Abs(drt("Importe").ToString.ToDecimal) + dr("Abono") = 0 + Else + dr("Cargo") = 0 + dr("Abono") = Math.Abs(drt("Importe").ToString.ToDecimal) + End If + + dr("IdCuenta") = IdCuenta + dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta + dr("Cuenta") = Cuenta + dr("Concepto") = Concepto + dr("Descripcion") = Concepto + dr("Referencia") = Referencia + dr("TipoMovto") = TipoMovto + dr("EsComodin") = EsComodin + dr("CveConcepto") = CveConcepto + dr("CveProveedor") = "-1" + dr("CveSubProyecto") = drt("CveSubProyecto") + dr("CvePersonal") = drt("CvePersonal") + dr("CveClasificacion") = drt("CveClasificacion") + dr("CveTipoGasto") = drt("CveTipoGasto") + + DtMovimientos.Rows.Add(dr) + Next + + GvMov.DataSource = DtMovimientos + GvMov.DataBind() + UPMovs.Update() + End If + + End Sub + + Private Sub CargaPrePoliza() + BtnEliminar.Visible = True + LblEncabezado.Text = "Edición de Póliza" + + Dim ObjContabilidad As New ClsContabilidad + If ObjContabilidad.GetPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa) Then + Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("") + If dr IsNot Nothing Then + DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza") + TxtFechaDocumento.Text = dr("Fecha") + TxtConcepto.Text = dr("Concepto") + DivDatosPoliza.Visible = True + + If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then + DivAgregarConceptos.Visible = True + CargaConceptos() + CargaSubProyectos() + CargaCuentasContables() + End If + + ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza) + + DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") + GvPrePoliza.DataSource = DtMovimientos + GvPrePoliza.DataBind() + + If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17)").Rows.Count > 0 Then + LnkComplementoPago.Visible = True + End If + + IdPoliza = dr("IdPoliza").ToString.ToEntero + If dr("IdPoliza").ToString.ToEntero > 0 Then + HplContabilizada.NavigateUrl = String.Format("RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) + divContabilziada.Visible = True + BtnEliminar.Visible = False + If UsuarioActual.CveUsuario = 100 Then + BtnContabilizar.Visible = True + BtnContabilizar.Text = "Actualizar Poliza" + End If + ElseIf TxtTotalCargos.Text.ToDouble = TxtTotalAbonos.Text.ToDouble Then + 'sino está contabilizada, se activa el botón + BtnContabilizar.Visible = True + End If + + divDatosPrincipales.Visible = False + divObservaciones.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 + + Else + Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia) + BtnEliminar.Visible = False + End If + + End If + CargaGvBitacora() + ObjContabilidad.Dispose() + UpPoliza.Update() + UpBitacora.Update() + 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 los Tipos de Gasto + e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlTipoGasto").DataBind() + e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) + e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto")) + + '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).ToString.FormatoNumero + TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCTextBox("TxtAbono").Text.ToDouble).ToString.FormatoNumero + + Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero + + If CveConceptoContable.Contiene(1, 2, 12, 13, 38, 207, 203, 39, 61, 62, 63, 150, 251, 226) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta")) + If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 205, 225, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra")) + If CveConceptoContable.Contiene(176) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/OC/OC.aspx?CveOrdenCompra={0}", e.Row.DataKey("CveOC")) + If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) + If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) + + + 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable + + End If + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind() + e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1")) + End If + + End Sub + + Private Sub CargaPlantillas(TipoPlantilla As Integer) + + 'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla) + 'GvPlantillas.DataBind() + If UsuarioActual.CveEmpresa.Contiene(120) Then DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1) Else @@ -532,304 +532,315 @@ Partial Class ContabilidadC_RegPrePoliza End If - 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 DdlConceptosContables_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContables.SelectedIndexChanged - If DdlConceptosContables.SelectedValue.ToEntero.Contiene(5, 17, 201, 205, 206, 14, 15, 16, 19, 25, 26, 21) Then - CargaProveedores() - DdlProveedores.Visible = True - DdlCompras.Visible = True - Else - DdlProveedores.Visible = False - DdlCompras.Visible = False - End If - - If DdlConceptosContables.SelectedValue.ToEntero.Contiene(28, 29) Then - CargaPersonal() - DdlPersonal.Visible = True - Else - DdlPersonal.Visible = False - End If - If DdlConceptosContables.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39) Then - CargaClientes() - DdlClientes.Visible = True - DdlVentas.Visible = True - Else - DdlClientes.Visible = False - DdlVentas.Visible = False - End If - - If DdlConceptosContables.SelectedValue.ToEntero.Contiene(201, 202, 203, 204, 206, 207, 226, 227, 229, 233, 234, 235, 239, 242, 256, 266) Then - TxtTC.Text = "2" - TxtTC.Visible = True - Else - TxtTC.Text = "" - TxtTC.Visible = False + 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 DdlConceptosContables_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContables.SelectedIndexChanged + If DdlConceptosContables.SelectedValue.ToEntero.Contiene(5, 17, 201, 205, 206, 14, 15, 16, 19, 25, 26, 21) Then + CargaProveedores() + DdlProveedores.Visible = True + DdlCompras.Visible = True + Else + DdlProveedores.Visible = False + DdlCompras.Visible = False + End If + + If DdlConceptosContables.SelectedValue.ToEntero.Contiene(28, 29) Then + CargaPersonal() + DdlPersonal.Visible = True + Else + DdlPersonal.Visible = False + End If + If DdlConceptosContables.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39) Then + CargaClientes() + DdlClientes.Visible = True + DdlVentas.Visible = True + Else + DdlClientes.Visible = False + DdlVentas.Visible = False + End If + + If DdlConceptosContables.SelectedValue.ToEntero.Contiene(51) Then + CargaClasificacionesE() + DdlClasificacionesE.Visible = True + Else + DdlClasificacionesE.Visible = False + End If + + If DdlConceptosContables.SelectedValue.ToEntero.Contiene(201, 202, 203, 204, 206, 207, 226, 227, 229, 233, 234, 235, 239, 242, 256, 266) Then + TxtTC.Text = "2" + TxtTC.Visible = True + Else + TxtTC.Text = "" + TxtTC.Visible = False End If If DdlConceptosContables.SelectedValue.ToEntero.Contiene(69) Then CargaClasificaciones() - DdlClasificaciones.Visible = True + DdlClasificaciones.Visible = True Else - TxtTC.Text = "" - DdlClasificaciones.Visible = False + TxtTC.Text = "" + DdlClasificaciones.Visible = False End If - End Sub - - Private Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.SelectedIndexChanged - CargaCompras(DdlProveedores.SelectedValue.ToEntero) - End Sub - - Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.selectedindexchange - CargaVentas(DdlClientes.SelectedValue.ToEntero) - End Sub - - Private Sub CargaSubProyectos() - DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem(" - ", "-1")) - DdlSubProyectoFiltroMov.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - DdlSubProyectoFiltroMov.DataBind() - DdlSubProyectoFiltroMov.Items.Insert(0, New ListItem("Todos", "-1")) - End Sub - - Private Sub CargaCuentasContables() - DdlCtaContable.DataSource = Session("DtCuentas") - DdlCtaContable.DataBind() - DdlCtaContable.Items.Insert(0, New ListItem("Sin Asignar", "0")) - End Sub - - Private Sub CargaTiposGasto() - DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - DdlTipoGasto.DataBind() - DdlTipoGasto.Items.Insert(0, New ListItem("Sin Asignar", "0")) - End Sub - - Private Sub CargaProveedores() - DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - DdlProveedores.DataBind() - DdlProveedores.Items.Insert(0, New ListItem(" - ", "-1")) - End Sub - - Private Sub CargaCompras(CveProveedor As Integer) - If Not DdlConceptosContables.SelectedValue.ToEntero.Contiene(21) Then - Dim ObjCompras As New ClsCompras - - DdlCompras.ClearSelection() - If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then - DdlCompras.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0") - DdlCompras.DataBind() - DdlCompras.Items.Insert(0, New ListItem(" - ", "-1")) - Else - DdlCompras.DataSource = Nothing - DdlCompras.DataBind() - DdlCompras.Items.Insert(0, New ListItem(" - ", "-1")) - End If - ObjCompras.Dispose() - End If - End Sub - - Private Sub CargaClientes() - DdlClientes.setEsWebService(True) - DdlClientes.Attributes.Add("data-metodo", "getcliente") - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() - ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Private Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.SelectedIndexChanged + CargaCompras(DdlProveedores.SelectedValue.ToEntero) + End Sub + + Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.selectedindexchange + CargaVentas(DdlClientes.SelectedValue.ToEntero) + End Sub + + Private Sub CargaSubProyectos() + DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem(" - ", "-1")) + DdlSubProyectoFiltroMov.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + DdlSubProyectoFiltroMov.DataBind() + DdlSubProyectoFiltroMov.Items.Insert(0, New ListItem("Todos", "-1")) + End Sub + + Private Sub CargaCuentasContables() + DdlCtaContable.DataSource = Session("DtCuentas") + DdlCtaContable.DataBind() + DdlCtaContable.Items.Insert(0, New ListItem("Sin Asignar", "0")) + End Sub + + Private Sub CargaTiposGasto() + DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + DdlTipoGasto.DataBind() + DdlTipoGasto.Items.Insert(0, New ListItem("Sin Asignar", "0")) + End Sub + + Private Sub CargaProveedores() + DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + DdlProveedores.DataBind() + DdlProveedores.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Private Sub CargaCompras(CveProveedor As Integer) + If Not DdlConceptosContables.SelectedValue.ToEntero.Contiene(21) Then + Dim ObjCompras As New ClsCompras + + DdlCompras.ClearSelection() + If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then + DdlCompras.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0") + DdlCompras.DataBind() + DdlCompras.Items.Insert(0, New ListItem(" - ", "-1")) + Else + DdlCompras.DataSource = Nothing + DdlCompras.DataBind() + DdlCompras.Items.Insert(0, New ListItem(" - ", "-1")) + End If + ObjCompras.Dispose() + End If + End Sub + + Private Sub CargaClientes() + DdlClientes.setEsWebService(True) + DdlClientes.Attributes.Add("data-metodo", "getcliente") + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + DdlClientes.DataBind() + ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1")) End Sub Private Sub CargaClasificaciones() - DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) - DdlClasificaciones.DataBind() - ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1")) - End Sub - - Private Sub CargaVentas(CveCliente As Integer) - Dim ObjVentas As New ClsVentas - - DdlVentas.ClearSelection() - If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - DdlVentas.DataSource = ObjVentas.DtResultados '.FiltraParametros("Saldo > 0") - DdlVentas.DataBind() - DdlVentas.Items.Insert(0, New ListItem(" - ", "-1")) - Else - DdlVentas.DataSource = Nothing - DdlVentas.DataBind() - DdlVentas.Items.Insert(0, New ListItem(" - ", "-1")) - End If - ObjVentas.Dispose() - End Sub - - Private Sub CargaPersonal() - DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) - DdlPersonal.DataBind() - DdlPersonal.Items.Insert(0, New ListItem(" - ", "-1")) - 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() + DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificaciones.DataBind() + ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Private Sub CargaVentas(CveCliente As Integer) + Dim ObjVentas As New ClsVentas + + DdlVentas.ClearSelection() + If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + DdlVentas.DataSource = ObjVentas.DtResultados '.FiltraParametros("Saldo > 0") + DdlVentas.DataBind() + DdlVentas.Items.Insert(0, New ListItem(" - ", "-1")) + Else + DdlVentas.DataSource = Nothing + DdlVentas.DataBind() + DdlVentas.Items.Insert(0, New ListItem(" - ", "-1")) + End If + ObjVentas.Dispose() + End Sub + + Private Sub CargaPersonal() + DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + DdlPersonal.DataBind() + DdlPersonal.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Private Sub CargaClasificacionesE() + DdlClasificacionesE.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificacionesE.DataBind() + DdlClasificacionesE.Items.Insert(0, New ListItem(" - ", "-1")) + 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() - NombreCuenta = CodigoCuenta & "
" & NombreCuenta - End If - EsComodin = 0 - End If - + NombreCuenta = CodigoCuenta & "
" & NombreCuenta + End If + EsComodin = 0 + End If + If drt("CveCuenta").ToString.ToEntero > 0 Then NombreCuenta = String.Format("{0}
{1}", drt("Codigo"), drt("Nombre")) - End If - - Dim dr As DataRow = DtMovimientos.NewRow - dr("IdCuenta") = IdCuenta - dr("CodigoCuenta") = 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") - dr("CveClasificacion") = -1 + End If + + Dim dr As DataRow = DtMovimientos.NewRow + dr("IdCuenta") = IdCuenta + dr("CodigoCuenta") = 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") + dr("CveClasificacion") = -1 dr("MultipleSubProyecto") = drt("MultipleSubProyecto") dr("PorcentajeImpuesto") = drt("PorcentajeImpuesto") - dr("CveCuenta") = drt("CveCuenta") - 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") - - If CvePeriodo > 0 Then - e.Row.FCTextBox("TxtCargo").Enabled = False - e.Row.FCTextBox("TxtAbono").Enabled = False - End If - - 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") - - 'Asignamos los Tipos de Gasto - e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlTipoGasto").DataBind() - e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) - e.Row.FCDropDownList("DdlTipoGasto").SelectedValue = e.Row.DBCampo("CveTipoGasto") - - If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada - e.Row.FCDropDownList("DdlSubProyecto").Enabled = True - e.Row.FCImageButton("imgD").Visible = True - Else - e.Row.FCDropDownList("DdlSubProyecto").Enabled = False - End If - - If e.Row.DBCampo("MultipleSubProyecto") = "True" Then - e.Row.FCDropDownList("DdlSubProyecto").Enabled = True - 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, CveMoneda, 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 - - If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then - e.Row.FCLinkButton("ImgBancos").Visible = True - - - If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then - e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" - End If - End If - - If e.Row.DataKey("CveConcepto").ToEntero.Contiene(17) Then + dr("CveCuenta") = drt("CveCuenta") + 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") + + If CvePeriodo > 0 Then + e.Row.FCTextBox("TxtCargo").Enabled = False + e.Row.FCTextBox("TxtAbono").Enabled = False + End If + + 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") + + 'Asignamos los Tipos de Gasto + e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlTipoGasto").DataBind() + e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) + e.Row.FCDropDownList("DdlTipoGasto").SelectedValue = e.Row.DBCampo("CveTipoGasto") + + If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada + e.Row.FCDropDownList("DdlSubProyecto").Enabled = True + e.Row.FCImageButton("imgD").Visible = True + Else + e.Row.FCDropDownList("DdlSubProyecto").Enabled = False + End If + + If e.Row.DBCampo("MultipleSubProyecto") = "True" Then + e.Row.FCDropDownList("DdlSubProyecto").Enabled = True + 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, CveMoneda, 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 + + If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then + e.Row.FCLinkButton("ImgBancos").Visible = True + + + If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then + e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" + End If + End If + + If e.Row.DataKey("CveConcepto").ToEntero.Contiene(17) Then e.Row.FCDropDownList("DdlProveedores").Visible = True e.Row.FCDropDownList("DdlProveedores").DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) e.Row.FCDropDownList("DdlProveedores").DataBind() @@ -838,162 +849,162 @@ Partial Class ContabilidadC_RegPrePoliza 'If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then ' e.Row.FCLinkButton("ImgPagoCompra").CssClass = "btn btn-circle btn-sm green" 'End If - 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.ToDecimal - TotalAbonos = TxtTotalAbonos.Text.ToDecimal - 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 Not (TotalCargos = TotalAbonos AndAlso (GvPrePoliza.Rows.Count > 0 Or GvMov.Rows.Count > 0)) Then - Alert($"La suma de los movimientos no son iguales ({TotalCargos}-{TotalAbonos})", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If CvePrePoliza > 0 Then - 'Nuevo Modulo Charlie + 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.ToDecimal + TotalAbonos = TxtTotalAbonos.Text.ToDecimal + 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 Not (TotalCargos = TotalAbonos AndAlso (GvPrePoliza.Rows.Count > 0 Or GvMov.Rows.Count > 0)) Then + Alert($"La suma de los movimientos no son iguales ({TotalCargos}-{TotalAbonos})", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 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 ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL) - Dim Conta As ClsContPAQi = Nothing - Dim IDPoliza As Integer = 0 - Dim MsgError As String = "" - Dim CveIE As Integer = -1 - Dim CveIEInsertado As Integer = -1 - Dim FolioIE As String = "" - - 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, CveTipoPoliza:=DdlTipoPolizaAdd.SelectedValue.ToEntero) - - If CvePrePoliza > 0 Then - Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" - Dim idCuentaContabilizacion As Long = 1 - Dim Importe As Double = 0 - Dim TipoMovto As Boolean = False - Dim IdCtaContable As Integer = 0 - Dim PorcentajeImpuesto As Decimal = 0 - - 'Registra movimieno bancario - If CveConcepto = 30 Then - CveIE = ObjIE.AddBancos_IE(CveCuenta, CveTipoTransaccion, TxtFecha.Text, Folio, Beneficiario, ImporteDocumento, CveMoneda, 0, Observaciones, "", False, False, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveIE < 0 Then MsgError = "No se pudo registrar movimiento bancario" - CveIEInsertado = CveIE - If ObjIE.GetBancosIE(CveIE, -1, -1, "-1", -1, "-1", "-1", -1, -1, -1, -1, -1, MinFecha, MaxFecha, MinFecha, MaxFecha, MinFecha, MaxFecha, -1, -1, UsuarioActual.CveEmpresa) Then - FolioIE = ObjIE.Folio - End If + Else + Dim MensajeAlert = New StringBuilder + Dim ObjIE As New ClsBancos() + Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) + Dim ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL) + Dim Conta As ClsContPAQi = Nothing + Dim IDPoliza As Integer = 0 + Dim MsgError As String = "" + Dim CveIE As Integer = -1 + Dim CveIEInsertado As Integer = -1 + Dim FolioIE As String = "" + + 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, CveTipoPoliza:=DdlTipoPolizaAdd.SelectedValue.ToEntero) + + If CvePrePoliza > 0 Then + Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" + Dim idCuentaContabilizacion As Long = 1 + Dim Importe As Double = 0 + Dim TipoMovto As Boolean = False + Dim IdCtaContable As Integer = 0 + Dim PorcentajeImpuesto As Decimal = 0 + + 'Registra movimieno bancario + If CveConcepto = 30 Then + CveIE = ObjIE.AddBancos_IE(CveCuenta, CveTipoTransaccion, TxtFecha.Text, Folio, Beneficiario, ImporteDocumento, CveMoneda, 0, Observaciones, "", False, False, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveIE < 0 Then MsgError = "No se pudo registrar movimiento bancario" + CveIEInsertado = CveIE + If ObjIE.GetBancosIE(CveIE, -1, -1, "-1", -1, "-1", "-1", -1, -1, -1, -1, -1, MinFecha, MaxFecha, MinFecha, MaxFecha, MinFecha, MaxFecha, -1, -1, UsuarioActual.CveEmpresa) Then + FolioIE = ObjIE.Folio + End If End If Dim CveProveedor As Integer = -1 - Dim CveCompra As Integer = -1 - - 'inserto las compras que voy a pagarDdlSaldos + Dim CveCompra As Integer = -1 + + 'inserto las compras que voy a pagarDdlSaldos For Each gvr As GridViewRow In GvMov.Rows - If gvr.DataKey("IDCuenta").ToEntero > 0 Then - IdCtaContable = gvr.DataKey("IDCuenta") - End If - CveProveedor = gvr.DataKey("CveProveedor").ToEntero - CveCompra = gvr.DataKey("CveCompra").ToEntero - CveConcepto = gvr.DataKey("CveConcepto").ToEntero - - If gvr.DataKey("TipoMovto").ToDouble <> 0 Then - Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble - TipoMovto = True - Else - Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble - TipoMovto = False + If gvr.DataKey("IDCuenta").ToEntero > 0 Then + IdCtaContable = gvr.DataKey("IDCuenta") + End If + CveProveedor = gvr.DataKey("CveProveedor").ToEntero + CveCompra = gvr.DataKey("CveCompra").ToEntero + CveConcepto = gvr.DataKey("CveConcepto").ToEntero + + 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 'Registra pago de compra If CveConcepto = 17 Then CveProveedor = gvr.FCDropDownList("DdlProveedores").SelectedValue.ToEntero CveCompra = gvr.FCDropDownList("DdlCompras").SelectedValue.ToEntero - End If - - If CveConcepto = 41 Then - CveIE = gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero - Else - If CveConcepto = 30 Then - CveIE = CveIEInsertado - Else - CveIE = -1 - End If - End If - - - 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:=CveIE, - CveProveedor:=CveProveedor, CveCompra:=CveCompra, - CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero, - ImporteMX:=Importe, CveTipoGasto:=gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, - CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, gvr.DataKey("TC").ToString.ToDecimal, 1), - ImporteME:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, (Importe / (gvr.DataKey("TC").ToString.ToDecimal - 1)).RoundSQL, 0), - PorcentajeImpuesto:=gvr.DataKey("PorcentajeImpuesto").ToDecimal, CveCuenta:=gvr.DataKey("CveCuenta").ToEntero) Then - Else - MsgError = "No se pudo insertar el detalle de la póliza2" - Exit For - End If - End If + End If + + If CveConcepto = 41 Then + CveIE = gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero + Else + If CveConcepto = 30 Then + CveIE = CveIEInsertado + Else + CveIE = -1 + End If + End If + + + 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:=CveIE, + CveProveedor:=CveProveedor, CveCompra:=CveCompra, + CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero, + ImporteMX:=Importe, CveTipoGasto:=gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, + CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, gvr.DataKey("TC").ToString.ToDecimal, 1), + ImporteME:=If(gvr.DataKey("TC").ToString.ToDecimal > 0, (Importe / (gvr.DataKey("TC").ToString.ToDecimal - 1)).RoundSQL, 0), + PorcentajeImpuesto:=gvr.DataKey("PorcentajeImpuesto").ToDecimal, CveCuenta:=gvr.DataKey("CveCuenta").ToEntero) Then + Else + MsgError = "No se pudo insertar el detalle de la póliza2" + Exit For + End If + End If Next - If CvePeriodo > 0 Then - If Not ObjNom.UpdateProvisionNomina(CvePeriodo, CvePrePoliza, UsuarioActual.CveEmpresa) Then - MsgError = "No se pudo actualizar el periodo de la nómina" - End If - End If - - If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then - If ObjMov.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - MsgError = ObjMov.MensajePolizaDescuadre & "-" - End If + If CvePeriodo > 0 Then + If Not ObjNom.UpdateProvisionNomina(CvePeriodo, CvePrePoliza, UsuarioActual.CveEmpresa) Then + MsgError = "No se pudo actualizar el periodo de la nómina" + End If + End If + + If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then + If ObjMov.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + MsgError = ObjMov.MensajePolizaDescuadre & "-" + End If End If 'El movimiento 2 es el de Pago - If ChkAutoConta.Checked AndAlso MsgError = "" Or UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then - If idCuentaContabilizacion > 0 Then - If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then - - 'MENSAJE PRINCIPAL - MensajeAlert.AppendFormat("

Folio de Póliza: {1}", ObjMov.ContaIdPoliza, ObjMov.ContaFolio) - MensajeAlert.AppendFormat("

Prepóliza: {1}", CvePrePoliza, 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" + If ChkAutoConta.Checked AndAlso MsgError = "" Or UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then + If idCuentaContabilizacion > 0 Then + If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + + 'MENSAJE PRINCIPAL + MensajeAlert.AppendFormat("

Folio de Póliza: {1}", ObjMov.ContaIdPoliza, ObjMov.ContaFolio) + MensajeAlert.AppendFormat("

Prepóliza: {1}", CvePrePoliza, 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 If MsgError = "" Then @@ -1022,23 +1033,23 @@ Partial Class ContabilidadC_RegPrePoliza Catch ex As Exception ex.GuardaLog(ex.Message) ObjIE.RollBack() - If Conta IsNot Nothing Then Conta.RollBack() + If Conta IsNot Nothing Then Conta.RollBack() Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgInformacion) End Try - ObjIE.Dispose() - ObjMov.Dispose() - If Conta IsNot Nothing Then Conta.Dispose() - End If - End Sub - - Private Sub ActualizarPrePoliza() - - Dim OcurrioError As Boolean = False - Dim ObjContabilidad As New ClsContabilidad + ObjIE.Dispose() + ObjMov.Dispose() + If Conta IsNot Nothing Then Conta.Dispose() + End If + End Sub + + Private Sub ActualizarPrePoliza() + + Dim OcurrioError As Boolean = False + Dim ObjContabilidad As New ClsContabilidad ObjContabilidad.IniciaTransacSQL() @@ -1055,19 +1066,19 @@ Partial Class ContabilidadC_RegPrePoliza For Each row As GridViewRow In GvPrePoliza.Rows If row.DataKey("CvePrePolizaDetalle").ToEntero > 0 Then - 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, + 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), CveTipoGasto:=If(DdlTipoGasto.Visible, row.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, row.DataKey("CveTipoGasto").ToEntero), CveUsuarioModifico:=UsuarioActual.CveUsuario) Then OcurrioError = True Exit For End If Else - If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, 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), row.DataKey("Referencia").ToString, - row.DataKey("CveConceptoContable").ToEntero, row.FCTextBox("TxtConcepto").Text, Now, - row.FCDropDownList("DdlCtaContable").SelectedValue.ToEntero, 0, CveSubProyecto:=row.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, - CveTipoGasto:=If(DdlTipoGasto.Visible, row.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, row.DataKey("CveTipoGasto").ToEntero), - ImporteMX:=If(row.FCTextBox("TxtCargo").Text.ToDecimal <> 0, + If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, 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), row.DataKey("Referencia").ToString, + row.DataKey("CveConceptoContable").ToEntero, row.FCTextBox("TxtConcepto").Text, Now, + row.FCDropDownList("DdlCtaContable").SelectedValue.ToEntero, 0, CveSubProyecto:=row.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, + CveTipoGasto:=If(DdlTipoGasto.Visible, row.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, row.DataKey("CveTipoGasto").ToEntero), + ImporteMX:=If(row.FCTextBox("TxtCargo").Text.ToDecimal <> 0, row.FCTextBox("TxtCargo").Text.ToDecimal, row.FCTextBox("TxtAbono").Text.ToDecimal), CveProveedor:=DdlProveedores.SelectedValue.ToEntero) Then OcurrioError = True Exit For @@ -1079,581 +1090,581 @@ Partial Class ContabilidadC_RegPrePoliza OcurrioError = True End If - If Not OcurrioError Then - ObjContabilidad.Commit() - Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion) + 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() - CargaPrePoliza() - + ObjContabilidad.RollBack() + Alert("Ocurrio un error al actualizar la PrePoliza.", TipoMensaje.MsgError) + End If + + ObjContabilidad.Dispose() + CargaPrePoliza() + If Not OcurrioError Then If IdPoliza > 0 Then BtnContabilizar_Click(Nothing, Nothing) End If - End If - End Sub - Protected Sub GvPrePoliza_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvPrePoliza.RowUpdating - RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto")) - CargaSubProyectos() - IndiceGrid = e.RowIndex - - Dim DtTemp As New DataTable - DtTemp.Columns.Add("ConceptoContable", GetType(String)) - DtTemp.Columns.Add("FolioFactura", GetType(String)) - DtTemp.Columns.Add("Concepto", GetType(String)) - DtTemp.Columns.Add("CveSubProyecto", GetType(Integer)) - DtTemp.Columns.Add("CveTipoGasto", GetType(Integer)) - DtTemp.Columns.Add("Id", GetType(Integer)) - DtTemp.Columns.Add("CargoImporteMN", GetType(Decimal)) - DtTemp.Columns.Add("AbonoImporteMN", GetType(Decimal)) - - Dim ConceptoContable As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("LtlConceptoContable").Text - Dim FolioFactura As String = GvPrePoliza.Rows(IndiceGrid).FCHyperLink("HlReferencia").Text - Dim Concepto As String = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtConcepto").Text - Dim CveSubProyecto As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero - Dim CveTipoGasto As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero - Dim Id As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlCtaContable").SelectedValue.ToEntero - Dim Cargo As Double = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtCargo").Text.ToDouble - Dim Abono As Double = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtAbono").Text.ToDouble - - Dim registro As DataRow = DtTemp.NewRow - registro.Item("ConceptoContable") = ConceptoContable - registro.Item("FolioFactura") = FolioFactura - registro.Item("Concepto") = Concepto - registro.Item("CveSubProyecto") = CveSubProyecto - registro.Item("CveTipoGasto") = CveTipoGasto - registro.Item("Id") = Id - registro.Item("CargoImporteMN") = Cargo - registro.Item("AbonoImporteMN") = Abono - DtTemp.Rows.Add(registro) - - GvConcepto.DataSource = DtTemp - GvConcepto.DataBind() - - UppGrid.Update() - - End Sub - Private Sub GvConcepto_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvConcepto.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 los Tipos de Gasto - e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlTipoGasto").DataBind() - e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) - e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto")) - - '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).ToString.FormatoNumero - 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCTextBox("TxtAbono").Text.ToDouble).ToString.FormatoNumero - - 'Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero - - 'If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta")) - 'If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra")) - 'If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) - - 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable - - End If - - If e.Row.RowType = DataControlRowType.Header Then - e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind() - e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1")) - End If - - End Sub - Protected Sub BtnAceptar_Click(sender As Object, e As EventArgs) Handles BtnAceptar.Click - - - 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 - RegistraScript("calculateCargo();calculateAbono();comparar()") - - '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 - - If DtMovimientos Is Nothing Then CreaDT() - - If Actualizar Then - - Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & HdnCve.Value) - - If Rows.Count > 0 Then - Dim dr As DataRow = Rows(0) - 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 & "
" & NombreCuenta - dr("Cuenta") = DdlConceptosContables.SelectedItem - dr("Referencia") = TxtReferencia.Text - dr("Concepto") = TxtObservaciones.Text - dr("TipoMovto") = If(Math.Abs(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 - dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero - dr("CveCompra") = DdlCompras.SelectedValue.ToEntero - dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - dr("CveClasificacion") = DdlClasificaciones.SelectedValue.ToEntero - dr("CveCliente") = DdlClientes.SelectedValue.ToEntero - dr("CveVenta") = DdlVentas.SelectedValue.ToEntero - End If - - GvMov.DataSource = DtMovimientos - GvMov.DataBind() - UPMovs.Update() - - LbCancelarEdicion.Visible = False - LbAgregar.Text = "Agregar" - Actualizar = False - Else - - If CvePrePoliza > 0 Then - Dim dr As DataRow = DtMovimientos.NewRow - dr("IdCtaContable") = DdlCtaContable.SelectedValue - dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text - dr("CveConceptoContable") = DdlConceptosContables.SelectedValue - dr("Concepto") = TxtDescripcion.Text - dr("Referencia") = TxtReferencia.Text - dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) - dr("Cargo") = TxtCargo.Text.ToDouble - dr("Abono") = TxtAbono.Text.ToDouble - dr("ImporteMN") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, TxtCargo.Text.ToDouble, TxtAbono.Text.ToDouble) - 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) - DtMovimientos.AcceptChanges() - - If CvePrePoliza > 0 Then - GvPrePoliza.DataSource = DtMovimientos - GvPrePoliza.DataBind() - UpPrePoliza.Update() - End If - Else - 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 & "
" & NombreCuenta - dr("Cuenta") = DdlConceptosContables.SelectedItem.Text - dr("Referencia") = TxtReferencia.Text - dr("Concepto") = TxtObservaciones.Text - dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) - dr("EsComodin") = 0 - dr("CveConcepto") = DdlConceptosContables.SelectedValue - dr("CveConceptoContable") = DdlConceptosContables.SelectedValue - dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text - dr("Cargo") = TxtCargo.Text.ToDouble - dr("Abono") = TxtAbono.Text.ToDouble - dr("Descripcion") = TxtDescripcion.Text - dr("CveSubProyecto") = DdlSubProyecto.SelectedValue - dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero - dr("CveCompra") = DdlCompras.SelectedValue.ToEntero - dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - dr("CveClasificacion") = DdlClasificaciones.SelectedValue.ToEntero - dr("CveCliente") = DdlClientes.SelectedValue.ToEntero - dr("CveVenta") = DdlVentas.SelectedValue.ToEntero - dr("TC") = TxtTC.Text.ToDouble - - 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() - - 'If CvePrePoliza > 0 Then - ' GvPrePoliza.DataSource = DtMovimientos - ' GvPrePoliza.DataBind() - ' UpPrePoliza.Update() - 'End If - - GvMov.DataSource = DtMovimientos - GvMov.DataBind() - UPMovs.Update() - Actualizar = False - - End If - - End If - - TxtCargo.Text = "" - TxtAbono.Text = "" - TxtReferencia.Text = "" - TxtDescripcion.Text = "" - End Sub - -#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE" - Public Sub Bancos_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - RowIndex = GvRow.RowIndex - - If GvRow.FCTextBox("TxtAbono").Text = "" Then - CargaTipoTransaccion("Ing") - Else - CargaTipoTransaccion("Egs") - End If - - - TxtDocumentoImporte.Text = If(GvRow.FCTextBox("TxtAbono").Text = "", GvRow.FCTextBox("TxtCargo").Text.FormatoNumero, GvRow.FCTextBox("TxtAbono").Text.FormatoNumero) - UpBancos.Update() - RegistraScript(String.Format("$('#{0}').modal();", "DivContadoModal")) - End Sub - Private Sub CargaTipoTransaccion(Tipo As String) - DdlTipoTransaccion.Items.Clear() - DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}'") - DdlTipoTransaccion.DataBind() - DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) - End Sub - Private Sub CargaCuentas() - DdlCuenta.Items.Clear() - DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) '.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", DdlMoneda.SelectedValue)) - DdlCuenta.DataBind() - DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - Private Sub BtnContado_Click(sender As Object, e As EventArgs) Handles BtnContado.Click - CveConcepto = 30 - CveTipoTransaccion = DdlTipoTransaccion.SelectedValue.ToEntero - CveCuenta = DdlCuenta.SelectedValue.ToEntero - Folio = TxtDocumentoFolio.Text - ImporteDocumento = TxtDocumentoImporte.Text.ToDecimal - Observaciones = TxtDocumentoObservaciones.Text - Beneficiario = TxtDocumentoBeneficiario.Text - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal")) - GvMov.Rows(RowIndex).FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" - UPMovs.Update() - End Sub - - Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click - Dim ObjContabilidad As New ClsContabilidad + End If + End Sub + Protected Sub GvPrePoliza_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvPrePoliza.RowUpdating + RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto")) + CargaSubProyectos() + IndiceGrid = e.RowIndex + + Dim DtTemp As New DataTable + DtTemp.Columns.Add("ConceptoContable", GetType(String)) + DtTemp.Columns.Add("FolioFactura", GetType(String)) + DtTemp.Columns.Add("Concepto", GetType(String)) + DtTemp.Columns.Add("CveSubProyecto", GetType(Integer)) + DtTemp.Columns.Add("CveTipoGasto", GetType(Integer)) + DtTemp.Columns.Add("Id", GetType(Integer)) + DtTemp.Columns.Add("CargoImporteMN", GetType(Decimal)) + DtTemp.Columns.Add("AbonoImporteMN", GetType(Decimal)) + + Dim ConceptoContable As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("LtlConceptoContable").Text + Dim FolioFactura As String = GvPrePoliza.Rows(IndiceGrid).FCHyperLink("HlReferencia").Text + Dim Concepto As String = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtConcepto").Text + Dim CveSubProyecto As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero + Dim CveTipoGasto As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero + Dim Id As Integer = GvPrePoliza.Rows(IndiceGrid).FCDropDownList("DdlCtaContable").SelectedValue.ToEntero + Dim Cargo As Double = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtCargo").Text.ToDouble + Dim Abono As Double = GvPrePoliza.Rows(IndiceGrid).FCTextBox("TxtAbono").Text.ToDouble + + Dim registro As DataRow = DtTemp.NewRow + registro.Item("ConceptoContable") = ConceptoContable + registro.Item("FolioFactura") = FolioFactura + registro.Item("Concepto") = Concepto + registro.Item("CveSubProyecto") = CveSubProyecto + registro.Item("CveTipoGasto") = CveTipoGasto + registro.Item("Id") = Id + registro.Item("CargoImporteMN") = Cargo + registro.Item("AbonoImporteMN") = Abono + DtTemp.Rows.Add(registro) + + GvConcepto.DataSource = DtTemp + GvConcepto.DataBind() + + UppGrid.Update() + + End Sub + Private Sub GvConcepto_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvConcepto.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 los Tipos de Gasto + e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlTipoGasto").DataBind() + e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) + e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto")) + + '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).ToString.FormatoNumero + 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCTextBox("TxtAbono").Text.ToDouble).ToString.FormatoNumero + + 'Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero + + 'If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta")) + 'If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra")) + 'If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) + + 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable + + End If + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind() + e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1")) + End If + + End Sub + Protected Sub BtnAceptar_Click(sender As Object, e As EventArgs) Handles BtnAceptar.Click + + + 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 + RegistraScript("calculateCargo();calculateAbono();comparar()") + + '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 + + If DtMovimientos Is Nothing Then CreaDT() + + If Actualizar Then + + Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & HdnCve.Value) + + If Rows.Count > 0 Then + Dim dr As DataRow = Rows(0) + 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 & "
" & NombreCuenta + dr("Cuenta") = DdlConceptosContables.SelectedItem + dr("Referencia") = TxtReferencia.Text + dr("Concepto") = TxtObservaciones.Text + dr("TipoMovto") = If(Math.Abs(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 + dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero + dr("CveCompra") = DdlCompras.SelectedValue.ToEntero + dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + dr("CveClasificacion") = DdlClasificaciones.SelectedValue.ToEntero + dr("CveCliente") = DdlClientes.SelectedValue.ToEntero + dr("CveVenta") = DdlVentas.SelectedValue.ToEntero + End If + + GvMov.DataSource = DtMovimientos + GvMov.DataBind() + UPMovs.Update() + + LbCancelarEdicion.Visible = False + LbAgregar.Text = "Agregar" + Actualizar = False + Else + + If CvePrePoliza > 0 Then + Dim dr As DataRow = DtMovimientos.NewRow + dr("IdCtaContable") = DdlCtaContable.SelectedValue + dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text + dr("CveConceptoContable") = DdlConceptosContables.SelectedValue + dr("Concepto") = TxtDescripcion.Text + dr("Referencia") = TxtReferencia.Text + dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) + dr("Cargo") = TxtCargo.Text.ToDouble + dr("Abono") = TxtAbono.Text.ToDouble + dr("ImporteMN") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, TxtCargo.Text.ToDouble, TxtAbono.Text.ToDouble) + 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) + DtMovimientos.AcceptChanges() + + If CvePrePoliza > 0 Then + GvPrePoliza.DataSource = DtMovimientos + GvPrePoliza.DataBind() + UpPrePoliza.Update() + End If + Else + 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 & "
" & NombreCuenta + dr("Cuenta") = DdlConceptosContables.SelectedItem.Text + dr("Referencia") = TxtReferencia.Text + dr("Concepto") = TxtObservaciones.Text + dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) + dr("EsComodin") = 0 + dr("CveConcepto") = DdlConceptosContables.SelectedValue + dr("CveConceptoContable") = DdlConceptosContables.SelectedValue + dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text + dr("Cargo") = TxtCargo.Text.ToDouble + dr("Abono") = TxtAbono.Text.ToDouble + dr("Descripcion") = TxtDescripcion.Text + dr("CveSubProyecto") = DdlSubProyecto.SelectedValue + dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero + dr("CveCompra") = DdlCompras.SelectedValue.ToEntero + dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + dr("CveClasificacion") = DdlClasificaciones.SelectedValue.ToEntero + dr("CveCliente") = DdlClientes.SelectedValue.ToEntero + dr("CveVenta") = DdlVentas.SelectedValue.ToEntero + dr("TC") = TxtTC.Text.ToDouble + + 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() + + 'If CvePrePoliza > 0 Then + ' GvPrePoliza.DataSource = DtMovimientos + ' GvPrePoliza.DataBind() + ' UpPrePoliza.Update() + 'End If + + GvMov.DataSource = DtMovimientos + GvMov.DataBind() + UPMovs.Update() + Actualizar = False + + End If + + End If + + TxtCargo.Text = "" + TxtAbono.Text = "" + TxtReferencia.Text = "" + TxtDescripcion.Text = "" + End Sub + +#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE" + Public Sub Bancos_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + RowIndex = GvRow.RowIndex + + If GvRow.FCTextBox("TxtAbono").Text = "" Then + CargaTipoTransaccion("Ing") + Else + CargaTipoTransaccion("Egs") + End If + + + TxtDocumentoImporte.Text = If(GvRow.FCTextBox("TxtAbono").Text = "", GvRow.FCTextBox("TxtCargo").Text.FormatoNumero, GvRow.FCTextBox("TxtAbono").Text.FormatoNumero) + UpBancos.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivContadoModal")) + End Sub + Private Sub CargaTipoTransaccion(Tipo As String) + DdlTipoTransaccion.Items.Clear() + DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}'") + DdlTipoTransaccion.DataBind() + DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + End Sub + Private Sub CargaCuentas() + DdlCuenta.Items.Clear() + DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) '.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", DdlMoneda.SelectedValue)) + DdlCuenta.DataBind() + DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + Private Sub BtnContado_Click(sender As Object, e As EventArgs) Handles BtnContado.Click + CveConcepto = 30 + CveTipoTransaccion = DdlTipoTransaccion.SelectedValue.ToEntero + CveCuenta = DdlCuenta.SelectedValue.ToEntero + Folio = TxtDocumentoFolio.Text + ImporteDocumento = TxtDocumentoImporte.Text.ToDecimal + Observaciones = TxtDocumentoObservaciones.Text + Beneficiario = TxtDocumentoBeneficiario.Text + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal")) + GvMov.Rows(RowIndex).FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" + UPMovs.Update() + End Sub + + Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click + Dim ObjContabilidad As New ClsContabilidad ObjContabilidad.IniciaTransacSQL() Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) ObjConta.IniciaTransacSQL() Dim TieneError As Boolean = False - If ObjContabilidad.RemovePrePolizas(CvePrePoliza, UsuarioActual.CveEmpresa) Then + If ObjContabilidad.RemovePrePolizas(CvePrePoliza, UsuarioActual.CveEmpresa) Then If IdPoliza > 0 Then If Not ObjConta.RemovePoliza(IdPoliza) Then TieneError = True End If - End If - - Alert("La Prepóliza ha sido eliminada", TipoMensaje.MsgInformacion) - Else - Alert("La Prepóliza ha podido ser eliminada", TipoMensaje.MsgError) + End If + + Alert("La Prepóliza ha sido eliminada", TipoMensaje.MsgInformacion) + Else + Alert("La Prepóliza ha podido ser eliminada", TipoMensaje.MsgError) TieneError = True - End If - + End If + If Not TieneError Then ObjContabilidad.Commit() ObjConta.Commit() Else ObjContabilidad.RollBack() ObjConta.RollBack() - End If - - ObjContabilidad.Dispose() - End Sub -#End Region - - Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs) - If UpPrePoliza.Visible Then - For Each Gvr As GridViewRow In GvPrePoliza.Rows - Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue) - Next - UpPrePoliza.Update() - End If - If UPMovs.Visible Then - For Each Gvr As GridViewRow In GvMov.Rows - Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue) - Next - UPMovs.Update() - End If - End Sub - Protected Sub DdlSubProyectoFiltro_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim Ddl As DropDownList = CType(sender, DropDownList) - For Each Gvr As GridViewRow In GvPrePoliza.Rows - If Ddl.SelectedValue.ToEntero > 0 Then - If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = Ddl.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Or Gvr.FCDropDownList("DdlSubProyecto").Enabled Then - Gvr.Visible = True - Gvr.FCDropDownList("DdlSubProyecto").SelectedValueExist(Ddl.SelectedValue) - Else - Gvr.Visible = False - End If - Else - Gvr.Visible = True - End If - Next - UpPrePoliza.Update() - RegistraScript("calculateAbono()", "cargo") - RegistraScript("calculateCargo()", "abono") - RegistraScript("comparar()", "compara") - End Sub - Protected Sub DdlSubProyectoFiltroMov_SelectedIndexChanged(sender As Object, e As EventArgs) - For Each Gvr As GridViewRow In GvMov.Rows - If DdlSubProyectoFiltroMov.SelectedValue.ToEntero > 0 Then - If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = DdlSubProyectoFiltroMov.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Or Gvr.FCDropDownList("DdlSubProyecto").Enabled Then - Gvr.Visible = True - Gvr.FCDropDownList("DdlSubProyecto").SelectedValueExist(DdlSubProyectoFiltroMov.SelectedValue) - Else - Gvr.Visible = False - End If - Else - Gvr.Visible = True - End If - Next - UpPrePoliza.Update() - RegistraScript("calculateAbono()", "cargo") - RegistraScript("calculateCargo()", "abono") - RegistraScript("comparar()", "compara") - End Sub - - Private Sub GvMov_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvMov.RowEditing - Actualizar = True - GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero - Dim idMov As Integer = GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero - - Dim DrM As DataRow = DtMovimientos.Rows(e.NewEditIndex) - - If DrM IsNot Nothing Then - HdnCve.Value = idMov.ToString - - DdlCtaContable.SelectedValue = DrM("IdCuenta") - TxtReferencia.Text = DrM("Referencia") - TxtObservaciones.Text = DrM("Concepto") - ' (Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) = dr("TipoMovto") - DrM("EsComodin") = 0 - DdlConceptosContables.SelectedValue = DrM("CveConcepto").ToString - TxtCargo.Text = DrM("Cargo").ToString - TxtAbono.Text = DrM("Abono").ToString - TxtDescripcion.Text = DrM("Descripcion") - DdlSubProyecto.SelectedValue = DrM("CveSubProyecto") - DdlProveedores.SelectedValue = DrM("CveProveedor") - DdlCompras.SelectedValue = DrM("CveCompra") - DdlPersonal.SelectedValue = DrM("CvePersonal") - ' DrM("CveClasificacion") = -1 - DdlClientes.SelectedValue = DrM("CveCliente") - DdlVentas.SelectedValue = DrM("CveVenta") - LbCancelarEdicion.Visible = True - LbAgregar.Text = "Actualizar" - GvMov.Rows(e.NewEditIndex).FCTextBox("TxtCargo").CssClass = "" - GvMov.Rows(e.NewEditIndex).FCTextBox("TxtAbono").CssClass = "" - End If - - UPPDocumento.Update() - DivAgregarConceptos.Visible = True - - 'If DtMovimientos Is Nothing Then CreaDT() - - '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 & "
" & NombreCuenta - 'dr("Cuenta") = DdlConceptosContables.SelectedItem - 'dr("Referencia") = TxtReferencia.Text - 'dr("Concepto") = TxtObservaciones.Text - 'dr("TipoMovto") = If(Math.Abs(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 - 'dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero - 'dr("CveCompra") = DdlCompras.SelectedValue.ToEntero - 'dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - 'dr("CveClasificacion") = -1 - 'dr("CveCliente") = DdlClientes.SelectedValue.ToEntero - 'dr("CveVenta") = DdlVentas.SelectedValue.ToEntero - - 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero - 'TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero - 'DtMovimientos.Rows.Add(dr) - - 'If CvePrePoliza > 0 Then - ' GvPrePoliza.DataSource = DtMovimientos - ' GvPrePoliza.DataBind() - 'End If - - - 'GvMov.DataSource = DtMovimientos - 'GvMov.DataBind() - 'UPMovs.Update() - - - End Sub - - Private Sub LbCancelarEdicion_Click(sender As Object, e As EventArgs) Handles LbCancelarEdicion.Click - LbCancelarEdicion.Visible = False - TxtObservaciones.Text = "" - Actualizar = False - LbAgregar.Text = "Agregar" - - GvMov.DataSource = DtMovimientos - GvMov.DataBind() - UPMovs.Update() - RegistraScript("calculateCargo();calculateAbono();comparar()") - End Sub - - Private Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click - + End If + + ObjContabilidad.Dispose() + End Sub +#End Region + + Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs) + If UpPrePoliza.Visible Then + For Each Gvr As GridViewRow In GvPrePoliza.Rows + Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue) + Next + UpPrePoliza.Update() + End If + If UPMovs.Visible Then + For Each Gvr As GridViewRow In GvMov.Rows + Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue) + Next + UPMovs.Update() + End If + End Sub + Protected Sub DdlSubProyectoFiltro_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim Ddl As DropDownList = CType(sender, DropDownList) + For Each Gvr As GridViewRow In GvPrePoliza.Rows + If Ddl.SelectedValue.ToEntero > 0 Then + If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = Ddl.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Or Gvr.FCDropDownList("DdlSubProyecto").Enabled Then + Gvr.Visible = True + Gvr.FCDropDownList("DdlSubProyecto").SelectedValueExist(Ddl.SelectedValue) + Else + Gvr.Visible = False + End If + Else + Gvr.Visible = True + End If + Next + UpPrePoliza.Update() + RegistraScript("calculateAbono()", "cargo") + RegistraScript("calculateCargo()", "abono") + RegistraScript("comparar()", "compara") + End Sub + Protected Sub DdlSubProyectoFiltroMov_SelectedIndexChanged(sender As Object, e As EventArgs) + For Each Gvr As GridViewRow In GvMov.Rows + If DdlSubProyectoFiltroMov.SelectedValue.ToEntero > 0 Then + If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = DdlSubProyectoFiltroMov.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Or Gvr.FCDropDownList("DdlSubProyecto").Enabled Then + Gvr.Visible = True + Gvr.FCDropDownList("DdlSubProyecto").SelectedValueExist(DdlSubProyectoFiltroMov.SelectedValue) + Else + Gvr.Visible = False + End If + Else + Gvr.Visible = True + End If + Next + UpPrePoliza.Update() + RegistraScript("calculateAbono()", "cargo") + RegistraScript("calculateCargo()", "abono") + RegistraScript("comparar()", "compara") + End Sub + + Private Sub GvMov_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvMov.RowEditing + Actualizar = True + GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero + Dim idMov As Integer = GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero + + Dim DrM As DataRow = DtMovimientos.Rows(e.NewEditIndex) + + If DrM IsNot Nothing Then + HdnCve.Value = idMov.ToString + + DdlCtaContable.SelectedValue = DrM("IdCuenta") + TxtReferencia.Text = DrM("Referencia") + TxtObservaciones.Text = DrM("Concepto") + ' (Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) = dr("TipoMovto") + DrM("EsComodin") = 0 + DdlConceptosContables.SelectedValue = DrM("CveConcepto").ToString + TxtCargo.Text = DrM("Cargo").ToString + TxtAbono.Text = DrM("Abono").ToString + TxtDescripcion.Text = DrM("Descripcion") + DdlSubProyecto.SelectedValue = DrM("CveSubProyecto") + DdlProveedores.SelectedValue = DrM("CveProveedor") + DdlCompras.SelectedValue = DrM("CveCompra") + DdlPersonal.SelectedValue = DrM("CvePersonal") + ' DrM("CveClasificacion") = -1 + DdlClientes.SelectedValue = DrM("CveCliente") + DdlVentas.SelectedValue = DrM("CveVenta") + LbCancelarEdicion.Visible = True + LbAgregar.Text = "Actualizar" + GvMov.Rows(e.NewEditIndex).FCTextBox("TxtCargo").CssClass = "" + GvMov.Rows(e.NewEditIndex).FCTextBox("TxtAbono").CssClass = "" + End If + + UPPDocumento.Update() + DivAgregarConceptos.Visible = True + + 'If DtMovimientos Is Nothing Then CreaDT() + + '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 & "
" & NombreCuenta + 'dr("Cuenta") = DdlConceptosContables.SelectedItem + 'dr("Referencia") = TxtReferencia.Text + 'dr("Concepto") = TxtObservaciones.Text + 'dr("TipoMovto") = If(Math.Abs(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 + 'dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero + 'dr("CveCompra") = DdlCompras.SelectedValue.ToEntero + 'dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + 'dr("CveClasificacion") = -1 + 'dr("CveCliente") = DdlClientes.SelectedValue.ToEntero + 'dr("CveVenta") = DdlVentas.SelectedValue.ToEntero + + 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero + 'TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero + 'DtMovimientos.Rows.Add(dr) + + 'If CvePrePoliza > 0 Then + ' GvPrePoliza.DataSource = DtMovimientos + ' GvPrePoliza.DataBind() + 'End If + + + 'GvMov.DataSource = DtMovimientos + 'GvMov.DataBind() + 'UPMovs.Update() + + + End Sub + + Private Sub LbCancelarEdicion_Click(sender As Object, e As EventArgs) Handles LbCancelarEdicion.Click + LbCancelarEdicion.Visible = False + TxtObservaciones.Text = "" + Actualizar = False + LbAgregar.Text = "Agregar" + + GvMov.DataSource = DtMovimientos + GvMov.DataBind() + UPMovs.Update() + RegistraScript("calculateCargo();calculateAbono();comparar()") + End Sub + + Private Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click + Contabilizar() End Sub Private Sub Contabilizar() - Dim ObjConta As New ClsContabilidad - + Dim ObjConta As New ClsContabilidad + If IdPoliza > 0 Then 'si está bloqueada, lo desbloqueaprimero ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) - End If - - If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, pIDPoliza:=If(IdPoliza > 0, IdPoliza, -1), Concepto:=TxtConcepto.Text, Fecha:=TxtFechaDocumento.Text.ToDateTime) Then - Alert(String.Format("Prepóliza contabilizada.

Folio:Ver Póliza", ObjConta.ContaIdPoliza), ModExtensiones.TipoMensaje.MsgInformacion) - Else - - Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) - End If - + End If + + If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, pIDPoliza:=If(IdPoliza > 0, IdPoliza, -1), Concepto:=TxtConcepto.Text, Fecha:=TxtFechaDocumento.Text.ToDateTime) Then + Alert(String.Format("Prepóliza contabilizada.

Folio:Ver Póliza", ObjConta.ContaIdPoliza), ModExtensiones.TipoMensaje.MsgInformacion) + Else + + Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) + End If + ObjConta.Dispose() End Sub -#Region "COMPLEMENTO DE PAGO" +#Region "COMPLEMENTO DE PAGO" - Private Sub GeneraTimbre(CvePrePoliza As Integer) - Dim Str As New StringBuilder - Dim Banco As New ClsBancos - Banco.IniciaTransacSQL() - If Banco.GeneraTimbrePago(-1, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then - If Banco.Mensaje = "" Then - Banco.Commit() - PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False) - Str.AppendFormat("Folio: {0}  ", Banco.ComplementoSerieFolio) - Str.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) - Str.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) - MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo) - End If - Else - Banco.RollBack() - Str.AppendFormat("No se genero complemento por el siguiente motivo: {0}", Banco.Mensaje) - End If - Banco.Dispose() - Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();") - End Sub - - Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True) - Try - Dim Msg As String = "" - If NombreArchivo <> "-1" Then ' - Dim ObjMail As New ClsSisMail() - Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo) - Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo) - Dim Cuerpo As String = "Se hace entrega del comprobante de pago" - Dim Asunto As String = "Entrega de comprobante de pago" - If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) - If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then - If ConAlerta Then - 'RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - End If - Else - Msg = "No se pudo enviar el correo electrónico." - End If - Else - Msg = "No se pudo adjuntar el correo electrónico." - End If - End If - If ConAlerta AndAlso Msg <> "" Then - Alert(Msg, TipoMensaje.MsgError) - End If - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - End Try - End Sub - - Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) - GeneraTimbre(CvePrePoliza) + Private Sub GeneraTimbre(CvePrePoliza As Integer) + Dim Str As New StringBuilder + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + If Banco.GeneraTimbrePago(-1, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then + If Banco.Mensaje = "" Then + Banco.Commit() + PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False) + Str.AppendFormat("Folio: {0}  ", Banco.ComplementoSerieFolio) + Str.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) + Str.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) + MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo) + End If + Else + Banco.RollBack() + Str.AppendFormat("No se genero complemento por el siguiente motivo: {0}", Banco.Mensaje) + End If + Banco.Dispose() + Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();") End Sub -#End Region + + Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True) + Try + Dim Msg As String = "" + If NombreArchivo <> "-1" Then ' + Dim ObjMail As New ClsSisMail() + Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo) + Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo) + Dim Cuerpo As String = "Se hace entrega del comprobante de pago" + Dim Asunto As String = "Entrega de comprobante de pago" + If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) + If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then + If ConAlerta Then + 'RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + End If + Else + Msg = "No se pudo enviar el correo electrónico." + End If + Else + Msg = "No se pudo adjuntar el correo electrónico." + End If + End If + If ConAlerta AndAlso Msg <> "" Then + Alert(Msg, TipoMensaje.MsgError) + End If + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + End Try + End Sub + + Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) + GeneraTimbre(CvePrePoliza) + End Sub +#End Region @@ -1679,7 +1690,7 @@ Partial Class ContabilidadC_RegPrePoliza ddl.Items.Insert(0, New ListItem(" - ", "-1")) End If - ObjCompras.Dispose() + ObjCompras.Dispose() End Sub Private Sub CargaGvBitacora() @@ -1691,5 +1702,5 @@ Partial Class ContabilidadC_RegPrePoliza End If ObjGral.Dispose() End Sub -End Class - +End Class + diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index e3b61c3c4..5d6f271af 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -650,6 +650,7 @@ + diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index 2c17d3d82..2210878a2 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -1079,6 +1079,13 @@ Partial Class ContabilidadC_RegPrePolizaS Else DdlPersonalE.Visible = False End If + + If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(51) Then + CargaClasificacionesE() + DdlClasificacionesE.Visible = True + Else + DdlClasificacionesE.Visible = False + End If If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39) Then CargaClientesE() DdlClientesE.Visible = True @@ -1136,6 +1143,12 @@ Partial Class ContabilidadC_RegPrePolizaS DdlPersonalE.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) DdlPersonalE.DataBind() DdlPersonalE.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Private Sub CargaClasificacionesE() + DdlClasificacionesE.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificacionesE.DataBind() + DdlClasificacionesE.Items.Insert(0, New ListItem(" - ", "-1")) End Sub Private Sub DdlProveedoresE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedoresE.SelectedIndexChanged CargaComprasE(DdlProveedoresE.SelectedValue.ToEntero) From 8ae837108f51e61d11c2520802c230b6b19e5592 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 11 Jan 2021 09:22:57 -0700 Subject: [PATCH 02/13] Contratos --- AF/CatActividades.aspx | 2 +- AF/CatActividades.aspx.cs | 2 +- AF/CatCheckList.aspx | 4 ++-- AF/CatCheckList.aspx.cs | 4 ++-- AF/CatCheckListActividades.aspx | 4 ++-- AF/CatCheckListActividades.aspx.cs | 2 +- App_Code/ClsValidaCFDi.vb | 13 ++++++++++-- Bancos/IE.aspx.vb | 2 +- Compras/Compras.aspx.vb | 34 ++++++++++++++++++------------ Contratos/ContratoObra.aspx.vb | 20 ++++++++++-------- 10 files changed, 53 insertions(+), 34 deletions(-) diff --git a/AF/CatActividades.aspx b/AF/CatActividades.aspx index 907d6a766..30c434641 100644 --- a/AF/CatActividades.aspx +++ b/AF/CatActividades.aspx @@ -43,7 +43,7 @@