From 2d15b9ef55459ad6b468090eb74d648dc50b9f45 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 13 Mar 2020 18:40:43 -0700 Subject: [PATCH 01/24] -- parametro de cvecorte --- Bancos/PopIEVentas.aspx.vb | 88 ++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 7a3e359f8..1395d747c 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -322,6 +322,15 @@ Partial Class Bancos_PopIEVentas End Set End Property + Private Property CveCorte As Integer + Get + Return ViewState("CveCorte").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCorte") = value + End Set + End Property + Private Property TipoCambioOriginal As Decimal Get Return ViewState("TipoCambioOriginal").ToString.ToDecimal @@ -527,7 +536,7 @@ Partial Class Bancos_PopIEVentas ViewState("IdCtaAnticipo") = 0 ViewState("IdCtaContMonedaExtranjeraAnticipo") = 0 ViewState("IdCtaContMonedaComplementariaAnticipo") = 0 - + CveCorte = -1 IdCuentaBancariaComplementaria = 0 @@ -672,48 +681,46 @@ Partial Class Bancos_PopIEVentas If ObjVenta.DtResultados IsNot Nothing AndAlso ObjVenta.DtResultados.Rows.Count > 0 Then - - 'CargaProveedor Dim dr As DataRow = ObjVenta.DtResultados.Rows(0) Dim Validada As Boolean = True 'JJMQ:20190606 Se cancela código de validacion ante el SAT por lentitud en el servicio. 'Sustituir la línea anterior por todo lo siguiente hasta donde termina el end if para que valide de nueva cuenta 'Dim Validada As Boolean = False - 'If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then + If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then - ' Dim Valida As New ClsValidaCFDi(dr("FolioFiscal").ToString(), dr("ClienteRFC").ToString, UsuarioActual.Empresa.RFC) + Dim Valida As New ClsValidaCFDi(dr("FolioFiscal").ToString(), dr("ClienteRFC").ToString, UsuarioActual.Empresa.RFC) - ' If Valida.EsValida > 0 Then - ' If Valida.EsValida = 2 Then - ' Validada = False - ' 'Dim ObjDatos As New ClsCompras + If Valida.EsValida > 0 Then + If Valida.EsValida = 2 Then + Validada = False + 'Dim ObjDatos As New ClsCompras - ' 'If ObjDatos.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then + 'If ObjDatos.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then - ' 'End If - ' 'ObjDatos.Dispose() + 'End If + 'ObjDatos.Dispose() - ' BtnGuardar.Enabled = False + BtnGuardar.Enabled = False - ' If UsuarioActual.Empresa.UsaAC Then - ' RegistraScript("if (confirm('La factura está cancelada ante el SAT., ¿Desea eliminar la compra?')) { $get('BtnEliminarCompra').click();}") - ' Else - ' Alert("La factura está cancelada ante el SAT.") - ' End If + If UsuarioActual.Empresa.UsaAC Then + RegistraScript("if (confirm('La factura está cancelada ante el SAT., ¿Desea eliminar la compra?')) { $get('BtnEliminarCompra').click();}") + Else + Alert("La factura está cancelada ante el SAT.") + End If - ' Else - ' Validada = True - ' End If - ' Else - ' 'no se pudo validar, pero ya tuvo la primera vuelta de validacion - ' Validada = True - ' End If - ' Valida.Dispose() - 'Else - ' Validada = True - 'End If + Else + Validada = True + End If + Else + 'no se pudo validar, pero ya tuvo la primera vuelta de validacion + Validada = True + End If + Valida.Dispose() + Else + Validada = True + End If If Validada Then @@ -725,7 +732,7 @@ Partial Class Bancos_PopIEVentas CveMoneda = dr("CveMoneda").ToString.ToEntero CveMonedaVenta = dr("CveMoneda").ToString.ToEntero CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero - NombreCliente = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Nombre", String.Format("CveCliente = {0}", CveCliente)) + NombreCliente = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=CveCliente).FiltroPrimeroValor("Nombre", String.Format("CveCliente = {0}", CveCliente)) SerieFolio = dr("SerieFolio").ToString TipoCambioOriginal = dr("TipoCambio").ToString.ToDecimal CveSubProyectoVenta = dr("CveSubProyecto").ToString.ToEntero @@ -777,6 +784,12 @@ Partial Class Bancos_PopIEVentas FechaVenta = dr("Fecha").ToString.ToDate SaldoVenta = dr("Saldo").ToString.ToDouble + + + 'Cortes de Caja + If UsuarioActual.TienePermisoProceso(160) Then + CargaCorteCaja() + End If End If @@ -786,6 +799,19 @@ Partial Class Bancos_PopIEVentas ObjVenta.Dispose() End Sub + Private Sub CargaCorteCaja() + 'Checar si hay un Turno Abierto + Dim ObjPVenta As New ClsPuntoVenta + + If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then + + If ObjPVenta.DtResultados.Rows.Count > 0 Then + CveCorte = ObjPVenta.CveCorte + End If + End If + ObjPVenta.Dispose() + End Sub + Private Sub CargaCliente(ByVal CveCliente As Integer, RFC As String) Dim ObjCliente As New ClsClientes @@ -1497,7 +1523,7 @@ Partial Class Bancos_PopIEVentas Select Case RBLContado.SelectedValue Case "1" ' Banco - CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, tipoCambioPago, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1")) + CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, tipoCambioPago, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), CveCorte:=CveCorte) If CveIE > 0 Then If CveVenta > 0 Then CveConcepto = 2 From 74c116ac826525508c11cdb7cb94c1664466224f Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 17 Mar 2020 16:31:23 -0700 Subject: [PATCH 02/24] -optimizacion --- Sistemas/UsuarioDetalle.aspx.vb | 14 +- Ventas/Ventas.aspx | 5 +- Ventas/Ventas.aspx.vb | 382 ++++++++++++++++++++------------ 3 files changed, 245 insertions(+), 156 deletions(-) diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index 6daf7065a..1794f951d 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -1288,12 +1288,14 @@ Partial Class Sistemas_UsuarioDetalle Private Sub RecargaGlobales(TieneError As Boolean, ObjSubProyectos As ClsSubProyectos, ObjBancos As ClsBancos, ObjOC As ClsOC, ObjUsuarios As ClsSisUsuarios) 'RECARGA GLOBAL SUBPROYECTOS If Not TieneError Then - If ObjSubProyectos.GetSubProyectosUsuarios Then - Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados - Else - Application("GlobalDTSubProyectosUsuarios") = Nothing - TieneError = True - End If + GlobalDTSubProyectosUsuarios(-1, -1, UsuarioActual.CveEmpresa) = Nothing + + 'If ObjSubProyectos.GetSubProyectosUsuarios Then + ' Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados + 'Else + ' Application("GlobalDTSubProyectosUsuarios") = Nothing + ' TieneError = True + 'End If End If If Not TieneError Then diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 840c535f4..d05f330be 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3355,7 +3355,7 @@ - + @@ -3364,8 +3364,7 @@ - - + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 52b6db6e6..657193607 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2418,18 +2418,21 @@ Partial Class Ventas LblSubProyecto.Text = "" divProyectoPyME.Visible = False LblSubProyectoPyME.InnerText = "Sucursal" + Dim dttSub As New DataTable + dttSub = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) DdlSubProyecto.Items.Clear() - DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = dttSub 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlSubProyectoPyME.Items.Clear() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dttSub 'DdlSubProyectoPyME.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyectoPyME.DataBind() DdlSubProyectoPyME.Items.Insert(0, New ListItem("Seleccione", "-1")) + dttSub.Dispose() ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then DdlProyecto.Visible = False @@ -2439,18 +2442,21 @@ Partial Class Ventas LblSubProyecto.Text = "" divProyectoPyME.Visible = False LblSubProyectoPyME.InnerText = "Proyecto" + Dim dttSub As New DataTable + dttSub = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) DdlSubProyecto.Items.Clear() - DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = dttSub 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlSubProyectoPyME.Items.Clear() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dttSub 'DdlSubProyectoPyME.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyectoPyME.DataBind() DdlSubProyectoPyME.Items.Insert(0, New ListItem("Seleccione", "-1")) + dttSub.Dispose() ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then LblProyectoHeader.Text = "Sucursal" @@ -2603,8 +2609,6 @@ Partial Class Ventas End If TxtFecha.Enabled = True - CargaPorcentajeMarcas() - BloqueaCondiconesPago() BloqueaClasificaciones() @@ -3538,13 +3542,17 @@ Partial Class Ventas Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Rows(0) Dim CveCliente As Integer = DbRowVenta("CveCliente").ToString.ToEntero HdnCveVenta.Value = CveVenta.ToString - - Dim ObjUsados As New ClsVentas Dim DtUsados As DataTable = Nothing - If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString.ToDateTime, UsuarioActual.CveEmpresa) Then - DtUsados = ObjUsados.DtResultados + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Dim ObjUsados As New ClsVentas + + If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString.ToDateTime, UsuarioActual.CveEmpresa) Then + DtUsados = ObjUsados.DtResultados + End If + ObjUsados.Dispose() End If - ObjUsados.Dispose() + Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString.ToEntero 'CargaEncabezado @@ -3605,6 +3613,19 @@ Partial Class Ventas End If End If + 'CargaDetalle + If ObjVentas.GetVentaDetalle(CveVenta) Then + TmpDT = ObjVentas.DtResultados + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + GvPS.DataSource = ObjVentas.DtResultados + GvPS.DataBind() + + 'IEPS A NIVEL DETALLE + 'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text) + End If + + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso LblFolioFiscal.Text.Trim = "" Then HplFolioFiscalModal.Visible = True Select Case DbRowVenta("TipoDocto").ToString @@ -3622,7 +3643,7 @@ Partial Class Ventas If TienePermiso <> "" Then ' si tiene acceso en el subproyecto 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion() + InicializaAplicaDevolucion(TmpDT) End If End If @@ -3754,11 +3775,11 @@ Partial Class Ventas End If 'contado 0, credito 1, terminal 2 - If ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 1 Then + If DbRowVenta("CondicionesPago").ToString.ToEntero = 1 Then RBLPago.SelectedValue = "1" RBLPago_SelectedIndexChanged(Nothing, Nothing) UPCondicionesPago.Update() - ElseIf ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 0 Then + ElseIf DbRowVenta("CondicionesPago").ToString.ToEntero = 0 Then RBLPago.SelectedValue = "2" RBLPago.Items(0).Enabled = False RBLPago_SelectedIndexChanged(Nothing, Nothing) @@ -3771,17 +3792,6 @@ Partial Class Ventas UPCondicionesPago.Update() End If - 'CargaDetalle - If ObjVentas.GetVentaDetalle(CveVenta) Then - TmpDT = ObjVentas.DtResultados - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - GvPS.DataSource = ObjVentas.DtResultados - GvPS.DataBind() - - 'IEPS A NIVEL DETALLE - 'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text) - End If 'ESCONDE ACCIONES LnkRemisiones.Visible = False @@ -5151,6 +5161,10 @@ Partial Class Ventas CargaRestriccionesCreditoCliente(True, Me.CveVenta) End If + ' si es empresa acumuladores + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + CargaPorcentajeMarcas() + End If UpFacturar.Update() UpEstatus.Update() @@ -5205,124 +5219,122 @@ Partial Class Ventas End Sub Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1) - Dim ObjCliente As New ClsClientes() - If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then - If ObjCliente.DtResultados.Rows.Count > 0 Then - If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso ObjCliente.DtResultados.Rows(0)("PermiteCredito").ToString = "False" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1 Then - RBLPago.SelectedValue = "2" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - If UsuarioActual.CveEmpresa.Contiene(119) AndAlso Not UsuarioActual.TienePermisoProceso(268) Then + + If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1 Then + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + If UsuarioActual.CveEmpresa.Contiene(119) AndAlso Not UsuarioActual.TienePermisoProceso(268) Then + DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") + DdlTipoComprobante.SelectedValue = "PA" + TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString + 'si llegó por la opción de cotización no debe de restringuir + If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + End If + UPCondicionesPago.Update() + ElseIf UsuarioActual.CveEmpresa.Contiene(72, 119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then + RBLPago.SelectedValue = "1" + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) + + If CreditoDispo > 0 Then + TrCreditoDisponible.Visible = True + LblCreditoDisponible.Text = CreditoDispo.FormatoNumero + If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%" + If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then + + 'If LblRFC.Text.Trim <> "XAXX010101000" Then + + Dim Vta As New ClsVentas + Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) + Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) + Vta.Dispose() + If Opcion > 0 Then + 'si la cotización no debe de existir este canddado + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + 'RBLPago.SelectedValue = "2" + 'RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") DdlTipoComprobante.SelectedValue = "PA" TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString 'si llegó por la opción de cotización no debe de restringuir If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + 'quito remisión y factura DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - End If - UPCondicionesPago.Update() - ElseIf UsuarioActual.CveEmpresa.Contiene(72, 119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then - RBLPago.SelectedValue = "1" - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) - - If CreditoDispo > 0 Then - TrCreditoDisponible.Visible = True - LblCreditoDisponible.Text = CreditoDispo.FormatoNumero - If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%" - If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then - - 'If LblRFC.Text.Trim <> "XAXX010101000" Then - - Dim Vta As New ClsVentas - Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) - Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) - Vta.Dispose() - If Opcion > 0 Then - 'si la cotización no debe de existir este canddado - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - 'RBLPago.SelectedValue = "2" - 'RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") - DdlTipoComprobante.SelectedValue = "PA" - TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString - 'si llegó por la opción de cotización no debe de restringuir - If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" - 'quito remisión y factura - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - If Opcion = 1 Then - BtnEmitirImprimir.Visible = False - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - LnkOCs.Visible = False - End If - Else - ' el cliente tiene crédito disponible, no tiene bloqueo - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA")) - - If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar - If UsuarioActual.TienePermisoProceso(199) Then DdlTipoComprobante.SelectedValueExistInsert("Rem", "Remisión") ' puede remisionar - DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) - - TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString - End If - - 'Else - ' 'que no de crédito, solo contado - ' RBLPago.SelectedValue = "2" - ' RBLPago.Items(0).Enabled = False - 'End If - - End If - Else - - If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") Then - Dim Vta As New ClsVentas - Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) - Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) - Vta.Dispose() - If Opcion > 0 Then - If Opcion = 1 Then - BtnEmitirImprimir.Visible = False - End If - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - Else - If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) - End If - - 'RBLPago.SelectedValue = "2" - 'RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") - DdlTipoComprobante.SelectedValue = "PA" - TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString - 'si llegó por la opción de cotización no debe de restringuir - If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + If Opcion = 1 Then + BtnEmitirImprimir.Visible = False BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False LnkPedido2SinFacturar.Visible = False LnkCotizaciones.Visible = False LnkOCs.Visible = False End If + Else + ' el cliente tiene crédito disponible, no tiene bloqueo + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA")) + + If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar + If UsuarioActual.TienePermisoProceso(199) Then DdlTipoComprobante.SelectedValueExistInsert("Rem", "Remisión") ' puede remisionar + DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) + + TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString End If - UPPCreditoDisponible.Update() - ElseIf UsuarioActual.CveEmpresa.Contiene(119, 1) AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso CveVenta > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Pd2", "Cot") Or (DdlTipoComprobante.SelectedValue = "Rem" And ModalidadEdicion And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000")) Then - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) + + 'Else + ' 'que no de crédito, solo contado + ' RBLPago.SelectedValue = "2" + ' RBLPago.Items(0).Enabled = False + 'End If + + End If + Else + + If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") Then + Dim Vta As New ClsVentas + Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) + Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) + Vta.Dispose() + If Opcion > 0 Then + If Opcion = 1 Then + BtnEmitirImprimir.Visible = False + End If + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + Else + If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) + End If + + 'RBLPago.SelectedValue = "2" + 'RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") + DdlTipoComprobante.SelectedValue = "PA" + TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString + 'si llegó por la opción de cotización no debe de restringuir + If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + LnkOCs.Visible = False + End If + End If + UPPCreditoDisponible.Update() + ElseIf UsuarioActual.CveEmpresa.Contiene(119, 1) AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso CveVenta > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Pd2", "Cot") Or (DdlTipoComprobante.SelectedValue = "Rem" And ModalidadEdicion And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000")) Then + Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) If CreditoDispo > 0 Then Dim Vta As New ClsVentas Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) @@ -5331,8 +5343,8 @@ Partial Class Ventas If Opcion > 0 Then If ModalidadEdicion AndAlso ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero And DdlTipoComprobante.SelectedValue = "Rem" And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000" Then ViewState("CveCliente") = ViewState("CveClienteAnterior").ToString.ToEntero - ObjCliente.Dispose() - CargaCliente(ViewState("CveCliente").ToString.ToEntero) + + CargaCliente(ViewState("CveCliente").ToString.ToEntero) If Opcion > 0 Then If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) Else @@ -5382,9 +5394,7 @@ Partial Class Ventas End If End If End If - End If - End If - ObjCliente.Dispose() + End Sub @@ -5516,14 +5526,17 @@ Partial Class Ventas Return Retorno End Function Private Sub CargaDdlSubProyectos() - DdlSubProyectoDatos.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + Dim dtt As New DataTable + dtt = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoDatos.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoDatos.DataBind() - DdlSubProyectoCobranza.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + DdlSubProyectoCobranza.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoCobranza.DataBind() - DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + DdlSubProyectoEjecucion.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoEjecucion.DataBind() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dtt DdlSubProyectoPyME.DataBind() + dtt.Dispose() End Sub Private Sub CargaClasificaciones() If UsuarioActual.Empresa.UsaAC Then @@ -5618,13 +5631,16 @@ Partial Class Ventas Public Sub CargaDdlNCPS() Dim CveSATNC = "84111506" - DdlNCPS.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + Dim dtt As New DataTable + dtt = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + DdlNCPS.DataSource = dtt DdlNCPS.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlNCPS.DataBind() - DdlNCPSAnt.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + DdlNCPSAnt.DataSource = dtt DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlNCPSAnt.DataBind() + dtt.Dispose() End Sub #End Region @@ -15780,7 +15796,7 @@ Partial Class Ventas If ConSalida AndAlso Not OcurrioError Then If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura) + OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) End If If Not OcurrioError Then @@ -16136,7 +16152,7 @@ Partial Class Ventas Return Not OcurrioError End Function - Private Function GenerarMovimientoAlmacenVirtual(CveRemision As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura) As Boolean + Private Function GenerarMovimientoAlmacenVirtual(CveRemision As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura, Optional ByRef ObjConta As ClsContabilidad = Nothing) As Boolean Dim OcurrioError As Boolean = False Try @@ -16190,6 +16206,57 @@ Partial Class Ventas OcurrioError = True End If + 'Agregamos las PrePolizas + If Not OcurrioError Then + If CveMovimientoVirtual > 0 Then + 'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen) + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim ValorInventario As Decimal + Dim TotalCostoAcumulado As Decimal = 0D + Dim Cont As Integer = 1 + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + Try + 'If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ValorInventario, ObjFactura.SerieFolio, 69, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + Exit For + End If + 'End If + Catch ex As Exception + OcurrioError = True + Alert("Error inesperado (15148). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + End Try + Cont += 1 + Next + + If Not OcurrioError Then + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacenVirtual)).ToEntero + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, TotalCosto, ObjFactura.SerieFolio, 68, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + End If + End If + End If Catch ex As Exception @@ -21953,7 +22020,7 @@ Partial Class Ventas #End Region #Region " APLICA DEVOLUCION " - Private Sub InicializaAplicaDevolucion() + Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable) 'If Not UsuarioActual.CveUsuario = 100 Then ' If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 140, 141, 146) Then ' Exit Sub @@ -21967,13 +22034,13 @@ Partial Class Ventas LBAplicaDevolucion.Visible = True Dim SeEsconde As Boolean = False - Dim ObjVenta As New ClsVentas - If ObjVenta.GetVentaDetalle(CveVenta) Then - If Not ObjVenta.DtResultados.SUM("CantSur").ToString.ToDecimal > 0 Then SeEsconde = True + + If DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0 Then + If Not DtDetalle.SUM("CantSur").ToString.ToDecimal > 0 Then SeEsconde = True 'NO MOSTRAR LOS PRODUCTOS CON LA CLASIFICACION DE USADOS - GvAplicaDevolucion.DataSource = ObjVenta.DtResultados.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519") + GvAplicaDevolucion.DataSource = DtDetalle.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519") End If - ObjVenta.Dispose() + 'activo el permiso para registrar el importe diferente a la devolución GvAplicaDevolucion.Columns(9).Visible = UsuarioActual.TienePermisoProceso(253) @@ -24903,4 +24970,25 @@ Partial Class Ventas Protected Sub LnkGenerarOC_Click(sender As Object, e As EventArgs) Response.Redirect($"~/OC/OC.aspx?CveCotizacion={Me.CveVenta}&Tipo=OC") End Sub + + 'Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + ' Dim ObjVentas As New ClsVentas + ' ObjVentas.IniciaTransacSQL() + + ' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) + ' Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) + ' Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL()) + ' Dim ObjAC As ClsContPAQi = Nothing + + ' If Not RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then + ' ObjVentas.Commit() + ' If ObjAC IsNot Nothing Then ObjAC.Commit() + ' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();") + ' End If + + ' ObjVentas.Dispose() + ' ObjConta.Dispose() + ' ObjBancos.Dispose() + ' If ObjAC IsNot Nothing Then ObjAC.Dispose() + 'End Sub End Class \ No newline at end of file From 0f1ed5d000eb679bd8f53baf06d6ac3dc1f1b9f3 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 17 Mar 2020 16:33:31 -0700 Subject: [PATCH 03/24] - --- Acumuladores/CatFoliosGarantia.aspx | 6 +- Acumuladores/CatFoliosGarantia.aspx.vb | 4 +- App_Code/ClsAcumuladores.vb | 10 +- App_Code/ClsPaginas.vb | 37 +- App_Code/Modelos.vb | 1 + Ashx/SIGWeb.ashx | 7 +- Compras/Compras.aspx.vb | 36822 ++++++++++++----------- Compras/PopUpVerFactura.aspx | 2 +- Inventarios/RecepcionUsados.aspx.vb | 2 +- 9 files changed, 18453 insertions(+), 18438 deletions(-) diff --git a/Acumuladores/CatFoliosGarantia.aspx b/Acumuladores/CatFoliosGarantia.aspx index 3d1962323..4dd384796 100644 --- a/Acumuladores/CatFoliosGarantia.aspx +++ b/Acumuladores/CatFoliosGarantia.aspx @@ -90,8 +90,8 @@
- - + +
@@ -151,7 +151,7 @@   - +   diff --git a/Acumuladores/CatFoliosGarantia.aspx.vb b/Acumuladores/CatFoliosGarantia.aspx.vb index 795b00dfc..1d4de3735 100644 --- a/Acumuladores/CatFoliosGarantia.aspx.vb +++ b/Acumuladores/CatFoliosGarantia.aspx.vb @@ -57,7 +57,7 @@ Partial Class Acumuladores_CatFoliosGarantia Dim objAcum As New ClsAcumuladores - If objAcum.FoliosGarantiaGet(-1, UsuarioActual.Empresa.CveEmpresa, Estatus:=EstatusValor, TipoFolio:=tipoFolioValor) Then + If objAcum.FoliosGarantiaGet(-1, UsuarioActual.Empresa.CveEmpresa, Estatus:=EstatusValor, TipoFolio:=tipoFolioValor, Area:=-1) Then GvFolioGarantia.DataSource = objAcum.DtResultados Else GvFolioGarantia.DataSource = Nothing @@ -116,7 +116,7 @@ Partial Class Acumuladores_CatFoliosGarantia If Not Actualizar Then - If ObjAcum.FoliosGarantiaAdd(TxtFolioGarantia.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlSubProyectos.SelectedValue.ToEntero, DdlTipoFolioModal.SelectedValue, TxtLimite.Text.ToEntero) Then + If ObjAcum.FoliosGarantiaAdd(TxtFolioGarantia.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlSubProyectos.SelectedValue.ToEntero, DdlTipoFolioModal.SelectedValue, TxtLimite.Text.ToEntero, 2) Then TxtFolioGarantia.Text = "" ChkEstatus.Checked = True diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 75fc8ce98..2d74b5f69 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -483,7 +483,7 @@ Public Class ClsAcumuladores #Region " FOLIOS GARANTÍA " - Public Function FoliosGarantiaGet(CveFolioGarantia As Integer, CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional TipoFolio As String = "-1") As Boolean + Public Function FoliosGarantiaGet(CveFolioGarantia As Integer, CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional TipoFolio As String = "-1", Optional Area As Integer = 1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -493,7 +493,8 @@ Public Class ClsAcumuladores .Add("@CveFolioGarantia", SqlDbType.Int).Value = CveFolioGarantia .Add("@Estatus", SqlDbType.Int).Value = Estatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@tipoFolio", SqlDbType.VarChar).Value = TipoFolio + .Add("@tipoFolio", SqlDbType.VarChar).Value = TipoFolio + .Add("@Area", SqlDbType.Int).Value = Area End With Try @@ -508,7 +509,7 @@ Public Class ClsAcumuladores Return Retorno End Function - Public Function FoliosGarantiaAdd(FolioGarantia As String, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, TipoFolio As String, Limite As Integer) As Boolean + Public Function FoliosGarantiaAdd(FolioGarantia As String, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, TipoFolio As String, Limite As Integer, Area As Integer) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -522,7 +523,8 @@ Public Class ClsAcumuladores .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@TipoFolio", SqlDbType.VarChar).Value = TipoFolio - .Add("@Limite", SqlDbType.Int).Value = Limite + .Add("@Limite", SqlDbType.Int).Value = Limite + .Add("@Area", SqlDbType.Int).Value = Area End With diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index fc4d4beab..47d1faa3d 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -931,11 +931,11 @@ Public Class ClsPaginas End Set End Property Property GlobalDTSubProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable - Get - - If Application("GlobalDTSubProyectosUsuarios") Is Nothing Then + Get + Dim AppNombre As String = String.Format("GlobalDTSubProyectosUsuarios{0}", CveEmpresa) + If Application(AppNombre) Is Nothing Then Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios Then Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) + If ObjSubProyectos.GetSubProyectosUsuarios(CveEmpresa:=CveEmpresa) Then Application(AppNombre) = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) ObjSubProyectos.Dispose() End If @@ -947,33 +947,26 @@ Public Class ClsPaginas If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", CveEstatus) - Dim Dv As New DataView(DirectCast(Application("GlobalDTSubProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) GlobalDTSubProyectosUsuarios = Dv.ToTable Dv.Dispose() - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then - GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados - Else - GlobalDTSubProyectosUsuarios = Nothing - End If - ObjSubProyectos.Dispose() + 'Dim ObjSubProyectos As New ClsSubProyectos() + 'If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then + ' GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados + 'Else + ' GlobalDTSubProyectosUsuarios = Nothing + 'End If + 'ObjSubProyectos.Dispose() Else - GlobalDTSubProyectosUsuarios = DirectCast(Application("GlobalDTSubProyectosUsuarios"), DataTable) + GlobalDTSubProyectosUsuarios = DirectCast(Application(AppNombre), DataTable) End If End Get Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - Dim msg As String = "aqui no se carga subproyectos" - If Request IsNot Nothing Then - msg = msg & Request.ServerVariables("URL") - End If - msg.GuardaLog() - - End If - Application("GlobalDTSubProyectosUsuarios") = value + Dim AppNombre As String = String.Format("GlobalDTSubProyectosUsuarios{0}", CveEmpresa) + Application(AppNombre) = value End Set End Property Property GlobalDTProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, CveEstatus As Integer) As DataTable diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 833d6b4c2..045b59ec5 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -8828,6 +8828,7 @@ Namespace Modelos Estado = "" Pais = "" CP = "" + Telefono = "" AplicaFord = False Ford_GSDB = "" AplicaFEMSA = False diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 9af99331f..986094a69 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -210,6 +210,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then DtRetorno = dt.FiltraParametros($"NombreComercial like '%{Name}%' OR Nombre like '%{Name}%' ") End If + dt.Dispose() End If If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then @@ -220,6 +221,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Else context.Response.Write("[]") End If + DtRetorno.Dispose() Return retorno End Function @@ -256,6 +258,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then DtRetorno = dt.FiltraParametros($"NombreCortoProveedor like '%{Name}%'") End If + dt.Dispose() End If If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then @@ -266,7 +269,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Else context.Response.Write("[]") End If - + DtRetorno.Dispose() Return retorno End Function #End Region @@ -464,6 +467,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState End Try End If + DTPS = Nothing End If If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then DtPSRetorno.Columns("CvePS").ColumnName = "id" @@ -478,6 +482,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Else context.Response.Write("[]") End If + DtPSRetorno.Dispose() End If Return retorno diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index c8104569b..80d869dbf 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1,1614 +1,1614 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports System.Data -Imports System.Xml -Imports System.Globalization -Imports System.Linq -Imports System -Imports System.IO -Imports ADServerControl -Imports System.Threading.Tasks +Option Explicit On +Option Strict On + +Imports Extensiones +Imports System.Data +Imports System.Xml +Imports System.Globalization +Imports System.Linq +Imports System +Imports System.IO +Imports ADServerControl +Imports System.Threading.Tasks Imports System.Diagnostics -Partial Class Compras_Compras +Partial Class Compras_Compras Inherits ClsPaginas -#Region "Propiedades" +#Region "Propiedades" 'Local - Private Property RequiereEvaluacion() As Boolean - Get - Return If(IsNothing(ViewState("RequiereEvaluacion")), False, CBool(ViewState("RequiereEvaluacion"))) - End Get - Set - ViewState("RequiereEvaluacion") = Value - End Set - End Property - - Private Property CveUsuarioEvaluador() As Integer - Get - Return If(IsNothing(ViewState("CveUsuarioEvaluador")), -1, CInt(ViewState("CveUsuarioEvaluador"))) - End Get - Set - ViewState("CveUsuarioEvaluador") = Value - End Set - End Property - Private Property TmpDT As DataTable - Get - Return CType(ViewState("TmpDT"), DataTable) - End Get - Set(value As DataTable) - ViewState("TmpDT") = value - End Set - End Property - Private Property TmpDTOriginal As DataTable - Get - Return CType(ViewState("TmpDTOriginal"), DataTable) - End Get - Set(value As DataTable) - ViewState("TmpDTOriginal") = value - End Set - End Property - Private Property TmpCXP As DataTable - Get - Return CType(ViewState("TmpCXP"), DataTable) - End Get - Set(value As DataTable) - ViewState("TmpCXP") = value - End Set - End Property - - 'Private Property PSDTRemplazo As DataTable - ' Get - ' Return CType(ViewState("PSDTRemplazo"), DataTable) - ' End Get - ' Set(value As DataTable) - ' ViewState("PSDTRemplazo") = value - ' End Set - 'End Property - Private Property DtCheques As DataTable - Get - Return CType(ViewState("DtCheques"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtCheques") = value - End Set - End Property - - Private Property Modalidad As String - Get - Return ViewState("Modalidad").ToString - End Get - Set(value As String) - ViewState("Modalidad") = value - End Set - End Property - - Public Property IdVale As List(Of Integer) - Get - IdVale = DirectCast(ViewState("IdVale"), List(Of Integer)) - End Get - - Set(ByVal value As List(Of Integer)) - ViewState("IdVale") = value - End Set - End Property - Public Property ListaDocumentos As List(Of String) - Get - ListaDocumentos = DirectCast(ViewState("ListaDocumentos"), List(Of String)) - End Get - Set(ByVal value As List(Of String)) - ViewState("ListaDocumentos") = value - End Set + Private Property RequiereEvaluacion() As Boolean + Get + Return If(IsNothing(ViewState("RequiereEvaluacion")), False, CBool(ViewState("RequiereEvaluacion"))) + End Get + Set + ViewState("RequiereEvaluacion") = Value + End Set End Property - Public Property TieneAnticiposXML As Boolean - Get - TieneAnticiposXML = DirectCast(ViewState("TieneAnticiposXML"), Boolean) - End Get - Set(ByVal value As Boolean) - ViewState("TieneAnticiposXML") = value - End Set - End Property - - Private Property DTOCTemp As DataTable - Get - Return CType(ViewState("DTOCTemp"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTOCTemp") = value - End Set - End Property - Private Property DTOCGV As DataTable - Get - Return CType(ViewState("DTOCGV"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTOCGV") = value - End Set - End Property - Private Property DtConsignaciones As DataTable - Get - Return CType(ViewState("DtConsignaciones"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtConsignaciones") = value - End Set - End Property - - 'Private Property DtCuentas As DataTable - ' Get - ' Return CType(ViewState("DtCuentas"), DataTable) - ' End Get - ' Set(value As DataTable) - ' ViewState("DtCuentas") = value - ' End Set - 'End Property - 'Private Property CargoFactura As Boolean - ' Get - ' Return CType(ViewState("CargoFactura"), Boolean) - ' End Get - ' Set(value As Boolean) - ' ViewState("CargoFactura") = value - ' End Set - 'End Property - Private Property tDTAcarreos As DataTable - Get - Return If(IsNothing(ViewState("tDTAcarreos")), Nothing, CType(ViewState("tDTAcarreos"), DataTable)) - End Get - Set(value As DataTable) - ViewState("tDTAcarreos") = value - End Set - End Property - Private Property DtDeudores As DataTable - Get - Return CType(ViewState("DtDeudores"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDeudores") = value - End Set - End Property - Private Property DtDeudoresDetalle As DataTable - Get - Return CType(ViewState("DtDeudoresDetalle"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDeudoresDetalle") = value - End Set - End Property - Private Property DtAcreedores As DataTable - Get - Return CType(ViewState("DtAcreedores"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtAcreedores") = value - End Set - End Property - Private Property DTUM As DataTable - Get - Return CType(ViewState("DTUM"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTUM") = value - End Set - End Property - Private Property TmpDTTiposAF As DataTable - Get - Return CType(ViewState("TmpDTTiposAF"), DataTable) - End Get - Set(value As DataTable) - ViewState("TmpDTTiposAF") = value - End Set - End Property - Private Property DtFacturas As DataTable - Get - Return CType(ViewState("DtFacturas"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtFacturas") = value - End Set - End Property - - Private Property DtServicios As DataTable - Get - Return CType(ViewState("DtServicios"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtServicios") = value - End Set - End Property - Private ReadOnly Property CveProveedor As Integer - Get - Return ViewState("CveProveedor").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveTipoProveedor As Integer - Get - Return ViewState("CveTipoProveedor").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedor As Integer - Get - Return ViewState("CtaProveedor").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedor As Integer - Get - Return ViewState("CveCuentaProveedor").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorDeudores As Integer - Get - Return ViewState("CtaProveedorDeudores").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorDeudores As Integer - Get - Return ViewState("CveCuentaProveedorDeudores").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorAcreedores As Integer - Get - Return ViewState("CveCuentaProveedorAcreedores").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorAcreedores As Integer - Get - Return ViewState("CtaProveedorAcreedores").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorAnticipos As Integer - Get - Return ViewState("CtaProveedorAnticipos").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorAnticipos As Integer - Get - Return ViewState("CveCuentaProveedorAnticipos").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorAnticiposExtranjera As Integer - Get - Return ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorAnticiposExtranjera As Integer - Get - Return ViewState("CveCuentaProveedorAnticiposExtranjera").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorAnticiposComplementaria As Integer - Get - Return ViewState("CtaProveedorAnticiposComplementaria").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorAnticiposComplementaria As Integer - Get - Return ViewState("CveCuentaProveedorAnticiposComplementaria").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property CtaProveedorRetIVA As Integer - Get - Return ViewState("CtaProveedorRetIVA").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorRetIVA As Integer - Get - Return ViewState("CveCuentaProveedorRetIVA").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property CtaProveedorRetISR As Integer - Get - Return ViewState("CtaProveedorRetISR").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorRetISR As Integer - Get - Return ViewState("CveCuentaProveedorRetISR").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property CveCuentaIEPS As Integer - Get - Return ViewState("CveCuentaIEPS").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorExtranjera As Integer - Get - Return ViewState("CtaProveedorExtranjera").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorExtranjera As Integer - Get - Return ViewState("CveCuentaProveedorExtranjera").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CtaProveedorComplementaria As Integer - Get - Return ViewState("CtaProveedorComplementaria").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaProveedorComplementaria As Integer - Get - Return ViewState("CveCuentaProveedorComplementaria").ToString.ToEntero - End Get - End Property - Private ReadOnly Property NombreProveedor As String - Get - Return ViewState("NombreProveedor").ToString - End Get - End Property - Private Property IdPoliza As Integer - Get - Return ViewState("IdPoliza").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdPoliza") = value - End Set - End Property - Private Property CveOrdenCorte As Integer - Get - Return ViewState("CveOrdenCorte").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveOrdenCorte") = value - End Set - End Property - Private Property CvePrePoliza As Integer - Get - Return ViewState("CvePrePoliza").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CvePrePoliza") = value - End Set - End Property - Private ReadOnly Property CveCompra As Integer - Get - Return ViewState("CveCompra").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveFactura As Integer - Get - Return ViewState("CveFactura").ToString.ToEntero - End Get - End Property - Private Property CveMovimientoAlmacen As Integer - Get - Return ViewState("CveMovimientoAlmacen").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMovimientoAlmacen") = value - End Set - End Property - Private Property CveConsignacion As Integer - Get - Return ViewState("CveConsignacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveConsignacion") = value - End Set - End Property - Private Property PermisoEdicionManual As Boolean - Get - Return CType(ViewState("PermisoEdicionManual"), Boolean) - End Get - Set(value As Boolean) - ViewState("PermisoEdicionManual") = value - End Set - End Property - - Private Property NuevaValidacionXML As Integer - Get - Return ViewState("NuevaValidacionXML").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("NuevaValidacionXML") = value - End Set - End Property - Private Property IdCuentaBancaria As Integer - Get - Return ViewState("IdCuentaBancaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCuentaBancaria") = value - End Set - End Property - Private Property CveCuentaBancaria As Integer - Get - Return ViewState("CveCuentaBancaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBancaria") = value - End Set - End Property - Private Property IdCuentaBancariaComplementaria As Integer - Get - Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCuentaBancariaComplementaria") = value - End Set - End Property - Private Property CveCuentaBancariaComplementaria As Integer - Get - Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBancariaComplementaria") = value - End Set - End Property - Private Property IvaAcumulado As Double - Get - Return ViewState("IvaAcumulado").ToString.ToDouble - End Get - Set(value As Double) - ViewState("IvaAcumulado") = value - End Set - End Property - - Private Property EsContado As Boolean - Get - Return CType(ViewState("EsContado"), Boolean) - End Get - Set(value As Boolean) - ViewState("EsContado") = value - End Set - End Property - - 'Private ReadOnly Property CompraFolio As String - ' Get - ' Return ViewState("CompraFolio").ToString - ' End Get - 'End Property - 'Private ReadOnly Property FolioFiscal As String - ' Get - ' Return ViewState("FolioFiscal").ToString - ' End Get - 'End Property - - 'Private ReadOnly Property IdCtaContProveedores As Integer - ' Get - ' Return ViewState("IdCtaContProveedores").ToString.ToEntero - ' End Get - 'End Property - 'Private ReadOnly Property IdCtaContAnticipos As Integer - ' Get - ' Return ViewState("IdCtaContAnticipos").ToString.ToEntero - ' End Get - 'End Property - 'Private ReadOnly Property IdCtaContRetIVA As Integer - ' Get - ' Return ViewState("IdCtaContRetIVA").ToString.ToEntero - ' End Get - 'End Property - 'Private ReadOnly Property IdCtaContRetISR As Integer - ' Get - ' Return ViewState("IdCtaContRetISR").ToString.ToEntero - ' End Get - 'End Property - - 'Private ReadOnly Property IVAPS As Double - ' Get - ' Return ViewState("IVAPS").ToString.ToDouble - ' End Get - 'End Property - 'Private ReadOnly Property RetIVA As Double - ' Get - ' Return ViewState("RetIVA").ToString.ToDouble - ' End Get - 'End Property - 'Private ReadOnly Property RetISR As Double - ' Get - ' Return ViewState("RetISR").ToString.ToDouble - ' End Get - 'End Property - 'Private ReadOnly Property IEPSPS As Double - ' Get - ' Return ViewState("IEPSPS").ToString.ToDouble - ' End Get - 'End Property - 'Private ReadOnly Property IEPSPSIVA As Double - ' Get - ' Return ViewState("IEPSPSIVA").ToString.ToDouble - ' End Get - 'End Property - Private Property TotalGeneral As Double - Get - Return ViewState("TotalGeneral").ToString.ToDouble - End Get - Set(value As Double) - ViewState("TotalGeneral") = value - End Set - End Property - - Private Property CompraSaldo As Double - Get - Return ViewState("CompraSaldo").ToString.ToDouble - End Get - Set(value As Double) - ViewState("CompraSaldo") = value - End Set - End Property - Private Property Saldo As Double - Get - Return ViewState("Saldo").ToString.ToDouble - End Get - Set(value As Double) - ViewState("Saldo") = value - End Set - End Property - - Private Property CveMoneda As Integer - Get - Return ViewState("CveMoneda").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMoneda") = value - End Set - End Property - Private Property CveAlmacenConsignacion As Integer - Get - Return ViewState("CveAlmacenConsignacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveAlmacenConsignacion") = value - End Set - End Property - - Private Property DtFuncionarios As DataTable - Get - Return CType(ViewState("DtFuncionarios"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtFuncionarios") = value - End Set - End Property - - Private Property DtDatosDetalle As DataTable - Get - Return CType(ViewState("DtDatosDetalle"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDatosDetalle") = value - End Set - End Property - Private Property CvePSSerieLote As Integer - Get - Return CType(ViewState("CvePSSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CvePSSerieLote") = value - End Set - End Property - Private Property CveUMSerieLote As Integer - Get - Return CType(ViewState("CveUMSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveUMSerieLote") = value - End Set - End Property - Private Property PUSerieLote As Decimal - Get - Return CType(ViewState("PUSerieLote"), Decimal) - End Get - Set(value As Decimal) - ViewState("PUSerieLote") = value - End Set - End Property - Private Property TotAcarreos As Double - Get - Return CType(ViewState("TotAcarreos"), Double) - End Get - Set(value As Double) - ViewState("TotAcarreos") = value - End Set - End Property - - 'Private ReadOnly Property Ruta As String - ' Get - ' Return AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" - ' End Get - 'End Property - - - Public Class Anticipos - Public Property TipoMovto As String - Public Property CveIE As Integer - Public Property Importe As Decimal - Public Property TCCompra As Decimal - - Public Property CvePersonal As Integer - Public Property CveCompra As Integer - Public Property CvePrePoliza As Integer - End Class - Private Property ArrAnticipos As ArrayList - Get - Return CType(ViewState("ArrAnticipos"), ArrayList) - End Get - Set(value As ArrayList) - ViewState("ArrAnticipos") = value - End Set - End Property - Private Property ArrIE As ArrayList - Get - Return CType(ViewState("ArrIE"), ArrayList) - End Get - Set(value As ArrayList) - ViewState("ArrIE") = value - End Set - End Property - Private Property ArrIEFuncionariosEmpleados As ArrayList - Get - Return CType(ViewState("ArrIEFuncionariosEmpleados"), ArrayList) - End Get - Set(value As ArrayList) - ViewState("ArrIEFuncionariosEmpleados") = value - End Set - End Property - 'Inventarios - Private Property DtInv As DataTable - Get - Return CType(ViewState("DtInv"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtInv") = value - End Set - End Property - - Private Property DtAC As DataTable - Get - DtAC = DirectCast(ViewState("DtAC"), DataTable) - End Get - - Set(ByVal value As DataTable) - ViewState("DtAC") = value - End Set - End Property - - 'Caja Chica, Funcionario/Empleado - Private ReadOnly Property CveCajaChica As Integer - Get - Return ViewState("CveCajaChica").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CvePersonal As Integer - Get - Return ViewState("CvePersonal").ToString.ToEntero - End Get - End Property - Private Property OCsVinculadas As String - Get - Return ViewState("OCsVinculadas").ToString - End Get - Set(value As String) - ViewState("OCsVinculadas") = value - End Set - End Property - - Private Property DdlOC As DropDownList - Get - Return CType(ViewState("OCsVinculadas"), DropDownList) - End Get - Set(value As DropDownList) - ViewState("OCsVinculadas") = value - End Set - End Property - - Private Property TieneOC As Boolean - Get - Return CType(ViewState("TieneOC"), Boolean) - End Get - Set(value As Boolean) - ViewState("TieneOC") = value - End Set - End Property - Private Property OCVinculada As Boolean - Get - Return CType(ViewState("OCVinculada"), Boolean) - End Get - Set(value As Boolean) - ViewState("OCVinculada") = value - End Set - End Property - Private Property CierrePeriodo As Boolean - Get - Return CType(ViewState("CierrePeriodo"), Boolean) - End Get - Set(value As Boolean) - ViewState("CierrePeriodo") = value - End Set - End Property - Private Property NCDevolucion As Boolean - Get - Return CType(ViewState("NCDevolucion"), Boolean) - End Get - Set(value As Boolean) - ViewState("NCDevolucion") = value - End Set - End Property - Private Property CompraCargada As Boolean - Get - Return CType(ViewState("CompraCargada"), Boolean) - End Get - Set(value As Boolean) - ViewState("CompraCargada") = value - End Set - End Property - Private Property ModalidadUMAlias As Integer - Get - Return ViewState("EjercicioAC").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("EjercicioAC") = value - End Set - End Property - - Private Property CveConceptoContableAlmacen As Integer - Get - Return ViewState("CveConceptoContableAlmacen").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveConceptoContableAlmacen") = value - End Set - End Property - Private Property EsNoDeducible As Boolean - Get - Return CType(ViewState("EsNoDeducible"), Boolean) - End Get - Set(value As Boolean) - ViewState("EsNoDeducible") = value - End Set + Private Property CveUsuarioEvaluador() As Integer + Get + Return If(IsNothing(ViewState("CveUsuarioEvaluador")), -1, CInt(ViewState("CveUsuarioEvaluador"))) + End Get + Set + ViewState("CveUsuarioEvaluador") = Value + End Set End Property -#End Region - -#Region "PROPIEDADES - AC NEW" - Private Property DtPresupuestos As DataTable - Get - Return CType(ViewState("DtPresupuestos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtPresupuestos") = value - End Set - End Property - Private Property EjercicioAC As Integer - Get - Return ViewState("EjercicioAC").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("EjercicioAC") = value - End Set + Private Property TmpDT As DataTable + Get + Return CType(ViewState("TmpDT"), DataTable) + End Get + Set(value As DataTable) + ViewState("TmpDT") = value + End Set End Property -#End Region - -#Region " PROPIEDADES REFACTURACION " - Private Property DtRefacturacion As DataTable - Get - Return CType(ViewState("DtRefacturacion"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtRefacturacion") = value - End Set - End Property - Private Property CveCompraRefacturacion As Integer - Get - Return ViewState("CveCompraRefacturacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCompraRefacturacion") = value - End Set - End Property - Private Property EmpresaPrueba As Boolean - Get - Return CBool(ViewState("EmpresaPrueba")) - End Get - Set(value As Boolean) - ViewState("EmpresaPrueba") = value - End Set - End Property - Private Property StringProrrateo As String - Get - Return ViewState("StringProrrateo").ToString - End Get - Set(value As String) - ViewState("StringProrrateo") = value - End Set - End Property - Private Property ClavesBorradas As ArrayList - Get - Return CType(ViewState("ClavesBorradas"), ArrayList) - End Get - Set(value As ArrayList) - ViewState("ClavesBorradas") = value - End Set + Private Property TmpDTOriginal As DataTable + Get + Return CType(ViewState("TmpDTOriginal"), DataTable) + End Get + Set(value As DataTable) + ViewState("TmpDTOriginal") = value + End Set + End Property + Private Property TmpCXP As DataTable + Get + Return CType(ViewState("TmpCXP"), DataTable) + End Get + Set(value As DataTable) + ViewState("TmpCXP") = value + End Set End Property -#End Region - -#Region " PROPIEDADES OC " - Private Property TipoCambioOC As Decimal - Get - Return ViewState("TipoCambioOC").ToString.ToDecimal - End Get - Set(value As Decimal) - ViewState("TipoCambioOC") = value - End Set - End Property - Private Property PopUpOC As Boolean - Get - Return CBool(ViewState("PopUpOC")) - End Get - Set(value As Boolean) - ViewState("PopUpOC") = value - End Set + 'Private Property PSDTRemplazo As DataTable + ' Get + ' Return CType(ViewState("PSDTRemplazo"), DataTable) + ' End Get + ' Set(value As DataTable) + ' ViewState("PSDTRemplazo") = value + ' End Set + 'End Property + Private Property DtCheques As DataTable + Get + Return CType(ViewState("DtCheques"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCheques") = value + End Set End Property -#End Region -#Region "PROPIEDADES ALMACEN" 'Charlie - Private Property TotalAlmacen As Decimal - Get - Return ViewState("TotalAlmacen").ToString.ToDecimal - End Get - Set(value As Decimal) - ViewState("TotalAlmacen") = value - End Set - End Property - - Private Property TotalFlete As Decimal - Get - Return ViewState("TotalFlete").ToString.ToDecimal - End Get - Set(value As Decimal) - ViewState("TotalFlete") = value - End Set + Private Property Modalidad As String + Get + Return ViewState("Modalidad").ToString + End Get + Set(value As String) + ViewState("Modalidad") = value + End Set End Property -#End Region -#Region "Propiedades" + Public Property IdVale As List(Of Integer) + Get + IdVale = DirectCast(ViewState("IdVale"), List(Of Integer)) + End Get + + Set(ByVal value As List(Of Integer)) + ViewState("IdVale") = value + End Set + End Property + Public Property ListaDocumentos As List(Of String) + Get + ListaDocumentos = DirectCast(ViewState("ListaDocumentos"), List(Of String)) + End Get + Set(ByVal value As List(Of String)) + ViewState("ListaDocumentos") = value + End Set + End Property + + Public Property TieneAnticiposXML As Boolean + Get + TieneAnticiposXML = DirectCast(ViewState("TieneAnticiposXML"), Boolean) + End Get + Set(ByVal value As Boolean) + ViewState("TieneAnticiposXML") = value + End Set + End Property + + Private Property DTOCTemp As DataTable + Get + Return CType(ViewState("DTOCTemp"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTOCTemp") = value + End Set + End Property + Private Property DTOCGV As DataTable + Get + Return CType(ViewState("DTOCGV"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTOCGV") = value + End Set + End Property + Private Property DtConsignaciones As DataTable + Get + Return CType(ViewState("DtConsignaciones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtConsignaciones") = value + End Set + End Property + + 'Private Property DtCuentas As DataTable + ' Get + ' Return CType(ViewState("DtCuentas"), DataTable) + ' End Get + ' Set(value As DataTable) + ' ViewState("DtCuentas") = value + ' End Set + 'End Property + 'Private Property CargoFactura As Boolean + ' Get + ' Return CType(ViewState("CargoFactura"), Boolean) + ' End Get + ' Set(value As Boolean) + ' ViewState("CargoFactura") = value + ' End Set + 'End Property + Private Property tDTAcarreos As DataTable + Get + Return If(IsNothing(ViewState("tDTAcarreos")), Nothing, CType(ViewState("tDTAcarreos"), DataTable)) + End Get + Set(value As DataTable) + ViewState("tDTAcarreos") = value + End Set + End Property + Private Property DtDeudores As DataTable + Get + Return CType(ViewState("DtDeudores"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDeudores") = value + End Set + End Property + Private Property DtDeudoresDetalle As DataTable + Get + Return CType(ViewState("DtDeudoresDetalle"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDeudoresDetalle") = value + End Set + End Property + Private Property DtAcreedores As DataTable + Get + Return CType(ViewState("DtAcreedores"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtAcreedores") = value + End Set + End Property + Private Property DTUM As DataTable + Get + Return CType(ViewState("DTUM"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTUM") = value + End Set + End Property + Private Property TmpDTTiposAF As DataTable + Get + Return CType(ViewState("TmpDTTiposAF"), DataTable) + End Get + Set(value As DataTable) + ViewState("TmpDTTiposAF") = value + End Set + End Property + Private Property DtFacturas As DataTable + Get + Return CType(ViewState("DtFacturas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtFacturas") = value + End Set + End Property + + Private Property DtServicios As DataTable + Get + Return CType(ViewState("DtServicios"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtServicios") = value + End Set + End Property + Private ReadOnly Property CveProveedor As Integer + Get + Return ViewState("CveProveedor").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveTipoProveedor As Integer + Get + Return ViewState("CveTipoProveedor").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedor As Integer + Get + Return ViewState("CtaProveedor").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedor As Integer + Get + Return ViewState("CveCuentaProveedor").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorDeudores As Integer + Get + Return ViewState("CtaProveedorDeudores").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorDeudores As Integer + Get + Return ViewState("CveCuentaProveedorDeudores").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorAcreedores As Integer + Get + Return ViewState("CveCuentaProveedorAcreedores").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorAcreedores As Integer + Get + Return ViewState("CtaProveedorAcreedores").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorAnticipos As Integer + Get + Return ViewState("CtaProveedorAnticipos").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorAnticipos As Integer + Get + Return ViewState("CveCuentaProveedorAnticipos").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorAnticiposExtranjera As Integer + Get + Return ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorAnticiposExtranjera As Integer + Get + Return ViewState("CveCuentaProveedorAnticiposExtranjera").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorAnticiposComplementaria As Integer + Get + Return ViewState("CtaProveedorAnticiposComplementaria").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorAnticiposComplementaria As Integer + Get + Return ViewState("CveCuentaProveedorAnticiposComplementaria").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property CtaProveedorRetIVA As Integer + Get + Return ViewState("CtaProveedorRetIVA").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorRetIVA As Integer + Get + Return ViewState("CveCuentaProveedorRetIVA").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property CtaProveedorRetISR As Integer + Get + Return ViewState("CtaProveedorRetISR").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorRetISR As Integer + Get + Return ViewState("CveCuentaProveedorRetISR").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property CveCuentaIEPS As Integer + Get + Return ViewState("CveCuentaIEPS").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorExtranjera As Integer + Get + Return ViewState("CtaProveedorExtranjera").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorExtranjera As Integer + Get + Return ViewState("CveCuentaProveedorExtranjera").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CtaProveedorComplementaria As Integer + Get + Return ViewState("CtaProveedorComplementaria").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaProveedorComplementaria As Integer + Get + Return ViewState("CveCuentaProveedorComplementaria").ToString.ToEntero + End Get + End Property + Private ReadOnly Property NombreProveedor As String + Get + Return ViewState("NombreProveedor").ToString + End Get + End Property + Private Property IdPoliza As Integer + Get + Return ViewState("IdPoliza").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdPoliza") = value + End Set + End Property + Private Property CveOrdenCorte As Integer + Get + Return ViewState("CveOrdenCorte").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveOrdenCorte") = value + End Set + End Property + Private Property CvePrePoliza As Integer + Get + Return ViewState("CvePrePoliza").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CvePrePoliza") = value + End Set + End Property + Private ReadOnly Property CveCompra As Integer + Get + Return ViewState("CveCompra").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveFactura As Integer + Get + Return ViewState("CveFactura").ToString.ToEntero + End Get + End Property + Private Property CveMovimientoAlmacen As Integer + Get + Return ViewState("CveMovimientoAlmacen").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMovimientoAlmacen") = value + End Set + End Property + Private Property CveConsignacion As Integer + Get + Return ViewState("CveConsignacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveConsignacion") = value + End Set + End Property + Private Property PermisoEdicionManual As Boolean + Get + Return CType(ViewState("PermisoEdicionManual"), Boolean) + End Get + Set(value As Boolean) + ViewState("PermisoEdicionManual") = value + End Set + End Property + + Private Property NuevaValidacionXML As Integer + Get + Return ViewState("NuevaValidacionXML").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("NuevaValidacionXML") = value + End Set + End Property + Private Property IdCuentaBancaria As Integer + Get + Return ViewState("IdCuentaBancaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaBancaria") = value + End Set + End Property + Private Property CveCuentaBancaria As Integer + Get + Return ViewState("CveCuentaBancaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBancaria") = value + End Set + End Property + Private Property IdCuentaBancariaComplementaria As Integer + Get + Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaBancariaComplementaria") = value + End Set + End Property + Private Property CveCuentaBancariaComplementaria As Integer + Get + Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBancariaComplementaria") = value + End Set + End Property + Private Property IvaAcumulado As Double + Get + Return ViewState("IvaAcumulado").ToString.ToDouble + End Get + Set(value As Double) + ViewState("IvaAcumulado") = value + End Set + End Property + + Private Property EsContado As Boolean + Get + Return CType(ViewState("EsContado"), Boolean) + End Get + Set(value As Boolean) + ViewState("EsContado") = value + End Set + End Property + + 'Private ReadOnly Property CompraFolio As String + ' Get + ' Return ViewState("CompraFolio").ToString + ' End Get + 'End Property + 'Private ReadOnly Property FolioFiscal As String + ' Get + ' Return ViewState("FolioFiscal").ToString + ' End Get + 'End Property + + 'Private ReadOnly Property IdCtaContProveedores As Integer + ' Get + ' Return ViewState("IdCtaContProveedores").ToString.ToEntero + ' End Get + 'End Property + 'Private ReadOnly Property IdCtaContAnticipos As Integer + ' Get + ' Return ViewState("IdCtaContAnticipos").ToString.ToEntero + ' End Get + 'End Property + 'Private ReadOnly Property IdCtaContRetIVA As Integer + ' Get + ' Return ViewState("IdCtaContRetIVA").ToString.ToEntero + ' End Get + 'End Property + 'Private ReadOnly Property IdCtaContRetISR As Integer + ' Get + ' Return ViewState("IdCtaContRetISR").ToString.ToEntero + ' End Get + 'End Property + + 'Private ReadOnly Property IVAPS As Double + ' Get + ' Return ViewState("IVAPS").ToString.ToDouble + ' End Get + 'End Property + 'Private ReadOnly Property RetIVA As Double + ' Get + ' Return ViewState("RetIVA").ToString.ToDouble + ' End Get + 'End Property + 'Private ReadOnly Property RetISR As Double + ' Get + ' Return ViewState("RetISR").ToString.ToDouble + ' End Get + 'End Property + 'Private ReadOnly Property IEPSPS As Double + ' Get + ' Return ViewState("IEPSPS").ToString.ToDouble + ' End Get + 'End Property + 'Private ReadOnly Property IEPSPSIVA As Double + ' Get + ' Return ViewState("IEPSPSIVA").ToString.ToDouble + ' End Get + 'End Property + Private Property TotalGeneral As Double + Get + Return ViewState("TotalGeneral").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalGeneral") = value + End Set + End Property + + Private Property CompraSaldo As Double + Get + Return ViewState("CompraSaldo").ToString.ToDouble + End Get + Set(value As Double) + ViewState("CompraSaldo") = value + End Set + End Property + Private Property Saldo As Double + Get + Return ViewState("Saldo").ToString.ToDouble + End Get + Set(value As Double) + ViewState("Saldo") = value + End Set + End Property + + Private Property CveMoneda As Integer + Get + Return ViewState("CveMoneda").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMoneda") = value + End Set + End Property + Private Property CveAlmacenConsignacion As Integer + Get + Return ViewState("CveAlmacenConsignacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveAlmacenConsignacion") = value + End Set + End Property + + Private Property DtFuncionarios As DataTable + Get + Return CType(ViewState("DtFuncionarios"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtFuncionarios") = value + End Set + End Property + + Private Property DtDatosDetalle As DataTable + Get + Return CType(ViewState("DtDatosDetalle"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDatosDetalle") = value + End Set + End Property + Private Property CvePSSerieLote As Integer + Get + Return CType(ViewState("CvePSSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CvePSSerieLote") = value + End Set + End Property + Private Property CveUMSerieLote As Integer + Get + Return CType(ViewState("CveUMSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CveUMSerieLote") = value + End Set + End Property + Private Property PUSerieLote As Decimal + Get + Return CType(ViewState("PUSerieLote"), Decimal) + End Get + Set(value As Decimal) + ViewState("PUSerieLote") = value + End Set + End Property + Private Property TotAcarreos As Double + Get + Return CType(ViewState("TotAcarreos"), Double) + End Get + Set(value As Double) + ViewState("TotAcarreos") = value + End Set + End Property + + 'Private ReadOnly Property Ruta As String + ' Get + ' Return AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" + ' End Get + 'End Property + + + Public Class Anticipos + Public Property TipoMovto As String + Public Property CveIE As Integer + Public Property Importe As Decimal + Public Property TCCompra As Decimal + + Public Property CvePersonal As Integer + Public Property CveCompra As Integer + Public Property CvePrePoliza As Integer + End Class + Private Property ArrAnticipos As ArrayList + Get + Return CType(ViewState("ArrAnticipos"), ArrayList) + End Get + Set(value As ArrayList) + ViewState("ArrAnticipos") = value + End Set + End Property + Private Property ArrIE As ArrayList + Get + Return CType(ViewState("ArrIE"), ArrayList) + End Get + Set(value As ArrayList) + ViewState("ArrIE") = value + End Set + End Property + Private Property ArrIEFuncionariosEmpleados As ArrayList + Get + Return CType(ViewState("ArrIEFuncionariosEmpleados"), ArrayList) + End Get + Set(value As ArrayList) + ViewState("ArrIEFuncionariosEmpleados") = value + End Set + End Property + 'Inventarios + Private Property DtInv As DataTable + Get + Return CType(ViewState("DtInv"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtInv") = value + End Set + End Property + + Private Property DtAC As DataTable + Get + DtAC = DirectCast(ViewState("DtAC"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtAC") = value + End Set + End Property + + 'Caja Chica, Funcionario/Empleado + Private ReadOnly Property CveCajaChica As Integer + Get + Return ViewState("CveCajaChica").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CvePersonal As Integer + Get + Return ViewState("CvePersonal").ToString.ToEntero + End Get + End Property + Private Property OCsVinculadas As String + Get + Return ViewState("OCsVinculadas").ToString + End Get + Set(value As String) + ViewState("OCsVinculadas") = value + End Set + End Property + + Private Property DdlOC As DropDownList + Get + Return CType(ViewState("OCsVinculadas"), DropDownList) + End Get + Set(value As DropDownList) + ViewState("OCsVinculadas") = value + End Set + End Property + + Private Property TieneOC As Boolean + Get + Return CType(ViewState("TieneOC"), Boolean) + End Get + Set(value As Boolean) + ViewState("TieneOC") = value + End Set + End Property + Private Property OCVinculada As Boolean + Get + Return CType(ViewState("OCVinculada"), Boolean) + End Get + Set(value As Boolean) + ViewState("OCVinculada") = value + End Set + End Property + Private Property CierrePeriodo As Boolean + Get + Return CType(ViewState("CierrePeriodo"), Boolean) + End Get + Set(value As Boolean) + ViewState("CierrePeriodo") = value + End Set + End Property + Private Property NCDevolucion As Boolean + Get + Return CType(ViewState("NCDevolucion"), Boolean) + End Get + Set(value As Boolean) + ViewState("NCDevolucion") = value + End Set + End Property + Private Property CompraCargada As Boolean + Get + Return CType(ViewState("CompraCargada"), Boolean) + End Get + Set(value As Boolean) + ViewState("CompraCargada") = value + End Set + End Property + Private Property ModalidadUMAlias As Integer + Get + Return ViewState("EjercicioAC").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("EjercicioAC") = value + End Set + End Property + + Private Property CveConceptoContableAlmacen As Integer + Get + Return ViewState("CveConceptoContableAlmacen").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveConceptoContableAlmacen") = value + End Set + End Property + Private Property EsNoDeducible As Boolean + Get + Return CType(ViewState("EsNoDeducible"), Boolean) + End Get + Set(value As Boolean) + ViewState("EsNoDeducible") = value + End Set + End Property +#End Region + +#Region "PROPIEDADES - AC NEW" + Private Property DtPresupuestos As DataTable + Get + Return CType(ViewState("DtPresupuestos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtPresupuestos") = value + End Set + End Property + Private Property EjercicioAC As Integer + Get + Return ViewState("EjercicioAC").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("EjercicioAC") = value + End Set + End Property +#End Region + +#Region " PROPIEDADES REFACTURACION " + Private Property DtRefacturacion As DataTable + Get + Return CType(ViewState("DtRefacturacion"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtRefacturacion") = value + End Set + End Property + Private Property CveCompraRefacturacion As Integer + Get + Return ViewState("CveCompraRefacturacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCompraRefacturacion") = value + End Set + End Property + Private Property EmpresaPrueba As Boolean + Get + Return CBool(ViewState("EmpresaPrueba")) + End Get + Set(value As Boolean) + ViewState("EmpresaPrueba") = value + End Set + End Property + Private Property StringProrrateo As String + Get + Return ViewState("StringProrrateo").ToString + End Get + Set(value As String) + ViewState("StringProrrateo") = value + End Set + End Property + Private Property ClavesBorradas As ArrayList + Get + Return CType(ViewState("ClavesBorradas"), ArrayList) + End Get + Set(value As ArrayList) + ViewState("ClavesBorradas") = value + End Set + End Property + +#End Region + +#Region " PROPIEDADES OC " + Private Property TipoCambioOC As Decimal + Get + Return ViewState("TipoCambioOC").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("TipoCambioOC") = value + End Set + End Property + Private Property PopUpOC As Boolean + Get + Return CBool(ViewState("PopUpOC")) + End Get + Set(value As Boolean) + ViewState("PopUpOC") = value + End Set + End Property +#End Region + +#Region "PROPIEDADES ALMACEN" 'Charlie + Private Property TotalAlmacen As Decimal + Get + Return ViewState("TotalAlmacen").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("TotalAlmacen") = value + End Set + End Property + + Private Property TotalFlete As Decimal + Get + Return ViewState("TotalFlete").ToString.ToDecimal + End Get + Set(value As Decimal) + ViewState("TotalFlete") = value + End Set + End Property +#End Region + +#Region "Propiedades" 'CFDi - Private Property Serie As String - Private Property Folio As String - Private Property Fecha As String - Private Property SubTotal As Decimal + Private Property Serie As String + Private Property Folio As String + Private Property Fecha As String + Private Property SubTotal As Decimal Private Property Total As Decimal = 0 - Private Property Descuentos As Decimal = 0 - Private Property Amortizaciones As Decimal = 0 - Private Property EmisorRFC As String - Private Property ReceptorRFC As String - Private Property TrasladoIVA As Decimal = 0 - Private Property RetencionIVA As Decimal = 0 - Private Property RetencionISR As Decimal = 0 - Private Property TrasladoIEPS As Decimal = 0 - Private Property TFDUUID As String = "" - Private Property Moneda As String = "" - Private Property TipoComprobante As String = "" - Private Property MetodoPago As String = "" - Private Property CveMetodoPago As Integer - Get - Return ViewState("CveMetodoPago").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMetodoPago") = value - End Set - End Property - Private Property TipoCambio As Double - Get - Return ViewState("TipoCambio").ToString.ToDouble - End Get - Set(value As Double) - ViewState("TipoCambio") = value - End Set - End Property - 'Private Property TipoCambio As Double = 0 - Private Property OtrosImpuestos As Decimal = 0 - Private Property OtrosImpuestosRetenciones As Decimal = 0 - Private Property TotalRetenciones As Decimal = 0 - Private Property SumaTotalRetenciones As Decimal = 0 - Private Property TotalTraslados As Decimal = 0 - Private Property SumaTotalTraslados As Decimal = 0 - Private Property SubTotalConceptos As Decimal = 0 - Private Property Redondeo As Decimal = 0 - Private Property IEPSGasto As Boolean = False - Private Property OtrosImpuestosGasto As Boolean = False - - Private Property Version As String - Get - Return ViewState("Version").ToString - End Get - Set(value As String) - ViewState("Version") = value - End Set - End Property - Private Property Index As Integer - Get - Return ViewState("Index").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("Index") = value - End Set - End Property - - Private Property Con As Integer - Get - Return ViewState("Con").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("Con") = value - End Set - End Property - - Private Property IvaTotalGv As Double - Get - Return DirectCast(ViewState("IvaTotalGv"), Double) - End Get - Set(value As Double) - ViewState("IvaTotalGv") = value - End Set - End Property - - Private Property SerieVieja As String - Get - Return DirectCast(ViewState("SerieVieja"), String) - End Get - Set(value As String) - ViewState("SerieVieja") = value - End Set - End Property - - Private Property EstatusAlmacen As Integer - Get - Return ViewState("EstatusAlmacen").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("EstatusAlmacen") = value - End Set - End Property - - Private Property DtTemporalGuardados As DataTable - Get - Return CType(ViewState("DtTemporalGuardados"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtTemporalGuardados") = value - End Set - End Property - - Private Property RFCProv As String - Get - Return IfNull(ViewState("RFCProv"), "").ToString - End Get - Set(value As String) - ViewState("RFCProv") = value - End Set - End Property - - Private Property CveImportacion As Integer - Get - Return IfNull(ViewState("CveImportacion"), -1).ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveImportacion") = value - End Set - End Property - Private Property CveFlete As Integer - Get - Return IfNull(ViewState("CveFlete"), -1).ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveFlete") = value - End Set - End Property - Private Property FleteImportacionOpcion As Integer - Get - Return IfNull(ViewState("FleteImportacionOpcion"), -1).ToString.ToEntero - End Get - Set(value As Integer) - ViewState("FleteImportacionOpcion") = value - End Set + Private Property Descuentos As Decimal = 0 + Private Property Amortizaciones As Decimal = 0 + Private Property EmisorRFC As String + Private Property ReceptorRFC As String + Private Property TrasladoIVA As Decimal = 0 + Private Property RetencionIVA As Decimal = 0 + Private Property RetencionISR As Decimal = 0 + Private Property TrasladoIEPS As Decimal = 0 + Private Property TFDUUID As String = "" + Private Property Moneda As String = "" + Private Property TipoComprobante As String = "" + Private Property MetodoPago As String = "" + Private Property CveMetodoPago As Integer + Get + Return ViewState("CveMetodoPago").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMetodoPago") = value + End Set + End Property + Private Property TipoCambio As Double + Get + Return ViewState("TipoCambio").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TipoCambio") = value + End Set + End Property + 'Private Property TipoCambio As Double = 0 + Private Property OtrosImpuestos As Decimal = 0 + Private Property OtrosImpuestosRetenciones As Decimal = 0 + Private Property TotalRetenciones As Decimal = 0 + Private Property SumaTotalRetenciones As Decimal = 0 + Private Property TotalTraslados As Decimal = 0 + Private Property SumaTotalTraslados As Decimal = 0 + Private Property SubTotalConceptos As Decimal = 0 + Private Property Redondeo As Decimal = 0 + Private Property IEPSGasto As Boolean = False + Private Property OtrosImpuestosGasto As Boolean = False + + Private Property Version As String + Get + Return ViewState("Version").ToString + End Get + Set(value As String) + ViewState("Version") = value + End Set + End Property + Private Property Index As Integer + Get + Return ViewState("Index").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("Index") = value + End Set End Property -#End Region - -#Region " PROPIEDADES DE TOTALES " - Private Property SubTotalOriginal As Double - Get - Return ViewState("SubTotalOriginal").ToString.ToDouble - End Get - Set(value As Double) - ViewState("SubTotalOriginal") = value - End Set - End Property - Private Property SubTotal2Original As Double - Get - Return ViewState("SubTotal2Original").ToString.ToDouble - End Get - Set(value As Double) - ViewState("SubTotal2Original") = value - End Set + Private Property Con As Integer + Get + Return ViewState("Con").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("Con") = value + End Set End Property - Private Property IVAOriginal As Double + Private Property IvaTotalGv As Double + Get + Return DirectCast(ViewState("IvaTotalGv"), Double) + End Get + Set(value As Double) + ViewState("IvaTotalGv") = value + End Set + End Property + + Private Property SerieVieja As String + Get + Return DirectCast(ViewState("SerieVieja"), String) + End Get + Set(value As String) + ViewState("SerieVieja") = value + End Set + End Property + + Private Property EstatusAlmacen As Integer + Get + Return ViewState("EstatusAlmacen").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("EstatusAlmacen") = value + End Set + End Property + + Private Property DtTemporalGuardados As DataTable + Get + Return CType(ViewState("DtTemporalGuardados"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtTemporalGuardados") = value + End Set + End Property + + Private Property RFCProv As String + Get + Return IfNull(ViewState("RFCProv"), "").ToString + End Get + Set(value As String) + ViewState("RFCProv") = value + End Set + End Property + + Private Property CveImportacion As Integer + Get + Return IfNull(ViewState("CveImportacion"), -1).ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveImportacion") = value + End Set + End Property + Private Property CveFlete As Integer + Get + Return IfNull(ViewState("CveFlete"), -1).ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveFlete") = value + End Set + End Property + Private Property FleteImportacionOpcion As Integer + Get + Return IfNull(ViewState("FleteImportacionOpcion"), -1).ToString.ToEntero + End Get + Set(value As Integer) + ViewState("FleteImportacionOpcion") = value + End Set + End Property + +#End Region + +#Region " PROPIEDADES DE TOTALES " + Private Property SubTotalOriginal As Double + Get + Return ViewState("SubTotalOriginal").ToString.ToDouble + End Get + Set(value As Double) + ViewState("SubTotalOriginal") = value + End Set + End Property + Private Property SubTotal2Original As Double + Get + Return ViewState("SubTotal2Original").ToString.ToDouble + End Get + Set(value As Double) + ViewState("SubTotal2Original") = value + End Set + End Property + + Private Property IVAOriginal As Double Get - If ViewState("IVAOriginal") Is Nothing Then - Return 0 - Else - Return ViewState("IVAOriginal").ToString.ToDouble + If ViewState("IVAOriginal") Is Nothing Then + Return 0 + Else + Return ViewState("IVAOriginal").ToString.ToDouble End If - End Get - Set(value As Double) - ViewState("IVAOriginal") = value - End Set - End Property - Private Property RetIVAOriginal As Double - Get - Return ViewState("RetIVAOriginal").ToString.ToDouble - End Get - Set(value As Double) - ViewState("RetIVAOriginal") = value - End Set - End Property - Private Property RetISROriginal As Double - Get - Return ViewState("RetISROriginal").ToString.ToDouble - End Get - Set(value As Double) - ViewState("RetISROriginal") = value - End Set + End Get + Set(value As Double) + ViewState("IVAOriginal") = value + End Set + End Property + Private Property RetIVAOriginal As Double + Get + Return ViewState("RetIVAOriginal").ToString.ToDouble + End Get + Set(value As Double) + ViewState("RetIVAOriginal") = value + End Set + End Property + Private Property RetISROriginal As Double + Get + Return ViewState("RetISROriginal").ToString.ToDouble + End Get + Set(value As Double) + ViewState("RetISROriginal") = value + End Set End Property - Private Property TotalOriginal As Double - Get + Private Property TotalOriginal As Double + Get If ViewState("TotalOriginal") Is Nothing Then Return 0 Else Return ViewState("TotalOriginal").ToString.ToDouble End If - End Get - Set(value As Double) - ViewState("TotalOriginal") = value - End Set - End Property - - Private Property ActualizaTotales As Boolean - Get - Return CBool(ViewState("ActualizaTotales")) - End Get - Set(value As Boolean) - ViewState("ActualizaTotales") = value - End Set + End Get + Set(value As Double) + ViewState("TotalOriginal") = value + End Set End Property -#End Region + Private Property ActualizaTotales As Boolean + Get + Return CBool(ViewState("ActualizaTotales")) + End Get + Set(value As Boolean) + ViewState("ActualizaTotales") = value + End Set + End Property - Dim DTConceptos As DataTable - Private Property EmpresasOC As List(Of Integer) - Get - EmpresasOC = DirectCast(ViewState("EmpresasOC"), List(Of Integer)) - End Get - Set(ByVal value As List(Of Integer)) - ViewState("EmpresasOC") = value - End Set - End Property - - Private Property DtPendientesAlmacen As DataTable - Get - DtPendientesAlmacen = DirectCast(ViewState("DtPendientesAlmacen"), DataTable) - End Get - - Set(ByVal value As DataTable) - ViewState("DtPendientesAlmacen") = value - End Set - End Property - - Private Property CveTipoConcepto As Integer - Get - Return ViewState("CveTipoConcepto").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveTipoConcepto") = value - End Set - End Property - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - 'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip") - 'ImgBtnBuscarOC.Attributes.Add("data-placement", "top") - CargaDatosAgregarPS() +#End Region + + Dim DTConceptos As DataTable + Private Property EmpresasOC As List(Of Integer) + Get + EmpresasOC = DirectCast(ViewState("EmpresasOC"), List(Of Integer)) + End Get + Set(ByVal value As List(Of Integer)) + ViewState("EmpresasOC") = value + End Set + End Property + + Private Property DtPendientesAlmacen As DataTable + Get + DtPendientesAlmacen = DirectCast(ViewState("DtPendientesAlmacen"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtPendientesAlmacen") = value + End Set + End Property + + Private Property CveTipoConcepto As Integer + Get + Return ViewState("CveTipoConcepto").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveTipoConcepto") = value + End Set + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + 'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip") + 'ImgBtnBuscarOC.Attributes.Add("data-placement", "top") + CargaDatosAgregarPS() TieneAnticiposXML = False - Modalidad = "" - Version = "" - CveMetodoPago = -1 - RFCProv = "" - CargaDdlTipoGasto() - CreaTmpAcarreos() - EsContado = False - CierrePeriodo = False - NCDevolucion = False - CompraCargada = False - Saldo = 0 - SubTotalOriginal = 0 - CveConceptoContableAlmacen = 0 - EsNoDeducible = False - CveTipoConcepto = 1 - '******** Prorrateo ******************************************** - If UsuarioActual.Empresa.Funcionalidad(117) <> "" Then - btnProrateo.Visible = True - End If - - If UsuarioActual.Empresa.Funcionalidad(303) <> "" Then - btnProrateo2.Visible = True - End If - '**************************************************************** - 'If UsuarioActual.CveEmpresa = 72 Then - ' LiRecepcion.Visible = True - ' DdlRecepcion.SelectedValue = "2" - 'End If - - TipoCambio = 1 - IvaAcumulado = 0 - TotalAlmacen = 0 - TotalFlete = 0 - CveOrdenCorte = -1 - - 'VALIDACION DE XML - NuevaValidacionXML = IfNull(Request("NuevaValidacionXML"), 0).ToString.ToEntero - - - IdVale = New List(Of Integer) - - ListaDocumentos = New List(Of String) - - 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then 'Esquema nuevo PrePolizas - If Not UsuarioActual.Empresa.UsaAC Then - EmpresaPrueba = True - TotalGeneral = 0 - CompraSaldo = 0 - ViewState("CvePersonal") = -1 - IdCuentaBancaria = 0 - CveCuentaBancaria = 0 - End If - - IdCuentaBancariaComplementaria = 0 - CveCuentaBancariaComplementaria = 0 - - 'If UsuarioActual.TienePermisoProceso(259) Then - DivEsNoDeducible.Visible = True - 'End If - - If UsuarioActual.Empresa.Funcionalidad(125) = "1" Then 'Seleccionar a quien se abona la Prepoliza - 'ddlCargoPrePoliza.Visible = True - 'lblProveedor.Visible = False - End If - - If isAlmacenistaGluyas() Then - GvInv.Columns(10).Visible = True - 'Dim productos As New ClsProductosServicios - 'If productos.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then - ' PSDTRemplazo = productos.DtResultados.FiltraParametros("PendienteEnOC=1", "PS") - 'End If - 'productos.Dispose() - End If - - PermisoEdicionManual = False - CveMovimientoAlmacen = 0 - SetValues() - ArrAnticipos = New ArrayList() - ArrIE = New ArrayList() - ArrIEFuncionariosEmpleados = New ArrayList() - ClavesBorradas = New ArrayList() - TxtFecha.Text = Now.ToShortDateString - TxtFechaEjecucion.Text = Now.ToShortDateString - ViewState("CveCompra") = "0" - ViewState("CveFactura") = "0" - ViewState("IdPoliza") = "0" - ViewState("CveCompra") = -1 - ViewState("EjercicioAC") = -1 - ViewState("CveTipoProveedor") = -1 - CveCompraRefacturacion = -1 - ModalidadUMAlias = -1 - CvePrePoliza = -1 - TabActivosFijos.Enabled = UsuarioActual.Empresa.UsaAF - - TieneOC = False - CveMoneda = -1 - - '[IPP] Eliminar 22Junio2018 - 'If UsuarioActual.Empresa.UsaInventarios Then - ' TabAlmacen.Enabled = Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 - 'End If - - ImgAnticiposPendientes.Attributes.Add("OnClick", "MuestraAnticipos();") - 'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide(200);") - 'BtnCancelar.Attributes.Add("OnClick", "$('#DivAddEq').hide();") - ' ImageButton1.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") - ImgClose.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") - ImgAdd.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") - 'LbTotalPorDevengar.Attributes.Add("OnInnerTextChanged", "TotalDevendar();") - 'Mensaje temporalca - - RBLPago.Visible = True - If UsuarioActual.Empresa.UsaAC Then RBLPago.Items.RemoveAt(2) 'Elimina Reembolso cuando es AC - - - If UsuarioActual.Empresa.UsaAC Then - TrReembolso.Visible = True - GvPS.Columns(1).Visible = True - TxtFecha.Attributes.Add("onblur", "CambiaFecha();") - End If - - TxtOC.Attributes.Add("onkeypress", "fncBuscaOC(event);") - - 'If UsuarioActual.Empresa.GralSoloProyecto Then - - ' LitHProyecto.Text = "Sucursal" - ' DdlSubProyecto.Items.Clear() - ' DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - ' DdlSubProyecto.DataBind() - ' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - ' DdlAsignaSubProyecto.Items.Clear() - ' DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - ' DdlAsignaSubProyecto.DataBind() - ' DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - ' divproyecto.Visible = False - ' divasignaproyecto.Visible = False - ' DdlProyecto.Visible = False - ' DdlProyecto.Items(0).Text = "" - - 'End If - - If UsuarioActual.CveEmpresa = 66 And UsuarioActual.TienePermisoProceso(96) Then - ChkProgramarPago.Visible = True - End If - - - 'CARGA PERSONAL - Dim ObjPersonal As New ClsRH - ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa) - DdlPersonal.DataSource = ObjPersonal.DtResultados - DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados - ObjPersonal.Dispose() - DdlPersonal.DataBind() - DdlPersonalReembolso.DataBind() - - - 'Carga Proveedor - If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then - ViewState("CveProveedor") = Request("CveProveedor") - HdnCveProveedor.Value = Request("CveProveedor") - CargaProveedor(CveProveedor, "-1") - GvInv.Visible = True - ElseIf Request("CveFactura") IsNot Nothing AndAlso IsNumeric(Request("CveFactura")) AndAlso Request("CveFactura").ToEntero > 0 Then - ViewState("CveFactura") = Request("CveFactura").ToEntero - - Dim RFC As String = CargaFactura(CveFactura) - DdlProveedor.Visible = False - HplProveedor.Visible = True - GvInv.Visible = True - CargaProveedor(-1, RFC) - - If Not DdlTipoComprobante.SelectedValue = "NC" Then - If UsuarioActual.Empresa.Funcionalidad(128) = "1" And Not UsuarioActual.TienePermisoProceso(213) Then - If TmpDT.MAX("CvePS").ToEntero > 0 Then - BtnGuardar.Enabled = False - RegistraScript("$('#ImgBtnBuscarOC').click()") - End If - End If - End If - - If DdlTipoComprobante.SelectedValue = "NC" Then - paneldevolucion.Visible = True - Pnlalmaceninventarios.Visible = False - cargaddldevoluciones(CveProveedor, TxtSubTotal.Text.ToDouble) - InicializaAplicaNCFact() - DivReembolso.Visible = False - RBLPago.Items(2).Enabled = False - - End If - - - - If UsuarioActual.Empresa.UsaAC Then - CambiaEjercicioAC() - End If - - ' ''Fecha limite para ingreso de facturas - ''Dim DtEmpresa As DataTable = GlobalDTEmpresas(UsuarioActual.CveEmpresa) - ''If DtEmpresa.Rows.Count > 0 Then - '' Dim FechaLimite = DateSerial(DtEmpresa.Rows(0)("EjercicioActual").ToString.ToEntero, DtEmpresa.Rows(0)("PeriodoActual").ToString.ToEntero, DtEmpresa.Rows(0)("DiasPermitidos").ToString.ToEntero) - '' If Month(TxtFecha.Text.ToDate) < (Month(FechaLimite) - 1) Or (Month(TxtFecha.Text.ToDate) = (Month(FechaLimite) - 1) And Day(Date.Now) > Day(FechaLimite)) Then - '' Alert("La factura actual ya no aplica para ingresarse al sístema.", TipoMensaje.MsgAdvertencia) - '' BtnGuardar.Enabled = False - '' Else - '' Alert("En tiempo") - '' End If - ''Else - '' Alert("No se pudieron cargar los datos de la empresa", TipoMensaje.MsgAdvertencia) - ''End If - 'Carga Compra - - If UsuarioActual.Empresa.Funcionalidad(123).ToEntero > 0 And Not UsuarioActual.TienePermisoProceso(156) Then - If Not ValidaCierrePeriodo() Then - Alert("El periodo de la compra actual ya se encuentra cerrado. No podra registrar la compra.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Visible = False - TxtOC.Enabled = False - ImgBtnBuscarOC.Enabled = False - CierrePeriodo = True - DivRestriccionAdvertencia.Visible = True - LtRestriccionAdvertencia.Text = "El periodo de la compra actual ya se encuentra cerrado." - End If - End If - - Dim HayDifIEPS As Boolean = False - For Each Gvr As GridViewRow In GvPS.Rows - If Gvr.DataKey("CvePS").ToEntero > 0 AndAlso Gvr.DataKey("IEPSPSPorcentaje").ToDouble > 0 Then - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=Gvr.DataKey("CvePS").ToEntero).Rows.Count > 0 Then - Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=Gvr.DataKey("CvePS").ToEntero).Rows(0) - If DrPS IsNot Nothing Then - If DrPS("IEPSPorcentaje").ToString.ToDouble <> Gvr.DataKey("IEPSPSPorcentaje").ToDouble Then - HayDifIEPS = True - End If - End If - End If - End If - Next - - If HayDifIEPS Then Alert("El porcentaje de IEPS del producto no coincide con el especificado.", TipoMensaje.MsgAdvertencia) - - If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) - - ElseIf Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then - - ViewState("CveCompra") = Request("CveCompra") - CargaCompra() - BtnGuardar.Enabled = False - 'TdIVA.Visible = True - 'DdlIVA.Enabled = False - CargaGvBitacora() - InventarioMov() - HabilitaNCInv() - DivConsignaciones.Visible = False - - ' 2018/05/25 - Muestra Boton Agregar Guia - LnkAgregarGuia.Visible = True - UpLnkPaqueteriaGuias.Update() - DivEsNoDeducible.Visible = True - DivActualizarVincular.Visible = True - - Else - - ViewState("CveProveedor") = -1 - HdnCveProveedor.Value = "-1" - DdlProveedor.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) - GvInv.Visible = True - 'TdIVA.Visible = True - 'cuando es nuevo - TxtSubTotal2.Attributes.Add("onkeyup", "ActIVA();") - TxtIVA.Attributes.Add("onkeyup", "ActTotal();") - If UsuarioActual.Empresa.UsaAC Then ChkACGeneral.Checked = False ' codigo que se usa para que al agregar una compra manual, al cambiar el filtro del presupuestos afecte a lo capturado - - If UsuarioActual.Empresa.UsaAC Then - CambiaEjercicioAC() - End If - UpConsignaciones.Update() - UpINV.Update() - 'DdlIVA.Visible = True ' cuando es compra manual - If UsuarioActual.CveEmpresa = 126 Then - CargaOrdenCorte() - LnkAddOtrosGastos.Visible = True - UpnTools.Update() - End If - LnkAgregarGuia.Visible = False - UpLnkPaqueteriaGuias.Update() - End If - - 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO + Modalidad = "" + Version = "" + CveMetodoPago = -1 + RFCProv = "" + CargaDdlTipoGasto() + CreaTmpAcarreos() + EsContado = False + CierrePeriodo = False + NCDevolucion = False + CompraCargada = False + Saldo = 0 + SubTotalOriginal = 0 + CveConceptoContableAlmacen = 0 + EsNoDeducible = False + CveTipoConcepto = 1 + '******** Prorrateo ******************************************** + If UsuarioActual.Empresa.Funcionalidad(117) <> "" Then + btnProrateo.Visible = True + End If + + If UsuarioActual.Empresa.Funcionalidad(303) <> "" Then + btnProrateo2.Visible = True + End If + '**************************************************************** + 'If UsuarioActual.CveEmpresa = 72 Then + ' LiRecepcion.Visible = True + ' DdlRecepcion.SelectedValue = "2" + 'End If + + TipoCambio = 1 + IvaAcumulado = 0 + TotalAlmacen = 0 + TotalFlete = 0 + CveOrdenCorte = -1 + + 'VALIDACION DE XML + NuevaValidacionXML = IfNull(Request("NuevaValidacionXML"), 0).ToString.ToEntero + + + IdVale = New List(Of Integer) + + ListaDocumentos = New List(Of String) + + 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then 'Esquema nuevo PrePolizas + If Not UsuarioActual.Empresa.UsaAC Then + EmpresaPrueba = True + TotalGeneral = 0 + CompraSaldo = 0 + ViewState("CvePersonal") = -1 + IdCuentaBancaria = 0 + CveCuentaBancaria = 0 + End If + + IdCuentaBancariaComplementaria = 0 + CveCuentaBancariaComplementaria = 0 + + 'If UsuarioActual.TienePermisoProceso(259) Then + DivEsNoDeducible.Visible = True + 'End If + + If UsuarioActual.Empresa.Funcionalidad(125) = "1" Then 'Seleccionar a quien se abona la Prepoliza + 'ddlCargoPrePoliza.Visible = True + 'lblProveedor.Visible = False + End If + + If isAlmacenistaGluyas() Then + GvInv.Columns(10).Visible = True + 'Dim productos As New ClsProductosServicios + 'If productos.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then + ' PSDTRemplazo = productos.DtResultados.FiltraParametros("PendienteEnOC=1", "PS") + 'End If + 'productos.Dispose() + End If + + PermisoEdicionManual = False + CveMovimientoAlmacen = 0 + SetValues() + ArrAnticipos = New ArrayList() + ArrIE = New ArrayList() + ArrIEFuncionariosEmpleados = New ArrayList() + ClavesBorradas = New ArrayList() + TxtFecha.Text = Now.ToShortDateString + TxtFechaEjecucion.Text = Now.ToShortDateString + ViewState("CveCompra") = "0" + ViewState("CveFactura") = "0" + ViewState("IdPoliza") = "0" + ViewState("CveCompra") = -1 + ViewState("EjercicioAC") = -1 + ViewState("CveTipoProveedor") = -1 + CveCompraRefacturacion = -1 + ModalidadUMAlias = -1 + CvePrePoliza = -1 + TabActivosFijos.Enabled = UsuarioActual.Empresa.UsaAF + + TieneOC = False + CveMoneda = -1 + + '[IPP] Eliminar 22Junio2018 + 'If UsuarioActual.Empresa.UsaInventarios Then + ' TabAlmacen.Enabled = Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 + 'End If + + ImgAnticiposPendientes.Attributes.Add("OnClick", "MuestraAnticipos();") + 'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide(200);") + 'BtnCancelar.Attributes.Add("OnClick", "$('#DivAddEq').hide();") + ' ImageButton1.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") + ImgClose.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") + ImgAdd.Attributes.Add("OnClick", "$('#DivAlmacen').hide();") + 'LbTotalPorDevengar.Attributes.Add("OnInnerTextChanged", "TotalDevendar();") + 'Mensaje temporalca + + RBLPago.Visible = True + If UsuarioActual.Empresa.UsaAC Then RBLPago.Items.RemoveAt(2) 'Elimina Reembolso cuando es AC + + + If UsuarioActual.Empresa.UsaAC Then + TrReembolso.Visible = True + GvPS.Columns(1).Visible = True + TxtFecha.Attributes.Add("onblur", "CambiaFecha();") + End If + + TxtOC.Attributes.Add("onkeypress", "fncBuscaOC(event);") + + 'If UsuarioActual.Empresa.GralSoloProyecto Then + + ' LitHProyecto.Text = "Sucursal" + ' DdlSubProyecto.Items.Clear() + ' DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + ' DdlSubProyecto.DataBind() + ' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + ' DdlAsignaSubProyecto.Items.Clear() + ' DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + ' DdlAsignaSubProyecto.DataBind() + ' DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + ' divproyecto.Visible = False + ' divasignaproyecto.Visible = False + ' DdlProyecto.Visible = False + ' DdlProyecto.Items(0).Text = "" + + 'End If + + If UsuarioActual.CveEmpresa = 66 And UsuarioActual.TienePermisoProceso(96) Then + ChkProgramarPago.Visible = True + End If + + + 'CARGA PERSONAL + Dim ObjPersonal As New ClsRH + ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa) + DdlPersonal.DataSource = ObjPersonal.DtResultados + DdlPersonalReembolso.DataSource = ObjPersonal.DtResultados + ObjPersonal.Dispose() + DdlPersonal.DataBind() + DdlPersonalReembolso.DataBind() + + + 'Carga Proveedor + If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then + ViewState("CveProveedor") = Request("CveProveedor") + HdnCveProveedor.Value = Request("CveProveedor") + CargaProveedor(CveProveedor, "-1") + GvInv.Visible = True + ElseIf Request("CveFactura") IsNot Nothing AndAlso IsNumeric(Request("CveFactura")) AndAlso Request("CveFactura").ToEntero > 0 Then + ViewState("CveFactura") = Request("CveFactura").ToEntero + + Dim RFC As String = CargaFactura(CveFactura) + DdlProveedor.Visible = False + HplProveedor.Visible = True + GvInv.Visible = True + CargaProveedor(-1, RFC) + + If Not DdlTipoComprobante.SelectedValue = "NC" Then + If UsuarioActual.Empresa.Funcionalidad(128) = "1" And Not UsuarioActual.TienePermisoProceso(213) Then + If TmpDT.MAX("CvePS").ToEntero > 0 Then + BtnGuardar.Enabled = False + RegistraScript("$('#ImgBtnBuscarOC').click()") + End If + End If + End If + + If DdlTipoComprobante.SelectedValue = "NC" Then + paneldevolucion.Visible = True + Pnlalmaceninventarios.Visible = False + cargaddldevoluciones(CveProveedor, TxtSubTotal.Text.ToDouble) + InicializaAplicaNCFact() + DivReembolso.Visible = False + RBLPago.Items(2).Enabled = False + + End If + + + + If UsuarioActual.Empresa.UsaAC Then + CambiaEjercicioAC() + End If + + ' ''Fecha limite para ingreso de facturas + ''Dim DtEmpresa As DataTable = GlobalDTEmpresas(UsuarioActual.CveEmpresa) + ''If DtEmpresa.Rows.Count > 0 Then + '' Dim FechaLimite = DateSerial(DtEmpresa.Rows(0)("EjercicioActual").ToString.ToEntero, DtEmpresa.Rows(0)("PeriodoActual").ToString.ToEntero, DtEmpresa.Rows(0)("DiasPermitidos").ToString.ToEntero) + '' If Month(TxtFecha.Text.ToDate) < (Month(FechaLimite) - 1) Or (Month(TxtFecha.Text.ToDate) = (Month(FechaLimite) - 1) And Day(Date.Now) > Day(FechaLimite)) Then + '' Alert("La factura actual ya no aplica para ingresarse al sístema.", TipoMensaje.MsgAdvertencia) + '' BtnGuardar.Enabled = False + '' Else + '' Alert("En tiempo") + '' End If + ''Else + '' Alert("No se pudieron cargar los datos de la empresa", TipoMensaje.MsgAdvertencia) + ''End If + 'Carga Compra + + If UsuarioActual.Empresa.Funcionalidad(123).ToEntero > 0 And Not UsuarioActual.TienePermisoProceso(156) Then + If Not ValidaCierrePeriodo() Then + Alert("El periodo de la compra actual ya se encuentra cerrado. No podra registrar la compra.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Visible = False + TxtOC.Enabled = False + ImgBtnBuscarOC.Enabled = False + CierrePeriodo = True + DivRestriccionAdvertencia.Visible = True + LtRestriccionAdvertencia.Text = "El periodo de la compra actual ya se encuentra cerrado." + End If + End If + + Dim HayDifIEPS As Boolean = False + For Each Gvr As GridViewRow In GvPS.Rows + If Gvr.DataKey("CvePS").ToEntero > 0 AndAlso Gvr.DataKey("IEPSPSPorcentaje").ToDouble > 0 Then + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=Gvr.DataKey("CvePS").ToEntero).Rows.Count > 0 Then + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=Gvr.DataKey("CvePS").ToEntero).Rows(0) + If DrPS IsNot Nothing Then + If DrPS("IEPSPorcentaje").ToString.ToDouble <> Gvr.DataKey("IEPSPSPorcentaje").ToDouble Then + HayDifIEPS = True + End If + End If + End If + End If + Next + + If HayDifIEPS Then Alert("El porcentaje de IEPS del producto no coincide con el especificado.", TipoMensaje.MsgAdvertencia) + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) + + ElseIf Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then + + ViewState("CveCompra") = Request("CveCompra") + CargaCompra() + BtnGuardar.Enabled = False + 'TdIVA.Visible = True + 'DdlIVA.Enabled = False + CargaGvBitacora() + InventarioMov() + HabilitaNCInv() + DivConsignaciones.Visible = False + + ' 2018/05/25 - Muestra Boton Agregar Guia + LnkAgregarGuia.Visible = True + UpLnkPaqueteriaGuias.Update() + DivEsNoDeducible.Visible = True + DivActualizarVincular.Visible = True + + Else + + ViewState("CveProveedor") = -1 + HdnCveProveedor.Value = "-1" + DdlProveedor.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) + GvInv.Visible = True + 'TdIVA.Visible = True + 'cuando es nuevo + TxtSubTotal2.Attributes.Add("onkeyup", "ActIVA();") + TxtIVA.Attributes.Add("onkeyup", "ActTotal();") + If UsuarioActual.Empresa.UsaAC Then ChkACGeneral.Checked = False ' codigo que se usa para que al agregar una compra manual, al cambiar el filtro del presupuestos afecte a lo capturado + + If UsuarioActual.Empresa.UsaAC Then + CambiaEjercicioAC() + End If + UpConsignaciones.Update() + UpINV.Update() + 'DdlIVA.Visible = True ' cuando es compra manual + If UsuarioActual.CveEmpresa = 126 Then + CargaOrdenCorte() + LnkAddOtrosGastos.Visible = True + UpnTools.Update() + End If + LnkAgregarGuia.Visible = False + UpLnkPaqueteriaGuias.Update() + End If + + 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO LblSaldoFactura.Text = If(CveCompra > 0, Saldo.FormatoNumero, TxtTotal.Text.FormatoNumero) 'cuando es factura con amortizacion, el importe a descontar es el saldo que se debe de aplicar para la amortizacion - If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then - LblSaldoFactura.Text = TmpDT.SUMD("Descuento").ToString - End If - - If UsuarioActual.CveEmpresa = 126 And CveCompra > 0 Then - LnkExportaGv.Visible = True - End If - - 'Condiciones de la Compra - Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) - dt = dt.FiltraParametros(String.Format("CveTipoCuenta = 1")) - - DdlCajaChica.DataSource = dt - DdlCajaChica.DataBind() - DdlCuentaCajaChicaReembolso.DataSource = dt - DdlCuentaCajaChicaReembolso.DataBind() - - ViewState("CveCajaChica") = -1 - ViewState("CvePersonal") = -1 - - CargaTipoTransaccion() - CargaCuentas() - - 'If CveFactura > 0 AndAlso UsuarioActual.Empresa.UsaAC Then - ' CompruebaAgregar() - 'End If - - - 'VALIDA REQUIERE CENTRO COSTOS - If UsuarioActual.Empresa.RequiereCentroCostos Then - 'RFVSubProyecto.Enabled = True - End If - - - 'VALIDA Usuario TIPO REMESA - If UsuarioActual.TienePermisoProceso(108) Then - RBLPago.Enabled = False - - 'VALIDA FECHAPAGO PARA USUARIO TIPO REMESA - If UsuarioActual.TienePermisoProceso(109) Then - TxtFechaPago.Enabled = False - End If - - End If - - 'Valida Proceso 115 para ALMACENISTA - If UsuarioActual.TienePermisoProceso(115) Then - TxtFechaPago.Enabled = False - ChkAplicaNotaCredito.Enabled = False - RBLPago.Enabled = False - BtnGuardar.Enabled = False - BtnGuardar.ToolTip = "Obliga a seleccionar una Orden de compra para su registro." - End If - - - - 'Valida Proceso 119 para ROL Administrador de obra - Bloquea Contado - If UsuarioActual.TienePermisoProceso(119) Then - RBLPago.Items(1).Enabled = False - End If - - 'VALIDA REFACTURACION - ValidaRefacturacion() - If UsuarioActual.TienePermisoProceso(118) Then - RBLPago.Enabled = True - RBLPago.Items(1).Enabled = False - End If - - 'Cargamos los Fletes - ValidaFletesServicios() - If CveCompra > 0 Then - CargaFletesAgregados() - End If - - InicializaOC() - - 'Valida si el IVA del XML es está bien calculado - ValidaIVA() - - If UsuarioActual.TienePermisoProceso(196) Then - BtnRegenerarPrePolizaAlmacen.Visible = True - UpFacturar.Update() - End If - - If CompraCargada AndAlso Request("ADRegenerarPPD") IsNot Nothing AndAlso IsNumeric(Request("ADRegenerarPPD")) AndAlso Request("ADRegenerarPPD").ToEntero = 15062017 Then - RegeneraPrePoliza() - End If - - CargaFletes() - - - If UsuarioActual.Empresa.CvePlataforma = 2 Then - TabActivosFijos.Visible = False - VerRefacturacion.Visible = False - liServicios.Visible = False - DivConsignaciones.Visible = False - End If - - If UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then - LitHProyecto.Text = "Proyecto" - LthProyectoP.Text = "Proyecto" - - LblSubProyectoHeader.Text = "" - LblSubProyectoPHeader.Text = "" - - LblSubProyecto.InnerText = "Proyecto" - 'LblSubProyectoDivAplica.InnerText = "Proyecto" - - DdlSubProyecto.Items.Clear() - 'DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'DdlAsignaSubProyecto.Items.Clear() - 'DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - 'DdlAsignaSubProyecto.DataBind() - 'DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - divproyecto.Visible = False - 'divasignaproyecto.Visible = False - DdlProyecto.Visible = False - DdlProyecto.Items(0).Text = "" - - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then - LitHProyecto.Text = "Sucursal" - LthProyectoP.Text = "Sucursal" - - LblSubProyectoHeader.Text = "" - LblSubProyectoPHeader.Text = "" - - LblSubProyecto.InnerText = "Sucursal" - 'LblSubProyectoDivAplica.InnerText = "Sucursal" - - DdlSubProyecto.Items.Clear() - 'DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'DdlAsignaSubProyecto.Items.Clear() - 'DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - 'DdlAsignaSubProyecto.DataBind() - 'DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - - divproyecto.Visible = False - 'divasignaproyecto.Visible = False - DdlProyecto.Visible = False - DdlProyecto.Items(0).Text = "" - - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then - LitHProyecto.Text = "Sucursal" - LthProyectoP.Text = "Sucursal" - - LblSubProyectoHeader.Text = "Proyecto" - LblSubProyectoPHeader.Text = "Proyecto" - - 'LblSubProyectoDivAplica.InnerText = "Sucursal" - 'LblProyectoDivAplica.InnerText = "Proyecto" - LblSubProyecto.InnerText = "Sucursal" - LblProyecto.InnerText = "Proyecto" - - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then - LitHProyecto.Text = "Proyecto" - LthProyectoP.Text = "Proyecto" - - LblSubProyectoHeader.Text = "Sucursal" - LblSubProyectoPHeader.Text = "Sucursal" - - 'LblSubProyectoDivAplica.InnerText = "Proyecto" - 'LblProyectoDivAplica.InnerText = "Sucursal" - LblSubProyecto.InnerText = "Proyecto" - LblProyecto.InnerText = "Sucursal" - End If - - CargaGvPersonal() - CargaDdlPersonal() - - - InicializaDevolucionAlmacen() - HabilitaEdicionManualAgregar() - InicializaActualizarTC() - End If - - - 'SE OCUPAN AFUERA DEL POSTBACK ?? - cargaddlVinculacionServcios() - If UsuarioActual.TienePermisoProceso(117) Then - - HplAddClasificacion.Visible = False - ImgClasificacion.Visible = False + If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then + LblSaldoFactura.Text = TmpDT.SUMD("Descuento").ToString + End If + + If UsuarioActual.CveEmpresa = 126 And CveCompra > 0 Then + LnkExportaGv.Visible = True + End If + + 'Condiciones de la Compra + Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) + dt = dt.FiltraParametros(String.Format("CveTipoCuenta = 1")) + + DdlCajaChica.DataSource = dt + DdlCajaChica.DataBind() + DdlCuentaCajaChicaReembolso.DataSource = dt + DdlCuentaCajaChicaReembolso.DataBind() + + ViewState("CveCajaChica") = -1 + ViewState("CvePersonal") = -1 + + CargaTipoTransaccion() + CargaCuentas() + + 'If CveFactura > 0 AndAlso UsuarioActual.Empresa.UsaAC Then + ' CompruebaAgregar() + 'End If + + + 'VALIDA REQUIERE CENTRO COSTOS + If UsuarioActual.Empresa.RequiereCentroCostos Then + 'RFVSubProyecto.Enabled = True + End If + + + 'VALIDA Usuario TIPO REMESA + If UsuarioActual.TienePermisoProceso(108) Then + RBLPago.Enabled = False + + 'VALIDA FECHAPAGO PARA USUARIO TIPO REMESA + If UsuarioActual.TienePermisoProceso(109) Then + TxtFechaPago.Enabled = False + End If + + End If + + 'Valida Proceso 115 para ALMACENISTA + If UsuarioActual.TienePermisoProceso(115) Then + TxtFechaPago.Enabled = False + ChkAplicaNotaCredito.Enabled = False + RBLPago.Enabled = False + BtnGuardar.Enabled = False + BtnGuardar.ToolTip = "Obliga a seleccionar una Orden de compra para su registro." + End If + + + + 'Valida Proceso 119 para ROL Administrador de obra - Bloquea Contado + If UsuarioActual.TienePermisoProceso(119) Then + RBLPago.Items(1).Enabled = False + End If + + 'VALIDA REFACTURACION + ValidaRefacturacion() + If UsuarioActual.TienePermisoProceso(118) Then + RBLPago.Enabled = True + RBLPago.Items(1).Enabled = False + End If + + 'Cargamos los Fletes + ValidaFletesServicios() + If CveCompra > 0 Then + CargaFletesAgregados() + End If + + InicializaOC() + + 'Valida si el IVA del XML es está bien calculado + ValidaIVA() + + If UsuarioActual.TienePermisoProceso(196) Then + BtnRegenerarPrePolizaAlmacen.Visible = True + UpFacturar.Update() + End If + + If CompraCargada AndAlso Request("ADRegenerarPPD") IsNot Nothing AndAlso IsNumeric(Request("ADRegenerarPPD")) AndAlso Request("ADRegenerarPPD").ToEntero = 15062017 Then + RegeneraPrePoliza() + End If + + CargaFletes() + + + If UsuarioActual.Empresa.CvePlataforma = 2 Then + TabActivosFijos.Visible = False + VerRefacturacion.Visible = False + liServicios.Visible = False + DivConsignaciones.Visible = False + End If + + If UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then + LitHProyecto.Text = "Proyecto" + LthProyectoP.Text = "Proyecto" + + LblSubProyectoHeader.Text = "" + LblSubProyectoPHeader.Text = "" + + LblSubProyecto.InnerText = "Proyecto" + 'LblSubProyectoDivAplica.InnerText = "Proyecto" + + DdlSubProyecto.Items.Clear() + 'DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'DdlAsignaSubProyecto.Items.Clear() + 'DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + 'DdlAsignaSubProyecto.DataBind() + 'DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + divproyecto.Visible = False + 'divasignaproyecto.Visible = False + DdlProyecto.Visible = False + DdlProyecto.Items(0).Text = "" + + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then + LitHProyecto.Text = "Sucursal" + LthProyectoP.Text = "Sucursal" + + LblSubProyectoHeader.Text = "" + LblSubProyectoPHeader.Text = "" + + LblSubProyecto.InnerText = "Sucursal" + 'LblSubProyectoDivAplica.InnerText = "Sucursal" + + DdlSubProyecto.Items.Clear() + 'DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'DdlAsignaSubProyecto.Items.Clear() + 'DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + 'DdlAsignaSubProyecto.DataBind() + 'DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + + divproyecto.Visible = False + 'divasignaproyecto.Visible = False + DdlProyecto.Visible = False + DdlProyecto.Items(0).Text = "" + + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then + LitHProyecto.Text = "Sucursal" + LthProyectoP.Text = "Sucursal" + + LblSubProyectoHeader.Text = "Proyecto" + LblSubProyectoPHeader.Text = "Proyecto" + + 'LblSubProyectoDivAplica.InnerText = "Sucursal" + 'LblProyectoDivAplica.InnerText = "Proyecto" + LblSubProyecto.InnerText = "Sucursal" + LblProyecto.InnerText = "Proyecto" + + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then + LitHProyecto.Text = "Proyecto" + LthProyectoP.Text = "Proyecto" + + LblSubProyectoHeader.Text = "Sucursal" + LblSubProyectoPHeader.Text = "Sucursal" + + 'LblSubProyectoDivAplica.InnerText = "Proyecto" + 'LblProyectoDivAplica.InnerText = "Sucursal" + LblSubProyecto.InnerText = "Proyecto" + LblProyecto.InnerText = "Sucursal" + End If + + CargaGvPersonal() + CargaDdlPersonal() + + + InicializaDevolucionAlmacen() + HabilitaEdicionManualAgregar() + InicializaActualizarTC() + End If + + + 'SE OCUPAN AFUERA DEL POSTBACK ?? + cargaddlVinculacionServcios() + If UsuarioActual.TienePermisoProceso(117) Then + + HplAddClasificacion.Visible = False + ImgClasificacion.Visible = False End If 'If CargoFactura Then @@ -1625,64 +1625,64 @@ Partial Class Compras_Compras 'RegistraScript("ScrollVentanaAddProducto();") End Sub -#Region "C A R G A S" - Private Sub CargaOrdenCorte() - Dim ObjCGame As New ClsCGame() - If ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa) Then - DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros("Disponible = 1") - DdlOrdenCorte.Items.Insert(0, New ListItem("No vincular", "-1")) - End If - ObjCGame.Dispose() - DdlOrdenCorte.DataBind() - UpOtrosGastos.Update() - End Sub - - Private Sub CargaDdlTipoGasto() - DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - DdlTipoGasto.DataBind() - DdlTipoGastoAsignar.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) - DdlTipoGastoAsignar.DataBind() - UpParametros.Update() - End Sub - - Private Sub CargaGvAcarreos(tCveProveedor As Integer) - Dim ObjAcar As New ClsAcarreos - If ObjAcar.GetPreEstimacion(tCveProveedor, UsuarioActual.CveEmpresa, -1) Then - GvAcarreo.DataSource = ObjAcar.DtResultados - If ObjAcar.DtResultados.Rows.Count > 0 Then - LnkAcarreo.Visible = True - End If - End If - ObjAcar.Dispose() - UpAddAcarreo.Update() - GvAcarreo.DataBind() - End Sub - - Private Sub ValidaIVA() - If Version <> "3.3" And CveCompra <= 0 Then - Dim ImporteIVAXML As Double = (TxtSubTotal.Text.Trim.ToDouble - TxtDescuento.Text.Trim.ToDouble - TxtIEPS.Text.Trim.ToDouble) * 0.16 - If Math.Abs(TxtIVA.Text.Trim.ToDouble - ImporteIVAXML) >= 1 Then - Alert("El IVA del CFDi no tiene un comportamiento normal, por favor verifique que sea correcto.

NOTA: Esta advertencia no aplica en casos de conceptos(alimentos, combustibles o servicios de comunicación) exentos de IVA o causantes de IEPS.", TipoMensaje.MsgAdvertencia) - End If - End If - End Sub - - Private Function isAlmacenistaGluyas() As Boolean - 'Return (UsuarioActual.CveRol = 1052 And UsuarioActual.CveEmpresa = 66) - Return False - End Function - - Private Function CargaFactura(CveFactura As Integer) As String - Dim ObjeFacturas As New ClsCompras - Dim RFC As String = "" - If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-3), Now, "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) AndAlso ObjeFacturas.DtResultados.Rows.Count > 0 Then - Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0) ' no toma la cero, porque es el totalizador - - Dim XMLDoc As New XmlDocument - Dim Archivo As String = String.Format("{0}Empresas\{1}\Compras\{2}\{3}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, dr("RFCDe"), dr("XML")) - If IO.File.Exists(Archivo) Then - - Dim Validada As Boolean = True +#Region "C A R G A S" + Private Sub CargaOrdenCorte() + Dim ObjCGame As New ClsCGame() + If ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa) Then + DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros("Disponible = 1") + DdlOrdenCorte.Items.Insert(0, New ListItem("No vincular", "-1")) + End If + ObjCGame.Dispose() + DdlOrdenCorte.DataBind() + UpOtrosGastos.Update() + End Sub + + Private Sub CargaDdlTipoGasto() + DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + DdlTipoGasto.DataBind() + DdlTipoGastoAsignar.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) + DdlTipoGastoAsignar.DataBind() + UpParametros.Update() + End Sub + + Private Sub CargaGvAcarreos(tCveProveedor As Integer) + Dim ObjAcar As New ClsAcarreos + If ObjAcar.GetPreEstimacion(tCveProveedor, UsuarioActual.CveEmpresa, -1) Then + GvAcarreo.DataSource = ObjAcar.DtResultados + If ObjAcar.DtResultados.Rows.Count > 0 Then + LnkAcarreo.Visible = True + End If + End If + ObjAcar.Dispose() + UpAddAcarreo.Update() + GvAcarreo.DataBind() + End Sub + + Private Sub ValidaIVA() + If Version <> "3.3" And CveCompra <= 0 Then + Dim ImporteIVAXML As Double = (TxtSubTotal.Text.Trim.ToDouble - TxtDescuento.Text.Trim.ToDouble - TxtIEPS.Text.Trim.ToDouble) * 0.16 + If Math.Abs(TxtIVA.Text.Trim.ToDouble - ImporteIVAXML) >= 1 Then + Alert("El IVA del CFDi no tiene un comportamiento normal, por favor verifique que sea correcto.

NOTA: Esta advertencia no aplica en casos de conceptos(alimentos, combustibles o servicios de comunicación) exentos de IVA o causantes de IEPS.", TipoMensaje.MsgAdvertencia) + End If + End If + End Sub + + Private Function isAlmacenistaGluyas() As Boolean + 'Return (UsuarioActual.CveRol = 1052 And UsuarioActual.CveEmpresa = 66) + Return False + End Function + + Private Function CargaFactura(CveFactura As Integer) As String + Dim ObjeFacturas As New ClsCompras + Dim RFC As String = "" + If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-3), Now, "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) AndAlso ObjeFacturas.DtResultados.Rows.Count > 0 Then + Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0) ' no toma la cero, porque es el totalizador + + Dim XMLDoc As New XmlDocument + Dim Archivo As String = String.Format("{0}Empresas\{1}\Compras\{2}\{3}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, dr("RFCDe"), dr("XML")) + If IO.File.Exists(Archivo) Then + + Dim Validada As Boolean = True If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then 'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui @@ -1705,145 +1705,145 @@ Partial Class Compras_Compras Alert($"Los servicios de validacion del SAT presentan lentitud en la respuesta [{ SegundosRespuesta } s].", TipoMensaje.ToastError, "", 0) End If - If UsuarioActual.CveEmpresa < 2 Then - Valida.EsValida = 1 - End If - - If Valida.EsValida > 0 Then - If Valida.EsValida = 2 Then - Validada = False - - If ObjeFacturas.UpdateEstatus(Valida.EsValida, CveFactura) Then - - End If - - Alert("La factura está cancelada ante el SAT.", TipoMensaje.MsgError) - Else ' cuando es valor =1, es vigente - Validada = True - 'solicitud de activacion de facturas - 'If UsuarioActual.CveEmpresa = 66 Then Alert("Se deshabilitado la validación ante el SAT.
Pero el Sistema validación del SAT esta funcionando. ") - End If - - Else - 'no se pudo validar, pero ya tuvo la primera vuelta de validacion - Validada = True - End If - 'Valida.Dispose() - End If - - UpPSS.Update() - - - If Validada Then - - - - Try - - XMLDoc.Load(Archivo) - Catch ex As Exception - - Dim oReader = New StreamReader(Archivo, Encoding.GetEncoding("ISO-8859-1")) - XMLDoc.Load(oReader) - oReader.Dispose() - - End Try - - - CreaDTConceptos() - - CargaComprobanteXML(XMLDoc) - - If NuevaValidacionXML = 1 Or Version = "3.3" Then - Dim Xml As New StringBuilder - Dim nodo As XmlNode = XMLDoc.DocumentElement - Dim Version = ValorXML(nodo, "version") - Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) - Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" - Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) - - If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" - namespaces.AddNamespace(Prefijo, cfdVer) - namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") - namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") - namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") - - Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) - - Xml.Append(Replace(Replace(Replace(nodeconceptos.OuterXml, " 0 Then + If Valida.EsValida = 2 Then + Validada = False + + If ObjeFacturas.UpdateEstatus(Valida.EsValida, CveFactura) Then + + End If + + Alert("La factura está cancelada ante el SAT.", TipoMensaje.MsgError) + Else ' cuando es valor =1, es vigente + Validada = True + 'solicitud de activacion de facturas + 'If UsuarioActual.CveEmpresa = 66 Then Alert("Se deshabilitado la validación ante el SAT.
Pero el Sistema validación del SAT esta funcionando. ") + End If + + Else + 'no se pudo validar, pero ya tuvo la primera vuelta de validacion + Validada = True + End If + 'Valida.Dispose() + End If + + UpPSS.Update() + + + If Validada Then + + + + Try + + XMLDoc.Load(Archivo) + Catch ex As Exception + + Dim oReader = New StreamReader(Archivo, Encoding.GetEncoding("ISO-8859-1")) + XMLDoc.Load(oReader) + oReader.Dispose() + + End Try + + + CreaDTConceptos() + + CargaComprobanteXML(XMLDoc) + + If NuevaValidacionXML = 1 Or Version = "3.3" Then + Dim Xml As New StringBuilder + Dim nodo As XmlNode = XMLDoc.DocumentElement + Dim Version = ValorXML(nodo, "version") + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + + If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + + Xml.Append(Replace(Replace(Replace(nodeconceptos.OuterXml, " 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then - AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero) - ' TrasladoIEPS = 0 - End If - - 'AGREGA IEPS COMO IMPORTE GENERAL - 'If TrasladoIEPS > 0 And Not UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then - ' IEPS = TrasladoIEPS - 'End If - - 'en otro impuesto lo esta registrando en ajuste en automatico - If OtrosImpuestos > 0 Then - AjustaUltimoConcepto = True - End If - - If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP - 'OtrosImpuestos = Total - (SubTotal2 + IVA) - 'este importe lo vamos a meter al gasto - 'AjustaImporteUltimoConcepto(OtrosImpuestos) - OtrosImpuestos = 1 - AjustaUltimoConcepto = True - 'SubTotal2 = SubTotal - End If - - Dim SubTotalReal As Decimal = 0 - - - SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra - - Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2) - - - If DiferenciaTotales <> 0 Then - 'Verificamos IEPS y Otros Impuestos - 'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final - If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then - - 'Condicion necesaria cuando hay IVA pero no hay diferencia - If DiferenciaTotales <> 0 Then - - If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then - Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos - AjustaImporteUltimoConcepto(IA, True) - - ElseIf DiferenciaTotales > 50 Then - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next - - End If - - End If - TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal - - Else - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next - End If - End If - - - 'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto - If Descuentos > 0 Then - - '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 - If CveFactura = 286290 Then - - Else - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4) - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next - End If - - End If - - - SubTotal2 = SubTotalReal - Descuentos - - If Descuentos > 0 Then - TrDescuento.Visible = True - End If - - If Msg <> "" Then - Alert(Msg, TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - End If - - 'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA) - If SubTotal2 <> SubTotal Then - SubTotal = SubTotalConceptos - End If - - TxtSubTotal.Text = SubTotal.FormatoNumero - TxtDescuento.Text = Descuentos.FormatoNumero - TxtSubTotal2.Text = SubTotal2.FormatoNumero - TxtIVA.Text = IVA.FormatoNumero - TxtTotal.Text = Total.ToString.FormatoNumero - - HfTotalCompra.Value = Total.ToString - CompraSaldo = Total - - CalculaTotalPorDevengar() - TxtDocumentoImporteFE.Text = Total.ToString - RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString - RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - TxtDocumentoImporte.Text = Total.FormatoNumero - TxtDocumentoImporteCaja.Text = Total.FormatoNumero - TxtRetIVA.Text = RetencionIVA.FormatoNumero - TxtRetISR.Text = RetencionISR.FormatoNumero - TxtIEPS.Text = IEPS.FormatoNumero - If IEPS > 0 Then TrIEPS.Visible = True - If RetencionIVA > 0 Then TrRetIVA.Visible = True - If RetencionISR > 0 Then TrRetISR.Visible = True - TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero - If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True - - HFDiferenciaCompra.Value = TxtTotal.Text - - - LblRetIVA.Text = (If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%" - LblRetISR.Text = (If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3) - - - 'ASIGNA VALORES ORIGINALES PARA GUARDAR - AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total) - - End If - - - TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString - - Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda)) - If drMon IsNot Nothing Then - DdlMoneda.SelectedValue = drMon("CveMoneda").ToString - Else - 'sino busco en la tabla de alias - drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda)) - - If drMon IsNot Nothing Then - DdlMoneda.SelectedValue = drMon("CveMoneda").ToString - Else - LblMoneda.Text = Moneda - LblMoneda.ForeColor = Drawing.Color.Red - End If - - End If - - If DdlMoneda.SelectedValue.ToEntero > 1 Then - If TipoCambio <= 10 Then - TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate) - End If - - TxtFecha.Attributes.Remove("onblur") - If UsuarioActual.Empresa.UsaAC Then - TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") - Else - TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") - End If - - End If - - If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) - - 'DF - 10-04-17 - If UsuarioActual.TienePermisoProceso(187) Then - TxtSerie.Enabled = True - End If - - - End If - - Else - Alert("No se Encontró la Factura", TipoMensaje.MsgAdvertencia) - BtnGuardar.Visible = False - End If - - 'GvPS.DataSource = 'DTConceptos - 'GvPS.DataBind() - End If - - ObjeFacturas.Dispose() - - Dim ObjSAT As New ClsSAT - Dim RFCRequest As String = Request("RFC").ToString - If ObjSAT.GetListado69B(2, UsuarioActual.CveEmpresa, RFCRequest) Then - If ObjSAT.DtResultados.Rows.Count > 0 Then - Dim Estatus As String = ObjSAT.DtResultados.Rows(0)("Situacion").ToString - BtnGuardar.Enabled = False - UpParametros.Update() - - Alert($"El RFC del proveedor se encuentra en estado {Estatus} en el Listado EFOS (69B) del SAT", TipoMensaje.MsgAdvertencia) - System.Threading.Thread.Sleep(5) - End If - End If - ObjSAT.Dispose() - - - Return RFC - End Function - + End If + + Dim Msg As String = "" + + + If Version = "3.3" Then + + ValidacionesTotalesXml() + + Else + + 'PRUEBA + 'http://rm/Compras/Compras.aspx?CveFactura=122518 Emp: 48 + + 'tTotal = Math.Round(SubTotal2 + IVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos, 2) + HdnCompraSaldo.Value = Total.ToString + CompraSaldo = Total + Dim AjustaUltimoConcepto = False + + 'AGREGA IEPS COMO CONCEPTO + If TrasladoIEPS > 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then + AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero) + ' TrasladoIEPS = 0 + End If + + 'AGREGA IEPS COMO IMPORTE GENERAL + 'If TrasladoIEPS > 0 And Not UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then + ' IEPS = TrasladoIEPS + 'End If + + 'en otro impuesto lo esta registrando en ajuste en automatico + If OtrosImpuestos > 0 Then + AjustaUltimoConcepto = True + End If + + If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP + 'OtrosImpuestos = Total - (SubTotal2 + IVA) + 'este importe lo vamos a meter al gasto + 'AjustaImporteUltimoConcepto(OtrosImpuestos) + OtrosImpuestos = 1 + AjustaUltimoConcepto = True + 'SubTotal2 = SubTotal + End If + + Dim SubTotalReal As Decimal = 0 + + + SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra + + Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2) + + + If DiferenciaTotales <> 0 Then + 'Verificamos IEPS y Otros Impuestos + 'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final + If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then + + 'Condicion necesaria cuando hay IVA pero no hay diferencia + If DiferenciaTotales <> 0 Then + + If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then + Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos + AjustaImporteUltimoConcepto(IA, True) + + ElseIf DiferenciaTotales > 50 Then + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False + + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next + + End If + + End If + TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal + + Else + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False + + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next + End If + End If + + + 'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto + If Descuentos > 0 Then + + '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 + If CveFactura = 286290 Then + + Else + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4) + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False + + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next + End If + + End If + + + SubTotal2 = SubTotalReal - Descuentos + + If Descuentos > 0 Then + TrDescuento.Visible = True + End If + + If Msg <> "" Then + Alert(Msg, TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + End If + + 'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA) + If SubTotal2 <> SubTotal Then + SubTotal = SubTotalConceptos + End If + + TxtSubTotal.Text = SubTotal.FormatoNumero + TxtDescuento.Text = Descuentos.FormatoNumero + TxtSubTotal2.Text = SubTotal2.FormatoNumero + TxtIVA.Text = IVA.FormatoNumero + TxtTotal.Text = Total.ToString.FormatoNumero + + HfTotalCompra.Value = Total.ToString + CompraSaldo = Total + + CalculaTotalPorDevengar() + TxtDocumentoImporteFE.Text = Total.ToString + RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString + RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + TxtDocumentoImporte.Text = Total.FormatoNumero + TxtDocumentoImporteCaja.Text = Total.FormatoNumero + TxtRetIVA.Text = RetencionIVA.FormatoNumero + TxtRetISR.Text = RetencionISR.FormatoNumero + TxtIEPS.Text = IEPS.FormatoNumero + If IEPS > 0 Then TrIEPS.Visible = True + If RetencionIVA > 0 Then TrRetIVA.Visible = True + If RetencionISR > 0 Then TrRetISR.Visible = True + TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero + If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True + + HFDiferenciaCompra.Value = TxtTotal.Text + + + LblRetIVA.Text = (If(SubTotal2 > 0, (RetencionIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%" + LblRetISR.Text = (If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3) + + + 'ASIGNA VALORES ORIGINALES PARA GUARDAR + AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total) + + End If + + + TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString + + Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda)) + If drMon IsNot Nothing Then + DdlMoneda.SelectedValue = drMon("CveMoneda").ToString + Else + 'sino busco en la tabla de alias + drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda)) + + If drMon IsNot Nothing Then + DdlMoneda.SelectedValue = drMon("CveMoneda").ToString + Else + LblMoneda.Text = Moneda + LblMoneda.ForeColor = Drawing.Color.Red + End If + + End If + + If DdlMoneda.SelectedValue.ToEntero > 1 Then + If TipoCambio <= 10 Then + TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate) + End If + + TxtFecha.Attributes.Remove("onblur") + If UsuarioActual.Empresa.UsaAC Then + TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") + Else + TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") + End If + + End If + + If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) + + 'DF - 10-04-17 + If UsuarioActual.TienePermisoProceso(187) Then + TxtSerie.Enabled = True + End If + + + End If + + Else + Alert("No se Encontró la Factura", TipoMensaje.MsgAdvertencia) + BtnGuardar.Visible = False + End If + + 'GvPS.DataSource = 'DTConceptos + 'GvPS.DataBind() + End If + + ObjeFacturas.Dispose() + + Dim ObjSAT As New ClsSAT + Dim RFCRequest As String = Request("RFC").ToString + If ObjSAT.GetListado69B(2, UsuarioActual.CveEmpresa, RFCRequest) Then + If ObjSAT.DtResultados.Rows.Count > 0 Then + Dim Estatus As String = ObjSAT.DtResultados.Rows(0)("Situacion").ToString + BtnGuardar.Enabled = False + UpParametros.Update() + + Alert($"El RFC del proveedor se encuentra en estado {Estatus} en el Listado EFOS (69B) del SAT", TipoMensaje.MsgAdvertencia) + System.Threading.Thread.Sleep(5) + End If + End If + ObjSAT.Dispose() + + + Return RFC + End Function + Private Sub CargaRetIVAConcepto(Optional Cambio As Boolean = False) - If TrRetIVA.Visible Then + If TrRetIVA.Visible Then TdRetIVAConcepto.Visible = True @@ -2116,18 +2116,18 @@ Partial Class Compras_Compras - End If - - If Cambio Then - DdlRetIVAConcepto.Items.Clear() - - If RFCProv.Length = 13 Then - DdlRetIVAConcepto.Items.Insert(0, New ListItem("Honorarios/Serv. Prof.", "1")) - DdlRetIVAConcepto.Items.Insert(1, New ListItem("Fletes P.F.", "2")) - ElseIf RFCProv.Length = 12 Then - DdlRetIVAConcepto.Items.Insert(0, New ListItem("Fletes P.M.", "3")) - End If - + End If + + If Cambio Then + DdlRetIVAConcepto.Items.Clear() + + If RFCProv.Length = 13 Then + DdlRetIVAConcepto.Items.Insert(0, New ListItem("Honorarios/Serv. Prof.", "1")) + DdlRetIVAConcepto.Items.Insert(1, New ListItem("Fletes P.F.", "2")) + ElseIf RFCProv.Length = 12 Then + DdlRetIVAConcepto.Items.Insert(0, New ListItem("Fletes P.M.", "3")) + End If + DdlRetIVAConcepto.Items.Add(New ListItem("Arrendamiento", "4")) If UsuarioActual.Empresa.Funcionalidad(577).ToEntero = 1 Then @@ -2138,96 +2138,96 @@ Partial Class Compras_Compras End If - UpPS.Update() - - End Sub - Private Sub CargaRetISRConcepto(Optional Cambio As Boolean = False) - If TrRetISR.Visible Then - TdRetISRConcepto.Visible = True - End If - If Cambio Then - DdlRetISRConcepto.Items.Clear() - DdlRetISRConcepto.Items.Insert(0, New ListItem("Honorarios", "1")) - DdlRetISRConcepto.Items.Insert(1, New ListItem("Arrendamiento", "2")) - End If - UpPS.Update() - End Sub - - Private Sub ValidacionesTotalesXml() - - Dim Msg As String = "" - Dim SubtotalTemp = TmpDT.SUM("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2) - Dim DescuentosTemp = TmpDT.SUM("Descuento") - Dim Subtotal2Temp = TmpDT.SUM("Total") - Dim IVATemp = TmpDT.SUM("IVA") - Dim IEPSTemp = TmpDT.SUM("IEPSPS") - Dim RetIVATemp = TmpDT.SUM("RetIVA") - Dim RetISRTemp = TmpDT.SUM("RetISR") - Dim TotalTemp As Decimal = (Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones).ToDecimal - - - If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuentos, 6)) > 0.01 Then - Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general
") - End If - - If Math.Abs(Math.Round(IVATemp, 6) - Math.Round(TrasladoIVA, 6)) > 0.01 Then - Msg &= String.Format("- Los IVAS del detalle no coinciden con el IVA general
") - End If - - If Math.Abs(Math.Round(IEPSTemp, 6) - Math.Round(TrasladoIEPS, 6)) > 0.01 Then - Msg &= String.Format("- Los IEPS del detalle no coinciden con el IEPS general
") - End If - - If Math.Abs(Math.Round(RetIVATemp, 6) - Math.Round(RetencionIVA, 6)) > 0.01 Then - Msg &= String.Format("- Los RetIVA del detalle no coinciden con el RetIVA general
") - End If - - If Math.Abs(Math.Round(RetISRTemp, 6) - Math.Round(RetencionISR, 6)) > 0.01 Then - Msg &= String.Format("- Las RetISR del detalle no coinciden con el RetIVA general
") - End If - - If Math.Abs(Math.Round(TotalTemp, 2) - Math.Round(Total, 2)) > 0.01 Then - Msg &= String.Format("- El total generado por los detalles no coincide con el total general
({0}-{1})", Math.Round(TotalTemp, 2), Math.Round(Total, 2)) - End If - - If Msg <> "" Then - Alert($"El comprobante XML presenta las siguientes inconsistencias:

{Msg}", TipoMensaje.MsgAdvertencia) - - TAB.ActiveTabIndex = 0 - - ''''BLOQUEA ACCIONES'''' - BtnGuardar.Enabled = False - - 'BLOQUEA OC - TxtOC.Enabled = False - ImgBtnBuscarOC.Visible = False - Else - '[IPP] IGUALAMOS VALORES PARA RESPETAR LOS DEL XML EN CASO DE DIF DE 0.01 - DescuentosTemp = Descuentos - IVATemp = TrasladoIVA - TotalTemp = Total - RetIVATemp = RetencionIVA - RetISRTemp = RetencionISR + UpPS.Update() + + End Sub + Private Sub CargaRetISRConcepto(Optional Cambio As Boolean = False) + If TrRetISR.Visible Then + TdRetISRConcepto.Visible = True + End If + If Cambio Then + DdlRetISRConcepto.Items.Clear() + DdlRetISRConcepto.Items.Insert(0, New ListItem("Honorarios", "1")) + DdlRetISRConcepto.Items.Insert(1, New ListItem("Arrendamiento", "2")) + End If + UpPS.Update() + End Sub + + Private Sub ValidacionesTotalesXml() + + Dim Msg As String = "" + Dim SubtotalTemp = TmpDT.SUM("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2) + Dim DescuentosTemp = TmpDT.SUM("Descuento") + Dim Subtotal2Temp = TmpDT.SUM("Total") + Dim IVATemp = TmpDT.SUM("IVA") + Dim IEPSTemp = TmpDT.SUM("IEPSPS") + Dim RetIVATemp = TmpDT.SUM("RetIVA") + Dim RetISRTemp = TmpDT.SUM("RetISR") + Dim TotalTemp As Decimal = (Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones).ToDecimal + + + If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuentos, 6)) > 0.01 Then + Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general
") + End If + + If Math.Abs(Math.Round(IVATemp, 6) - Math.Round(TrasladoIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los IVAS del detalle no coinciden con el IVA general
") + End If + + If Math.Abs(Math.Round(IEPSTemp, 6) - Math.Round(TrasladoIEPS, 6)) > 0.01 Then + Msg &= String.Format("- Los IEPS del detalle no coinciden con el IEPS general
") + End If + + If Math.Abs(Math.Round(RetIVATemp, 6) - Math.Round(RetencionIVA, 6)) > 0.01 Then + Msg &= String.Format("- Los RetIVA del detalle no coinciden con el RetIVA general
") + End If + + If Math.Abs(Math.Round(RetISRTemp, 6) - Math.Round(RetencionISR, 6)) > 0.01 Then + Msg &= String.Format("- Las RetISR del detalle no coinciden con el RetIVA general
") + End If + + If Math.Abs(Math.Round(TotalTemp, 2) - Math.Round(Total, 2)) > 0.01 Then + Msg &= String.Format("- El total generado por los detalles no coincide con el total general
({0}-{1})", Math.Round(TotalTemp, 2), Math.Round(Total, 2)) + End If + + If Msg <> "" Then + Alert($"El comprobante XML presenta las siguientes inconsistencias:

{Msg}", TipoMensaje.MsgAdvertencia) + + TAB.ActiveTabIndex = 0 + + ''''BLOQUEA ACCIONES'''' + BtnGuardar.Enabled = False + + 'BLOQUEA OC + TxtOC.Enabled = False + ImgBtnBuscarOC.Visible = False + Else + '[IPP] IGUALAMOS VALORES PARA RESPETAR LOS DEL XML EN CASO DE DIF DE 0.01 + DescuentosTemp = Descuentos + IVATemp = TrasladoIVA + TotalTemp = Total + RetIVATemp = RetencionIVA + RetISRTemp = RetencionISR IEPSTemp = TrasladoIEPS - End If - + End If + If TrasladoIEPS > 0 Or OtrosImpuestos > 0 Then - RegistraScript("$('#ModalIEPS').modal('show');") - - If TrasladoIEPS > 0 Then - ChkIEPS.Visible = True - ChkIEPS.Checked = True - DdlConceptoIEPS.Visible = True - CargaProductos(DdlConceptoIEPS, If(UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero, -1)) - LbImporte.Text = "$" + TrasladoIEPS.ToString - End If - If OtrosImpuestos > 0 Then - ChkOtrosI.Visible = True - ChkOtrosI.Checked = True - DdlConceptoOI.Visible = True - CargaProductos(DdlConceptoOI, If(UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero, -1)) - LbImporte2.Text = "$" + OtrosImpuestos.ToString - End If + RegistraScript("$('#ModalIEPS').modal('show');") + + If TrasladoIEPS > 0 Then + ChkIEPS.Visible = True + ChkIEPS.Checked = True + DdlConceptoIEPS.Visible = True + CargaProductos(DdlConceptoIEPS, If(UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero, -1)) + LbImporte.Text = "$" + TrasladoIEPS.ToString + End If + If OtrosImpuestos > 0 Then + ChkOtrosI.Visible = True + ChkOtrosI.Checked = True + DdlConceptoOI.Visible = True + CargaProductos(DdlConceptoOI, If(UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero, -1)) + LbImporte2.Text = "$" + OtrosImpuestos.ToString + End If End If Dim MostrarRetIva6 As Boolean = False @@ -2236,49 +2236,49 @@ Partial Class Compras_Compras - TxtSubTotal.Text = SubtotalTemp.FormatoNumero - TxtDescuento.Text = DescuentosTemp.FormatoNumero - TxtSubTotal2.Text = Subtotal2Temp.FormatoNumero - TxtIVA.Text = IVATemp.FormatoNumero - TxtTotal.Text = TotalTemp.FormatoNumero - TxtRetIVA.Text = RetIVATemp.FormatoNumero - TxtRetISR.Text = RetISRTemp.FormatoNumero + TxtSubTotal.Text = SubtotalTemp.FormatoNumero + TxtDescuento.Text = DescuentosTemp.FormatoNumero + TxtSubTotal2.Text = Subtotal2Temp.FormatoNumero + TxtIVA.Text = IVATemp.FormatoNumero + TxtTotal.Text = TotalTemp.FormatoNumero + TxtRetIVA.Text = RetIVATemp.FormatoNumero + TxtRetISR.Text = RetISRTemp.FormatoNumero TxtIEPS.Text = IEPSTemp.FormatoNumero - TrDescuento.Visible = DescuentosTemp > 0 - TrIEPS.Visible = IEPSTemp > 0 - TrRetIVA.Visible = RetIVATemp > 0 - TrRetISR.Visible = RetISRTemp > 0 - - TxtSubTotal.Enabled = False - TxtDescuento.Enabled = False - TxtSubTotal2.Enabled = False - TxtIVA.Enabled = False - TxtTotal.Enabled = False - TxtRetIVA.Enabled = False - TxtRetISR.Enabled = False - TxtIEPS.Enabled = False - - HfTotalCompra.Value = TotalTemp.ToString - CompraSaldo = TotalTemp - CalculaTotalPorDevengar() - TxtDocumentoImporteFE.Text = TotalTemp.ToString - RVDocumentoImporte.MaximumValue = Math.Round(TotalTemp, 2).ToString - RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - TxtDocumentoImporte.Text = TotalTemp.FormatoNumero - TxtDocumentoImporteCaja.Text = TotalTemp.FormatoNumero - TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero - If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True - If OtrosImpuestosRetenciones > 0 Then TrOtrosImpuestos.Visible = True : TxtOtrosImpuestos.Text = (-OtrosImpuestosRetenciones).FormatoNumero - HFDiferenciaCompra.Value = TxtTotal.Text - HdnCompraSaldo.Value = TotalTemp.ToString - CompraSaldo = TotalTemp - - LblRetIVA.Text = (If(Subtotal2Temp > 0, (RetIVATemp / Subtotal2Temp), 0) * 100).FormatoNumero(3) + "%" - LblRetISR.Text = (If(Subtotal2Temp > 0, (RetISRTemp / Subtotal2Temp), 0) * 100).FormatoNumero(3) - - 'ASIGNA VALORES ORIGINALES PARA GUARDAR + TrDescuento.Visible = DescuentosTemp > 0 + TrIEPS.Visible = IEPSTemp > 0 + TrRetIVA.Visible = RetIVATemp > 0 + TrRetISR.Visible = RetISRTemp > 0 + + TxtSubTotal.Enabled = False + TxtDescuento.Enabled = False + TxtSubTotal2.Enabled = False + TxtIVA.Enabled = False + TxtTotal.Enabled = False + TxtRetIVA.Enabled = False + TxtRetISR.Enabled = False + TxtIEPS.Enabled = False + + HfTotalCompra.Value = TotalTemp.ToString + CompraSaldo = TotalTemp + CalculaTotalPorDevengar() + TxtDocumentoImporteFE.Text = TotalTemp.ToString + RVDocumentoImporte.MaximumValue = Math.Round(TotalTemp, 2).ToString + RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + TxtDocumentoImporte.Text = TotalTemp.FormatoNumero + TxtDocumentoImporteCaja.Text = TotalTemp.FormatoNumero + TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero + If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True + If OtrosImpuestosRetenciones > 0 Then TrOtrosImpuestos.Visible = True : TxtOtrosImpuestos.Text = (-OtrosImpuestosRetenciones).FormatoNumero + HFDiferenciaCompra.Value = TxtTotal.Text + HdnCompraSaldo.Value = TotalTemp.ToString + CompraSaldo = TotalTemp + + LblRetIVA.Text = (If(Subtotal2Temp > 0, (RetIVATemp / Subtotal2Temp), 0) * 100).FormatoNumero(3) + "%" + LblRetISR.Text = (If(Subtotal2Temp > 0, (RetISRTemp / Subtotal2Temp), 0) * 100).FormatoNumero(3) + + 'ASIGNA VALORES ORIGINALES PARA GUARDAR AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total) If UsuarioActual.Empresa.Funcionalidad(577).ToString = "1" Then @@ -2299,711 +2299,711 @@ Partial Class Compras_Compras End If - End Sub - - ''' - ''' Método que convierte el IEPS en un concepto para no ajustar totales - ''' - Private Sub AgregarConceptoIEPS(IEPS As Decimal, CvePS1 As Integer) - Dim SubTotalR As Decimal = TmpDT.SUM("Total").ToString.ToDecimal - - Dim PSS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") - Dim PSS2 As DataTable = TmpDT.FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") - - If PSS.Rows.Count > 0 Or PSS2.Rows.Count > 0 Then - Dim CveUM As Integer = 0 - Dim UM As String = "" - Dim CveClasificacion As Integer = 0 - Dim Clasificacion As String = "" - Dim CvePS As Integer = 0 - Dim PS As String = "" - Dim CveTipoPS As Integer = 0 - - If PSS.Rows.Count > 0 Then - CveUM = PSS.Rows(0)("CveUM").ToString.ToEntero - UM = PSS.Rows(0)("UnidadMedida").ToString - CveClasificacion = PSS.Rows(0)("CveClasificacion").ToString.ToEntero - Clasificacion = PSS.Rows(0)("Clasificacion").ToString - CvePS = PSS.Rows(0)("CvePS").ToString.ToEntero - PS = PSS.Rows(0)("PS").ToString - CveTipoPS = PSS.Rows(0)("CveTipoPS").ToString.ToEntero - End If - - Dim Cantidad As Double = 1 - Dim CveSubProyectoContrato As String = "-1" - Dim CveProyecto As String = "-1" - Dim SubProyecto As String = "SE" - Dim Proyecto As String = "SE" - Dim Obs As String = "" - Dim PU As Double = IEPS - Dim Total As Double = Cantidad * PU - Dim IVA As Double = 0 - Dim Descuento As Double = 0 - - If PSS2.Rows.Count > 0 Then - CveUM = PSS2.Rows(0)("CveUM").ToString.ToEntero - UM = PSS2.Rows(0)("UM").ToString - CveClasificacion = PSS2.Rows(0)("CveClasificacion").ToString.ToEntero - Clasificacion = PSS2.Rows(0)("Clasificacion").ToString - CvePS = PSS2.Rows(0)("CvePS").ToString.ToEntero - PS = PSS2.Rows(0)("PS").ToString - CveTipoPS = PSS2.Rows(0)("CveTipoPS").ToString.ToEntero - - CveSubProyectoContrato = PSS2.Rows(0)("CveSubProyecto").ToString - CveProyecto = PSS2.Rows(0)("CveProyecto").ToString - SubProyecto = PSS2.Rows(0)("SubProyecto").ToString - Proyecto = PSS2.Rows(0)("Proyecto").ToString - Obs = PSS2.Rows(0)("Obs").ToString - - Dim CveTipoGasto As Integer = PSS2.Rows(0)("CveTipoGasto").ToString.ToEntero - Dim TipoGasto As String = PSS2.Rows(0)("TipoGasto").ToString - - AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) - AddPS2() - Else - AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False) - AddPS2() - End If - End If - - Dim SubTotalIEPS = TmpDT.SUM("Total").ToString.ToDecimal - - SubTotal = Math.Round(SubTotalIEPS, 2) - SubTotalConceptos = Math.Round(SubTotalIEPS, 2) - - 'If SubTotalR <> SubTotalIEPS Then - ' Dim IA As Decimal = SubTotalR - SubTotalIEPS - ' AjustaImporteUltimoConcepto(IA) - 'End If - - PSS.Dispose() - End Sub - - Private Sub CargaCompra() - Dim ObjCompra As New ClsCompras() - Dim ObjOC As New ClsOC() - - If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - - CompraCargada = True - - 'data-toggle="tooltip" data-placement="left" title="Agregar Escolaridad ." - If ObjCompra.DtResultados.Rows(0)("FolioREQ").ToString <> "" Then - lblOCLabel.Attributes.Add("data-toggle", "tooltip") - lblOCLabel.Attributes.Add("data-placement", "top") - lblOCLabel.Attributes.Add("title", "REQ: " & ObjCompra.DtResultados.Rows(0)("FolioREQ").ToString) - End If - - 'CargaProveedor - Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) - Saldo = dr("Saldo").ToString.ToDecimal - RBLPago.Visible = False - Dim CveProveedor As Integer = dr("CveProveedor").ToString.ToEntero - - HdnCveProveedor.Value = CveProveedor.ToString - ViewState("CveProveedor") = CveProveedor - - ImgBtnBuscarOC.OnClientClick = String.Format("AbrirVentana('/OC/PopUpBuscarReq.aspx?V=VOCCOMP&P={0}&T={1}&Masterimpoup=true',1000,600,'S'); return false;", CveProveedor, DdlTipoComprobante.SelectedValue) - - - Dim ObjBancos As New ClsBancos() - - If ObjBancos.GetCreditosCompra(CveCompra) And ObjBancos.DtResultados.Rows.Count > 0 Then - GvCreditosRelacionados.DataSource = ObjBancos.DtResultados - GvCreditosRelacionados.Visible = True - GvCreditosRelacionados.DataBind() - romCreditosTabla.Visible = True - GvCreditos.Visible = False - GvCreditosRelacionados.Visible = True - - PnlContadoCreditos.Visible = True - Else - GvCreditosRelacionados.DataSource = Nothing - GvCreditosRelacionados.Visible = False - GvCreditosRelacionados.DataBind() - - End If - UpGvCreditos.Update() - LblImporteCreditos.Visible = True - ObjBancos.Dispose() - - 'RegistraScript("CargaProveedor(""" & CveProveedor & """);") - - 'CargaEncabezado - 'ViewState("FolioFiscal") = ObjCompra.DtResultados.Rows(0)("FolioFiscal").ToString - TxtSerie.Text = dr("Serie").ToString - TxtFolio.Text = dr("Folio").ToString - TxtFolioSecundario.Text = dr("FolioSecundario").ToString - TxtFecha.Text = dr("Fecha").ToString.ToDate.ToShortDateString - TxtDescripcion.Text = dr("Descripcion").ToString - CvePrePoliza = dr("CvePrePoliza").ToString.ToEntero - EstatusAlmacen = dr("EstatusAlmacen").ToString.ToEntero - DdlTipoCompra.SelectedValueExist(dr("CveTipoCompra")) - 'Select Case dr("PorcentajeIVA").ToString.ToDouble - ' Case 0 - ' DdlIVA.SelectedValue = "1" - ' Case 0.16 - ' DdlIVA.SelectedValue = "1.16" - ' Case 0.08 - ' DdlIVA.SelectedValue = "1.08" - 'End Select - 'If dr("PorcentajeIVA").ToString.ToDouble = 0 Then DdlIVA.SelectedValue = "1" Else DdlIVA.SelectedValue = "1.16" - - LblMetodoPago.Text = dr("MetodoPagoSAT").ToString - - If UsuarioActual.Empresa.UsaAC Then - CambiaEjercicioAC(False) - End If - - If GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).Rows.Count > 0 Then - RowProveedorSucursal.Visible = True - DdlProveedorSucursal.Items.Clear() - DdlProveedorSucursal.DataSource = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa) - DdlProveedorSucursal.DataBind() - DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) - DdlProveedorSucursal.SelectedValueExist(dr("CveProveedorSucursal").ToString.ToEntero) - End If - - ''SE AJUSTO EL SUBTOTAL POR LA COMPRA # 52433 DE LA EMPRESA 48 PARA QUE CUADREN LOS TOTALES CUANDO VIENE CON DESCUENTOS - 'TxtSubTotal.Text = (dr("SubTotal").ToString.ToDouble + dr("Descuentos").ToString.ToDouble).FormatoNumero(2) - TxtSubTotal.Text = (dr("SubTotal").ToString.ToDouble).FormatoNumero - 'TxtSubTotal2.Text = (dr("SubTotal").ToString.ToDouble).FormatoNumero - TxtSubTotal2.Text = (dr("SubTotal").ToString.ToDouble - dr("Descuentos").ToString.ToDouble).FormatoNumero(2) - - TxtDescuento.Text = dr("Descuentos").ToString.FormatoNumero(2) - LblAmortizacion.Text = dr("Amortizacion").ToString.FormatoNumero(2) - TxtIVA.Text = dr("IVA").ToString.FormatoNumero(2) - TxtRetIVA.Text = dr("RetIVA").ToString.FormatoNumero(2) - TxtRetISR.Text = dr("RetISR").ToString.FormatoNumero(2) - TxtIEPS.Text = dr("IEPS").ToString.FormatoNumero(2) - If dr("IEPS").ToString.ToDouble > 0 Then TrIEPS.Visible = True - If dr("RetIVA").ToString.ToDouble > 0 Then TrRetIVA.Visible = True - If dr("RetISR").ToString.ToDouble > 0 Then TrRetISR.Visible = True - If Math.Abs(dr("Redondeo").ToString.ToDouble) > 0 Then TrRedondeo.Visible = True - TxtRedondeo.Text = dr("Redondeo").ToString.FormatoNumero(2) - - TxtOtrosImpuestos.Text = dr("OtrosImpuestos").ToString.FormatoNumero(2) - If dr("OtrosImpuestos").ToString.ToDouble > 0 Then TrOtrosImpuestos.Visible = True - TxtTotal.Text = dr("Total").ToString.FormatoNumero(2) - - HfTotalCompra.Value = TxtTotal.Text - CompraSaldo = TxtTotal.Text.ToDouble - - TipoCambio = dr("TipoCambio").ToString.ToDouble - Dim TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDouble - If TipoCambio > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) - If TipoCambio <> TipoCambioOriginal Then LblTCO.Text = String.Format("
TC Original: {0}", TipoCambioOriginal.ToString("N4")) - - - AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) - CalculaTotalPorDevengar() - TxtDocumentoImporteFE.Text = dr("Total").ToString - RVDocumentoImporte.MaximumValue = dr("Total").ToString.FormatoNumero(2) - RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - - HFDiferenciaCompra.Value = TxtTotal.Text - - - - TotalGeneral = dr("Total").ToString.ToDouble - CveMoneda = dr("CveMoneda").ToString.ToEntero - DdlValidadaSAT.SelectedValue = "Si" - TxtObsFact.Text = dr("Observaciones").ToString - LblUsuarioCaptura.Text = dr("Usuario").ToString - LitFechCaptura.Text = dr("FechaIng").ToString.ToDate.ToShortDateString - LblRetIVA.Text = Math.Round((dr("RetIVA").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3) + "%" - LblRetISR.Text = Math.Round((dr("RetISR").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3) - If dr("TipoFactura").ToString <> "CFDi" Then LblTipoFact.Text = dr("TipoFactura").ToString : divTipoFactura.Visible = True - ViewState("CveFactura") = dr("CveFactura").ToString.ToEntero - ViewState("IdPoliza") = dr("IdPoliza").ToString.ToEntero - - DdlMoneda.SelectedValue = dr("CveMoneda").ToString - 'primero se asigna la moneda, para que dentro del proveedor carge los anticipos solo de esa moneda - DdlProveedor.Visible = False - HplProveedor.Visible = True - CargaProveedor(CveProveedor, "-1") - - - DdlRetIVAConcepto.SelectedValueExist(dr("CveRetIVAConcepto").ToString) + End Sub + + ''' + ''' Método que convierte el IEPS en un concepto para no ajustar totales + ''' + Private Sub AgregarConceptoIEPS(IEPS As Decimal, CvePS1 As Integer) + Dim SubTotalR As Decimal = TmpDT.SUM("Total").ToString.ToDecimal + + Dim PSS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + Dim PSS2 As DataTable = TmpDT.FiltraParametros(String.Format("CvePS = {0} ", CvePS1), "PS") + + If PSS.Rows.Count > 0 Or PSS2.Rows.Count > 0 Then + Dim CveUM As Integer = 0 + Dim UM As String = "" + Dim CveClasificacion As Integer = 0 + Dim Clasificacion As String = "" + Dim CvePS As Integer = 0 + Dim PS As String = "" + Dim CveTipoPS As Integer = 0 + + If PSS.Rows.Count > 0 Then + CveUM = PSS.Rows(0)("CveUM").ToString.ToEntero + UM = PSS.Rows(0)("UnidadMedida").ToString + CveClasificacion = PSS.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS.Rows(0)("Clasificacion").ToString + CvePS = PSS.Rows(0)("CvePS").ToString.ToEntero + PS = PSS.Rows(0)("PS").ToString + CveTipoPS = PSS.Rows(0)("CveTipoPS").ToString.ToEntero + End If + + Dim Cantidad As Double = 1 + Dim CveSubProyectoContrato As String = "-1" + Dim CveProyecto As String = "-1" + Dim SubProyecto As String = "SE" + Dim Proyecto As String = "SE" + Dim Obs As String = "" + Dim PU As Double = IEPS + Dim Total As Double = Cantidad * PU + Dim IVA As Double = 0 + Dim Descuento As Double = 0 + + If PSS2.Rows.Count > 0 Then + CveUM = PSS2.Rows(0)("CveUM").ToString.ToEntero + UM = PSS2.Rows(0)("UM").ToString + CveClasificacion = PSS2.Rows(0)("CveClasificacion").ToString.ToEntero + Clasificacion = PSS2.Rows(0)("Clasificacion").ToString + CvePS = PSS2.Rows(0)("CvePS").ToString.ToEntero + PS = PSS2.Rows(0)("PS").ToString + CveTipoPS = PSS2.Rows(0)("CveTipoPS").ToString.ToEntero + + CveSubProyectoContrato = PSS2.Rows(0)("CveSubProyecto").ToString + CveProyecto = PSS2.Rows(0)("CveProyecto").ToString + SubProyecto = PSS2.Rows(0)("SubProyecto").ToString + Proyecto = PSS2.Rows(0)("Proyecto").ToString + Obs = PSS2.Rows(0)("Obs").ToString + + Dim CveTipoGasto As Integer = PSS2.Rows(0)("CveTipoGasto").ToString.ToEntero + Dim TipoGasto As String = PSS2.Rows(0)("TipoGasto").ToString + + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) + AddPS2() + Else + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, TCalculaTotales:=False) + AddPS2() + End If + End If + + Dim SubTotalIEPS = TmpDT.SUM("Total").ToString.ToDecimal + + SubTotal = Math.Round(SubTotalIEPS, 2) + SubTotalConceptos = Math.Round(SubTotalIEPS, 2) + + 'If SubTotalR <> SubTotalIEPS Then + ' Dim IA As Decimal = SubTotalR - SubTotalIEPS + ' AjustaImporteUltimoConcepto(IA) + 'End If + + PSS.Dispose() + End Sub + + Private Sub CargaCompra() + Dim ObjCompra As New ClsCompras() + Dim ObjOC As New ClsOC() + + If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + + CompraCargada = True + + 'data-toggle="tooltip" data-placement="left" title="Agregar Escolaridad ." + If ObjCompra.DtResultados.Rows(0)("FolioREQ").ToString <> "" Then + lblOCLabel.Attributes.Add("data-toggle", "tooltip") + lblOCLabel.Attributes.Add("data-placement", "top") + lblOCLabel.Attributes.Add("title", "REQ: " & ObjCompra.DtResultados.Rows(0)("FolioREQ").ToString) + End If + + 'CargaProveedor + Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) + Saldo = dr("Saldo").ToString.ToDecimal + RBLPago.Visible = False + Dim CveProveedor As Integer = dr("CveProveedor").ToString.ToEntero + + HdnCveProveedor.Value = CveProveedor.ToString + ViewState("CveProveedor") = CveProveedor + + ImgBtnBuscarOC.OnClientClick = String.Format("AbrirVentana('/OC/PopUpBuscarReq.aspx?V=VOCCOMP&P={0}&T={1}&Masterimpoup=true',1000,600,'S'); return false;", CveProveedor, DdlTipoComprobante.SelectedValue) + + + Dim ObjBancos As New ClsBancos() + + If ObjBancos.GetCreditosCompra(CveCompra) And ObjBancos.DtResultados.Rows.Count > 0 Then + GvCreditosRelacionados.DataSource = ObjBancos.DtResultados + GvCreditosRelacionados.Visible = True + GvCreditosRelacionados.DataBind() + romCreditosTabla.Visible = True + GvCreditos.Visible = False + GvCreditosRelacionados.Visible = True + + PnlContadoCreditos.Visible = True + Else + GvCreditosRelacionados.DataSource = Nothing + GvCreditosRelacionados.Visible = False + GvCreditosRelacionados.DataBind() + + End If + UpGvCreditos.Update() + LblImporteCreditos.Visible = True + ObjBancos.Dispose() + + 'RegistraScript("CargaProveedor(""" & CveProveedor & """);") + + 'CargaEncabezado + 'ViewState("FolioFiscal") = ObjCompra.DtResultados.Rows(0)("FolioFiscal").ToString + TxtSerie.Text = dr("Serie").ToString + TxtFolio.Text = dr("Folio").ToString + TxtFolioSecundario.Text = dr("FolioSecundario").ToString + TxtFecha.Text = dr("Fecha").ToString.ToDate.ToShortDateString + TxtDescripcion.Text = dr("Descripcion").ToString + CvePrePoliza = dr("CvePrePoliza").ToString.ToEntero + EstatusAlmacen = dr("EstatusAlmacen").ToString.ToEntero + DdlTipoCompra.SelectedValueExist(dr("CveTipoCompra")) + 'Select Case dr("PorcentajeIVA").ToString.ToDouble + ' Case 0 + ' DdlIVA.SelectedValue = "1" + ' Case 0.16 + ' DdlIVA.SelectedValue = "1.16" + ' Case 0.08 + ' DdlIVA.SelectedValue = "1.08" + 'End Select + 'If dr("PorcentajeIVA").ToString.ToDouble = 0 Then DdlIVA.SelectedValue = "1" Else DdlIVA.SelectedValue = "1.16" + + LblMetodoPago.Text = dr("MetodoPagoSAT").ToString + + If UsuarioActual.Empresa.UsaAC Then + CambiaEjercicioAC(False) + End If + + If GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).Rows.Count > 0 Then + RowProveedorSucursal.Visible = True + DdlProveedorSucursal.Items.Clear() + DdlProveedorSucursal.DataSource = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa) + DdlProveedorSucursal.DataBind() + DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) + DdlProveedorSucursal.SelectedValueExist(dr("CveProveedorSucursal").ToString.ToEntero) + End If + + ''SE AJUSTO EL SUBTOTAL POR LA COMPRA # 52433 DE LA EMPRESA 48 PARA QUE CUADREN LOS TOTALES CUANDO VIENE CON DESCUENTOS + 'TxtSubTotal.Text = (dr("SubTotal").ToString.ToDouble + dr("Descuentos").ToString.ToDouble).FormatoNumero(2) + TxtSubTotal.Text = (dr("SubTotal").ToString.ToDouble).FormatoNumero + 'TxtSubTotal2.Text = (dr("SubTotal").ToString.ToDouble).FormatoNumero + TxtSubTotal2.Text = (dr("SubTotal").ToString.ToDouble - dr("Descuentos").ToString.ToDouble).FormatoNumero(2) + + TxtDescuento.Text = dr("Descuentos").ToString.FormatoNumero(2) + LblAmortizacion.Text = dr("Amortizacion").ToString.FormatoNumero(2) + TxtIVA.Text = dr("IVA").ToString.FormatoNumero(2) + TxtRetIVA.Text = dr("RetIVA").ToString.FormatoNumero(2) + TxtRetISR.Text = dr("RetISR").ToString.FormatoNumero(2) + TxtIEPS.Text = dr("IEPS").ToString.FormatoNumero(2) + If dr("IEPS").ToString.ToDouble > 0 Then TrIEPS.Visible = True + If dr("RetIVA").ToString.ToDouble > 0 Then TrRetIVA.Visible = True + If dr("RetISR").ToString.ToDouble > 0 Then TrRetISR.Visible = True + If Math.Abs(dr("Redondeo").ToString.ToDouble) > 0 Then TrRedondeo.Visible = True + TxtRedondeo.Text = dr("Redondeo").ToString.FormatoNumero(2) + + TxtOtrosImpuestos.Text = dr("OtrosImpuestos").ToString.FormatoNumero(2) + If dr("OtrosImpuestos").ToString.ToDouble > 0 Then TrOtrosImpuestos.Visible = True + TxtTotal.Text = dr("Total").ToString.FormatoNumero(2) + + HfTotalCompra.Value = TxtTotal.Text + CompraSaldo = TxtTotal.Text.ToDouble + + TipoCambio = dr("TipoCambio").ToString.ToDouble + Dim TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDouble + If TipoCambio > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) + If TipoCambio <> TipoCambioOriginal Then LblTCO.Text = String.Format("
TC Original: {0}", TipoCambioOriginal.ToString("N4")) + + + AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) + CalculaTotalPorDevengar() + TxtDocumentoImporteFE.Text = dr("Total").ToString + RVDocumentoImporte.MaximumValue = dr("Total").ToString.FormatoNumero(2) + RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + + HFDiferenciaCompra.Value = TxtTotal.Text + + + + TotalGeneral = dr("Total").ToString.ToDouble + CveMoneda = dr("CveMoneda").ToString.ToEntero + DdlValidadaSAT.SelectedValue = "Si" + TxtObsFact.Text = dr("Observaciones").ToString + LblUsuarioCaptura.Text = dr("Usuario").ToString + LitFechCaptura.Text = dr("FechaIng").ToString.ToDate.ToShortDateString + LblRetIVA.Text = Math.Round((dr("RetIVA").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3) + "%" + LblRetISR.Text = Math.Round((dr("RetISR").ToString.ToDouble / TxtSubTotal2.Text.ToDouble) * 100, 4).FormatoNumero(3) + If dr("TipoFactura").ToString <> "CFDi" Then LblTipoFact.Text = dr("TipoFactura").ToString : divTipoFactura.Visible = True + ViewState("CveFactura") = dr("CveFactura").ToString.ToEntero + ViewState("IdPoliza") = dr("IdPoliza").ToString.ToEntero + + DdlMoneda.SelectedValue = dr("CveMoneda").ToString + 'primero se asigna la moneda, para que dentro del proveedor carge los anticipos solo de esa moneda + DdlProveedor.Visible = False + HplProveedor.Visible = True + CargaProveedor(CveProveedor, "-1") + + + DdlRetIVAConcepto.SelectedValueExist(dr("CveRetIVAConcepto").ToString) DdlRetISRConcepto.SelectedValueExist(dr("CveRetISRConcepto").ToString) - If dr("CveTipoConcepto").ToString.ToEntero = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:" - - HdnCveEstatusFactura.Value = dr("CveEstatusFactura").ToString - LblCompraEstatus.Text = dr("EstatusFactura").ToString - If dr("CveEstatusFactura").ToString = "2" Then ChkProgramarPago.Checked = True - - TrRembolsoUpdate.Visible = True - TrRembolsoNumero.Visible = True - - Dim DtPersonal = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltraParametros("", "NombreCompleto") - DdlRembolsoPersonal.DataSource = DtPersonal - DdlRembolsoPersonal.Items.Insert(0, New ListItem("Sin Seleccionar", "-1")) - DdlRembolsoPersonal.DataBind() - If dr("CvePersonal").ToString.ToEntero > 0 Then - DdlRembolsoPersonal.SelectedValueExist(dr("CvePersonal").ToString) - TxtRembolsoNumero.Text = dr("NumeroReembolso").ToString - RblRembolso.SelectedValuesIfExist("1") - TrRembolsoPersonal.Visible = True - End If - - Dim DtCajaChica As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) - DtCajaChica = DtCajaChica.FiltraParametros(String.Format("CveTipoCuenta = 1")) - DdlRembolsoCajaChica.DataSource = DtCajaChica - DdlRembolsoCajaChica.Items.Insert(0, New ListItem("Sin Seleccionar", "-1")) - DdlRembolsoCajaChica.DataBind() - If dr("CveCajaChica").ToString.ToEntero > 0 Then - DdlRembolsoCajaChica.SelectedValueExist(dr("CveCajaChica").ToString) - TxtRembolsoNumero.Text = dr("NumeroReembolso").ToString - RblRembolso.SelectedValuesIfExist("2") - TrRembolsoCajaChica.Visible = True - End If - - VisualizaEstatusCompraSaldo(dr("TipoDocto").ToString, dr("Saldo").ToString.ToDecimal, dr("Total").ToString.ToDecimal) - If dr("IdPoliza").ToString.ToEntero > 0 Then - HplCompraContabilizada.Text = "Si" - HplCompraContabilizada.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) - LblCompraEstatus.ForeColor = Drawing.Color.Navy - trContabilizada.Visible = True - If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True - Else - BtnDescontabilizar.Visible = False - HplCompraContabilizada.Text = "No" - trContabilizada.Visible = True - If UsuarioActual.Empresa.UsaAC Then - LBContabilizarAC.Visible = True - End If - End If - UPPDescontablizar.Update() - - TxtFechaPago.Text = dr("FechaVencimiento").ToString.ToDate.ToShortDateString - RowBitacora.Visible = True - CargaEventoBitacora() - 'ImgAddObs.Attributes.Add("onclick", "javascript: PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ") - ImgAddObs.Visible = True - ChkAplicaNotaCredito.Checked = CBool(dr("AplicaNotaCredito").ToString) - 'RBLPago.Enabled = False - 'If dr("CveIE").ToString.ToEntero > 0 Then - ' RBLPago.SelectedValue = "2" - ' 'cargo los datos del pago - ' 'PnlPago.Visible = True - ' 'PnlChkFuncionariosEmpleados.Visible = True - - ' Dim ObjIE As New ClsBancos() - - ' If ObjIE.GetBancosIE(dr("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - ' If ObjIE.DtResultados.Rows.Count > 0 Then - - ' DdlTipoTransaccion.SelectedValue = ObjIE.CveTipoTransaccion.ToString - ' DdlCuenta.SelectedValue = ObjIE.CveCuenta.ToString - ' TxtDocumentoFolio.Text = ObjIE.Folio - ' TxtDocumentoImporte.Text = ObjIE.Importe.FormatoNumero - ' TxtDocumentoObservaciones.Text = ObjIE.Observaciones - - ' End If - ' End If - - ' ObjIE.Dispose() - 'End If - CompraSaldo = TotalGeneral - LblAmortizacion.Text.ToDouble - If EmpresaPrueba Then - CompraSaldo = dr("Saldo").ToString.ToDouble - End If - - If CompraSaldo > dr("Saldo").ToString.ToDouble Then - CompraSaldo = dr("Saldo").ToString.ToDouble - End If - HdnCompraSaldo.Value = CompraSaldo.ToString - - If CompraSaldo > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIECompras.aspx?CveCompra={CveCompra}&TB_iframe=true&height=520&width=700" - End If - - If dr("CveFactura").ToString.ToEntero > 0 Then - ImgDownXML.Visible = True : ImgDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Fact&EXT=xml&CveFactura={0}&RFC={1}", dr("CveFactura"), dr("RFC").ToString.Replace("&", "%26%")))) - ImgDownPDF.Visible = True : ImgDownPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Fact&EXT=pdf&CveFactura={0}&RFC={1}", dr("CveFactura"), dr("RFC").ToString.Replace("&", "%26%")))) - End If - - 'CargaDetalle - If ObjCompra.GetCompraDetalle(CveCompra) Then - TmpDT = ObjCompra.DtResultados - TmpDTOriginal = ObjCompra.DtResultados.Copy - - TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer)) - 'TmpDT.Columns.Add("CveEq", GetType(Integer)) - TmpDT.Columns.Add("CveAlmacen", GetType(Integer)) - 'TmpDT.Columns.Add("CvePersonal", GetType(Integer)) - - TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer)) - - TmpDT.Columns.Add("PSDescripcion", GetType(String)) - TmpDT.Columns.Add("ProductoOC", GetType(String)) - TmpDT.Columns.Add("CantidadF", GetType(Double)) - - 'Consignaciones - TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) - TmpDT.Columns.Add("NoConsignacion", GetType(Integer)) - TmpDT.Columns.Add("CveConsignacion", GetType(Integer)) - TmpDT.Columns.Add("HdnPS", GetType(String)) - TmpDT.Columns.Add("HdnCvePS", GetType(String)) - TmpDT.Columns.Add("HdnClasificacion", GetType(String)) - TmpDT.Columns.Add("HdnCveClasificacion", GetType(String)) - TmpDT.Columns.Add("HdnCveAlmacen", GetType(String)) - - 'INVENTARIO SERIE/LOTE - TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer)) - - 'Fletes y Servicios - 'TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) 'Ya traemos el estatus flete - TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - - TmpDT.Columns.Add("CveContrato", GetType(Integer)) - - - - GvPS.DataSource = TmpDT - GvPS.DataBind() - - If UsuarioActual.Empresa.UsaAC Then - CargaHidendsAC() - End If - - CalculaTotales(True) - - If UsuarioActual.Empresa.UsaInventarios Then - DtInv = TmpDT.FiltraParametros(String.Format("CveTipoPS = 2")).Copy - - If dr("Inventario").ToString = "1" Then - - CveMovimientoAlmacen = dr("CveMovimiento").ToString.ToEntero - - Dim Inv As New ClsInventarios - If Inv.GetMovimientosDetalle(dr("CveMovimiento").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - 'Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", dr("CveMovimiento"))) - 'ImgImprimirAlmacen.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", TempParametros) - - ImgImprimirAlmacen.Visible = True - ImgImprimirAlmacen.NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", dr("CveMovimiento")) - - Dim drt As DataRow - 'actualizo el almacen - For Each dri As DataRow In DtInv.Rows - - drt = Inv.DtResultados.FiltroPrimero(String.Format("CvePS = {0} AND Cantidad = {1}", dri("CvePS"), dri("Cantidad"))) - If drt IsNot Nothing Then - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dri("Consec").ToString.ToEntero}")(0) 'Charlie - TmpDr("CveAlmacen") = drt("CveAlmacen") 'Charlie - - dri("CveAlmacen") = drt("CveAlmacen") - - End If - - Next - - End If - - 'Proceso Super Tramposo de Charlie - If Inv.GetMovimientosDetalle(dr("CveMovimiento").ToString.ToEntero, UsuarioActual.CveEmpresa, CveCompra:=-123) Then - Dim drt As DataRow - For Each dri As DataRow In DtInv.Rows - drt = Inv.DtResultados.FiltroPrimero(String.Format("CvePS = {0} AND Cantidad = {1}", dri("CvePS"), dri("Cantidad"))) - If drt IsNot Nothing Then - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dri("Consec").ToString.ToEntero}")(0) - TmpDr("CveAlmacen") = drt("CveAlmacen") - End If - Next - End If - - Inv.Dispose() - - End If - - CargaGvInv() - - 'Ocultamos "Recibir Aqui" - GvInv.Columns(6).Visible = False - GvInv.Columns(7).Visible = False - - End If - End If - - DdlTipoComprobante.Enabled = False - DdlTipoComprobante.SelectedValue = dr("TipoDocto").ToString - If dr("TipoDocto").ToString = "Fac" Then - ChkAplicaNotaCredito.Enabled = True - ImgAnticiposPendientes.Visible = True - Else - ImgAnticiposPendientes.Visible = False - ChkAplicaNotaCredito.Enabled = False - End If - HlProveedor.HRef = "" - TxtCodigo.ReadOnly = True - 'IPP Usuario Sistema No Bloquea, se cambió al proceso - If UsuarioActual.TienePermisoProceso(79) Then - TxtCantidad.Enabled = True - TxtPrecio.Enabled = True - Else - TxtCantidad.Enabled = False - TxtPrecio.Enabled = False - End If - - DdlPS.Enabled = False - TxtObsPS.Enabled = False - 'ImgAmort.Attributes.Clear() - LbAgregar.Enabled = False - TxtSerie.Enabled = False + If dr("CveTipoConcepto").ToString.ToEntero = 1 Then LblProveedor.Text = "Proveedor:" Else LblProveedor.Text = "Acreedor:" + + HdnCveEstatusFactura.Value = dr("CveEstatusFactura").ToString + LblCompraEstatus.Text = dr("EstatusFactura").ToString + If dr("CveEstatusFactura").ToString = "2" Then ChkProgramarPago.Checked = True + + TrRembolsoUpdate.Visible = True + TrRembolsoNumero.Visible = True + + Dim DtPersonal = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltraParametros("", "NombreCompleto") + DdlRembolsoPersonal.DataSource = DtPersonal + DdlRembolsoPersonal.Items.Insert(0, New ListItem("Sin Seleccionar", "-1")) + DdlRembolsoPersonal.DataBind() + If dr("CvePersonal").ToString.ToEntero > 0 Then + DdlRembolsoPersonal.SelectedValueExist(dr("CvePersonal").ToString) + TxtRembolsoNumero.Text = dr("NumeroReembolso").ToString + RblRembolso.SelectedValuesIfExist("1") + TrRembolsoPersonal.Visible = True + End If + + Dim DtCajaChica As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) + DtCajaChica = DtCajaChica.FiltraParametros(String.Format("CveTipoCuenta = 1")) + DdlRembolsoCajaChica.DataSource = DtCajaChica + DdlRembolsoCajaChica.Items.Insert(0, New ListItem("Sin Seleccionar", "-1")) + DdlRembolsoCajaChica.DataBind() + If dr("CveCajaChica").ToString.ToEntero > 0 Then + DdlRembolsoCajaChica.SelectedValueExist(dr("CveCajaChica").ToString) + TxtRembolsoNumero.Text = dr("NumeroReembolso").ToString + RblRembolso.SelectedValuesIfExist("2") + TrRembolsoCajaChica.Visible = True + End If + + VisualizaEstatusCompraSaldo(dr("TipoDocto").ToString, dr("Saldo").ToString.ToDecimal, dr("Total").ToString.ToDecimal) + If dr("IdPoliza").ToString.ToEntero > 0 Then + HplCompraContabilizada.Text = "Si" + HplCompraContabilizada.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) + LblCompraEstatus.ForeColor = Drawing.Color.Navy + trContabilizada.Visible = True + If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True + Else + BtnDescontabilizar.Visible = False + HplCompraContabilizada.Text = "No" + trContabilizada.Visible = True + If UsuarioActual.Empresa.UsaAC Then + LBContabilizarAC.Visible = True + End If + End If + UPPDescontablizar.Update() + + TxtFechaPago.Text = dr("FechaVencimiento").ToString.ToDate.ToShortDateString + RowBitacora.Visible = True + CargaEventoBitacora() + 'ImgAddObs.Attributes.Add("onclick", "javascript: PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ") + ImgAddObs.Visible = True + ChkAplicaNotaCredito.Checked = CBool(dr("AplicaNotaCredito").ToString) + 'RBLPago.Enabled = False + 'If dr("CveIE").ToString.ToEntero > 0 Then + ' RBLPago.SelectedValue = "2" + ' 'cargo los datos del pago + ' 'PnlPago.Visible = True + ' 'PnlChkFuncionariosEmpleados.Visible = True + + ' Dim ObjIE As New ClsBancos() + + ' If ObjIE.GetBancosIE(dr("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + + ' DdlTipoTransaccion.SelectedValue = ObjIE.CveTipoTransaccion.ToString + ' DdlCuenta.SelectedValue = ObjIE.CveCuenta.ToString + ' TxtDocumentoFolio.Text = ObjIE.Folio + ' TxtDocumentoImporte.Text = ObjIE.Importe.FormatoNumero + ' TxtDocumentoObservaciones.Text = ObjIE.Observaciones + + ' End If + ' End If + + ' ObjIE.Dispose() + 'End If + CompraSaldo = TotalGeneral - LblAmortizacion.Text.ToDouble + If EmpresaPrueba Then + CompraSaldo = dr("Saldo").ToString.ToDouble + End If + + If CompraSaldo > dr("Saldo").ToString.ToDouble Then + CompraSaldo = dr("Saldo").ToString.ToDouble + End If + HdnCompraSaldo.Value = CompraSaldo.ToString + + If CompraSaldo > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIECompras.aspx?CveCompra={CveCompra}&TB_iframe=true&height=520&width=700" + End If + + If dr("CveFactura").ToString.ToEntero > 0 Then + ImgDownXML.Visible = True : ImgDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Fact&EXT=xml&CveFactura={0}&RFC={1}", dr("CveFactura"), dr("RFC").ToString.Replace("&", "%26%")))) + ImgDownPDF.Visible = True : ImgDownPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Fact&EXT=pdf&CveFactura={0}&RFC={1}", dr("CveFactura"), dr("RFC").ToString.Replace("&", "%26%")))) + End If + + 'CargaDetalle + If ObjCompra.GetCompraDetalle(CveCompra) Then + TmpDT = ObjCompra.DtResultados + TmpDTOriginal = ObjCompra.DtResultados.Copy + + TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer)) + 'TmpDT.Columns.Add("CveEq", GetType(Integer)) + TmpDT.Columns.Add("CveAlmacen", GetType(Integer)) + 'TmpDT.Columns.Add("CvePersonal", GetType(Integer)) + + TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer)) + + TmpDT.Columns.Add("PSDescripcion", GetType(String)) + TmpDT.Columns.Add("ProductoOC", GetType(String)) + TmpDT.Columns.Add("CantidadF", GetType(Double)) + + 'Consignaciones + TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) + TmpDT.Columns.Add("NoConsignacion", GetType(Integer)) + TmpDT.Columns.Add("CveConsignacion", GetType(Integer)) + TmpDT.Columns.Add("HdnPS", GetType(String)) + TmpDT.Columns.Add("HdnCvePS", GetType(String)) + TmpDT.Columns.Add("HdnClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveAlmacen", GetType(String)) + + 'INVENTARIO SERIE/LOTE + TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer)) + + 'Fletes y Servicios + 'TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) 'Ya traemos el estatus flete + TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + + TmpDT.Columns.Add("CveContrato", GetType(Integer)) + + + + GvPS.DataSource = TmpDT + GvPS.DataBind() + + If UsuarioActual.Empresa.UsaAC Then + CargaHidendsAC() + End If + + CalculaTotales(True) + + If UsuarioActual.Empresa.UsaInventarios Then + DtInv = TmpDT.FiltraParametros(String.Format("CveTipoPS = 2")).Copy + + If dr("Inventario").ToString = "1" Then + + CveMovimientoAlmacen = dr("CveMovimiento").ToString.ToEntero + + Dim Inv As New ClsInventarios + If Inv.GetMovimientosDetalle(dr("CveMovimiento").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + 'Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", dr("CveMovimiento"))) + 'ImgImprimirAlmacen.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", TempParametros) + + ImgImprimirAlmacen.Visible = True + ImgImprimirAlmacen.NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", dr("CveMovimiento")) + + Dim drt As DataRow + 'actualizo el almacen + For Each dri As DataRow In DtInv.Rows + + drt = Inv.DtResultados.FiltroPrimero(String.Format("CvePS = {0} AND Cantidad = {1}", dri("CvePS"), dri("Cantidad"))) + If drt IsNot Nothing Then + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dri("Consec").ToString.ToEntero}")(0) 'Charlie + TmpDr("CveAlmacen") = drt("CveAlmacen") 'Charlie + + dri("CveAlmacen") = drt("CveAlmacen") + + End If + + Next + + End If + + 'Proceso Super Tramposo de Charlie + If Inv.GetMovimientosDetalle(dr("CveMovimiento").ToString.ToEntero, UsuarioActual.CveEmpresa, CveCompra:=-123) Then + Dim drt As DataRow + For Each dri As DataRow In DtInv.Rows + drt = Inv.DtResultados.FiltroPrimero(String.Format("CvePS = {0} AND Cantidad = {1}", dri("CvePS"), dri("Cantidad"))) + If drt IsNot Nothing Then + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dri("Consec").ToString.ToEntero}")(0) + TmpDr("CveAlmacen") = drt("CveAlmacen") + End If + Next + End If + + Inv.Dispose() + + End If + + CargaGvInv() + + 'Ocultamos "Recibir Aqui" + GvInv.Columns(6).Visible = False + GvInv.Columns(7).Visible = False + + End If + End If + + DdlTipoComprobante.Enabled = False + DdlTipoComprobante.SelectedValue = dr("TipoDocto").ToString + If dr("TipoDocto").ToString = "Fac" Then + ChkAplicaNotaCredito.Enabled = True + ImgAnticiposPendientes.Visible = True + Else + ImgAnticiposPendientes.Visible = False + ChkAplicaNotaCredito.Enabled = False + End If + HlProveedor.HRef = "" + TxtCodigo.ReadOnly = True + 'IPP Usuario Sistema No Bloquea, se cambió al proceso + If UsuarioActual.TienePermisoProceso(79) Then + TxtCantidad.Enabled = True + TxtPrecio.Enabled = True + Else + TxtCantidad.Enabled = False + TxtPrecio.Enabled = False + End If + + DdlPS.Enabled = False + TxtObsPS.Enabled = False + 'ImgAmort.Attributes.Clear() + LbAgregar.Enabled = False + TxtSerie.Enabled = False TxtFolio.Enabled = False TxtFecha.Enabled = UsuarioActual.TienePermisoProceso(216) ImgFecha.Enabled = UsuarioActual.TienePermisoProceso(216) - CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216) - - DdlProveedor.Enabled = False - DdlProveedorSucursal.Enabled = False - DdlEstatus.Enabled = False - DdlMoneda.Enabled = False - DdlRetIVAConcepto.Enabled = False - DdlRetISRConcepto.Enabled = False - If UsuarioActual.TienePermisoProceso(79) Then - BtnActualizar.Visible = True - DdlProveedorSucursal.Enabled = True - DdlPS.Enabled = True - TxtObsPS.Enabled = True - LbAgregar.Enabled = True - LnkUpdateFechaPago.Visible = True - End If - - BtnGuardar.Visible = False - BtnGuardar.Enabled = False - UpPSS.Update() - - 'GvLeyendasFiscales.Enabled = False - TxtSubTotal.ReadOnly = True - TxtIVA.ReadOnly = True - TxtRetIVA.ReadOnly = True - TxtRetISR.ReadOnly = True - TxtIEPS.ReadOnly = True - TxtOtrosImpuestos.ReadOnly = True - TxtTotal.ReadOnly = True - - - 'CargaLeyendasFiscales - ViewState("CompraFolio") = TxtFolio.Text.Trim - - Dim dtnc As DataTable = Nothing - If dr("TipoDocto").ToString = "Fac" Then - 'carga as notas de credito vinculadas - If ObjCompra.GetComprasNotasCredito(CveCompra, -1) Then - dtnc = ObjCompra.DtResultados - End If - ElseIf dr("TipoDocto").ToString.Contiene("NC", "DEV", "Ant") Then - If dr("TipoDocto").ToString = "NC" Then - DivReembolso.Visible = False - RBLPago.Items(2).Enabled = False - End If - If ObjCompra.GetComprasNotasCredito(-1, CveCompra) Then - dtnc = ObjCompra.DtResultados - GvAnticiposSel.Caption = "
Compras Aplicadas
" - End If - End If - - - 'VINCULACIÓN OC - NUEVA DICIEMBRE 2015 - If dr("OCVinculada").ToString() <> "" Then - Dim DtOCs As New DataTable - Dim OCS = "", CveOCS = "" - - DtOCs.Columns.Add("FolioOC", GetType(Integer)) - DtOCs.Columns.Add("CveOrdenCompra", GetType(Integer)) - - - For Each drt As DataRow In TmpDT.Rows - If drt("FolioOC").ToString <> "" Then - Dim DrOC = DtOCs.NewRow - DrOC("FolioOC") = drt("FolioOC").ToString - DrOC("CveOrdenCompra") = drt("CveOrdenCompra").ToString - DtOCs.Rows.Add(DrOC) - End If - Next - - DtOCs = DtOCs.FiltraParametros("", "", {"FolioOC", "CveOrdenCompra"}) - DtOCs.Columns.Add("Fecha", GetType(Date)) - DtOCs.Columns.Add("Descripcion", GetType(String)) - - If DtOCs.Rows.Count > 0 Then - For Each drt As DataRow In DtOCs.Rows - If ObjOC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, drt("CveOrdenCompra").ToString.ToEntero, CveProveedor, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then - If ObjOC.DtResultados.Rows.Count = 1 Then - OCS += If(OCS <> "", String.Format(",{0}", drt("FolioOC").ToString), drt("FolioOC").ToString) - CveOCS += If(CveOCS <> "", String.Format(",{0}", drt("CveOrdenCompra").ToString), drt("CveOrdenCompra").ToString) - drt("Fecha") = ObjOC.DtResultados.FiltroPrimeroValor("FechaIng") - drt("Descripcion") = ObjOC.DtResultados.FiltroPrimeroValor("Descripcion") - End If - End If - Next - End If - - TxtOC.Text = OCS - TieneOC = True - - If DtOCs.Rows.Count > 1 Then - HLOCsVinculadas.Visible = True - GvOCsVinculadas.DataSource = DtOCs - GvOCsVinculadas.DataBind() - UpOCsVinculadas.Update() - ElseIf DtOCs.Rows.Count = 1 Then - HLOCsVinculadas.Visible = True - HLOCsVinculadas.Attributes.Remove("data-toggle") - HLOCsVinculadas.Attributes.Remove("data-target") - HLOCsVinculadas.Attributes.Add("data-toggle", "tooltip") - HLOCsVinculadas.NavigateUrl = $"/OC/OC.aspx?OC={DtOCs.FiltroPrimeroValor("CveOrdenCompra")}" - HLOCsVinculadas.Target = "_blank" - End If - - - End If - - 'BLOQUEA OC - TxtOC.Enabled = False - ImgBtnBuscarOC.Visible = False - TAB.ActiveTabIndex = 0 - - GvAnticiposSel.DataSource = dtnc - GvAnticiposSel.DataBind() - - - '' VALIDA ELIMINAR COMPRA - If UsuarioActual.TienePermisoProceso(77) OrElse UsuarioActual.TienePermisoProceso(135) Then ' Eliminar compra - - 'SIN VINCULACIÓN - If UsuarioActual.TienePermisoProceso(135) Then - If TxtOC.Text = "" AndAlso IdPoliza < 1 AndAlso CveMovimientoAlmacen < 1 AndAlso LblUsuarioCaptura.Text = UsuarioActual.Usuario AndAlso TmpDT.MAX("CveActivoFijo").ToEntero < 1 AndAlso Not ChkProgramarPago.Checked AndAlso CompraSaldo = TxtTotal.Text.ToDouble Then - BtnEliminarCompra.Visible = True - End If - End If - - 'ELIMINAR A FUERZAS - If UsuarioActual.TienePermisoProceso(77) Then - If Not (IdPoliza > 0) Then - BtnEliminarCompra.Visible = True - End If - End If - - - Dim StrInventario As String = "" - If dr("Inventario").ToString = "1" Then - StrInventario = "los Movimientos de Inventario relacionados" - End If - - If UsuarioActual.Empresa.UsaAC Then - BtnEliminarCompra.Attributes.Add("data-original-title", String.Format("¿Está seguro que desea eliminar la Compra, {0} y la Poliza Asociada?", StrInventario)) - Else - BtnEliminarCompra.Attributes.Add("data-original-title", String.Format("¿Está seguro que desea eliminar la Compra y {0}?", StrInventario)) - End If - End If - - 'VALIDA CANCELAR COMPRA - AC - ValidaCancelarCompra() - - 'CUANDO ESTA CANCELADA - If dr("CveEstatusFactura").ToString = "-2" Then - BtnEliminarCompra.Visible = False - BtnActualizar.Visible = False - BtnGuardar.Visible = False - BtnCancelarCompra.Visible = False - - LblCompraEstatus.Text = "CANCELADA" - LblCompraEstatus.Font.Bold = True - LblCompraEstatus.Font.Size = 12 - LblCompraEstatus.ForeColor = Drawing.Color.DarkRed - 'HplIr.Visible = False - - BtnDescontabilizar.Visible = False - BtnEliminarPolizaMultiple.Visible = False - - 'LIGA POLIZA CANCELACIÓN - 'HplPolizaCancelación.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) - - End If - - 'CUANDO FUE REFACTURADA - If dr("CompraRefacturada").ToString.ToEntero > 0 Then - BtnEliminarCompra.Visible = False - BtnActualizar.Visible = False - BtnGuardar.Visible = False - BtnCancelarCompra.Visible = False - End If - - 'TIENE AMORTIZACIÓN - If GvAnticiposSel.Rows.Count > 0 Then - BtnEliminarCompra.Visible = False - If Not DdlTipoComprobante.SelectedValue.Contiene("NC") Then - BtnCancelarCompra.Visible = False - End If - End If - - CargaComplementosPago() - - Else - Alert("La compra solicitada no se encontró. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("Ocurrió un error al cargar la compra. Por favor vuelta a intentar o comuniquese con Sistemas.", TipoMensaje.MsgError) - End If - - ObjCompra.Dispose() - ObjOC.Dispose() - End Sub - - Private Sub VisualizaEstatusCompraSaldo(TipoDocto As String, Saldo As Decimal, Total As Decimal) - - If TipoDocto.Contiene("Fac", "Ant") Then - - If HdnCveEstatusFactura.Value.ToEntero = 6 Then - LblCompraEstatus.Text = "Vinculada a Crédito" - LblCompraEstatus.Font.Bold = True - LblCompraEstatus.Font.Size = 12 - LblCompraEstatus.ForeColor = Drawing.Color.Navy - BtnAceptarAnticipos.Visible = False - trImporte.Visible = False - HplImporte.Visible = False - HplImporte.Text = "" - HplImporte.NavigateUrl = "" - - Else - If Saldo <= 0 Then - LblCompraEstatus.Text = "PAGADA" - LblCompraEstatus.Font.Bold = True - LblCompraEstatus.Font.Size = 12 - LblCompraEstatus.ForeColor = Drawing.Color.Navy - BtnAceptarAnticipos.Visible = False - trImporte.Visible = True - HplImporte.Visible = True - HplImporte.Text = String.Format("$ {0}", Total.FormatoNumero()) - HplImporte.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra) - - - Else - If Saldo < Total Then - LblCompraEstatus.Text = "ABONADA" + CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216) + + DdlProveedor.Enabled = False + DdlProveedorSucursal.Enabled = False + DdlEstatus.Enabled = False + DdlMoneda.Enabled = False + DdlRetIVAConcepto.Enabled = False + DdlRetISRConcepto.Enabled = False + If UsuarioActual.TienePermisoProceso(79) Then + BtnActualizar.Visible = True + DdlProveedorSucursal.Enabled = True + DdlPS.Enabled = True + TxtObsPS.Enabled = True + LbAgregar.Enabled = True + LnkUpdateFechaPago.Visible = True + End If + + BtnGuardar.Visible = False + BtnGuardar.Enabled = False + UpPSS.Update() + + 'GvLeyendasFiscales.Enabled = False + TxtSubTotal.ReadOnly = True + TxtIVA.ReadOnly = True + TxtRetIVA.ReadOnly = True + TxtRetISR.ReadOnly = True + TxtIEPS.ReadOnly = True + TxtOtrosImpuestos.ReadOnly = True + TxtTotal.ReadOnly = True + + + 'CargaLeyendasFiscales + ViewState("CompraFolio") = TxtFolio.Text.Trim + + Dim dtnc As DataTable = Nothing + If dr("TipoDocto").ToString = "Fac" Then + 'carga as notas de credito vinculadas + If ObjCompra.GetComprasNotasCredito(CveCompra, -1) Then + dtnc = ObjCompra.DtResultados + End If + ElseIf dr("TipoDocto").ToString.Contiene("NC", "DEV", "Ant") Then + If dr("TipoDocto").ToString = "NC" Then + DivReembolso.Visible = False + RBLPago.Items(2).Enabled = False + End If + If ObjCompra.GetComprasNotasCredito(-1, CveCompra) Then + dtnc = ObjCompra.DtResultados + GvAnticiposSel.Caption = "
Compras Aplicadas
" + End If + End If + + + 'VINCULACIÓN OC - NUEVA DICIEMBRE 2015 + If dr("OCVinculada").ToString() <> "" Then + Dim DtOCs As New DataTable + Dim OCS = "", CveOCS = "" + + DtOCs.Columns.Add("FolioOC", GetType(Integer)) + DtOCs.Columns.Add("CveOrdenCompra", GetType(Integer)) + + + For Each drt As DataRow In TmpDT.Rows + If drt("FolioOC").ToString <> "" Then + Dim DrOC = DtOCs.NewRow + DrOC("FolioOC") = drt("FolioOC").ToString + DrOC("CveOrdenCompra") = drt("CveOrdenCompra").ToString + DtOCs.Rows.Add(DrOC) + End If + Next + + DtOCs = DtOCs.FiltraParametros("", "", {"FolioOC", "CveOrdenCompra"}) + DtOCs.Columns.Add("Fecha", GetType(Date)) + DtOCs.Columns.Add("Descripcion", GetType(String)) + + If DtOCs.Rows.Count > 0 Then + For Each drt As DataRow In DtOCs.Rows + If ObjOC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, drt("CveOrdenCompra").ToString.ToEntero, CveProveedor, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then + If ObjOC.DtResultados.Rows.Count = 1 Then + OCS += If(OCS <> "", String.Format(",{0}", drt("FolioOC").ToString), drt("FolioOC").ToString) + CveOCS += If(CveOCS <> "", String.Format(",{0}", drt("CveOrdenCompra").ToString), drt("CveOrdenCompra").ToString) + drt("Fecha") = ObjOC.DtResultados.FiltroPrimeroValor("FechaIng") + drt("Descripcion") = ObjOC.DtResultados.FiltroPrimeroValor("Descripcion") + End If + End If + Next + End If + + TxtOC.Text = OCS + TieneOC = True + + If DtOCs.Rows.Count > 1 Then + HLOCsVinculadas.Visible = True + GvOCsVinculadas.DataSource = DtOCs + GvOCsVinculadas.DataBind() + UpOCsVinculadas.Update() + ElseIf DtOCs.Rows.Count = 1 Then + HLOCsVinculadas.Visible = True + HLOCsVinculadas.Attributes.Remove("data-toggle") + HLOCsVinculadas.Attributes.Remove("data-target") + HLOCsVinculadas.Attributes.Add("data-toggle", "tooltip") + HLOCsVinculadas.NavigateUrl = $"/OC/OC.aspx?OC={DtOCs.FiltroPrimeroValor("CveOrdenCompra")}" + HLOCsVinculadas.Target = "_blank" + End If + + + End If + + 'BLOQUEA OC + TxtOC.Enabled = False + ImgBtnBuscarOC.Visible = False + TAB.ActiveTabIndex = 0 + + GvAnticiposSel.DataSource = dtnc + GvAnticiposSel.DataBind() + + + '' VALIDA ELIMINAR COMPRA + If UsuarioActual.TienePermisoProceso(77) OrElse UsuarioActual.TienePermisoProceso(135) Then ' Eliminar compra + + 'SIN VINCULACIÓN + If UsuarioActual.TienePermisoProceso(135) Then + If TxtOC.Text = "" AndAlso IdPoliza < 1 AndAlso CveMovimientoAlmacen < 1 AndAlso LblUsuarioCaptura.Text = UsuarioActual.Usuario AndAlso TmpDT.MAX("CveActivoFijo").ToEntero < 1 AndAlso Not ChkProgramarPago.Checked AndAlso CompraSaldo = TxtTotal.Text.ToDouble Then + BtnEliminarCompra.Visible = True + End If + End If + + 'ELIMINAR A FUERZAS + If UsuarioActual.TienePermisoProceso(77) Then + If Not (IdPoliza > 0) Then + BtnEliminarCompra.Visible = True + End If + End If + + + Dim StrInventario As String = "" + If dr("Inventario").ToString = "1" Then + StrInventario = "los Movimientos de Inventario relacionados" + End If + + If UsuarioActual.Empresa.UsaAC Then + BtnEliminarCompra.Attributes.Add("data-original-title", String.Format("¿Está seguro que desea eliminar la Compra, {0} y la Poliza Asociada?", StrInventario)) + Else + BtnEliminarCompra.Attributes.Add("data-original-title", String.Format("¿Está seguro que desea eliminar la Compra y {0}?", StrInventario)) + End If + End If + + 'VALIDA CANCELAR COMPRA - AC + ValidaCancelarCompra() + + 'CUANDO ESTA CANCELADA + If dr("CveEstatusFactura").ToString = "-2" Then + BtnEliminarCompra.Visible = False + BtnActualizar.Visible = False + BtnGuardar.Visible = False + BtnCancelarCompra.Visible = False + + LblCompraEstatus.Text = "CANCELADA" + LblCompraEstatus.Font.Bold = True + LblCompraEstatus.Font.Size = 12 + LblCompraEstatus.ForeColor = Drawing.Color.DarkRed + 'HplIr.Visible = False + + BtnDescontabilizar.Visible = False + BtnEliminarPolizaMultiple.Visible = False + + 'LIGA POLIZA CANCELACIÓN + 'HplPolizaCancelación.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza")) + + End If + + 'CUANDO FUE REFACTURADA + If dr("CompraRefacturada").ToString.ToEntero > 0 Then + BtnEliminarCompra.Visible = False + BtnActualizar.Visible = False + BtnGuardar.Visible = False + BtnCancelarCompra.Visible = False + End If + + 'TIENE AMORTIZACIÓN + If GvAnticiposSel.Rows.Count > 0 Then + BtnEliminarCompra.Visible = False + If Not DdlTipoComprobante.SelectedValue.Contiene("NC") Then + BtnCancelarCompra.Visible = False + End If + End If + + CargaComplementosPago() + + Else + Alert("La compra solicitada no se encontró. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("Ocurrió un error al cargar la compra. Por favor vuelta a intentar o comuniquese con Sistemas.", TipoMensaje.MsgError) + End If + + ObjCompra.Dispose() + ObjOC.Dispose() + End Sub + + Private Sub VisualizaEstatusCompraSaldo(TipoDocto As String, Saldo As Decimal, Total As Decimal) + + If TipoDocto.Contiene("Fac", "Ant") Then + + If HdnCveEstatusFactura.Value.ToEntero = 6 Then + LblCompraEstatus.Text = "Vinculada a Crédito" + LblCompraEstatus.Font.Bold = True + LblCompraEstatus.Font.Size = 12 + LblCompraEstatus.ForeColor = Drawing.Color.Navy + BtnAceptarAnticipos.Visible = False + trImporte.Visible = False + HplImporte.Visible = False + HplImporte.Text = "" + HplImporte.NavigateUrl = "" + + Else + If Saldo <= 0 Then + LblCompraEstatus.Text = "PAGADA" + LblCompraEstatus.Font.Bold = True + LblCompraEstatus.Font.Size = 12 + LblCompraEstatus.ForeColor = Drawing.Color.Navy + BtnAceptarAnticipos.Visible = False + trImporte.Visible = True + HplImporte.Visible = True + HplImporte.Text = String.Format("$ {0}", Total.FormatoNumero()) + HplImporte.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra) + + + Else + If Saldo < Total Then + LblCompraEstatus.Text = "ABONADA" LblCompraEstatus.Font.Bold = True - End If + End If LblCompraEstatus.ForeColor = Drawing.Color.Navy trSaldo.Visible = True HplSaldoAuxiliar.Text = String.Format("$ {0}", Saldo.FormatoNumero()) HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra) - End If - End If - + End If + End If + UpEstatus.Update() Else @@ -3015,1424 +3015,1424 @@ Partial Class Compras_Compras HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=700&width=920", CveProveedor, CveCompra) End If - End If - - End Sub - - Private Sub CargaMonedas() - DdlMoneda.DataSource = GlobalDTMonedas - DdlMoneda.DataBind() - End Sub - - Private Sub CargarAlmacen() - 'ddlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2)") 'solo muestra tipo material y herramientas - 'ddlAlmacen.DataBind() - - ddlAlmacenAdd.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2,7,14,19)") 'solo muestra tipo material y herramientas - ddlAlmacenAdd.DataBind() - End Sub - - Protected Sub CargaFuncionariosEmpleados() - 'Cargar los FUncionarios Empleados que tengan saldo - Dim objGastosXComprobar As New ClsMovimientos - Dim dtFE As New DataTable - - If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then - 'TRATAR DE HACERLO CON c - - dtFE.Columns.Add("CvePersonal", GetType(Integer)) - dtFE.Columns.Add("NombreCompleto", GetType(String)) - dtFE.Columns.Add("Saldo", GetType(Double)) - 'dtFE.Columns.Add("CveIE", GetType(Integer)) - DtFuncionarios = objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 ") 'objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND Saldo > 0 ") ' saco los egresos sin comprobar de funcionarios y empleados - - For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 ", "NombreCompleto").Rows ' saco los totalizadores - Dim RowFE As DataRow = Nothing - RowFE = dtFE.NewRow() - - RowFE("CvePersonal") = Row("CvePersonal").ToString.ToEntero - RowFE("NombreCompleto") = String.Format("{0} - ${1}", Row("NombreCompleto").ToString.Trim, Row("Saldo").ToString.FormatoNumero(2)) - RowFE("Saldo") = Row("Saldo").ToString.ToDouble - - dtFE.Rows.Add(RowFE) - Next - ' DtFuncionarios = dtFE - 'For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND FechaDocumento IS NOT NULL").Rows - ' ArrIE.Add(New Anticipos With {.CveIE = Row("CveIE").ToString.ToEntero, .Importe = Row("Saldo").ToString.ToDouble, .CvePersonal = Row("CvePersonal").ToString.ToEntero}) - 'Next - - - End If - - objGastosXComprobar.Dispose() - - DdlFuncionarioEmpleado.DataSource = dtFE.FiltraParametros("", "NombreCompleto") - DdlFuncionarioEmpleado.DataBind() - - DdlFuncionarioEmpleado.Items.Insert(0, New ListItem("Seleccione Funcionario Empleado", "-1")) - - 'UPCondicionesPago.Update() - UpContado.Update() - End Sub - - Protected Sub CargaDeudores() - 'Cargar los FUncionarios Empleados que tengan saldo - Dim Deudores As New ClsMovimientos - - If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then - If Deudores.GetDeudoresSaldos(-1, UsuarioActual.CveEmpresa) Then - DtDeudores = Deudores.DtResultados.FiltraParametros("CveProveedor > 0") - DdlDeudor.DataSource = DtDeudores - DdlDeudor.DataBind() - - DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1")) - UpContado.Update() - End If - Else - If Deudores.GetDeudoresComisionesSaldos(UsuarioActual.CveEmpresa) Then - DtDeudores = Deudores.DtResultados.FiltraParametros("CveProveedor > 0") - DdlDeudor.DataSource = DtDeudores - DdlDeudor.DataBind() - - DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1")) - UpContado.Update() - End If - End If - - Deudores.Dispose() - End Sub - - Private Sub CreaTmpAcarreos() - tDTAcarreos = New DataTable - tDTAcarreos.Columns.Add("CvePreEstimacion", GetType(Integer)) - tDTAcarreos.Columns.Add("Importe", GetType(Double)) - End Sub - - Protected Sub CargaAcreedores() - Dim ObjMov As New ClsMovimientos - - If ObjMov.GetAcreedoresSaldos(-1, UsuarioActual.CveEmpresa) Then - DtAcreedores = ObjMov.DtResultados.FiltraParametros("CveProveedor > 0") - DdlAcreedor.DataSource = DtAcreedores - DdlAcreedor.DataBind() - - - - DdlAcreedor.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1")) - UpContado.Update() - End If - - ObjMov.Dispose() - End Sub - - Private Sub CargaCreditos() - - Dim Cred As New ClsBancos - Dim Dt As DataTable = Nothing - Dim DtD As DataTable = Nothing - If Cred.GetCreditos(-1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then - Dt = Cred.DtResultados.FiltraParametros("CveCredito > 0 AND CveTipoCredito IN (4,5)") - If Dt.Rows.Count > 0 AndAlso Cred.GetCreditosDetalle(Dt.Rows(0)("CveCredito").ToString.ToEntero, -1) Then - DtD = Cred.DtResultados.FiltraParametros("Estatus = 2 AND CveIE IS NOT NULL") - End If - End If - Cred.Dispose() - - If DdlTipoCredito.SelectedValue.ToEntero = 1 Then - Dt = Dt.FiltraParametros("CveCompraFactura IS NULL") - End If - - DdlCredito.DataSource = Dt.FiltraParametros("", DistinctColumns:={"CveCredito", "ReferenciaImporte"}) - DdlCredito.DataBind() - DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1")) - - - DdlCreditoDetalle.DataSource = DtD - DdlCreditoDetalle.DataBind() - DdlCreditoDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) - - End Sub - - Private Sub CargaCreditosDetalle(CveCredito As Integer) - Dim Cred As New ClsBancos - - Dim DtD As DataTable = Nothing - - If Cred.GetCreditosDetalle(CveCredito, -1) Then - DtD = Cred.DtResultados.FiltraParametros("Estatus = 2") - End If - Cred.Dispose() - - DdlCreditoDetalle.DataSource = DtD - DdlCreditoDetalle.DataBind() - DdlCreditoDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) - - End Sub - - Private Sub CargaProveedor(CveProveedor As Integer, RFC As String, Optional RecargaCombo As Boolean = True) - - Dim ObjProveedor As New ClsCompProveedores() - - If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then - If ObjProveedor.DtResultados.Rows.Count > 0 Then - - If RecargaCombo Then DdlProveedor.DataSource = ObjProveedor.DtResultados : DdlProveedor.DataBind() - - ChkConsignacion.Enabled = True - - ViewState("CveProveedor") = ObjProveedor.CveProveedor - ViewState("CveTipoProveedor") = ObjProveedor.CveTipoProveedor - - 'Conta ContPAQ - ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores - ViewState("CtaProveedorAnticipos") = ObjProveedor.IdCtaContAnticipos - ViewState("CtaProveedorAnticiposExtranjera") = ObjProveedor.IdCtaContAnticiposExtranjera - ViewState("CtaProveedorAnticiposComplementaria") = ObjProveedor.IdCtaContAnticiposComplementaria - ViewState("CtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor - ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor - ViewState("CtaProveedorRetISR") = ObjProveedor.IdCtaContRetISR - ViewState("CtaProveedorRetIVA") = ObjProveedor.IdCtaContRetIVA - ViewState("CtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera - ViewState("CtaProveedorComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria - ViewState("IdCtaContDocsXPagar") = ObjProveedor.IdCtaContDocsXPagar - - 'Conta SIG - ViewState("CveCuentaProveedor") = ObjProveedor.CveCuentaProveedores - ViewState("CveCuentaProveedorAnticipos") = ObjProveedor.CveCuentaAnticipos - ViewState("CveCuentaProveedorAnticiposExtranjera") = ObjProveedor.CveCuentaAnticiposExtranjera - ViewState("CveCuentaProveedorAnticiposComplementaria") = ObjProveedor.CveCuentaAnticiposComplementaria - ViewState("CveCuentaProveedorDeudores") = ObjProveedor.CveCuentaDeudor - ViewState("CveCuentaProveedorAcreedores") = ObjProveedor.CveCuentaAcreedor - ViewState("CveCuentaProveedorRetISR") = ObjProveedor.CveCuentaRetISR - ViewState("CveCuentaProveedorRetIVA") = ObjProveedor.CveCuentaRetIVA - ViewState("CveCuentaProveedorExtranjera") = ObjProveedor.CveCuentaProveedoresExtranjera - ViewState("CveCuentaProveedorComplementaria") = ObjProveedor.CveCuentaProveedoresComplementaria - - - ViewState("NombreProveedor") = ObjProveedor.RazonSocial - - HdnCveProveedor.Value = ObjProveedor.CveProveedor.ToString - - If ObjProveedor.EditarFolioDuplicado Then - TxtFolio.Enabled = True - TxtSerie.Enabled = True - End If - - TxtCodigo.Text = ObjProveedor.Codigo - LblRFC.Text = String.Format("{1}", Me.CveProveedor, ObjProveedor.RFC) - HplProveedor.Text = ObjProveedor.NombreComercial : HplProveedor.NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", Me.CveProveedor) - DdlProveedor.SelectedValue = ObjProveedor.CveProveedor.ToString - LblDiasCredito.Text = ObjProveedor.PlazoPago.ToString - LblLimiteCredito.Text = ObjProveedor.LimiteCredito.FormatoNumero - LblCreditoDisponible.Text = ObjProveedor.LimiteCredito.FormatoNumero - - If Not CveCompra > 0 Then '[IPP] SI YA ESTA REGISTRADA LOS VALORES SE CARGAN EN EL CARGACOMPRA() - 'DF 11-04-17 - Dim dtprovsuc As DataTable = GlobalDTProveedorSucursales(ObjProveedor.CveProveedor, UsuarioActual.CveEmpresa) - If dtprovsuc IsNot Nothing AndAlso dtprovsuc.Rows.Count > 0 Then - RowProveedorSucursal.Visible = True - DdlProveedorSucursal.Items.Clear() - DdlProveedorSucursal.DataSource = dtprovsuc - DdlProveedorSucursal.DataBind() - DdlProveedorSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) - 'si tiene una serie cargada, sugiere la sucursal - If TxtSerie.Text.Trim <> "" Then - DdlProveedorSucursal.SelectedValueExist(dtprovsuc.FiltroPrimeroValor("CveProveedorSucursal", $"Serie LIKE '%{TxtSerie.Text.Trim}%'").ToString()) - End If - Else - RowProveedorSucursal.Visible = False - DdlProveedorSucursal.Items.Clear() - DdlProveedorSucursal.Items.Insert(0, New ListItem("N/A", "-1")) - DdlProveedorSucursal.DataBind() - End If - End If - - If CveCompra <= 0 AndAlso CveFactura <= 0 Then 'si se está cargando una factura o compra no se carga - 'LblRetIVA.Text = ObjProveedor.RetIVA.ToString.FormatoNumero(5) - 'LblRetISR.Text = ObjProveedor.RetISR.ToString.FormatoNumero(5) - - If ObjProveedor.RFC = "XAXX010101000" Then ' RFC Generico - 'cuando se esta dando de alta de nueva la compra, se obtiene el folio siguiente de no deducibles - Dim ObjComp As New ClsCompras - TxtFolio.Text = ObjComp.GetSiguienteFolio(ObjProveedor.CveProveedor, TxtSerie.Text).ToString - ObjComp.Dispose() - End If - End If - ViewState("IVA") = ObjProveedor.IVA - HdnProveedorIVA.Value = ObjProveedor.IVA.ToString - - ViewState("IdCtaContProveedores") = ObjProveedor.IdCtaContProveedores - ViewState("IdCtaContAnticipos") = ObjProveedor.IdCtaContAnticipos - ViewState("IdCtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor - ViewState("IdCtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor - ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA - ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR - - If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ObjProveedor.IdCtaContProveedores < 1 Then - Alert("El Proveedor seleccionado no tiene cuenta contable asignada.", TipoMensaje.MsgAdvertencia) - End If - - ViewState("CveProveedor") = ObjProveedor.CveProveedor - HdnCveProveedor.Value = ObjProveedor.CveProveedor.ToString - TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString - RFCProv = ObjProveedor.RFC - CargaRetIVAConcepto(True) - CargaRetISRConcepto(True) - - If ObjProveedor.DIOTCveTipoOperacion = 1 Then '03 - Prestación de Servicios Profesionales - DdlRetIVAConcepto.SelectedValueExist("1") - DdlRetISRConcepto.SelectedValueExist("1") ' honorarios - ElseIf ObjProveedor.DIOTCveTipoOperacion = 2 Then ' 06 - Arrendamiento de inmuebles - DdlRetIVAConcepto.SelectedValueExist("4") - DdlRetISRConcepto.SelectedValueExist("2") ' arrendamiento - ElseIf ObjProveedor.DIOTCveTipoOperacion = 3 Then ' 85 - Otros - DdlRetIVAConcepto.SelectedValueExist("2") ' flete pf - DdlRetIVAConcepto.SelectedValueExist("3") ' fletes pm - DdlRetISRConcepto.SelectedValueExist("1") ' honorarios - End If - - LbAgregar.Enabled = True - UpPSS.Update() - UpPS.Update() - UpParametros.Update() - UPCondicionesPago.Update() - 'si tiene el habiltiado el módulo de Contratos - 'checo si tiene estimaciones - - 'CargaDatosEstimaciones(ObjProveedor.CveProveedor) - ImgBtnBuscarOC.OnClientClick = String.Format("AbrirVentana('/OC/PopUpBuscarReq.aspx?V=VOCCOMP&P={0}&T={1}&Masterimpoup=true',1000,600,'S'); return false;", ObjProveedor.CveProveedor, DdlTipoComprobante.SelectedValue) - CargaAnticipos(ObjProveedor.CveProveedor) : UpAnticipos.Update() - - If UsuarioActual.Empresa.UsaAC Then - If (TxtRetIVA.Text.ToDouble > 0 And Not ObjProveedor.IdCtaContRetIVA > 0) Or (TxtRetISR.Text.ToDouble > 0 And Not ObjProveedor.IdCtaContRetISR > 0) Then ' - ImgBtnBuscarOC.Visible = False - TxtOC.Enabled = False - BtnGuardar.Visible = False - Alert("El proveedor no tiene registrada cuentas contables de retenciones. Debe asignar las cuentas en el registro del proveedor.", TipoMensaje.MsgAdvertencia) - DivRestriccionAdvertencia.Visible = True - LtRestriccionAdvertencia.Text = "El proveedor no tiene registrada cuentas contables de retenciones." - End If - End If - - CargaGvAcarreos(ViewState("CveProveedor").ToString.ToEntero) - - - 'MONEDA PREFERENTE - If CveCompra <= 0 Then - If CveFactura <= 0 Then - DdlMoneda.SelectedValueExist(ObjProveedor.CveMonedaPreferente) - End If - CambiaMoneda(False) - End If - - - If CveProveedor > 0 Then - - Dim ObjSAT As New ClsSAT - Dim RFCRequest As String = ObjProveedor.RFC - If ObjSAT.GetListado69B(2, UsuarioActual.CveEmpresa, RFCRequest) Then - If ObjSAT.DtResultados.Rows.Count > 0 Then - Dim Estatus As String = ObjSAT.DtResultados.Rows(0)("Situacion").ToString - BtnGuardar.Enabled = False - UpParametros.Update() - - Alert($"El RFC del proveedor se encuentra en estado {Estatus} en el Listado EFOS (69B) del SAT", TipoMensaje.MsgAdvertencia) - System.Threading.Thread.Sleep(5) - End If - End If - ObjSAT.Dispose() - - End If - - - - Else - Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("Ocurrió un error al consultar el proveedor.", TipoMensaje.MsgError) - End If - - If UsuarioActual.Empresa.Funcionalidad(560) = "1" Then - If ObjProveedor.GetProveedoresEvaluacionPediente(Me.CveProveedor, UsuarioActual.CveEmpresa) Then - If ObjProveedor.DtResultados.Rows.Count > 0 Then - Me.RequiereEvaluacion = ObjProveedor.DtResultados.Rows(0)("RequiereEvaluacion").ToString() = "1" - Me.CveUsuarioEvaluador = ObjProveedor.DtResultados.Rows(0)("CveUsuarioEvaluador").ToString().ToEntero() - End If - End If - End If - - ObjProveedor.Dispose() - End Sub - - Private Sub CargaAnticipos(CveProveedor As Integer, Optional FiltroTipo As String = "-1") - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetAnticiposProveedor(CveProveedor, -1, CveMoneda:=-1, SelectTop:=-1, TipoDocto:=FiltroTipo) AndAlso ObjMovtos.DtResultados.Rows.Count > 0 Then - Dim CveMoneda As Integer = If(ChkPagarConPesos.Checked, 1, If(ChkPagarConDolares.Checked, 2, DdlMoneda.SelectedValue.ToEntero)) - If DdlMoneda.SelectedValue.ToEntero = 1 AndAlso CveCompra > 0 Then DivPagarConDolares.Visible = True Else If CveCompra > 0 Then DivPagarConPesos.Visible = True - GVAnticipos.DataSource = ObjMovtos.DtResultados.FiltraParametros($"Tipo = 'Act' AND CveMoneda = {CveMoneda}") - If ObjMovtos.DtResultados.FiltraParametros("Saldo > 0").Rows.Count > 0 Then - BtnAceptarAnticipos.Enabled = True - If DdlTipoComprobante.SelectedValue = "Fac" Then ImgAnticiposPendientes.Visible = True - End If - Else - GVAnticipos.DataSource = Nothing - End If - ObjMovtos.Dispose() - GVAnticipos.DataBind() - End Sub - - Private Sub CargaTiposAF() - ViewState("TmpDTTiposAF") = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa) - Dim Row As DataRow = DirectCast(ViewState("TmpDTTiposAF"), DataTable).NewRow() - Row("CveTipoActivoFijo") = -1 : Row("TipoActivoFijo") = "Seleccione" - DirectCast(ViewState("TmpDTTiposAF"), DataTable).Rows.InsertAt(Row, 0) - End Sub - - Public Function isWhitFamily() As Boolean - Return UsuarioActual.CveEmpresa = 66 - End Function - - Private Sub CargaPSAlias() - DdlPSAlias2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.CveEmpresa = 66 Then - DdlPSAlias2.ddlWS.Attributes.Add("data-subfamilia", "-1") - DdlPSAlias2.ddlWS.Attributes.Add("data-fueporxml", "0") - 'SOLO CUANDO SEA FACTURA DE INGRESOS - If DdlTipoComprobante.SelectedValue = "Fac" Then - DdlPSAlias2.ddlWS.Attributes.Add("data-pagina", "Compras") - Else - DdlPSAlias2.ddlWS.Attributes.Add("data-pagina", "Compras2") - End If - End If - If Not DdlPSAlias2.UsaWebService AndAlso CType(DdlPSAlias2.DataSource, DataTable) Is Nothing Then - DdlPSAlias2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPSAlias2.DataBind() - End If - - End Sub - - Private Sub CargarUM(CvePS As Integer, ob As DropDownList) - Dim ObjUM As New ClsProductosServicios() - If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then - ViewState("DTUM") = ObjUM.DtResultados - ob.Items.Clear() - ob.DataSource = DTUM - ob.DataBind() - - End If - ObjUM.Dispose() - - End Sub - - Private Sub CargaGridTarjetas() - Dim ObjCreditos As New ClsBancos - ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero) - - DdlTarjeta.Items.Clear() - DdlTarjeta.DataSource = ObjCreditos.DtResultados - DdlTarjeta.DataBind() - DdlTarjeta.Items.Insert(0, New ListItem("Seleccione", "-1")) - - ObjCreditos.Dispose() - DivTarjeta.Visible = True - End Sub - - Private Sub CargaConceptosXML(XMLDoc As XmlDocument) - Dim i As Integer = 0 - - Dim Total As Decimal = 0 - Dim PU As Decimal = 0 - Dim Descuento As Double = 0 - Dim CveUM As Integer = 0 - Dim UMM As String = "No Aplica" - Dim tCvePS As Integer = 0 - Dim TipoPS As Integer = 0 - Dim tCveClasif As Integer = -1 - Dim Clasif As String = "Sin Clasificación" - Dim tPSCodigo As String = "-" - Dim tPSDescripcion As String = "-" - Dim PSS As String = "" - Dim Obs As String = "" - Dim SubTotalTemp = 0.0D - Dim IVA As Double = 0 - Dim IEPS As Double = 0 - Dim RetISR As Double = 0 - Dim RetIVA As Double = 0 - Dim PorcentajeIVA As Double = 0 - Dim PorcentajeIEPS As Double = 0 - Dim PorcentajeRetISR As Double = 0 - Dim PorcentajeRetIVA As Double = 0 - Dim DtTemporalGuardados = New DataTable - DtTemporalGuardados.Columns.Add("Contador", GetType(Integer)) - DtTemporalGuardados.Columns.Add("Tipo", GetType(Integer)) - - 'GLOBALS - Dim DtUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).AsEnumerable - Dim DtUMAlias = GlobalDTUnidadesMedidaAlias(UsuarioActual.CveEmpresa).AsEnumerable - Dim DtPS = GlobalDTPS(UsuarioActual.CveEmpresa).AsEnumerable - Dim DtPSAlias = GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa).AsEnumerable - - ''AGREGA EN TABLA TEMPORAL - 'Dim DtPSTemp = TmpDT.Clone - 'Dim Row As DataRow = Nothing - - Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) - Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" - Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) - - If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" - namespaces.AddNamespace(Prefijo, cfdVer) - namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") - namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") - namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") - - Dim nodeconcepto As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) - If nodeconcepto IsNot Nothing AndAlso nodeconcepto.ChildNodes.Count > 0 Then - Dim nodosConceptos As XmlNodeList = nodeconcepto.SelectNodes(String.Format("//{0}:Concepto", Prefijo), namespaces) - For Each node As XmlNode In nodosConceptos - - ' INICIALIZA VALORES - PU = 0 - Descuento = 0 - CveUM = 0 - UMM = "No Aplica" - tCvePS = 0 - TipoPS = 0 - tCveClasif = -1 - Clasif = "Sin Clasificación" - tPSCodigo = "-" - tPSDescripcion = "-" - PSS = "" - Obs = "" - Total = 0 - IVA = 0 - IEPS = 0 - RetISR = 0 - RetIVA = 0 - PorcentajeIVA = 0 - PorcentajeIEPS = 0 - PorcentajeRetISR = 0 - PorcentajeRetIVA = 0 - - - 'CARGA NODO ACTUAL - ' node = XMLDoc.DocumentElement.ChildNodes(2).ChildNodes(i) - - 'CARGA PU - PU = ValorXML(node, "valorUnitario").ToDecimal - - 'SI PU >= TOTAL AND CANTIDAD > 0 : PU / CANTIDAD, por si tiene descuento en el importe y el valor unitario es mayor, lo ajusta - If ValorXML(node, "cantidad").ToDecimal > 0 AndAlso ValorXML(node, "valorUnitario").ToDecimal >= (ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal) Then - PU = ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal - End If - If ValorXML(node, "cantidad").ToDecimal > 0 AndAlso ValorXML(node, "valorUnitario").ToDouble <= 0 And ValorXML(node, "importe").ToDouble > 0 Then - PU = ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal - End If - - - - - 'OBTIENE DESCUENTO - If ValorXML(node, "descuento") IsNot Nothing Then Descuento = ValorXML(node, "descuento").Trim.ToDouble - - 'OBTIENE TOTAL - If ValorXML(node, "importe") IsNot Nothing Then Total = ValorXML(node, "importe").Trim.ToDecimal - - 'OBTIENE SUBTOTAL - SubTotalTemp += If(Total > 0, Total, PU * ValorXML(node, "cantidad").ToDecimal) - - - 'OBTIENE UM - If ValorXML(node, "unidad") IsNot Nothing Then UMM = ValorXML(node, "unidad").Trim - 'BUSCA UM EN CATALOGO - UMM = UMM.ToUpper.Replace(".", "").Replace(",", "") - Dim fUM = (From u In DtUM - Where String.Compare(u!UnidadMedida.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 OrElse - String.Compare(u!Abreviatura.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 - Select CveUnidadMedida = u!CveUnidadMedida, UnidadMedida = u!UnidadMedida).FirstOrDefault() - If fUM IsNot Nothing AndAlso fUM.CveUnidadMedida.ToString.ToEntero > 0 Then - CveUM = fUM.CveUnidadMedida.ToString.ToEntero - UMM = fUM.UnidadMedida.ToString - Else - - 'BUSCA UM EN ALIAS - Dim fUMAlias = (From u In DtUMAlias - Where String.Compare(u!UnidadMedidaAlias.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 - Select u!CveUnidadMedida, u!UnidadMedida).FirstOrDefault() - - If fUMAlias IsNot Nothing Then - CveUM = fUMAlias.CveUnidadMedida.ToString.ToEntero - UMM = fUMAlias.UnidadMedida.ToString - End If - End If - - - - 'se le puso una condicion de que ignorara los acentos, porque en la bd, marcaria error porque no distingue acentos - 'CONCEPTO PRUEBA "TRABAJOS DE CONSTRUCCION", RM/Compras/Compras.aspx?CveFactura=13402&RFC=ECO061206QW7 - '' u!PS.ToString.ToUpper.Trim = PSS - - - 'BUSCA PS - - PSS = ValorXML(node, "descripcion").ToUpper.Trim.Replace(vbCrLf, " ").Replace(vbLf, " ").Replace("'", "''").Replace(" ", " ").Replace("�", "") - If PSS.Length > 844 Then - PSS = PSS.Substring(0, 844) '844,por ser el numero de caracteres aceptados en la columna de la BD - End If - tPSCodigo = PSS - - 'BUSCA PS EN CATALOGO - Dim fPS = (From u In DtPS - Where String.Compare(u!PS.ToString.ToUpper.Trim, PSS, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 - Select u!CvePS, u!CveClasificacion, u!Clasificacion, u!CveTipoPS, u!PSCodigo).FirstOrDefault() - - If fPS IsNot Nothing Then - PSS = fPS.PSCodigo.ToString - tCvePS = fPS.CvePS.ToString.ToEntero - TipoPS = fPS.CveTipoPS.ToString.ToEntero - tCveClasif = fPS.CveClasificacion.ToString.ToEntero - Clasif = fPS.Clasificacion.ToString - tPSCodigo = fPS.PSCodigo.ToString - Else - 'BUSCA PS EN ALIAS - Dim fPSAlias = (From u In DtPSAlias - Where String.Compare(u!PSAlias.ToString.ToUpper.Trim, PSS, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 - Select u!CvePS, u!PS, u!CveClasificacion, u!Clasificacion, u!CveTipoPS, u!PSCodigo).FirstOrDefault() - If fPSAlias IsNot Nothing Then - Obs = PSS - PSS = fPSAlias.PS.ToString - tCvePS = fPSAlias.CvePS.ToString.ToEntero - TipoPS = fPSAlias.CveTipoPS.ToString.ToEntero - tCveClasif = fPSAlias.CveClasificacion.ToString.ToEntero - Clasif = fPSAlias.Clasificacion.ToString - tPSCodigo = fPSAlias.PSCodigo.ToString - End If - End If - - - 'PARA GLUYAS - If UsuarioActual.CveEmpresa = 66 Then - tPSCodigo = String.Format("{1} - {0}", ValorXML(node, "descripcion").ToUpper.Trim.Replace(vbCrLf, " ").Replace(vbLf, " ").Replace("'", "''"), ValorXML(node, "noIdentificacion").Trim) - End If - - - If Version = "3.3" Then - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - 'OBTENER TRASLADOS POR DETALLES - Dim ContadorTraslado = 0 - Dim nodosConceptosTraslado As XmlNodeList = node.SelectNodes(String.Format("//{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) - For Each nodeTraslado As XmlNode In nodosConceptosTraslado - - If Not DtTemporalGuardados.FiltraParametros($"Contador = {ContadorTraslado} AND Tipo = 1").Rows.Count > 0 Then - If ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal > 0 And ValorXML(nodeTraslado, "Base").Trim.ToDecimal = Total Then - If ValorXML(nodeTraslado, "Impuesto") = "002" Then - IVA = ValorXML(nodeTraslado, "Importe").Trim.ToDecimal - PorcentajeIVA = ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal - Dim Dr As DataRow - Dr = DtTemporalGuardados.NewRow() - Dr("Contador") = ContadorTraslado - Dr("Tipo") = 1 - DtTemporalGuardados.Rows.Add(Dr) - DtTemporalGuardados.AcceptChanges() - Exit For - ElseIf ValorXML(nodeTraslado, "Impuesto") = "003" Then - IEPS = ValorXML(nodeTraslado, "Importe").Trim.ToDecimal - PorcentajeIEPS = ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal - Dim Dr As DataRow - Dr = DtTemporalGuardados.NewRow() - Dr("Contador") = ContadorTraslado - Dr("Tipo") = 1 - DtTemporalGuardados.Rows.Add(Dr) - DtTemporalGuardados.AcceptChanges() - Exit For - End If - - End If - End If - ContadorTraslado += 1 - Next - - 'OBTENER RETENCIONES POR DETALLES - Dim ContadorRetenciones = 0 - Dim nodosConceptosRetenciones As XmlNodeList = node.SelectNodes(String.Format("//{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) - For Each nodeRetencion As XmlNode In nodosConceptosRetenciones - - If Not DtTemporalGuardados.FiltraParametros($"Contador = {ContadorRetenciones} AND Tipo = 2").Rows.Count > 0 Then - If ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal > 0 And ValorXML(nodeRetencion, "Base").Trim.ToDecimal = Total Then - If ValorXML(nodeRetencion, "Impuesto".Trim) = "001" Then - RetISR = ValorXML(nodeRetencion, "Importe").Trim.ToDecimal - PorcentajeRetISR = ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal - Dim Dr As DataRow - Dr = DtTemporalGuardados.NewRow() - Dr("Contador") = ContadorRetenciones - Dr("Tipo") = 2 - DtTemporalGuardados.Rows.Add(Dr) - DtTemporalGuardados.AcceptChanges() - Exit For - ElseIf ValorXML(nodeRetencion, "Impuesto") = "002" Then - RetIVA = ValorXML(nodeRetencion, "Importe").Trim.ToDecimal - PorcentajeRetIVA = ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal - Dim Dr As DataRow - Dr = DtTemporalGuardados.NewRow() - Dr("Contador") = ContadorRetenciones - Dr("Tipo") = 2 - DtTemporalGuardados.Rows.Add(Dr) - DtTemporalGuardados.AcceptChanges() - Exit For - End If - - End If - End If - ContadorRetenciones += 1 - Next - End If - - End If - - If Version = "3.2" Then - - - - - Try - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - Dim ContadorTraslado = 0 - Dim nodosConceptosTraslado As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) - - For Each nodeTraslado As XmlNode In nodosConceptosTraslado - If ValorXML(nodeTraslado, "tasa").Trim.ToDecimal > 0 And ValorXML(nodeTraslado, "impuesto").Trim = "IVA" Then - PorcentajeIVA = ValorXML(nodeTraslado, "tasa").Trim.ToDecimal - Alert($"{PorcentajeIVA}") - End If - Next - End If - Catch ex As Exception - - End Try - - End If - - - - '' AGREGA PS - 'AGREGA A TMPDT - AddPS(ValorXML(node, "cantidad").ToDouble, CveUM, UMM, tCveClasif, Clasif, tCvePS, PSS, TipoPS, "-1", "SE", "SE", "-1", Obs, PU, Total, IVA, RetIVA, RetISR, IEPS, 0, Descuento, PSCodigo:=tPSCodigo, TCalculaTotales:=False, CveSATPS:=ValorXML(node, "ClaveProdServ").ToEntero(), CargaXml:=True, PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, PorcentajeRetISR:=PorcentajeRetISR, PorcentajeIEPS:=PorcentajeIEPS) - - Next - End If - - AddPS2(False) - - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - - If isAlmacenistaGluyas() Then - BtnGuardar.Visible = False - AlmacenCambiaPS.Visible = True - End If - - SubTotalConceptos = Math.Round(SubTotalTemp, 2) - 'TmpDT = DtPSTemp.Copy - 'DtPSTemp.Dispose() - - End Sub -#End Region + End If -#Region "Vinculacion De Servcios" - Private Function isAdminObraGluyas() As Boolean - Return (UsuarioActual.CveRol = 1047 And UsuarioActual.CveEmpresa = 66) - End Function - Private Sub cargaddlVinculacionServcios() - If isAdminObraGluyas() Then - TabVinculacionServicios.Visible = True - 'Dim productos As New ClsProductosServicios - 'If productos.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then - ' PSDTRemplazo = productos.DtResultados.FiltraParametros("CveTipoPS=2", "PS") - 'End If - 'productos.Dispose() - GVVinculacionServicios.DataSource = TmpDT - GVVinculacionServicios.DataBind() - End If - End Sub - Protected Sub GVVinculacionServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVVinculacionServicios.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim dt As DataTable = Nothing - dt = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS=2", "PS") - e.Row.FCDropDownList("Ddlnewps").DataSource = dt 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("Ddlnewps").DataBind() - e.Row.FCDropDownList("Ddlnewps").Items.Insert(0, New ListItem("Seleccione", "-1")) - dt.Dispose() - - End If End Sub -#End Region + Private Sub CargaMonedas() + DdlMoneda.DataSource = GlobalDTMonedas + DdlMoneda.DataBind() + End Sub -#Region "BTN'S" - Protected Sub BtnVincularServicios_Click(sender As Object, e As EventArgs) Handles BtnVincularServicios.Click - Dim correcto As Boolean = True - Dim x As Integer = 0 - 'Dim buid As New StringBuilder - For Each Dr As DataRow In TmpDT.Rows - Dim newps As Integer = GVVinculacionServicios.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero - If newps > 0 Then - 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) - Dr("CvePS") = newps - 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) - Else 'limpio el valor para que no truene en linq mas abajo - correcto = False - Alert("Favor de vincular todos los servicios", TipoMensaje.MsgAdvertencia) - Exit For - End If - x = x + 1 - Next - x = 0 - For Each Dr As DataRow In GVVinculacionServicios.Rows - Dim newps As Integer = GVVinculacionServicios.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero - If newps > 0 Then - 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) - Dr("CvePS") = newps - 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) - Else 'limpio el valor para que no truene en linq mas abajo - correcto = False - Alert("Favor de vincular todos los servicios", TipoMensaje.MsgAdvertencia) - Exit For - End If - x = x + 1 - Next - - TmpDT.AcceptChanges() - 'Alert(buid.ToString) - If correcto Then - If Not CierrePeriodo Then - BtnGuardar.Visible = True - End If - UpFacturar.Update() - End If - End Sub - - Protected Sub BtnCargarProveedores_Click(sender As Object, e As System.EventArgs) Handles BtnCargarProveedores.Click - DdlProveedor.CssClass += " select2me" - DdlProveedor.AutoPostBack = True - DdlProveedor.Items.Clear() - DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - 'Dim ObjProveedor As New ClsCompProveedores - 'If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then - 'DdlProveedor.DataSource = ObjProveedor.DtResultados - 'End If - DdlProveedor.DataBind() - DdlProveedor.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) - DdlProveedor.Attributes.Remove("onclick") - - 'RegistraScript("$('#C_DdlProveedor').select2('open');") - End Sub - - Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click - ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero - CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1") - - If DdlPS.SelectedValue IsNot Nothing AndAlso DdlPS.SelectedValue.ToEntero > 0 Then - DdlPS_SelectedIndexChanged(sender, e) - DdlPS.Focus() - Else - TxtCantidad.Focus() - End If - - End Sub - - Protected Sub BtnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click - - '------------------INICIA VALIDACIONES------------------ - Dim EstatusCredito As Integer = 0 - 'Credito Multiple - If RBLPago.SelectedValue.ToEntero = 4 Then - - Dim DifCreCompra As Decimal = 0 - Dim TotalCreditos As Decimal = 0 - Dim MensualidadMultipleTotal As Decimal = 0 - Dim CveUltimoCreditoDetalleInterno As Integer - - For Each GvRow As GridViewRow In GvCreditos.Rows - - Dim CapitalMiltiple As Decimal = GvRow.FCTextBox("TxtCapital").Text.ToDecimal - Dim InteresMiltiple As Decimal = GvRow.FCTextBox("TxtInteres").Text.ToDecimal - - Dim AmbosMiltiple As Decimal = GvRow.FCTextBox("TxtAmbos").Text.ToDecimal - Dim MensualidadMultiple As Decimal = GvRow.DataKey("Mensualidad").ToDecimal - - If CapitalMiltiple > 0 Or InteresMiltiple > 0 Then - - TotalCreditos = TotalCreditos + CapitalMiltiple + InteresMiltiple - MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple - CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero - - ElseIf AmbosMiltiple > 0 Then - - TotalCreditos = TotalCreditos + AmbosMiltiple - MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple - CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero - EstatusCredito = GvRow.DataKey("Estatus").ToEntero - End If - Next - - If TotalCreditos <> TxtTotal.Text.ToDecimal Then - Alert($"El importe de La factura no concide con el total de los creditos, diferencia: { (TotalCreditos - TxtTotal.Text.ToDecimal).FormatoNumero(2)}", TipoMensaje.MsgAdvertencia) - Exit Sub - - End If - End If - - 'Si se marcó No Deducible en el encabezado mínimo se debe registrar un No Deducible en el Detalle - Dim GuardaNoDeducibles As Boolean = False - If ChkEsNoDeducible.Checked Then - For Each Row As DataRow In TmpDT.Rows - If Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1") Then - GuardaNoDeducibles = True - End If - Next - If GuardaNoDeducibles = False Then - Alert("Si la compra es No Deducible, mínimo se debe registrar un producto No Deducible", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - - If CierrePeriodo Then - Alert("El periodo de la compra actual ya se encuentra cerrado. No podra registrar la compra.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'DF - 10/04/2017 - If UsuarioActual.TienePermisoProceso(187) Then - If TxtSerie.Text <> SerieVieja Then - Dim SerieNueva As String = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).FiltroPrimeroValor("Serie", $"Serie = '{TxtSerie.Text}'").ToString - If SerieNueva = "" Then - Alert("La Serie no es válida, por favor revise que se encuentre dentro de la lista de las sucursales del proveedor.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If - - 'Excede el limite de credito - If RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac") AndAlso UsuarioActual.Empresa.Funcionalidad(518) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(185) Then - Dim ObjCompras As New ClsCompras - If ObjCompras.ObtenerCreditoRestante(CveProveedor) Then - If ObjCompras.DtResultados.Rows.Count > 0 Then - Dim Saldo As Decimal = ObjCompras.DtResultados(0)("Saldo").ToString.ToDecimal + TxtTotal.Text.ToDecimal - Dim LimiteCredito As Decimal = ObjCompras.DtResultados(0)("LimiteCredito").ToString.ToDecimal - - If LimiteCredito > 0 Then - If Saldo / LimiteCredito * 100 > 90 Then - Alert($"Nuestro Limite de Credito con este proveedor supera el 90%
Porcentaje Actual: {(Saldo / LimiteCredito * 100).FormatoNumero(2)}%", TipoMensaje.MsgAdvertencia) - End If - End If - Else - ObjCompras.Dispose() - Alert("El proveedor no tiene límite de crédito", TipoMensaje.MsgError) - Exit Sub - End If - Else - ObjCompras.Dispose() - Alert("Ocurrio un error al obtener el limite de credito del Proveedor", TipoMensaje.MsgError) - Exit Sub - End If - ObjCompras.Dispose() - End If - - If Not (HFDiferenciaCompra.Value = TxtTotal.Text Or CveFactura < 1 Or CveCompra < 1) Then - Alert("La compra no se puede registrar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError) - Exit Sub - End If - - 'UM EQUIVALENCIAS - For Each gvr As GridViewRow In GvPS.Rows - If gvr.DataKey("CvePS").ToString.ToEntero > 0 Then - If gvr.DataKey("CveUM").ToString.ToEntero = 0 Then - Alert("Existe un error, Unidad de Medida no registrada", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - Next - - If ChkConsignacion.Checked Then - For Each gvr As GridViewRow In GvInv.Rows - If gvr.FCDropDownList("DdlVinculaConsignacion").SelectedValue.ToEntero < 0 Then - Alert("Si la compra aplica consignación debe vincular todos los conceptos en Almacén.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Next - End If - - If RowProveedorSucursal.Visible And DdlProveedorSucursal.SelectedValue.ToEntero = -1 Then - Alert("Favor de seleccionar una sucursal del proveedor", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.TienePermisoProceso(121) Then - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - If Not NCDevolucion Then - Alert("Favor de seleccionar un producto en la pestaña de almacen", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Else - Dim x As Integer = 0 - For Each Dr As GridViewRow In GvInv.Rows - If Dr.FCCheckBox("cbInv").Checked Then - x = x + 1 - End If - Next - If x = 0 AndAlso GvInv.Rows.Count > 0 Then - Alert("Favor de seleccionar un producto en la pestaña de almacen", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(538).ToEntero = 1 Then - If TmpDT.MIN("CvePS").ToEntero <= 0 Then - Alert("Todos los Productos/Servicios deben estar registrados o aliados a un productos ya registrado.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(123).ToEntero > 0 And Not UsuarioActual.TienePermisoProceso(156) Then - If Not ValidaCierrePeriodo() Then - Alert("No se puede registar la compra. Se ha cerrado el periodo de la compra actual", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Dim TotalPorDevengar = Math.Round(TxtTotal.Text.ToDouble, 2) - Dim TotalDetalle = 0.0 - Dim RequiereCentroCosto As Boolean = False - - 'If Not (UsuarioActual.Empresa.Funcionalidad(102) = "") Then - ' Dim NotHas117 As Boolean = Not UsuarioActual.TienePermisoProceso(117) - ' 'verifica que tenga proyecto y clasificacion - For Each Row As DataRow In TmpDT.Rows - If Row("CveSubProyecto").ToString.ToEntero <= 0 Then - Alert("No se ha completado la asignacion de proyectos en la compra. ", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then 'If NotHas117 AndAlso Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then - Alert("Hay productos que no tienen clasificación asignada.
Favor de asignarle una y darle guardar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then - If Row("CveTipoGasto").ToString.ToEntero <= 0 Then - Alert("No se ha completado la asignacion de tipos de gasto en la compra.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - Next - 'End If - - 'SI LA CANTIDAD EN SERIE/LOTE NO ES IGUAL A CANTIDAD EN GVPS - 'Dim DtDetalles As DataTable - Dim Cantidad As Integer - - If GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True Then - For Each Dr As DataRow In DtInv.Rows - If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then - Cantidad = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS").ToString)).Rows.Count - If Cantidad < Dr("Cantidad").ToString.ToEntero Then - Alert("No hay productos a los que no se le ha asociado Serie-Lote", TipoMensaje.MsgError) - Exit Sub - End If - End If - Next - End If - - If Not HdnCveProveedor.Value <> "-1" Then - Alert("En necesario seleccionar un proveedor, al cual se le va a facturar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not TmpDT.Rows.Count > 0 Then - Alert("Es necesario agregar al menos un Producto o Servicio a la factura.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDA SI LA CLASIFICACIÓN REQUIERE PERSONAL, AF COMPRA O AF INSUMO - Dim ErrorValidacion As Boolean = False - Dim DtTemporal As New DataTable - DtTemporal.Columns.Add("CveClasificacion", GetType(Integer)) - For Each Gvr As GridViewRow In GvPS.Rows - Dim Dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros($"CveClasificacion = {Gvr.DataKey("CveClasificacion").ToEntero}")(0) - If Dr IsNot Nothing Then - Dim SeValido As Boolean = False - For Each Drt As DataRow In DtTemporal.Rows - If Drt("CveClasificacion").ToString.ToEntero = Dr("CveClasificacion").ToString.ToEntero Then - SeValido = True - Exit For - End If - Next - If Not SeValido Then - If CBool(Dr("RequierePersonal")) Then - For Each GvP As GridViewRow In GvPersonal.Rows - If GvP.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then - If Not GvP.FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero > 0 Then - ErrorValidacion = True - Alert($"Tiene que seleccionar un personal para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) - Exit For - End If - End If - Next - End If - If CBool(Dr("RequiereAFCompra")) Then - For Each GvAFC As GridViewRow In GvAFCompras.Rows - If GvAFC.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then - If Not GvAFC.FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - ErrorValidacion = True - Alert($"Tiene que seleccionar un AF compra para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) - Exit For - End If - End If - Next - End If - If CBool(Dr("RequiereAFInsumo")) Then - For Each GvAFI As GridViewRow In GvAFInsumos.Rows - If GvAFI.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then - If Not GvAFI.FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - ErrorValidacion = True - If Not SeValido Then - Alert($"Tiene que seleccionar un AF insumo para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) - End If - Exit For - End If - End If - Next - End If - Dim Drr As DataRow = DtTemporal.NewRow - Drr("CveClasificacion") = Dr("CveClasificacion").ToString.ToEntero - DtTemporal.Rows.Add(Drr) - End If - End If - Next - If ErrorValidacion Then Exit Sub - - '------------------TERMINA VALIDACIONES------------------ - - 'RECORRO LOS PRODUCTOS O SERVICIOS PARA REGISTRARLOS LOS QUE NO EXISTEN EN EL CATÁLOGO - Dim tCve As Integer - Dim RegeneraPS As Boolean = False - 'OBJETOS PROVISIONALES - Dim UM As New ClsUnidadesMedida - Dim PSS As New ClsProductosServicios - Dim Correcto = True - - For Each Row As DataRow In TmpDT.Rows - - 'VALIDACION DE CENTRO DE COSTO - If UsuarioActual.Empresa.RequiereCentroCostos AndAlso Row("CveSubProyecto").ToString.ToEntero <= 0 Then - RequiereCentroCosto = True - UM.Dispose() - PSS.Dispose() - Alert("Falta asignar Proyecto a la compra", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'REGISTRO LAS UNIDADES DE MEDIDA - If Row("CveUM").ToString.ToEntero = 0 Then - tCve = UM.AddUnidadMedida(Row("UM").ToString, Row("UM").ToString, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) - If tCve > 0 Then - Row("CveUM") = tCve - Dim rowsToUpdate = TmpDT.AsEnumerable().Where(Function(r) r.Field(Of String)("UM").ToString.ToUpper = Row("UM").ToString.ToUpper AndAlso r!CveUM.ToString.ToEntero = 0) - For Each roww As DataRow In rowsToUpdate - roww.SetField("CveUM", tCve) - Next - Else - Correcto = False - End If - End If - - 'REGISTRO LOS PRODUCTOS - If Row("CvePS").ToString.ToEntero = 0 Then - tCve = PSS.AddPS(Row("CveClasificacionActualizar").ToString.ToEntero, -1, Row("CveUM").ToString.ToEntero, "", "", "", Row("PS").ToString, Row("PU").ToString.ToDouble, If(TxtIVA.Text.ToDouble > 0, -1, 0), 0, False, 0, True, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, 0) - If tCve > 0 Then - RegeneraPS = True - Row("CvePS") = tCve - Row("CveClasificacion") = Row("CveClasificacionActualizar").ToString.ToEntero - 'Row("CveEq") = 1 - TmpDT.AcceptChanges() - - 'busco el mismo PS dentro de la tabla por si está más de una vez y lo actualizo - Dim rowsToUpdate = TmpDT.AsEnumerable().Where(Function(r) r.Field(Of String)("PS") = Row("PS").ToString AndAlso r!CvePS.ToString.ToEntero = 0) - For Each roww As DataRow In rowsToUpdate - roww.SetField("CvePS", tCve) - roww.SetField("CveClasificacion", Row("CveClasificacionActualizar").ToString.ToEntero) - 'roww.SetField("CveEq", 1) - Next - TmpDT.AcceptChanges() - Else - Correcto = False - End If - Else - 'UPDATE CLASIFICACION DE PRODUCTO YA REGISTRADO - If Row("CveClasificacionActualizar").ToString.ToEntero > 0 AndAlso Row("CveClasificacion").ToString.ToEntero <= 0 Then - If PSS.UpdateClasificacionPS(Row("CveClasificacionActualizar").ToString.ToEntero, UsuarioActual.CveUsuario, Row("CvePS").ToString.ToEntero) Then - Row("CveClasificacion") = Row("CveClasificacionActualizar").ToString.ToEntero - RegeneraPS = True - Else - Correcto = False - End If - End If - End If - Next - UM.Dispose() - PSS.Dispose() - - 'si hay necesidad de actualizar el globaldtps - If RegeneraPS Then - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) - 'Hilo.Start() - GeneraGlobalDT(Nothing) - End If - - Dim CvePlantillaPrePoliza As Integer - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - CvePlantillaPrePoliza = 60 - Else - CvePlantillaPrePoliza = 1 - End If - Dim tIdContaProveedor As Integer = CtaProveedor - Dim ImporteAnticipo As Decimal = 0 - - If (ArrAnticipos.Count > 0 And CveCompra > 0) Or (ArrAnticipos.Count > 0 And UsuarioActual.Empresa.UsaAC) Then '-- ESTO SE QUITO - IPP - 04 NOVIMEBRE 2016 - CvePlantillaPrePoliza = 52 - 'cuenta de anticipos - tIdContaProveedor = CtaProveedorAnticipos - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - ImporteAnticipo += Ant.Importe - Next - If Math.Round(ImporteAnticipo, 2) > TxtTotal.Text.ToDouble Then - Alert("El Importe seleccionado es mayor a la compra", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - End If - - If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then - If EmpresaPrueba Then - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - CvePlantillaPrePoliza = 60 - Else - CvePlantillaPrePoliza = 1 - End If - Else - CvePlantillaPrePoliza = 9 - End If - End If - - 'If RBLPago.SelectedValue.ToEntero = 4 And UsuarioActual.CveEmpresa.Contiene(1, 7) Then - ' CvePlantillaPrePoliza = 69 - 'End If - - TmpDT.AcceptChanges() - If Correcto Then - - 'VALIDA IMPORTES - If Not ValidaTotalesGuardar() Then - Exit Sub - End If - - - Dim ObjCompras As New ClsCompras() - Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) - Dim ObjIE As New ClsBancos(ObjCompras.IniciaTransacSQL) - Dim ObjInventario As New ClsInventarios(ObjCompras.IniciaTransacSQL) - Dim ObjAF As New ClsAF(ObjCompras.IniciaTransacSQL) - Dim ObjOC As New ClsOC(ObjCompras.IniciaTransacSQL) - Dim ObjContratos As New ClsContratos(ObjCompras.IniciaTransacSQL()) - Dim ObjProveedores As New ClsCompProveedores(ObjCompras.IniciaTransacSQL()) - Dim ObjEventos As New ClsOIEventos(ObjCompras.IniciaTransacSQL()) - Dim ObjAcar As New ClsAcarreos(ObjCompras.IniciaTransacSQL()) - Dim ObjCGame As New ClsCGame(ObjCompras.IniciaTransacSQL()) - Dim ObjProductosServicios As New ClsProductosServicios(ObjCompras.IniciaTransacSQL()) - - - Dim ObjContaAC As ClsContPAQi = Nothing - - Dim ErrorMovtosCxP As Boolean = False - Dim ErrorPrepoliza As Boolean = False - Dim ErrorPrepolizaDescuadre As Boolean = False - Dim ErrorMovtosRetIVA As Boolean = False - Dim ErrorMovtosRetISR As Boolean = False - Dim ErrorMovtosEstimaciones As Boolean = False - Dim ErrorMovtosIVA As Boolean = False - Dim ErrorMovtosIE As Boolean = False - Dim ErrorMovInv As Boolean - Dim ErrorMovDev As Boolean = False - Dim ErrorOC = False - Dim TieneError As Boolean = False - Dim ErrorAC As Boolean = False - Dim ErrorAF As Boolean = False - Dim ErrorReembolso As Boolean = False - Dim ErrorBitacora = False - Dim ErrorAddAcarreos As Boolean = False - Dim ErrorCreditosCompra As Boolean = False - Dim ErrorOtrosGastos As Boolean = False - Dim ErrorSATPS As Boolean = False - Dim ErrorACMEnsaje As New StringBuilder - Dim ErrorSaldosInvComp As Boolean = False - - Dim CveIE As Integer = -1 - Dim CveEstatusFactura As Integer = 1 - Dim PolizaFolio As Integer = 0 - Dim CvePrePoliza As Integer - Dim ImporteCompra As Decimal = TxtTotal.Text.ToDecimal - Dim MultiplicadorNC = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) - Dim CveMovimientoInventario As Integer = -1 - Dim IVA = 1.16 - Dim ListaMovimientosAlmacen As New List(Of Integer) - - Dim ErrorCreditoCapitalIntres As Boolean = False - Dim ErrorCredito As Boolean = False - - If ChkProgramarPago.Checked Then - CveEstatusFactura = 2 - End If - Dim EntregaDirecta = False - - Dim ConceptoPoliza As String = String.Format("{0} - {1}{2} - {3}", NombreProveedor, TxtSerie.Text, TxtFolio.Text, TxtDescripcion.Text.Trim) - - 'TIPO CAMBIO MANUAL CON COMPRA NUEVA - Dim TipoCambioGuardar = 1.0 - If DdlMoneda.SelectedValue.ToEntero > 1 Then - TipoCambioGuardar = If(DivTC.Visible, TxtTC.Text.ToDouble, LblTC.Text.Substring(3).ToDouble) - End If - TipoCambio = If(DivTC.Visible, TipoCambioGuardar, TipoCambio) - - Try - Dim FolioFijo As Integer = 0 - 'cheque - If DdlTipoTransaccion.SelectedValue = "1" Then FolioFijo = TxtFolio.Text.ToEntero - - CvePrePoliza = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) - - If CvePrePoliza > 0 Then - - 'seria de contado, solo cuando no tenga vinculado ningun anticipo - Dim ImportePago As Decimal = 0 - Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal - Dim CveMonedaPago As Integer = DdlMoneda.SelectedValue.ToEntero - - If RBLPago.SelectedValue.ToEntero = 2 Then 'Contado - - If RBLContado.SelectedValue = "1" Then - ImportePago = TxtDocumentoImporte.Text.Trim.ToDecimal - Dim Dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0) - - If Dr IsNot Nothing Then - CveMonedaPago = Dr("CveMoneda").ToString.ToEntero - End If - - If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then - ImportePago = (ImportePago * TCPago).RoundSQL - ElseIf CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - ImportePago = (ImportePago / TCPago).RoundSQL - ElseIf CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - TCPago = 1 - End If - - 'se registra primero el movimiento en bancos para luego vincularlo en la compra - CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, ImportePago, CveMonedaPago, TCPago, TxtDocumentoObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1)) - ElseIf RBLContado.SelectedValue = "6" Then - ImportePago = TxtDocumentoImporteCaja.Text.Trim.ToDecimal - Dim Dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuentaCaja.SelectedValue}").Rows(0) - If Dr IsNot Nothing Then - CveMonedaPago = Dr("CveMoneda").ToString.ToEntero - End If - - If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then - ImportePago = (ImportePago * TCPago).RoundSQL - ElseIf CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - ImportePago = (ImportePago / TCPago).RoundSQL - ElseIf CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - TCPago = 1 - End If - - 'se registra primero el movimiento en bancos para luego vincularlo en la compra - CveIE = ObjIE.AddBancos_IE(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolioCaja.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, ImportePago, CveMonedaPago, TCPago, TxtDocumentoObservacionesCaja.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - End If - - If (RBLContado.SelectedValue = "1" OrElse RBLContado.SelectedValue = "6") AndAlso Not CveIE > 0 Then - ErrorMovtosIE = True - End If - End If - - If Not ErrorMovtosIE Then - - 'REEMBOLSOS NO USA AC - Dim NumeroReembolso = "-1" - If TxtNumeroReembolso IsNot Nothing And RBLPago.SelectedValue = "3" Then - NumeroReembolso = TxtNumeroReembolso.Text - - ''GUARDA VALORES PARA SESSION - UsuarioActual.Sesion("Comp-NumeroReembolso") = TxtNumeroReembolso.Text - UsuarioActual.Sesion("Comp-CveFYE") = DdlPersonalReembolso.SelectedValue - UsuarioActual.Sesion("Comp-Descripcion") = TxtDescripcion.Text - - If NumeroReembolso <> "-1" Then - If CvePersonal <= 0 And CveCajaChica <= 0 Then - ErrorReembolso = True - End If - End If - Else - UsuarioActual.Sesion("Comp-NumeroReembolso") = "" - End If - - - If Not ErrorReembolso Then - - 'PORCENTAJE IVA - Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal - - 'If DdlIVA.SelectedValue.ToDouble = 1.16 Then - ' PorcentajeIVA = 0.16 - 'ElseIf DdlIVA.SelectedValue.ToDouble = 1.08 Then - ' PorcentajeIVA = 0.08 - 'End If - - 'METODO DE PREPOLIZA DE ALMACEN - If UsuarioActual.CveEmpresa.Contiene(1, 119, 72, 80, 140, 141) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal - If ImporteAlmacen > 0 Then - If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - If (CveImportacion > 0 Or CveFlete > 0) Then - CveConceptoContableAlmacen = CveConceptoContableAlmacen - Else - CveConceptoContableAlmacen = 205 - End If - If OCVinculada And Not (CveImportacion > 0 Or CveFlete > 0) Then - CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero - End If - If UsuarioActual.CveEmpresa.Contiene(72, 80, 140, 141) Then - CveConceptoContableAlmacen = 205 - End If + Private Sub CargarAlmacen() + 'ddlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2)") 'solo muestra tipo material y herramientas + 'ddlAlmacen.DataBind() + + ddlAlmacenAdd.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2,7,14,19)") 'solo muestra tipo material y herramientas + ddlAlmacenAdd.DataBind() + End Sub + + Protected Sub CargaFuncionariosEmpleados() + 'Cargar los FUncionarios Empleados que tengan saldo + Dim objGastosXComprobar As New ClsMovimientos + Dim dtFE As New DataTable + + If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then + 'TRATAR DE HACERLO CON c + + dtFE.Columns.Add("CvePersonal", GetType(Integer)) + dtFE.Columns.Add("NombreCompleto", GetType(String)) + dtFE.Columns.Add("Saldo", GetType(Double)) + 'dtFE.Columns.Add("CveIE", GetType(Integer)) + DtFuncionarios = objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 ") 'objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND Saldo > 0 ") ' saco los egresos sin comprobar de funcionarios y empleados + + For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 ", "NombreCompleto").Rows ' saco los totalizadores + Dim RowFE As DataRow = Nothing + RowFE = dtFE.NewRow() + + RowFE("CvePersonal") = Row("CvePersonal").ToString.ToEntero + RowFE("NombreCompleto") = String.Format("{0} - ${1}", Row("NombreCompleto").ToString.Trim, Row("Saldo").ToString.FormatoNumero(2)) + RowFE("Saldo") = Row("Saldo").ToString.ToDouble + + dtFE.Rows.Add(RowFE) + Next + ' DtFuncionarios = dtFE + 'For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND FechaDocumento IS NOT NULL").Rows + ' ArrIE.Add(New Anticipos With {.CveIE = Row("CveIE").ToString.ToEntero, .Importe = Row("Saldo").ToString.ToDouble, .CvePersonal = Row("CvePersonal").ToString.ToEntero}) + 'Next + + + End If + + objGastosXComprobar.Dispose() + + DdlFuncionarioEmpleado.DataSource = dtFE.FiltraParametros("", "NombreCompleto") + DdlFuncionarioEmpleado.DataBind() + + DdlFuncionarioEmpleado.Items.Insert(0, New ListItem("Seleccione Funcionario Empleado", "-1")) + + 'UPCondicionesPago.Update() + UpContado.Update() + End Sub + + Protected Sub CargaDeudores() + 'Cargar los FUncionarios Empleados que tengan saldo + Dim Deudores As New ClsMovimientos + + If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then + If Deudores.GetDeudoresSaldos(-1, UsuarioActual.CveEmpresa) Then + DtDeudores = Deudores.DtResultados.FiltraParametros("CveProveedor > 0") + DdlDeudor.DataSource = DtDeudores + DdlDeudor.DataBind() + + DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1")) + UpContado.Update() + End If + Else + If Deudores.GetDeudoresComisionesSaldos(UsuarioActual.CveEmpresa) Then + DtDeudores = Deudores.DtResultados.FiltraParametros("CveProveedor > 0") + DdlDeudor.DataSource = DtDeudores + DdlDeudor.DataBind() + + DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1")) + UpContado.Update() + End If + End If + + Deudores.Dispose() + End Sub + + Private Sub CreaTmpAcarreos() + tDTAcarreos = New DataTable + tDTAcarreos.Columns.Add("CvePreEstimacion", GetType(Integer)) + tDTAcarreos.Columns.Add("Importe", GetType(Double)) + End Sub + + Protected Sub CargaAcreedores() + Dim ObjMov As New ClsMovimientos + + If ObjMov.GetAcreedoresSaldos(-1, UsuarioActual.CveEmpresa) Then + DtAcreedores = ObjMov.DtResultados.FiltraParametros("CveProveedor > 0") + DdlAcreedor.DataSource = DtAcreedores + DdlAcreedor.DataBind() + + + + DdlAcreedor.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1")) + UpContado.Update() + End If + + ObjMov.Dispose() + End Sub + + Private Sub CargaCreditos() + + Dim Cred As New ClsBancos + Dim Dt As DataTable = Nothing + Dim DtD As DataTable = Nothing + If Cred.GetCreditos(-1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then + Dt = Cred.DtResultados.FiltraParametros("CveCredito > 0 AND CveTipoCredito IN (4,5)") + If Dt.Rows.Count > 0 AndAlso Cred.GetCreditosDetalle(Dt.Rows(0)("CveCredito").ToString.ToEntero, -1) Then + DtD = Cred.DtResultados.FiltraParametros("Estatus = 2 AND CveIE IS NOT NULL") + End If + End If + Cred.Dispose() + + If DdlTipoCredito.SelectedValue.ToEntero = 1 Then + Dt = Dt.FiltraParametros("CveCompraFactura IS NULL") + End If + + DdlCredito.DataSource = Dt.FiltraParametros("", DistinctColumns:={"CveCredito", "ReferenciaImporte"}) + DdlCredito.DataBind() + DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1")) + + + DdlCreditoDetalle.DataSource = DtD + DdlCreditoDetalle.DataBind() + DdlCreditoDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaCreditosDetalle(CveCredito As Integer) + Dim Cred As New ClsBancos + + Dim DtD As DataTable = Nothing + + If Cred.GetCreditosDetalle(CveCredito, -1) Then + DtD = Cred.DtResultados.FiltraParametros("Estatus = 2") + End If + Cred.Dispose() + + DdlCreditoDetalle.DataSource = DtD + DdlCreditoDetalle.DataBind() + DdlCreditoDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaProveedor(CveProveedor As Integer, RFC As String, Optional RecargaCombo As Boolean = True) + + Dim ObjProveedor As New ClsCompProveedores() + + If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then + If ObjProveedor.DtResultados.Rows.Count > 0 Then + + If RecargaCombo Then DdlProveedor.DataSource = ObjProveedor.DtResultados : DdlProveedor.DataBind() + + ChkConsignacion.Enabled = True + + ViewState("CveProveedor") = ObjProveedor.CveProveedor + ViewState("CveTipoProveedor") = ObjProveedor.CveTipoProveedor + + 'Conta ContPAQ + ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores + ViewState("CtaProveedorAnticipos") = ObjProveedor.IdCtaContAnticipos + ViewState("CtaProveedorAnticiposExtranjera") = ObjProveedor.IdCtaContAnticiposExtranjera + ViewState("CtaProveedorAnticiposComplementaria") = ObjProveedor.IdCtaContAnticiposComplementaria + ViewState("CtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor + ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor + ViewState("CtaProveedorRetISR") = ObjProveedor.IdCtaContRetISR + ViewState("CtaProveedorRetIVA") = ObjProveedor.IdCtaContRetIVA + ViewState("CtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera + ViewState("CtaProveedorComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria + ViewState("IdCtaContDocsXPagar") = ObjProveedor.IdCtaContDocsXPagar + + 'Conta SIG + ViewState("CveCuentaProveedor") = ObjProveedor.CveCuentaProveedores + ViewState("CveCuentaProveedorAnticipos") = ObjProveedor.CveCuentaAnticipos + ViewState("CveCuentaProveedorAnticiposExtranjera") = ObjProveedor.CveCuentaAnticiposExtranjera + ViewState("CveCuentaProveedorAnticiposComplementaria") = ObjProveedor.CveCuentaAnticiposComplementaria + ViewState("CveCuentaProveedorDeudores") = ObjProveedor.CveCuentaDeudor + ViewState("CveCuentaProveedorAcreedores") = ObjProveedor.CveCuentaAcreedor + ViewState("CveCuentaProveedorRetISR") = ObjProveedor.CveCuentaRetISR + ViewState("CveCuentaProveedorRetIVA") = ObjProveedor.CveCuentaRetIVA + ViewState("CveCuentaProveedorExtranjera") = ObjProveedor.CveCuentaProveedoresExtranjera + ViewState("CveCuentaProveedorComplementaria") = ObjProveedor.CveCuentaProveedoresComplementaria + + + ViewState("NombreProveedor") = ObjProveedor.RazonSocial + + HdnCveProveedor.Value = ObjProveedor.CveProveedor.ToString + + If ObjProveedor.EditarFolioDuplicado Then + TxtFolio.Enabled = True + TxtSerie.Enabled = True + End If + + TxtCodigo.Text = ObjProveedor.Codigo + LblRFC.Text = String.Format("{1}", Me.CveProveedor, ObjProveedor.RFC) + HplProveedor.Text = ObjProveedor.NombreComercial : HplProveedor.NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", Me.CveProveedor) + DdlProveedor.SelectedValue = ObjProveedor.CveProveedor.ToString + LblDiasCredito.Text = ObjProveedor.PlazoPago.ToString + LblLimiteCredito.Text = ObjProveedor.LimiteCredito.FormatoNumero + LblCreditoDisponible.Text = ObjProveedor.LimiteCredito.FormatoNumero + + If Not CveCompra > 0 Then '[IPP] SI YA ESTA REGISTRADA LOS VALORES SE CARGAN EN EL CARGACOMPRA() + 'DF 11-04-17 + Dim dtprovsuc As DataTable = GlobalDTProveedorSucursales(ObjProveedor.CveProveedor, UsuarioActual.CveEmpresa) + If dtprovsuc IsNot Nothing AndAlso dtprovsuc.Rows.Count > 0 Then + RowProveedorSucursal.Visible = True + DdlProveedorSucursal.Items.Clear() + DdlProveedorSucursal.DataSource = dtprovsuc + DdlProveedorSucursal.DataBind() + DdlProveedorSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) + 'si tiene una serie cargada, sugiere la sucursal + If TxtSerie.Text.Trim <> "" Then + DdlProveedorSucursal.SelectedValueExist(dtprovsuc.FiltroPrimeroValor("CveProveedorSucursal", $"Serie LIKE '%{TxtSerie.Text.Trim}%'").ToString()) + End If + Else + RowProveedorSucursal.Visible = False + DdlProveedorSucursal.Items.Clear() + DdlProveedorSucursal.Items.Insert(0, New ListItem("N/A", "-1")) + DdlProveedorSucursal.DataBind() + End If + End If + + If CveCompra <= 0 AndAlso CveFactura <= 0 Then 'si se está cargando una factura o compra no se carga + 'LblRetIVA.Text = ObjProveedor.RetIVA.ToString.FormatoNumero(5) + 'LblRetISR.Text = ObjProveedor.RetISR.ToString.FormatoNumero(5) + + If ObjProveedor.RFC = "XAXX010101000" Then ' RFC Generico + 'cuando se esta dando de alta de nueva la compra, se obtiene el folio siguiente de no deducibles + Dim ObjComp As New ClsCompras + TxtFolio.Text = ObjComp.GetSiguienteFolio(ObjProveedor.CveProveedor, TxtSerie.Text).ToString + ObjComp.Dispose() + End If + End If + ViewState("IVA") = ObjProveedor.IVA + HdnProveedorIVA.Value = ObjProveedor.IVA.ToString + + ViewState("IdCtaContProveedores") = ObjProveedor.IdCtaContProveedores + ViewState("IdCtaContAnticipos") = ObjProveedor.IdCtaContAnticipos + ViewState("IdCtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor + ViewState("IdCtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor + ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA + ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR + + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ObjProveedor.IdCtaContProveedores < 1 Then + Alert("El Proveedor seleccionado no tiene cuenta contable asignada.", TipoMensaje.MsgAdvertencia) + End If + + ViewState("CveProveedor") = ObjProveedor.CveProveedor + HdnCveProveedor.Value = ObjProveedor.CveProveedor.ToString + TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString + RFCProv = ObjProveedor.RFC + CargaRetIVAConcepto(True) + CargaRetISRConcepto(True) + + If ObjProveedor.DIOTCveTipoOperacion = 1 Then '03 - Prestación de Servicios Profesionales + DdlRetIVAConcepto.SelectedValueExist("1") + DdlRetISRConcepto.SelectedValueExist("1") ' honorarios + ElseIf ObjProveedor.DIOTCveTipoOperacion = 2 Then ' 06 - Arrendamiento de inmuebles + DdlRetIVAConcepto.SelectedValueExist("4") + DdlRetISRConcepto.SelectedValueExist("2") ' arrendamiento + ElseIf ObjProveedor.DIOTCveTipoOperacion = 3 Then ' 85 - Otros + DdlRetIVAConcepto.SelectedValueExist("2") ' flete pf + DdlRetIVAConcepto.SelectedValueExist("3") ' fletes pm + DdlRetISRConcepto.SelectedValueExist("1") ' honorarios + End If + + LbAgregar.Enabled = True + UpPSS.Update() + UpPS.Update() + UpParametros.Update() + UPCondicionesPago.Update() + 'si tiene el habiltiado el módulo de Contratos + 'checo si tiene estimaciones + + 'CargaDatosEstimaciones(ObjProveedor.CveProveedor) + ImgBtnBuscarOC.OnClientClick = String.Format("AbrirVentana('/OC/PopUpBuscarReq.aspx?V=VOCCOMP&P={0}&T={1}&Masterimpoup=true',1000,600,'S'); return false;", ObjProveedor.CveProveedor, DdlTipoComprobante.SelectedValue) + CargaAnticipos(ObjProveedor.CveProveedor) : UpAnticipos.Update() + + If UsuarioActual.Empresa.UsaAC Then + If (TxtRetIVA.Text.ToDouble > 0 And Not ObjProveedor.IdCtaContRetIVA > 0) Or (TxtRetISR.Text.ToDouble > 0 And Not ObjProveedor.IdCtaContRetISR > 0) Then ' + ImgBtnBuscarOC.Visible = False + TxtOC.Enabled = False + BtnGuardar.Visible = False + Alert("El proveedor no tiene registrada cuentas contables de retenciones. Debe asignar las cuentas en el registro del proveedor.", TipoMensaje.MsgAdvertencia) + DivRestriccionAdvertencia.Visible = True + LtRestriccionAdvertencia.Text = "El proveedor no tiene registrada cuentas contables de retenciones." + End If + End If + + CargaGvAcarreos(ViewState("CveProveedor").ToString.ToEntero) + + + 'MONEDA PREFERENTE + If CveCompra <= 0 Then + If CveFactura <= 0 Then + DdlMoneda.SelectedValueExist(ObjProveedor.CveMonedaPreferente) + End If + CambiaMoneda(False) + End If + + + If CveProveedor > 0 Then + + Dim ObjSAT As New ClsSAT + Dim RFCRequest As String = ObjProveedor.RFC + If ObjSAT.GetListado69B(2, UsuarioActual.CveEmpresa, RFCRequest) Then + If ObjSAT.DtResultados.Rows.Count > 0 Then + Dim Estatus As String = ObjSAT.DtResultados.Rows(0)("Situacion").ToString + BtnGuardar.Enabled = False + UpParametros.Update() + + Alert($"El RFC del proveedor se encuentra en estado {Estatus} en el Listado EFOS (69B) del SAT", TipoMensaje.MsgAdvertencia) + System.Threading.Thread.Sleep(5) + End If + End If + ObjSAT.Dispose() + + End If + + + + Else + Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("Ocurrió un error al consultar el proveedor.", TipoMensaje.MsgError) + End If + + If UsuarioActual.Empresa.Funcionalidad(560) = "1" Then + If ObjProveedor.GetProveedoresEvaluacionPediente(Me.CveProveedor, UsuarioActual.CveEmpresa) Then + If ObjProveedor.DtResultados.Rows.Count > 0 Then + Me.RequiereEvaluacion = ObjProveedor.DtResultados.Rows(0)("RequiereEvaluacion").ToString() = "1" + Me.CveUsuarioEvaluador = ObjProveedor.DtResultados.Rows(0)("CveUsuarioEvaluador").ToString().ToEntero() + End If + End If + End If + + ObjProveedor.Dispose() + End Sub + + Private Sub CargaAnticipos(CveProveedor As Integer, Optional FiltroTipo As String = "-1") + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetAnticiposProveedor(CveProveedor, -1, CveMoneda:=-1, SelectTop:=-1, TipoDocto:=FiltroTipo) AndAlso ObjMovtos.DtResultados.Rows.Count > 0 Then + Dim CveMoneda As Integer = If(ChkPagarConPesos.Checked, 1, If(ChkPagarConDolares.Checked, 2, DdlMoneda.SelectedValue.ToEntero)) + If DdlMoneda.SelectedValue.ToEntero = 1 AndAlso CveCompra > 0 Then DivPagarConDolares.Visible = True Else If CveCompra > 0 Then DivPagarConPesos.Visible = True + GVAnticipos.DataSource = ObjMovtos.DtResultados.FiltraParametros($"Tipo = 'Act' AND CveMoneda = {CveMoneda}") + If ObjMovtos.DtResultados.FiltraParametros("Saldo > 0").Rows.Count > 0 Then + BtnAceptarAnticipos.Enabled = True + If DdlTipoComprobante.SelectedValue = "Fac" Then ImgAnticiposPendientes.Visible = True + End If + Else + GVAnticipos.DataSource = Nothing + End If + ObjMovtos.Dispose() + GVAnticipos.DataBind() + End Sub + + Private Sub CargaTiposAF() + ViewState("TmpDTTiposAF") = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa) + Dim Row As DataRow = DirectCast(ViewState("TmpDTTiposAF"), DataTable).NewRow() + Row("CveTipoActivoFijo") = -1 : Row("TipoActivoFijo") = "Seleccione" + DirectCast(ViewState("TmpDTTiposAF"), DataTable).Rows.InsertAt(Row, 0) + End Sub + + Public Function isWhitFamily() As Boolean + Return UsuarioActual.CveEmpresa = 66 + End Function + + Private Sub CargaPSAlias() + DdlPSAlias2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.CveEmpresa = 66 Then + DdlPSAlias2.ddlWS.Attributes.Add("data-subfamilia", "-1") + DdlPSAlias2.ddlWS.Attributes.Add("data-fueporxml", "0") + 'SOLO CUANDO SEA FACTURA DE INGRESOS + If DdlTipoComprobante.SelectedValue = "Fac" Then + DdlPSAlias2.ddlWS.Attributes.Add("data-pagina", "Compras") + Else + DdlPSAlias2.ddlWS.Attributes.Add("data-pagina", "Compras2") + End If + End If + If Not DdlPSAlias2.UsaWebService AndAlso CType(DdlPSAlias2.DataSource, DataTable) Is Nothing Then + DdlPSAlias2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlPSAlias2.DataBind() + End If + + End Sub + + Private Sub CargarUM(CvePS As Integer, ob As DropDownList) + Dim ObjUM As New ClsProductosServicios() + If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then + ViewState("DTUM") = ObjUM.DtResultados + ob.Items.Clear() + ob.DataSource = DTUM + ob.DataBind() + + End If + ObjUM.Dispose() + + End Sub + + Private Sub CargaGridTarjetas() + Dim ObjCreditos As New ClsBancos + ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero) + + DdlTarjeta.Items.Clear() + DdlTarjeta.DataSource = ObjCreditos.DtResultados + DdlTarjeta.DataBind() + DdlTarjeta.Items.Insert(0, New ListItem("Seleccione", "-1")) + + ObjCreditos.Dispose() + DivTarjeta.Visible = True + End Sub + + Private Sub CargaConceptosXML(XMLDoc As XmlDocument) + Dim i As Integer = 0 + + Dim Total As Decimal = 0 + Dim PU As Decimal = 0 + Dim Descuento As Double = 0 + Dim CveUM As Integer = 0 + Dim UMM As String = "No Aplica" + Dim tCvePS As Integer = 0 + Dim TipoPS As Integer = 0 + Dim tCveClasif As Integer = -1 + Dim Clasif As String = "Sin Clasificación" + Dim tPSCodigo As String = "-" + Dim tPSDescripcion As String = "-" + Dim PSS As String = "" + Dim Obs As String = "" + Dim SubTotalTemp = 0.0D + Dim IVA As Double = 0 + Dim IEPS As Double = 0 + Dim RetISR As Double = 0 + Dim RetIVA As Double = 0 + Dim PorcentajeIVA As Double = 0 + Dim PorcentajeIEPS As Double = 0 + Dim PorcentajeRetISR As Double = 0 + Dim PorcentajeRetIVA As Double = 0 + Dim DtTemporalGuardados = New DataTable + DtTemporalGuardados.Columns.Add("Contador", GetType(Integer)) + DtTemporalGuardados.Columns.Add("Tipo", GetType(Integer)) + + 'GLOBALS + Dim DtUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).AsEnumerable + Dim DtUMAlias = GlobalDTUnidadesMedidaAlias(UsuarioActual.CveEmpresa).AsEnumerable + Dim DtPS = GlobalDTPS(UsuarioActual.CveEmpresa).AsEnumerable + Dim DtPSAlias = GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa).AsEnumerable + + ''AGREGA EN TABLA TEMPORAL + 'Dim DtPSTemp = TmpDT.Clone + 'Dim Row As DataRow = Nothing + + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + + If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + Dim nodeconcepto As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + If nodeconcepto IsNot Nothing AndAlso nodeconcepto.ChildNodes.Count > 0 Then + Dim nodosConceptos As XmlNodeList = nodeconcepto.SelectNodes(String.Format("//{0}:Concepto", Prefijo), namespaces) + For Each node As XmlNode In nodosConceptos + + ' INICIALIZA VALORES + PU = 0 + Descuento = 0 + CveUM = 0 + UMM = "No Aplica" + tCvePS = 0 + TipoPS = 0 + tCveClasif = -1 + Clasif = "Sin Clasificación" + tPSCodigo = "-" + tPSDescripcion = "-" + PSS = "" + Obs = "" + Total = 0 + IVA = 0 + IEPS = 0 + RetISR = 0 + RetIVA = 0 + PorcentajeIVA = 0 + PorcentajeIEPS = 0 + PorcentajeRetISR = 0 + PorcentajeRetIVA = 0 + + + 'CARGA NODO ACTUAL + ' node = XMLDoc.DocumentElement.ChildNodes(2).ChildNodes(i) + + 'CARGA PU + PU = ValorXML(node, "valorUnitario").ToDecimal + + 'SI PU >= TOTAL AND CANTIDAD > 0 : PU / CANTIDAD, por si tiene descuento en el importe y el valor unitario es mayor, lo ajusta + If ValorXML(node, "cantidad").ToDecimal > 0 AndAlso ValorXML(node, "valorUnitario").ToDecimal >= (ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal) Then + PU = ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal + End If + If ValorXML(node, "cantidad").ToDecimal > 0 AndAlso ValorXML(node, "valorUnitario").ToDouble <= 0 And ValorXML(node, "importe").ToDouble > 0 Then + PU = ValorXML(node, "importe").ToDecimal / ValorXML(node, "cantidad").ToDecimal + End If + + + + + 'OBTIENE DESCUENTO + If ValorXML(node, "descuento") IsNot Nothing Then Descuento = ValorXML(node, "descuento").Trim.ToDouble + + 'OBTIENE TOTAL + If ValorXML(node, "importe") IsNot Nothing Then Total = ValorXML(node, "importe").Trim.ToDecimal + + 'OBTIENE SUBTOTAL + SubTotalTemp += If(Total > 0, Total, PU * ValorXML(node, "cantidad").ToDecimal) + + + 'OBTIENE UM + If ValorXML(node, "unidad") IsNot Nothing Then UMM = ValorXML(node, "unidad").Trim + 'BUSCA UM EN CATALOGO + UMM = UMM.ToUpper.Replace(".", "").Replace(",", "") + Dim fUM = (From u In DtUM + Where String.Compare(u!UnidadMedida.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 OrElse + String.Compare(u!Abreviatura.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 + Select CveUnidadMedida = u!CveUnidadMedida, UnidadMedida = u!UnidadMedida).FirstOrDefault() + If fUM IsNot Nothing AndAlso fUM.CveUnidadMedida.ToString.ToEntero > 0 Then + CveUM = fUM.CveUnidadMedida.ToString.ToEntero + UMM = fUM.UnidadMedida.ToString + Else + + 'BUSCA UM EN ALIAS + Dim fUMAlias = (From u In DtUMAlias + Where String.Compare(u!UnidadMedidaAlias.ToString.ToUpper.Trim, UMM, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 + Select u!CveUnidadMedida, u!UnidadMedida).FirstOrDefault() + + If fUMAlias IsNot Nothing Then + CveUM = fUMAlias.CveUnidadMedida.ToString.ToEntero + UMM = fUMAlias.UnidadMedida.ToString + End If + End If + + + + 'se le puso una condicion de que ignorara los acentos, porque en la bd, marcaria error porque no distingue acentos + 'CONCEPTO PRUEBA "TRABAJOS DE CONSTRUCCION", RM/Compras/Compras.aspx?CveFactura=13402&RFC=ECO061206QW7 + '' u!PS.ToString.ToUpper.Trim = PSS + + + 'BUSCA PS + + PSS = ValorXML(node, "descripcion").ToUpper.Trim.Replace(vbCrLf, " ").Replace(vbLf, " ").Replace("'", "''").Replace(" ", " ").Replace("�", "") + If PSS.Length > 844 Then + PSS = PSS.Substring(0, 844) '844,por ser el numero de caracteres aceptados en la columna de la BD + End If + tPSCodigo = PSS + + 'BUSCA PS EN CATALOGO + Dim fPS = (From u In DtPS + Where String.Compare(u!PS.ToString.ToUpper.Trim, PSS, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 + Select u!CvePS, u!CveClasificacion, u!Clasificacion, u!CveTipoPS, u!PSCodigo).FirstOrDefault() + + If fPS IsNot Nothing Then + PSS = fPS.PSCodigo.ToString + tCvePS = fPS.CvePS.ToString.ToEntero + TipoPS = fPS.CveTipoPS.ToString.ToEntero + tCveClasif = fPS.CveClasificacion.ToString.ToEntero + Clasif = fPS.Clasificacion.ToString + tPSCodigo = fPS.PSCodigo.ToString + Else + 'BUSCA PS EN ALIAS + Dim fPSAlias = (From u In DtPSAlias + Where String.Compare(u!PSAlias.ToString.ToUpper.Trim, PSS, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) = 0 + Select u!CvePS, u!PS, u!CveClasificacion, u!Clasificacion, u!CveTipoPS, u!PSCodigo).FirstOrDefault() + If fPSAlias IsNot Nothing Then + Obs = PSS + PSS = fPSAlias.PS.ToString + tCvePS = fPSAlias.CvePS.ToString.ToEntero + TipoPS = fPSAlias.CveTipoPS.ToString.ToEntero + tCveClasif = fPSAlias.CveClasificacion.ToString.ToEntero + Clasif = fPSAlias.Clasificacion.ToString + tPSCodigo = fPSAlias.PSCodigo.ToString + End If + End If + + + 'PARA GLUYAS + If UsuarioActual.CveEmpresa = 66 Then + tPSCodigo = String.Format("{1} - {0}", ValorXML(node, "descripcion").ToUpper.Trim.Replace(vbCrLf, " ").Replace(vbLf, " ").Replace("'", "''"), ValorXML(node, "noIdentificacion").Trim) + End If + + + If Version = "3.3" Then + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + 'OBTENER TRASLADOS POR DETALLES + Dim ContadorTraslado = 0 + Dim nodosConceptosTraslado As XmlNodeList = node.SelectNodes(String.Format("//{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) + For Each nodeTraslado As XmlNode In nodosConceptosTraslado + + If Not DtTemporalGuardados.FiltraParametros($"Contador = {ContadorTraslado} AND Tipo = 1").Rows.Count > 0 Then + If ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal > 0 And ValorXML(nodeTraslado, "Base").Trim.ToDecimal = Total Then + If ValorXML(nodeTraslado, "Impuesto") = "002" Then + IVA = ValorXML(nodeTraslado, "Importe").Trim.ToDecimal + PorcentajeIVA = ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal + Dim Dr As DataRow + Dr = DtTemporalGuardados.NewRow() + Dr("Contador") = ContadorTraslado + Dr("Tipo") = 1 + DtTemporalGuardados.Rows.Add(Dr) + DtTemporalGuardados.AcceptChanges() + Exit For + ElseIf ValorXML(nodeTraslado, "Impuesto") = "003" Then + IEPS = ValorXML(nodeTraslado, "Importe").Trim.ToDecimal + PorcentajeIEPS = ValorXML(nodeTraslado, "TasaOCuota").Trim.ToDecimal + Dim Dr As DataRow + Dr = DtTemporalGuardados.NewRow() + Dr("Contador") = ContadorTraslado + Dr("Tipo") = 1 + DtTemporalGuardados.Rows.Add(Dr) + DtTemporalGuardados.AcceptChanges() + Exit For + End If + + End If + End If + ContadorTraslado += 1 + Next + + 'OBTENER RETENCIONES POR DETALLES + Dim ContadorRetenciones = 0 + Dim nodosConceptosRetenciones As XmlNodeList = node.SelectNodes(String.Format("//{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) + For Each nodeRetencion As XmlNode In nodosConceptosRetenciones + + If Not DtTemporalGuardados.FiltraParametros($"Contador = {ContadorRetenciones} AND Tipo = 2").Rows.Count > 0 Then + If ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal > 0 And ValorXML(nodeRetencion, "Base").Trim.ToDecimal = Total Then + If ValorXML(nodeRetencion, "Impuesto".Trim) = "001" Then + RetISR = ValorXML(nodeRetencion, "Importe").Trim.ToDecimal + PorcentajeRetISR = ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal + Dim Dr As DataRow + Dr = DtTemporalGuardados.NewRow() + Dr("Contador") = ContadorRetenciones + Dr("Tipo") = 2 + DtTemporalGuardados.Rows.Add(Dr) + DtTemporalGuardados.AcceptChanges() + Exit For + ElseIf ValorXML(nodeRetencion, "Impuesto") = "002" Then + RetIVA = ValorXML(nodeRetencion, "Importe").Trim.ToDecimal + PorcentajeRetIVA = ValorXML(nodeRetencion, "TasaOCuota").Trim.ToDecimal + Dim Dr As DataRow + Dr = DtTemporalGuardados.NewRow() + Dr("Contador") = ContadorRetenciones + Dr("Tipo") = 2 + DtTemporalGuardados.Rows.Add(Dr) + DtTemporalGuardados.AcceptChanges() + Exit For + End If + + End If + End If + ContadorRetenciones += 1 + Next + End If + + End If + + If Version = "3.2" Then + + + + + Try + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + Dim ContadorTraslado = 0 + Dim nodosConceptosTraslado As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) + + For Each nodeTraslado As XmlNode In nodosConceptosTraslado + If ValorXML(nodeTraslado, "tasa").Trim.ToDecimal > 0 And ValorXML(nodeTraslado, "impuesto").Trim = "IVA" Then + PorcentajeIVA = ValorXML(nodeTraslado, "tasa").Trim.ToDecimal + Alert($"{PorcentajeIVA}") + End If + Next + End If + Catch ex As Exception + + End Try + + End If + + + + '' AGREGA PS + 'AGREGA A TMPDT + AddPS(ValorXML(node, "cantidad").ToDouble, CveUM, UMM, tCveClasif, Clasif, tCvePS, PSS, TipoPS, "-1", "SE", "SE", "-1", Obs, PU, Total, IVA, RetIVA, RetISR, IEPS, 0, Descuento, PSCodigo:=tPSCodigo, TCalculaTotales:=False, CveSATPS:=ValorXML(node, "ClaveProdServ").ToEntero(), CargaXml:=True, PorcentajeIVA:=PorcentajeIVA, PorcentajeRetIVA:=PorcentajeRetIVA, PorcentajeRetISR:=PorcentajeRetISR, PorcentajeIEPS:=PorcentajeIEPS) + + Next + End If + + AddPS2(False) + + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + + If isAlmacenistaGluyas() Then + BtnGuardar.Visible = False + AlmacenCambiaPS.Visible = True + End If + + SubTotalConceptos = Math.Round(SubTotalTemp, 2) + 'TmpDT = DtPSTemp.Copy + 'DtPSTemp.Dispose() + + End Sub +#End Region + +#Region "Vinculacion De Servcios" + Private Function isAdminObraGluyas() As Boolean + Return (UsuarioActual.CveRol = 1047 And UsuarioActual.CveEmpresa = 66) + End Function + Private Sub cargaddlVinculacionServcios() + If isAdminObraGluyas() Then + TabVinculacionServicios.Visible = True + 'Dim productos As New ClsProductosServicios + 'If productos.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then + ' PSDTRemplazo = productos.DtResultados.FiltraParametros("CveTipoPS=2", "PS") + 'End If + 'productos.Dispose() + GVVinculacionServicios.DataSource = TmpDT + GVVinculacionServicios.DataBind() + End If + End Sub + Protected Sub GVVinculacionServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVVinculacionServicios.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim dt As DataTable = Nothing + dt = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS=2", "PS") + e.Row.FCDropDownList("Ddlnewps").DataSource = dt 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("Ddlnewps").DataBind() + e.Row.FCDropDownList("Ddlnewps").Items.Insert(0, New ListItem("Seleccione", "-1")) + dt.Dispose() + + End If + End Sub + +#End Region + +#Region "BTN'S" + Protected Sub BtnVincularServicios_Click(sender As Object, e As EventArgs) Handles BtnVincularServicios.Click + Dim correcto As Boolean = True + Dim x As Integer = 0 + 'Dim buid As New StringBuilder + For Each Dr As DataRow In TmpDT.Rows + Dim newps As Integer = GVVinculacionServicios.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero + If newps > 0 Then + 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) + Dr("CvePS") = newps + 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) + Else 'limpio el valor para que no truene en linq mas abajo + correcto = False + Alert("Favor de vincular todos los servicios", TipoMensaje.MsgAdvertencia) + Exit For + End If + x = x + 1 + Next + x = 0 + For Each Dr As DataRow In GVVinculacionServicios.Rows + Dim newps As Integer = GVVinculacionServicios.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero + If newps > 0 Then + 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) + Dr("CvePS") = newps + 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) + Else 'limpio el valor para que no truene en linq mas abajo + correcto = False + Alert("Favor de vincular todos los servicios", TipoMensaje.MsgAdvertencia) + Exit For + End If + x = x + 1 + Next + + TmpDT.AcceptChanges() + 'Alert(buid.ToString) + If correcto Then + If Not CierrePeriodo Then + BtnGuardar.Visible = True + End If + UpFacturar.Update() + End If + End Sub + + Protected Sub BtnCargarProveedores_Click(sender As Object, e As System.EventArgs) Handles BtnCargarProveedores.Click + DdlProveedor.CssClass += " select2me" + DdlProveedor.AutoPostBack = True + DdlProveedor.Items.Clear() + DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + 'Dim ObjProveedor As New ClsCompProveedores + 'If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then + 'DdlProveedor.DataSource = ObjProveedor.DtResultados + 'End If + DdlProveedor.DataBind() + DdlProveedor.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) + DdlProveedor.Attributes.Remove("onclick") + + 'RegistraScript("$('#C_DdlProveedor').select2('open');") + End Sub + + Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click + ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero + CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1") + + If DdlPS.SelectedValue IsNot Nothing AndAlso DdlPS.SelectedValue.ToEntero > 0 Then + DdlPS_SelectedIndexChanged(sender, e) + DdlPS.Focus() + Else + TxtCantidad.Focus() + End If + + End Sub + + Protected Sub BtnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click + + '------------------INICIA VALIDACIONES------------------ + Dim EstatusCredito As Integer = 0 + 'Credito Multiple + If RBLPago.SelectedValue.ToEntero = 4 Then + + Dim DifCreCompra As Decimal = 0 + Dim TotalCreditos As Decimal = 0 + Dim MensualidadMultipleTotal As Decimal = 0 + Dim CveUltimoCreditoDetalleInterno As Integer + + For Each GvRow As GridViewRow In GvCreditos.Rows + + Dim CapitalMiltiple As Decimal = GvRow.FCTextBox("TxtCapital").Text.ToDecimal + Dim InteresMiltiple As Decimal = GvRow.FCTextBox("TxtInteres").Text.ToDecimal + + Dim AmbosMiltiple As Decimal = GvRow.FCTextBox("TxtAmbos").Text.ToDecimal + Dim MensualidadMultiple As Decimal = GvRow.DataKey("Mensualidad").ToDecimal + + If CapitalMiltiple > 0 Or InteresMiltiple > 0 Then + + TotalCreditos = TotalCreditos + CapitalMiltiple + InteresMiltiple + MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple + CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero + + ElseIf AmbosMiltiple > 0 Then + + TotalCreditos = TotalCreditos + AmbosMiltiple + MensualidadMultipleTotal = MensualidadMultipleTotal + MensualidadMultiple + CveUltimoCreditoDetalleInterno = GvRow.DataKey("CveCreditoDetalle").ToEntero + EstatusCredito = GvRow.DataKey("Estatus").ToEntero + End If + Next + + If TotalCreditos <> TxtTotal.Text.ToDecimal Then + Alert($"El importe de La factura no concide con el total de los creditos, diferencia: { (TotalCreditos - TxtTotal.Text.ToDecimal).FormatoNumero(2)}", TipoMensaje.MsgAdvertencia) + Exit Sub + + End If + End If + + 'Si se marcó No Deducible en el encabezado mínimo se debe registrar un No Deducible en el Detalle + Dim GuardaNoDeducibles As Boolean = False + If ChkEsNoDeducible.Checked Then + For Each Row As DataRow In TmpDT.Rows + If Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1") Then + GuardaNoDeducibles = True + End If + Next + If GuardaNoDeducibles = False Then + Alert("Si la compra es No Deducible, mínimo se debe registrar un producto No Deducible", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + + If CierrePeriodo Then + Alert("El periodo de la compra actual ya se encuentra cerrado. No podra registrar la compra.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'DF - 10/04/2017 + If UsuarioActual.TienePermisoProceso(187) Then + If TxtSerie.Text <> SerieVieja Then + Dim SerieNueva As String = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).FiltroPrimeroValor("Serie", $"Serie = '{TxtSerie.Text}'").ToString + If SerieNueva = "" Then + Alert("La Serie no es válida, por favor revise que se encuentre dentro de la lista de las sucursales del proveedor.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + + 'Excede el limite de credito + If RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac") AndAlso UsuarioActual.Empresa.Funcionalidad(518) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(185) Then + Dim ObjCompras As New ClsCompras + If ObjCompras.ObtenerCreditoRestante(CveProveedor) Then + If ObjCompras.DtResultados.Rows.Count > 0 Then + Dim Saldo As Decimal = ObjCompras.DtResultados(0)("Saldo").ToString.ToDecimal + TxtTotal.Text.ToDecimal + Dim LimiteCredito As Decimal = ObjCompras.DtResultados(0)("LimiteCredito").ToString.ToDecimal + + If LimiteCredito > 0 Then + If Saldo / LimiteCredito * 100 > 90 Then + Alert($"Nuestro Limite de Credito con este proveedor supera el 90%
Porcentaje Actual: {(Saldo / LimiteCredito * 100).FormatoNumero(2)}%", TipoMensaje.MsgAdvertencia) + End If + End If + Else + ObjCompras.Dispose() + Alert("El proveedor no tiene límite de crédito", TipoMensaje.MsgError) + Exit Sub + End If + Else + ObjCompras.Dispose() + Alert("Ocurrio un error al obtener el limite de credito del Proveedor", TipoMensaje.MsgError) + Exit Sub + End If + ObjCompras.Dispose() + End If + + If Not (HFDiferenciaCompra.Value = TxtTotal.Text Or CveFactura < 1 Or CveCompra < 1) Then + Alert("La compra no se puede registrar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError) + Exit Sub + End If + + 'UM EQUIVALENCIAS + For Each gvr As GridViewRow In GvPS.Rows + If gvr.DataKey("CvePS").ToString.ToEntero > 0 Then + If gvr.DataKey("CveUM").ToString.ToEntero = 0 Then + Alert("Existe un error, Unidad de Medida no registrada", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + Next + + If ChkConsignacion.Checked Then + For Each gvr As GridViewRow In GvInv.Rows + If gvr.FCDropDownList("DdlVinculaConsignacion").SelectedValue.ToEntero < 0 Then + Alert("Si la compra aplica consignación debe vincular todos los conceptos en Almacén.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + End If + + If RowProveedorSucursal.Visible And DdlProveedorSucursal.SelectedValue.ToEntero = -1 Then + Alert("Favor de seleccionar una sucursal del proveedor", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.TienePermisoProceso(121) Then + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + If Not NCDevolucion Then + Alert("Favor de seleccionar un producto en la pestaña de almacen", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Else + Dim x As Integer = 0 + For Each Dr As GridViewRow In GvInv.Rows + If Dr.FCCheckBox("cbInv").Checked Then + x = x + 1 + End If + Next + If x = 0 AndAlso GvInv.Rows.Count > 0 Then + Alert("Favor de seleccionar un producto en la pestaña de almacen", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(538).ToEntero = 1 Then + If TmpDT.MIN("CvePS").ToEntero <= 0 Then + Alert("Todos los Productos/Servicios deben estar registrados o aliados a un productos ya registrado.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(123).ToEntero > 0 And Not UsuarioActual.TienePermisoProceso(156) Then + If Not ValidaCierrePeriodo() Then + Alert("No se puede registar la compra. Se ha cerrado el periodo de la compra actual", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Dim TotalPorDevengar = Math.Round(TxtTotal.Text.ToDouble, 2) + Dim TotalDetalle = 0.0 + Dim RequiereCentroCosto As Boolean = False + + 'If Not (UsuarioActual.Empresa.Funcionalidad(102) = "") Then + ' Dim NotHas117 As Boolean = Not UsuarioActual.TienePermisoProceso(117) + ' 'verifica que tenga proyecto y clasificacion + For Each Row As DataRow In TmpDT.Rows + If Row("CveSubProyecto").ToString.ToEntero <= 0 Then + Alert("No se ha completado la asignacion de proyectos en la compra. ", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then 'If NotHas117 AndAlso Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then + Alert("Hay productos que no tienen clasificación asignada.
Favor de asignarle una y darle guardar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then + If Row("CveTipoGasto").ToString.ToEntero <= 0 Then + Alert("No se ha completado la asignacion de tipos de gasto en la compra.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + Next + 'End If + + 'SI LA CANTIDAD EN SERIE/LOTE NO ES IGUAL A CANTIDAD EN GVPS + 'Dim DtDetalles As DataTable + Dim Cantidad As Integer + + If GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True Then + For Each Dr As DataRow In DtInv.Rows + If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then + Cantidad = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS").ToString)).Rows.Count + If Cantidad < Dr("Cantidad").ToString.ToEntero Then + Alert("No hay productos a los que no se le ha asociado Serie-Lote", TipoMensaje.MsgError) + Exit Sub + End If + End If + Next + End If + + If Not HdnCveProveedor.Value <> "-1" Then + Alert("En necesario seleccionar un proveedor, al cual se le va a facturar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not TmpDT.Rows.Count > 0 Then + Alert("Es necesario agregar al menos un Producto o Servicio a la factura.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'VALIDA SI LA CLASIFICACIÓN REQUIERE PERSONAL, AF COMPRA O AF INSUMO + Dim ErrorValidacion As Boolean = False + Dim DtTemporal As New DataTable + DtTemporal.Columns.Add("CveClasificacion", GetType(Integer)) + For Each Gvr As GridViewRow In GvPS.Rows + Dim Dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros($"CveClasificacion = {Gvr.DataKey("CveClasificacion").ToEntero}")(0) + If Dr IsNot Nothing Then + Dim SeValido As Boolean = False + For Each Drt As DataRow In DtTemporal.Rows + If Drt("CveClasificacion").ToString.ToEntero = Dr("CveClasificacion").ToString.ToEntero Then + SeValido = True + Exit For + End If + Next + If Not SeValido Then + If CBool(Dr("RequierePersonal")) Then + For Each GvP As GridViewRow In GvPersonal.Rows + If GvP.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then + If Not GvP.FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero > 0 Then + ErrorValidacion = True + Alert($"Tiene que seleccionar un personal para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) + Exit For + End If + End If + Next + End If + If CBool(Dr("RequiereAFCompra")) Then + For Each GvAFC As GridViewRow In GvAFCompras.Rows + If GvAFC.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then + If Not GvAFC.FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + ErrorValidacion = True + Alert($"Tiene que seleccionar un AF compra para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) + Exit For + End If + End If + Next + End If + If CBool(Dr("RequiereAFInsumo")) Then + For Each GvAFI As GridViewRow In GvAFInsumos.Rows + If GvAFI.DataKey("CveClasificacion").ToEntero = Dr("CveClasificacion").ToString.ToEntero Then + If Not GvAFI.FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + ErrorValidacion = True + If Not SeValido Then + Alert($"Tiene que seleccionar un AF insumo para esta clasificación: {Dr("Clasificacion").ToString}.", TipoMensaje.MsgAdvertencia) + End If + Exit For + End If + End If + Next + End If + Dim Drr As DataRow = DtTemporal.NewRow + Drr("CveClasificacion") = Dr("CveClasificacion").ToString.ToEntero + DtTemporal.Rows.Add(Drr) + End If + End If + Next + If ErrorValidacion Then Exit Sub + + '------------------TERMINA VALIDACIONES------------------ + + 'RECORRO LOS PRODUCTOS O SERVICIOS PARA REGISTRARLOS LOS QUE NO EXISTEN EN EL CATÁLOGO + Dim tCve As Integer + Dim RegeneraPS As Boolean = False + 'OBJETOS PROVISIONALES + Dim UM As New ClsUnidadesMedida + Dim PSS As New ClsProductosServicios + Dim Correcto = True + + For Each Row As DataRow In TmpDT.Rows + + 'VALIDACION DE CENTRO DE COSTO + If UsuarioActual.Empresa.RequiereCentroCostos AndAlso Row("CveSubProyecto").ToString.ToEntero <= 0 Then + RequiereCentroCosto = True + UM.Dispose() + PSS.Dispose() + Alert("Falta asignar Proyecto a la compra", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'REGISTRO LAS UNIDADES DE MEDIDA + If Row("CveUM").ToString.ToEntero = 0 Then + tCve = UM.AddUnidadMedida(Row("UM").ToString, Row("UM").ToString, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) + If tCve > 0 Then + Row("CveUM") = tCve + Dim rowsToUpdate = TmpDT.AsEnumerable().Where(Function(r) r.Field(Of String)("UM").ToString.ToUpper = Row("UM").ToString.ToUpper AndAlso r!CveUM.ToString.ToEntero = 0) + For Each roww As DataRow In rowsToUpdate + roww.SetField("CveUM", tCve) + Next + Else + Correcto = False + End If + End If + + 'REGISTRO LOS PRODUCTOS + If Row("CvePS").ToString.ToEntero = 0 Then + tCve = PSS.AddPS(Row("CveClasificacionActualizar").ToString.ToEntero, -1, Row("CveUM").ToString.ToEntero, "", "", "", Row("PS").ToString, Row("PU").ToString.ToDouble, If(TxtIVA.Text.ToDouble > 0, -1, 0), 0, False, 0, True, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, 0) + If tCve > 0 Then + RegeneraPS = True + Row("CvePS") = tCve + Row("CveClasificacion") = Row("CveClasificacionActualizar").ToString.ToEntero + 'Row("CveEq") = 1 + TmpDT.AcceptChanges() + + 'busco el mismo PS dentro de la tabla por si está más de una vez y lo actualizo + Dim rowsToUpdate = TmpDT.AsEnumerable().Where(Function(r) r.Field(Of String)("PS") = Row("PS").ToString AndAlso r!CvePS.ToString.ToEntero = 0) + For Each roww As DataRow In rowsToUpdate + roww.SetField("CvePS", tCve) + roww.SetField("CveClasificacion", Row("CveClasificacionActualizar").ToString.ToEntero) + 'roww.SetField("CveEq", 1) + Next + TmpDT.AcceptChanges() + Else + Correcto = False + End If + Else + 'UPDATE CLASIFICACION DE PRODUCTO YA REGISTRADO + If Row("CveClasificacionActualizar").ToString.ToEntero > 0 AndAlso Row("CveClasificacion").ToString.ToEntero <= 0 Then + If PSS.UpdateClasificacionPS(Row("CveClasificacionActualizar").ToString.ToEntero, UsuarioActual.CveUsuario, Row("CvePS").ToString.ToEntero) Then + Row("CveClasificacion") = Row("CveClasificacionActualizar").ToString.ToEntero + RegeneraPS = True + Else + Correcto = False + End If + End If + End If + Next + UM.Dispose() + PSS.Dispose() + + 'si hay necesidad de actualizar el globaldtps + If RegeneraPS Then + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) + 'Hilo.Start() + GeneraGlobalDT(Nothing) + End If + + Dim CvePlantillaPrePoliza As Integer + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + Dim tIdContaProveedor As Integer = CtaProveedor + Dim ImporteAnticipo As Decimal = 0 + + If (ArrAnticipos.Count > 0 And CveCompra > 0) Or (ArrAnticipos.Count > 0 And UsuarioActual.Empresa.UsaAC) Then '-- ESTO SE QUITO - IPP - 04 NOVIMEBRE 2016 + CvePlantillaPrePoliza = 52 + 'cuenta de anticipos + tIdContaProveedor = CtaProveedorAnticipos + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + ImporteAnticipo += Ant.Importe + Next + If Math.Round(ImporteAnticipo, 2) > TxtTotal.Text.ToDouble Then + Alert("El Importe seleccionado es mayor a la compra", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + End If + + If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + If EmpresaPrueba Then + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + Else + CvePlantillaPrePoliza = 9 + End If + End If + + 'If RBLPago.SelectedValue.ToEntero = 4 And UsuarioActual.CveEmpresa.Contiene(1, 7) Then + ' CvePlantillaPrePoliza = 69 + 'End If + + TmpDT.AcceptChanges() + If Correcto Then + + 'VALIDA IMPORTES + If Not ValidaTotalesGuardar() Then + Exit Sub + End If + + + Dim ObjCompras As New ClsCompras() + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) + Dim ObjIE As New ClsBancos(ObjCompras.IniciaTransacSQL) + Dim ObjInventario As New ClsInventarios(ObjCompras.IniciaTransacSQL) + Dim ObjAF As New ClsAF(ObjCompras.IniciaTransacSQL) + Dim ObjOC As New ClsOC(ObjCompras.IniciaTransacSQL) + Dim ObjContratos As New ClsContratos(ObjCompras.IniciaTransacSQL()) + Dim ObjProveedores As New ClsCompProveedores(ObjCompras.IniciaTransacSQL()) + Dim ObjEventos As New ClsOIEventos(ObjCompras.IniciaTransacSQL()) + Dim ObjAcar As New ClsAcarreos(ObjCompras.IniciaTransacSQL()) + Dim ObjCGame As New ClsCGame(ObjCompras.IniciaTransacSQL()) + Dim ObjProductosServicios As New ClsProductosServicios(ObjCompras.IniciaTransacSQL()) + + + Dim ObjContaAC As ClsContPAQi = Nothing + + Dim ErrorMovtosCxP As Boolean = False + Dim ErrorPrepoliza As Boolean = False + Dim ErrorPrepolizaDescuadre As Boolean = False + Dim ErrorMovtosRetIVA As Boolean = False + Dim ErrorMovtosRetISR As Boolean = False + Dim ErrorMovtosEstimaciones As Boolean = False + Dim ErrorMovtosIVA As Boolean = False + Dim ErrorMovtosIE As Boolean = False + Dim ErrorMovInv As Boolean + Dim ErrorMovDev As Boolean = False + Dim ErrorOC = False + Dim TieneError As Boolean = False + Dim ErrorAC As Boolean = False + Dim ErrorAF As Boolean = False + Dim ErrorReembolso As Boolean = False + Dim ErrorBitacora = False + Dim ErrorAddAcarreos As Boolean = False + Dim ErrorCreditosCompra As Boolean = False + Dim ErrorOtrosGastos As Boolean = False + Dim ErrorSATPS As Boolean = False + Dim ErrorACMEnsaje As New StringBuilder + Dim ErrorSaldosInvComp As Boolean = False + + Dim CveIE As Integer = -1 + Dim CveEstatusFactura As Integer = 1 + Dim PolizaFolio As Integer = 0 + Dim CvePrePoliza As Integer + Dim ImporteCompra As Decimal = TxtTotal.Text.ToDecimal + Dim MultiplicadorNC = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) + Dim CveMovimientoInventario As Integer = -1 + Dim IVA = 1.16 + Dim ListaMovimientosAlmacen As New List(Of Integer) + + Dim ErrorCreditoCapitalIntres As Boolean = False + Dim ErrorCredito As Boolean = False + + If ChkProgramarPago.Checked Then + CveEstatusFactura = 2 + End If + Dim EntregaDirecta = False + + Dim ConceptoPoliza As String = String.Format("{0} - {1}{2} - {3}", NombreProveedor, TxtSerie.Text, TxtFolio.Text, TxtDescripcion.Text.Trim) + + 'TIPO CAMBIO MANUAL CON COMPRA NUEVA + Dim TipoCambioGuardar = 1.0 + If DdlMoneda.SelectedValue.ToEntero > 1 Then + TipoCambioGuardar = If(DivTC.Visible, TxtTC.Text.ToDouble, LblTC.Text.Substring(3).ToDouble) + End If + TipoCambio = If(DivTC.Visible, TipoCambioGuardar, TipoCambio) + + Try + Dim FolioFijo As Integer = 0 + 'cheque + If DdlTipoTransaccion.SelectedValue = "1" Then FolioFijo = TxtFolio.Text.ToEntero + + CvePrePoliza = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) + + If CvePrePoliza > 0 Then + + 'seria de contado, solo cuando no tenga vinculado ningun anticipo + Dim ImportePago As Decimal = 0 + Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal + Dim CveMonedaPago As Integer = DdlMoneda.SelectedValue.ToEntero + + If RBLPago.SelectedValue.ToEntero = 2 Then 'Contado + + If RBLContado.SelectedValue = "1" Then + ImportePago = TxtDocumentoImporte.Text.Trim.ToDecimal + Dim Dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0) + + If Dr IsNot Nothing Then + CveMonedaPago = Dr("CveMoneda").ToString.ToEntero + End If + + If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then + ImportePago = (ImportePago * TCPago).RoundSQL + ElseIf CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + ImportePago = (ImportePago / TCPago).RoundSQL + ElseIf CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + TCPago = 1 + End If + + 'se registra primero el movimiento en bancos para luego vincularlo en la compra + CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, ImportePago, CveMonedaPago, TCPago, TxtDocumentoObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1)) + ElseIf RBLContado.SelectedValue = "6" Then + ImportePago = TxtDocumentoImporteCaja.Text.Trim.ToDecimal + Dim Dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuentaCaja.SelectedValue}").Rows(0) + If Dr IsNot Nothing Then + CveMonedaPago = Dr("CveMoneda").ToString.ToEntero + End If + + If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then + ImportePago = (ImportePago * TCPago).RoundSQL + ElseIf CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + ImportePago = (ImportePago / TCPago).RoundSQL + ElseIf CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + TCPago = 1 + End If + + 'se registra primero el movimiento en bancos para luego vincularlo en la compra + CveIE = ObjIE.AddBancos_IE(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolioCaja.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, ImportePago, CveMonedaPago, TCPago, TxtDocumentoObservacionesCaja.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + End If + + If (RBLContado.SelectedValue = "1" OrElse RBLContado.SelectedValue = "6") AndAlso Not CveIE > 0 Then + ErrorMovtosIE = True + End If + End If + + If Not ErrorMovtosIE Then + + 'REEMBOLSOS NO USA AC + Dim NumeroReembolso = "-1" + If TxtNumeroReembolso IsNot Nothing And RBLPago.SelectedValue = "3" Then + NumeroReembolso = TxtNumeroReembolso.Text + + ''GUARDA VALORES PARA SESSION + UsuarioActual.Sesion("Comp-NumeroReembolso") = TxtNumeroReembolso.Text + UsuarioActual.Sesion("Comp-CveFYE") = DdlPersonalReembolso.SelectedValue + UsuarioActual.Sesion("Comp-Descripcion") = TxtDescripcion.Text + + If NumeroReembolso <> "-1" Then + If CvePersonal <= 0 And CveCajaChica <= 0 Then + ErrorReembolso = True + End If + End If + Else + UsuarioActual.Sesion("Comp-NumeroReembolso") = "" + End If + + + If Not ErrorReembolso Then + + 'PORCENTAJE IVA + Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + + 'If DdlIVA.SelectedValue.ToDouble = 1.16 Then + ' PorcentajeIVA = 0.16 + 'ElseIf DdlIVA.SelectedValue.ToDouble = 1.08 Then + ' PorcentajeIVA = 0.08 + 'End If + + 'METODO DE PREPOLIZA DE ALMACEN + If UsuarioActual.CveEmpresa.Contiene(1, 119, 72, 80, 140, 141) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal + If ImporteAlmacen > 0 Then + If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + If (CveImportacion > 0 Or CveFlete > 0) Then + CveConceptoContableAlmacen = CveConceptoContableAlmacen + Else + CveConceptoContableAlmacen = 205 + End If + If OCVinculada And Not (CveImportacion > 0 Or CveFlete > 0) Then + CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero + End If + If UsuarioActual.CveEmpresa.Contiene(72, 80, 140, 141) Then + CveConceptoContableAlmacen = 205 + End If Else - CveConceptoContableAlmacen = 225 - End If - - 'Condiciones para los casos de facturas que son en 0 pero que se utiliza el almacen - ElseIf OCVinculada AndAlso Not (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero - ElseIf (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - CveConceptoContableAlmacen = CveConceptoContableAlmacen - End If - End If - - - If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(1, 101) Then - CveEstatusFactura = 6 - End If - 'hay amortización directa como descuento. RMF Temporal + CveConceptoContableAlmacen = 225 + End If + + 'Condiciones para los casos de facturas que son en 0 pero que se utiliza el almacen + ElseIf OCVinculada AndAlso Not (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero + ElseIf (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + CveConceptoContableAlmacen = CveConceptoContableAlmacen + End If + End If + + + If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(1, 101) Then + CveEstatusFactura = 6 + End If + 'hay amortización directa como descuento. RMF Temporal If UsuarioActual.CveEmpresa = 119 Then 'If LblAmortizacion.Text.ToDouble > 0 AndAlso TxtDescuento.Text.ToDouble = 0 Then ' TxtDescuento.Text = LblAmortizacion.Text @@ -4445,1450 +4445,1450 @@ Partial Class Compras_Compras ' LblAmortizacion.Text = "0.00" 'End If - End If - - 'Compra - If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble, - LblAmortizacion.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtOtrosImpuestos.Text.ToDouble, - TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura, - CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero, - AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen, - CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto) Then - - ViewState("CveCompra") = ObjCompras.CveCompra - If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - ErrorMovDev = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate) - End If - Dim ErrorDetalles As Boolean = False - ' Dim IDPoliza As Integer - Dim IDPolizaComprometido = 0 - Dim ErrorComprometido = False - - If CveImportacion > 0 Or CveFlete > 0 Then - - - Select Case CveConceptoContableAlmacen - Case 237 - Select Case FleteImportacionOpcion - Case 1 - Dim Dr As DataRow = Nothing - If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - Dr = ObjInventario.DtResultados.Rows(0) - End If - End If - If Dr IsNot Nothing Then - If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then - ErrorOC = True - End If - Else - ErrorOC = True - End If - Case 2 - If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then - ErrorOC = True - End If - 'actualiza la compra para que no se surta en almacen. sino por el flete o importación - If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then - ErrorOC = True - End If - End Select - Case 240 - Select Case FleteImportacionOpcion - Case 1 - If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then - ErrorOC = True - End If - Case 2 - If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then - ErrorOC = True - End If - 'actualiza la compra para que no se surta en almacen. sino por el flete o importación - If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then - ErrorOC = True - End If - End Select - End Select - End If - - - If UsuarioActual.Empresa.UsaAC Then - - If TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0 Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - - ''POLIZA COMPROMETIDO SOLO SI NO SE VINCULA OC - If HdnVCveOC.Value.ToEntero > 0 Then - ' IDPolizaComprometido = ObjContaAC.AddPoliza( 4, "Comprometido", Total, Total, UsuarioActual.CveUsuario, Now) - ' If IDPolizaComprometido <= 0 Then - ' ErrorComprometido = True - ' End If - IDPolizaComprometido = 1 - TotalPorDevengar = TotalPorDevengar * 2 - Else - TotalPorDevengar = TotalPorDevengar * 3 - End If - - IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) - - 'Dim filtro As New StringBuilder - If IdPoliza > 0 Then - PolizaFolio = ObjContaAC.Folio - 'Dim RegistroMatriz As DataRow - 'Dim CuentaCargo As Integer - Dim CuentaAbono As Integer - Dim Importe As Decimal - - 'CUENTA PROVEEDOR - If tIdContaProveedor <= 0 Then - 'normalmente debe de ser la cuenta 021120000000000000, para el caso de APH, se el cmabio al 2119 - If ObjContaAC.GetCuentas(-1, "021190000000000000", -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021190000000000000").ToString - ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02119{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) - ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) - tIdContaProveedor = CtaProveedor - - Else - ErrorAC = True - ErrorACMEnsaje.Append(" - DrCuenta Nula") - End If - Else - ErrorACMEnsaje.Append(" - Error al consultar cuenta 021190000000000000 ") - ErrorAC = True - End If - End If - - Dim ConceptoRenglon As String = "" - If Not ErrorAC Then - - - 'INVENTARIOS EN AC - Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) - Dim CtaAlmacen As Integer - If ContadorInventario > 0 Then - Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) - If drr IsNot Nothing Then - CtaAlmacen = drr("IdCtaContable").ToString.ToEntero - End If - End If - - Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal - Dim ipresup As Integer = 0 - 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS - Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() - Group gvr By Grp = New With { - Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, - Key .CveOrdencompraDetalle = If(gvr("CveOrdencompraDetalle").ToString.ToEntero > 0, 1, -1), - Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) - } Into Group - Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, Grp.CveOrdencompraDetalle, - TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) - Dim Fecha As Date = TxtFecha.Text.ToDate - - 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double - tTotalIVA = TxtIVA.Text.ToDecimal - tRetIVA = TxtRetIVA.Text.ToDecimal - tRetISR = TxtRetISR.Text.ToDecimal - - 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR - - tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA - tDiferenciaIVA = tTotalIVA - - ipresup = 0 - - Dim CuentaMatrizAlmacen As Integer - - 'PresupuestoEgresos - Dim DtPresupuestosTemp As DataTable - Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer - ' Dim DescuentoConIVA As Decimal - Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) - Dim tAjusteTotal As Decimal - - For Each grp In Presup - Importe = grp.TotalImporte - TotalDetalle += Importe - ipresup += 1 - If Importe > 0 Then - 'saco la proporcion de iva que le corresponde - tIVA = Math.Round(Importe * tPorIVA, 2) - tDiferenciaIVA -= tIVA - 'identifico si es el ultimo registro, para ver si es necesario un ajuste - If ipresup = Presup.Count Then - If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then - tIVA += tDiferenciaIVA - End If - End If - - 'le sumo el iva al concepto - Importe += tIVA - - 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF - If TxtDescuento.Text.ToDouble > 0 Then - Importe = grp.TotalImporte * 1.16D - End If - - tAjusteTotal += Importe - 'valido que la sumas de lo detalles no exceda al totalgeneral - If Math.Round(tAjusteTotal, 2) > tTotalGral Then - 'le resto la diferencia - Importe -= (tAjusteTotal - tTotalGral) - End If - - 'Presupuesto Egresos - DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) - If DtPresupuestosTemp.Rows.Count <> 1 Then - ErrorAC = True - ErrorACMEnsaje.Append(" - DtPresupuestosTemp.Rows.Count <> 1 ") - Exit For - End If - IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero - IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero - IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero - IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero - - 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA - If grp.CveOrdencompraDetalle = -1 Then - ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 1") - Exit For - End If - Else - ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 2") - ErrorAC = True - Exit For - End If - End If - - ConceptoRenglon = String.Format("GD Fact:{0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - 'DEVENGADO - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 3") - ErrorAC = True - Exit For - End If - Else - ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 4") - ErrorAC = True - Exit For - End If - - If ContadorInventario > 0 Then - CuentaMatrizAlmacen = CtaAlmacen - ElseIf grp.CveActivoFijo > 0 Then - - Dim CtaAF = -1 - Dim AF = "" - Dim CuentaInicial = -1 - - If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then - CtaAF = ObjAF.Cuenta - AF = ObjAF.Descripcion - CuentaInicial = ObjAF.CuentaInicial - Else - ErrorAC = True - ErrorACMEnsaje.Append(" - Error al obtener activos fijos ") - Exit For - End If - - If Not CuentaInicial > 0 Then - CuentaInicial = 1241 - End If - - 'CUENTA AF - If CtaAF <= 0 Then - If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nula") - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString - CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) - - ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) - Else - ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nulo") - ErrorAC = True - End If - Else - ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000") - ErrorAC = True - End If - End If - - CuentaMatrizAlmacen = CtaAF - Else - CuentaMatrizAlmacen = IdCuentaMatriz - End If - - - ''AFECTAR MATRIZ EGRESOS - If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - - - ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) - 'If TxtDescuento.Text.ToDouble > 0 Then - ' DescuentoConIVA = TxtDescuento.Text.ToDouble * 1.16 - - ' 'Valida que el descuento con iva cuadre en los totales - ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then - ' DescuentoConIVA = Importe - TxtTotal.Text.ToDouble - ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDouble) Then - ' ErrorAC = True - ' Exit For - ' End If - - ' 'actualizo el idcuenta del presupuesto - ' If ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, Importe - DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then - ' 'agrego a la cuenta contable anticipos - ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then - ' ErrorAC = True - ' Exit For - ' End If - ' Else - ' ErrorAC = True - ' Exit For - ' End If - - 'Else - ' 'actualizo el idcuenta del presupuesto - ' Importe = TxtTotal.Text.ToDouble - ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe), "", ConceptoRenglon, 0, Fecha, "") Then - ' ErrorAC = True - ' Exit For - ' End If - - 'End If - - - Else - ErrorACMEnsaje.Append(" - Error AFECTAR MATRIZ EGRESOS ObjContaAC.AddMovimiento") - ErrorAC = True - Exit For - End If - ''TERMINA AFECTAR MATRIZ EGRESOS - - Else - ErrorACMEnsaje.Append(" - For Each grp In Presup Importe > 0 ") - ErrorAC = True - Exit For - End If - - Next - - ''[IPP] COMENTADO A MIRAS DE ELIMINAR 21-FEBRERO-2018 - ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) - 'If TxtDescuento.Text.ToDouble > 0 Then - ' DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16D - - ' 'Valida que el descuento con iva cuadre en los totales - ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDecimal)) < 0.02 Then - ' DescuentoConIVA = Importe - TxtTotal.Text.ToDecimal - ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then - ' ErrorACMEnsaje.Append(" - Valida que el descuento con iva cuadre en los totales ") - ' ErrorAC = True - ' End If - - ' 'actualizo el idcuenta del presupuesto - ' If ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then - ' 'agrego a la cuenta contable anticipos - ' If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then - ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 1") - ' ErrorAC = True - ' End If - ' Else - ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 2") - ' ErrorAC = True - ' End If - 'Else - 'actualizo el idcuenta del presupuesto - Importe = TxtTotal.Text.ToDecimal - If Not ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe)), "", ConceptoRenglon, 0, Fecha, "") Then - ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 3") - ErrorAC = True - End If - 'End If - - - If tRetISR > 0 Then - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorACMEnsaje.Append(" RetISR > 0 ObjContaAC.AddMovimiento") - ErrorAC = True - End If - End If - - 'TERMINA: PRUEBA AGRUPACION CONCEPTOS - - 'registrar amortizar anticipos - End If - - Else - ErrorACMEnsaje.Append(" - Id Poliza = 0 ") - ErrorAC = True - End If - Else - TieneError = True - ErrorACMEnsaje.Append("- TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0") - ErrorAC = True - End If - End If - - If Not ErrorAC Then - - - Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - - If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then - AutoConta = False - End If - - If (AutoConta Or UsuarioActual.Empresa.UsaAC) And ObjContaAC Is Nothing Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - End If - - ''EMPIEZA: INSERTA DETALLES DE LA COMPRA - Dim indiceTR = 0 - Dim Cont As Integer = 0 - For Each Row As DataRow In TmpDT.Rows - Dim TipoRecepcion As Integer = -1 - - - ''INVENTARIOS - If GvInv.Rows.Count > indiceTR Then - If GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then - TipoRecepcion = 1 - ElseIf GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "0" Then - TipoRecepcion = 2 - End If - End If - - Dim CvePersonal = -1 - Dim Referencia = "" - - If GvPersonal.Rows.Count > Cont Then - CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero - Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text - End If - Cont = Cont + 1 - - 'Si es AF-INSUMO se guarda CveAF en CompraDetalle - Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) - - 'Si es AF-COMPRA se guarda CveAF en la Columna CveAFCompra - Dim CveAFC = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) - - 'AGREGA COMPRA DETALLE - If Not ObjCompras.AddCompraDetalle(CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF, - Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, Row("Descuento").ToString.ToDouble, - Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, - AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal, - CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, - RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble, - IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, - IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False)) Then - - ErrorDetalles = True - Exit For - Else - - If Row("EntregaDirecta").ToString.ToEntero > 0 Then - EntregaDirecta = True - End If - - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Row("Consec").ToString}")(0) - TmpDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle - - ' Si no es un movimiento de almacen va a tronar - Try - Dim InvDr As DataRow = DtInv.Select($"Consec = {Row("Consec").ToString}")(0) - InvDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle - Catch ex As Exception - End Try - - End If - - 'Vincula Vales - If IdVale.Count > 0 Then - For Each cve In IdVale - If Not ObjAF.UpdateValeCombustible(cve, CveCompra, -1, "", -1, -1, -1, UsuarioActual.CveEmpresa) Then - ErrorAF = True - Exit For - End If - Next - Else - - End If - - - - 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF - If Row("TipoAF").ToString.ToEntero = 2 Then - If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, ObjCompras.CveCompraDetalle, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then - ErrorDetalles = True - Exit For - End If - End If - - 'ACTUALIZAR PRODUCTO/SERVICIO SAT - If Version = "3.3" Then - If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario) Then - ErrorSATPS = True - End If - End If - - indiceTR += 1 - Next - ''TERMINA: INSERTA DETALLES DE LA COMPRA - - 'QUEMA SALDOS DE INV-COMPRA | MERCANCIA RECIBIDA POR ADELANTADO (OC) | PP 176 - If OCVinculada And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - For Each Row As DataRow In TmpDT.FiltraParametros("CveTipoPS = 2").Rows - If Not ObjOC.OrdenesCompraDetalleSaldosInvCompraAdd(Row("CveOrdenCompraDetalle").ToString.ToEntero, -1, -1, Row("CveCompraDetalle").ToString.ToEntero, Row("Cantidad").ToString.ToDouble) Then - ErrorSaldosInvComp = True - Exit For - End If - Next - - 'verifica si fue vinculada con una OC, y si fue la opción de entrega por adelantado, que si hubo cambios de precios - If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(176, 205) Then - If Not AjustarPrePolizaVinculacionOC(ObjOC, ObjEventos, ObjInventario, ObjConta, ObjContaAC) Then - ErrorPrepoliza = True - End If - End If - - End If - - If CvePrePoliza > 0 Then - - 'INVENTARIOS - ALMACEN - If UsuarioActual.Empresa.UsaInventarios Then 'And UsuarioActual.Empresa.UsaAC = False - - ''SI ES CON DOLARES VALIDA QUE SE TENGA EL TIPO DE CAMBIO DEL DIA DE LA FACTURA - SI NO, NO HACE NADA, la validación del TC, ya está chk constrains - ' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then - - ''ALMACEN CONSIGNACION - If CveConsignacion > 0 Then - - 'actualizamos cvecompraconsignacion - For Each gvr As GridViewRow In GvInv.Rows - If gvr.FCCheckBox("cbinv").Checked AndAlso gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero > 0 Then - If Not ObjInventario.UpdateConsignacionesCompra(CveCompra, gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero, gvr.FCHiddenField("HdnCveAlmacen").Value.ToEntero, gvr.FCHiddenField("HdnCvePS").Value.ToEntero, gvr.DataKey("Cantidad").ToDouble, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True - Exit For - End If - End If - Next - - If Not ErrorMovInv Then - - Dim x As Integer = 0 - For Each dr As DataRow In DtInv.Rows - If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble > 0 Then - - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie - TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero 'Charlie - - dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlealmacen").SelectedValue.ToEntero - dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble - Else - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie - TmpDr("CveAlmacen") = 0 'Charlie - - dr("CveAlmacen") = 0 - End If - x = x + 1 - Next - - Dim cvemovimientosalida = 0 - Dim cvemovimientoentrada = 0 - Dim cvemovimientosalidagasto = 0 - Dim folio = 0 - Dim fecha As Date = TxtFecha.Text.ToDate - Dim indice = 0 - Dim importeconcepto = 0.0 - - Dim listalmacenes = (From cvealmacen In DtInv.AsEnumerable() Where cvealmacen.Field(Of Integer)("cvealmacen") > 0 Select cvealmacen.Field(Of Integer)("cvealmacen")).Distinct().ToList - - For Each tcvealmacen As Integer In listalmacenes - If GvInv.Rows(indice).FCDropDownList("ddlrecibirinv").SelectedValue = "1" Then - Continue For - End If - indice += 1 - - - ''agregamos la salida de consignacion - 'folio = objinventario.getfoliosiguiente(3, usuarioactual.cveempresa) - 'cvemovimientosalida = objinventario.addmovimiento(cvealmacenconsignacion, 3, ddlmoneda.selectedvalue.toentero, fecha, folio, usuarioactual.cveusuario, usuarioactual.cveempresa, cvecompra, -1, -1, -1) - 'if cvemovimientosalida <= 0 then - ' errormovinv = true - ' exit for - 'else - ' for each dr as datarow in dtinv.rows - ' if dr("cvealmacen").tostring.toentero = tcvealmacen then - ' if not objinventario.addmovimientodetalle(cvemovimientosalida, dr("cantidad").tostring.todouble, ddlum.selectedvalue.toentero, dr("cveps").tostring.toentero, 0, -1) then - ' errormovinv = true - ' exit for - - ' end if - ' end if - ' next - 'end if - - - 'agregamos la entrada - If Not UsuarioActual.Empresa.UsaAC Then fecha = Now - - folio = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa) - cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G") - If cvemovimientoentrada <= 0 Then - ErrorMovInv = True - Exit For - Else - CveMovimientoInventario = cvemovimientoentrada - ListaMovimientosAlmacen.Add(CveMovimientoInventario) - - For Each dr As DataRow In DtInv.Rows - If dr("cvealmacen").ToString.ToEntero = tcvealmacen Then - - importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDouble, dr("pu").ToString.ToDouble * TipoCambioGuardar) - If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDouble), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then - - ErrorMovInv = True - Exit For - End If - End If - Next - - End If - - 'agregamos la salida gasto - folio = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa) - cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G") - If cvemovimientosalidagasto <= 0 Then - ErrorMovInv = True - Exit For - Else - If ObjInventario.GetMovimientosDetalle(cvemovimientoentrada, UsuarioActual.CveEmpresa) Then - For Each dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(cvemovimientosalidagasto, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, 0, dr("cveaf").ToString.ToEntero, CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then - ErrorMovInv = True - Exit For - End If - Next - End If - End If - - Next - - End If - - ''ALMACEN NORMAL - Else - - 'OBTIENE ALMACENES - Dim x As Integer = 0 - For Each Dr As DataRow In DtInv.Rows - If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDecimal > 0 Then - - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0) - TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero - - Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero - Dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble - - Else 'limpio el valor para que no truene en linq mas abajo - - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0) - TmpDr("CveAlmacen") = 0 - - Dr("CveAlmacen") = 0 - End If - x = x + 1 - Next - - Dim i As Integer = 0 - Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList - Dim indice = 0 - Dim ImporteConcepto = 0.0 - - For Each tCveAlmacen As Integer In ListAlmacenes - If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then - Continue For - End If - indice += 1 - - Dim fecha As Date = TxtFecha.Text.ToDate - If Not UsuarioActual.Empresa.UsaAC Then fecha = Now - - CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G") - - If CveMovimientoInventario <= 0 Then - ErrorMovInv = True - Else - - Dim DtDetalle As New DataTable - Dim DtEquivalencias As DataTable - Dim CveProducto As Integer - Dim CantidadInv As Double - Dim PUInv As Double - Dim CveUnidad As Integer - Dim CostoIndirecto As Double - - ListaMovimientosAlmacen.Add(CveMovimientoInventario) - - - For Each Dr As DataRow In DtInv.Rows - - CveProducto = Dr("CvePS").ToString.ToEntero - CveUnidad = Dr("CveUM").ToString.ToEntero - CantidadInv = Dr("Cantidad").ToString.ToDouble - PUInv = Dr("PU").ToString.ToDouble - CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDouble - - If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then - 'SI FUE POR SERIE LOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS"))) - If DtDetalle.Rows.Count > 0 Then - For Each drr As DataRow In DtDetalle.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDouble, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then - ErrorMovInv = True - Exit For - End If - - Next - End If - Else - - 'UNIDAD BASE - EQUIVALENCIAS - INVENTARIO - If UsuarioActual.CveEmpresa = 1 Then - DtEquivalencias = New DataTable - DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1, UsuarioActual.CveEmpresa) - Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero - Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") - - 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) - If CveUnidadBase <> CveUnidad Then - ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA - CantidadInv = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble - PUInv = PUInv * Dr("Cantidad").ToString.ToDouble / CantidadInv - CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDouble / CantidadInv - CveUnidad = CveUnidadBase - End If - End If - - 'si no es por serie lote - ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar) - ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto) - If Dr("CveAlmacen").ToString.ToEntero = tCveAlmacen Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDouble), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then - ErrorMovInv = True - Exit For - End If - End If - - End If - - - i = i + 1 - Next - End If - Next - - End If - - - - If AplicarCostoIndirecto(ObjInventario, ObjCompras) Then - ErrorMovInv = True - End If - - 'Else - ' Alert("El tipo de cambio no esta actualizado. Por favor comuniquese con un asistente SIG.", TipoMensaje.MsgError) - ' ErrorMovInv = True - 'End If - - End If - - '*************************************************** P R I M E R A P A R T E C O M P R A S ************************************************************************************************************************************************************************************************************************************************************************************************** - 'P R E P O L I Z A S - - Dim CveConceptoAfectacion As Integer = 5 'Proveedores - Dim CveConceptoAfectacionContado As Integer = 17 'Pago Proveedores - Dim CveConceptoCompra As Integer = 6 'Compra - Dim CveConceptoIVA As Integer = 14 'IVA Trasladado - Dim CveConceptoRetIVA As Integer = 15 'Ret IVA - Dim CveConceptoRetISR As Integer = 16 'Ret ISR - Dim CveConceptoDescuento As Integer = 24 'DSC - Dim CveConceptoRetIEPS As Integer = 25 'IEPS - Dim CveConceptoRetOtrosImpuestos As Integer = 27 'Otros Impuestos - Dim CveCreditoDetalle As Integer = -1 - - 'Afectable con el tabpanel Contable - Dim CveProveedorLocal As Integer - Dim CveProveedorConcepto As Integer - Dim CveAcreedor As Integer - Dim CveColectiva As Integer = -1 - - Dim TipoCreditoInteres As Boolean = False - Dim ImporteIECredito As Decimal = 0 - Dim SeContabiliza As Boolean = If(UsuarioActual.CveEmpresa.Contiene(119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant"), False, True) - - If RBLPago.SelectedValue = "1" Or RBLPago.SelectedValue = "3" Then - 'Credito Proveedor - CveProveedorLocal = CveProveedor - CveProveedorConcepto = CveProveedor - CveAcreedor = -1 - - Else - 'cuando es contado - - Select Case RBLContado.SelectedValue - Case "1", "6" 'Proveedores - CveProveedorLocal = CveProveedor - CveProveedorConcepto = CveProveedor - CveAcreedor = -1 - Case "2" ' F y E - CveProveedorLocal = CveProveedor - CveProveedorConcepto = CveProveedor - CveAcreedor = -1 - CveIE = DDlCheques.SelectedValue.ToEntero - Case "3" ' Doctos - - CveProveedorConcepto = CveProveedor - - If DdlTipoCredito.SelectedValue.ToEntero = 2 Then - CveProveedorLocal = CveProveedor - CveProveedorConcepto = CveProveedor - CveAcreedor = -1 - CveColectiva = -1 - ' CveConceptoAfectacionContado = 55 - CveConceptoAfectacion = 59 - CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero - ObjIE.UpdateCreditosDetalle(3, CveCreditoDetalle) - End If - Case "4" ' Deudores - CveProveedorLocal = CveProveedor - CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero - For Each row As GridViewRow In GvDeudores.Rows - If row.FCCheckBox("Chk").Checked Then - CveIE = row.DataKey("CveIE").ToString.ToEntero - Exit For - End If - Next - CveAcreedor = -1 - CveColectiva = -1 - ' CveConceptoAfectacionContado = 55 - CveConceptoAfectacion = 37 - Case "5" ' Acreedores - CveProveedorLocal = CveProveedor - CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero - CveAcreedor = -1 - CveColectiva = -1 - CveConceptoAfectacion = 41 - - If EmpresaPrueba Then - CveIE = If(DdlAcreedorDetalle.SelectedValue.ToEntero = -2, -1, DdlAcreedorDetalle.SelectedValue.ToEntero) - End If - End Select - End If - - If RBLPago.SelectedValue.ToEntero = 4 Then - Dim TmpTotal As Decimal = TxtTotal.Text.ToDecimal - Dim TmpTotalCreditos As Decimal = 0 - - For Each GvRow As GridViewRow In GvCreditos.Rows - TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtCapital").Text.ToDecimal - TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtInteres").Text.ToDecimal - TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtAmbos").Text.ToDecimal - Next - - If TmpTotalCreditos > TmpTotal Then - ErrorCredito = True - End If - - For Each GvRow As GridViewRow In GvCreditos.Rows - - Dim Capital As Decimal = GvRow.FCTextBox("TxtCapital").Text.Replace(",", "").ToDecimal - Dim Interes As Decimal = GvRow.FCTextBox("TxtInteres").Text.Replace(",", "").ToDecimal - Dim Ambos As Decimal = GvRow.FCTextBox("TxtAmbos").Text.Replace(",", "").ToDecimal - - Dim CveCreditoDetalleTemp As Integer = GvRow.DataKey("CveCreditoDetalle").ToEntero - Dim CveCreditoTemp As Integer = GvRow.DataKey("CveCredito").ToEntero - Dim EstusTemp = GvRow.DataKey("Estatus").ToEntero - ' Dim ImporteOpcionCompra As Decimal = GvRow.DataKey("ImporteOpcionCompra").ToDecimal - Dim Marcador As Decimal = GvRow.DataKey("Marcador").ToEntero - Dim CreditoEstatus As Integer = -1 - - If Capital > 0 Or Interes > 0 Or Ambos > 0 Then - - If ObjIE.GetCreditosDetalle(CveCreditoTemp, -1) Then - - Dim CveCompraCapital As Integer = -1 - Dim CveCompraInteres As Integer = -1 - - 'Dim ImporteCapital As Decimal = 0 - ' Dim ImporteCapitalIVA As Decimal = 0 - - 'Dim ImporteInteres As Decimal = 0 - ' Dim ImporteInteresIVA As Decimal = 0 - - ' Dim ImporteIEMensualidad As Decimal = ObjIE.DtResultados.FiltroPrimeroValor("ImporteIE", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal - CreditoEstatus = ObjIE.DtResultados.FiltroPrimeroValor("Estatus", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero - - CveCompraCapital = ObjIE.DtResultados.FiltroPrimeroValor("CveCompra", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero - CveCompraInteres = ObjIE.DtResultados.FiltroPrimeroValor("CveCompraInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero - - CveCompraCapital = If(CveCompraCapital < 1, -1, CveCompraCapital) - CveCompraInteres = If(CveCompraInteres < 1, -1, CveCompraInteres) - - TipoCreditoInteres = Boolean.Parse(ObjIE.DtResultados.FiltroPrimeroValor("TipoInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}")) - ImporteIECredito = ObjIE.DtResultados.FiltroPrimeroValor("ImportePago", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal - - If Ambos > 0 Then - CveCompraCapital = CveCompra - CveCompraInteres = CveCompra - - Capital = Ambos - Interes = Ambos - - End If - - If Capital > 0 Then - CveCompraCapital = CveCompra - End If - If Interes > 0 Then - CveCompraInteres = CveCompra - End If - - - - If (CveCompraCapital > 0 And CveCompraInteres > 0) And EstusTemp = 2 Then - If EstusTemp = 2 Then - EstusTemp = 3 - ElseIf EstusTemp = 1 Or EstusTemp = 4 Then - EstusTemp = 4 - End If - ElseIf CveCompraCapital > 0 Or CveCompraInteres > 0 Then - If EstusTemp = 2 Then - EstusTemp = 2 - ElseIf EstusTemp = 1 Or EstusTemp = 4 Then - EstusTemp = 4 - End If - End If - - If Not ObjIE.UpdateCreditosDetalle(CveCreditoDetalleTemp, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, EstusTemp, CveCompra:=CveCompraCapital, CveCompraInteres:=CveCompraInteres, importeCapital:=Capital, - ImporteInteres:=Interes) Then - ErrorCredito = True - End If - 'ObjIE.UpdateCreditosDetalle(CveCreditoDetalle, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, Estatus) - - - - Else - ErrorCredito = True - End If - End If - Next - End If - - Dim TipoMovimientoCompra As Boolean = False - Dim TipoMovimientoImpuestos As Boolean = True - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - CveConceptoAfectacion = 18 'Devolución del Proveedor (NC) - TipoMovimientoCompra = Not TipoMovimientoCompra - TipoMovimientoImpuestos = Not TipoMovimientoImpuestos - End If - - If EmpresaPrueba Then 'Empresa Prueba - - Dim PorcentajePagos As Decimal = 0 - Dim sumaPagos As Decimal = 0 - Dim tipoCambioActual As Decimal - Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" - Dim idCuentaContabilizacion As Long = 1 - Dim CveCuentaContabilizacion As Long = 1 - Dim FechaMovimiento As Date = TxtFecha.Text.ToDate - Dim DT As DataTable = Nothing - Dim CuentasContablesInvalidas As New StringBuilder - Dim CuentasContablesInvalidasSIG As New StringBuilder - Dim ConceptoPersonal As String = "" - Dim IdCtaIVAXAcreditar As Integer = 0 - Dim IdCtaIVAAcreditable As Integer = 0 - Dim GuardoConcepto18 As Boolean = False - - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows.Count > 0 Then - IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero - IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero - End If - - - - '********************** Variables '********************** - - '****** Pagos - - 'Bancos (30) - Dim importeBanco As Decimal = 0 - If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then - importeBanco = TxtDocumentoImporte.Text.ToDecimal - sumaPagos += importeBanco - End If - - 'Caja Chica (30) - Dim importeCajaChica As Decimal = 0 - If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "6" Then - importeCajaChica = TxtDocumentoImporteCaja.Text.ToDecimal - sumaPagos += importeCajaChica - End If - - 'Funcionarios y Empleados (29) - Dim importeFE As Decimal = 0 - If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "2" Then - ViewState("CvePersonal") = DdlFuncionarioEmpleado.SelectedValue.ToEntero - ConceptoPersonal = DdlFuncionarioEmpleado.SelectedItem.ToString - importeFE = TxtDocumentoImporteFE.Text.ToDecimal - sumaPagos += importeFE - End If - - 'Deudores (37) - Dim importeDD As Decimal = 0 - If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "4" Then - ConceptoPersonal = DdlDeudor.SelectedItem.ToString - importeDD = TxtContadoDeudor.Text.ToDecimal - sumaPagos += importeDD - End If - - 'Acreedores (41) SinTarjeta - Dim importeAcreedores As Decimal = 0 - If (CveIE > 0 Or DdlAcreedorDetalle.SelectedValue.ToEntero = -2) AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "5" Then - ConceptoPersonal = DdlAcreedor.SelectedItem.ToString - importeAcreedores = TxtContadoAcreedor.Text.ToDecimal - sumaPagos += importeAcreedores - End If - - 'Acreedores (42) ConTarjeta - Dim importeAcreedoresTarjeta As Decimal = 0 - If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then - ConceptoPersonal = DdlTarjeta.SelectedItem.ToString - importeAcreedoresTarjeta = TxtDocumentoImporte.Text.ToDecimal - sumaPagos += importeAcreedoresTarjeta - End If - - 'Creditos/Documentos (59) - Dim importeCreditos As Decimal = 0 - Dim CveIECreditos = -1 - If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "3" AndAlso DdlTipoCredito.SelectedValue.ToEntero = 2 Then - If ObjIE.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then - CveIECreditos = ObjIE.DtResultados.FiltroPrimero($"CveCreditoDetalle = {DdlCreditoDetalle.SelectedValue.ToEntero}")("CveIE").ToString.ToEntero - End If - ConceptoPersonal = DdlCredito.SelectedItem.ToString - importeCreditos = TxtTotal.Text.ToDecimal - sumaPagos += importeCreditos - End If - - PorcentajePagos = If(TxtTotal.Text.ToDecimal > 0, sumaPagos / TxtTotal.Text.ToDecimal, 0) - - '****** Acreditables - - 'IVA Acreditable (19) - Dim importeIVAAcreditable As Decimal = 0 - importeIVAAcreditable = TxtIVA.Text.ToDecimal * PorcentajePagos - - 'IEPS Acreditable (26) - Dim ImporteIEPSAcreditable As Decimal = 0 - ImporteIEPSAcreditable = TxtIEPS.Text.ToDecimal * PorcentajePagos - - 'RetIVA Acrediable (22) - Dim importeRetIVAAcreditable As Decimal = 0 - importeRetIVAAcreditable = TxtRetIVA.Text.ToDecimal * PorcentajePagos - - 'RetISR Acreditable (23) - Dim importeRetISRAcreditable As Decimal = 0 - importeRetISRAcreditable = TxtRetISR.Text.ToDecimal * PorcentajePagos - - - - '****** X Acreditar - 'IVA X Acreditar (14) - Dim importeIVAxAcreditar As Decimal = 0 - importeIVAxAcreditar = TxtIVA.Text.ToDecimal - - 'IEPS X Acreditar (25) - Dim ImporteIEPSxAcreditar As Decimal = 0 - ImporteIEPSxAcreditar = TxtIEPS.Text.ToDecimal - - 'Otros Impuestos (224) - Dim OtrosImpuestos As Decimal = 0 - OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal - - 'RetIVA X Acreditar (15) - Dim importeRetIVAxAcreditar As Decimal = 0 - importeRetIVAxAcreditar = TxtRetIVA.Text.ToDecimal - - 'RetISR X Acreditar (16) - Dim importeRetISRxAcreditar As Decimal = 0 - importeRetISRxAcreditar = TxtRetISR.Text.ToDecimal - - - - '****** Movimientos Independientes - - 'Pago Proveedores (17) - Dim importePagoProv As Decimal = 0 - importePagoProv = sumaPagos - - 'If CveIE > 0 AndAlso ((RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0) Or (RBLContado.SelectedValue = "4" AndAlso DdlDeudor.SelectedValue.ToEntero > 0)) Then - ' importePagoProv = TxtDocumentoImporteFE.Text.ToDecimal - 'End If - - 'Compra (6) - 'Ya que es un foreach todo su proceso esta en el Case 6 - - 'Proveedores (5) - Dim importeProv As Decimal = 0 - importeProv = TxtTotal.Text.ToDecimal - - 'Nota de Credito (18) - Dim importeNC As Decimal = 0 - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - importeNC = TxtTotal.Text.ToDecimal - End If - - '************************************************************************************************************************** - - Dim TipoCambioCompra As Decimal = 1 - TipoCambioCompra = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal - TipoCambioCompra = If(DivTC.Visible, TipoCambio.ToDecimal, TipoCambioCompra) - - If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - TipoCambioCompra = 1 - End If - - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then - tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal - tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual) - Else - tipoCambioActual = 1 - End If - - 'CASO ESPECIAL CREDITOS - If CveIECreditos > 0 Then - CveIE = CveIECreditos - 'Dim CveIEProvisional = CveIE - End If - - - - If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then - - Dim DTPlatilla As New DataTable - DTPlatilla = ObjConta.DtResultados - - For Each Row As DataRow In DTPlatilla.Rows - - Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero - Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) - Dim importeMovimiento As Decimal = 0 - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - Dim Concepto As String = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, $"{TxtSerie.Text}-{TxtFolio.Text}", If(TxtDocumentoFolio.Visible, TxtDocumentoFolio.Text, If(TxtDocumentoFolioCaja.Visible, TxtDocumentoFolioCaja.Text, ConceptoPersonal))) - Dim importeMN As Decimal = 0 - Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) - Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation - Dim PorcentajeImpuesto As Decimal = 0 - - - Select Case ConceptoContable - - - - - Case 17 'Pago Proveedores - - importeMovimiento = importePagoProv - If CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - importeMovimiento = importeMovimiento / TipoCambioCompra - End If - importeMN = importeMovimiento * TipoCambioCompra * Multiplicador - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - - - If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(2, 102) Then 'SI ES CRÉDITO Y ESTA PAGADO - - Dim IdSegmentoNegocio As Integer = -1 - For Each Row2 As DataRow In TmpDT.Rows - - importeMovimiento = TxtTotal.Text.ToDecimal 'TmpDT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - 'CLASIFICACION - If Row2("CveClasificacion").ToString.ToEntero > 0 Then - If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - End If - End If - End If - - - - - 'SEGMENTO DE NEGOCIO - - Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) - If drT IsNot Nothing Then - IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero - End If - - 'AGREGA MOVIMIENTO - If importeMovimiento <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - End If - Next - - - - Dim CveClasificacionDT As Integer = -1 - Dim CveSubProyectoDT As Integer = -1 - Dim CveTipoGastoDT As Integer = -1 - - If TmpDT.Rows.Count > 0 Then - CveClasificacionDT = TmpDT(0)("CveClasificacion").ToString.ToEntero - CveSubProyectoDT = TmpDT(0)("CveSubProyecto").ToString.ToEntero - CveTipoGastoDT = TmpDT(0)("CveTipoGasto").ToString.ToEntero - End If - - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - - Dim ImporteSubCre As Decimal = TxtSubTotal.Text.ToDecimal - Dim ImporteSubCreMN As Decimal = TxtSubTotal.Text.ToDecimal * tipoCambioActual - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteSubCre, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=ImporteSubCreMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteSubCre), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - If TipoCreditoInteres Then - - - Dim importeMovimientoIn As Decimal = ImporteIECredito - importeMovimiento - Dim importeMNIn As Decimal = importeMovimientoIn * tipoCambioActual * Multiplicador - - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoIn, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoIn, Referencia, 50, Concepto, FechaMovimiento, ViewState("IdCtaContDocsXPagar").ToString.ToEntero(), IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - - End If - End If - - - - - End If - - If TipoCambioCompra > 1 AndAlso DdlMoneda.SelectedValue.ToEntero <> 1 Then Concepto += $" TC:{TipoCambioCompra} ${importeMovimiento.FormatoNumero(2)}" - - If TipoCambioCompra = 1 Or DdlMoneda.SelectedValue.ToEntero = 1 Then - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - importeMovimiento = importeMN - Else - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos - importeMN = importeMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento * TipoCambioCompra - importeMovimiento, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * TipoCambioCompra - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=TipoCambioCompra) Then - ErrorPrepoliza = True - End If - End If - - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - End If - - Case 30 'Bancos - importeMovimiento = importeBanco + importeCajaChica 'Uno de los dos debe ser 0 - If CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then - importeMovimiento = importeMovimiento / TCPago - End If - importeMN = importeMovimiento * TCPago * Multiplicador - - If TCPago > 1 AndAlso CveMonedaPago <> 1 Then Concepto += $" TC:{TCPago} ${importeMovimiento.FormatoNumero(2)}" - - If TCPago = 1 Or CveMonedaPago = 1 Then - IdCtaContable = IdCuentaBancaria - CveCuenta = CveCuentaBancaria - Else - IdCtaContable = IdCuentaBancariaComplementaria - CveCuenta = CveCuentaBancariaComplementaria - If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos - importeMN = importeMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento * TCPago - importeMovimiento, Referencia, 204, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * TCPago - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=TCPago) Then - ErrorPrepoliza = True - End If - End If - - IdCtaContable = IdCuentaBancaria - CveCuenta = CveCuentaBancaria - End If - - - Case 19 'IVA Acreditable - If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then - If importePagoProv = importeProv Then - importeMovimiento = TxtIVA.Text.ToDecimal - Else - importeMovimiento = 0 - End If - Else - importeMovimiento = importeIVAAcreditable - End If - - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - - PorcentajeImpuesto = PorcentajeIVA - IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) - - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero - End If - End If - - 'Agregamos el Opuesto del 19 -> 14 - If importeMovimiento <> 0 Then - Dim IdCtaIva As Integer = 0 - Dim CveCuentaIVA As Integer = 0 - IdCtaIva = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) - - If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaIva = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero - CveCuentaIVA = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero - End If - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 14, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIva, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVA, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - Case 14 'IVA X Acreditar - importeMovimiento = importeIVAxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - PorcentajeImpuesto = PorcentajeIVA - IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero - End If - End If - Case 25 'IEPS X Acreditar - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - importeMovimiento = ImporteIEPSxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero - End If - End If - End If - - Case 224 'Otros impuestos - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - importeMovimiento = OtrosImpuestos - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - IdCtaContable = If(UsuarioActual.CveEmpresa = 119, 1171, -1) - CveCuenta = -1 - End If - Case 26 'IEPS Acreditable - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - importeMovimiento = ImporteIEPSAcreditable - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero - End If - End If - - 'Agregamos el Opuesto del 26 -> 25 - If importeMovimiento <> 0 Then - Dim IdCtaIEPS As Integer = 0 - Dim CveCuentaIEPS As Integer = 0 - If ObjConta.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero - CveCuentaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero - End If - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 25, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIEPS, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIEPS, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - - End If - Case 22 'RetIVA Acreditable Honorarios/Serv. Prof. - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then - importeMovimiento = importeRetIVAAcreditable - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If + End If + + 'Compra + If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble, + LblAmortizacion.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtOtrosImpuestos.Text.ToDouble, + TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura, + CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero, + AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen, + CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, TotalOriginal:=TotalOriginal, CveTipoConcepto:=CveTipoConcepto) Then + + ViewState("CveCompra") = ObjCompras.CveCompra + If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + ErrorMovDev = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate) + End If + Dim ErrorDetalles As Boolean = False + ' Dim IDPoliza As Integer + Dim IDPolizaComprometido = 0 + Dim ErrorComprometido = False + + If CveImportacion > 0 Or CveFlete > 0 Then + + + Select Case CveConceptoContableAlmacen + Case 237 + Select Case FleteImportacionOpcion + Case 1 + Dim Dr As DataRow = Nothing + If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + Dr = ObjInventario.DtResultados.Rows(0) + End If + End If + If Dr IsNot Nothing Then + If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then + ErrorOC = True + End If + Else + ErrorOC = True + End If + Case 2 + If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then + ErrorOC = True + End If + 'actualiza la compra para que no se surta en almacen. sino por el flete o importación + If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then + ErrorOC = True + End If + End Select + Case 240 + Select Case FleteImportacionOpcion + Case 1 + If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then + ErrorOC = True + End If + Case 2 + If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then + ErrorOC = True + End If + 'actualiza la compra para que no se surta en almacen. sino por el flete o importación + If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then + ErrorOC = True + End If + End Select + End Select + End If + + + If UsuarioActual.Empresa.UsaAC Then + + If TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0 Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + + ''POLIZA COMPROMETIDO SOLO SI NO SE VINCULA OC + If HdnVCveOC.Value.ToEntero > 0 Then + ' IDPolizaComprometido = ObjContaAC.AddPoliza( 4, "Comprometido", Total, Total, UsuarioActual.CveUsuario, Now) + ' If IDPolizaComprometido <= 0 Then + ' ErrorComprometido = True + ' End If + IDPolizaComprometido = 1 + TotalPorDevengar = TotalPorDevengar * 2 + Else + TotalPorDevengar = TotalPorDevengar * 3 + End If + + IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) + + 'Dim filtro As New StringBuilder + If IdPoliza > 0 Then + PolizaFolio = ObjContaAC.Folio + 'Dim RegistroMatriz As DataRow + 'Dim CuentaCargo As Integer + Dim CuentaAbono As Integer + Dim Importe As Decimal + + 'CUENTA PROVEEDOR + If tIdContaProveedor <= 0 Then + 'normalmente debe de ser la cuenta 021120000000000000, para el caso de APH, se el cmabio al 2119 + If ObjContaAC.GetCuentas(-1, "021190000000000000", -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021190000000000000").ToString + ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02119{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) + ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) + tIdContaProveedor = CtaProveedor + + Else + ErrorAC = True + ErrorACMEnsaje.Append(" - DrCuenta Nula") + End If + Else + ErrorACMEnsaje.Append(" - Error al consultar cuenta 021190000000000000 ") + ErrorAC = True + End If + End If + + Dim ConceptoRenglon As String = "" + If Not ErrorAC Then + + + 'INVENTARIOS EN AC + Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) + Dim CtaAlmacen As Integer + If ContadorInventario > 0 Then + Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) + If drr IsNot Nothing Then + CtaAlmacen = drr("IdCtaContable").ToString.ToEntero + End If + End If + + Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal + Dim ipresup As Integer = 0 + 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS + Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() + Group gvr By Grp = New With { + Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, + Key .CveOrdencompraDetalle = If(gvr("CveOrdencompraDetalle").ToString.ToEntero > 0, 1, -1), + Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) + } Into Group + Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, Grp.CveOrdencompraDetalle, + TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) + Dim Fecha As Date = TxtFecha.Text.ToDate + + 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double + tTotalIVA = TxtIVA.Text.ToDecimal + tRetIVA = TxtRetIVA.Text.ToDecimal + tRetISR = TxtRetISR.Text.ToDecimal + + 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR + + tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA + tDiferenciaIVA = tTotalIVA + + ipresup = 0 + + Dim CuentaMatrizAlmacen As Integer + + 'PresupuestoEgresos + Dim DtPresupuestosTemp As DataTable + Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer + ' Dim DescuentoConIVA As Decimal + Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) + Dim tAjusteTotal As Decimal + + For Each grp In Presup + Importe = grp.TotalImporte + TotalDetalle += Importe + ipresup += 1 + If Importe > 0 Then + 'saco la proporcion de iva que le corresponde + tIVA = Math.Round(Importe * tPorIVA, 2) + tDiferenciaIVA -= tIVA + 'identifico si es el ultimo registro, para ver si es necesario un ajuste + If ipresup = Presup.Count Then + If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then + tIVA += tDiferenciaIVA + End If + End If + + 'le sumo el iva al concepto + Importe += tIVA + + 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF + If TxtDescuento.Text.ToDouble > 0 Then + Importe = grp.TotalImporte * 1.16D + End If + + tAjusteTotal += Importe + 'valido que la sumas de lo detalles no exceda al totalgeneral + If Math.Round(tAjusteTotal, 2) > tTotalGral Then + 'le resto la diferencia + Importe -= (tAjusteTotal - tTotalGral) + End If + + 'Presupuesto Egresos + DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) + If DtPresupuestosTemp.Rows.Count <> 1 Then + ErrorAC = True + ErrorACMEnsaje.Append(" - DtPresupuestosTemp.Rows.Count <> 1 ") + Exit For + End If + IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero + IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero + IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero + IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero + + 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA + If grp.CveOrdencompraDetalle = -1 Then + ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 1") + Exit For + End If + Else + ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 2") + ErrorAC = True + Exit For + End If + End If + + ConceptoRenglon = String.Format("GD Fact:{0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + 'DEVENGADO + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 3") + ErrorAC = True + Exit For + End If + Else + ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 4") + ErrorAC = True + Exit For + End If + + If ContadorInventario > 0 Then + CuentaMatrizAlmacen = CtaAlmacen + ElseIf grp.CveActivoFijo > 0 Then + + Dim CtaAF = -1 + Dim AF = "" + Dim CuentaInicial = -1 + + If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then + CtaAF = ObjAF.Cuenta + AF = ObjAF.Descripcion + CuentaInicial = ObjAF.CuentaInicial + Else + ErrorAC = True + ErrorACMEnsaje.Append(" - Error al obtener activos fijos ") + Exit For + End If + + If Not CuentaInicial > 0 Then + CuentaInicial = 1241 + End If + + 'CUENTA AF + If CtaAF <= 0 Then + If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nula") + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString + CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) + + ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) + Else + ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nulo") + ErrorAC = True + End If + Else + ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000") + ErrorAC = True + End If + End If + + CuentaMatrizAlmacen = CtaAF + Else + CuentaMatrizAlmacen = IdCuentaMatriz + End If + + + ''AFECTAR MATRIZ EGRESOS + If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + + + ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) + 'If TxtDescuento.Text.ToDouble > 0 Then + ' DescuentoConIVA = TxtDescuento.Text.ToDouble * 1.16 + + ' 'Valida que el descuento con iva cuadre en los totales + ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then + ' DescuentoConIVA = Importe - TxtTotal.Text.ToDouble + ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDouble) Then + ' ErrorAC = True + ' Exit For + ' End If + + ' 'actualizo el idcuenta del presupuesto + ' If ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, Importe - DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then + ' 'agrego a la cuenta contable anticipos + ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then + ' ErrorAC = True + ' Exit For + ' End If + ' Else + ' ErrorAC = True + ' Exit For + ' End If + + 'Else + ' 'actualizo el idcuenta del presupuesto + ' Importe = TxtTotal.Text.ToDouble + ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe), "", ConceptoRenglon, 0, Fecha, "") Then + ' ErrorAC = True + ' Exit For + ' End If + + 'End If + + + Else + ErrorACMEnsaje.Append(" - Error AFECTAR MATRIZ EGRESOS ObjContaAC.AddMovimiento") + ErrorAC = True + Exit For + End If + ''TERMINA AFECTAR MATRIZ EGRESOS + + Else + ErrorACMEnsaje.Append(" - For Each grp In Presup Importe > 0 ") + ErrorAC = True + Exit For + End If + + Next + + ''[IPP] COMENTADO A MIRAS DE ELIMINAR 21-FEBRERO-2018 + ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) + 'If TxtDescuento.Text.ToDouble > 0 Then + ' DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16D + + ' 'Valida que el descuento con iva cuadre en los totales + ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDecimal)) < 0.02 Then + ' DescuentoConIVA = Importe - TxtTotal.Text.ToDecimal + ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then + ' ErrorACMEnsaje.Append(" - Valida que el descuento con iva cuadre en los totales ") + ' ErrorAC = True + ' End If + + ' 'actualizo el idcuenta del presupuesto + ' If ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then + ' 'agrego a la cuenta contable anticipos + ' If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then + ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 1") + ' ErrorAC = True + ' End If + ' Else + ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 2") + ' ErrorAC = True + ' End If + 'Else + 'actualizo el idcuenta del presupuesto + Importe = TxtTotal.Text.ToDecimal + If Not ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe)), "", ConceptoRenglon, 0, Fecha, "") Then + ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 3") + ErrorAC = True + End If + 'End If + + + If tRetISR > 0 Then + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorACMEnsaje.Append(" RetISR > 0 ObjContaAC.AddMovimiento") + ErrorAC = True + End If + End If + + 'TERMINA: PRUEBA AGRUPACION CONCEPTOS + + 'registrar amortizar anticipos + End If + + Else + ErrorACMEnsaje.Append(" - Id Poliza = 0 ") + ErrorAC = True + End If + Else + TieneError = True + ErrorACMEnsaje.Append("- TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0") + ErrorAC = True + End If + End If + + If Not ErrorAC Then + + + Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" + + If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then + AutoConta = False + End If + + If (AutoConta Or UsuarioActual.Empresa.UsaAC) And ObjContaAC Is Nothing Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + End If + + ''EMPIEZA: INSERTA DETALLES DE LA COMPRA + Dim indiceTR = 0 + Dim Cont As Integer = 0 + For Each Row As DataRow In TmpDT.Rows + Dim TipoRecepcion As Integer = -1 + + + ''INVENTARIOS + If GvInv.Rows.Count > indiceTR Then + If GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then + TipoRecepcion = 1 + ElseIf GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "0" Then + TipoRecepcion = 2 + End If + End If + + Dim CvePersonal = -1 + Dim Referencia = "" + + If GvPersonal.Rows.Count > Cont Then + CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero + Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text + End If + Cont = Cont + 1 + + 'Si es AF-INSUMO se guarda CveAF en CompraDetalle + Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) + + 'Si es AF-COMPRA se guarda CveAF en la Columna CveAFCompra + Dim CveAFC = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) + + 'AGREGA COMPRA DETALLE + If Not ObjCompras.AddCompraDetalle(CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF, + Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, Row("Descuento").ToString.ToDouble, + Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, + AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal, + CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, + RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble, + IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, + IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False)) Then + + ErrorDetalles = True + Exit For + Else + + If Row("EntregaDirecta").ToString.ToEntero > 0 Then + EntregaDirecta = True + End If + + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Row("Consec").ToString}")(0) + TmpDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle + + ' Si no es un movimiento de almacen va a tronar + Try + Dim InvDr As DataRow = DtInv.Select($"Consec = {Row("Consec").ToString}")(0) + InvDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle + Catch ex As Exception + End Try + + End If + + 'Vincula Vales + If IdVale.Count > 0 Then + For Each cve In IdVale + If Not ObjAF.UpdateValeCombustible(cve, CveCompra, -1, "", -1, -1, -1, UsuarioActual.CveEmpresa) Then + ErrorAF = True + Exit For + End If + Next + Else + + End If + + + + 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF + If Row("TipoAF").ToString.ToEntero = 2 Then + If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, ObjCompras.CveCompraDetalle, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then + ErrorDetalles = True + Exit For + End If + End If + + 'ACTUALIZAR PRODUCTO/SERVICIO SAT + If Version = "3.3" Then + If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario) Then + ErrorSATPS = True + End If + End If + + indiceTR += 1 + Next + ''TERMINA: INSERTA DETALLES DE LA COMPRA + + 'QUEMA SALDOS DE INV-COMPRA | MERCANCIA RECIBIDA POR ADELANTADO (OC) | PP 176 + If OCVinculada And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + For Each Row As DataRow In TmpDT.FiltraParametros("CveTipoPS = 2").Rows + If Not ObjOC.OrdenesCompraDetalleSaldosInvCompraAdd(Row("CveOrdenCompraDetalle").ToString.ToEntero, -1, -1, Row("CveCompraDetalle").ToString.ToEntero, Row("Cantidad").ToString.ToDouble) Then + ErrorSaldosInvComp = True + Exit For + End If + Next + + 'verifica si fue vinculada con una OC, y si fue la opción de entrega por adelantado, que si hubo cambios de precios + If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(176, 205) Then + If Not AjustarPrePolizaVinculacionOC(ObjOC, ObjEventos, ObjInventario, ObjConta, ObjContaAC) Then + ErrorPrepoliza = True + End If + End If + + End If + + If CvePrePoliza > 0 Then + + 'INVENTARIOS - ALMACEN + If UsuarioActual.Empresa.UsaInventarios Then 'And UsuarioActual.Empresa.UsaAC = False + + ''SI ES CON DOLARES VALIDA QUE SE TENGA EL TIPO DE CAMBIO DEL DIA DE LA FACTURA - SI NO, NO HACE NADA, la validación del TC, ya está chk constrains + ' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then + + ''ALMACEN CONSIGNACION + If CveConsignacion > 0 Then + + 'actualizamos cvecompraconsignacion + For Each gvr As GridViewRow In GvInv.Rows + If gvr.FCCheckBox("cbinv").Checked AndAlso gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero > 0 Then + If Not ObjInventario.UpdateConsignacionesCompra(CveCompra, gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero, gvr.FCHiddenField("HdnCveAlmacen").Value.ToEntero, gvr.FCHiddenField("HdnCvePS").Value.ToEntero, gvr.DataKey("Cantidad").ToDouble, UsuarioActual.CveEmpresa) Then + ErrorMovInv = True + Exit For + End If + End If + Next + + If Not ErrorMovInv Then + + Dim x As Integer = 0 + For Each dr As DataRow In DtInv.Rows + If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble > 0 Then + + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie + TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero 'Charlie + + dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlealmacen").SelectedValue.ToEntero + dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble + Else + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie + TmpDr("CveAlmacen") = 0 'Charlie + + dr("CveAlmacen") = 0 + End If + x = x + 1 + Next + + Dim cvemovimientosalida = 0 + Dim cvemovimientoentrada = 0 + Dim cvemovimientosalidagasto = 0 + Dim folio = 0 + Dim fecha As Date = TxtFecha.Text.ToDate + Dim indice = 0 + Dim importeconcepto = 0.0 + + Dim listalmacenes = (From cvealmacen In DtInv.AsEnumerable() Where cvealmacen.Field(Of Integer)("cvealmacen") > 0 Select cvealmacen.Field(Of Integer)("cvealmacen")).Distinct().ToList + + For Each tcvealmacen As Integer In listalmacenes + If GvInv.Rows(indice).FCDropDownList("ddlrecibirinv").SelectedValue = "1" Then + Continue For + End If + indice += 1 + + + ''agregamos la salida de consignacion + 'folio = objinventario.getfoliosiguiente(3, usuarioactual.cveempresa) + 'cvemovimientosalida = objinventario.addmovimiento(cvealmacenconsignacion, 3, ddlmoneda.selectedvalue.toentero, fecha, folio, usuarioactual.cveusuario, usuarioactual.cveempresa, cvecompra, -1, -1, -1) + 'if cvemovimientosalida <= 0 then + ' errormovinv = true + ' exit for + 'else + ' for each dr as datarow in dtinv.rows + ' if dr("cvealmacen").tostring.toentero = tcvealmacen then + ' if not objinventario.addmovimientodetalle(cvemovimientosalida, dr("cantidad").tostring.todouble, ddlum.selectedvalue.toentero, dr("cveps").tostring.toentero, 0, -1) then + ' errormovinv = true + ' exit for + + ' end if + ' end if + ' next + 'end if + + + 'agregamos la entrada + If Not UsuarioActual.Empresa.UsaAC Then fecha = Now + + folio = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa) + cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G") + If cvemovimientoentrada <= 0 Then + ErrorMovInv = True + Exit For + Else + CveMovimientoInventario = cvemovimientoentrada + ListaMovimientosAlmacen.Add(CveMovimientoInventario) + + For Each dr As DataRow In DtInv.Rows + If dr("cvealmacen").ToString.ToEntero = tcvealmacen Then + + importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDouble, dr("pu").ToString.ToDouble * TipoCambioGuardar) + If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDouble), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then + + ErrorMovInv = True + Exit For + End If + End If + Next + + End If + + 'agregamos la salida gasto + folio = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa) + cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G") + If cvemovimientosalidagasto <= 0 Then + ErrorMovInv = True + Exit For + Else + If ObjInventario.GetMovimientosDetalle(cvemovimientoentrada, UsuarioActual.CveEmpresa) Then + For Each dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(cvemovimientosalidagasto, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, 0, dr("cveaf").ToString.ToEntero, CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then + ErrorMovInv = True + Exit For + End If + Next + End If + End If + + Next + + End If + + ''ALMACEN NORMAL + Else + + 'OBTIENE ALMACENES + Dim x As Integer = 0 + For Each Dr As DataRow In DtInv.Rows + If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDecimal > 0 Then + + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0) + TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero + + Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero + Dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble + + Else 'limpio el valor para que no truene en linq mas abajo + + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0) + TmpDr("CveAlmacen") = 0 + + Dr("CveAlmacen") = 0 + End If + x = x + 1 + Next + + Dim i As Integer = 0 + Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList + Dim indice = 0 + Dim ImporteConcepto = 0.0 + + For Each tCveAlmacen As Integer In ListAlmacenes + If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then + Continue For + End If + indice += 1 + + Dim fecha As Date = TxtFecha.Text.ToDate + If Not UsuarioActual.Empresa.UsaAC Then fecha = Now + + CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar), Modulo:="Comp/G") + + If CveMovimientoInventario <= 0 Then + ErrorMovInv = True + Else + + Dim DtDetalle As New DataTable + Dim DtEquivalencias As DataTable + Dim CveProducto As Integer + Dim CantidadInv As Double + Dim PUInv As Double + Dim CveUnidad As Integer + Dim CostoIndirecto As Double + + ListaMovimientosAlmacen.Add(CveMovimientoInventario) + + + For Each Dr As DataRow In DtInv.Rows + + CveProducto = Dr("CvePS").ToString.ToEntero + CveUnidad = Dr("CveUM").ToString.ToEntero + CantidadInv = Dr("Cantidad").ToString.ToDouble + PUInv = Dr("PU").ToString.ToDouble + CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDouble + + If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then + 'SI FUE POR SERIE LOTE + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS"))) + If DtDetalle.Rows.Count > 0 Then + For Each drr As DataRow In DtDetalle.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDouble, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then + ErrorMovInv = True + Exit For + End If + + Next + End If + Else + + 'UNIDAD BASE - EQUIVALENCIAS - INVENTARIO + If UsuarioActual.CveEmpresa = 1 Then + DtEquivalencias = New DataTable + DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1, UsuarioActual.CveEmpresa) + Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero + Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") + + 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) + If CveUnidadBase <> CveUnidad Then + ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA + CantidadInv = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble + PUInv = PUInv * Dr("Cantidad").ToString.ToDouble / CantidadInv + CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDouble / CantidadInv + CveUnidad = CveUnidadBase + End If + End If + + 'si no es por serie lote + ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar) + ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto) + If Dr("CveAlmacen").ToString.ToEntero = tCveAlmacen Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDouble), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then + ErrorMovInv = True + Exit For + End If + End If + + End If + + + i = i + 1 + Next + End If + Next + + End If + + + + If AplicarCostoIndirecto(ObjInventario, ObjCompras) Then + ErrorMovInv = True + End If + + 'Else + ' Alert("El tipo de cambio no esta actualizado. Por favor comuniquese con un asistente SIG.", TipoMensaje.MsgError) + ' ErrorMovInv = True + 'End If + + End If + + '*************************************************** P R I M E R A P A R T E C O M P R A S ************************************************************************************************************************************************************************************************************************************************************************************************** + 'P R E P O L I Z A S + + Dim CveConceptoAfectacion As Integer = 5 'Proveedores + Dim CveConceptoAfectacionContado As Integer = 17 'Pago Proveedores + Dim CveConceptoCompra As Integer = 6 'Compra + Dim CveConceptoIVA As Integer = 14 'IVA Trasladado + Dim CveConceptoRetIVA As Integer = 15 'Ret IVA + Dim CveConceptoRetISR As Integer = 16 'Ret ISR + Dim CveConceptoDescuento As Integer = 24 'DSC + Dim CveConceptoRetIEPS As Integer = 25 'IEPS + Dim CveConceptoRetOtrosImpuestos As Integer = 27 'Otros Impuestos + Dim CveCreditoDetalle As Integer = -1 + + 'Afectable con el tabpanel Contable + Dim CveProveedorLocal As Integer + Dim CveProveedorConcepto As Integer + Dim CveAcreedor As Integer + Dim CveColectiva As Integer = -1 + + Dim TipoCreditoInteres As Boolean = False + Dim ImporteIECredito As Decimal = 0 + Dim SeContabiliza As Boolean = If(UsuarioActual.CveEmpresa.Contiene(119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant"), False, True) + + If RBLPago.SelectedValue = "1" Or RBLPago.SelectedValue = "3" Then + 'Credito Proveedor + CveProveedorLocal = CveProveedor + CveProveedorConcepto = CveProveedor + CveAcreedor = -1 + + Else + 'cuando es contado + + Select Case RBLContado.SelectedValue + Case "1", "6" 'Proveedores + CveProveedorLocal = CveProveedor + CveProveedorConcepto = CveProveedor + CveAcreedor = -1 + Case "2" ' F y E + CveProveedorLocal = CveProveedor + CveProveedorConcepto = CveProveedor + CveAcreedor = -1 + CveIE = DDlCheques.SelectedValue.ToEntero + Case "3" ' Doctos + + CveProveedorConcepto = CveProveedor + + If DdlTipoCredito.SelectedValue.ToEntero = 2 Then + CveProveedorLocal = CveProveedor + CveProveedorConcepto = CveProveedor + CveAcreedor = -1 + CveColectiva = -1 + ' CveConceptoAfectacionContado = 55 + CveConceptoAfectacion = 59 + CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero + ObjIE.UpdateCreditosDetalle(3, CveCreditoDetalle) + End If + Case "4" ' Deudores + CveProveedorLocal = CveProveedor + CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero + For Each row As GridViewRow In GvDeudores.Rows + If row.FCCheckBox("Chk").Checked Then + CveIE = row.DataKey("CveIE").ToString.ToEntero + Exit For + End If + Next + CveAcreedor = -1 + CveColectiva = -1 + ' CveConceptoAfectacionContado = 55 + CveConceptoAfectacion = 37 + Case "5" ' Acreedores + CveProveedorLocal = CveProveedor + CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero + CveAcreedor = -1 + CveColectiva = -1 + CveConceptoAfectacion = 41 + + If EmpresaPrueba Then + CveIE = If(DdlAcreedorDetalle.SelectedValue.ToEntero = -2, -1, DdlAcreedorDetalle.SelectedValue.ToEntero) + End If + End Select + End If + + If RBLPago.SelectedValue.ToEntero = 4 Then + Dim TmpTotal As Decimal = TxtTotal.Text.ToDecimal + Dim TmpTotalCreditos As Decimal = 0 + + For Each GvRow As GridViewRow In GvCreditos.Rows + TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtCapital").Text.ToDecimal + TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtInteres").Text.ToDecimal + TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtAmbos").Text.ToDecimal + Next + + If TmpTotalCreditos > TmpTotal Then + ErrorCredito = True + End If + + For Each GvRow As GridViewRow In GvCreditos.Rows + + Dim Capital As Decimal = GvRow.FCTextBox("TxtCapital").Text.Replace(",", "").ToDecimal + Dim Interes As Decimal = GvRow.FCTextBox("TxtInteres").Text.Replace(",", "").ToDecimal + Dim Ambos As Decimal = GvRow.FCTextBox("TxtAmbos").Text.Replace(",", "").ToDecimal + + Dim CveCreditoDetalleTemp As Integer = GvRow.DataKey("CveCreditoDetalle").ToEntero + Dim CveCreditoTemp As Integer = GvRow.DataKey("CveCredito").ToEntero + Dim EstusTemp = GvRow.DataKey("Estatus").ToEntero + ' Dim ImporteOpcionCompra As Decimal = GvRow.DataKey("ImporteOpcionCompra").ToDecimal + Dim Marcador As Decimal = GvRow.DataKey("Marcador").ToEntero + Dim CreditoEstatus As Integer = -1 + + If Capital > 0 Or Interes > 0 Or Ambos > 0 Then + + If ObjIE.GetCreditosDetalle(CveCreditoTemp, -1) Then + + Dim CveCompraCapital As Integer = -1 + Dim CveCompraInteres As Integer = -1 + + 'Dim ImporteCapital As Decimal = 0 + ' Dim ImporteCapitalIVA As Decimal = 0 + + 'Dim ImporteInteres As Decimal = 0 + ' Dim ImporteInteresIVA As Decimal = 0 + + ' Dim ImporteIEMensualidad As Decimal = ObjIE.DtResultados.FiltroPrimeroValor("ImporteIE", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal + CreditoEstatus = ObjIE.DtResultados.FiltroPrimeroValor("Estatus", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero + + CveCompraCapital = ObjIE.DtResultados.FiltroPrimeroValor("CveCompra", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero + CveCompraInteres = ObjIE.DtResultados.FiltroPrimeroValor("CveCompraInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero + + CveCompraCapital = If(CveCompraCapital < 1, -1, CveCompraCapital) + CveCompraInteres = If(CveCompraInteres < 1, -1, CveCompraInteres) + + TipoCreditoInteres = Boolean.Parse(ObjIE.DtResultados.FiltroPrimeroValor("TipoInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}")) + ImporteIECredito = ObjIE.DtResultados.FiltroPrimeroValor("ImportePago", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal + + If Ambos > 0 Then + CveCompraCapital = CveCompra + CveCompraInteres = CveCompra + + Capital = Ambos + Interes = Ambos + + End If + + If Capital > 0 Then + CveCompraCapital = CveCompra + End If + If Interes > 0 Then + CveCompraInteres = CveCompra + End If + + + + If (CveCompraCapital > 0 And CveCompraInteres > 0) And EstusTemp = 2 Then + If EstusTemp = 2 Then + EstusTemp = 3 + ElseIf EstusTemp = 1 Or EstusTemp = 4 Then + EstusTemp = 4 + End If + ElseIf CveCompraCapital > 0 Or CveCompraInteres > 0 Then + If EstusTemp = 2 Then + EstusTemp = 2 + ElseIf EstusTemp = 1 Or EstusTemp = 4 Then + EstusTemp = 4 + End If + End If + + If Not ObjIE.UpdateCreditosDetalle(CveCreditoDetalleTemp, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, EstusTemp, CveCompra:=CveCompraCapital, CveCompraInteres:=CveCompraInteres, importeCapital:=Capital, + ImporteInteres:=Interes) Then + ErrorCredito = True + End If + 'ObjIE.UpdateCreditosDetalle(CveCreditoDetalle, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, Estatus) + + + + Else + ErrorCredito = True + End If + End If + Next + End If + + Dim TipoMovimientoCompra As Boolean = False + Dim TipoMovimientoImpuestos As Boolean = True + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CveConceptoAfectacion = 18 'Devolución del Proveedor (NC) + TipoMovimientoCompra = Not TipoMovimientoCompra + TipoMovimientoImpuestos = Not TipoMovimientoImpuestos + End If + + If EmpresaPrueba Then 'Empresa Prueba + + Dim PorcentajePagos As Decimal = 0 + Dim sumaPagos As Decimal = 0 + Dim tipoCambioActual As Decimal + Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" + Dim idCuentaContabilizacion As Long = 1 + Dim CveCuentaContabilizacion As Long = 1 + Dim FechaMovimiento As Date = TxtFecha.Text.ToDate + Dim DT As DataTable = Nothing + Dim CuentasContablesInvalidas As New StringBuilder + Dim CuentasContablesInvalidasSIG As New StringBuilder + Dim ConceptoPersonal As String = "" + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + Dim GuardoConcepto18 As Boolean = False + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + + + + '********************** Variables '********************** + + '****** Pagos + + 'Bancos (30) + Dim importeBanco As Decimal = 0 + If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then + importeBanco = TxtDocumentoImporte.Text.ToDecimal + sumaPagos += importeBanco + End If + + 'Caja Chica (30) + Dim importeCajaChica As Decimal = 0 + If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "6" Then + importeCajaChica = TxtDocumentoImporteCaja.Text.ToDecimal + sumaPagos += importeCajaChica + End If + + 'Funcionarios y Empleados (29) + Dim importeFE As Decimal = 0 + If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "2" Then + ViewState("CvePersonal") = DdlFuncionarioEmpleado.SelectedValue.ToEntero + ConceptoPersonal = DdlFuncionarioEmpleado.SelectedItem.ToString + importeFE = TxtDocumentoImporteFE.Text.ToDecimal + sumaPagos += importeFE + End If + + 'Deudores (37) + Dim importeDD As Decimal = 0 + If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "4" Then + ConceptoPersonal = DdlDeudor.SelectedItem.ToString + importeDD = TxtContadoDeudor.Text.ToDecimal + sumaPagos += importeDD + End If + + 'Acreedores (41) SinTarjeta + Dim importeAcreedores As Decimal = 0 + If (CveIE > 0 Or DdlAcreedorDetalle.SelectedValue.ToEntero = -2) AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "5" Then + ConceptoPersonal = DdlAcreedor.SelectedItem.ToString + importeAcreedores = TxtContadoAcreedor.Text.ToDecimal + sumaPagos += importeAcreedores + End If + + 'Acreedores (42) ConTarjeta + Dim importeAcreedoresTarjeta As Decimal = 0 + If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then + ConceptoPersonal = DdlTarjeta.SelectedItem.ToString + importeAcreedoresTarjeta = TxtDocumentoImporte.Text.ToDecimal + sumaPagos += importeAcreedoresTarjeta + End If + + 'Creditos/Documentos (59) + Dim importeCreditos As Decimal = 0 + Dim CveIECreditos = -1 + If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "3" AndAlso DdlTipoCredito.SelectedValue.ToEntero = 2 Then + If ObjIE.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then + CveIECreditos = ObjIE.DtResultados.FiltroPrimero($"CveCreditoDetalle = {DdlCreditoDetalle.SelectedValue.ToEntero}")("CveIE").ToString.ToEntero + End If + ConceptoPersonal = DdlCredito.SelectedItem.ToString + importeCreditos = TxtTotal.Text.ToDecimal + sumaPagos += importeCreditos + End If + + PorcentajePagos = If(TxtTotal.Text.ToDecimal > 0, sumaPagos / TxtTotal.Text.ToDecimal, 0) + + '****** Acreditables + + 'IVA Acreditable (19) + Dim importeIVAAcreditable As Decimal = 0 + importeIVAAcreditable = TxtIVA.Text.ToDecimal * PorcentajePagos + + 'IEPS Acreditable (26) + Dim ImporteIEPSAcreditable As Decimal = 0 + ImporteIEPSAcreditable = TxtIEPS.Text.ToDecimal * PorcentajePagos + + 'RetIVA Acrediable (22) + Dim importeRetIVAAcreditable As Decimal = 0 + importeRetIVAAcreditable = TxtRetIVA.Text.ToDecimal * PorcentajePagos + + 'RetISR Acreditable (23) + Dim importeRetISRAcreditable As Decimal = 0 + importeRetISRAcreditable = TxtRetISR.Text.ToDecimal * PorcentajePagos + + + + '****** X Acreditar + 'IVA X Acreditar (14) + Dim importeIVAxAcreditar As Decimal = 0 + importeIVAxAcreditar = TxtIVA.Text.ToDecimal + + 'IEPS X Acreditar (25) + Dim ImporteIEPSxAcreditar As Decimal = 0 + ImporteIEPSxAcreditar = TxtIEPS.Text.ToDecimal + + 'Otros Impuestos (224) + Dim OtrosImpuestos As Decimal = 0 + OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal + + 'RetIVA X Acreditar (15) + Dim importeRetIVAxAcreditar As Decimal = 0 + importeRetIVAxAcreditar = TxtRetIVA.Text.ToDecimal + + 'RetISR X Acreditar (16) + Dim importeRetISRxAcreditar As Decimal = 0 + importeRetISRxAcreditar = TxtRetISR.Text.ToDecimal + + + + '****** Movimientos Independientes + + 'Pago Proveedores (17) + Dim importePagoProv As Decimal = 0 + importePagoProv = sumaPagos + + 'If CveIE > 0 AndAlso ((RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0) Or (RBLContado.SelectedValue = "4" AndAlso DdlDeudor.SelectedValue.ToEntero > 0)) Then + ' importePagoProv = TxtDocumentoImporteFE.Text.ToDecimal + 'End If + + 'Compra (6) + 'Ya que es un foreach todo su proceso esta en el Case 6 + + 'Proveedores (5) + Dim importeProv As Decimal = 0 + importeProv = TxtTotal.Text.ToDecimal + + 'Nota de Credito (18) + Dim importeNC As Decimal = 0 + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + importeNC = TxtTotal.Text.ToDecimal + End If + + '************************************************************************************************************************** + + Dim TipoCambioCompra As Decimal = 1 + TipoCambioCompra = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal + TipoCambioCompra = If(DivTC.Visible, TipoCambio.ToDecimal, TipoCambioCompra) + + If CveMonedaPago = 1 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + TipoCambioCompra = 1 + End If + + If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then + tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal + tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual) + Else + tipoCambioActual = 1 + End If + + 'CASO ESPECIAL CREDITOS + If CveIECreditos > 0 Then + CveIE = CveIECreditos + 'Dim CveIEProvisional = CveIE + End If + + + + If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then + + Dim DTPlatilla As New DataTable + DTPlatilla = ObjConta.DtResultados + + For Each Row As DataRow In DTPlatilla.Rows + + Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero + Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) + Dim importeMovimiento As Decimal = 0 + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim Concepto As String = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, $"{TxtSerie.Text}-{TxtFolio.Text}", If(TxtDocumentoFolio.Visible, TxtDocumentoFolio.Text, If(TxtDocumentoFolioCaja.Visible, TxtDocumentoFolioCaja.Text, ConceptoPersonal))) + Dim importeMN As Decimal = 0 + Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) + Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation + Dim PorcentajeImpuesto As Decimal = 0 + + + Select Case ConceptoContable + + + + + Case 17 'Pago Proveedores + + importeMovimiento = importePagoProv + If CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + importeMovimiento = importeMovimiento / TipoCambioCompra + End If + importeMN = importeMovimiento * TipoCambioCompra * Multiplicador + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + + + If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(2, 102) Then 'SI ES CRÉDITO Y ESTA PAGADO + + Dim IdSegmentoNegocio As Integer = -1 + For Each Row2 As DataRow In TmpDT.Rows + + importeMovimiento = TxtTotal.Text.ToDecimal 'TmpDT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + 'CLASIFICACION + If Row2("CveClasificacion").ToString.ToEntero > 0 Then + If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + End If + End If + End If + + + + + 'SEGMENTO DE NEGOCIO + + Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) + If drT IsNot Nothing Then + IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero + End If + + 'AGREGA MOVIMIENTO + If importeMovimiento <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + End If + Next + + + + Dim CveClasificacionDT As Integer = -1 + Dim CveSubProyectoDT As Integer = -1 + Dim CveTipoGastoDT As Integer = -1 + + If TmpDT.Rows.Count > 0 Then + CveClasificacionDT = TmpDT(0)("CveClasificacion").ToString.ToEntero + CveSubProyectoDT = TmpDT(0)("CveSubProyecto").ToString.ToEntero + CveTipoGastoDT = TmpDT(0)("CveTipoGasto").ToString.ToEntero + End If + + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + + Dim ImporteSubCre As Decimal = TxtSubTotal.Text.ToDecimal + Dim ImporteSubCreMN As Decimal = TxtSubTotal.Text.ToDecimal * tipoCambioActual + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteSubCre, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=ImporteSubCreMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteSubCre), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + If TipoCreditoInteres Then + + + Dim importeMovimientoIn As Decimal = ImporteIECredito - importeMovimiento + Dim importeMNIn As Decimal = importeMovimientoIn * tipoCambioActual * Multiplicador + + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoIn, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoIn, Referencia, 50, Concepto, FechaMovimiento, ViewState("IdCtaContDocsXPagar").ToString.ToEntero(), IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + + End If + End If + + + + + End If + + If TipoCambioCompra > 1 AndAlso DdlMoneda.SelectedValue.ToEntero <> 1 Then Concepto += $" TC:{TipoCambioCompra} ${importeMovimiento.FormatoNumero(2)}" + + If TipoCambioCompra = 1 Or DdlMoneda.SelectedValue.ToEntero = 1 Then + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + importeMovimiento = importeMN + Else + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos + importeMN = importeMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento * TipoCambioCompra - importeMovimiento, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * TipoCambioCompra - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=TipoCambioCompra) Then + ErrorPrepoliza = True + End If + End If + + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + End If + + Case 30 'Bancos + importeMovimiento = importeBanco + importeCajaChica 'Uno de los dos debe ser 0 + If CveMonedaPago = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 1 Then + importeMovimiento = importeMovimiento / TCPago + End If + importeMN = importeMovimiento * TCPago * Multiplicador + + If TCPago > 1 AndAlso CveMonedaPago <> 1 Then Concepto += $" TC:{TCPago} ${importeMovimiento.FormatoNumero(2)}" + + If TCPago = 1 Or CveMonedaPago = 1 Then + IdCtaContable = IdCuentaBancaria + CveCuenta = CveCuentaBancaria + Else + IdCtaContable = IdCuentaBancariaComplementaria + CveCuenta = CveCuentaBancariaComplementaria + If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos + importeMN = importeMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento * TCPago - importeMovimiento, Referencia, 204, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * TCPago - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=TCPago) Then + ErrorPrepoliza = True + End If + End If + + IdCtaContable = IdCuentaBancaria + CveCuenta = CveCuentaBancaria + End If + + + Case 19 'IVA Acreditable + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + If importePagoProv = importeProv Then + importeMovimiento = TxtIVA.Text.ToDecimal + Else + importeMovimiento = 0 + End If + Else + importeMovimiento = importeIVAAcreditable + End If + + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + + PorcentajeImpuesto = PorcentajeIVA + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + + 'Agregamos el Opuesto del 19 -> 14 + If importeMovimiento <> 0 Then + Dim IdCtaIva As Integer = 0 + Dim CveCuentaIVA As Integer = 0 + IdCtaIva = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) + + If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaIva = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero + CveCuentaIVA = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero + End If + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 14, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIva, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVA, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + Case 14 'IVA X Acreditar + importeMovimiento = importeIVAxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + PorcentajeImpuesto = PorcentajeIVA + IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero + End If + End If + Case 25 'IEPS X Acreditar + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + importeMovimiento = ImporteIEPSxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero + End If + End If + End If + + Case 224 'Otros impuestos + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + importeMovimiento = OtrosImpuestos + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + IdCtaContable = If(UsuarioActual.CveEmpresa = 119, 1171, -1) + CveCuenta = -1 + End If + Case 26 'IEPS Acreditable + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + importeMovimiento = ImporteIEPSAcreditable + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero + End If + End If + + 'Agregamos el Opuesto del 26 -> 25 + If importeMovimiento <> 0 Then + Dim IdCtaIEPS As Integer = 0 + Dim CveCuentaIEPS As Integer = 0 + If ObjConta.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero + CveCuentaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero + End If + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 25, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIEPS, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIEPS, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + + End If + Case 22 'RetIVA Acreditable Honorarios/Serv. Prof. + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then + importeMovimiento = importeRetIVAAcreditable + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If End If @@ -5898,191 +5898,191 @@ Partial Class Compras_Compras 'Agregamos el Opuesto del 22 -> 15 - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - End If - End If - End If - Case 15 'RetIVA X Acreditar Honorarios/Serv. Prof. - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then - importeMovimiento = importeRetIVAxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 184 'RetIVA Acreditable Fletes P.F - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then - importeMovimiento = importeRetIVAAcreditable - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - - 'Agregamos el Opuesto del 184 -> 183 - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 183, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - End If - End If - End If - Case 183 'RetIVA X Acreditar Fletes P.F - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then - importeMovimiento = importeRetIVAxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 248 'RetIVA X Acreditar Arrendamiento - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then - importeMovimiento = importeRetIVAxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - - End If - End If - Case 186 'RetIVA Acreditable Fletes P.M. - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then - importeMovimiento = importeRetIVAAcreditable - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - - 'Agregamos el Opuesto del 186 -> 185 - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 185, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - End If - End If - End If - Case 185 'RetIVA X Acreditar Fletes P.M. - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then - importeMovimiento = importeRetIVAxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 249 'RetIVA Acreditable Arrendamiento - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then - importeMovimiento = importeRetIVAAcreditable - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - End If - + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + End If + End If + End If + Case 15 'RetIVA X Acreditar Honorarios/Serv. Prof. + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then + importeMovimiento = importeRetIVAxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 184 'RetIVA Acreditable Fletes P.F + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then + importeMovimiento = importeRetIVAAcreditable + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + + 'Agregamos el Opuesto del 184 -> 183 + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 183, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + End If + End If + End If + Case 183 'RetIVA X Acreditar Fletes P.F + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then + importeMovimiento = importeRetIVAxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 248 'RetIVA X Acreditar Arrendamiento + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then + importeMovimiento = importeRetIVAxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + + End If + End If + Case 186 'RetIVA Acreditable Fletes P.M. + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then + importeMovimiento = importeRetIVAAcreditable + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + + 'Agregamos el Opuesto del 186 -> 185 + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 185, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + End If + End If + End If + Case 185 'RetIVA X Acreditar Fletes P.M. + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then + importeMovimiento = importeRetIVAxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 249 'RetIVA Acreditable Arrendamiento + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then + importeMovimiento = importeRetIVAAcreditable + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + End If + End If 'Case 23 'RetISR Acreditable ' If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then @@ -6113,48 +6113,48 @@ Partial Class Compras_Compras ' If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" ' End If ' End If - Case 16 'Ret ISR X Acreditar - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then - importeMovimiento = importeRetISRxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - Case 243 'RetISR X Acreditar Terceros y Arrendamiento - If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then - importeMovimiento = importeRetISRxAcreditar - importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - End If + Case 16 'Ret ISR X Acreditar + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then + importeMovimiento = importeRetISRxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + Case 243 'RetISR X Acreditar Terceros y Arrendamiento + If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then + importeMovimiento = importeRetISRxAcreditar + importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + End If End If 'Case 244 'RetISR Acreditable Terceros y Arrendamiento ' If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then @@ -6183,487 +6183,487 @@ Partial Class Compras_Compras ' If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" ' End If ' End If - Case 64 'Ganancia - If TCPago <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - If TCPago < TipoCambioCompra Then - importeMovimiento = Math.Abs(TCPago - TipoCambioCompra) * importePagoProv - importeMovimiento -= Math.Abs(TCPago - TipoCambioCompra) * importeIVAAcreditable - importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetIVAAcreditable - importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetISRAcreditable - importeMN = importeMovimiento - End If - Else - importeMovimiento = 0 - End If - + Case 64 'Ganancia + If TCPago <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + If TCPago < TipoCambioCompra Then + importeMovimiento = Math.Abs(TCPago - TipoCambioCompra) * importePagoProv + importeMovimiento -= Math.Abs(TCPago - TipoCambioCompra) * importeIVAAcreditable + importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetIVAAcreditable + importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetISRAcreditable + importeMN = importeMovimiento + End If + Else + importeMovimiento = 0 + End If + Case 65 'Perdida - If TCPago <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - If TCPago < TipoCambioCompra Then - importeMovimiento = Math.Abs(TCPago - TipoCambioCompra) * importePagoProv - importeMovimiento -= Math.Abs(TCPago - TipoCambioCompra) * importeIVAAcreditable - importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetIVAAcreditable - importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetISRAcreditable - importeMN = importeMovimiento - End If - Else - importeMovimiento = 0 + If TCPago <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + If TCPago < TipoCambioCompra Then + importeMovimiento = Math.Abs(TCPago - TipoCambioCompra) * importePagoProv + importeMovimiento -= Math.Abs(TCPago - TipoCambioCompra) * importeIVAAcreditable + importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetIVAAcreditable + importeMovimiento += Math.Abs(TCPago - TipoCambioCompra) * importeRetISRAcreditable + importeMN = importeMovimiento + End If + Else + importeMovimiento = 0 End If - Case 285 'Ret IVA 6% Servicios - - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero - - 'If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - ' CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - ' End If - 'End If - - - If DdlRetIVAConcepto.SelectedValue.ToEntero = 5 Then - - If CveMoneda = 2 Then - importeMN = TmpDT.SUMD("RetIVA") * TxtTC.Text.ToDecimal - Else - importeMN = TmpDT.SUMD("RetIVA") - importeMovimiento = TmpDT.SUMD("RetIVA") - - End If - - Else - importeMovimiento = 0 + Case 285 'Ret IVA 6% Servicios + + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero + + 'If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + ' CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + ' End If + 'End If + + + If DdlRetIVAConcepto.SelectedValue.ToEntero = 5 Then + + If CveMoneda = 2 Then + importeMN = TmpDT.SUMD("RetIVA") * TxtTC.Text.ToDecimal + Else + importeMN = TmpDT.SUMD("RetIVA") + importeMovimiento = TmpDT.SUMD("RetIVA") + + End If + + Else + importeMovimiento = 0 End If - Case 6 'Compra - + Case 6 'Compra + Dim AgregaMercanciaInventario As Boolean = UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 140, 141) AndAlso UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Dim RegistraConcepto225 As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" - If RBLPago.SelectedValue.ToEntero = 4 Then - Exit Select 'Es credito el concepto 6 se agrega en CASE 17 - End If - - If Not CveCompraRefacturacion > 0 OrElse ChkRefacNC.Checked Then - 'AF TipoAF 2 Es para las compras - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1") - If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - For Each Row2 As DataRow In DT.Rows - importeMovimiento = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Row2("ImporteSinImpuestos").ToString.ToDecimal, Row2("Total").ToString.ToDecimal) - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero - End If - End If - - If importeMovimiento <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - Next - End If - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - 'COSTO ALMACEN - Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - For Each Dr As DataRow In DT.Rows - If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then - Dr("CveAlmacen") = 0 - End If - Dr.AcceptChanges() - Next - DT.AcceptChanges() - DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") - If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - For Each Row2 As DataRow In DT.Rows - - importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero - End If - End If - If importeMovimiento <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - Next - End If - End If - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - ''FLETES - 'If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And DdlTipoComprobante.SelectedValue <> "NC" And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(237, 240) Then - - 'End If - Dim CostoIndirectoAcum176 As Decimal = 0 - 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] - If AgregaMercanciaInventario AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") AndAlso CveConceptoContableAlmacen.Contiene(205, 176, 237, 240) Then - - importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND (ISNULL(CveTipoPS,0) = 2 OR (ISNULL(CveTipoPS,0) = 1 AND ISNULL(AplicaCostoIndirecto,0) = 1))").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - Dim ConceptoContabilizacion = 205 - Dim ConceptoContabilizacionME = -1 - Dim IdCtaContableME = -1 - Dim ConceptoContabilizacionMEComp = -1 - Dim IdCtaContableMEComp = -1 - - If OCVinculada Or CveConceptoContableAlmacen.Contiene(237, 240) Then - ConceptoContabilizacion = CveConceptoContableAlmacen - End If - Dim UsaComplementariaFleteImportaciones As Boolean = False - - Select Case ConceptoContabilizacion - Case 176 - ConceptoContabilizacionME = 228 - ConceptoContabilizacionMEComp = 229 - Case 205 - ConceptoContabilizacionME = 230 - ConceptoContabilizacionMEComp = 231 - Case 237 - ConceptoContabilizacionME = 238 - ConceptoContabilizacionMEComp = 239 - importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) - importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO - Case 240 - ConceptoContabilizacionME = 241 - ConceptoContabilizacionMEComp = 242 - importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) - importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO - End Select - - If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - - If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - - If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - Dim CveMovimientoAlmacen As Integer = -1 - - 'If importeMovimiento <> 0 Then - Select Case ConceptoContabilizacion - Case 176 - Dim SumatoriaOCINV = 0.0D, Importe176 = 0.0D, ImporteME176 = 0.0D, ImporteMN176 = 0.0D, Importe228 = 0.0D, ImporteME228 = 0.0D, ImporteMN228 = 0.0D, Importe229 = 0.0D, ImporteME229 = 0.0D, ImporteMN229 = 0.0D, ImporteCI176 = 0.0D - For Each Dr As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").Rows - If ObjOC.OrdenesCompraDetalleCostoPP(Dr("CveOrdenCompraDetalle").ToString.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count >= 1 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text} OC: {ObjOC.DtResultados.FiltroPrimeroValor("Folio").ToString} Inv:{ObjOC.DtResultados.FiltroPrimeroValor("FolioAlmacen").ToString}" - Importe176 = ObjOC.DtResultados.FiltroPrimeroValor("Importe176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN176").ToDecimal * Dr("Cantidad").ToString.ToDecimal - Importe228 = ObjOC.DtResultados.FiltroPrimeroValor("Importe228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN228").ToDecimal * Dr("Cantidad").ToString.ToDecimal - Importe229 = ObjOC.DtResultados.FiltroPrimeroValor("Importe229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN229").ToDecimal * Dr("Cantidad").ToString.ToDecimal - ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI176").ToDecimal - CveMovimientoAlmacen = ObjOC.DtResultados.FiltroPrimeroValor("CveMovimientoAlmacen").ToEntero - Dim TCAjuste As Decimal = ObjOC.DtResultados.FiltroPrimeroValor("TipoCambioAjuste").ToDecimal - 'RMF. falta verificar el costo indirecto de la OC - If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI228").ToDecimal - CostoIndirectoAcum176 += ImporteCI176 - 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio - SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN228 + ImporteMN229 - ImporteCI176) - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe228, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN228, ImporteME:=ImporteME228, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe229, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN229, ImporteME:=ImporteME229, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - Else - CostoIndirectoAcum176 += ImporteCI176 - 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio - SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN176 - ImporteCI176) - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe176, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN176, ImporteME:=ImporteME176, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - Else - Alert("Ocurrió un error al procesar la mercancia recibida por adelantado. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) - ErrorPrepoliza = True - Exit For - End If - Next - If SumatoriaOCINV.RoundSQL <> 0 Then - ' se abona el costo, cambiamos su naturaleza - SumatoriaOCINV = -SumatoriaOCINV - Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SumatoriaOCINV, Referencia, 69, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=CveClasificacionCostoOC, ImporteMX:=SumatoriaOCINV, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - Case 205, 237, 240 - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If DdlMoneda.SelectedValue.ToEntero <> 1 AndAlso UsaComplementariaFleteImportaciones Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN - importeMovimiento, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - Else - ErrorPrepoliza = True - End If - Else - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - End Select - 'End If - - End If - - 'falta el registro de la NC cuando es - Dim RegistroCuentaPuente As Boolean = False - 'NC CON PRODUCTOS - CUENTA PUENTE - If RegistraConcepto225 Then - - importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - Dim ConceptoContabilizacionNC = 225 - - If ObjConta.GetRetCuenta(ConceptoContabilizacionNC, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - End If - - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - - If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then - RegistroCuentaPuente = True - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - End If - - - If UsuarioActual.CveEmpresa.Contiene(119) Then - Dim ContienePSNeteoBonif As Boolean = False - For Each Dr As DataRow In TmpDT.Rows - If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Then 'clasificación de Bonificación, no se incluirá en el neteo - ContienePSNeteoBonif = True - Exit For - End If - Next - - If ContienePSNeteoBonif Then - importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 ").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - Else - ErrorPrepoliza = True - End If - End If - End If - - + If RBLPago.SelectedValue.ToEntero = 4 Then + Exit Select 'Es credito el concepto 6 se agrega en CASE 17 + End If + + If Not CveCompraRefacturacion > 0 OrElse ChkRefacNC.Checked Then + 'AF TipoAF 2 Es para las compras + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1") + If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + For Each Row2 As DataRow In DT.Rows + importeMovimiento = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Row2("ImporteSinImpuestos").ToString.ToDecimal, Row2("Total").ToString.ToDecimal) + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero + End If + End If + + If importeMovimiento <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next + End If + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + 'COSTO ALMACEN + Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + For Each Dr As DataRow In DT.Rows + If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then + Dr("CveAlmacen") = 0 + End If + Dr.AcceptChanges() + Next + DT.AcceptChanges() + DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") + If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + For Each Row2 As DataRow In DT.Rows + + importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero + End If + End If + If importeMovimiento <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next + End If + End If + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + ''FLETES + 'If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And DdlTipoComprobante.SelectedValue <> "NC" And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(237, 240) Then + + 'End If + Dim CostoIndirectoAcum176 As Decimal = 0 + 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] + If AgregaMercanciaInventario AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") AndAlso CveConceptoContableAlmacen.Contiene(205, 176, 237, 240) Then + + importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND (ISNULL(CveTipoPS,0) = 2 OR (ISNULL(CveTipoPS,0) = 1 AND ISNULL(AplicaCostoIndirecto,0) = 1))").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + Dim ConceptoContabilizacion = 205 + Dim ConceptoContabilizacionME = -1 + Dim IdCtaContableME = -1 + Dim ConceptoContabilizacionMEComp = -1 + Dim IdCtaContableMEComp = -1 + + If OCVinculada Or CveConceptoContableAlmacen.Contiene(237, 240) Then + ConceptoContabilizacion = CveConceptoContableAlmacen + End If + Dim UsaComplementariaFleteImportaciones As Boolean = False + + Select Case ConceptoContabilizacion + Case 176 + ConceptoContabilizacionME = 228 + ConceptoContabilizacionMEComp = 229 + Case 205 + ConceptoContabilizacionME = 230 + ConceptoContabilizacionMEComp = 231 + Case 237 + ConceptoContabilizacionME = 238 + ConceptoContabilizacionMEComp = 239 + importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) + importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO + Case 240 + ConceptoContabilizacionME = 241 + ConceptoContabilizacionMEComp = 242 + importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) + importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO + End Select + + If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + + If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + + If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + Dim CveMovimientoAlmacen As Integer = -1 + + 'If importeMovimiento <> 0 Then + Select Case ConceptoContabilizacion + Case 176 + Dim SumatoriaOCINV = 0.0D, Importe176 = 0.0D, ImporteME176 = 0.0D, ImporteMN176 = 0.0D, Importe228 = 0.0D, ImporteME228 = 0.0D, ImporteMN228 = 0.0D, Importe229 = 0.0D, ImporteME229 = 0.0D, ImporteMN229 = 0.0D, ImporteCI176 = 0.0D + For Each Dr As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").Rows + If ObjOC.OrdenesCompraDetalleCostoPP(Dr("CveOrdenCompraDetalle").ToString.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count >= 1 Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text} OC: {ObjOC.DtResultados.FiltroPrimeroValor("Folio").ToString} Inv:{ObjOC.DtResultados.FiltroPrimeroValor("FolioAlmacen").ToString}" + Importe176 = ObjOC.DtResultados.FiltroPrimeroValor("Importe176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN176").ToDecimal * Dr("Cantidad").ToString.ToDecimal + Importe228 = ObjOC.DtResultados.FiltroPrimeroValor("Importe228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN228").ToDecimal * Dr("Cantidad").ToString.ToDecimal + Importe229 = ObjOC.DtResultados.FiltroPrimeroValor("Importe229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN229").ToDecimal * Dr("Cantidad").ToString.ToDecimal + ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI176").ToDecimal + CveMovimientoAlmacen = ObjOC.DtResultados.FiltroPrimeroValor("CveMovimientoAlmacen").ToEntero + Dim TCAjuste As Decimal = ObjOC.DtResultados.FiltroPrimeroValor("TipoCambioAjuste").ToDecimal + 'RMF. falta verificar el costo indirecto de la OC + If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI228").ToDecimal + CostoIndirectoAcum176 += ImporteCI176 + 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio + SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN228 + ImporteMN229 - ImporteCI176) + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe228, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN228, ImporteME:=ImporteME228, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe229, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN229, ImporteME:=ImporteME229, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + Else + CostoIndirectoAcum176 += ImporteCI176 + 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio + SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN176 - ImporteCI176) + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe176, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN176, ImporteME:=ImporteME176, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoAlmacen, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + Else + Alert("Ocurrió un error al procesar la mercancia recibida por adelantado. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) + ErrorPrepoliza = True + Exit For + End If + Next + If SumatoriaOCINV.RoundSQL <> 0 Then + ' se abona el costo, cambiamos su naturaleza + SumatoriaOCINV = -SumatoriaOCINV + Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SumatoriaOCINV, Referencia, 69, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=CveClasificacionCostoOC, ImporteMX:=SumatoriaOCINV, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + Case 205, 237, 240 + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If DdlMoneda.SelectedValue.ToEntero <> 1 AndAlso UsaComplementariaFleteImportaciones Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN - importeMovimiento, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + Else + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + End Select + 'End If + + End If + + 'falta el registro de la NC cuando es + Dim RegistroCuentaPuente As Boolean = False + 'NC CON PRODUCTOS - CUENTA PUENTE + If RegistraConcepto225 Then + + importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + Dim ConceptoContabilizacionNC = 225 + + If ObjConta.GetRetCuenta(ConceptoContabilizacionNC, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + End If + + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + + If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then + RegistroCuentaPuente = True + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + End If + + + If UsuarioActual.CveEmpresa.Contiene(119) Then + Dim ContienePSNeteoBonif As Boolean = False + For Each Dr As DataRow In TmpDT.Rows + If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Then 'clasificación de Bonificación, no se incluirá en el neteo + ContienePSNeteoBonif = True + Exit For + End If + Next + + If ContienePSNeteoBonif Then + importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 ").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + End If + End If + + End If ' adfasdasd 'ChkNCInvNC - If Not RegistroCuentaPuente AndAlso Not ChkNCInvNC.Checked Then - 'GASTO - If UsuarioActual.CveEmpresa = 119 Then - DT = TmpDT - Else - DT = TmpDT.FiltraParametros("ISNULL(AplicaCostoIndirecto,0) <> 1") - End If - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - For Each Dr As DataRow In DT.Rows - If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then - Dr("CveAlmacen") = 0 - End If - Dr.AcceptChanges() - Next - DT.AcceptChanges() - DtAlmacenes.Dispose() - - 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] - If AgregaMercanciaInventario Then - DT = DT.FiltraParametros("ISNULL(CveTipoPS,0) <> 2") - End If - - Dim DTDistinct = DT.Copy - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - Else - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - End If - 'RMF, si es concepto relacionado a flete o importacion, no debe de afectar al gasto - If CveFlete > 0 OrElse CveImportacion > 0 Then - DTDistinct.Clear() - End If - - If DTDistinct.Rows.Count > 0 Then - For Each Row2 As DataRow In DTDistinct.Rows - - 'DETERMINA IMPORTE - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - Else - importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - End If - 'se debe de restar el costo indirecto, si se recibió por OC sobre el importe del gasto, por si ya está incuido - importeMovimiento = importeMovimiento - CostoIndirectoAcum176 - - importeMN = importeMovimiento * tipoCambioActual * Multiplicador '[IPP] EL 6 DEBE SER POSITIVO 27/AGOSTO/2018 - - 'CLASIFICACION - If Row2("CveClasificacion").ToString.ToEntero > 0 Then - If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - End If - End If - End If - - 'SEGMENTO DE NEGOCIO - Dim IdSegmentoNegocio As Integer = -1 - Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) - If drT IsNot Nothing Then - IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero - End If - - 'AGREGA MOVIMIENTO - If importeMovimiento.RoundSQL <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - Dim tcvecon As Integer = 6 - Dim tidctacon As Integer = 6 - tidctacon = IdCtaContable - If DdlTipoComprobante.SelectedValue = "Ant" Then - tcvecon = 264 - tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero - If DdlMoneda.SelectedValue = "2" Then - tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero - End If - End If - - Dim usacomplementariaProveedor As Boolean = False - usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) - - If usacomplementariaProveedor AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then - 'importeMovimiento - - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - importeMN = tipoCambioActual * importeMovimiento - importeMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 266, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - importeMN = importeMovimiento - End If - - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, tcvecon, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - - - - - End If - - Next - End If - End If - - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - End If + If Not RegistroCuentaPuente AndAlso Not ChkNCInvNC.Checked Then + 'GASTO + If UsuarioActual.CveEmpresa = 119 Then + DT = TmpDT + Else + DT = TmpDT.FiltraParametros("ISNULL(AplicaCostoIndirecto,0) <> 1") + End If + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + For Each Dr As DataRow In DT.Rows + If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then + Dr("CveAlmacen") = 0 + End If + Dr.AcceptChanges() + Next + DT.AcceptChanges() + DtAlmacenes.Dispose() + + 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] + If AgregaMercanciaInventario Then + DT = DT.FiltraParametros("ISNULL(CveTipoPS,0) <> 2") + End If + + Dim DTDistinct = DT.Copy + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + Else + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + End If + 'RMF, si es concepto relacionado a flete o importacion, no debe de afectar al gasto + If CveFlete > 0 OrElse CveImportacion > 0 Then + DTDistinct.Clear() + End If + + If DTDistinct.Rows.Count > 0 Then + For Each Row2 As DataRow In DTDistinct.Rows + + 'DETERMINA IMPORTE + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + Else + importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + End If + 'se debe de restar el costo indirecto, si se recibió por OC sobre el importe del gasto, por si ya está incuido + importeMovimiento = importeMovimiento - CostoIndirectoAcum176 + + importeMN = importeMovimiento * tipoCambioActual * Multiplicador '[IPP] EL 6 DEBE SER POSITIVO 27/AGOSTO/2018 + + 'CLASIFICACION + If Row2("CveClasificacion").ToString.ToEntero > 0 Then + If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + End If + End If + End If + + 'SEGMENTO DE NEGOCIO + Dim IdSegmentoNegocio As Integer = -1 + Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) + If drT IsNot Nothing Then + IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero + End If + + 'AGREGA MOVIMIENTO + If importeMovimiento.RoundSQL <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + Dim tcvecon As Integer = 6 + Dim tidctacon As Integer = 6 + tidctacon = IdCtaContable + If DdlTipoComprobante.SelectedValue = "Ant" Then + tcvecon = 264 + tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero + If DdlMoneda.SelectedValue = "2" Then + tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero + End If + End If + + Dim usacomplementariaProveedor As Boolean = False + usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) + + If usacomplementariaProveedor AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then + 'importeMovimiento + + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + importeMN = tipoCambioActual * importeMovimiento - importeMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 266, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + importeMN = importeMovimiento + End If + + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, tcvecon, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + + + + + End If + + Next + End If + End If + + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + End If Case 5 'Proveedores - If CveTipoConcepto = 2 Then ConceptoContable = 305 'cuando es acreedor - If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - - importeMovimiento = importeProv - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - Dim CveConceptoComplementario As Integer = 201 + If CveTipoConcepto = 2 Then ConceptoContable = 305 'cuando es acreedor + If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + + importeMovimiento = importeProv + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + Dim CveConceptoComplementario As Integer = 201 If CveTipoConcepto = 2 Then CveConceptoComplementario = 310 If tipoCambioActual = 1 Then @@ -6684,534 +6684,534 @@ Partial Class Compras_Compras End If - Case 59 'Documentos - importeMovimiento = importeCreditos - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(ConceptoContable, CveProveedor) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero - End If - End If - End If - - Case 37 'Deudores - If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then - For Each rw As GridViewRow In GvDeudores.Rows - If rw.FCCheckBox("Chk").Checked Then - importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorDeudores - CveCuenta = CveCuentaProveedorDeudores - - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - Next - Else - For Each rw As GridViewRow In GvDeudores.Rows - If rw.FCCheckBox("Chk").Checked Then - importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorDeudores - CveCuenta = CveCuentaProveedorDeudores - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 254, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - Next - End If - - importeMovimiento = 0 - - Case 41 'Acreedores - importeMovimiento = importeAcreedores - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - IdCtaContable = CtaProveedorAcreedores - CveCuenta = CveCuentaProveedorAcreedores - - Case 42 'Acreedores - importeMovimiento = importeAcreedoresTarjeta - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorAcreedores - CveCuenta = CveCuentaProveedorAcreedores - - Case 18 'NC - Notas de Credito - importeMovimiento = importeNC - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - End If - - If importeMovimiento <> 0 Then - GuardoConcepto18 = True - If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - - 'PROVISION - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Referencia, 234, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then - ErrorPrepoliza = True - Exit Select - End If - Else - ErrorPrepoliza = True - Exit Select - End If - - 'AMORTIZACIÓN EN EL REGISTRO - For Each Gvr As GridViewRow In GvFacturaNC.Rows - If Gvr.FCCheckBox("ChkFacturaNC").Checked Then - Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar-NC", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) - Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal - Dim TipoCambioFactura = Gvr.DataKey("TipoCambio").ToDecimal - Dim importeMNNC = importeMovimientoNC * TipoCambioFactura * Multiplicador - - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, CveCompraAmortizacion:=CveCompra) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, CveCompraAmortizacion:=CveCompra) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - - - importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - Exit For - End If - - ' FLUCTUACION CAMBIARIA - If tipoCambioActual <> TipoCambioFactura Then - importeMovimiento = (importeMovimientoNC * TipoCambioFactura) - (importeMovimientoNC * tipoCambioActual) - - If importeMovimiento > 0 Then - ConceptoContable = 64 - TipoMovimiento = True - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - ElseIf importeMovimiento < 0 Then - ConceptoContable = 65 - TipoMovimiento = False - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - End If - - importeMovimiento = importeMovimiento.Abs.RoundSQL() - importeMN = importeMovimiento - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - End If - - - ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp) - End If - Next - - If ErrorPrepoliza Then - Exit Select - End If - - Else - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - For Each Gvr As GridViewRow In GvFacturaNC.Rows - If Gvr.FCCheckBox("ChkFacturaNC").Checked Then - Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) - Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal - Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador - If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - Else - ErrorPrepoliza = True - End If - ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp) - End If - Next - End If - End If - End If - - importeMovimiento = 0 - - Case 29 'Funcionarios y Empleados - importeMovimiento = importeFE - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(ConceptoContable, CvePersonal) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContPersonal").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContPersonalSIG").ToString.ToEntero - End If - End If - - Case 21 'Anticipo - - If ArrAnticipos.Count > 0 Then - - - Dim CtaIvaxAcreditar As Integer = 0 - Dim CtaIvaAcreditable As Integer = 0 - Dim CveCuentaIvaxAcreditar As Integer = 0 - Dim PorcentajeImpuestoAnticipo = PorcentajeIVA - CtaIvaxAcreditar = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) - CtaIvaAcreditable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) - If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not CtaIvaxAcreditar > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - CtaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero - CveCuentaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero - End If - End If - If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) And Not CtaIvaAcreditable > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero - End If - End If - - '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JMURUAM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA - 'Dim CtaIvaAcreditable As Integer = 0 - 'If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) Then - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero - ' End If - 'End If - - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - - Dim ConceptoContableAnticipo, ConceptoContableAnticipoComplementaria As Integer - Dim CveCompraNC As Integer = CveCompra - - Select Case Ant.TipoMovto - Case "NC", "DEV" - ConceptoContableAnticipo = 60 - ConceptoContableAnticipoComplementaria = 235 - CveCompraNC = Ant.CveCompra 'cuando es NC, se utiliza la clave de compra de la nota de credito - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - Case "Egsc" - ConceptoContableAnticipo = 21 - IdCtaContable = CtaProveedorAnticipos - CveCuenta = CveCuentaProveedorAnticipos - - Case "DD" - ConceptoContableAnticipo = 37 - IdCtaContable = CtaProveedorDeudores - CveCuenta = CveCuentaProveedorDeudores - Case "Ant" - ConceptoContableAnticipo = 265 - ConceptoContableAnticipoComplementaria = 266 - CveCompraNC = Ant.CveCompra - IdCtaContable = CtaProveedorAnticipos - CveCuenta = CveCuentaProveedorAnticipos - End Select - - importeMovimiento = Ant.Importe - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If importeMovimiento <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - - 'AMORTIZACIÓN NC ESPECIAL COMPLEMENTARIA - If ConceptoContableAnticipo.Contiene(60) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - Dim importeMovimientoNC = Ant.Importe - Dim importeMNNC = 0.0D - Dim TipoCambioNC = Ant.TCCompra - - importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - - importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - - ' FLUCTUACION CAMBIARIA - If tipoCambioActual <> TipoCambioNC Then - importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC) - - If importeMovimiento > 0 Then - ConceptoContable = 64 - TipoMovimiento = True - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - ElseIf importeMovimiento < 0 Then - ConceptoContable = 65 - TipoMovimiento = False - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - End If - - importeMovimiento = importeMovimiento.Abs.RoundSQL() - importeMN = importeMovimiento - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - End If - - ElseIf ConceptoContableAnticipo.Contiene(265) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - Dim importeMovimientoNC = Ant.Importe - Dim importeMNNC = 0.0D - Dim TipoCambioNC = Ant.TCCompra - - importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador - IdCtaContable = CtaProveedorAnticiposExtranjera - CveCuenta = CveCuentaProveedorAnticiposExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 265, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorAnticiposComplementaria - CveCuenta = CveCuentaProveedorAnticiposComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - - If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then - importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador - IdCtaContable = CtaProveedorExtranjera ' CtaProveedorAnticiposExtranjera - CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, CveCompraAmortizacion:=CveCompraNC, Contabilizable:=SeContabiliza) Then - IdCtaContable = CtaProveedorExtranjera 'CtaProveedorAnticiposComplementaria - CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - Else - ErrorPrepoliza = True - Exit For - End If - - If Ant.TipoMovto.Contiene("Ant") Then - Dim PorcentajePagoAnt As Decimal = importeMovimientoNC / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) - Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2) - - 'Agregamos el 14 - If ImporteIVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - 'Agregamos el 19 - If ImporteIVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - Dim ImporteIEPS As Decimal = Math.Round(PorcentajePagoAnt * TxtIEPS.Text.ToDecimal, 2) - - 'Agregamos el 25 - If ImporteIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIEPS, Referencia, 25, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - 'Agregamos el 26 - If ImporteIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIEPS, Referencia, 26, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - End If - - - ' FLUCTUACION CAMBIARIA - If tipoCambioActual <> TipoCambioNC Then - importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC) - - If importeMovimiento > 0 Then - ConceptoContable = 64 - TipoMovimiento = True - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - ElseIf importeMovimiento < 0 Then - ConceptoContable = 65 - TipoMovimiento = False - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - End If - - importeMovimiento = importeMovimiento.Abs.RoundSQL() - importeMN = importeMovimiento - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - End If - End If - - Else - - - Dim usacomplementariaAnticipo As Boolean = False - usacomplementariaAnticipo = If(Ant.TCCompra > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) - Dim TipoCambioAnt = Ant.TCCompra - - - Dim ImporteAnt As Decimal = importeMovimiento - Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt - If usacomplementariaAnticipo Then - IdCtaContable = CtaProveedorAnticiposComplementaria - CveCuenta = CveCuentaProveedorAnticiposComplementaria - ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - ImporteAntMN = ImporteAnt - End If - - If TipoCambioAnt > 1 Then - IdCtaContable = CtaProveedorAnticiposExtranjera - CveCuenta = CveCuentaProveedorAnticiposExtranjera - End If - - 'Agregamos el 21/37/60 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, ConceptoContableAnticipo, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteAntMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteAnt), TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then - Dim IdCtaContablePago As Integer = CtaProveedor - Dim CveCuentaPago As Integer = CveCuentaProveedor - Dim usacomplementariaProveedor As Boolean = False - usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) - If usacomplementariaProveedor Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - importeMN = tipoCambioActual * importeMovimiento - importeMovimiento - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 201, Concepto, FechaMovimiento, CtaProveedorComplementaria, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaProveedorComplementaria, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - importeMN = importeMovimiento - End If - - If tipoCambioActual > 1 Then - IdCtaContablePago = CtaProveedorExtranjera - CveCuentaPago = CveCuentaProveedorExtranjera - End If - - 'Agregamos el 17 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 17, Concepto, FechaMovimiento, IdCtaContablePago, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaPago, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - - End If - ' FLUCTUACION CAMBIARIA - If tipoCambioActual <> TipoCambioAnt Then - Dim importeFluctuacion = (ImporteAnt * tipoCambioActual) - (ImporteAnt * TipoCambioAnt) - - If importeFluctuacion > 0 Then - ConceptoContable = 64 - TipoMovimiento = True - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - ElseIf importeFluctuacion < 0 Then - ConceptoContable = 65 - TipoMovimiento = False - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - End If - - importeFluctuacion = importeFluctuacion.Abs.RoundSQL() - If importeFluctuacion <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeFluctuacion, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - End If - End If - - - End If - - - - '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA - '[IPP] NC NO DEBE REGISTRAR IMPUESTOS EN AMORTIZACIÓN 27/Agosto/2018 - If Not Ant.TipoMovto.Contiene("NC", "DEV") Then - Dim PorcentajePagoAnt As Decimal = importeMovimiento / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) - Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2) - - + Case 59 'Documentos + importeMovimiento = importeCreditos + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(ConceptoContable, CveProveedor) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero + End If + End If + End If + + Case 37 'Deudores + If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then + For Each rw As GridViewRow In GvDeudores.Rows + If rw.FCCheckBox("Chk").Checked Then + importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorDeudores + CveCuenta = CveCuentaProveedorDeudores + + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next + Else + For Each rw As GridViewRow In GvDeudores.Rows + If rw.FCCheckBox("Chk").Checked Then + importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorDeudores + CveCuenta = CveCuentaProveedorDeudores + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 254, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next + End If + + importeMovimiento = 0 + + Case 41 'Acreedores + importeMovimiento = importeAcreedores + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + IdCtaContable = CtaProveedorAcreedores + CveCuenta = CveCuentaProveedorAcreedores + + Case 42 'Acreedores + importeMovimiento = importeAcreedoresTarjeta + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorAcreedores + CveCuenta = CveCuentaProveedorAcreedores + + Case 18 'NC - Notas de Credito + importeMovimiento = importeNC + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + End If + + If importeMovimiento <> 0 Then + GuardoConcepto18 = True + If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + + 'PROVISION + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Referencia, 234, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + Exit Select + End If + Else + ErrorPrepoliza = True + Exit Select + End If + + 'AMORTIZACIÓN EN EL REGISTRO + For Each Gvr As GridViewRow In GvFacturaNC.Rows + If Gvr.FCCheckBox("ChkFacturaNC").Checked Then + Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar-NC", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) + Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal + Dim TipoCambioFactura = Gvr.DataKey("TipoCambio").ToDecimal + Dim importeMNNC = importeMovimientoNC * TipoCambioFactura * Multiplicador + + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, CveCompraAmortizacion:=CveCompra) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, CveCompraAmortizacion:=CveCompra) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + + + importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + Exit For + End If + + ' FLUCTUACION CAMBIARIA + If tipoCambioActual <> TipoCambioFactura Then + importeMovimiento = (importeMovimientoNC * TipoCambioFactura) - (importeMovimientoNC * tipoCambioActual) + + If importeMovimiento > 0 Then + ConceptoContable = 64 + TipoMovimiento = True + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ElseIf importeMovimiento < 0 Then + ConceptoContable = 65 + TipoMovimiento = False + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + importeMovimiento = importeMovimiento.Abs.RoundSQL() + importeMN = importeMovimiento + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + End If + + + ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp) + End If + Next + + If ErrorPrepoliza Then + Exit Select + End If + + Else + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + For Each Gvr As GridViewRow In GvFacturaNC.Rows + If Gvr.FCCheckBox("ChkFacturaNC").Checked Then + Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa)) + Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal + Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador + If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp) + End If + Next + End If + End If + End If + + importeMovimiento = 0 + + Case 29 'Funcionarios y Empleados + importeMovimiento = importeFE + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(ConceptoContable, CvePersonal) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContPersonal").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContPersonalSIG").ToString.ToEntero + End If + End If + + Case 21 'Anticipo + + If ArrAnticipos.Count > 0 Then + + + Dim CtaIvaxAcreditar As Integer = 0 + Dim CtaIvaAcreditable As Integer = 0 + Dim CveCuentaIvaxAcreditar As Integer = 0 + Dim PorcentajeImpuestoAnticipo = PorcentajeIVA + CtaIvaxAcreditar = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) + CtaIvaAcreditable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not CtaIvaxAcreditar > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + CtaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero + CveCuentaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero + End If + End If + If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) And Not CtaIvaAcreditable > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + End If + End If + + '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JMURUAM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA + 'Dim CtaIvaAcreditable As Integer = 0 + 'If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) Then + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + ' End If + 'End If + + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + + Dim ConceptoContableAnticipo, ConceptoContableAnticipoComplementaria As Integer + Dim CveCompraNC As Integer = CveCompra + + Select Case Ant.TipoMovto + Case "NC", "DEV" + ConceptoContableAnticipo = 60 + ConceptoContableAnticipoComplementaria = 235 + CveCompraNC = Ant.CveCompra 'cuando es NC, se utiliza la clave de compra de la nota de credito + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + Case "Egsc" + ConceptoContableAnticipo = 21 + IdCtaContable = CtaProveedorAnticipos + CveCuenta = CveCuentaProveedorAnticipos + + Case "DD" + ConceptoContableAnticipo = 37 + IdCtaContable = CtaProveedorDeudores + CveCuenta = CveCuentaProveedorDeudores + Case "Ant" + ConceptoContableAnticipo = 265 + ConceptoContableAnticipoComplementaria = 266 + CveCompraNC = Ant.CveCompra + IdCtaContable = CtaProveedorAnticipos + CveCuenta = CveCuentaProveedorAnticipos + End Select + + importeMovimiento = Ant.Importe + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If importeMovimiento <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + + 'AMORTIZACIÓN NC ESPECIAL COMPLEMENTARIA + If ConceptoContableAnticipo.Contiene(60) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + Dim importeMovimientoNC = Ant.Importe + Dim importeMNNC = 0.0D + Dim TipoCambioNC = Ant.TCCompra + + importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + + importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + + ' FLUCTUACION CAMBIARIA + If tipoCambioActual <> TipoCambioNC Then + importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC) + + If importeMovimiento > 0 Then + ConceptoContable = 64 + TipoMovimiento = True + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ElseIf importeMovimiento < 0 Then + ConceptoContable = 65 + TipoMovimiento = False + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + importeMovimiento = importeMovimiento.Abs.RoundSQL() + importeMN = importeMovimiento + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + End If + + ElseIf ConceptoContableAnticipo.Contiene(265) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + Dim importeMovimientoNC = Ant.Importe + Dim importeMNNC = 0.0D + Dim TipoCambioNC = Ant.TCCompra + + importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador + IdCtaContable = CtaProveedorAnticiposExtranjera + CveCuenta = CveCuentaProveedorAnticiposExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 265, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorAnticiposComplementaria + CveCuenta = CveCuentaProveedorAnticiposComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + + If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then + importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador + IdCtaContable = CtaProveedorExtranjera ' CtaProveedorAnticiposExtranjera + CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, CveCompraAmortizacion:=CveCompraNC, Contabilizable:=SeContabiliza) Then + IdCtaContable = CtaProveedorExtranjera 'CtaProveedorAnticiposComplementaria + CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + Else + ErrorPrepoliza = True + Exit For + End If + + If Ant.TipoMovto.Contiene("Ant") Then + Dim PorcentajePagoAnt As Decimal = importeMovimientoNC / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) + Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2) + + 'Agregamos el 14 + If ImporteIVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + 'Agregamos el 19 + If ImporteIVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + Dim ImporteIEPS As Decimal = Math.Round(PorcentajePagoAnt * TxtIEPS.Text.ToDecimal, 2) + + 'Agregamos el 25 + If ImporteIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIEPS, Referencia, 25, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + 'Agregamos el 26 + If ImporteIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIEPS, Referencia, 26, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + + + ' FLUCTUACION CAMBIARIA + If tipoCambioActual <> TipoCambioNC Then + importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC) + + If importeMovimiento > 0 Then + ConceptoContable = 64 + TipoMovimiento = True + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ElseIf importeMovimiento < 0 Then + ConceptoContable = 65 + TipoMovimiento = False + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + importeMovimiento = importeMovimiento.Abs.RoundSQL() + importeMN = importeMovimiento + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + End If + End If + + Else + + + Dim usacomplementariaAnticipo As Boolean = False + usacomplementariaAnticipo = If(Ant.TCCompra > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) + Dim TipoCambioAnt = Ant.TCCompra + + + Dim ImporteAnt As Decimal = importeMovimiento + Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt + If usacomplementariaAnticipo Then + IdCtaContable = CtaProveedorAnticiposComplementaria + CveCuenta = CveCuentaProveedorAnticiposComplementaria + ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + ImporteAntMN = ImporteAnt + End If + + If TipoCambioAnt > 1 Then + IdCtaContable = CtaProveedorAnticiposExtranjera + CveCuenta = CveCuentaProveedorAnticiposExtranjera + End If + + 'Agregamos el 21/37/60 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, ConceptoContableAnticipo, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteAntMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteAnt), TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then + Dim IdCtaContablePago As Integer = CtaProveedor + Dim CveCuentaPago As Integer = CveCuentaProveedor + Dim usacomplementariaProveedor As Boolean = False + usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) + If usacomplementariaProveedor Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + importeMN = tipoCambioActual * importeMovimiento - importeMovimiento + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 201, Concepto, FechaMovimiento, CtaProveedorComplementaria, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaProveedorComplementaria, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + importeMN = importeMovimiento + End If + + If tipoCambioActual > 1 Then + IdCtaContablePago = CtaProveedorExtranjera + CveCuentaPago = CveCuentaProveedorExtranjera + End If + + 'Agregamos el 17 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 17, Concepto, FechaMovimiento, IdCtaContablePago, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaPago, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + + End If + ' FLUCTUACION CAMBIARIA + If tipoCambioActual <> TipoCambioAnt Then + Dim importeFluctuacion = (ImporteAnt * tipoCambioActual) - (ImporteAnt * TipoCambioAnt) + + If importeFluctuacion > 0 Then + ConceptoContable = 64 + TipoMovimiento = True + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ElseIf importeFluctuacion < 0 Then + ConceptoContable = 65 + TipoMovimiento = False + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + importeFluctuacion = importeFluctuacion.Abs.RoundSQL() + If importeFluctuacion <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeFluctuacion, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + End If + + + End If + + + + '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA + '[IPP] NC NO DEBE REGISTRAR IMPUESTOS EN AMORTIZACIÓN 27/Agosto/2018 + If Not Ant.TipoMovto.Contiene("NC", "DEV") Then + Dim PorcentajePagoAnt As Decimal = importeMovimiento / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) + Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2) + + If ImporteIVA <> 0 Then 'Agregamos el 14 If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then @@ -7224,30 +7224,30 @@ Partial Class Compras_Compras End If End If - End If - - - End If - - ''Unificacion de PrePolizas - 'If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then - ' If Not ObjConta.PrePolizaUnificacion(Ant.CvePrePoliza, CvePrePoliza) Then - ' ErrorPrepoliza = True - ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) - ' End If - 'End If - - ''Simplificacion de PrePolizas - 'If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then - ' If Not ObjConta.PrePolizaSimplificacion(Ant.CvePrePoliza, UsuarioActual.CveEmpresa) Then - ' ErrorPrepoliza = True - ' Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) - ' End If - 'End If - - Next - importeMovimiento = 0 - + End If + + + End If + + ''Unificacion de PrePolizas + 'If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then + ' If Not ObjConta.PrePolizaUnificacion(Ant.CvePrePoliza, CvePrePoliza) Then + ' ErrorPrepoliza = True + ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) + ' End If + 'End If + + ''Simplificacion de PrePolizas + 'If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then + ' If Not ObjConta.PrePolizaSimplificacion(Ant.CvePrePoliza, UsuarioActual.CveEmpresa) Then + ' ErrorPrepoliza = True + ' Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) + ' End If + 'End If + + Next + importeMovimiento = 0 + End If @@ -7261,719 +7261,719 @@ Partial Class Compras_Compras ' End If - End Select - - If ErrorPrepoliza Then - Exit For - End If - - If importeMovimiento <> 0 Or (ConceptoContable.Contiene(5) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac", "Ant")) Or (ConceptoContable.Contiene(18) AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not GuardoConcepto18) Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'COnta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Exit For - End If - - End If - - Next - - 'EMPIEZA REFACTURACION - If CveCompraRefacturacion > 0 Then - ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza) - If ErrorBitacora Then - Alert("Ocurrió un error al hacer la Refacturación", TipoMensaje.MsgError) - End If - End If - - 'Simplificacion de PrePolizas - If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then - If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then - ErrorPrepolizaDescuadre = True - End If - End If - - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Compras/Compras-Guardar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - ErrorPrepolizaDescuadre = True - End If - End If - - 'Conta ContPAQ - If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then - If idCuentaContabilizacion > 0 Then - If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then - ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) - IdPoliza = ObjConta.ContaIdPoliza - Else - ErrorPrepoliza = True - Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) - End If - Else - Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas:
{0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia) - ErrorPrepoliza = True - End If - End If - End If - - - - - '' A N T I C I P O S - If UsuarioActual.Empresa.UsaAC Then - If ArrAnticipos.Count > 0 Then - - Dim PorcentajePago As Decimal - Dim ConceptoRenglon As String - - - 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar - If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then - PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal - ConceptoRenglon = String.Format("GE Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - ErrorACMEnsaje.Append(" - si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar ObjContaAC.AddMovimiento") - ErrorAC = True - End If - End If - - 'una vez amortizado, se generan los movimientos presupuestales - If ImporteAnticipo > 0 Then - PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal - If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then - 'DtAC.Merge(ObjConta.DtResultados) - For Each dr As DataRow In ObjCompras.DtResultados.Rows - Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago - If Total > 0 Then - - 'EJERCIDO - If True Then - ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) - If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - TieneError = True - Exit For - End If - Else - TieneError = True - Exit For - End If - End If - - 'PAGADO - ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) - If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - TieneError = True - Exit For - End If - Else - TieneError = True - Exit For - End If - - End If - Next - - Else - ErrorACMEnsaje.Append(" - error al obtener presupuestos ObjCompras.GetPresupuestosCompras") - ErrorAC = True - End If - - End If - End If - End If - - - '' F U N C I O N A R I O S Y E M P L E A D O S - If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then - TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text - TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text - - End If - - Else 'Empresa Prueba - - If RBLPago.SelectedValue.ToEntero = 2 AndAlso (RBLContado.SelectedValue = "1" Or RBLContado.SelectedValue = "6") Then 'Contado - Bancos y Caja Chica - 'se agrego un movimiento de pago - ' CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFecha.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, 1, 0.0, TxtDocumentoObservaciones.Text.Trim, True, True, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveIE > 0 Then - - 'inserto los movimientos de la conta para abonar al saldo - - 'Se agregamovimiento de pago de proveedor - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteCompra, " ", CveConceptoAfectacionContado, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then - ErrorMovtosCxP = True - End If - - 'Compra - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtSubTotal2.Text.ToDecimal, " ", 30, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then - ErrorMovtosCxP = True - End If - - 'IVA por Acreditar . siempre se registra aunque sea cero - If Not ErrorMovtosCxP Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then - ErrorMovtosCxP = True - End If - End If - - If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then - 'Agrego el RetIVA - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then - ErrorMovtosCxP = True - End If - End If - - If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then - 'Agrego el RetIVA - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva) Then - ErrorMovtosCxP = True - End If - End If - - - Else - ErrorMovtosIE = True - End If - - End If - - - 'movimiento de compra - '[IPP] PARCHE PROVISIONAL DE CLASIFICACION Y SUBPROYECTO [CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero] [CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero] - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, TxtSubTotal2.Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero, CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtSubTotal2.Text.ToDecimal) Then - ErrorMovtosCxP = True - End If - - 'Se agregan las CxP - If CveConceptoAfectacion = 37 Then - For Each rw As GridViewRow In GvDeudores.Rows - If rw.FCCheckBox("Chk").Checked Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal) Then - ErrorMovtosCxP = True - End If - End If - Next - Else - If ImporteCompra > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, ImporteCompra, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteCompra) Then - ErrorMovtosCxP = True - End If - End If - - - If CvePlantillaPrePoliza = 1 Or CvePlantillaPrePoliza = 60 Then - - 'Siempre: Se agrega IVA aunque sea cero - ' If TxtIVA.Text.Replace(", ", "").Trim.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoImpuestos, TxtIVA.Text.ToDecimal, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal) Then - ErrorMovtosIVA = True - End If - 'End If - - 'Se agregan las Ret IVA - If TxtRetIVA.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetIVA.Text.ToDecimal, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal) Then - ErrorMovtosRetIVA = True - End If - End If - - 'Se agregan las Ret ISR - If TxtRetISR.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetISR.Text.ToDecimal, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal) Then - ErrorMovtosRetISR = True - End If - End If - - If TxtIEPS.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtIEPS.Text.ToDecimal, " ", CveConceptoRetIEPS, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIEPS.Text.ToDecimal) Then - ErrorMovtosRetISR = True - End If - End If - - If TxtOtrosImpuestos.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtOtrosImpuestos.Text.ToDecimal, " ", CveConceptoRetOtrosImpuestos, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtOtrosImpuestos.Text.ToDecimal) Then - ErrorMovtosRetISR = True - End If - End If - - End If - - - '' A N T I C I P O S - If ArrAnticipos.Count > 0 Then - - Dim TotalIVA As Double = TxtIVA.Text.ToDouble - - 'Inserto otra poliza del mo - 'Dim CvePrePolizaAnticipo As Integer = ObjConta.AddPrePolizas("Banc", 10, ImporteAnticipo, ImporteAnticipo, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - ' CveConceptoAfectacion = 21 'Cancelacion Anticipo Proveedores - Dim PorcentajePago As Decimal - Dim CveConceptoAnt As Integer = 21 - Dim CveCompraNC As Integer - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - CveCompraNC = CveCompra - Dim CveConceptoPago As Integer = 17 - Select Case Ant.TipoMovto - Case "NC", "DEV" - CveConceptoAnt = 60 - CveCompraNC = Ant.CveCompra ' cuando es NC, se utiliza la clave de compra de la nota de credito - CveConceptoPago = 272 - Case "Egsc" - CveConceptoAnt = 21 - Case "DD" - CveConceptoAnt = 37 - - End Select - + End Select + + If ErrorPrepoliza Then + Exit For + End If + + If importeMovimiento <> 0 Or (ConceptoContable.Contiene(5) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac", "Ant")) Or (ConceptoContable.Contiene(18) AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not GuardoConcepto18) Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'COnta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + + End If + + Next + + 'EMPIEZA REFACTURACION + If CveCompraRefacturacion > 0 Then + ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza) + If ErrorBitacora Then + Alert("Ocurrió un error al hacer la Refacturación", TipoMensaje.MsgError) + End If + End If + + 'Simplificacion de PrePolizas + If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then + If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then + ErrorPrepolizaDescuadre = True + End If + End If + + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Compras/Compras-Guardar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + ErrorPrepolizaDescuadre = True + End If + End If + + 'Conta ContPAQ + If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then + If idCuentaContabilizacion > 0 Then + If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then + ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) + IdPoliza = ObjConta.ContaIdPoliza + Else + ErrorPrepoliza = True + Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) + End If + Else + Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas:
{0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia) + ErrorPrepoliza = True + End If + End If + End If + + + + + '' A N T I C I P O S + If UsuarioActual.Empresa.UsaAC Then + If ArrAnticipos.Count > 0 Then + + Dim PorcentajePago As Decimal + Dim ConceptoRenglon As String + + + 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar + If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then + PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal + ConceptoRenglon = String.Format("GE Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + ErrorACMEnsaje.Append(" - si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar ObjContaAC.AddMovimiento") + ErrorAC = True + End If + End If + + 'una vez amortizado, se generan los movimientos presupuestales + If ImporteAnticipo > 0 Then + PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal + If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then + 'DtAC.Merge(ObjConta.DtResultados) + For Each dr As DataRow In ObjCompras.DtResultados.Rows + Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago + If Total > 0 Then + + 'EJERCIDO + If True Then + ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) + If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + TieneError = True + Exit For + End If + Else + TieneError = True + Exit For + End If + End If + + 'PAGADO + ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) + If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + TieneError = True + Exit For + End If + Else + TieneError = True + Exit For + End If + + End If + Next + + Else + ErrorACMEnsaje.Append(" - error al obtener presupuestos ObjCompras.GetPresupuestosCompras") + ErrorAC = True + End If + + End If + End If + End If + + + '' F U N C I O N A R I O S Y E M P L E A D O S + If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text + TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text + + End If + + Else 'Empresa Prueba + + If RBLPago.SelectedValue.ToEntero = 2 AndAlso (RBLContado.SelectedValue = "1" Or RBLContado.SelectedValue = "6") Then 'Contado - Bancos y Caja Chica + 'se agrego un movimiento de pago + ' CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFecha.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, 1, 0.0, TxtDocumentoObservaciones.Text.Trim, True, True, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveIE > 0 Then + + 'inserto los movimientos de la conta para abonar al saldo + + 'Se agregamovimiento de pago de proveedor + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteCompra, " ", CveConceptoAfectacionContado, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then + ErrorMovtosCxP = True + End If + + 'Compra + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtSubTotal2.Text.ToDecimal, " ", 30, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then + ErrorMovtosCxP = True + End If + + 'IVA por Acreditar . siempre se registra aunque sea cero + If Not ErrorMovtosCxP Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then + ErrorMovtosCxP = True + End If + End If + + If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then + 'Agrego el RetIVA + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then + ErrorMovtosCxP = True + End If + End If + + If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then + 'Agrego el RetIVA + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva) Then + ErrorMovtosCxP = True + End If + End If + + + Else + ErrorMovtosIE = True + End If + + End If + + + 'movimiento de compra + '[IPP] PARCHE PROVISIONAL DE CLASIFICACION Y SUBPROYECTO [CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero] [CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero] + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, TxtSubTotal2.Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero, CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtSubTotal2.Text.ToDecimal) Then + ErrorMovtosCxP = True + End If + + 'Se agregan las CxP + If CveConceptoAfectacion = 37 Then + For Each rw As GridViewRow In GvDeudores.Rows + If rw.FCCheckBox("Chk").Checked Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal) Then + ErrorMovtosCxP = True + End If + End If + Next + Else + If ImporteCompra > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, ImporteCompra, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteCompra) Then + ErrorMovtosCxP = True + End If + End If + + + If CvePlantillaPrePoliza = 1 Or CvePlantillaPrePoliza = 60 Then + + 'Siempre: Se agrega IVA aunque sea cero + ' If TxtIVA.Text.Replace(", ", "").Trim.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoImpuestos, TxtIVA.Text.ToDecimal, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal) Then + ErrorMovtosIVA = True + End If + 'End If + + 'Se agregan las Ret IVA + If TxtRetIVA.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetIVA.Text.ToDecimal, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal) Then + ErrorMovtosRetIVA = True + End If + End If + + 'Se agregan las Ret ISR + If TxtRetISR.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetISR.Text.ToDecimal, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal) Then + ErrorMovtosRetISR = True + End If + End If + + If TxtIEPS.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtIEPS.Text.ToDecimal, " ", CveConceptoRetIEPS, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIEPS.Text.ToDecimal) Then + ErrorMovtosRetISR = True + End If + End If + + If TxtOtrosImpuestos.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtOtrosImpuestos.Text.ToDecimal, " ", CveConceptoRetOtrosImpuestos, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtOtrosImpuestos.Text.ToDecimal) Then + ErrorMovtosRetISR = True + End If + End If + + End If + + + '' A N T I C I P O S + If ArrAnticipos.Count > 0 Then + + Dim TotalIVA As Double = TxtIVA.Text.ToDouble + + 'Inserto otra poliza del mo + 'Dim CvePrePolizaAnticipo As Integer = ObjConta.AddPrePolizas("Banc", 10, ImporteAnticipo, ImporteAnticipo, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + ' CveConceptoAfectacion = 21 'Cancelacion Anticipo Proveedores + Dim PorcentajePago As Decimal + Dim CveConceptoAnt As Integer = 21 + Dim CveCompraNC As Integer + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + CveCompraNC = CveCompra + Dim CveConceptoPago As Integer = 17 + Select Case Ant.TipoMovto + Case "NC", "DEV" + CveConceptoAnt = 60 + CveCompraNC = Ant.CveCompra ' cuando es NC, se utiliza la clave de compra de la nota de credito + CveConceptoPago = 272 + Case "Egsc" + CveConceptoAnt = 21 + Case "DD" + CveConceptoAnt = 37 + + End Select + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Ant.Importe, " ", CveConceptoAnt, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then ' ImporteAnticipo += Ant.Importe ' RESTO DEL IMPORTE POR SI QUEDA DIFERENCIA DE LA SUMA DE LOS ANTICIPOS Y EL PROVEEDOR TIENE QUE PAGAR 'movimiento de pago proveedor, --no se regisra porque no se registra el total de la compra como deuda del proveedor, solo lo que queda a deber 'si es l moviemiento es de amortizacion con descuento, no registra el pago, ya esta descontado - If TieneAnticiposXML = False AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then - ErrorMovtosCxP = True - End If - PorcentajePago = (Ant.Importe) / TxtTotal.Text.ToDecimal - - 'IVA por Acreditar . siempre se registra aunque sea cero - If Not ErrorMovtosCxP Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - End If - - 'Agrego el RetIVA - If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - End If - - 'Agrego el RetISR - If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - End If - Else - ErrorMovtosCxP = True - End If - Next - - Dim ConceptoRenglon As String - - - 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar - If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then - PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal - 'Siempre: Se agrega IVA aunque sea cero - If TxtIVA.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosIVA = True - End If - End If - - 'Se agregan las Ret IVA - If TxtRetIVA.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosRetIVA = True - End If - End If - - 'Se agregan las Ret ISR - If TxtRetISR.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosRetISR = True - End If - End If - - If UsuarioActual.Empresa.UsaAC Then - If CtaProveedor > 0 Then - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - ErrorAC = True - ErrorACMEnsaje.Append("- CtaProveedor > 0 ObjContaAC.AddMovimiento") - End If - Else - Alert(" - El proveedor no tiene cuenta contable.", TipoMensaje.MsgAdvertencia) - - ErrorAC = True - End If - End If - End If - - 'una vez amortizado, se generan los movimientos presupuestales - - If UsuarioActual.Empresa.UsaAC AndAlso ImporteAnticipo > 0 Then - - - PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal - - If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then - 'DtAC.Merge(ObjConta.DtResultados) - - For Each dr As DataRow In ObjCompras.DtResultados.Rows - Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago - - If Total > 0 Then - - 'EJERCIDO - If True Then - - ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) - If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - TieneError = True - Exit For - End If - - Else - TieneError = True - Exit For - End If - End If - - 'PAGADO - ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) - If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then - TieneError = True - Exit For - End If - Else - TieneError = True - Exit For - End If - - End If - Next - - Else - ErrorACMEnsaje.Append("- error al obtener presupuestos 2") - ErrorAC = True - End If - End If - - End If - - - '' F U N C I O N A R I O S Y E M P L E A D O S - If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then - 'Si es con funcionarios empleados Ya existe un registro en Bancos de Ingresos Egresos - TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text - TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text - - Dim ImportePagadoFE As Decimal = 0 - Dim ImporteAPagarFE As Decimal = TxtDocumentoImporteFE.Text.ToDecimal - Dim ImportePagar As Decimal = ImporteAPagarFE - - 'CvePrePoliza = ObjConta.AddPrePolizas("Banc", 2, ImporteAPagarFE, ImporteAPagarFE, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePoliza > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePagar, " ", 29, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then - ErrorMovtosCxP = True - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePagar, " ", 17, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then - ErrorMovtosCxP = True - End If - - - Dim PorcentajePago As Decimal = (ImportePagar) / TxtTotal.Text.ToDecimal - - 'IVA por Acreditar . siempre se registra aunque sea cero - If Not ErrorMovtosCxP Then - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - - End If - - If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then - 'Agrego el RetIVA - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - - End If - - If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then - 'Agrego el RetISR - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True - - End If - - - 'sino alcanzo a cubrir se regitran los ivas por acreditar - If TxtTotal.Text.ToDouble - ImportePagar > 0 Then - PorcentajePago = (TxtTotal.Text.ToDecimal - ImportePagar) / TxtTotal.Text.ToDecimal - 'Movimiento, se omite, porque se esta registrando la totalidad de la deuda - 'If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtTotal.Text.ToDouble - ImporteAnticipo, " ", 5, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then - ' ErrorMovtosCxP = True - 'End If - 'Siempre: Se agrega IVA aunque sea cero - If TxtIVA.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosIVA = True - End If - End If - - 'Se agregan las Ret IVA - If TxtRetIVA.Text.ToDouble <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosRetIVA = True - End If - End If - - 'Se agregan las Ret ISR - If TxtRetISR.Text.ToDouble > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then - ErrorMovtosRetISR = True - End If - End If - - End If - - Else - ErrorMovtosCxP = True - End If - - - End If - - End If 'Empresa Prueba - - '************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************ - - 'End If - Else - ErrorMovtosCxP = True - End If - - - End If - - If HdnVCveOC.Value <> "-1" AndAlso HdnCveEstatusOC.Value <> "-1" Then - Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) - Dim ArrayCveEstatusOC As String() = HdnCveEstatusOC.Value.Split(New Char() {","c}) - - If ArrayCveEstatusOC.Count = ArrayCveOC.Count Then - For i = 0 To ArrayCveEstatusOC.Count - 1 - If Not ObjOC.UpdateOrdenCompraCompletada(ArrayCveEstatusOC(i).ToEntero, ArrayCveOC(i).ToEntero, UsuarioActual.CveUsuario, "Se vinculó Compra", CveCompra) Then - ErrorOC = True - Exit For - End If - Next - Else - ErrorOC = True - End If - - End If - - If ChkNCInvNC.Checked Then - For Each Gvr As GridViewRow In GVNCInv.Rows - If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then - If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True - Exit For - End If - End If - Next - End If - - - 'GUARDA BITACORA TIPO CAMBIO OC - If Not ErrorOC And TipoCambioOC > 0 Then - If Not ObjEventos.AddEventoBitacora(String.Format("La vinculación con la orden de compra fue con un tipo de cambio de: ${0}", TipoCambioOC.ToString), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - ErrorOC = True - End If - End If - - - If tDTAcarreos.Rows.Count > 0 Then - If TotAcarreos = TxtSubTotal.Text.ToDouble Then - 'ACARREOS - For Each tDTAcar As DataRow In tDTAcarreos.Rows - If Not ObjAcar.UpdatePreEstimacion(CInt(tDTAcar("CvePreEstimacion")), CveCompra) Then - ErrorAddAcarreos = True - Exit For - End If - Next - Else - ErrorAddAcarreos = True - End If - End If - - 'AGREGAR OTROS GASTOS A ORDEN DE CORTE - If CveOrdenCorte > 0 And UsuarioActual.CveEmpresa = 126 Then - If ObjCGame.AddCorteGasto(CveOrdenCorte, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Now, 0, CveCompra) Then - If Not ObjCGame.AddCorteGastoDetalle(ObjCGame.CveCorteGasto, 32, 1, TxtSubTotal.Text.ToDouble()) Then - ErrorOtrosGastos = True - End If - Else - ErrorOtrosGastos = True - End If - End If - - 'CREDITO COMPRA - Dim CvePrePolizaCredito = 0 - If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue.ToEntero = 3 AndAlso DdlTipoCredito.SelectedValue.ToEntero = 1 AndAlso DdlCredito.SelectedValue.ToEntero > 0 Then - - If Not ObjIE.UpdateCreditosCompra(DdlCredito.SelectedValue.ToEntero, CveCompra, UsuarioActual.CveEmpresa) Then - ErrorCreditosCompra = True - End If - - If Not ErrorCreditosCompra Then - - If ObjIE.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then - CvePrePolizaCredito = ObjConta.AddPrePolizas("Compras/RegistrarCredito", -1, ObjIE.TotalFinanciado, ObjIE.TotalFinanciado, 1, TxtFecha.Text.ToDate, "Vinculación crédito con factura", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, False, ObjIE.TotalFinanciado.ToDecimal, "", 17, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, True, ObjIE.TotalFinanciado.ToDecimal, "", 50, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then - ErrorCreditosCompra = True - End If - Else - ErrorCreditosCompra = True - End If - - If Not ErrorCreditosCompra Then - ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCredito) - End If - - End If - End If - - End If - - - - - 'VALIDAR ERRORES - If ErrorAC OrElse ErrorPrepoliza OrElse ErrorPrepolizaDescuadre OrElse ErrorDetalles OrElse ErrorMovDev OrElse ErrorMovtosCxP OrElse ErrorMovtosRetIVA OrElse ErrorMovtosRetISR OrElse ErrorMovtosEstimaciones OrElse ErrorMovtosIE OrElse ErrorMovtosIVA OrElse ErrorMovInv OrElse TieneError OrElse ErrorAF OrElse ErrorOC OrElse ErrorBitacora OrElse ErrorAddAcarreos OrElse ErrorCreditosCompra Then - If ErrorDetalles Then - Alert("Ocurrió un Error al agregar un Producto o Servicio a la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosCxP Then - Alert("Ocurrió un Error al agregar las CxP.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosRetIVA Then - Alert("Ocurrió un Error al agregar las Retenciones de IVA.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosRetISR Then - Alert("Ocurrió un Error al agregar las Retenciones de ISR.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosEstimaciones Then - Alert("Ocurrió un Error al agregar las Estimaciones.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosIE Then - Alert("Ocurrió un Error al agregar el movimiento bancario.
Revise sus datos y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovtosIVA Then - Alert("Ocurrió un Error al agregar el IVA.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf ErrorMovInv Then - Alert("Ocurrió un Error al agregar el Producto o Servicio al Inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ElseIf TieneError Then - Alert("El total de los IMPORTES del FINANCIAMIENTO debe ser mayor que 0 y menor o igual al total de la compra", TipoMensaje.MsgAdvertencia) - ElseIf ErrorAF Then - Alert("Error al actualizar la vinculacion del Activo Fijo", TipoMensaje.MsgAdvertencia) - ElseIf ErrorAC Then - Alert("Ocurrió un Error al insertar los movimientos contables.", TipoMensaje.MsgError) - GuardaLog($" Error Compras DESCRIPCIÓN DETALLADA: {ErrorACMEnsaje.ToString} {vbCrLf} Usuario={UsuarioActual.CveUsuario}, Empresa={UsuarioActual.CveEmpresa}, CveFactura={CveFactura}, CveProveedor={CveProveedor}") - ElseIf ErrorPrepolizaDescuadre Then - Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError) - ElseIf ErrorPrepoliza Then - Alert("Ocurrió un error al verificar los movimientos contables", TipoMensaje.MsgError) - ElseIf ErrorOC Then - Alert("Ocurrió un Error al vincular la Orden(es) de Compra. Por favor vuelva intentar.", TipoMensaje.MsgError) - ElseIf ErrorBitacora Then - Alert("Ocurrió un Error al guardar la refacturación.", TipoMensaje.MsgError) - ElseIf ErrorAddAcarreos Then - Alert("Ocurrio un Error al momento de agregar los acarreos.", TipoMensaje.MsgError) - ElseIf ErrorCreditosCompra Then - Alert("Ocurrió un Error al vincular la compra con el crédito.", TipoMensaje.MsgError) - ElseIf ErrorOtrosGastos Then - Alert("Ocurrió un Error al vincular la compra con la orden de corte.", TipoMensaje.MsgError) - ElseIf ErrorSATPS Then - Alert("Ocurrió un Error al actualizar el producto/servicio SAT.", TipoMensaje.MsgError) - ElseIf ErrorSaldosInvComp Then - Alert("Ocurrió un error al validar la mercancía recibida por adelantado.", TipoMensaje.MsgError) - End If - - ViewState("CveCompra") = -1 - ObjCompras.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - CargaProveedor(CveProveedor, "-1") - Else - Dim MsgAccionAceptar As String = "" - Dim Msg As New StringBuilder - Msg.Append("La compra se registró correctamente") - - - 'ACTUALIZA CVEFACTURA - If Request("CveFactura") IsNot Nothing Then - + If TieneAnticiposXML = False AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then + ErrorMovtosCxP = True + End If + PorcentajePago = (Ant.Importe) / TxtTotal.Text.ToDecimal + + 'IVA por Acreditar . siempre se registra aunque sea cero + If Not ErrorMovtosCxP Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + End If + + 'Agrego el RetIVA + If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + End If + + 'Agrego el RetISR + If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + End If + Else + ErrorMovtosCxP = True + End If + Next + + Dim ConceptoRenglon As String + + + 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar + If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then + PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal + 'Siempre: Se agrega IVA aunque sea cero + If TxtIVA.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosIVA = True + End If + End If + + 'Se agregan las Ret IVA + If TxtRetIVA.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosRetIVA = True + End If + End If + + 'Se agregan las Ret ISR + If TxtRetISR.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosRetISR = True + End If + End If + + If UsuarioActual.Empresa.UsaAC Then + If CtaProveedor > 0 Then + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + ErrorAC = True + ErrorACMEnsaje.Append("- CtaProveedor > 0 ObjContaAC.AddMovimiento") + End If + Else + Alert(" - El proveedor no tiene cuenta contable.", TipoMensaje.MsgAdvertencia) + + ErrorAC = True + End If + End If + End If + + 'una vez amortizado, se generan los movimientos presupuestales + + If UsuarioActual.Empresa.UsaAC AndAlso ImporteAnticipo > 0 Then + + + PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal + + If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then + 'DtAC.Merge(ObjConta.DtResultados) + + For Each dr As DataRow In ObjCompras.DtResultados.Rows + Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago + + If Total > 0 Then + + 'EJERCIDO + If True Then + + ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) + If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + TieneError = True + Exit For + End If + + Else + TieneError = True + Exit For + End If + End If + + 'PAGADO + ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text) + If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then + TieneError = True + Exit For + End If + Else + TieneError = True + Exit For + End If + + End If + Next + + Else + ErrorACMEnsaje.Append("- error al obtener presupuestos 2") + ErrorAC = True + End If + End If + + End If + + + '' F U N C I O N A R I O S Y E M P L E A D O S + If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + 'Si es con funcionarios empleados Ya existe un registro en Bancos de Ingresos Egresos + TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text + TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text + + Dim ImportePagadoFE As Decimal = 0 + Dim ImporteAPagarFE As Decimal = TxtDocumentoImporteFE.Text.ToDecimal + Dim ImportePagar As Decimal = ImporteAPagarFE + + 'CvePrePoliza = ObjConta.AddPrePolizas("Banc", 2, ImporteAPagarFE, ImporteAPagarFE, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePoliza > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePagar, " ", 29, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then + ErrorMovtosCxP = True + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePagar, " ", 17, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then + ErrorMovtosCxP = True + End If + + + Dim PorcentajePago As Decimal = (ImportePagar) / TxtTotal.Text.ToDecimal + + 'IVA por Acreditar . siempre se registra aunque sea cero + If Not ErrorMovtosCxP Then + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + + End If + + If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then + 'Agrego el RetIVA + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + + End If + + If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then + 'Agrego el RetISR + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True + + End If + + + 'sino alcanzo a cubrir se regitran los ivas por acreditar + If TxtTotal.Text.ToDouble - ImportePagar > 0 Then + PorcentajePago = (TxtTotal.Text.ToDecimal - ImportePagar) / TxtTotal.Text.ToDecimal + 'Movimiento, se omite, porque se esta registrando la totalidad de la deuda + 'If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtTotal.Text.ToDouble - ImporteAnticipo, " ", 5, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then + ' ErrorMovtosCxP = True + 'End If + 'Siempre: Se agrega IVA aunque sea cero + If TxtIVA.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosIVA = True + End If + End If + + 'Se agregan las Ret IVA + If TxtRetIVA.Text.ToDouble <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosRetIVA = True + End If + End If + + 'Se agregan las Ret ISR + If TxtRetISR.Text.ToDouble > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then + ErrorMovtosRetISR = True + End If + End If + + End If + + Else + ErrorMovtosCxP = True + End If + + + End If + + End If 'Empresa Prueba + + '************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************ + + 'End If + Else + ErrorMovtosCxP = True + End If + + + End If + + If HdnVCveOC.Value <> "-1" AndAlso HdnCveEstatusOC.Value <> "-1" Then + Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) + Dim ArrayCveEstatusOC As String() = HdnCveEstatusOC.Value.Split(New Char() {","c}) + + If ArrayCveEstatusOC.Count = ArrayCveOC.Count Then + For i = 0 To ArrayCveEstatusOC.Count - 1 + If Not ObjOC.UpdateOrdenCompraCompletada(ArrayCveEstatusOC(i).ToEntero, ArrayCveOC(i).ToEntero, UsuarioActual.CveUsuario, "Se vinculó Compra", CveCompra) Then + ErrorOC = True + Exit For + End If + Next + Else + ErrorOC = True + End If + + End If + + If ChkNCInvNC.Checked Then + For Each Gvr As GridViewRow In GVNCInv.Rows + If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then + If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then + ErrorMovInv = True + Exit For + End If + End If + Next + End If + + + 'GUARDA BITACORA TIPO CAMBIO OC + If Not ErrorOC And TipoCambioOC > 0 Then + If Not ObjEventos.AddEventoBitacora(String.Format("La vinculación con la orden de compra fue con un tipo de cambio de: ${0}", TipoCambioOC.ToString), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + ErrorOC = True + End If + End If + + + If tDTAcarreos.Rows.Count > 0 Then + If TotAcarreos = TxtSubTotal.Text.ToDouble Then + 'ACARREOS + For Each tDTAcar As DataRow In tDTAcarreos.Rows + If Not ObjAcar.UpdatePreEstimacion(CInt(tDTAcar("CvePreEstimacion")), CveCompra) Then + ErrorAddAcarreos = True + Exit For + End If + Next + Else + ErrorAddAcarreos = True + End If + End If + + 'AGREGAR OTROS GASTOS A ORDEN DE CORTE + If CveOrdenCorte > 0 And UsuarioActual.CveEmpresa = 126 Then + If ObjCGame.AddCorteGasto(CveOrdenCorte, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Now, 0, CveCompra) Then + If Not ObjCGame.AddCorteGastoDetalle(ObjCGame.CveCorteGasto, 32, 1, TxtSubTotal.Text.ToDouble()) Then + ErrorOtrosGastos = True + End If + Else + ErrorOtrosGastos = True + End If + End If + + 'CREDITO COMPRA + Dim CvePrePolizaCredito = 0 + If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue.ToEntero = 3 AndAlso DdlTipoCredito.SelectedValue.ToEntero = 1 AndAlso DdlCredito.SelectedValue.ToEntero > 0 Then + + If Not ObjIE.UpdateCreditosCompra(DdlCredito.SelectedValue.ToEntero, CveCompra, UsuarioActual.CveEmpresa) Then + ErrorCreditosCompra = True + End If + + If Not ErrorCreditosCompra Then + + If ObjIE.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then + CvePrePolizaCredito = ObjConta.AddPrePolizas("Compras/RegistrarCredito", -1, ObjIE.TotalFinanciado, ObjIE.TotalFinanciado, 1, TxtFecha.Text.ToDate, "Vinculación crédito con factura", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, False, ObjIE.TotalFinanciado.ToDecimal, "", 17, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, True, ObjIE.TotalFinanciado.ToDecimal, "", 50, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then + ErrorCreditosCompra = True + End If + Else + ErrorCreditosCompra = True + End If + + If Not ErrorCreditosCompra Then + ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCredito) + End If + + End If + End If + + End If + + + + + 'VALIDAR ERRORES + If ErrorAC OrElse ErrorPrepoliza OrElse ErrorPrepolizaDescuadre OrElse ErrorDetalles OrElse ErrorMovDev OrElse ErrorMovtosCxP OrElse ErrorMovtosRetIVA OrElse ErrorMovtosRetISR OrElse ErrorMovtosEstimaciones OrElse ErrorMovtosIE OrElse ErrorMovtosIVA OrElse ErrorMovInv OrElse TieneError OrElse ErrorAF OrElse ErrorOC OrElse ErrorBitacora OrElse ErrorAddAcarreos OrElse ErrorCreditosCompra Then + If ErrorDetalles Then + Alert("Ocurrió un Error al agregar un Producto o Servicio a la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosCxP Then + Alert("Ocurrió un Error al agregar las CxP.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosRetIVA Then + Alert("Ocurrió un Error al agregar las Retenciones de IVA.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosRetISR Then + Alert("Ocurrió un Error al agregar las Retenciones de ISR.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosEstimaciones Then + Alert("Ocurrió un Error al agregar las Estimaciones.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosIE Then + Alert("Ocurrió un Error al agregar el movimiento bancario.
Revise sus datos y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovtosIVA Then + Alert("Ocurrió un Error al agregar el IVA.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf ErrorMovInv Then + Alert("Ocurrió un Error al agregar el Producto o Servicio al Inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ElseIf TieneError Then + Alert("El total de los IMPORTES del FINANCIAMIENTO debe ser mayor que 0 y menor o igual al total de la compra", TipoMensaje.MsgAdvertencia) + ElseIf ErrorAF Then + Alert("Error al actualizar la vinculacion del Activo Fijo", TipoMensaje.MsgAdvertencia) + ElseIf ErrorAC Then + Alert("Ocurrió un Error al insertar los movimientos contables.", TipoMensaje.MsgError) + GuardaLog($" Error Compras DESCRIPCIÓN DETALLADA: {ErrorACMEnsaje.ToString} {vbCrLf} Usuario={UsuarioActual.CveUsuario}, Empresa={UsuarioActual.CveEmpresa}, CveFactura={CveFactura}, CveProveedor={CveProveedor}") + ElseIf ErrorPrepolizaDescuadre Then + Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError) + ElseIf ErrorPrepoliza Then + Alert("Ocurrió un error al verificar los movimientos contables", TipoMensaje.MsgError) + ElseIf ErrorOC Then + Alert("Ocurrió un Error al vincular la Orden(es) de Compra. Por favor vuelva intentar.", TipoMensaje.MsgError) + ElseIf ErrorBitacora Then + Alert("Ocurrió un Error al guardar la refacturación.", TipoMensaje.MsgError) + ElseIf ErrorAddAcarreos Then + Alert("Ocurrio un Error al momento de agregar los acarreos.", TipoMensaje.MsgError) + ElseIf ErrorCreditosCompra Then + Alert("Ocurrió un Error al vincular la compra con el crédito.", TipoMensaje.MsgError) + ElseIf ErrorOtrosGastos Then + Alert("Ocurrió un Error al vincular la compra con la orden de corte.", TipoMensaje.MsgError) + ElseIf ErrorSATPS Then + Alert("Ocurrió un Error al actualizar el producto/servicio SAT.", TipoMensaje.MsgError) + ElseIf ErrorSaldosInvComp Then + Alert("Ocurrió un error al validar la mercancía recibida por adelantado.", TipoMensaje.MsgError) + End If + + ViewState("CveCompra") = -1 + ObjCompras.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + CargaProveedor(CveProveedor, "-1") + Else + Dim MsgAccionAceptar As String = "" + Dim Msg As New StringBuilder + Msg.Append("La compra se registró correctamente") + + + 'ACTUALIZA CVEFACTURA + If Request("CveFactura") IsNot Nothing Then + If Not ObjCompras.UpdateCompraFactura(CveCompra, Request("CveFactura").ToEntero, TxtSerie.Text.Trim, TxtFolio.Text.Trim) Then - TieneError = True - End If - - If UsuarioActual.Empresa.UsaAC Then - MsgAccionAceptar = String.Format("window.opener.location.href = window.opener.location.href; window.open(""/Contabilidad/RegPoliza.aspx?IdPoliza={0}""); window.close();", IdPoliza) - Else - MsgAccionAceptar = "if (window.opener){window.opener.location.href = window.opener.location.href; window.close();}" - End If - Else - MsgAccionAceptar = "location.href =""Compras.aspx""" - End If - - - - 'CUANDO ES REEMBOLSO COMPROBACION Y CAJA CHICA - If UsuarioActual.CveEmpresa.Contiene(1, 119) AndAlso TxtNumeroReembolso.Text.Trim <> "" AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then - If ObjCompras.GetComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, UsuarioActual.CveEmpresa) Then - Dim CvePreComprobacion As Integer - If ObjCompras.DtResultados.Rows.Count = 0 Then - 'sino existe, creamos la comprobacion - Dim tConcepto As String = If(DdlPersonalReembolso.SelectedValue.ToEntero > 0, DdlPersonalReembolso.SelectedItem.Text, DdlCuentaCajaChicaReembolso.SelectedItem.Text) - tConcepto = String.Format("{0}-{1}", tConcepto, TxtNumeroReembolso.Text.Trim) - - CvePreComprobacion = ObjConta.AddPrePolizas("Compras Comproba", 1, 0, 0, 1, TxtFecha.Text.ToDate, tConcepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - If ObjCompras.AddComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, CvePreComprobacion, UsuarioActual.CveEmpresa) > 0 Then - - End If - Else - 'si ya existe, obtenemos la prepóliza - CvePreComprobacion = ObjCompras.DtResultados.FiltroPrimeroValor("CvePrePoliza").ToEntero - End If - - ObjConta.PrePolizaUnificacion(CvePreComprobacion, CvePrePoliza) - End If - - End If - - - - 'AJUSTA POLIZA - If IdPoliza > 0 Then - PolizaFolio = ObjContaAC.Folio - ObjContaAC.AjustaPoliza(IdPoliza) - Msg.AppendFormat("

Ver Póliza", IdPoliza) - End If - - If CveMovimientoInventario > 0 Then - Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoInventario)) - Msg.AppendFormat("
Ver Movimiento de Almacen", CveMovimientoInventario) - Msg.AppendFormat("
Imprimir Entrada Almacen", TempParametros) - End If - + TieneError = True + End If + + If UsuarioActual.Empresa.UsaAC Then + MsgAccionAceptar = String.Format("window.opener.location.href = window.opener.location.href; window.open(""/Contabilidad/RegPoliza.aspx?IdPoliza={0}""); window.close();", IdPoliza) + Else + MsgAccionAceptar = "if (window.opener){window.opener.location.href = window.opener.location.href; window.close();}" + End If + Else + MsgAccionAceptar = "location.href =""Compras.aspx""" + End If + + + + 'CUANDO ES REEMBOLSO COMPROBACION Y CAJA CHICA + If UsuarioActual.CveEmpresa.Contiene(1, 119) AndAlso TxtNumeroReembolso.Text.Trim <> "" AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then + If ObjCompras.GetComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, UsuarioActual.CveEmpresa) Then + Dim CvePreComprobacion As Integer + If ObjCompras.DtResultados.Rows.Count = 0 Then + 'sino existe, creamos la comprobacion + Dim tConcepto As String = If(DdlPersonalReembolso.SelectedValue.ToEntero > 0, DdlPersonalReembolso.SelectedItem.Text, DdlCuentaCajaChicaReembolso.SelectedItem.Text) + tConcepto = String.Format("{0}-{1}", tConcepto, TxtNumeroReembolso.Text.Trim) + + CvePreComprobacion = ObjConta.AddPrePolizas("Compras Comproba", 1, 0, 0, 1, TxtFecha.Text.ToDate, tConcepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If ObjCompras.AddComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, CvePreComprobacion, UsuarioActual.CveEmpresa) > 0 Then + + End If + Else + 'si ya existe, obtenemos la prepóliza + CvePreComprobacion = ObjCompras.DtResultados.FiltroPrimeroValor("CvePrePoliza").ToEntero + End If + + ObjConta.PrePolizaUnificacion(CvePreComprobacion, CvePrePoliza) + End If + + End If + + + + 'AJUSTA POLIZA + If IdPoliza > 0 Then + PolizaFolio = ObjContaAC.Folio + ObjContaAC.AjustaPoliza(IdPoliza) + Msg.AppendFormat("

Ver Póliza", IdPoliza) + End If + + If CveMovimientoInventario > 0 Then + Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoInventario)) + Msg.AppendFormat("
Ver Movimiento de Almacen", CveMovimientoInventario) + Msg.AppendFormat("
Imprimir Entrada Almacen", TempParametros) + End If + If Not ObjCompras.UpdateCompraPrePoliza(TxtFecha.Text.ToDate, PolizaFolio.ToString, IdPoliza, CvePrePoliza, CveCompra, 0) Then TieneError = True End If - If EntregaDirecta Then - Msg.AppendFormat($"
Recibir mercancía de entrega directa.") - End If - + If EntregaDirecta Then + Msg.AppendFormat($"
Recibir mercancía de entrega directa.") + End If + If Not TieneError Then ObjCompras.Commit() If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() @@ -8003,363 +8003,363 @@ Partial Class Compras_Compras ObjCompras.RollBack() If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() Alert("Ocurrio un error al guardar la compra. Por favor intente nuevamente.", TipoMensaje.MsgError) - End If - - Alert(Msg.ToString, TipoMensaje.MsgInformacion, MsgAccionAceptar) - - End If - - Else - ObjCompras.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("Ocurrio un error al guardar la compra. Por favor intente nuevamente.", TipoMensaje.MsgError) - End If - - - Else - Alert("Debe seleccionar un Funcionario/Empleado o Caja Chica para Reembolsos. Por favor vuelva a intentar.", TipoMensaje.MsgError) - ObjCompras.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - End If - - Else - Alert("Ocurrió un error al agregar el movimiento bancario.
Revise sus datos de pago y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ObjCompras.RollBack() - End If - - End If - - Catch ex As Exception - ObjCompras.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("Ocurrió un error al registrar la compra y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgError) - GuardaLog($"Ocurrió un error al registrar la compra y cualquier detalle comuníquese a Soporte Técnico : {ex}") - ViewState("CveCompra") = -1 - End Try - ObjAcar.Dispose() - ObjCompras.Dispose() - ObjConta.Dispose() - ObjIE.Dispose() - ObjInventario.Dispose() - ObjAF.Dispose() - ObjOC.Dispose() - ObjProveedores.Dispose() - ObjCGame.Dispose() - ObjProductosServicios.Dispose() - End If - End Sub - - Protected Sub TxtCodigo_TextChanged(sender As Object, e As System.EventArgs) Handles TxtCodigo.TextChanged - Dim ObjProveedores As New ClsCompProveedores() - - Dim Codigo As String = "-1" - If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim - - If Codigo <> "-1" Then - If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, Codigo, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then - If ObjProveedores.DtResultados.Rows.Count > 0 Then - HdnCveProveedor.Value = ObjProveedores.CveProveedor.ToString - Else - Alert("No se encontró el Proveedor con el código: " & TxtCodigo.Text.Trim & ".", Extensiones.TipoMensaje.MsgAdvertencia) - End If - End If - ObjProveedores.Dispose() - BtnBuscarProveedor_Click(sender, e) - End If - End Sub - - Protected Sub ImgSubProyecto_Click(sender As Object, e As EventArgs) Handles ImgSubProyecto.Click - DdlAsignarProyecto.SelectedValue = "-1" - CargaSubProyectoAsignado() - RegistraScript(String.Format("$('#{0}').modal('show');", "DivAplicaSubProyecto")) - End Sub - - Protected Sub BtnEliminarCompra_Click(sender As Object, e As EventArgs) Handles BtnEliminarCompra.Click - - Dim ObjAC As ClsContPAQi = Nothing - Dim Comp As New ClsCompras() - Dim ObjEventos As New ClsOIEventos(Comp.IniciaTransacSQL()) - Dim ObjConta As New ClsContabilidad(Comp.IniciaTransacSQL()) - - - Dim ErrorCompra = False - - If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then - ObjAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - If Not ObjAC.RemovePoliza(IdPoliza) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - For Each gvr As GridViewRow In GvEB.Rows - If Not ObjEventos.RemoveEvento(gvr.DataKey("CveEvento").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - ErrorCompra = True - Exit For - End If - Next - End If - - If Not ErrorCompra Then - If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - If Not Comp.DeleteCompra(CveCompra, False) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - Alert("La Compra ha sido eliminada.", TipoMensaje.MsgInformacion, "document.location.href=""/Compras/Compras.aspx""") - If ObjAC IsNot Nothing Then ObjAC.Commit() - Comp.Commit() - Else - Alert("La Compra no ha sido eliminada.", TipoMensaje.MsgAdvertencia) - If ObjAC IsNot Nothing Then ObjAC.RollBack() - Comp.RollBack() - End If - - If ObjAC IsNot Nothing Then ObjAC.Dispose() - Comp.Dispose() - ObjConta.Dispose() - End Sub - - Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click - - If EstatusAlmacen = 1 Then - Alert("La compra encuentra pendiente de devolución de almacén, por lo cual no se puede amortizar el documento.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'SI TIENE PENDIENTES POR RECIBIR EN ALMACEN, ESTOS PENDIENTES SE PUEDEN QUEMAR CON LAS NC APLICADAS - If CveCompra > 0 And GvInvMov.Rows.Count > 0 And ChkNCInv.Checked Then - CargaNCINV() - Else - GuardaAnticipos(Nothing, Nothing) - End If - - End Sub - - Private Sub GuardaAnticipos(ByRef ObjComprasParametro As ClsCompras, ByRef ObjContaParametro As ClsContabilidad) - - 'SI YA VIENE LOS OBJETOS DE CLASE TOMA LOS DE PARAMETROS - Dim ObjCompra As ClsCompras - Dim ObjConta As ClsContabilidad - - If ObjComprasParametro IsNot Nothing And ObjContaParametro IsNot Nothing Then - ObjCompra = ObjComprasParametro - ObjConta = ObjContaParametro - Else - ObjCompra = New ClsCompras - ObjConta = New ClsContabilidad(ObjCompra.IniciaTransacSQL) - End If - - - Dim Contador As Integer = 0 - Dim Importe As Double = 0 - Dim ErrorMovtosCxP As Integer = 0 - Dim Fecha As Date - - If ListaDocumentos Is Nothing And Not ListaDocumentos.Count > 0 Then - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - Contador += 1 - 'If gvr.DataKey("Fecha").ToDate > Fecha Then Fecha = gvr.DataKey("Fecha").ToDate 'guardo la fecha mayor - Importe += gvr.FCTextBox("TxtAnticipo").Text.ToDouble + End If + + Alert(Msg.ToString, TipoMensaje.MsgInformacion, MsgAccionAceptar) + + End If + + Else + ObjCompras.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("Ocurrio un error al guardar la compra. Por favor intente nuevamente.", TipoMensaje.MsgError) + End If + + + Else + Alert("Debe seleccionar un Funcionario/Empleado o Caja Chica para Reembolsos. Por favor vuelva a intentar.", TipoMensaje.MsgError) + ObjCompras.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + End If + + Else + Alert("Ocurrió un error al agregar el movimiento bancario.
Revise sus datos de pago y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ObjCompras.RollBack() + End If + + End If + + Catch ex As Exception + ObjCompras.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("Ocurrió un error al registrar la compra y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgError) + GuardaLog($"Ocurrió un error al registrar la compra y cualquier detalle comuníquese a Soporte Técnico : {ex}") + ViewState("CveCompra") = -1 + End Try + ObjAcar.Dispose() + ObjCompras.Dispose() + ObjConta.Dispose() + ObjIE.Dispose() + ObjInventario.Dispose() + ObjAF.Dispose() + ObjOC.Dispose() + ObjProveedores.Dispose() + ObjCGame.Dispose() + ObjProductosServicios.Dispose() + End If + End Sub + + Protected Sub TxtCodigo_TextChanged(sender As Object, e As System.EventArgs) Handles TxtCodigo.TextChanged + Dim ObjProveedores As New ClsCompProveedores() + + Dim Codigo As String = "-1" + If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim + + If Codigo <> "-1" Then + If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, Codigo, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then + If ObjProveedores.DtResultados.Rows.Count > 0 Then + HdnCveProveedor.Value = ObjProveedores.CveProveedor.ToString + Else + Alert("No se encontró el Proveedor con el código: " & TxtCodigo.Text.Trim & ".", Extensiones.TipoMensaje.MsgAdvertencia) + End If + End If + ObjProveedores.Dispose() + BtnBuscarProveedor_Click(sender, e) + End If + End Sub + + Protected Sub ImgSubProyecto_Click(sender As Object, e As EventArgs) Handles ImgSubProyecto.Click + DdlAsignarProyecto.SelectedValue = "-1" + CargaSubProyectoAsignado() + RegistraScript(String.Format("$('#{0}').modal('show');", "DivAplicaSubProyecto")) + End Sub + + Protected Sub BtnEliminarCompra_Click(sender As Object, e As EventArgs) Handles BtnEliminarCompra.Click + + Dim ObjAC As ClsContPAQi = Nothing + Dim Comp As New ClsCompras() + Dim ObjEventos As New ClsOIEventos(Comp.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(Comp.IniciaTransacSQL()) + + + Dim ErrorCompra = False + + If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then + ObjAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + If Not ObjAC.RemovePoliza(IdPoliza) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + For Each gvr As GridViewRow In GvEB.Rows + If Not ObjEventos.RemoveEvento(gvr.DataKey("CveEvento").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + ErrorCompra = True + Exit For + End If + Next + End If + + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + If Not Comp.DeleteCompra(CveCompra, False) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + Alert("La Compra ha sido eliminada.", TipoMensaje.MsgInformacion, "document.location.href=""/Compras/Compras.aspx""") + If ObjAC IsNot Nothing Then ObjAC.Commit() + Comp.Commit() + Else + Alert("La Compra no ha sido eliminada.", TipoMensaje.MsgAdvertencia) + If ObjAC IsNot Nothing Then ObjAC.RollBack() + Comp.RollBack() + End If + + If ObjAC IsNot Nothing Then ObjAC.Dispose() + Comp.Dispose() + ObjConta.Dispose() + End Sub + + Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click + + If EstatusAlmacen = 1 Then + Alert("La compra encuentra pendiente de devolución de almacén, por lo cual no se puede amortizar el documento.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'SI TIENE PENDIENTES POR RECIBIR EN ALMACEN, ESTOS PENDIENTES SE PUEDEN QUEMAR CON LAS NC APLICADAS + If CveCompra > 0 And GvInvMov.Rows.Count > 0 And ChkNCInv.Checked Then + CargaNCINV() + Else + GuardaAnticipos(Nothing, Nothing) + End If + + End Sub + + Private Sub GuardaAnticipos(ByRef ObjComprasParametro As ClsCompras, ByRef ObjContaParametro As ClsContabilidad) + + 'SI YA VIENE LOS OBJETOS DE CLASE TOMA LOS DE PARAMETROS + Dim ObjCompra As ClsCompras + Dim ObjConta As ClsContabilidad + + If ObjComprasParametro IsNot Nothing And ObjContaParametro IsNot Nothing Then + ObjCompra = ObjComprasParametro + ObjConta = ObjContaParametro + Else + ObjCompra = New ClsCompras + ObjConta = New ClsContabilidad(ObjCompra.IniciaTransacSQL) + End If + + + Dim Contador As Integer = 0 + Dim Importe As Double = 0 + Dim ErrorMovtosCxP As Integer = 0 + Dim Fecha As Date + + If ListaDocumentos Is Nothing And Not ListaDocumentos.Count > 0 Then + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + Contador += 1 + 'If gvr.DataKey("Fecha").ToDate > Fecha Then Fecha = gvr.DataKey("Fecha").ToDate 'guardo la fecha mayor + Importe += gvr.FCTextBox("TxtAnticipo").Text.ToDouble If Math.Round(Importe, 2) - Math.Round(CompraSaldo, 2) > 0.01 Then gvr.FCTextBox("TxtAnticipo").Text = "" : gvr.FCCheckBox("Chk").Checked = False - End If + End If Next - Else - Contador = 1 - End If - - - - - 'If TxtFecha.Text.ToDate > Fecha Then Fecha = TxtFecha.Text.ToDate - Fecha = TxtFechaEjecucion.Text.ToDate - - 'Contador = 0 - If Contador > 0 Then - If ListaDocumentos Is Nothing And Not ListaDocumentos.Count > 0 Then - If Math.Round(Importe, 2) - Math.Round(CompraSaldo, 2) > 0.01 Then - Alert("El Importe seleccionado excede al importe de la compra", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - ArrAnticipos.Clear() - - If CveCompra > 0 Then - - 'INICIALIZA OBJETOS - If Not (ObjComprasParametro IsNot Nothing And ObjContaParametro IsNot Nothing) Then - ObjCompra = New ClsCompras - ObjConta = New ClsContabilidad(ObjCompra.IniciaTransacSQL) - End If - - Dim CveCompraNC, IdCtaContable, CveCuenta As Integer - - Dim PorcentajePago, ImporteMovimiento, sumaAmortizacion, sumaAmortizacionCompleto As Decimal - Dim ConceptoPoliza As String = $"Amortización {NombreProveedor} - {TxtSerie.Text}-{TxtFolio.Text}" - Dim CompraUnificada As Boolean = False - Dim IVACompleto As Boolean = False - Dim IdCtaIVAXAcreditar As Integer = 0 - Dim IdCtaIVAAcreditable As Integer = 0 - 'PorcentajeIVA - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows.Count > 0 Then - IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero - IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero - End If - - Try - Dim CveIE As Integer = -1 - - If EmpresaPrueba Then - Dim CvePlantillaPoliza = 52 - Dim tipoCambio As Decimal - Dim tipoCambioNC As Decimal - Dim alertaContabilizacion As New StringBuilder - Dim idCuentaContabilizacion As Long = 1 - Dim CveCuentaContabilizacion As Long = 1 - Dim CvePrepolizaPadre As Integer = CvePrePoliza - Dim CuentasContablesInvalidas As New StringBuilder - Dim CuentasContablesInvalidasSIG As New StringBuilder - - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then - tipoCambio = GlobalTipoCambio(Fecha).ToString.ToDecimal - Else - tipoCambio = 1 - End If - - '[IPP] PARCHE PARA AMORTIZACIÓN NC - Dim TipoCambioCompra = Me.TipoCambio.ToDecimal - - Dim CvePrePolizaNueva As Integer = ObjConta.AddPrePolizas("Compras/Anticipos", 52, Importe, Importe, DdlMoneda.SelectedValue.ToEntero, Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - - CveCompraNC = gvr.DataKey("CveCompra").ToEntero - tipoCambioNC = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, gvr.DataKey("TCCompra").ToDecimal) - sumaAmortizacion = 0 - - If CvePrePolizaNueva > 0 Then - If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then - - For Each Row As DataRow In ObjConta.DtResultados.Rows - - Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero - Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) - ImporteMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - Dim Concepto As String = String.Format("{0}-{1}", TxtSerie.Text, TxtFolio.Text) - Dim importeMN As Decimal = 0 - Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) - Dim PorcentajeImpuesto As Decimal = 0 - Dim ConceptoPartida As String = String.Format("{0}-{1}", TxtSerie.Text, TxtFolio.Text) - - - Select Case ConceptoContable - Case 265 'Amortización Anticipos Compras - If gvr.DataKey("TipoDocto").Contiene("Ant") Then - CveIE = -1 - ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal - importeMN = ImporteMovimiento * tipoCambioNC - sumaAmortizacion += ImporteMovimiento + Else + Contador = 1 + End If + + + + + 'If TxtFecha.Text.ToDate > Fecha Then Fecha = TxtFecha.Text.ToDate + Fecha = TxtFechaEjecucion.Text.ToDate + + 'Contador = 0 + If Contador > 0 Then + If ListaDocumentos Is Nothing And Not ListaDocumentos.Count > 0 Then + If Math.Round(Importe, 2) - Math.Round(CompraSaldo, 2) > 0.01 Then + Alert("El Importe seleccionado excede al importe de la compra", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + ArrAnticipos.Clear() + + If CveCompra > 0 Then + + 'INICIALIZA OBJETOS + If Not (ObjComprasParametro IsNot Nothing And ObjContaParametro IsNot Nothing) Then + ObjCompra = New ClsCompras + ObjConta = New ClsContabilidad(ObjCompra.IniciaTransacSQL) + End If + + Dim CveCompraNC, IdCtaContable, CveCuenta As Integer + + Dim PorcentajePago, ImporteMovimiento, sumaAmortizacion, sumaAmortizacionCompleto As Decimal + Dim ConceptoPoliza As String = $"Amortización {NombreProveedor} - {TxtSerie.Text}-{TxtFolio.Text}" + Dim CompraUnificada As Boolean = False + Dim IVACompleto As Boolean = False + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + 'PorcentajeIVA + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("IVAPorcentaje").ToDouble).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + + Try + Dim CveIE As Integer = -1 + + If EmpresaPrueba Then + Dim CvePlantillaPoliza = 52 + Dim tipoCambio As Decimal + Dim tipoCambioNC As Decimal + Dim alertaContabilizacion As New StringBuilder + Dim idCuentaContabilizacion As Long = 1 + Dim CveCuentaContabilizacion As Long = 1 + Dim CvePrepolizaPadre As Integer = CvePrePoliza + Dim CuentasContablesInvalidas As New StringBuilder + Dim CuentasContablesInvalidasSIG As New StringBuilder + + If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then + tipoCambio = GlobalTipoCambio(Fecha).ToString.ToDecimal + Else + tipoCambio = 1 + End If + + '[IPP] PARCHE PARA AMORTIZACIÓN NC + Dim TipoCambioCompra = Me.TipoCambio.ToDecimal + + Dim CvePrePolizaNueva As Integer = ObjConta.AddPrePolizas("Compras/Anticipos", 52, Importe, Importe, DdlMoneda.SelectedValue.ToEntero, Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + + CveCompraNC = gvr.DataKey("CveCompra").ToEntero + tipoCambioNC = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, gvr.DataKey("TCCompra").ToDecimal) + sumaAmortizacion = 0 + + If CvePrePolizaNueva > 0 Then + If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then + + For Each Row As DataRow In ObjConta.DtResultados.Rows + + Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero + Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) + ImporteMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + Dim Concepto As String = String.Format("{0}-{1}", TxtSerie.Text, TxtFolio.Text) + Dim importeMN As Decimal = 0 + Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) + Dim PorcentajeImpuesto As Decimal = 0 + Dim ConceptoPartida As String = String.Format("{0}-{1}", TxtSerie.Text, TxtFolio.Text) + + + Select Case ConceptoContable + Case 265 'Amortización Anticipos Compras + If gvr.DataKey("TipoDocto").Contiene("Ant") Then + CveIE = -1 + ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal + importeMN = ImporteMovimiento * tipoCambioNC + sumaAmortizacion += ImporteMovimiento sumaAmortizacionCompleto += ImporteMovimiento If ChkPagarConPesos.Checked Then ImporteMovimiento = ImporteMovimiento * GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal ElseIf ChkPagarConDolares.Checked Then ImporteMovimiento = ImporteMovimiento / gvr.DataKey("TCCompra").ToDecimal - End If - - If DdlMoneda.SelectedValue.ToEntero <> 1 Then - IdCtaContable = CtaProveedorAnticiposExtranjera - CveCuenta = CveCuentaProveedorAnticiposExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - If UsuarioActual.CveEmpresa.Contiene(119) Then - IdCtaContable = CtaProveedorAnticiposComplementaria - CveCuenta = CveCuentaProveedorAnticiposComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, "", 266, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit Select - End If - End If - Else - ErrorMovtosCxP = 1 - Exit Select - End If - Else - IdCtaContable = CtaProveedorAnticipos - CveCuenta = CveCuentaProveedorAnticipos - If ImporteMovimiento <> 0 Then - PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - End If - End If - End If - End If - - ImporteMovimiento = 0 - Case 60 'Nota de Credito - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then - CveIE = -1 - ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal - importeMN = ImporteMovimiento * tipoCambioNC - sumaAmortizacion += ImporteMovimiento + End If + + If DdlMoneda.SelectedValue.ToEntero <> 1 Then + IdCtaContable = CtaProveedorAnticiposExtranjera + CveCuenta = CveCuentaProveedorAnticiposExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + If UsuarioActual.CveEmpresa.Contiene(119) Then + IdCtaContable = CtaProveedorAnticiposComplementaria + CveCuenta = CveCuentaProveedorAnticiposComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, "", 266, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit Select + End If + End If + Else + ErrorMovtosCxP = 1 + Exit Select + End If + Else + IdCtaContable = CtaProveedorAnticipos + CveCuenta = CveCuentaProveedorAnticipos + If ImporteMovimiento <> 0 Then + PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + End If + End If + End If + End If + + ImporteMovimiento = 0 + Case 60 'Nota de Credito + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then + CveIE = -1 + ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal + importeMN = ImporteMovimiento * tipoCambioNC + sumaAmortizacion += ImporteMovimiento sumaAmortizacionCompleto += ImporteMovimiento If ChkPagarConPesos.Checked Then ImporteMovimiento = ImporteMovimiento * GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal ElseIf ChkPagarConDolares.Checked Then ImporteMovimiento = ImporteMovimiento / gvr.DataKey("TCCompra").ToDecimal - End If - - If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, ConceptoPartida, ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, ConceptoPartida, 235, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit Select - End If - Else - ErrorMovtosCxP = 1 - Exit Select - End If - Else - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - If ImporteMovimiento <> 0 Then - PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, ConceptoPartida, ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - End If - End If - End If - End If - - ImporteMovimiento = 0 - Case 21 'Anticipo - If gvr.DataKey("TipoDocto") = "Egsc" Then - CveCompraNC = -1 - CveIE = gvr.DataKey("CveIE").ToEntero - ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal - sumaAmortizacion += ImporteMovimiento - sumaAmortizacionCompleto += ImporteMovimiento - IdCtaContable = CtaProveedorAnticipos + End If + + If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, ConceptoPartida, ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, ConceptoPartida, 235, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioNC, CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit Select + End If + Else + ErrorMovtosCxP = 1 + Exit Select + End If + Else + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + If ImporteMovimiento <> 0 Then + PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, ConceptoPartida, ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + End If + End If + End If + End If + + ImporteMovimiento = 0 + Case 21 'Anticipo + If gvr.DataKey("TipoDocto") = "Egsc" Then + CveCompraNC = -1 + CveIE = gvr.DataKey("CveIE").ToEntero + ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal + sumaAmortizacion += ImporteMovimiento + sumaAmortizacionCompleto += ImporteMovimiento + IdCtaContable = CtaProveedorAnticipos CveCuenta = CveCuentaProveedorAnticipos PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal @@ -8373,533 +8373,533 @@ Partial Class Compras_Compras If ImporteMovimiento <> 0 Then Dim TipoCambioAnt = gvr.DataKey("TCCompra").ToDecimal - - Dim usacomplementariaAnticipo As Boolean = False + + Dim usacomplementariaAnticipo As Boolean = False usacomplementariaAnticipo = If(TipoCambioAnt > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False) - Dim ImporteAnt As Decimal = ImporteMovimiento - Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt - If usacomplementariaAnticipo Then - IdCtaContable = CtaProveedorAnticiposComplementaria - CveCuenta = CveCuentaProveedorAnticiposComplementaria - ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteAnt, "", 266, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - End If - ImporteAntMN = ImporteAnt - End If - - If TipoCambioAnt > 1 Then - IdCtaContable = CtaProveedorAnticiposExtranjera - CveCuenta = CveCuentaProveedorAnticiposExtranjera - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteAnt, "", ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteAntMN, CvePrePolizaOriginal:=CvePrePolizaNueva, ImporteME:=If(tipoCambio = 1, 0, ImporteAnt), CveCompraAmortizacion:=CveCompraNC, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 + Dim ImporteAnt As Decimal = ImporteMovimiento + Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt + If usacomplementariaAnticipo Then + IdCtaContable = CtaProveedorAnticiposComplementaria + CveCuenta = CveCuentaProveedorAnticiposComplementaria + ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteAnt, "", 266, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + End If + ImporteAntMN = ImporteAnt + End If + + If TipoCambioAnt > 1 Then + IdCtaContable = CtaProveedorAnticiposExtranjera + CveCuenta = CveCuentaProveedorAnticiposExtranjera + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteAnt, "", ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteAntMN, CvePrePolizaOriginal:=CvePrePolizaNueva, ImporteME:=If(tipoCambio = 1, 0, ImporteAnt), CveCompraAmortizacion:=CveCompraNC, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 End If If ChkPagarConPesos.Checked Or ChkPagarConDolares.Checked Then ImporteAnt = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal - TipoCambioAnt = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, gvr.DataKey("TCCompra").ToDecimal) - End If - + TipoCambioAnt = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, gvr.DataKey("TCCompra").ToDecimal) + End If + Dim TipoCambioDiferencia = If(ChkPagarConDolares.Checked, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambioCompra).ToDecimal - If TipoCambioDiferencia <> TipoCambioAnt Then - Dim importeFluctuacion = (ImporteAnt * TipoCambioDiferencia) - (ImporteAnt * TipoCambioAnt) - - If importeFluctuacion > 0 Then - ConceptoContable = 64 - TipoMovimiento = True - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - ElseIf importeFluctuacion < 0 Then - ConceptoContable = 65 - TipoMovimiento = False - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - End If - - importeFluctuacion = importeFluctuacion.Abs.RoundSQL() - If importeFluctuacion <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeFluctuacion, "", ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePolizaNueva, ImporteME:=0, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - End If - End If - End If - - End If - End If - - ImporteMovimiento = 0 - - Case 37 'Deudores Diversos - If gvr.DataKey("TipoDocto") = "DD" Then - CveCompraNC = -1 - CveIE = gvr.DataKey("CveIE").ToEntero - ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal - sumaAmortizacion += ImporteMovimiento - sumaAmortizacionCompleto += ImporteMovimiento - IdCtaContable = CtaProveedorDeudores - CveCuenta = CveCuentaProveedorDeudores - - If ImporteMovimiento <> 0 Then - PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento * tipoCambio, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompraNC, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - End If - End If - End If - - ImporteMovimiento = 0 - - Case 17 'Pago Proveedores - Dim TipoCambio17 = tipoCambio - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant", "Egsc") Then - TipoCambio17 = TipoCambioCompra - End If - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then - ConceptoContable = 272 - End If - - ImporteMovimiento = sumaAmortizacion - importeMN = ImporteMovimiento * TipoCambio17 - - If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then - IdCtaContable = CtaProveedorExtranjera - CveCuenta = CveCuentaProveedorExtranjera - If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=TipoCambio17, CveCuenta:=CveCuenta) Then - IdCtaContable = CtaProveedorComplementaria - CveCuenta = CveCuentaProveedorComplementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, Concepto, 206, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=TipoCambio17, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit Select - End If - Else - ErrorMovtosCxP = 1 - Exit Select - End If - Else - IdCtaContable = CtaProveedor - CveCuenta = CveCuentaProveedor - If ImporteMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(TipoCambio17 = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit For - End If - End If - End If - - ImporteMovimiento = 0 - Case 14 'Iva X Acreditar - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then - If sumaAmortizacion = CompraSaldo Then + If TipoCambioDiferencia <> TipoCambioAnt Then + Dim importeFluctuacion = (ImporteAnt * TipoCambioDiferencia) - (ImporteAnt * TipoCambioAnt) + + If importeFluctuacion > 0 Then + ConceptoContable = 64 + TipoMovimiento = True + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ElseIf importeFluctuacion < 0 Then + ConceptoContable = 65 + TipoMovimiento = False + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + importeFluctuacion = importeFluctuacion.Abs.RoundSQL() + If importeFluctuacion <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeFluctuacion, "", ConceptoContable, ConceptoPartida, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePolizaNueva, ImporteME:=0, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + End If + End If + End If + + End If + End If + + ImporteMovimiento = 0 + + Case 37 'Deudores Diversos + If gvr.DataKey("TipoDocto") = "DD" Then + CveCompraNC = -1 + CveIE = gvr.DataKey("CveIE").ToEntero + ImporteMovimiento = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal + sumaAmortizacion += ImporteMovimiento + sumaAmortizacionCompleto += ImporteMovimiento + IdCtaContable = CtaProveedorDeudores + CveCuenta = CveCuentaProveedorDeudores + + If ImporteMovimiento <> 0 Then + PorcentajePago = ImporteMovimiento / TxtTotal.Text.ToDecimal + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, "", ConceptoContable, "", Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento * tipoCambio, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCompraAmortizacion:=CveCompraNC, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + End If + End If + End If + + ImporteMovimiento = 0 + + Case 17 'Pago Proveedores + Dim TipoCambio17 = tipoCambio + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant", "Egsc") Then + TipoCambio17 = TipoCambioCompra + End If + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then + ConceptoContable = 272 + End If + + ImporteMovimiento = sumaAmortizacion + importeMN = ImporteMovimiento * TipoCambio17 + + If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then + IdCtaContable = CtaProveedorExtranjera + CveCuenta = CveCuentaProveedorExtranjera + If ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=TipoCambio17, CveCuenta:=CveCuenta) Then + IdCtaContable = CtaProveedorComplementaria + CveCuenta = CveCuentaProveedorComplementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, importeMN - ImporteMovimiento, Concepto, 206, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN - ImporteMovimiento, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=ImporteMovimiento, TipoCambio:=TipoCambio17, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit Select + End If + Else + ErrorMovtosCxP = 1 + Exit Select + End If + Else + IdCtaContable = CtaProveedor + CveCuenta = CveCuentaProveedor + If ImporteMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(TipoCambio17 = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit For + End If + End If + End If + + ImporteMovimiento = 0 + Case 14 'Iva X Acreditar + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + If sumaAmortizacion = CompraSaldo Then ImporteMovimiento = TxtIVA.Text.ToDecimal If ImporteMovimiento > 0 Then IVACompleto = True End If - Else - ImporteMovimiento = 0 - End If - Else - ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) - End If - importeMN = ImporteMovimiento * tipoCambio - PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal - IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero - End If - End If - End If - Case 19 'Iva Acreditado - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then - If sumaAmortizacion = CompraSaldo Then - ImporteMovimiento = TxtIVA.Text.ToDecimal - IVACompleto = True - Else - ImporteMovimiento = 0 - End If - Else - ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) - End If - importeMN = ImporteMovimiento * tipoCambio - PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal - IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero - End If - End If - End If - Case 15 'RetIVA x Acreditar Honorarios/Serv. Prof. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 22 'RetIVA Acreditable Honorarios/Serv. Prof. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + Else + ImporteMovimiento = 0 + End If + Else + ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) + End If + importeMN = ImporteMovimiento * tipoCambio + PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal + IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero + End If + End If + End If + Case 19 'Iva Acreditado + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + If sumaAmortizacion = CompraSaldo Then + ImporteMovimiento = TxtIVA.Text.ToDecimal + IVACompleto = True + Else + ImporteMovimiento = 0 + End If + Else + ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) + End If + importeMN = ImporteMovimiento * tipoCambio + PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + End If + Case 15 'RetIVA x Acreditar Honorarios/Serv. Prof. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 22 'RetIVA Acreditable Honorarios/Serv. Prof. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - - + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(577).ToEntero = 1 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero End If End If - End If - - End If - - - Case 183 'RetIVA x Acreditar Fletes P.F. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - - Case 184 'RetIVA Acreditable Fletes P.F. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - - Case 185 'RetIVA x Acreditar Fletes P.M. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - - Case 186 'RetIVA Acreditable Fletes P.M. - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 248 'RetIVA x Acreditar Arrendamiento - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - - Case 249 'RetIVA Acreditable Arrendamiento - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetIVAConcepto.Items.Count > 0 Then - If DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetIVA > 0 Then - IdCtaContable = CtaProveedorRetIVA - CveCuenta = CveCuentaProveedorRetIVA - ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - End If - Case 16 'RetISR x Acreditar - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - - Case 23 'RetISR Acreditable - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - Case 243 'RetISR X Acreditar Terceros y Arrendamiento - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - Case 244 'RetISR Acreditable Terceros y Arrendamiento - If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then - If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) - importeMN = ImporteMovimiento * tipoCambio - If CtaProveedorRetISR > 0 Then - IdCtaContable = CtaProveedorRetISR - CveCuenta = CveCuentaProveedorRetISR - ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).ToEntero - Else - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - End If - Case 64 'GANANCIA - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then 'SOLO SE IMPLEMENTÓ PARA NC - If DdlMoneda.SelectedValue.ToEntero <> 1 Or gvr.DataKey("CveMoneda").ToEntero <> 1 Then - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - Dim TipoCambioDiferenciaCambiaria = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, tipoCambioNC) - Dim TipoCambioDiferenciaCompra = If(ChkPagarConDolares.Checked, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambioCompra).ToDecimal - If TipoCambioDiferenciaCompra > TipoCambioDiferenciaCambiaria Then - ImporteMovimiento = (sumaAmortizacion * TipoCambioDiferenciaCompra) - (sumaAmortizacion * TipoCambioDiferenciaCambiaria) - ImporteMovimiento = ImporteMovimiento.RoundSQL() - importeMN = ImporteMovimiento - End If - - If ImporteMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit For - End If - End If - - End If - End If - ImporteMovimiento = 0 - Case 65 'PERDIDA - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then 'SOLO SE IMPLEMENTÓ PARA NC - If DdlMoneda.SelectedValue.ToEntero <> 1 Or gvr.DataKey("CveMoneda").ToEntero <> 1 Then - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + End If + + End If + + + Case 183 'RetIVA x Acreditar Fletes P.F. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + + Case 184 'RetIVA Acreditable Fletes P.F. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + + Case 185 'RetIVA x Acreditar Fletes P.M. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + + Case 186 'RetIVA Acreditable Fletes P.M. + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 248 'RetIVA x Acreditar Arrendamiento + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + + Case 249 'RetIVA Acreditable Arrendamiento + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetIVAConcepto.Items.Count > 0 Then + If DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetIVA > 0 Then + IdCtaContable = CtaProveedorRetIVA + CveCuenta = CveCuentaProveedorRetIVA + ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + End If + Case 16 'RetISR x Acreditar + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + + Case 23 'RetISR Acreditable + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + Case 243 'RetISR X Acreditar Terceros y Arrendamiento + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + Case 244 'RetISR Acreditable Terceros y Arrendamiento + If Not gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then + If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) + importeMN = ImporteMovimiento * tipoCambio + If CtaProveedorRetISR > 0 Then + IdCtaContable = CtaProveedorRetISR + CveCuenta = CveCuentaProveedorRetISR + ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).ToEntero + Else + If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + End If + Case 64 'GANANCIA + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then 'SOLO SE IMPLEMENTÓ PARA NC + If DdlMoneda.SelectedValue.ToEntero <> 1 Or gvr.DataKey("CveMoneda").ToEntero <> 1 Then + IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria Dim TipoCambioDiferenciaCambiaria = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, tipoCambioNC) - Dim TipoCambioDiferenciaCompra = If(ChkPagarConDolares.Checked, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambioCompra).ToDecimal - If TipoCambioDiferenciaCambiaria > TipoCambioDiferenciaCompra Then - ImporteMovimiento = (sumaAmortizacion * TipoCambioDiferenciaCambiaria) - (sumaAmortizacion * TipoCambioDiferenciaCompra) - ImporteMovimiento = ImporteMovimiento.RoundSQL() - importeMN = ImporteMovimiento - End If - - If ImporteMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta) Then - ErrorMovtosCxP = 1 - Exit For - End If - End If - - End If - End If - ImporteMovimiento = 0 - End Select - - If ImporteMovimiento <> 0 Then - 'Conta ContPAQ - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - 'Conta SIG - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto) Then - ErrorMovtosCxP = 1 - Exit For - End If - - End If - Next - - End If - - End If - - '[IPP] COMENTADO PORQUE REUNIFICABA AMORTIZACIÓN NC 27/Agosto/2018 - 'If Not CompraUnificada Then - ' 'Unificacion de PrePolizas - ' If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then - ' If Not ObjConta.PrePolizaUnificacion(gvr.DataKey("CvePrePoliza").ToEntero, CvePrepolizaPadre) Then - ' ErrorMovtosCxP = 1 - ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) - ' End If - ' End If - 'End If - End If - Next - - 'Si el importe total de la amortizacion es igual al saldo de la compra se registra IVA - If IVACompleto = False AndAlso UsuarioActual.Empresa.Funcionalidad(521) = "1" Then - If sumaAmortizacionCompleto = CompraSaldo Then + Dim TipoCambioDiferenciaCompra = If(ChkPagarConDolares.Checked, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambioCompra).ToDecimal + If TipoCambioDiferenciaCompra > TipoCambioDiferenciaCambiaria Then + ImporteMovimiento = (sumaAmortizacion * TipoCambioDiferenciaCompra) - (sumaAmortizacion * TipoCambioDiferenciaCambiaria) + ImporteMovimiento = ImporteMovimiento.RoundSQL() + importeMN = ImporteMovimiento + End If + + If ImporteMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit For + End If + End If + + End If + End If + ImporteMovimiento = 0 + Case 65 'PERDIDA + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV", "Ant") Then 'SOLO SE IMPLEMENTÓ PARA NC + If DdlMoneda.SelectedValue.ToEntero <> 1 Or gvr.DataKey("CveMoneda").ToEntero <> 1 Then + IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + Dim TipoCambioDiferenciaCambiaria = If(ChkPagarConPesos.Checked, GlobalTipoCambio(gvr.DataKey("Fecha").ToDate).ToDecimal, tipoCambioNC) + Dim TipoCambioDiferenciaCompra = If(ChkPagarConDolares.Checked, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambioCompra).ToDecimal + If TipoCambioDiferenciaCambiaria > TipoCambioDiferenciaCompra Then + ImporteMovimiento = (sumaAmortizacion * TipoCambioDiferenciaCambiaria) - (sumaAmortizacion * TipoCambioDiferenciaCompra) + ImporteMovimiento = ImporteMovimiento.RoundSQL() + importeMN = ImporteMovimiento + End If + + If ImporteMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta) Then + ErrorMovtosCxP = 1 + Exit For + End If + End If + + End If + End If + ImporteMovimiento = 0 + End Select + + If ImporteMovimiento <> 0 Then + 'Conta ContPAQ + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + 'Conta SIG + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaNueva, TipoMovimiento, ImporteMovimiento, Concepto, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=If(tipoCambio = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto) Then + ErrorMovtosCxP = 1 + Exit For + End If + + End If + Next + + End If + + End If + + '[IPP] COMENTADO PORQUE REUNIFICABA AMORTIZACIÓN NC 27/Agosto/2018 + 'If Not CompraUnificada Then + ' 'Unificacion de PrePolizas + ' If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then + ' If Not ObjConta.PrePolizaUnificacion(gvr.DataKey("CvePrePoliza").ToEntero, CvePrepolizaPadre) Then + ' ErrorMovtosCxP = 1 + ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) + ' End If + ' End If + 'End If + End If + Next + + 'Si el importe total de la amortizacion es igual al saldo de la compra se registra IVA + If IVACompleto = False AndAlso UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + If sumaAmortizacionCompleto = CompraSaldo Then Dim PorcentajeImpuesto As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal @@ -8914,1670 +8914,1684 @@ Partial Class Compras_Compras End If - End If - End If - - 'Unificacion de PrePolizas - If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then - If Not ObjConta.PrePolizaUnificacion(CvePrepolizaPadre, CvePrePolizaNueva) Then - ErrorMovtosCxP = 1 - Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) + End If + End If + + 'Unificacion de PrePolizas + If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then + If Not ObjConta.PrePolizaUnificacion(CvePrepolizaPadre, CvePrePolizaNueva) Then + ErrorMovtosCxP = 1 + Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) End If CvePrePolizaNueva = CvePrepolizaPadre 'para que se unifique siempre la prepolizanueva - End If - - 'Simplificacion de PrePolizas - If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then - If Not ObjConta.PrePolizaSimplificacion(CvePrePolizaNueva, UsuarioActual.CveEmpresa) Then - ErrorMovtosCxP = 1 - Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) - End If - End If - - 'Validacion de prepolizas - If ObjConta.ValidacionPrePolizaCuadre(CvePrePolizaNueva, 4) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Compras/Compras-Anticipos | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - 'ErrorMovtosCxP = 1 - End If - End If - - 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ErrorMovtosCxP = 0 Then - If idCuentaContabilizacion > 0 Then - If ObjConta.ContabilizarPrePoliza(CvePrePolizaNueva, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then - alertaContabilizacion.AppendFormat("{1}<\a>
", ObjConta.ContaIdPoliza, ObjConta.ContaFolio) - Else - ErrorMovtosCxP = 1 - End If - If ErrorMovtosCxP = 0 Then - Alert("Se enviaron correctamente las siguientes pólizas:

" & alertaContabilizacion.ToString, ModExtensiones.TipoMensaje.MsgInformacion) - Else - Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) - End If - Else - Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas:
{0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia) - End If - End If - - - Else 'Empresa Prueba - - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - - CveCompraNC = gvr.DataKey("CveCompra").ToEntero - If CvePrePoliza > 0 Then - - Dim CveConceptoCompra As Integer = 60 - Dim CveConceptoPago As Integer = 17 - Dim TipoMovimientoCompra As Boolean = True - Select Case gvr.DataKey("TipoDocto") - Case "NC", "DEV" - CveConceptoCompra = 60 - CveIE = -1 - CveConceptoPago = 272 - Case "Egsc" - CveConceptoCompra = 21 - 'vinculo la compra actual, y no la compra como si fuera nota de credito - CveCompraNC = -1 - CveIE = gvr.DataKey("CveIE").ToEntero - Case "DD" - CveConceptoCompra = 37 - 'vinculo la compra actual, y no la compra como si fuera nota de credito - CveCompraNC = -1 - CveIE = gvr.DataKey("CveIE").ToEntero - End Select - - PorcentajePago = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal / TxtTotal.Text.ToDecimal - - 'Se agrega la nota de credito - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, CveCompraAmortizacion:=CveCompraNC, ImporteMX:=gvr.FCTextBox("TxtAnticipo").Text.ToDecimal) Then - ErrorMovtosCxP = 1 - Exit For - End If - - 'movimiento de pago proveedor - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, CveCompraAmortizacion:=CveCompraNC, ImporteMX:=gvr.FCTextBox("TxtAnticipo").Text.ToDecimal) Then - ErrorMovtosCxP = 1 - Exit For - End If - - 'si tiene iva y su proporcion - ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) - If ImporteMovimiento > 0 Then - Dim PorcentajeImpuesto As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 14, " ", TxtFechaPago.Text.ToDate, IdCtaIVAXAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, PorcentajeImpuesto:=PorcentajeImpuesto) Then ErrorMovtosCxP = 1 : Exit For - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 19, " ", TxtFechaPago.Text.ToDate, IdCtaIVAAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, PorcentajeImpuesto:=PorcentajeImpuesto) Then ErrorMovtosCxP = 1 : Exit For - - End If - - 'si tiene Ret iva y su proporcion - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) - If ImporteMovimiento > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 15, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For - - End If - - 'si tiene Ret ISR y su proporcion - ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) - If ImporteMovimiento > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 16, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For - - End If - - - 'actualizo una tabla de vinculaciones - - 'actualizo la cantidad en amortizaciones - - If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then - If Not ObjCompra.AmortizarCompra(CveCompra, CveCompraNC, gvr.FCTextBox("TxtAnticipo").Text.ToDouble, UsuarioActual.CveUsuario) Then - ErrorMovtosCxP = 2 - Exit For - - End If - - End If - - - End If - - End If - - Next - - End If 'Empresa Prueba - - - - Select Case ErrorMovtosCxP - Case 0 - Alert("El movimiento se aplicó correctamente.", TipoMensaje.MsgInformacion) - ObjCompra.Commit() - - - Dim dtnc As DataTable = Nothing - If ObjCompra.GetComprasNotasCredito(CveCompra, -1) Then - dtnc = ObjCompra.DtResultados - End If - - GvAnticiposSel.DataSource = dtnc - GvAnticiposSel.DataBind() - - LblAmortizacion.Text = (LblAmortizacion.Text.ToDouble + Importe).FormatoNumero - CompraSaldo = CompraSaldo - Importe - HdnCompraSaldo.Value = CompraSaldo.ToString - - If CompraSaldo > 0 Then CargaAnticipos(CveProveedor) - If CveCompra > 0 Then VisualizaEstatusCompraSaldo(DdlTipoComprobante.SelectedValue, CompraSaldo.ToDecimal, TxtTotal.Text.ToDecimal) - - UpAnticipos.Update() - UpPS.Update() - dtnc.Dispose() - Case 1 - Alert("Ocurrió un error al amortizar la nota de crédito
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ObjCompra.RollBack() - Case 2 - Alert("Ocurrió un error al amortizar la nota de crédito
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) - ObjCompra.RollBack() - End Select - - Catch ex As Exception - ObjCompra.RollBack() - End Try - ObjCompra.Dispose() - Else - 'sino se ha guardado la compra, se registra temporal que anticpos van a cargarle - - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - ArrAnticipos.Add(New Anticipos With {.CvePrePoliza = gvr.DataKey("CvePrePoliza").ToEntero, .CveIE = gvr.DataKey("CveIE").ToString.ToEntero, .CveCompra = gvr.DataKey("CveCompra").ToEntero, .Importe = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, .TCCompra = gvr.DataKey("TCCompra").ToDecimal, .TipoMovto = gvr.DataKey("TipoDocto")}) - End If - Next - - Dim ImporteAnticipo As Decimal = 0 - If ArrAnticipos.Count > 0 Then - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - ImporteAnticipo += Ant.Importe - Next - End If - + End If + + 'Simplificacion de PrePolizas + If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then + If Not ObjConta.PrePolizaSimplificacion(CvePrePolizaNueva, UsuarioActual.CveEmpresa) Then + ErrorMovtosCxP = 1 + Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) + End If + End If + + 'Validacion de prepolizas + If ObjConta.ValidacionPrePolizaCuadre(CvePrePolizaNueva, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Compras/Compras-Anticipos | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + 'ErrorMovtosCxP = 1 + End If + End If + + 'Conta ContPAQ + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ErrorMovtosCxP = 0 Then + If idCuentaContabilizacion > 0 Then + If ObjConta.ContabilizarPrePoliza(CvePrePolizaNueva, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + alertaContabilizacion.AppendFormat("
{1}<\a>
", ObjConta.ContaIdPoliza, ObjConta.ContaFolio) + Else + ErrorMovtosCxP = 1 + End If + If ErrorMovtosCxP = 0 Then + Alert("Se enviaron correctamente las siguientes pólizas:

" & alertaContabilizacion.ToString, ModExtensiones.TipoMensaje.MsgInformacion) + Else + Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia) + End If + Else + Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas:
{0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia) + End If + End If + + + Else 'Empresa Prueba + + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + + CveCompraNC = gvr.DataKey("CveCompra").ToEntero + If CvePrePoliza > 0 Then + + Dim CveConceptoCompra As Integer = 60 + Dim CveConceptoPago As Integer = 17 + Dim TipoMovimientoCompra As Boolean = True + Select Case gvr.DataKey("TipoDocto") + Case "NC", "DEV" + CveConceptoCompra = 60 + CveIE = -1 + CveConceptoPago = 272 + Case "Egsc" + CveConceptoCompra = 21 + 'vinculo la compra actual, y no la compra como si fuera nota de credito + CveCompraNC = -1 + CveIE = gvr.DataKey("CveIE").ToEntero + Case "DD" + CveConceptoCompra = 37 + 'vinculo la compra actual, y no la compra como si fuera nota de credito + CveCompraNC = -1 + CveIE = gvr.DataKey("CveIE").ToEntero + End Select + + PorcentajePago = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal / TxtTotal.Text.ToDecimal + + 'Se agrega la nota de credito + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveProveedor:=CveProveedor, CveIE:=CveIE, CveCompraAmortizacion:=CveCompraNC, ImporteMX:=gvr.FCTextBox("TxtAnticipo").Text.ToDecimal) Then + ErrorMovtosCxP = 1 + Exit For + End If + + 'movimiento de pago proveedor + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, CveCompraAmortizacion:=CveCompraNC, ImporteMX:=gvr.FCTextBox("TxtAnticipo").Text.ToDecimal) Then + ErrorMovtosCxP = 1 + Exit For + End If + + 'si tiene iva y su proporcion + ImporteMovimiento = Math.Round(PorcentajePago * TxtIVA.Text.ToDecimal, 2) + If ImporteMovimiento > 0 Then + Dim PorcentajeImpuesto As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 14, " ", TxtFechaPago.Text.ToDate, IdCtaIVAXAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, PorcentajeImpuesto:=PorcentajeImpuesto) Then ErrorMovtosCxP = 1 : Exit For + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 19, " ", TxtFechaPago.Text.ToDate, IdCtaIVAAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento, PorcentajeImpuesto:=PorcentajeImpuesto) Then ErrorMovtosCxP = 1 : Exit For + + End If + + 'si tiene Ret iva y su proporcion + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetIVA.Text.ToDecimal, 2) + If ImporteMovimiento > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 15, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For + + End If + + 'si tiene Ret ISR y su proporcion + ImporteMovimiento = Math.Round(PorcentajePago * TxtRetISR.Text.ToDecimal, 2) + If ImporteMovimiento > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, " ", 16, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=ImporteMovimiento) Then ErrorMovtosCxP = 1 : Exit For + + End If + + + 'actualizo una tabla de vinculaciones + + 'actualizo la cantidad en amortizaciones + + If gvr.DataKey("TipoDocto").Contiene("NC", "DEV") Then + If Not ObjCompra.AmortizarCompra(CveCompra, CveCompraNC, gvr.FCTextBox("TxtAnticipo").Text.ToDouble, UsuarioActual.CveUsuario) Then + ErrorMovtosCxP = 2 + Exit For + + End If + + End If + + + End If + + End If + + Next + + End If 'Empresa Prueba + + + + Select Case ErrorMovtosCxP + Case 0 + Alert("El movimiento se aplicó correctamente.", TipoMensaje.MsgInformacion) + ObjCompra.Commit() + + + Dim dtnc As DataTable = Nothing + If ObjCompra.GetComprasNotasCredito(CveCompra, -1) Then + dtnc = ObjCompra.DtResultados + End If + + GvAnticiposSel.DataSource = dtnc + GvAnticiposSel.DataBind() + + LblAmortizacion.Text = (LblAmortizacion.Text.ToDouble + Importe).FormatoNumero + CompraSaldo = CompraSaldo - Importe + HdnCompraSaldo.Value = CompraSaldo.ToString + + If CompraSaldo > 0 Then CargaAnticipos(CveProveedor) + If CveCompra > 0 Then VisualizaEstatusCompraSaldo(DdlTipoComprobante.SelectedValue, CompraSaldo.ToDecimal, TxtTotal.Text.ToDecimal) + + UpAnticipos.Update() + UpPS.Update() + dtnc.Dispose() + Case 1 + Alert("Ocurrió un error al amortizar la nota de crédito
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ObjCompra.RollBack() + Case 2 + Alert("Ocurrió un error al amortizar la nota de crédito
Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia) + ObjCompra.RollBack() + End Select + + Catch ex As Exception + ObjCompra.RollBack() + End Try + ObjCompra.Dispose() + Else + 'sino se ha guardado la compra, se registra temporal que anticpos van a cargarle + + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + ArrAnticipos.Add(New Anticipos With {.CvePrePoliza = gvr.DataKey("CvePrePoliza").ToEntero, .CveIE = gvr.DataKey("CveIE").ToString.ToEntero, .CveCompra = gvr.DataKey("CveCompra").ToEntero, .Importe = gvr.FCTextBox("TxtAnticipo").Text.ToDecimal, .TCCompra = gvr.DataKey("TCCompra").ToDecimal, .TipoMovto = gvr.DataKey("TipoDocto")}) + End If + Next + + Dim ImporteAnticipo As Decimal = 0 + If ArrAnticipos.Count > 0 Then + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + ImporteAnticipo += Ant.Importe + Next + End If + LblAmortizacion.Text = ImporteAnticipo.FormatoNumero - UpPS.Update() - End If - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAnticipos")) - Else - Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia) - End If - UPPAnticiposSel.Update() - End Sub - - Protected Sub ImgClasificacion_Click(sender As Object, e As EventArgs) Handles ImgClasificacion.Click - - If CveCompra > 0 Then - - Dim SiSelecciono As Boolean = False - For Each gvr As GridViewRow In GvPS.Rows - If gvr.FCCheckBox("CheckClasificacion").Checked = True Then - SiSelecciono = True - Exit For - End If - Next - If SiSelecciono = False Then - Alert("Tiene que seleccionar algun Producto o Servicio", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - DdlAplicaClasificacion.SelectedValue = "-1" - RegistraScript(String.Format("$('#{0}').modal('show');", "DivClasificacion")) - Else - RegistraScript(String.Format("$('#{0}').modal('show');", "DivClasificacion")) - End If - - End Sub - - Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs) Handles BtnActualizar.Click - - 'VALIDA IMPORTES - If CveFactura > 0 Then 'SI NO VIENE DE FACTURA/XML NO VALIDA TOTALES - If Not ValidaTotalesGuardar() Then - Exit Sub - End If - End If - - For Each Row As DataRow In TmpDT.Rows - If Row("CveSubProyecto").ToString.ToEntero <= 0 Then - Alert("No se ha completado la asignacion de proyectos en la compra. ", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then 'If NotHas117 AndAlso Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then - Alert("Hay productos que no tienen clasificación asignada.
Favor de asignarle una y darle guardar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then - If Row("CveTipoGasto").ToString.ToEntero <= 0 Then - Alert("No se ha completado la asignacion de tipos de gasto en la compra.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - Next - - - Dim ObjCompra As New ClsCompras - Dim ObjProveedores As New ClsCompProveedores(ObjCompra.IniciaTransacSQL()) - Dim ObjInventario As New ClsInventarios(ObjCompra.IniciaTransacSQL) - Dim ObjContabilidad As New ClsContabilidad(ObjCompra.IniciaTransacSQL) - Dim ObjAF As New ClsAF(ObjCompra.IniciaTransacSQL) - Dim ObjContaAC As ClsContPAQi = New ClsContPAQi(UsuarioActual.Empresa) - - Dim Retorno As Boolean = True - Dim CveEstatusFactura As Integer = HdnCveEstatusFactura.Value.ToEntero - Dim MultiplicadorNC = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) - - Dim ErrorAC = False - Dim IDPolizaComprometido = 0 - - If ChkProgramarPago.Checked AndAlso CveEstatusFactura = 1 Then - CveEstatusFactura = 2 - End If - If Not ChkProgramarPago.Checked AndAlso CveEstatusFactura = 2 Then - CveEstatusFactura = 1 - End If - Try - 'Revisamos que los cambios hechos mantengan la interidad de los numeros - If HFDiferenciaCompra.Value = TxtTotal.Text Or CveFactura < 1 Or CveCompra < 1 Then - - If IdPoliza > 0 Then - If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then - Retorno = False - End If - - If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, Nothing, CvePrePoliza, UsuarioActual.CveEmpresa) Then - Retorno = False - End If - End If - - 'PORCENTAJE IVA - Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal - - If ObjCompra.UpdateCompra(TxtDescripcion.Text.Trim, TxtFolioSecundario.Text.Trim, TxtFechaPago.Text.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura, - TxtDescuento.Text.ToDouble, TxtSubTotal.Text.ToDouble, TxtIVA.Text.ToDouble, TxtTotal.Text.ToDouble, - UsuarioActual.CveUsuario, CveCompra, CveCajaChica:=DdlRembolsoCajaChica.SelectedValue.ToEntero, CvePersonal:=DdlRembolsoPersonal.SelectedValue.ToEntero, CveProveedorSucursal:=If(DdlProveedorSucursal.SelectedValue.ToEntero > 0, DdlProveedorSucursal.SelectedValue.ToEntero, -1), PorcentajeIVA:=PorcentajeIVA, NumeroReembolso:=TxtRembolsoNumero.Text, - CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=EsNoDeducible) Then - - If Not ComparaDatatables() Then - - 'Regeneramos el concepto 6 de PrePolizas - 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then - ' If Not RegenerarPrePoliza(ObjContabilidad, ObjContaAC, 6, False, MultiplicadorNC) Then - ' Retorno = False - ' End If - 'End If - - - - 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then - If Not ActualizarPrePoliza(ObjContabilidad, ObjCompra) Then - Retorno = False - End If - 'End If - - ''EMPIEZA: SI USA AC - If UsuarioActual.Empresa.UsaAC AndAlso IdPoliza > 0 Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - - - 'ELIMINA TODOS LOS MOVIMIENTOS DE LA POLIZA - ObjContaAC.RemoveAllMovimientos(IdPoliza) - - - 'INSERTA LOS NUEVOS MOVIMIENTOS DE LA POLIZA - If IdPoliza > 0 Then - Dim CuentaAbono As Integer - Dim Importe As Decimal = 0 - Dim TotalDetalle As Decimal = 0 - - 'CUENTA PROVEEDOR - If CtaProveedor <= 0 Then - If ObjContaAC.GetCuentas(-1, "021120000000000000", -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021120000000000000").ToString - ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02112{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) - ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - Dim ConceptoRenglon As String = "" - If Not ErrorAC Then - - Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal - - Dim ipresup As Integer = 0 - - 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS - Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() - Group gvr By Grp = New With { - Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, - Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) - } Into Group - Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, - TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) - Dim Fecha As Date = TxtFecha.Text.ToDate - - 'PresupuestoEgresos - Dim DtPresupuestosTemp As DataTable - Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer - - 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double - tTotalIVA = TxtIVA.Text.ToDecimal - tRetIVA = TxtRetIVA.Text.ToDecimal - tRetISR = TxtRetISR.Text.ToDecimal - - 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR - - tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA - tDiferenciaIVA = tTotalIVA - tIVA = 0 - ipresup = 0 - - 'INVENTARIOS EN AC - Dim CuentaMatrizAlmacen As Integer - Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) - - 'COMENTADO 15/3/2016 - 'cuando hay algo que ingresar a inventarios - 'Dim x As Integer = 0 - 'For Each Dr As DataRow In TmpDT.Rows - ' If GvInv.Rows.Count > 0 Then - ' If GvInv.Rows(x).FCCheckBox("cbInv").Checked Then - ' Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero - ' Else 'limpio el valor para que no truene en linq mas abajo - ' Dr("CveAlmacen") = 0 - ' End If - ' x = x + 1 - ' Else - ' Exit For - ' End If - 'Next - - ''previamente si hay un ingreso a inventarios - 'Dim CtaAlmacen As Integer - 'If ContadorInventario > 0 Then - ' Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", TmpDT.Rows(0)("CveAlmacen").ToString)) - ' If drr IsNot Nothing Then - ' CtaAlmacen = drr("IdCtaContable").ToString.ToEntero - ' End If - 'End If - - Dim CtaAlmacen As Integer - If ContadorInventario > 0 Then - Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) - If drr IsNot Nothing Then - CtaAlmacen = drr("IdCtaContable").ToString.ToEntero - End If - End If - Dim DescuentoConIVA As Double - Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) - Dim tAjusteTotal As Decimal = 0 - - For Each grp In Presup - Importe = grp.TotalImporte - TotalDetalle += Importe - ipresup += 1 - If Importe > 0 Then - 'saco la proporcion de iva que le corresponde - tIVA = Math.Round(Importe * tPorIVA, 2) - tDiferenciaIVA -= tIVA - 'identifico si es el ultimo registro, para ver si es necesario un ajuste - If ipresup = Presup.Count Then - If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then - tIVA += tDiferenciaIVA - End If - End If - - 'le sumo el iva al concepto - Importe += tIVA - 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF - If TxtDescuento.Text.ToDouble > 0 Then - Importe = grp.TotalImporte * (1 + tPorIVA) - End If - - tAjusteTotal += Importe - - 'valido que la sumas de lo detalles no exceda al totalgeneral - If Math.Round(tAjusteTotal, 2) > tTotalGral Then - 'le resto la diferencia - Importe -= (tAjusteTotal - tTotalGral) - End If - - 'Presupuesto Egresos - DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) - If DtPresupuestosTemp.Rows.Count <> 1 Then - ErrorAC = True - Exit For - End If - IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero - IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero - IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero - IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero - - 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA - If IDPolizaComprometido = 0 Then - ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - End If - - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - 'DEVENGADO - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - - - If ContadorInventario > 0 Then - Dim tImporte, ttIVA As Double - - For Each gvr As GridViewRow In GvPS.Rows - 'registra los movimientos del presupuesto asignado, para que no se duplique si hay varios presupeusto dentro de la compra - If gvr.DataKey("CvePresupuestoEgreso").ToEntero = grp.CvePresupuestoEgreso Then - 'saco la proporcion de iva que le corresponde - - tImporte = gvr.FCLiteral("LtlTotal").Text.ToDouble - - ttIVA = Math.Round(tImporte * tTotalIVA / tTotalGral, 2) - ' tDiferenciaIVA -= tIVA - ' 'identifico si es el ultimo registro, para ver si es necesario un ajuste - ' If ipresup = GvPS.Rows.Count Then - ' If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then - ' tIVA += tDiferenciaIVA - ' End If - ' End If - - ' ' 'le sumo el iva al concepto - tImporte += ttIVA - - 'PU = tImporte / gvr.DataKey("Cantidad").ToDouble - 'If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, gvr.DataKey("Cantidad").ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1) Then - ' ErrorAC = True - ' Exit For - 'End If - End If - - Next - - CuentaMatrizAlmacen = CtaAlmacen - - ElseIf grp.CveActivoFijo > 0 Then - - Dim CtaAF = -1 - Dim AF = "" - Dim CuentaInicial = -1 - - If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then - CtaAF = ObjAF.Cuenta - AF = ObjAF.Descripcion - CuentaInicial = ObjAF.CuentaInicial - Else - ErrorAC = True - Exit For - End If - - If Not CuentaInicial > 0 Then - CuentaInicial = 1241 - End If - - 'CUENTA AF - If CtaAF <= 0 Then - If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString - CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) - - ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - CuentaMatrizAlmacen = CtaAF - Else - CuentaMatrizAlmacen = IdCuentaMatriz - End If - - - ''AFECTAR MATRIZ EGRESOS - If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - - ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) - If TxtDescuento.Text.ToDouble > 0 AndAlso CtaProveedorAnticipos > 0 Then - DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16 - - 'Valida que el descuento con iva cuadre en los totales - If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then - DescuentoConIVA = Importe - TxtTotal.Text.ToDouble - ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then - ErrorAC = True - Exit For - End If - - 'actualizo el idcuenta del presupuesto - If ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then - 'agrego a la cuenta contable anticipos - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - Else - 'actualizo el idcuenta del - - End If - - Else - ErrorAC = True - Exit For - End If - ''TERMINA AFECTAR MATRIZ EGRESOS - - Else - ErrorAC = True - Exit For - End If - - Next - - If Not ErrorAC Then - 'registro un solo movimiento a proveedores - Importe = TxtTotal.Text.ToDecimal - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - End If - End If - - If tRetISR > 0 Then - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - End If - End If - - End If - - Else - ErrorAC = True - End If - - 'CUADRA LA POLIZA - ObjContaAC.AjustaPoliza(IdPoliza) - - End If - ''TERMINA: SI USA AC - - - - If Not ErrorAC Then - Dim Cont As Integer = 0 - For Each Row As DataRow In TmpDT.Rows - - 'actualizar las clasificaciones, que se hallan hecho - If Row("CveClasificacionActualizar").ToString.ToEntero > 0 Then - 'REGISTRO EL PRODUCTO - Dim PSS As New ClsProductosServicios - If Not PSS.UpdateClasificacionPS(Row("CveClasificacionActualizar").ToString.ToEntero, UsuarioActual.CveUsuario, Row("CvePS").ToString.ToEntero) Then - Retorno = False - Exit For - End If - 'Row("CvePS") = 20184 'PSS.DtResultados.FiltraParametros("PS = '" & Row("PS").ToString & "' AND CveEmpresa = " & UsuarioActual.CveEmpresa).Rows(0)("CvePS").ToString - PSS.Dispose() - End If - - Dim CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero - Dim Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text - - Cont = Cont + 1 - 'Si es AF-INSUMO se guarda en CveActivoFIjo - Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) - - 'Si es AF-COMPRA se guarda en CveActivoFijoCompra - Dim CveAFCompra = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) - - If Not ObjCompra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, - Row("Descuento").ToString.ToDouble, Row("Obs").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, CveAF, Row("CveCompraDetalle").ToString.ToEntero, CvePersonal:=CvePersonal, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, - RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble, - IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False)) Then - - Retorno = False - Exit For - End If - - 'If Not ObjCompra.VerificaPrepolizas(UsuarioActual.CveEmpresa, CveCompra) Then - ' Retorno = False - 'End If - - If Retorno Then - 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF - If Row("TipoAF").ToString.ToEntero = 2 Then - If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, Row("CveCompraDetalle").ToString.ToEntero, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then - Retorno = False - Exit For - End If - End If - End If - - - Next - - For Each item As String In ClavesBorradas - Dim ObjCompras As New ClsCompras - If Not ObjCompras.DeleteCompraDetalle(item.ToEntero) Then - Retorno = False - End If - Next - - If Retorno Then - If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IdPoliza > 0 Then - If ObjContaAC Is Nothing Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - End If - - If Not ObjContabilidad.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa, UsuarioActual.Empresa, MinFecha, String.Format("{0}-{1}", Serie, Folio), ObjContaAC, pIDPoliza:=ViewState("IdPoliza").ToString.ToEntero) Then - Retorno = False - End If - - End If - End If - - - - Else - Retorno = False - End If - - 'Retorno = True - 'Alert("La Compra se actualizó correctamente.") - Else - - If IdPoliza > 0 Then - If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then - Retorno = False - End If - - If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, IdPoliza, CvePrePoliza, UsuarioActual.CveEmpresa) Then - Retorno = False - End If - End If - - End If - - Else - Retorno = False - End If - - Else - - Alert("La compra no se puede actualizar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError) - - End If - Catch ex As Exception - Alert("Ocurrió un error al actualizar la compra", TipoMensaje.MsgError) - ObjCompra.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - - Finally - If Retorno Then - If ObjContabilidad.MensajePolizaDescuadre IsNot Nothing AndAlso ObjContabilidad.MensajePolizaDescuadre.ToString <> "" Then - Alert(ObjContabilidad.MensajePolizaDescuadre.ToString) - End If - ObjCompra.Commit() - If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() - Dim Msg As New StringBuilder() - - Msg.Append("La Compra se actualizó correctamente") - - Alert(Msg.ToString()) - Else - ObjCompra.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("Ocurrió un error al actualizar la compra, por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - - If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - - End Try - - ObjCompra.Dispose() - ObjProveedores.Dispose() - ObjInventario.Dispose() - ObjContabilidad.Dispose() - ObjAF.Dispose() - If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - - CargaGvBitacora() - UpBitacora.Update() - End Sub - - Private Function ComparaDatatables() As Boolean - Dim NumRow As Integer = 0 - For Each row1 As DataRow In TmpDT.Rows - Dim NumRow2 As Integer = 0 - For Each row2 As DataRow In TmpDTOriginal.Rows - If NumRow2 = NumRow Then - If (row1("CveSubProyecto").ToString.ToEntero <> row2("CveSubProyecto").ToString.ToEntero) Or - (row1("CveClasificacion").ToString.ToEntero <> row2("CveClasificacion").ToString.ToEntero) Or - (row1("CveTipoGasto").ToString.ToEntero <> row2("CveTipoGasto").ToString.ToEntero) Or - (row1("Total").ToString.ToDouble <> row2("Total").ToString.ToDouble) Or - (row1("NoDeducible").ToString <> row2("NoDeducible").ToString) Or - (row1("CvePS").ToString.ToEntero <> row2("CvePS").ToString.ToEntero) Then - Return False - End If - End If - NumRow2 += 1 - Next - NumRow += 1 - Next - Return True - End Function - - Private Function ActualizarPrePoliza(ObjConta As ClsContabilidad, ObjCompra As ClsCompras) As Boolean - - Dim Retorno = True, ErrorPrepoliza = False - Dim CvePlantillaPrePoliza As Integer - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - CvePlantillaPrePoliza = 60 - Else - CvePlantillaPrePoliza = 1 - End If - Dim tIdContaProveedor As Integer = CtaProveedor - Dim ImporteAnticipo As Decimal = 0 - - - If (ArrAnticipos.Count > 0 And CveCompra > 0) Or (ArrAnticipos.Count > 0 And UsuarioActual.Empresa.UsaAC) Then '-- ESTO SE QUITO - IPP - 04 NOVIMEBRE 2016 - CvePlantillaPrePoliza = 52 - 'cuenta de anticipos - tIdContaProveedor = CtaProveedorAnticipos - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - ImporteAnticipo += Ant.Importe - Next - If Math.Round(ImporteAnticipo, 2) > TxtTotal.Text.ToDouble Then - Alert("El Importe seleccionado es mayor a la compra", TipoMensaje.MsgAdvertencia) - Return False - End If - - End If - - If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then - If EmpresaPrueba Then - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - CvePlantillaPrePoliza = 60 - Else - CvePlantillaPrePoliza = 1 - End If - Else - CvePlantillaPrePoliza = 9 - End If - End If - - - - Dim CveMovimientoInventario As Integer = CveMovimientoAlmacen - - - Dim DT As DataTable - Dim tipoCambioActual, tipoCambioPago As Decimal - Dim FechaMovimiento As Date = TxtFecha.Text.ToDate - - - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then - tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal - tipoCambioActual = If(DivTC.Visible Or TipoCambio.ToDecimal > 0, TipoCambio.ToDecimal, tipoCambioActual) - tipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal - Else - tipoCambioActual = 1 - tipoCambioPago = 1 - End If - - If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then - For Each Row As DataRow In ObjConta.DtResultados.Rows - - Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero - Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) - Dim importeMovimiento As Decimal = 0 - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - Dim importeMN As Decimal = 0 - Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) - Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation - - Select Case ConceptoContable - 'Case 5 - ' IdCtaContable = 1244 - ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 5, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then - ' ErrorPrepoliza = True - ' End If - ' IdCtaContable = 1243 - ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 205, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then - ' ErrorPrepoliza = True - ' End If - Case 6 - Dim CveProveedorConcepto As Integer = 0, CveAcreedor As Integer = 0, CveIE As Integer = 0, CveColectiva As Integer = 0, CveCreditoDetalle As Integer = 0 - Dim ConceptoPersonal As String = "", Concepto As String = "" - - If Not ObjConta.GetPrePolizasDetalle(CvePrePoliza) Then - ErrorPrepoliza = True - Else - If ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176)").Rows.Count > 0 Then - CveProveedorConcepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveProveedor").ToString.ToEntero - CveAcreedor = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveAcreedor").ToString.ToEntero - CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero - CveColectiva = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveColectiva").ToString.ToEntero - CveCreditoDetalle = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveCreditoDetalle").ToString.ToEntero - Concepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("Concepto").ToString - End If - End If - - If CveProveedorConcepto <= 0 Then - CveProveedorConcepto = DdlProveedor.SelectedValue.ToEntero - End If - - 'Removemos los conceptos de la prepoliza - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) 'GASTO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) 'ALMACEN - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) 'AF - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 205, CveCompra, 1) 'PS YA RECIBIDO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 230, CveCompra, 1) 'PS YA RECIBIDO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 231, CveCompra, 1) 'PS YA RECIBIDO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 176, CveCompra, 1) 'PS NO RECIBIDO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 228, CveCompra, 1) 'PS NO RECIBIDO - ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 229, CveCompra, 1) 'PS NO RECIBIDO - - 'OBTIENE METODO DE CONTABILIZACIÓN AL GUARDAR - Dim ConceptoContabilizacionAlmacen = 0 - If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - ConceptoContabilizacionAlmacen = ObjCompra.DtResultados.FiltroPrimeroValor("CveConceptoContableAlmacen").ToEntero - End If - - 'AF - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2") - If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" And ConceptoContabilizacionAlmacen = 0 Then - For Each Row2 As DataRow In DT.Rows - importeMovimiento = Row2("Total").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero - End If - End If - - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If - End If - Next - End If - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - 'COSTO ALMACEN - Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen = 0 Then - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - For Each Dr As DataRow In DT.Rows - If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then - Dr("CveAlmacen") = 0 - End If - Dr.AcceptChanges() - Next - DT.AcceptChanges() - DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") - If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - For Each Row2 As DataRow In DT.Rows - - importeMovimiento = TmpDT.SUM("Total", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero - End If - End If - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If - End If - Next - End If - End If - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] - If UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen.Contiene(176, 205) Then - importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If ObjConta.GetRetCuenta(ConceptoContabilizacionAlmacen, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - End If - - If importeMovimiento <> 0 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionAlmacen, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If - End If - - End If - - 'NC CON PRODUCTOS - CUENTA PUENTE - - If UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen.Contiene(225) Then - importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If ObjConta.GetRetCuenta(ConceptoContabilizacionAlmacen, UsuarioActual.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - End If - - If importeMovimiento <> 0 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionAlmacen, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If - End If - End If - - - 'GASTO - DT = TmpDT.Copy - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - For Each Dr As DataRow In DT.Rows - If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then - Dr("CveAlmacen") = 0 - End If - Dr.AcceptChanges() - Next - DT.AcceptChanges() - DtAlmacenes.Dispose() - - 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] - If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen > 0 Then - DT = DT.FiltraParametros("CveTipoPS <> 2") - End If - - Dim DTDistinct = DT.Copy - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - Else - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - End If - - If DTDistinct.Rows.Count > 0 Then - For Each Row2 As DataRow In DTDistinct.Rows - - 'DETERMINA IMPORTE - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - Else - importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - End If - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - 'CLASIFICACION - If Row2("CveClasificacion").ToString.ToEntero > 0 Then - If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - End If - End If - End If - - 'SEGMENTO DE NEGOCIO - Dim IdSegmentoNegocio As Integer = -1 - Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) - If drT IsNot Nothing Then - IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero - End If - - 'AGREGA MOVIMIENTO - If importeMovimiento <> 0 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then - ErrorPrepoliza = True - End If - End If - - Next - End If - - 'LIMPIA - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - End Select - - Next - End If - - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - ErrorPrepoliza = True - GuardaLogAD($"Compras/Compras-Actualizar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - End If - End If - - If Not ErrorPrepoliza Then - Retorno = True - Else - Retorno = False - End If - - Return Retorno - End Function - - Protected Sub ImgActualizarProyecto_Click(sender As Object, e As EventArgs) Handles ImgActualizarProyecto.Click - 'actualizo los proyectos - Dim Compra As New ClsCompras - Dim Retorno As Boolean = True - Compra.IniciaTransacSQL() - - For Each Row As DataRow In TmpDT.Rows - - If Not Compra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, - Row("Descuento").ToString.ToDouble, Row("Observaciones").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, -2, Row("CveCompraDetalle").ToString.ToEntero, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero) Then - - Retorno = False - Exit For - End If - Next - - If Retorno Then - Compra.Commit() - Alert("La Compra se actualizó correctamente.") - Else - Compra.RollBack() - End If - - - Compra.Dispose() - - - End Sub - - Protected Sub BtnVerAmortizacion_Click(sender As Object, e As EventArgs) Handles BtnVerAmortizacion.Click - BtnVerAmortizacion.Visible = False - 'BtnAmortizar.Visible = True - 'activo el cuadro para amortizar - - RBLPago.SelectedValue = "2" ' selecciono contado - PnlContado.Visible = True - PnlContadoBancos.Visible = False - RBLContado.Items.Clear() - RBLContado.Items.Add(New ListItem("Deudores", "4")) - - RBLContado.SelectedValue = "4" 'selecciono deudores - PnlContadoDeudores.Visible = True - CargaDeudores() - End Sub - - Protected Sub ImgAjusteSobreTotal_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAjustaSobreTotal.Click - 'realizo el ajuste de los productos - 'total - iva - Dim Diferencia As Decimal = TxtTotal.Text.ToDecimal() - TxtIVA.Text.ToDecimal + TxtRetIVA.Text.ToDecimal + TxtRetISR.Text.ToDecimal - (TxtSubTotal2.Text.ToDecimal) - - AjustaImporteUltimoConcepto(Diferencia) - BtnGuardar.Enabled = True - UpFacturar.Update() - + UpPS.Update() + End If + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAnticipos")) + Else + Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia) + End If + UPPAnticiposSel.Update() End Sub -#End Region -#Region "CargaXML" + Protected Sub ImgClasificacion_Click(sender As Object, e As EventArgs) Handles ImgClasificacion.Click - Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String - Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) - If o Is Nothing Then - Return Retorno - Else - Return o.Value - End If - End Function - - Private Sub CargaComprobanteXML(XMLDoc As XmlDocument) - Dim nodo As XmlNode = XMLDoc.DocumentElement - - _Serie = ValorXML(nodo, "serie") - If _Serie <> "" Then _Serie = _Serie - - Version = ValorXML(nodo, "version") - _Folio = ValorXML(nodo, "folio") - _Fecha = ValorXML(nodo, "fecha") - SubTotal = ValorXML(nodo, "subTotal").ToDecimal - Total = ValorXML(nodo, "total").ToDecimal - Descuentos = ValorXML(nodo, "descuento").ToDecimal - _Moneda = ValorXML(nodo, "Moneda") - _TipoComprobante = ValorXML(nodo, "tipoDeComprobante") - TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDouble - - If Version = "3.3" Then - Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) - If drm IsNot Nothing Then - CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero - MetodoPago = drm("MetodoPagoSAT").ToString - End If - End If - - - Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) - Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" - Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) - - If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" - namespaces.AddNamespace(Prefijo, cfdVer) - namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") - namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") - namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") - - Dim node As XmlNode - node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) - - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - EmisorRFC = ValorXML(node, "RFC") - 'EmisorNombre = ValorXML(node, "nombre") - End If - - node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + If CveCompra > 0 Then + + Dim SiSelecciono As Boolean = False + For Each gvr As GridViewRow In GvPS.Rows + If gvr.FCCheckBox("CheckClasificacion").Checked = True Then + SiSelecciono = True + Exit For + End If + Next + If SiSelecciono = False Then + Alert("Tiene que seleccionar algun Producto o Servicio", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + DdlAplicaClasificacion.SelectedValue = "-1" + RegistraScript(String.Format("$('#{0}').modal('show');", "DivClasificacion")) + Else + RegistraScript(String.Format("$('#{0}').modal('show');", "DivClasificacion")) + End If + + End Sub + + Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs) Handles BtnActualizar.Click + + 'VALIDA IMPORTES + If CveFactura > 0 Then 'SI NO VIENE DE FACTURA/XML NO VALIDA TOTALES + If Not ValidaTotalesGuardar() Then + Exit Sub + End If + End If + + For Each Row As DataRow In TmpDT.Rows + If Row("CveSubProyecto").ToString.ToEntero <= 0 Then + Alert("No se ha completado la asignacion de proyectos en la compra. ", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then 'If NotHas117 AndAlso Row("CveClasificacionActualizar").ToString.ToEntero <= 0 Then + Alert("Hay productos que no tienen clasificación asignada.
Favor de asignarle una y darle guardar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then + If Row("CveTipoGasto").ToString.ToEntero <= 0 Then + Alert("No se ha completado la asignacion de tipos de gasto en la compra.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + Next + + + Dim ObjCompra As New ClsCompras + Dim ObjProveedores As New ClsCompProveedores(ObjCompra.IniciaTransacSQL()) + Dim ObjInventario As New ClsInventarios(ObjCompra.IniciaTransacSQL) + Dim ObjContabilidad As New ClsContabilidad(ObjCompra.IniciaTransacSQL) + Dim ObjAF As New ClsAF(ObjCompra.IniciaTransacSQL) + Dim ObjContaAC As ClsContPAQi = New ClsContPAQi(UsuarioActual.Empresa) + + Dim Retorno As Boolean = True + Dim CveEstatusFactura As Integer = HdnCveEstatusFactura.Value.ToEntero + Dim MultiplicadorNC = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) + + Dim ErrorAC = False + Dim IDPolizaComprometido = 0 + + If ChkProgramarPago.Checked AndAlso CveEstatusFactura = 1 Then + CveEstatusFactura = 2 + End If + If Not ChkProgramarPago.Checked AndAlso CveEstatusFactura = 2 Then + CveEstatusFactura = 1 + End If + Try + 'Revisamos que los cambios hechos mantengan la interidad de los numeros + If HFDiferenciaCompra.Value = TxtTotal.Text Or CveFactura < 1 Or CveCompra < 1 Then + + If IdPoliza > 0 Then + If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + Retorno = False + End If + + If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, Nothing, CvePrePoliza, UsuarioActual.CveEmpresa) Then + Retorno = False + End If + End If + + 'PORCENTAJE IVA + Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + + If ObjCompra.UpdateCompra(TxtDescripcion.Text.Trim, TxtFolioSecundario.Text.Trim, TxtFechaPago.Text.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura, + TxtDescuento.Text.ToDouble, TxtSubTotal.Text.ToDouble, TxtIVA.Text.ToDouble, TxtTotal.Text.ToDouble, + UsuarioActual.CveUsuario, CveCompra, CveCajaChica:=DdlRembolsoCajaChica.SelectedValue.ToEntero, CvePersonal:=DdlRembolsoPersonal.SelectedValue.ToEntero, CveProveedorSucursal:=If(DdlProveedorSucursal.SelectedValue.ToEntero > 0, DdlProveedorSucursal.SelectedValue.ToEntero, -1), PorcentajeIVA:=PorcentajeIVA, NumeroReembolso:=TxtRembolsoNumero.Text, + CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero, NoDeducible:=EsNoDeducible) Then + + If Not ComparaDatatables() Then + + 'Regeneramos el concepto 6 de PrePolizas + 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then + ' If Not RegenerarPrePoliza(ObjContabilidad, ObjContaAC, 6, False, MultiplicadorNC) Then + ' Retorno = False + ' End If + 'End If + + + + 'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then + If Not ActualizarPrePoliza(ObjContabilidad, ObjCompra) Then + Retorno = False + End If + 'End If + + ''EMPIEZA: SI USA AC + If UsuarioActual.Empresa.UsaAC AndAlso IdPoliza > 0 Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + + + 'ELIMINA TODOS LOS MOVIMIENTOS DE LA POLIZA + ObjContaAC.RemoveAllMovimientos(IdPoliza) + + + 'INSERTA LOS NUEVOS MOVIMIENTOS DE LA POLIZA + If IdPoliza > 0 Then + Dim CuentaAbono As Integer + Dim Importe As Decimal = 0 + Dim TotalDetalle As Decimal = 0 + + 'CUENTA PROVEEDOR + If CtaProveedor <= 0 Then + If ObjContaAC.GetCuentas(-1, "021120000000000000", -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021120000000000000").ToString + ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02112{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) + ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + Dim ConceptoRenglon As String = "" + If Not ErrorAC Then + + Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal + + Dim ipresup As Integer = 0 + + 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS + Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() + Group gvr By Grp = New With { + Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, + Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) + } Into Group + Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, + TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) + Dim Fecha As Date = TxtFecha.Text.ToDate + + 'PresupuestoEgresos + Dim DtPresupuestosTemp As DataTable + Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer + + 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double + tTotalIVA = TxtIVA.Text.ToDecimal + tRetIVA = TxtRetIVA.Text.ToDecimal + tRetISR = TxtRetISR.Text.ToDecimal + + 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR + + tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA + tDiferenciaIVA = tTotalIVA + tIVA = 0 + ipresup = 0 + + 'INVENTARIOS EN AC + Dim CuentaMatrizAlmacen As Integer + Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) + + 'COMENTADO 15/3/2016 + 'cuando hay algo que ingresar a inventarios + 'Dim x As Integer = 0 + 'For Each Dr As DataRow In TmpDT.Rows + ' If GvInv.Rows.Count > 0 Then + ' If GvInv.Rows(x).FCCheckBox("cbInv").Checked Then + ' Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero + ' Else 'limpio el valor para que no truene en linq mas abajo + ' Dr("CveAlmacen") = 0 + ' End If + ' x = x + 1 + ' Else + ' Exit For + ' End If + 'Next + + ''previamente si hay un ingreso a inventarios + 'Dim CtaAlmacen As Integer + 'If ContadorInventario > 0 Then + ' Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", TmpDT.Rows(0)("CveAlmacen").ToString)) + ' If drr IsNot Nothing Then + ' CtaAlmacen = drr("IdCtaContable").ToString.ToEntero + ' End If + 'End If + + Dim CtaAlmacen As Integer + If ContadorInventario > 0 Then + Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) + If drr IsNot Nothing Then + CtaAlmacen = drr("IdCtaContable").ToString.ToEntero + End If + End If + Dim DescuentoConIVA As Double + Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) + Dim tAjusteTotal As Decimal = 0 + + For Each grp In Presup + Importe = grp.TotalImporte + TotalDetalle += Importe + ipresup += 1 + If Importe > 0 Then + 'saco la proporcion de iva que le corresponde + tIVA = Math.Round(Importe * tPorIVA, 2) + tDiferenciaIVA -= tIVA + 'identifico si es el ultimo registro, para ver si es necesario un ajuste + If ipresup = Presup.Count Then + If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then + tIVA += tDiferenciaIVA + End If + End If + + 'le sumo el iva al concepto + Importe += tIVA + 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF + If TxtDescuento.Text.ToDouble > 0 Then + Importe = grp.TotalImporte * (1 + tPorIVA) + End If + + tAjusteTotal += Importe + + 'valido que la sumas de lo detalles no exceda al totalgeneral + If Math.Round(tAjusteTotal, 2) > tTotalGral Then + 'le resto la diferencia + Importe -= (tAjusteTotal - tTotalGral) + End If + + 'Presupuesto Egresos + DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) + If DtPresupuestosTemp.Rows.Count <> 1 Then + ErrorAC = True + Exit For + End If + IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero + IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero + IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero + IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero + + 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA + If IDPolizaComprometido = 0 Then + ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + End If + + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + 'DEVENGADO + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + + + If ContadorInventario > 0 Then + Dim tImporte, ttIVA As Double + + For Each gvr As GridViewRow In GvPS.Rows + 'registra los movimientos del presupuesto asignado, para que no se duplique si hay varios presupeusto dentro de la compra + If gvr.DataKey("CvePresupuestoEgreso").ToEntero = grp.CvePresupuestoEgreso Then + 'saco la proporcion de iva que le corresponde + + tImporte = gvr.FCLiteral("LtlTotal").Text.ToDouble + + ttIVA = Math.Round(tImporte * tTotalIVA / tTotalGral, 2) + ' tDiferenciaIVA -= tIVA + ' 'identifico si es el ultimo registro, para ver si es necesario un ajuste + ' If ipresup = GvPS.Rows.Count Then + ' If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then + ' tIVA += tDiferenciaIVA + ' End If + ' End If + + ' ' 'le sumo el iva al concepto + tImporte += ttIVA + + 'PU = tImporte / gvr.DataKey("Cantidad").ToDouble + 'If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, gvr.DataKey("Cantidad").ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1) Then + ' ErrorAC = True + ' Exit For + 'End If + End If + + Next + + CuentaMatrizAlmacen = CtaAlmacen + + ElseIf grp.CveActivoFijo > 0 Then + + Dim CtaAF = -1 + Dim AF = "" + Dim CuentaInicial = -1 + + If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then + CtaAF = ObjAF.Cuenta + AF = ObjAF.Descripcion + CuentaInicial = ObjAF.CuentaInicial + Else + ErrorAC = True + Exit For + End If + + If Not CuentaInicial > 0 Then + CuentaInicial = 1241 + End If + + 'CUENTA AF + If CtaAF <= 0 Then + If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString + CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) + + ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + CuentaMatrizAlmacen = CtaAF + Else + CuentaMatrizAlmacen = IdCuentaMatriz + End If + + + ''AFECTAR MATRIZ EGRESOS + If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + + ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) + If TxtDescuento.Text.ToDouble > 0 AndAlso CtaProveedorAnticipos > 0 Then + DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16 + + 'Valida que el descuento con iva cuadre en los totales + If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then + DescuentoConIVA = Importe - TxtTotal.Text.ToDouble + ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then + ErrorAC = True + Exit For + End If + + 'actualizo el idcuenta del presupuesto + If ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then + 'agrego a la cuenta contable anticipos + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + Else + 'actualizo el idcuenta del + + End If + + Else + ErrorAC = True + Exit For + End If + ''TERMINA AFECTAR MATRIZ EGRESOS + + Else + ErrorAC = True + Exit For + End If + + Next + + If Not ErrorAC Then + 'registro un solo movimiento a proveedores + Importe = TxtTotal.Text.ToDecimal + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + End If + End If + + If tRetISR > 0 Then + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + End If + End If + + End If + + Else + ErrorAC = True + End If + + 'CUADRA LA POLIZA + ObjContaAC.AjustaPoliza(IdPoliza) + + End If + ''TERMINA: SI USA AC + + + + If Not ErrorAC Then + Dim Cont As Integer = 0 + For Each Row As DataRow In TmpDT.Rows + + 'actualizar las clasificaciones, que se hallan hecho + If Row("CveClasificacionActualizar").ToString.ToEntero > 0 Then + 'REGISTRO EL PRODUCTO + Dim PSS As New ClsProductosServicios + If Not PSS.UpdateClasificacionPS(Row("CveClasificacionActualizar").ToString.ToEntero, UsuarioActual.CveUsuario, Row("CvePS").ToString.ToEntero) Then + Retorno = False + Exit For + End If + 'Row("CvePS") = 20184 'PSS.DtResultados.FiltraParametros("PS = '" & Row("PS").ToString & "' AND CveEmpresa = " & UsuarioActual.CveEmpresa).Rows(0)("CvePS").ToString + PSS.Dispose() + End If + + Dim CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero + Dim Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text + + Cont = Cont + 1 + 'Si es AF-INSUMO se guarda en CveActivoFIjo + Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1) + + 'Si es AF-COMPRA se guarda en CveActivoFijoCompra + Dim CveAFCompra = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1) + + If Not ObjCompra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, + Row("Descuento").ToString.ToDouble, Row("Obs").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, CveAF, Row("CveCompraDetalle").ToString.ToEntero, CvePersonal:=CvePersonal, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, + RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble, + IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1")) AndAlso EsNoDeducible, True, False)) Then + + Retorno = False + Exit For + End If + + 'If Not ObjCompra.VerificaPrepolizas(UsuarioActual.CveEmpresa, CveCompra) Then + ' Retorno = False + 'End If + + If Retorno Then + 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF + If Row("TipoAF").ToString.ToEntero = 2 Then + If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, Row("CveCompraDetalle").ToString.ToEntero, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then + Retorno = False + Exit For + End If + End If + End If + + + Next + + For Each item As String In ClavesBorradas + Dim ObjCompras As New ClsCompras + If Not ObjCompras.DeleteCompraDetalle(item.ToEntero) Then + Retorno = False + End If + Next + + If Retorno Then + If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IdPoliza > 0 Then + If ObjContaAC Is Nothing Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + End If + + If Not ObjContabilidad.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa, UsuarioActual.Empresa, MinFecha, String.Format("{0}-{1}", Serie, Folio), ObjContaAC, pIDPoliza:=ViewState("IdPoliza").ToString.ToEntero) Then + Retorno = False + End If + + End If + End If + + + + Else + Retorno = False + End If + + 'Retorno = True + 'Alert("La Compra se actualizó correctamente.") + Else + + If IdPoliza > 0 Then + If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then + Retorno = False + End If + + If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, IdPoliza, CvePrePoliza, UsuarioActual.CveEmpresa) Then + Retorno = False + End If + End If + + End If + + Else + Retorno = False + End If + + Else + + Alert("La compra no se puede actualizar debido a que los totales no son iguales, verifique sus cambios", TipoMensaje.MsgError) + + End If + Catch ex As Exception + Alert("Ocurrió un error al actualizar la compra", TipoMensaje.MsgError) + ObjCompra.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + + Finally + If Retorno Then + If ObjContabilidad.MensajePolizaDescuadre IsNot Nothing AndAlso ObjContabilidad.MensajePolizaDescuadre.ToString <> "" Then + Alert(ObjContabilidad.MensajePolizaDescuadre.ToString) + End If + ObjCompra.Commit() + If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() + Dim Msg As New StringBuilder() + + Msg.Append("La Compra se actualizó correctamente") + + Alert(Msg.ToString()) + Else + ObjCompra.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("Ocurrió un error al actualizar la compra, por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + + If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + + End Try + + ObjCompra.Dispose() + ObjProveedores.Dispose() + ObjInventario.Dispose() + ObjContabilidad.Dispose() + ObjAF.Dispose() + If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + + CargaGvBitacora() + UpBitacora.Update() + End Sub + + Private Function ComparaDatatables() As Boolean + Dim NumRow As Integer = 0 + For Each row1 As DataRow In TmpDT.Rows + Dim NumRow2 As Integer = 0 + For Each row2 As DataRow In TmpDTOriginal.Rows + If NumRow2 = NumRow Then + If (row1("CveSubProyecto").ToString.ToEntero <> row2("CveSubProyecto").ToString.ToEntero) Or + (row1("CveClasificacion").ToString.ToEntero <> row2("CveClasificacion").ToString.ToEntero) Or + (row1("CveTipoGasto").ToString.ToEntero <> row2("CveTipoGasto").ToString.ToEntero) Or + (row1("Total").ToString.ToDouble <> row2("Total").ToString.ToDouble) Or + (row1("NoDeducible").ToString <> row2("NoDeducible").ToString) Or + (row1("CvePS").ToString.ToEntero <> row2("CvePS").ToString.ToEntero) Then + Return False + End If + End If + NumRow2 += 1 + Next + NumRow += 1 + Next + Return True + End Function + + Private Function ActualizarPrePoliza(ObjConta As ClsContabilidad, ObjCompra As ClsCompras) As Boolean + + Dim Retorno = True, ErrorPrepoliza = False + Dim CvePlantillaPrePoliza As Integer + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + Dim tIdContaProveedor As Integer = CtaProveedor + Dim ImporteAnticipo As Decimal = 0 + + + If (ArrAnticipos.Count > 0 And CveCompra > 0) Or (ArrAnticipos.Count > 0 And UsuarioActual.Empresa.UsaAC) Then '-- ESTO SE QUITO - IPP - 04 NOVIMEBRE 2016 + CvePlantillaPrePoliza = 52 + 'cuenta de anticipos + tIdContaProveedor = CtaProveedorAnticipos + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + ImporteAnticipo += Ant.Importe + Next + If Math.Round(ImporteAnticipo, 2) > TxtTotal.Text.ToDouble Then + Alert("El Importe seleccionado es mayor a la compra", TipoMensaje.MsgAdvertencia) + Return False + End If + + End If + + If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + If EmpresaPrueba Then + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + Else + CvePlantillaPrePoliza = 9 + End If + End If + + + + Dim CveMovimientoInventario As Integer = CveMovimientoAlmacen + + + Dim DT As DataTable + Dim tipoCambioActual, tipoCambioPago As Decimal + Dim FechaMovimiento As Date = TxtFecha.Text.ToDate + + + If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then + tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal + tipoCambioActual = If(DivTC.Visible Or TipoCambio.ToDecimal > 0, TipoCambio.ToDecimal, tipoCambioActual) + tipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal + Else + tipoCambioActual = 1 + tipoCambioPago = 1 + End If + + If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then + For Each Row As DataRow In ObjConta.DtResultados.Rows + + Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero + Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False) + Dim importeMovimiento As Decimal = 0 + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim importeMN As Decimal = 0 + Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1) + Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation + + Select Case ConceptoContable + Case 5 + importeMovimiento = TxtTotal.Text.ToDecimal + importeMN = importeMovimiento * IIf(DdlMoneda.SelectedValue.ToEntero > 1, LblTC.Text.Replace("TC:", "").ToDecimal, 1D).ToString.ToDecimal + IdCtaContable = -1 '--1244 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 5, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + 'If DdlMoneda.SelectedValue.ToEntero > 1 Then + ' IdCtaContable = -1 + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 205, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then + ' ErrorPrepoliza = True + ' End If + 'End If + + Case 14 + importeMovimiento = TxtIVA.Text.ToDecimal + importeMN = importeMovimiento * IIf(DdlMoneda.SelectedValue.ToEntero > 1, LblTC.Text.Replace("TC:", "").ToDecimal, 1).ToString.ToDecimal + IdCtaContable = -1 '--1244 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 14, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + + + Case 6 + Dim CveProveedorConcepto As Integer = 0, CveAcreedor As Integer = 0, CveIE As Integer = 0, CveColectiva As Integer = 0, CveCreditoDetalle As Integer = 0 + Dim ConceptoPersonal As String = "", Concepto As String = "" + + If Not ObjConta.GetPrePolizasDetalle(CvePrePoliza) Then + ErrorPrepoliza = True + Else + If ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176)").Rows.Count > 0 Then + CveProveedorConcepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveProveedor").ToString.ToEntero + CveAcreedor = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveAcreedor").ToString.ToEntero + CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero + CveColectiva = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveColectiva").ToString.ToEntero + CveCreditoDetalle = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveCreditoDetalle").ToString.ToEntero + Concepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("Concepto").ToString + End If + End If + + If CveProveedorConcepto <= 0 Then + CveProveedorConcepto = DdlProveedor.SelectedValue.ToEntero + End If + + 'Removemos los conceptos de la prepoliza + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) 'GASTO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) 'ALMACEN + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) 'AF + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 205, CveCompra, 1) 'PS YA RECIBIDO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 230, CveCompra, 1) 'PS YA RECIBIDO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 231, CveCompra, 1) 'PS YA RECIBIDO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 176, CveCompra, 1) 'PS NO RECIBIDO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 228, CveCompra, 1) 'PS NO RECIBIDO + ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 229, CveCompra, 1) 'PS NO RECIBIDO + + 'OBTIENE METODO DE CONTABILIZACIÓN AL GUARDAR + Dim ConceptoContabilizacionAlmacen = 0 + If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + ConceptoContabilizacionAlmacen = ObjCompra.DtResultados.FiltroPrimeroValor("CveConceptoContableAlmacen").ToEntero + End If + + 'AF + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2") + If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" And ConceptoContabilizacionAlmacen = 0 Then + For Each Row2 As DataRow In DT.Rows + importeMovimiento = Row2("Total").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero + End If + End If + + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + End If + Next + End If + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + 'COSTO ALMACEN + Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen = 0 Then + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + For Each Dr As DataRow In DT.Rows + If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then + Dr("CveAlmacen") = 0 + End If + Dr.AcceptChanges() + Next + DT.AcceptChanges() + DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") + If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + For Each Row2 As DataRow In DT.Rows + + importeMovimiento = TmpDT.SUM("Total", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero + End If + End If + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + End If + Next + End If + End If + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] + If UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen.Contiene(176, 205) Then + importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If ObjConta.GetRetCuenta(ConceptoContabilizacionAlmacen, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + End If + + If importeMovimiento <> 0 Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionAlmacen, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + End If + + End If + + 'NC CON PRODUCTOS - CUENTA PUENTE + + If UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen.Contiene(225) Then + importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If ObjConta.GetRetCuenta(ConceptoContabilizacionAlmacen, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + End If + + If importeMovimiento <> 0 Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionAlmacen, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + End If + End If + End If + + + 'GASTO + DT = TmpDT.Copy + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + For Each Dr As DataRow In DT.Rows + If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then + Dr("CveAlmacen") = 0 + End If + Dr.AcceptChanges() + Next + DT.AcceptChanges() + DtAlmacenes.Dispose() + + 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] + If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And ConceptoContabilizacionAlmacen > 0 Then + DT = DT.FiltraParametros("CveTipoPS <> 2") + End If + + Dim DTDistinct = DT.Copy + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + Else + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + End If + + If DTDistinct.Rows.Count > 0 Then + For Each Row2 As DataRow In DTDistinct.Rows + + 'DETERMINA IMPORTE + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + Else + importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + End If + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + 'CLASIFICACION + If Row2("CveClasificacion").ToString.ToEntero > 0 Then + If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + End If + End If + End If + + 'SEGMENTO DE NEGOCIO + Dim IdSegmentoNegocio As Integer = -1 + Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero)) + If drT IsNot Nothing Then + IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero + End If + + 'AGREGA MOVIMIENTO + If importeMovimiento <> 0 Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then + ErrorPrepoliza = True + End If + End If + + Next + End If + + 'LIMPIA + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + End Select + + Next + End If + + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + ErrorPrepoliza = True + GuardaLogAD($"Compras/Compras-Actualizar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + End If + End If + + If Not ErrorPrepoliza Then + Retorno = True + Else + Retorno = False + End If + + Return Retorno + End Function + + Protected Sub ImgActualizarProyecto_Click(sender As Object, e As EventArgs) Handles ImgActualizarProyecto.Click + 'actualizo los proyectos + Dim Compra As New ClsCompras + Dim Retorno As Boolean = True + Compra.IniciaTransacSQL() + + For Each Row As DataRow In TmpDT.Rows + + If Not Compra.UpdateCompraDetalle(Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, + Row("Descuento").ToString.ToDouble, Row("Observaciones").ToString, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero, -2, Row("CveCompraDetalle").ToString.ToEntero, CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero) Then + + Retorno = False + Exit For + End If + Next + + If Retorno Then + Compra.Commit() + Alert("La Compra se actualizó correctamente.") + Else + Compra.RollBack() + End If + + + Compra.Dispose() + + + End Sub + + Protected Sub BtnVerAmortizacion_Click(sender As Object, e As EventArgs) Handles BtnVerAmortizacion.Click + BtnVerAmortizacion.Visible = False + 'BtnAmortizar.Visible = True + 'activo el cuadro para amortizar + + RBLPago.SelectedValue = "2" ' selecciono contado + PnlContado.Visible = True + PnlContadoBancos.Visible = False + RBLContado.Items.Clear() + RBLContado.Items.Add(New ListItem("Deudores", "4")) + + RBLContado.SelectedValue = "4" 'selecciono deudores + PnlContadoDeudores.Visible = True + CargaDeudores() + End Sub + + Protected Sub ImgAjusteSobreTotal_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAjustaSobreTotal.Click + 'realizo el ajuste de los productos + 'total - iva + Dim Diferencia As Decimal = TxtTotal.Text.ToDecimal() - TxtIVA.Text.ToDecimal + TxtRetIVA.Text.ToDecimal + TxtRetISR.Text.ToDecimal - (TxtSubTotal2.Text.ToDecimal) + + AjustaImporteUltimoConcepto(Diferencia) + BtnGuardar.Enabled = True + UpFacturar.Update() + + End Sub +#End Region + +#Region "CargaXML" + + Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String + Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) + If o Is Nothing Then + Return Retorno + Else + Return o.Value + End If + End Function + + Private Sub CargaComprobanteXML(XMLDoc As XmlDocument) + Dim nodo As XmlNode = XMLDoc.DocumentElement + + _Serie = ValorXML(nodo, "serie") + If _Serie <> "" Then _Serie = _Serie + + Version = ValorXML(nodo, "version") + _Folio = ValorXML(nodo, "folio") + _Fecha = ValorXML(nodo, "fecha") + SubTotal = ValorXML(nodo, "subTotal").ToDecimal + Total = ValorXML(nodo, "total").ToDecimal + Descuentos = ValorXML(nodo, "descuento").ToDecimal + _Moneda = ValorXML(nodo, "Moneda") + _TipoComprobante = ValorXML(nodo, "tipoDeComprobante") + TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDouble + + If Version = "3.3" Then + Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) + If drm IsNot Nothing Then + CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero + MetodoPago = drm("MetodoPagoSAT").ToString + End If + End If + + + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + + If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + Dim node As XmlNode + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + EmisorRFC = ValorXML(node, "RFC") + 'EmisorNombre = ValorXML(node, "nombre") + End If + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) node = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - ReceptorRFC = ValorXML(node, "RFC") - End If - - If UsuarioActual.CveEmpresa.Contiene(119, 7) Then - node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - If ValorXML(node, "TipoRelacion").ToString.Contiene("04", "07") Then - Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) - For Each documento As XmlNode In nodeDocumentosRelacionados - If documento.Attributes("UUID").Value <> "" Then - ListaDocumentos.Add(documento.Attributes("UUID").Value) - End If + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + ReceptorRFC = ValorXML(node, "RFC") + End If + + If UsuarioActual.CveEmpresa.Contiene(119, 7) Then + node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + If ValorXML(node, "TipoRelacion").ToString.Contiene("04", "07") Then + Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) + For Each documento As XmlNode In nodeDocumentosRelacionados + If documento.Attributes("UUID").Value <> "" Then + ListaDocumentos.Add(documento.Attributes("UUID").Value) + End If TieneAnticiposXML = True - Next - End If - End If - End If - - - node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) - - TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal - - If Version = "3.3" Then - - For Each retencion As XmlNode In nodeRetenciones - If retencion.Attributes("Impuesto").Value = "002" Then - RetencionIVA += retencion.Attributes("Importe").Value.ToDecimal - End If - If retencion.Attributes("Impuesto").Value = "001" Then - RetencionISR += retencion.Attributes("Importe").Value.ToDecimal - End If - ' Do something. - Next - GvOC1.Columns(6).Visible = True - GvOC2.Columns(4).Visible = True - Else - - For Each retencion As XmlNode In nodeRetenciones - If retencion.Attributes("impuesto").Value = "IVA" Then - RetencionIVA += retencion.Attributes("importe").Value.ToDecimal - End If - If retencion.Attributes("impuesto").Value = "ISR" Then - RetencionISR += retencion.Attributes("importe").Value.ToDecimal - End If - ' Do something. - Next - End If - SumaTotalRetenciones += RetencionIVA - SumaTotalRetenciones += RetencionISR - - TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal - Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) - - If Version = "3.3" Then - - For Each traslado As XmlNode In nodeTraslados - If traslado.Attributes("Impuesto").Value = "002" Then - TrasladoIVA += traslado.Attributes("Importe").Value.ToDecimal - End If - If traslado.Attributes("Impuesto").Value = "003" Then - TrasladoIEPS += traslado.Attributes("Importe").Value.ToDecimal - End If - If traslado.Attributes("Impuesto").Value = "001" Then - 'TrasladoISR = traslado.Attributes("importe").Value - End If - ' Do something. - Next - - Else - - For Each traslado As XmlNode In nodeTraslados - If traslado.Attributes("impuesto").Value = "IVA" Then - TrasladoIVA += traslado.Attributes("importe").Value.ToDecimal - End If - If traslado.Attributes("impuesto").Value = "IEPS" Then - TrasladoIEPS += traslado.Attributes("importe").Value.ToDecimal - End If - 'If traslado.Attributes("impuesto").Value = "ISR" Then - ' TrasladoISR = traslado.Attributes("importe").Value - 'End If - ' Do something. - Next - End If - - SumaTotalTraslados += TrasladoIVA - SumaTotalTraslados += TrasladoIEPS - End If - - Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - - Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) - - _TFDUUID = ValorXML(nodeTFD, "UUID", "") - - Dim nodeRF As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CFDIRegistroFiscal ", "registrofiscal"), namespaces) - If nodeRF IsNot Nothing Then - _Folio = ValorXML(nodeRF, "folio").TrimStart("0"c) - End If - - node = node.SelectSingleNode(String.Format("//{0}:ImpuestosLocales", "implocal"), namespaces) - - - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - OtrosImpuestos = ValorXML(node, "TotaldeTraslados", "0").ToDecimal - OtrosImpuestosRetenciones = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal - - 'If RetencionIVA <= 0 AndAlso ValorXML(node, "TotaldeRetenciones", "0").ToDouble > 0 Then RetencionIVA = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal - - 'For Each retencion As XmlNode In nodeImpLocales - ' If retencion.Attributes("impuesto").Value = "IVA" Then - ' RetencionIVA += retencion.Attributes("importe").Value.ToDouble - ' End If - ' If retencion.Attributes("impuesto").Value = "ISR" Then - ' RetencionISR += retencion.Attributes("importe").Value.ToDouble - ' End If - ' ' Do something. - 'Next - ' SumaTotalRetenciones += RetencionIVA - ' SumaTotalRetenciones += RetencionISR - - 'TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDouble - - 'Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces) - 'For Each traslado As XmlNode In nodeTraslados - ' If traslado.Attributes("impuesto").Value = "IVA" Then - ' TrasladoIVA += traslado.Attributes("importe").Value.ToDouble - ' End If - ' If traslado.Attributes("impuesto").Value = "IEPS" Then - ' TrasladoIEPS += traslado.Attributes("importe").Value.ToDouble - ' End If - ' 'If traslado.Attributes("impuesto").Value = "ISR" Then - ' ' TrasladoISR = traslado.Attributes("importe").Value - ' 'End If - ' ' Do something. - 'Next - 'SumaTotalTraslados += TrasladoIVA - 'SumaTotalTraslados += TrasladoIEPS - End If - - End If - - 'Try - ' _TFDUUID = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces).LastChild.Attributes("UUID").InnerText - 'Catch ex As Exception - ' _TFDUUID = "" - 'End Try - - + Next + End If + End If + End If + + + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) + + TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal + + If Version = "3.3" Then + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("Impuesto").Value = "002" Then + RetencionIVA += retencion.Attributes("Importe").Value.ToDecimal + End If + If retencion.Attributes("Impuesto").Value = "001" Then + RetencionISR += retencion.Attributes("Importe").Value.ToDecimal + End If + ' Do something. + Next + GvOC1.Columns(6).Visible = True + GvOC2.Columns(4).Visible = True + Else + + For Each retencion As XmlNode In nodeRetenciones + If retencion.Attributes("impuesto").Value = "IVA" Then + RetencionIVA += retencion.Attributes("importe").Value.ToDecimal + End If + If retencion.Attributes("impuesto").Value = "ISR" Then + RetencionISR += retencion.Attributes("importe").Value.ToDecimal + End If + ' Do something. + Next + End If + SumaTotalRetenciones += RetencionIVA + SumaTotalRetenciones += RetencionISR + + TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal + Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces) + + If Version = "3.3" Then + + For Each traslado As XmlNode In nodeTraslados + If traslado.Attributes("Impuesto").Value = "002" Then + TrasladoIVA += traslado.Attributes("Importe").Value.ToDecimal + End If + If traslado.Attributes("Impuesto").Value = "003" Then + TrasladoIEPS += traslado.Attributes("Importe").Value.ToDecimal + End If + If traslado.Attributes("Impuesto").Value = "001" Then + 'TrasladoISR = traslado.Attributes("importe").Value + End If + ' Do something. + Next + + Else + + For Each traslado As XmlNode In nodeTraslados + If traslado.Attributes("impuesto").Value = "IVA" Then + TrasladoIVA += traslado.Attributes("importe").Value.ToDecimal + End If + If traslado.Attributes("impuesto").Value = "IEPS" Then + TrasladoIEPS += traslado.Attributes("importe").Value.ToDecimal + End If + 'If traslado.Attributes("impuesto").Value = "ISR" Then + ' TrasladoISR = traslado.Attributes("importe").Value + 'End If + ' Do something. + Next + End If + + SumaTotalTraslados += TrasladoIVA + SumaTotalTraslados += TrasladoIEPS + End If + + Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + + Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) + + _TFDUUID = ValorXML(nodeTFD, "UUID", "") + + Dim nodeRF As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CFDIRegistroFiscal ", "registrofiscal"), namespaces) + If nodeRF IsNot Nothing Then + _Folio = ValorXML(nodeRF, "folio").TrimStart("0"c) + End If + + node = node.SelectSingleNode(String.Format("//{0}:ImpuestosLocales", "implocal"), namespaces) + + + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + OtrosImpuestos = ValorXML(node, "TotaldeTraslados", "0").ToDecimal + OtrosImpuestosRetenciones = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal + + 'If RetencionIVA <= 0 AndAlso ValorXML(node, "TotaldeRetenciones", "0").ToDouble > 0 Then RetencionIVA = ValorXML(node, "TotaldeRetenciones", "0").ToDecimal + + 'For Each retencion As XmlNode In nodeImpLocales + ' If retencion.Attributes("impuesto").Value = "IVA" Then + ' RetencionIVA += retencion.Attributes("importe").Value.ToDouble + ' End If + ' If retencion.Attributes("impuesto").Value = "ISR" Then + ' RetencionISR += retencion.Attributes("importe").Value.ToDouble + ' End If + ' ' Do something. + 'Next + ' SumaTotalRetenciones += RetencionIVA + ' SumaTotalRetenciones += RetencionISR + + 'TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDouble + + 'Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces) + 'For Each traslado As XmlNode In nodeTraslados + ' If traslado.Attributes("impuesto").Value = "IVA" Then + ' TrasladoIVA += traslado.Attributes("importe").Value.ToDouble + ' End If + ' If traslado.Attributes("impuesto").Value = "IEPS" Then + ' TrasladoIEPS += traslado.Attributes("importe").Value.ToDouble + ' End If + ' 'If traslado.Attributes("impuesto").Value = "ISR" Then + ' ' TrasladoISR = traslado.Attributes("importe").Value + ' 'End If + ' ' Do something. + 'Next + 'SumaTotalTraslados += TrasladoIVA + 'SumaTotalTraslados += TrasladoIEPS + End If + + End If + + 'Try + ' _TFDUUID = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", Prefijo), namespaces).LastChild.Attributes("UUID").InnerText + 'Catch ex As Exception + ' _TFDUUID = "" + 'End Try + + End Sub -#End Region +#End Region -#Region "GV'S" - Protected Sub GVAnticipos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAnticipos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("SerieFolio") = "" Then - e.Row.Cells(0).Text = "" - e.Row.Cells(5).Text = "" - e.Row.Cells(0).Width = Unit.Pixel(150) - e.Row.CssClass = "Totales TextCenter" - Select Case e.Row.DBCampo("TipoDocto") - Case "Egsc" - e.Row.Cells(0).Text = "Egreso Por Comprobar" - Case "Ant" - e.Row.Cells(0).Text = "Anticipos" - Case "NC" - e.Row.Cells(0).Text = "Notas de crédito" - Case "DEV" - e.Row.Cells(0).Text = "Devolución" - End Select - - ElseIf e.Row.DBCampo("CveProveedor") = "" Then - e.Row.Cells(0).Text = "" - e.Row.Cells(5).Text = "" - e.Row.BackColor = Drawing.Color.LightGray - Else - If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(3).ForeColor = Drawing.Color.Red +#Region "GV'S" + Protected Sub GVAnticipos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAnticipos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("SerieFolio") = "" Then + e.Row.Cells(0).Text = "" + e.Row.Cells(5).Text = "" + e.Row.Cells(0).Width = Unit.Pixel(150) + e.Row.CssClass = "Totales TextCenter" + Select Case e.Row.DBCampo("TipoDocto") + Case "Egsc" + e.Row.Cells(0).Text = "Egreso Por Comprobar" + Case "Ant" + e.Row.Cells(0).Text = "Anticipos" + Case "NC" + e.Row.Cells(0).Text = "Notas de crédito" + Case "DEV" + e.Row.Cells(0).Text = "Devolución" + End Select + + ElseIf e.Row.DBCampo("CveProveedor") = "" Then + e.Row.Cells(0).Text = "" + e.Row.Cells(5).Text = "" + e.Row.BackColor = Drawing.Color.LightGray + Else + If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(3).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Saldo").ToDouble = 0 Then e.Row.FCLiteral("LtlAnticipos").Text = "" - Dim ImporteAmortizacion As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) - - e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO - e.Row.FCTextBox("TxtAnticipo").Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1},{2});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO - - If ChkNCInv.Checked Then - e.Row.FCCheckBox("Chk").CssClass = "ChkAntNC" - End If - - If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then - Dim Entro As Boolean = False - For Each Documento In ListaDocumentos - If e.Row.DBCampo("UUID").ToString = Documento Then - Entro = True - End If - Next - 'permite vincular otro folio fiscal. - Entro = True - If Not Entro Then e.Row.FCCheckBox("Chk").Enabled = False - End If - End If - End If - End Sub - Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvPS.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If Not (e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5) Then - - If e.Row.RowIndex = 0 Then - 'e.Row.Cells(0).Width = Unit.Pixel(15) - 'e.Row.Cells(1).Width = Unit.Pixel(45) - 'e.Row.Cells(2).Width = Unit.Pixel(70) - 'e.Row.Cells(3).Width = Unit.Pixel(230) - 'e.Row.Cells(4).Width = Unit.Pixel(202) - 'e.Row.Cells(5).Width = Unit.Pixel(155) - 'e.Row.Cells(6).Width = Unit.Pixel(155) - 'e.Row.Cells(7).Width = Unit.Pixel(50) - 'e.Row.Cells(8).Width = Unit.Pixel(80) - 'e.Row.Cells(9).Width = Unit.Pixel(80) - 'e.Row.Cells(10).Width = Unit.Pixel(43) - 'e.Row.Cells(11).Width = Unit.Pixel(43) - - If UsuarioActual.Empresa.UsaAC Then 'AndAlso (CveFactura > 0 Or CveCompra > 0) - e.Row.Cells(12).Width = Unit.Pixel(150) - e.Row.Cells(13).Width = Unit.Pixel(150) - e.Row.Cells(14).Width = Unit.Pixel(150) - e.Row.Cells(15).Width = Unit.Pixel(150) - e.Row.Cells(16).Width = Unit.Pixel(100) - End If - End If - - 'Permite la Regeneracion de las prepolizas - If e.Row.DBCampo("CveClasificacion") <> "" AndAlso e.Row.DBCampo("CveClasificacion").ToEntero > 0 Then - TmpDT.Rows(e.Row.RowIndex)("CveClasificacionActualizar") = e.Row.DBCampo("CveClasificacion") - End If - - If CveCompra > 0 AndAlso UsuarioActual.TienePermisoProceso(104) AndAlso e.Row.FCCheckBox("CheckClasificacion") IsNot Nothing Then - e.Row.FCCheckBox("CheckClasificacion").Visible = True - End If - - If UsuarioActual.TienePermisoProceso(117) Then - e.Row.FCLinkButton("imgE").Visible = False - End If - - 'El Eliminar solo debera aparecer cuando se registre manual la compra, cuando viene de una factura se desactiva, o cuando esta registrada la compra - If CveFactura = 0 Then 'CveCompra <= 0 And - e.Row.FCLinkButton("imgD").Visible = True - 'If e.Row.FCImageButton("imgE") IsNot Nothing Then e.Row.FCImageButton("imgE").Visible = True - If e.Row.FCTextBox("TxtCantidadEdit") IsNot Nothing Then e.Row.FCTextBox("TxtCantidadEdit").Enabled = True - If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = True - End If - - 'Dejar un PS para ver que hace esto y documentar. - If e.Row.DBCampo("CvePS") = "0" Then - e.Row.Cells(0).ToolTip = "Producto/Servicio NO Registrado" - e.Row.Cells(0).ID = String.Format("tr{0}", e.Row.RowIndex) - e.Row.Cells(0).ClientIDMode = ClientIDMode.Static - e.Row.Cells(0).Attributes.Add("onclick", String.Format("fnAltaPS('{0}','{1}',{2})", String.Format("tr{0}", e.Row.RowIndex), e.Row.DBCampo("PS").Replace("'", "").Replace(Chr(13), "").Replace(Chr(10), ""), e.Row.RowIndex)) - If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = False - If e.Row.FCTextBox("TxtCantidadEdit") IsNot Nothing Then e.Row.FCTextBox("TxtCantidadEdit").Enabled = False - End If - - 'VALIDA UNIDAD DE MEDIDA - If e.Row.DBCampo("CvePS").ToString.ToEntero > 0 Then - Dim DtEquivalencias = GlobalDTProductosServiciosEquivalencias(e.Row.DBCampo("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) - - 'SI UM NO ESTA REGISTRADA - If e.Row.DBCampo("CveUM").ToString.ToEntero <= 0 Then - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(1,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}','{e.Row.DBCampo("CveSATUnidadMedida")}','{e.Row.DBCampo("SATClaveUnidadMedida")}')") - e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger manita centrarUM" - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida SIN registrar") - End If - - 'EQUIVALENCIA - If e.Row.DBCampo("CveUM").ToString.ToEntero > 0 And e.Row.DBCampo("CveTipoPS").ToString.ToEntero = 2 Then - If DtEquivalencias.FiltraParametros($"CveUM = {e.Row.DBCampo("CveUM").ToString.ToEntero}").Rows.Count > 0 Then - If Not DtEquivalencias.FiltraParametros($"CveUM = {e.Row.DBCampo("CveUM").ToString.ToEntero} AND UnidadBase = 1").Rows.Count > 0 Then - 'UM NO BASE - e.Row.FCLinkButton("LBAplicarEquivalencia").Visible = True - - 'e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(2,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}')") - e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger centrarUM" - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida NO medida base") - End If - Else - 'SIN EQUIVALENCIA - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(3,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}','{e.Row.DBCampo("CveSATUnidadMedida")}','{e.Row.DBCampo("SATClaveUnidadMedida")}')") - e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger manita centrarUM" - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") - e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida SIN equivalencia") - End If - End If - End If - - - If PermisoEdicionManual Then - If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = True - End If - - 'Esconde Editar y Eliminar cuando tiene una OC Vinculada - If OCVinculada Then - e.Row.FCLinkButton("ImgE").Visible = False - e.Row.FCLinkButton("ImgD").Visible = False - End If - - If e.Row.DBCampo("CvePS").ToEntero > 0 AndAlso e.Row.DBCampo("IEPSPSPorcentaje").ToDouble > 0 Then - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=e.Row.DBCampo("CvePS").ToEntero).Rows.Count > 0 Then - Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=e.Row.DBCampo("CvePS").ToEntero).Rows(0) - If DrPS IsNot Nothing Then - If DrPS("IEPSPorcentaje").ToString.ToDouble <> e.Row.DBCampo("IEPSPSPorcentaje").ToDouble Then - e.Row.CssClass = "danger" - e.Row.ToolTip = "El porcentaje de IEPS del producto no coincide con el especificado." - End If - End If - End If - End If - - 'CargaPresupuestosEgresos - If UsuarioActual.Empresa.UsaAC Then - e.Row.Cells(13).Visible = True - e.Row.Cells(14).Visible = True - e.Row.Cells(15).Visible = True - e.Row.Cells(16).Visible = True - e.Row.Cells(17).Visible = True - - e.Row.FCDropDownList("DdlAC1").Items.Clear() - e.Row.FCDropDownList("DdlAC1").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"}) - e.Row.FCDropDownList("DdlAC1").DataBind() - e.Row.FCDropDownList("DdlAC1").SelectedValueExist(e.Row.DBCampo("CveProgramaOperativo")) - - e.Row.FCDropDownList("DdlAC2").Items.Clear() - e.Row.FCDropDownList("DdlAC2").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"}, Orderby:="UnidadAdministrativa") - e.Row.FCDropDownList("DdlAC2").DataBind() - e.Row.FCDropDownList("DdlAC2").SelectedValueExist(e.Row.DBCampo("CveUnidadAdministrativa")) - - e.Row.FCDropDownList("DdlAC3").Items.Clear() - e.Row.FCDropDownList("DdlAC3").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"}, Orderby:="FuenteFinanciamiento") - e.Row.FCDropDownList("DdlAC3").DataBind() - e.Row.FCDropDownList("DdlAC3").SelectedValueExist(e.Row.DBCampo("CveFuenteFinanciamiento")) - - e.Row.FCDropDownList("DdlAC4").Items.Clear() - e.Row.FCDropDownList("DdlAC4").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"}) - e.Row.FCDropDownList("DdlAC4").DataBind() - e.Row.FCDropDownList("DdlAC4").SelectedValueExist(e.Row.DBCampo("CveTipoGasto")) - - e.Row.FCDropDownList("DdlAC5").Items.Clear() - e.Row.FCDropDownList("DdlAC5").Visible = True - e.Row.FCDropDownList("DdlAC5").DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("Afectable = 1 ") 'DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") - e.Row.FCDropDownList("DdlAC5").DataBind() - e.Row.FCDropDownList("DdlAC5").SelectedValueExist(e.Row.DBCampo("CveClasificacionOG")) - - 'SI EL PRESUPUESTO DE EGRESOS VIENE DESDE LA OC, SE BLOQUEA PE - If e.Row.DBCampo("CveOrdenCompraDetalle").ToEntero > 0 AndAlso e.Row.DBCampo("CvePresupuestoEgreso").ToEntero > 0 Then - - e.Row.Cells(13).Enabled = False - e.Row.Cells(14).Enabled = False - e.Row.Cells(15).Enabled = False - e.Row.Cells(16).Enabled = False - e.Row.Cells(17).Enabled = False - End If - Else - - e.Row.Cells(13).Visible = False - e.Row.Cells(14).Visible = False - e.Row.Cells(15).Visible = False - e.Row.Cells(16).Visible = False - e.Row.Cells(17).Visible = False - End If - - End If - - End If - End Sub - Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting - Dim DbRow As DataRow = Nothing - DbRow = TmpDT.Rows(e.RowIndex) - 'Dim TipoDescuento As Integer = -1 - Dim Cantidad, PU, IVA, Descuento As Double - - Cantidad = DbRow("Cantidad").ToString.ToDouble - PU = DbRow("PU").ToString.ToDouble - IVA = DbRow("IVA").ToString.ToDouble - 'IVA = Math.Round((((TxtSubTotal.Text.ToDouble - (Cantidad * PU - Descuento)) * TxtIVA.Text.ToDouble) / TxtSubTotal.Text.ToDouble), 2) - Descuento = DbRow("Descuento").ToString.ToDouble - - If CveCompra > 0 Then - ClavesBorradas.Add(DbRow("CveCompraDetalle").ToString.ToEntero) - End If - TmpDT.Rows.RemoveAt(e.RowIndex) - GvPS.DataSource = TmpDT - GvPS.DataBind() - - 'GVAF.DataSource = TmpDT - 'GVAF.DataBind() - ''UpnAF.Update() - - CalculaTotales(True) - CargaGvInv() - CargaGVsAF() - CargaGvPersonal() - Alert("El Concepto ha sido eliminado correctamente", TipoMensaje.MsgInformacion) - End Sub - Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim total As Double = TxtTotal.Text.ToString.ToDouble - Dim saldo As Double = e.Row.DataKey("Saldo").ToDouble - - e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) - e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", String.Format("AjustaTextboxDeudores(this);")) - - Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) - - If saldo > total Then - rv.MaximumValue = total.ToString - Else - rv.MaximumValue = saldo.ToString - End If - - End If - - End Sub -#End Region + Dim ImporteAmortizacion As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal) -#Region "METODOS" - Private Sub GeneraGlobalDT(data As Object) - GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) = Nothing + e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO + e.Row.FCTextBox("TxtAnticipo").Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1},{2});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO + + If ChkNCInv.Checked Then + e.Row.FCCheckBox("Chk").CssClass = "ChkAntNC" + End If + + If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then + Dim Entro As Boolean = False + For Each Documento In ListaDocumentos + If e.Row.DBCampo("UUID").ToString = Documento Then + Entro = True + End If + Next + 'permite vincular otro folio fiscal. + Entro = True + If Not Entro Then e.Row.FCCheckBox("Chk").Enabled = False + End If + End If + End If + End Sub + Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvPS.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If Not (e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5) Then + + If e.Row.RowIndex = 0 Then + 'e.Row.Cells(0).Width = Unit.Pixel(15) + 'e.Row.Cells(1).Width = Unit.Pixel(45) + 'e.Row.Cells(2).Width = Unit.Pixel(70) + 'e.Row.Cells(3).Width = Unit.Pixel(230) + 'e.Row.Cells(4).Width = Unit.Pixel(202) + 'e.Row.Cells(5).Width = Unit.Pixel(155) + 'e.Row.Cells(6).Width = Unit.Pixel(155) + 'e.Row.Cells(7).Width = Unit.Pixel(50) + 'e.Row.Cells(8).Width = Unit.Pixel(80) + 'e.Row.Cells(9).Width = Unit.Pixel(80) + 'e.Row.Cells(10).Width = Unit.Pixel(43) + 'e.Row.Cells(11).Width = Unit.Pixel(43) + + If UsuarioActual.Empresa.UsaAC Then 'AndAlso (CveFactura > 0 Or CveCompra > 0) + e.Row.Cells(12).Width = Unit.Pixel(150) + e.Row.Cells(13).Width = Unit.Pixel(150) + e.Row.Cells(14).Width = Unit.Pixel(150) + e.Row.Cells(15).Width = Unit.Pixel(150) + e.Row.Cells(16).Width = Unit.Pixel(100) + End If + End If + + 'Permite la Regeneracion de las prepolizas + If e.Row.DBCampo("CveClasificacion") <> "" AndAlso e.Row.DBCampo("CveClasificacion").ToEntero > 0 Then + TmpDT.Rows(e.Row.RowIndex)("CveClasificacionActualizar") = e.Row.DBCampo("CveClasificacion") + End If + + If CveCompra > 0 AndAlso UsuarioActual.TienePermisoProceso(104) AndAlso e.Row.FCCheckBox("CheckClasificacion") IsNot Nothing Then + e.Row.FCCheckBox("CheckClasificacion").Visible = True + End If + + If UsuarioActual.TienePermisoProceso(117) Then + e.Row.FCLinkButton("imgE").Visible = False + End If + + 'El Eliminar solo debera aparecer cuando se registre manual la compra, cuando viene de una factura se desactiva, o cuando esta registrada la compra + If CveFactura = 0 Then 'CveCompra <= 0 And + e.Row.FCLinkButton("imgD").Visible = True + 'If e.Row.FCImageButton("imgE") IsNot Nothing Then e.Row.FCImageButton("imgE").Visible = True + If e.Row.FCTextBox("TxtCantidadEdit") IsNot Nothing Then e.Row.FCTextBox("TxtCantidadEdit").Enabled = True + If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = True + End If + + 'Dejar un PS para ver que hace esto y documentar. + If e.Row.DBCampo("CvePS") = "0" Then + e.Row.Cells(0).ToolTip = "Producto/Servicio NO Registrado" + e.Row.Cells(0).ID = String.Format("tr{0}", e.Row.RowIndex) + e.Row.Cells(0).ClientIDMode = ClientIDMode.Static + e.Row.Cells(0).Attributes.Add("onclick", String.Format("fnAltaPS('{0}','{1}',{2})", String.Format("tr{0}", e.Row.RowIndex), e.Row.DBCampo("PS").Replace("'", "").Replace(Chr(13), "").Replace(Chr(10), ""), e.Row.RowIndex)) + If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = False + If e.Row.FCTextBox("TxtCantidadEdit") IsNot Nothing Then e.Row.FCTextBox("TxtCantidadEdit").Enabled = False + End If + + 'VALIDA UNIDAD DE MEDIDA + If e.Row.DBCampo("CvePS").ToString.ToEntero > 0 Then + Dim DtEquivalencias = GlobalDTProductosServiciosEquivalencias(e.Row.DBCampo("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) + + 'SI UM NO ESTA REGISTRADA + If e.Row.DBCampo("CveUM").ToString.ToEntero <= 0 Then + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(1,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}','{e.Row.DBCampo("CveSATUnidadMedida")}','{e.Row.DBCampo("SATClaveUnidadMedida")}')") + e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger manita centrarUM" + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida SIN registrar") + End If + + 'EQUIVALENCIA + If e.Row.DBCampo("CveUM").ToString.ToEntero > 0 And e.Row.DBCampo("CveTipoPS").ToString.ToEntero = 2 Then + If DtEquivalencias.FiltraParametros($"CveUM = {e.Row.DBCampo("CveUM").ToString.ToEntero}").Rows.Count > 0 Then + If Not DtEquivalencias.FiltraParametros($"CveUM = {e.Row.DBCampo("CveUM").ToString.ToEntero} AND UnidadBase = 1").Rows.Count > 0 Then + 'UM NO BASE + e.Row.FCLinkButton("LBAplicarEquivalencia").Visible = True + + 'e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(2,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}')") + e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger centrarUM" + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida NO medida base") + End If + Else + 'SIN EQUIVALENCIA + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("onclick", $"FncUMEquivalencias(3,'{e.Row.DBCampo("UM").Replace("'", "")}',{e.Row.RowIndex},'{DtEquivalencias.FiltroPrimeroValor("UnidadMedida", "UnidadBase = 1")}','{e.Row.DBCampo("CveSATUnidadMedida")}','{e.Row.DBCampo("SATClaveUnidadMedida")}')") + e.Row.FCLabel("LtlUnidadMedida").CssClass = "label label-danger manita centrarUM" + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("data-toggle", "tooltip") + e.Row.FCLabel("LtlUnidadMedida").Attributes.Add("title", "Unidad de medida SIN equivalencia") + End If + End If + End If + + + If PermisoEdicionManual Then + If e.Row.FCTextBox("TxtPrecioEdit") IsNot Nothing Then e.Row.FCTextBox("TxtPrecioEdit").Enabled = True + End If + + 'Esconde Editar y Eliminar cuando tiene una OC Vinculada + If OCVinculada Then + e.Row.FCLinkButton("ImgE").Visible = False + e.Row.FCLinkButton("ImgD").Visible = False + End If + + If e.Row.DBCampo("CvePS").ToEntero > 0 AndAlso e.Row.DBCampo("IEPSPSPorcentaje").ToDouble > 0 Then + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=e.Row.DBCampo("CvePS").ToEntero).Rows.Count > 0 Then + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=e.Row.DBCampo("CvePS").ToEntero).Rows(0) + If DrPS IsNot Nothing Then + If DrPS("IEPSPorcentaje").ToString.ToDouble <> e.Row.DBCampo("IEPSPSPorcentaje").ToDouble Then + e.Row.CssClass = "danger" + e.Row.ToolTip = "El porcentaje de IEPS del producto no coincide con el especificado." + End If + End If + End If + End If + + 'CargaPresupuestosEgresos + If UsuarioActual.Empresa.UsaAC Then + e.Row.Cells(13).Visible = True + e.Row.Cells(14).Visible = True + e.Row.Cells(15).Visible = True + e.Row.Cells(16).Visible = True + e.Row.Cells(17).Visible = True + + e.Row.FCDropDownList("DdlAC1").Items.Clear() + e.Row.FCDropDownList("DdlAC1").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"}) + e.Row.FCDropDownList("DdlAC1").DataBind() + e.Row.FCDropDownList("DdlAC1").SelectedValueExist(e.Row.DBCampo("CveProgramaOperativo")) + + e.Row.FCDropDownList("DdlAC2").Items.Clear() + e.Row.FCDropDownList("DdlAC2").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"}, Orderby:="UnidadAdministrativa") + e.Row.FCDropDownList("DdlAC2").DataBind() + e.Row.FCDropDownList("DdlAC2").SelectedValueExist(e.Row.DBCampo("CveUnidadAdministrativa")) + + e.Row.FCDropDownList("DdlAC3").Items.Clear() + e.Row.FCDropDownList("DdlAC3").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"}, Orderby:="FuenteFinanciamiento") + e.Row.FCDropDownList("DdlAC3").DataBind() + e.Row.FCDropDownList("DdlAC3").SelectedValueExist(e.Row.DBCampo("CveFuenteFinanciamiento")) + + e.Row.FCDropDownList("DdlAC4").Items.Clear() + e.Row.FCDropDownList("DdlAC4").DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"}) + e.Row.FCDropDownList("DdlAC4").DataBind() + e.Row.FCDropDownList("DdlAC4").SelectedValueExist(e.Row.DBCampo("CveTipoGasto")) + + e.Row.FCDropDownList("DdlAC5").Items.Clear() + e.Row.FCDropDownList("DdlAC5").Visible = True + e.Row.FCDropDownList("DdlAC5").DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") 'GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("Afectable = 1 ") 'DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") + e.Row.FCDropDownList("DdlAC5").DataBind() + e.Row.FCDropDownList("DdlAC5").SelectedValueExist(e.Row.DBCampo("CveClasificacionOG")) + + 'SI EL PRESUPUESTO DE EGRESOS VIENE DESDE LA OC, SE BLOQUEA PE + If e.Row.DBCampo("CveOrdenCompraDetalle").ToEntero > 0 AndAlso e.Row.DBCampo("CvePresupuestoEgreso").ToEntero > 0 Then + + e.Row.Cells(13).Enabled = False + e.Row.Cells(14).Enabled = False + e.Row.Cells(15).Enabled = False + e.Row.Cells(16).Enabled = False + e.Row.Cells(17).Enabled = False + End If + Else + + e.Row.Cells(13).Visible = False + e.Row.Cells(14).Visible = False + e.Row.Cells(15).Visible = False + e.Row.Cells(16).Visible = False + e.Row.Cells(17).Visible = False + End If + + End If + + End If + End Sub + Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting + Dim DbRow As DataRow = Nothing + DbRow = TmpDT.Rows(e.RowIndex) + 'Dim TipoDescuento As Integer = -1 + Dim Cantidad, PU, IVA, Descuento As Double + + Cantidad = DbRow("Cantidad").ToString.ToDouble + PU = DbRow("PU").ToString.ToDouble + IVA = DbRow("IVA").ToString.ToDouble + 'IVA = Math.Round((((TxtSubTotal.Text.ToDouble - (Cantidad * PU - Descuento)) * TxtIVA.Text.ToDouble) / TxtSubTotal.Text.ToDouble), 2) + Descuento = DbRow("Descuento").ToString.ToDouble + + If CveCompra > 0 Then + ClavesBorradas.Add(DbRow("CveCompraDetalle").ToString.ToEntero) + End If + TmpDT.Rows.RemoveAt(e.RowIndex) + GvPS.DataSource = TmpDT + GvPS.DataBind() + + 'GVAF.DataSource = TmpDT + 'GVAF.DataBind() + ''UpnAF.Update() + + CalculaTotales(True) + CargaGvInv() + CargaGVsAF() + CargaGvPersonal() + Alert("El Concepto ha sido eliminado correctamente", TipoMensaje.MsgInformacion) + End Sub + Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim total As Double = TxtTotal.Text.ToString.ToDouble + Dim saldo As Double = e.Row.DataKey("Saldo").ToDouble + + e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) + e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", String.Format("AjustaTextboxDeudores(this);")) + + Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) + + If saldo > total Then + rv.MaximumValue = total.ToString + Else + rv.MaximumValue = saldo.ToString + End If + + End If + + End Sub +#End Region + +#Region "METODOS" + Private Sub GeneraGlobalDT(data As Object) + GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) = Nothing GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing 'Dim ObjPS As New ClsProductosServicios @@ -10590,430 +10604,430 @@ Partial Class Compras_Compras 'End If 'ObjPS.Dispose() - End Sub - Private Function notienepresupuesto() As Boolean - Dim notienerecursos = False - Dim SinRecursos As New StringBuilder - SinRecursos.AppendFormat("No se cuenta con los Recursos Suficientes en los siguientes subproyectos ") - Dim subproyectosSr As New List(Of Integer) - Dim filtro As New StringBuilder - 'me traigo los proyectos y subproyectos para traer presupuesots de la bd - Dim subproyectos As New List(Of Integer) - - For Each Row As DataRow In TmpDT.FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}).Rows - Dim RowCon As DataRow = GlobalDTContratos.FiltroPrimero(String.Format("CveSubProyecto={0}", Row("CveSubProyecto"))) - If Not IsNothing(RowCon) Then - filtro.AppendFormat(",{0}", Row("CveSubProyecto")) - subproyectos.Add(Row("CveSubProyecto").ToString.ToEntero) - End If - Next - 'me traigo los presupuestos de la base de datos - Dim dtpresupuestos As New DataTable - Dim objContratos As New ClsContratos - If objContratos.GetContratosPresupuesto(filtro.ToString) Then - dtpresupuestos = objContratos.DtResultados - End If - objContratos.Dispose() - - 'resto los importes actuales a los presupuestos obtenidos de la bd - For Each dr As DataRow In TmpDT.Rows - Dim psclasificacion As String = String.Format("CveSubFamilia='{0}' AND CveSubProyecto={1}", GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CvePS={0}", dr("CvePS").ToString.ToEntero))("CveSubFamilia").ToString, dr("CveSubProyecto").ToString) - - If dtpresupuestos.Rows.Count > 0 AndAlso dtpresupuestos.Select(psclasificacion).Count > 0 Then - Dim rowpresupuesto As DataRow = dtpresupuestos.Select(psclasificacion)(0) - rowpresupuesto("Importe") = rowpresupuesto("Importe").ToString.ToDouble - dr("Total").ToString.ToDouble() - Else - If subproyectos.Contains(dr("CveSubProyecto").ToString.ToEntero) Then - notienerecursos = True - If Not subproyectosSr.Contains(dr("CveSubProyecto").ToString.ToEntero) Then - subproyectosSr.Add(dr("CveSubProyecto").ToString.ToEntero) - SinRecursos.AppendFormat(",{0}", dr("SubProyecto").ToString) - End If - End If - End If - Next - dtpresupuestos.AcceptChanges() - ' - For Each rowpresupuesto As DataRow In dtpresupuestos.Rows - If (rowpresupuesto("Importe").ToString.ToDouble() < 0) Then - If Not subproyectosSr.Contains(rowpresupuesto("CveSubProyecto").ToString.ToEntero) Then - subproyectosSr.Add(rowpresupuesto("CveSubProyecto").ToString.ToEntero) - SinRecursos.AppendFormat(",{0}", rowpresupuesto("SubProyecto").ToString) - End If - notienerecursos = True - End If - Next - If (notienerecursos) Then - Alert(SinRecursos.ToString, TipoMensaje.MsgAdvertencia) - End If - dtpresupuestos.Dispose() - Return notienerecursos - End Function - Private Sub CreaDTConceptos() - DTConceptos = New DataTable - DTConceptos.Columns.Add("Consec", GetType(Integer)) - DTConceptos.Columns.Add("Cantidad", GetType(Double)) - DTConceptos.Columns.Add("UM", GetType(String)) - DTConceptos.Columns.Add("CveClasificacion", GetType(Integer)) - DTConceptos.Columns.Add("PS", GetType(String)) - DTConceptos.Columns.Add("PU", GetType(Double)) - DTConceptos.Columns.Add("Descuento", GetType(Double)) - DTConceptos.Columns.Add("IVA", GetType(Double)) - DTConceptos.Columns.Add("Total", GetType(Double)) - DTConceptos.Columns.Add("Amortizacion", GetType(Double)) - End Sub - 'Private Sub AddPS(Cantidad As Double, UM As String, PS As String, PU As Double, IVA As Double, Descuento As Double, Optional Total As Double = 0) - ' Dim Row As DataRow = Nothing - ' Row = DTConceptos.NewRow() - ' Row("Consec") = DTConceptos.Rows.Count + 1 - ' Row("Cantidad") = Cantidad - ' Row("UM") = UM - ' Row("CveClasificacion") = -1 - ' Row("PS") = PS - ' Row("PU") = PU - ' Row("IVA") = IVA - ' Row("Total") = If(Total > 0, Total, Cantidad * PU) - ' Row("Descuento") = Descuento - - ' DTConceptos.Rows.Add(Row) - 'End Sub - Private Sub CreaDTCompras() - - TmpDT = New DataTable - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDT.Columns.Add("Clasificacion", GetType(String)) - TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer)) - TmpDT.Columns.Add("CvePS", GetType(Integer)) - TmpDT.Columns.Add("PS", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("IVAPorcentaje", GetType(Decimal)) - TmpDT.Columns.Add("RetIVA", GetType(Decimal)) - TmpDT.Columns.Add("RetIVAPorcentaje", GetType(Decimal)) - TmpDT.Columns.Add("RetISR", GetType(Decimal)) - TmpDT.Columns.Add("RetISRPorcentaje", GetType(Decimal)) - TmpDT.Columns.Add("IEPSPS", GetType(Double)) - TmpDT.Columns.Add("IEPSPSPorcentaje", GetType(Double)) - TmpDT.Columns.Add("IEPSPSIVA", GetType(Double)) - TmpDT.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("OtrosGastos", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - TmpDT.Columns.Add("AsientoContableCompras", GetType(Integer)) - TmpDT.Columns.Add("IdCtaContCompras", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("CveContrato", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - 'TmpDT.Columns.Add("CveEq", GetType(Integer)) - TmpDT.Columns.Add("CveAlmacen", GetType(Integer)) - TmpDT.Columns.Add("CvePersonal", GetType(String)) - TmpDT.Columns.Add("Referencia", GetType(String)) - - 'AC - TmpDT.Columns.Add("CveTipoGastoAC", GetType(Integer)) - TmpDT.Columns.Add("CvePresupuestoEgreso", GetType(Integer)) - TmpDT.Columns.Add("CveProgramaOperativo", GetType(Integer)) - TmpDT.Columns.Add("CveUnidadAdministrativa", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteFinanciamiento", GetType(Integer)) - TmpDT.Columns.Add("CveClasificacionOG", GetType(Integer)) - - TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer)) - TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer)) - - 'INVENTARIO SERIE/LOTE - TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer)) - - TmpDT.Columns.Add("CveConcepto", GetType(Integer)) - - 'AF - TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) - TmpDT.Columns.Add("CodAF", GetType(String)) - TmpDT.Columns.Add("TipoAF", GetType(Integer)) - TmpDT.Columns.Add("AFMedida", GetType(Integer)) - TmpDT.Columns.Add("AFTipoMantenimiento", GetType(Integer)) - - 'PS - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CodigoPS", GetType(String)) - TmpDT.Columns.Add("PSDescripcion", GetType(String)) - 'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR - TmpDT.Columns.Add("PSCodigo", GetType(String)) - - - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("ProductoOC", GetType(String)) - TmpDT.Columns.Add("CantidadF", GetType(Double)) - - 'Consignaciones - TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) - TmpDT.Columns.Add("NoConsignacion", GetType(Integer)) - TmpDT.Columns.Add("CveConsignacion", GetType(Integer)) - TmpDT.Columns.Add("HdnPS", GetType(String)) - TmpDT.Columns.Add("HdnCvePS", GetType(String)) - TmpDT.Columns.Add("HdnClasificacion", GetType(String)) - TmpDT.Columns.Add("HdnCveClasificacion", GetType(String)) - TmpDT.Columns.Add("HdnCveAlmacen", GetType(String)) - - 'Fletes y Servicios - TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) - TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) - TmpDT.Columns.Add("CveCompraDetalle", GetType(Integer)) - - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - - 'SAT - TmpDT.Columns.Add("CveSATPS", GetType(Integer)) - TmpDT.Columns.Add("SATClaveProductoServicio", GetType(String)) - TmpDT.Columns.Add("CveSATUnidadMedida", GetType(Integer)) - TmpDT.Columns.Add("SATClaveUnidadMedida", GetType(String)) - - 'Tipo de Gasto - TmpDT.Columns.Add("CveTipoGasto", GetType(Integer)) - TmpDT.Columns.Add("TipoGasto", GetType(String)) - - TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Double)) - TmpDT.Columns.Add("ImporteConImpuestos", GetType(Double)) - TmpDT.Columns.Add("NoDeducible", GetType(Boolean)) - - TmpDTOriginal = New DataTable - TmpDTOriginal.Columns.Add("Consec", GetType(Integer)) - TmpDTOriginal.Columns.Add("Cantidad", GetType(Decimal)) - TmpDTOriginal.Columns.Add("Codigo", GetType(String)) - TmpDTOriginal.Columns.Add("CveUM", GetType(Integer)) - TmpDTOriginal.Columns.Add("UM", GetType(String)) - TmpDTOriginal.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDTOriginal.Columns.Add("Clasificacion", GetType(String)) - TmpDTOriginal.Columns.Add("CveClasificacionActualizar", GetType(Integer)) - TmpDTOriginal.Columns.Add("CvePS", GetType(Integer)) - TmpDTOriginal.Columns.Add("PS", GetType(String)) - TmpDTOriginal.Columns.Add("Obs", GetType(String)) - TmpDTOriginal.Columns.Add("PU", GetType(Decimal)) - TmpDTOriginal.Columns.Add("IVA", GetType(Decimal)) - TmpDTOriginal.Columns.Add("IVAPorcentaje", GetType(Decimal)) - TmpDTOriginal.Columns.Add("RetIVA", GetType(Decimal)) - TmpDTOriginal.Columns.Add("RetIVAPorcentaje", GetType(Decimal)) - TmpDTOriginal.Columns.Add("RetISR", GetType(Decimal)) - TmpDTOriginal.Columns.Add("RetISRPorcentaje", GetType(Decimal)) - TmpDTOriginal.Columns.Add("IEPSPS", GetType(Double)) - TmpDTOriginal.Columns.Add("IEPSPSPorcentaje", GetType(Double)) - TmpDTOriginal.Columns.Add("IEPSPSIVA", GetType(Double)) - TmpDTOriginal.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double)) - TmpDTOriginal.Columns.Add("Descuento", GetType(Decimal)) - TmpDTOriginal.Columns.Add("OtrosGastos", GetType(Decimal)) - TmpDTOriginal.Columns.Add("Total", GetType(Decimal)) - TmpDTOriginal.Columns.Add("AsientoContableCompras", GetType(Integer)) - TmpDTOriginal.Columns.Add("IdCtaContCompras", GetType(Integer)) - TmpDTOriginal.Columns.Add("Proyecto", GetType(String)) - TmpDTOriginal.Columns.Add("CveProyecto", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveContrato", GetType(Integer)) - TmpDTOriginal.Columns.Add("SubProyecto", GetType(String)) - 'TmpDTOriginal.Columns.Add("CveEq", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveAlmacen", GetType(Integer)) - TmpDTOriginal.Columns.Add("CvePersonal", GetType(String)) - TmpDTOriginal.Columns.Add("Referencia", GetType(String)) - - 'AC - TmpDTOriginal.Columns.Add("CveTipoGastoAC", GetType(Integer)) - TmpDTOriginal.Columns.Add("CvePresupuestoEgreso", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveProgramaOperativo", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveUnidadAdministrativa", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveFuenteFinanciamiento", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveClasificacionOG", GetType(Integer)) - - TmpDTOriginal.Columns.Add("IdCuentaComprometido", GetType(Integer)) - TmpDTOriginal.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) - TmpDTOriginal.Columns.Add("IdCuentaDevengado", GetType(Integer)) - TmpDTOriginal.Columns.Add("IdCuentaMatriz", GetType(Integer)) - - 'INVENTARIO SERIE/LOTE - TmpDTOriginal.Columns.Add("CveMetodoInventario", GetType(Integer)) - - TmpDTOriginal.Columns.Add("CveConcepto", GetType(Integer)) - - 'AF - TmpDTOriginal.Columns.Add("CveActivoFijo", GetType(Integer)) - TmpDTOriginal.Columns.Add("CodAF", GetType(String)) - TmpDTOriginal.Columns.Add("TipoAF", GetType(Integer)) - TmpDTOriginal.Columns.Add("AFMedida", GetType(Integer)) - TmpDTOriginal.Columns.Add("AFTipoMantenimiento", GetType(Integer)) - - 'PS - TmpDTOriginal.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDTOriginal.Columns.Add("CodigoPS", GetType(String)) - TmpDTOriginal.Columns.Add("PSDescripcion", GetType(String)) - 'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR - TmpDTOriginal.Columns.Add("PSCodigo", GetType(String)) - - - 'OC - TmpDTOriginal.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDTOriginal.Columns.Add("ProductoOC", GetType(String)) - TmpDTOriginal.Columns.Add("CantidadF", GetType(Double)) - - 'Consignaciones - TmpDTOriginal.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) - TmpDTOriginal.Columns.Add("NoConsignacion", GetType(Integer)) - TmpDTOriginal.Columns.Add("CveConsignacion", GetType(Integer)) - TmpDTOriginal.Columns.Add("HdnPS", GetType(String)) - TmpDTOriginal.Columns.Add("HdnCvePS", GetType(String)) - TmpDTOriginal.Columns.Add("HdnClasificacion", GetType(String)) - TmpDTOriginal.Columns.Add("HdnCveClasificacion", GetType(String)) - TmpDTOriginal.Columns.Add("HdnCveAlmacen", GetType(String)) - - 'Fletes y Servicios - TmpDTOriginal.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) - TmpDTOriginal.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) - TmpDTOriginal.Columns.Add("CveCompraDetalle", GetType(Integer)) - - TmpDTOriginal.Columns.Add("EntregaDirecta", GetType(Integer)) - - 'SAT - TmpDTOriginal.Columns.Add("CveSATPS", GetType(Integer)) - TmpDTOriginal.Columns.Add("SATClaveProductoServicio", GetType(String)) - TmpDTOriginal.Columns.Add("CveSATUnidadMedida", GetType(Integer)) - TmpDTOriginal.Columns.Add("SATClaveUnidadMedida", GetType(String)) - - 'Tipo de Gasto - TmpDTOriginal.Columns.Add("CveTipoGasto", GetType(Integer)) - TmpDTOriginal.Columns.Add("TipoGasto", GetType(String)) - TmpDTOriginal.Columns.Add("NoDeducible", GetType(Boolean)) - - TmpDTOriginal.Columns.Add("Importe", GetType(Double)) - - - End Sub - 'Private Sub AddDTEnvio(Cantidad As Double, UM As String, CveUM As Integer, CvePS As Integer, PS As String, PU As Double, CveAlmacen As Integer, CveEq As Integer) - - ' Dim dr As DataRow = DtInv.NewRow - - ' dr("Cantidad") = Cantidad - ' dr("UM") = UM - ' dr("CveUM") = CveUM - ' dr("CvePS") = CvePS - ' dr("PS") = PS - ' dr("PU") = PU - ' dr("CveAlmacen") = CveAlmacen - ' dr("CveEq") = CveEq - - ' DtInv.Rows.InsertAt(dr, hdnIndexInv.Value.ToEntero + 1) - - ' GvInv.DataSource = DtInv - ' GvInv.DataBind() - - - 'End Sub - - Protected Sub RecargaMaximum_Click(sender As Object, e As System.EventArgs) - - CalculaTotales(True) - - 'RVDocumentoImporte.MaximumValue = (TxtSubTotal.Text.ToDouble - TxtDescuento.Text.ToDouble - LblAmortizacion.Text.Trim.ToDouble + TxtIVA.Text.ToDouble - TxtRetIVA.Text.ToDouble - TxtRetISR.Text.ToDouble).FormatoNumero(2) - 'RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - 'RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - End Sub - Protected Sub AlmacenCambiaPS_Click(sender As Object, e As EventArgs) Handles AlmacenCambiaPS.Click - Dim correcto As Boolean = True - Dim x As Integer = 0 - - 'Dim buid As New StringBuilder - For Each Dr As DataRow In TmpDT.Rows - Dim newps As Integer = GvInv.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero - If newps > 0 Then - 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) - Dr("CvePS") = newps - 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) - Else 'limpio el valor para que no truene en linq mas abajo - correcto = False - Alert("Favor de asociar todos los productos o servicios", TipoMensaje.MsgAdvertencia) - Exit For - End If - x = x + 1 - Next - - x = 0 - - For Each Dr As DataRow In DtInv.Rows - Dim newps As Integer = GvInv.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero - If newps > 0 Then - 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) - Dr("CvePS") = newps - 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) - Else 'limpio el valor para que no truene en linq mas abajo - correcto = False - Alert("Favor de asociar todos los productos o servicios", TipoMensaje.MsgAdvertencia) - Exit For - End If - x = x + 1 - Next - - TmpDT.AcceptChanges() - 'Alert(buid.ToString) - If correcto Then - If Not CierrePeriodo Then - BtnGuardar.Visible = True - End If - UpFacturar.Update() - End If - - End Sub - Private Sub SetValues() - 'Dim um As New ClsUnidadesMedida - TxtFecha.Text = Now.ToShortDateString() - LblUsuarioCaptura.Text = UsuarioActual.Usuario - DdlProveedor.Attributes.Add("onclick", "CargaProveedores();") - 'DdlFuncionarioEmpleado.Attributes.Add("onclick", "CargaFuncionariosEmpleados();") - TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") - TxtCantidad.Attributes.Add("onKeyUp ", "Recalcula();") - TxtDescuentoModal.Attributes.Add("onKeyUp ", "Recalcula();") - TxtOtrosGastos.Attributes.Add("onKeyUp ", "Recalcula();") - 'ImgAmort.Attributes.Add("onclick", "javascript:$('#DivDescP').show(1000); PosicionaObjeto(this.id,'DivDescP');") ' $get('LblTitulo1').style.display = 'none'; $get('LblTituloTipo1').style.display = 'none'; $get('LblTituloTipo2').style.display = ''; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = ''; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = 'none';") - - 'If um.GetUnidadesMedida() Then - ' GlobalDTUnidadesMedida = um.DtResultados - 'End If - 'um.Dispose() - - 'CargaEstatus() - CargaTiposAF() - CargaProyectoAsignado() - CargaClasificaciones() - CargaPS(-1) - CargaProyecto() - CreaDTCompras() - CargaMonedas() - CargarAlmacen() - 'CreaDtAF() - 'TabOC.Visible = False - - 'BORRAR OC - 'Valores para Vinculacion OC - 'If UsuarioActual.Empresa.MetodoOC = 1 Then GvOC2.Columns(2).Visible = False : tdSurtirOC.Visible = False Else GvOC2.Columns(0).Visible = False : tdFolioOC.Visible = False - - CveAlmacenConsignacion = -1 - CveConsignacion = -1 - OCVinculada = False - TipoCambioOC = -1 - EstatusAlmacen = -1 - CreaDtDetalle() - - CargarUMAlias() - End Sub -#End Region + Private Function notienepresupuesto() As Boolean + Dim notienerecursos = False + Dim SinRecursos As New StringBuilder + SinRecursos.AppendFormat("No se cuenta con los Recursos Suficientes en los siguientes subproyectos ") + Dim subproyectosSr As New List(Of Integer) + Dim filtro As New StringBuilder + 'me traigo los proyectos y subproyectos para traer presupuesots de la bd + Dim subproyectos As New List(Of Integer) -#Region " ALGO DE AF QUE NUNCA SE USABA " + For Each Row As DataRow In TmpDT.FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}).Rows + Dim RowCon As DataRow = GlobalDTContratos.FiltroPrimero(String.Format("CveSubProyecto={0}", Row("CveSubProyecto"))) + If Not IsNothing(RowCon) Then + filtro.AppendFormat(",{0}", Row("CveSubProyecto")) + subproyectos.Add(Row("CveSubProyecto").ToString.ToEntero) + End If + Next + 'me traigo los presupuestos de la base de datos + Dim dtpresupuestos As New DataTable + Dim objContratos As New ClsContratos + If objContratos.GetContratosPresupuesto(filtro.ToString) Then + dtpresupuestos = objContratos.DtResultados + End If + objContratos.Dispose() + + 'resto los importes actuales a los presupuestos obtenidos de la bd + For Each dr As DataRow In TmpDT.Rows + Dim psclasificacion As String = String.Format("CveSubFamilia='{0}' AND CveSubProyecto={1}", GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CvePS={0}", dr("CvePS").ToString.ToEntero))("CveSubFamilia").ToString, dr("CveSubProyecto").ToString) + + If dtpresupuestos.Rows.Count > 0 AndAlso dtpresupuestos.Select(psclasificacion).Count > 0 Then + Dim rowpresupuesto As DataRow = dtpresupuestos.Select(psclasificacion)(0) + rowpresupuesto("Importe") = rowpresupuesto("Importe").ToString.ToDouble - dr("Total").ToString.ToDouble() + Else + If subproyectos.Contains(dr("CveSubProyecto").ToString.ToEntero) Then + notienerecursos = True + If Not subproyectosSr.Contains(dr("CveSubProyecto").ToString.ToEntero) Then + subproyectosSr.Add(dr("CveSubProyecto").ToString.ToEntero) + SinRecursos.AppendFormat(",{0}", dr("SubProyecto").ToString) + End If + End If + End If + Next + dtpresupuestos.AcceptChanges() + ' + For Each rowpresupuesto As DataRow In dtpresupuestos.Rows + If (rowpresupuesto("Importe").ToString.ToDouble() < 0) Then + If Not subproyectosSr.Contains(rowpresupuesto("CveSubProyecto").ToString.ToEntero) Then + subproyectosSr.Add(rowpresupuesto("CveSubProyecto").ToString.ToEntero) + SinRecursos.AppendFormat(",{0}", rowpresupuesto("SubProyecto").ToString) + End If + notienerecursos = True + End If + Next + If (notienerecursos) Then + Alert(SinRecursos.ToString, TipoMensaje.MsgAdvertencia) + End If + dtpresupuestos.Dispose() + Return notienerecursos + End Function + Private Sub CreaDTConceptos() + DTConceptos = New DataTable + DTConceptos.Columns.Add("Consec", GetType(Integer)) + DTConceptos.Columns.Add("Cantidad", GetType(Double)) + DTConceptos.Columns.Add("UM", GetType(String)) + DTConceptos.Columns.Add("CveClasificacion", GetType(Integer)) + DTConceptos.Columns.Add("PS", GetType(String)) + DTConceptos.Columns.Add("PU", GetType(Double)) + DTConceptos.Columns.Add("Descuento", GetType(Double)) + DTConceptos.Columns.Add("IVA", GetType(Double)) + DTConceptos.Columns.Add("Total", GetType(Double)) + DTConceptos.Columns.Add("Amortizacion", GetType(Double)) + End Sub + 'Private Sub AddPS(Cantidad As Double, UM As String, PS As String, PU As Double, IVA As Double, Descuento As Double, Optional Total As Double = 0) + ' Dim Row As DataRow = Nothing + ' Row = DTConceptos.NewRow() + ' Row("Consec") = DTConceptos.Rows.Count + 1 + ' Row("Cantidad") = Cantidad + ' Row("UM") = UM + ' Row("CveClasificacion") = -1 + ' Row("PS") = PS + ' Row("PU") = PU + ' Row("IVA") = IVA + ' Row("Total") = If(Total > 0, Total, Cantidad * PU) + ' Row("Descuento") = Descuento + + ' DTConceptos.Rows.Add(Row) + 'End Sub + Private Sub CreaDTCompras() + + TmpDT = New DataTable + TmpDT.Columns.Add("Consec", GetType(Integer)) + TmpDT.Columns.Add("Cantidad", GetType(Decimal)) + TmpDT.Columns.Add("Codigo", GetType(String)) + TmpDT.Columns.Add("CveUM", GetType(Integer)) + TmpDT.Columns.Add("UM", GetType(String)) + TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) + TmpDT.Columns.Add("Clasificacion", GetType(String)) + TmpDT.Columns.Add("CveClasificacionActualizar", GetType(Integer)) + TmpDT.Columns.Add("CvePS", GetType(Integer)) + TmpDT.Columns.Add("PS", GetType(String)) + TmpDT.Columns.Add("Obs", GetType(String)) + TmpDT.Columns.Add("PU", GetType(Decimal)) + TmpDT.Columns.Add("IVA", GetType(Decimal)) + TmpDT.Columns.Add("IVAPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("RetIVA", GetType(Decimal)) + TmpDT.Columns.Add("RetIVAPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("RetISR", GetType(Decimal)) + TmpDT.Columns.Add("RetISRPorcentaje", GetType(Decimal)) + TmpDT.Columns.Add("IEPSPS", GetType(Double)) + TmpDT.Columns.Add("IEPSPSPorcentaje", GetType(Double)) + TmpDT.Columns.Add("IEPSPSIVA", GetType(Double)) + TmpDT.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double)) + TmpDT.Columns.Add("Descuento", GetType(Decimal)) + TmpDT.Columns.Add("OtrosGastos", GetType(Decimal)) + TmpDT.Columns.Add("Total", GetType(Decimal)) + TmpDT.Columns.Add("AsientoContableCompras", GetType(Integer)) + TmpDT.Columns.Add("IdCtaContCompras", GetType(Integer)) + TmpDT.Columns.Add("Proyecto", GetType(String)) + TmpDT.Columns.Add("CveProyecto", GetType(Integer)) + TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDT.Columns.Add("CveContrato", GetType(Integer)) + TmpDT.Columns.Add("SubProyecto", GetType(String)) + 'TmpDT.Columns.Add("CveEq", GetType(Integer)) + TmpDT.Columns.Add("CveAlmacen", GetType(Integer)) + TmpDT.Columns.Add("CvePersonal", GetType(String)) + TmpDT.Columns.Add("Referencia", GetType(String)) + + 'AC + TmpDT.Columns.Add("CveTipoGastoAC", GetType(Integer)) + TmpDT.Columns.Add("CvePresupuestoEgreso", GetType(Integer)) + TmpDT.Columns.Add("CveProgramaOperativo", GetType(Integer)) + TmpDT.Columns.Add("CveUnidadAdministrativa", GetType(Integer)) + TmpDT.Columns.Add("CveFuenteFinanciamiento", GetType(Integer)) + TmpDT.Columns.Add("CveClasificacionOG", GetType(Integer)) + + TmpDT.Columns.Add("IdCuentaComprometido", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaDevengado", GetType(Integer)) + TmpDT.Columns.Add("IdCuentaMatriz", GetType(Integer)) + + 'INVENTARIO SERIE/LOTE + TmpDT.Columns.Add("CveMetodoInventario", GetType(Integer)) + + TmpDT.Columns.Add("CveConcepto", GetType(Integer)) + + 'AF + TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) + TmpDT.Columns.Add("CodAF", GetType(String)) + TmpDT.Columns.Add("TipoAF", GetType(Integer)) + TmpDT.Columns.Add("AFMedida", GetType(Integer)) + TmpDT.Columns.Add("AFTipoMantenimiento", GetType(Integer)) + + 'PS + TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDT.Columns.Add("CodigoPS", GetType(String)) + TmpDT.Columns.Add("PSDescripcion", GetType(String)) + 'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR + TmpDT.Columns.Add("PSCodigo", GetType(String)) + + + 'OC + TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDT.Columns.Add("ProductoOC", GetType(String)) + TmpDT.Columns.Add("CantidadF", GetType(Double)) + + 'Consignaciones + TmpDT.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) + TmpDT.Columns.Add("NoConsignacion", GetType(Integer)) + TmpDT.Columns.Add("CveConsignacion", GetType(Integer)) + TmpDT.Columns.Add("HdnPS", GetType(String)) + TmpDT.Columns.Add("HdnCvePS", GetType(String)) + TmpDT.Columns.Add("HdnClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveClasificacion", GetType(String)) + TmpDT.Columns.Add("HdnCveAlmacen", GetType(String)) + + 'Fletes y Servicios + TmpDT.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) + TmpDT.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) + TmpDT.Columns.Add("CveCompraDetalle", GetType(Integer)) + + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + + 'SAT + TmpDT.Columns.Add("CveSATPS", GetType(Integer)) + TmpDT.Columns.Add("SATClaveProductoServicio", GetType(String)) + TmpDT.Columns.Add("CveSATUnidadMedida", GetType(Integer)) + TmpDT.Columns.Add("SATClaveUnidadMedida", GetType(String)) + + 'Tipo de Gasto + TmpDT.Columns.Add("CveTipoGasto", GetType(Integer)) + TmpDT.Columns.Add("TipoGasto", GetType(String)) + + TmpDT.Columns.Add("ImporteSinImpuestos", GetType(Double)) + TmpDT.Columns.Add("ImporteConImpuestos", GetType(Double)) + TmpDT.Columns.Add("NoDeducible", GetType(Boolean)) + + TmpDTOriginal = New DataTable + TmpDTOriginal.Columns.Add("Consec", GetType(Integer)) + TmpDTOriginal.Columns.Add("Cantidad", GetType(Decimal)) + TmpDTOriginal.Columns.Add("Codigo", GetType(String)) + TmpDTOriginal.Columns.Add("CveUM", GetType(Integer)) + TmpDTOriginal.Columns.Add("UM", GetType(String)) + TmpDTOriginal.Columns.Add("CveClasificacion", GetType(Integer)) + TmpDTOriginal.Columns.Add("Clasificacion", GetType(String)) + TmpDTOriginal.Columns.Add("CveClasificacionActualizar", GetType(Integer)) + TmpDTOriginal.Columns.Add("CvePS", GetType(Integer)) + TmpDTOriginal.Columns.Add("PS", GetType(String)) + TmpDTOriginal.Columns.Add("Obs", GetType(String)) + TmpDTOriginal.Columns.Add("PU", GetType(Decimal)) + TmpDTOriginal.Columns.Add("IVA", GetType(Decimal)) + TmpDTOriginal.Columns.Add("IVAPorcentaje", GetType(Decimal)) + TmpDTOriginal.Columns.Add("RetIVA", GetType(Decimal)) + TmpDTOriginal.Columns.Add("RetIVAPorcentaje", GetType(Decimal)) + TmpDTOriginal.Columns.Add("RetISR", GetType(Decimal)) + TmpDTOriginal.Columns.Add("RetISRPorcentaje", GetType(Decimal)) + TmpDTOriginal.Columns.Add("IEPSPS", GetType(Double)) + TmpDTOriginal.Columns.Add("IEPSPSPorcentaje", GetType(Double)) + TmpDTOriginal.Columns.Add("IEPSPSIVA", GetType(Double)) + TmpDTOriginal.Columns.Add("IEPSPSIVAPorcentaje", GetType(Double)) + TmpDTOriginal.Columns.Add("Descuento", GetType(Decimal)) + TmpDTOriginal.Columns.Add("OtrosGastos", GetType(Decimal)) + TmpDTOriginal.Columns.Add("Total", GetType(Decimal)) + TmpDTOriginal.Columns.Add("AsientoContableCompras", GetType(Integer)) + TmpDTOriginal.Columns.Add("IdCtaContCompras", GetType(Integer)) + TmpDTOriginal.Columns.Add("Proyecto", GetType(String)) + TmpDTOriginal.Columns.Add("CveProyecto", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveContrato", GetType(Integer)) + TmpDTOriginal.Columns.Add("SubProyecto", GetType(String)) + 'TmpDTOriginal.Columns.Add("CveEq", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveAlmacen", GetType(Integer)) + TmpDTOriginal.Columns.Add("CvePersonal", GetType(String)) + TmpDTOriginal.Columns.Add("Referencia", GetType(String)) + + 'AC + TmpDTOriginal.Columns.Add("CveTipoGastoAC", GetType(Integer)) + TmpDTOriginal.Columns.Add("CvePresupuestoEgreso", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveProgramaOperativo", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveUnidadAdministrativa", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveFuenteFinanciamiento", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveClasificacionOG", GetType(Integer)) + + TmpDTOriginal.Columns.Add("IdCuentaComprometido", GetType(Integer)) + TmpDTOriginal.Columns.Add("IdCuentaPorEjercer", GetType(Integer)) + TmpDTOriginal.Columns.Add("IdCuentaDevengado", GetType(Integer)) + TmpDTOriginal.Columns.Add("IdCuentaMatriz", GetType(Integer)) + + 'INVENTARIO SERIE/LOTE + TmpDTOriginal.Columns.Add("CveMetodoInventario", GetType(Integer)) + + TmpDTOriginal.Columns.Add("CveConcepto", GetType(Integer)) + + 'AF + TmpDTOriginal.Columns.Add("CveActivoFijo", GetType(Integer)) + TmpDTOriginal.Columns.Add("CodAF", GetType(String)) + TmpDTOriginal.Columns.Add("TipoAF", GetType(Integer)) + TmpDTOriginal.Columns.Add("AFMedida", GetType(Integer)) + TmpDTOriginal.Columns.Add("AFTipoMantenimiento", GetType(Integer)) + + 'PS + TmpDTOriginal.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDTOriginal.Columns.Add("CodigoPS", GetType(String)) + TmpDTOriginal.Columns.Add("PSDescripcion", GetType(String)) + 'CAMPO ESPECIAL PARA GLUYAS - LEE EL DEL XML - A GLUYAS LE INTERESA EL CODIGO DEL PROVEEDOR + TmpDTOriginal.Columns.Add("PSCodigo", GetType(String)) + + + 'OC + TmpDTOriginal.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDTOriginal.Columns.Add("ProductoOC", GetType(String)) + TmpDTOriginal.Columns.Add("CantidadF", GetType(Double)) + + 'Consignaciones + TmpDTOriginal.Columns.Add("CveAlmacenConsignacion", GetType(Integer)) + TmpDTOriginal.Columns.Add("NoConsignacion", GetType(Integer)) + TmpDTOriginal.Columns.Add("CveConsignacion", GetType(Integer)) + TmpDTOriginal.Columns.Add("HdnPS", GetType(String)) + TmpDTOriginal.Columns.Add("HdnCvePS", GetType(String)) + TmpDTOriginal.Columns.Add("HdnClasificacion", GetType(String)) + TmpDTOriginal.Columns.Add("HdnCveClasificacion", GetType(String)) + TmpDTOriginal.Columns.Add("HdnCveAlmacen", GetType(String)) + + 'Fletes y Servicios + TmpDTOriginal.Columns.Add("AplicaCostoIndirecto", GetType(Integer)) + TmpDTOriginal.Columns.Add("CostoIndirectoAlmacen", GetType(Decimal)) + TmpDTOriginal.Columns.Add("CveCompraDetalle", GetType(Integer)) + + TmpDTOriginal.Columns.Add("EntregaDirecta", GetType(Integer)) + + 'SAT + TmpDTOriginal.Columns.Add("CveSATPS", GetType(Integer)) + TmpDTOriginal.Columns.Add("SATClaveProductoServicio", GetType(String)) + TmpDTOriginal.Columns.Add("CveSATUnidadMedida", GetType(Integer)) + TmpDTOriginal.Columns.Add("SATClaveUnidadMedida", GetType(String)) + + 'Tipo de Gasto + TmpDTOriginal.Columns.Add("CveTipoGasto", GetType(Integer)) + TmpDTOriginal.Columns.Add("TipoGasto", GetType(String)) + TmpDTOriginal.Columns.Add("NoDeducible", GetType(Boolean)) + + TmpDTOriginal.Columns.Add("Importe", GetType(Double)) + + + End Sub + 'Private Sub AddDTEnvio(Cantidad As Double, UM As String, CveUM As Integer, CvePS As Integer, PS As String, PU As Double, CveAlmacen As Integer, CveEq As Integer) + + ' Dim dr As DataRow = DtInv.NewRow + + ' dr("Cantidad") = Cantidad + ' dr("UM") = UM + ' dr("CveUM") = CveUM + ' dr("CvePS") = CvePS + ' dr("PS") = PS + ' dr("PU") = PU + ' dr("CveAlmacen") = CveAlmacen + ' dr("CveEq") = CveEq + + ' DtInv.Rows.InsertAt(dr, hdnIndexInv.Value.ToEntero + 1) + + ' GvInv.DataSource = DtInv + ' GvInv.DataBind() + + + 'End Sub + + Protected Sub RecargaMaximum_Click(sender As Object, e As System.EventArgs) + + CalculaTotales(True) + + 'RVDocumentoImporte.MaximumValue = (TxtSubTotal.Text.ToDouble - TxtDescuento.Text.ToDouble - LblAmortizacion.Text.Trim.ToDouble + TxtIVA.Text.ToDouble - TxtRetIVA.Text.ToDouble - TxtRetISR.Text.ToDouble).FormatoNumero(2) + 'RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + 'RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + End Sub + Protected Sub AlmacenCambiaPS_Click(sender As Object, e As EventArgs) Handles AlmacenCambiaPS.Click + Dim correcto As Boolean = True + Dim x As Integer = 0 + + 'Dim buid As New StringBuilder + For Each Dr As DataRow In TmpDT.Rows + Dim newps As Integer = GvInv.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero + If newps > 0 Then + 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) + Dr("CvePS") = newps + 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) + Else 'limpio el valor para que no truene en linq mas abajo + correcto = False + Alert("Favor de asociar todos los productos o servicios", TipoMensaje.MsgAdvertencia) + Exit For + End If + x = x + 1 + Next + + x = 0 + + For Each Dr As DataRow In DtInv.Rows + Dim newps As Integer = GvInv.Rows(x).FCDropDownList("Ddlnewps").SelectedValue.ToEntero + If newps > 0 Then + 'buid.Append(String.Format("{0} ---> {1},", Dr("CvePS").ToString, newps)) + Dr("CvePS") = newps + 'buid.Append(String.Format("{0} ---> {1},
", Dr("CvePS").ToString, newps)) + Else 'limpio el valor para que no truene en linq mas abajo + correcto = False + Alert("Favor de asociar todos los productos o servicios", TipoMensaje.MsgAdvertencia) + Exit For + End If + x = x + 1 + Next + + TmpDT.AcceptChanges() + 'Alert(buid.ToString) + If correcto Then + If Not CierrePeriodo Then + BtnGuardar.Visible = True + End If + UpFacturar.Update() + End If + + End Sub + Private Sub SetValues() + 'Dim um As New ClsUnidadesMedida + TxtFecha.Text = Now.ToShortDateString() + LblUsuarioCaptura.Text = UsuarioActual.Usuario + DdlProveedor.Attributes.Add("onclick", "CargaProveedores();") + 'DdlFuncionarioEmpleado.Attributes.Add("onclick", "CargaFuncionariosEmpleados();") + TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") + TxtCantidad.Attributes.Add("onKeyUp ", "Recalcula();") + TxtDescuentoModal.Attributes.Add("onKeyUp ", "Recalcula();") + TxtOtrosGastos.Attributes.Add("onKeyUp ", "Recalcula();") + 'ImgAmort.Attributes.Add("onclick", "javascript:$('#DivDescP').show(1000); PosicionaObjeto(this.id,'DivDescP');") ' $get('LblTitulo1').style.display = 'none'; $get('LblTituloTipo1').style.display = 'none'; $get('LblTituloTipo2').style.display = ''; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = ''; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = 'none';") + + 'If um.GetUnidadesMedida() Then + ' GlobalDTUnidadesMedida = um.DtResultados + 'End If + 'um.Dispose() + + 'CargaEstatus() + CargaTiposAF() + CargaProyectoAsignado() + CargaClasificaciones() + CargaPS(-1) + CargaProyecto() + CreaDTCompras() + CargaMonedas() + CargarAlmacen() + 'CreaDtAF() + 'TabOC.Visible = False + + 'BORRAR OC + 'Valores para Vinculacion OC + 'If UsuarioActual.Empresa.MetodoOC = 1 Then GvOC2.Columns(2).Visible = False : tdSurtirOC.Visible = False Else GvOC2.Columns(0).Visible = False : tdFolioOC.Visible = False + + CveAlmacenConsignacion = -1 + CveConsignacion = -1 + OCVinculada = False + TipoCambioOC = -1 + EstatusAlmacen = -1 + CreaDtDetalle() + + CargarUMAlias() + + End Sub +#End Region + +#Region " ALGO DE AF QUE NUNCA SE USABA " 'Protected Sub GVAF_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAF.RowCreated ' If e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal) Then ' e.Row.FCDropDownList("DdlTipoActivoFijo").DataSource = TmpDTTiposAF @@ -11070,46 +11084,46 @@ Partial Class Compras_Compras ' PnlFuncionarioEmpleado.Visible = chkFuncionariosEmpleados.Checked ' UPCondicionesPago.Update() 'End Sub - Protected Sub BtnOCAceptar_Click(sender As Object, e As EventArgs) Handles BtnOCAceptar.Click - 'carga la OC - Dim CveOC As Integer = -1 - For Each gvr As GridViewRow In GvOC.Rows - If gvr.FCCheckBox("Chk").Checked Then - CveOC = gvr.DataKey("CveOrdenCompra").ToEntero - Exit For - End If - Next - - Dim dt As DataTable = Nothing - If CveOC > 0 Then - - Dim OC As New ClsOC - - If OC.GetOC(CveOC, UsuarioActual.CveEmpresa) Then - - TxtOC.Text = OC.Folio.ToString - 'RegistraScript(String.Format("$get('TxtOC').value = '{0}';tb_remove;", OC.Folio)) - RegistraScript("tb_remove();") - - If OC.GetOrdenesDetalle(CveOC) Then - dt = OC.DtResultados - End If - End If - - OC.Dispose() - End If - - 'GvOCC.DataSource = TmpDT - 'GvOCC.DataBind() - 'GvOCC2.DataSource = dt - 'GvOCC2.DataBind() - - 'UpnAF.Update() - - End Sub -#End Region + Protected Sub BtnOCAceptar_Click(sender As Object, e As EventArgs) Handles BtnOCAceptar.Click + 'carga la OC + Dim CveOC As Integer = -1 + For Each gvr As GridViewRow In GvOC.Rows + If gvr.FCCheckBox("Chk").Checked Then + CveOC = gvr.DataKey("CveOrdenCompra").ToEntero + Exit For + End If + Next -#Region "Estimaciones" + Dim dt As DataTable = Nothing + If CveOC > 0 Then + + Dim OC As New ClsOC + + If OC.GetOC(CveOC, UsuarioActual.CveEmpresa) Then + + TxtOC.Text = OC.Folio.ToString + 'RegistraScript(String.Format("$get('TxtOC').value = '{0}';tb_remove;", OC.Folio)) + RegistraScript("tb_remove();") + + If OC.GetOrdenesDetalle(CveOC) Then + dt = OC.DtResultados + End If + End If + + OC.Dispose() + End If + + 'GvOCC.DataSource = TmpDT + 'GvOCC.DataBind() + 'GvOCC2.DataSource = dt + 'GvOCC2.DataBind() + + 'UpnAF.Update() + + End Sub +#End Region + +#Region "Estimaciones" 'Private Sub CargaDatosEstimaciones(pCveProveedor As Integer) ' Dim Con As New ClsContratos @@ -11143,354 +11157,354 @@ Partial Class Compras_Compras ' End If 'End Sub -#End Region +#End Region -#Region " ALMACEN " - Private Sub CargaGvInv() - - 'SI ES CONSIGNACION NO LIMITA POR TIPO PS - PARA GLUYAS - If ChkConsignacion.Checked Then - DtInv = TmpDT.Copy - Else - DtInv = TmpDT.FiltraParametros(String.Format("CveTipoPS = 2")).Copy - End If - - GvInv.DataSource = DtInv - GvInv.DataBind() - - 'If (GvInv.Rows.Count > 0) Then - ' GvInv.UseAccessibleHeader = True - ' GvInv.HeaderRow.TableSection = TableRowSection.TableHeader - ' RegistraScript("OrdenarGVInv();") - 'End If - - InicializaCargaEvidenciaAlmacen() - - 'CARGA VALORES YA SELECCIONADOS DE CONSIGNACION - If ChkConsignacion.Checked Then - End If - - UpINV.Update() - - End Sub - - Private Sub CargaFletesAgregados() - CreaDTServicios() - BtnFiltrar_Click(Nothing, Nothing) - End Sub - - Protected Sub GVINV_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvInv.RowEditing - CargaGvInv() - End Sub - - Protected Sub GVINV_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvInv.RowCancelingEdit - CargaGvInv() - End Sub - - Protected Sub GVINV_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvInv.RowUpdating - Dim Cantidad As Double = DirectCast(GvInv.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDouble - Dim CveUnidadMedida As Integer = DirectCast(GvInv.Rows(e.RowIndex).FindControl("ddlEUnidad"), DropDownList).SelectedValue.ToString.ToEntero - DtInv.Rows.Item(e.RowIndex)("Cantidad") = Cantidad - DtInv.Rows.Item(e.RowIndex)("CveUM") = CveUnidadMedida - - CargaGvInv() - End Sub - - Protected Sub GVINV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - 'SI USA SERIE-LOTE INVENTARIO - If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then - e.Row.FCButton("BtnSerieLote").Visible = True - e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("Cantidad")) - e.Row.FCTextBox("TbCantidad").Enabled = False - e.Row.FCCheckBox("cbInv").Enabled = False - Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", e.Row.DataKey("CvePS"))).Rows.Count - e.Row.FCTextBox("TbCantidad").Text = Contador.ToString - 'e.Row.FCTextBox("TbCantidadF").Text = "0" - Else - e.Row.FCButton("BtnSerieLote").Visible = False - e.Row.FCTextBox("TbCantidad").Enabled = True - e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) - End If - - 'SIEMPRE ENABLED FALSE - e.Row.FCCheckBox("cbInv").Enabled = False - - 'si ya hay cargada una compra - If CveCompra > 0 AndAlso CveMovimientoAlmacen > 0 Then - If e.Row.DBCampo("AlmacenRegistrado").ToString = "1" Then - e.Row.FCCheckBox("cbInv").Checked = True - End If - e.Row.FCCheckBox("cbInv").Enabled = False - End If - - 'CONSIGNACIONES - If ChkConsignacion.Checked Then - e.Row.FCTextBox("TbCantidad").Enabled = False - e.Row.FCCheckBox("cbInv").Enabled = False - - If Not OCVinculada Then - e.Row.Cells(3).Text = e.Row.DBCampo("PSCodigo").ToString - End If - - Else - If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then - e.Row.FCTextBox("TbCantidad").Enabled = False - Else - e.Row.FCTextBox("TbCantidad").Enabled = True - End If - - e.Row.FCCheckBox("cbInv").Enabled = False - End If - - If UsuarioActual.Empresa.UsaAC Then - e.Row.FCCheckBox("cbInv").Enabled = False - End If - - e.Row.FCDropDownList("ddlEAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2,7,14,19)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("ddlEAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) - e.Row.FCDropDownList("ddlEAlmacen").DataBind() - 'e.Row.FCDropDownList("ddlEAlmacen").SelectedValue = If(e.Row.DBCampo("CveAlmacen").ToEntero <= 0, "-1", e.Row.DBCampo("CveAlmacen")) - If UsuarioActual.Empresa.UsaAC Then e.Row.FCDropDownList("ddlEAlmacen").Enabled = False - - If Not e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then - e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF")))) - e.Row.FCTextBox("TbCantidad").Text = If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF")) - End If - - 'e.Row.FCImageButton("btnImgDestino").Attributes.Add("onclick", "javascript:$('#DivAlmacen').show(500); PosicionaObjeto(this.id,'DivAlmacen'); CargarValores('" & e.Row.RowIndex & "','" & e.Row.DBCampo("Cantidad") & "','" & e.Row.DBCampo("PS").Replace("'", "\'") & "'); ") - ' e.Row.FCImageButton("btnImgDestino").ID = e.Row.FCImageButton("btnImgDestino").ID.ToString + e.Row.RowIndex.ToString - 'e.Row.Cells(6).ToolTip = "Enviar a otro Almacén." - - If e.Row.DBCampo("Consec").ToEntero = 0 Then - e.Row.BackColor = Drawing.Color.PaleGreen - End If - - If UsuarioActual.CveEmpresa = 66 Then - e.Row.FCDropDownList("DdlRecibirInv").Items.RemoveAt(1) - End If - - 'If isAlmacenistaGluyas() Then - ' Dim dt As DataTable = Nothing - ' dt = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS=2", "PS") - ' e.Row.FCDropDownList("Ddlnewps").DataSource = dt 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - ' e.Row.FCDropDownList("Ddlnewps").DataBind() - ' e.Row.FCDropDownList("Ddlnewps").Items.Insert(0, New ListItem("Seleccione", "-1")) - ' dt.Dispose() - 'End If - - 'Consignaciones - If CveConsignacion > 0 Then - ''CARGA ALMACEN CONSIGNACION - e.Row.FCDropDownList("ddlAlmacenConsignacion").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) - e.Row.FCDropDownList("ddlAlmacenConsignacion").DataBind() - - If e.Row.DBCampo("CveAlmacenConsignacion").ToEntero > 0 Then - e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValueExist(e.Row.DBCampo("CveAlmacenConsignacion")) - End If - - ''CARGA CONSIGNACIONES - e.Row.FCDropDownList("DdlVinculaConsignacion").DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValue)) - e.Row.FCDropDownList("DdlVinculaConsignacion").DataBind() - e.Row.FCDropDownList("DdlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) - - If e.Row.DBCampo("NoConsignacion").ToEntero > 0 Then - e.Row.FCDropDownList("DdlVinculaConsignacion").SelectedValueExist(e.Row.DBCampo("NoConsignacion")) - e.Row.FCHiddenField("HdnNoConsignacion").Value = e.Row.DBCampo("NoConsignacion") - End If - - If e.Row.DBCampo("CveConsignacion").ToEntero > 0 Then - e.Row.FCHiddenField("HdnCveConsignacion").Value = e.Row.DBCampo("CveConsignacion") - e.Row.FCHiddenField("HdnPS").Value = e.Row.DBCampo("HdnPS") - e.Row.FCHiddenField("HdnCvePS").Value = e.Row.DBCampo("HdnCvePS") - e.Row.FCHiddenField("HdnClasificacion").Value = e.Row.DBCampo("HdnClasificacion") - e.Row.FCHiddenField("HdnCveClasificacion").Value = e.Row.DBCampo("HdnCveClasificacion") - e.Row.FCHiddenField("HdnCveAlmacen").Value = e.Row.DBCampo("HdnCveAlmacen") - End If - - e.Row.FCTextBox("TxtDividir").Visible = True - Else - e.Row.FCTextBox("TxtDividir").Visible = False - End If - - If Not UsuarioActual.Empresa.UsaAC Then - - - e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirCompra").ClientID)) - - e.Row.FCTextBox("TxtDividir").Text = "" - If e.Row.DBCampo("Cantidad").ToDouble > 0.02 Then - e.Row.FCButton("BtnDividirCompra").CommandArgument = e.Row.RowIndex.ToString - Else - e.Row.FCButton("BtnDividirCompra").Visible = False - e.Row.FCTextBox("TxtDividir").Visible = False - End If - End If - - End If - - 'HEADER GvInv - If e.Row.RowType = DataControlRowType.Header Then - Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2,7,14,19)" - - If UsuarioActual.CveUsuario.Contiene(1397, 1517, 1565) Then ' iliana, horacio, marco, RMF. 2017.03.13 - StrAlmacenes = "CveTipoAlmacen IN (1,2,7,14,12,19)" - End If - e.Row.FCDropDownList("ddlAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("ddlAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) - e.Row.FCDropDownList("ddlAlmacen").DataBind() - - 'si ya hay cargada una compra - If CveCompra > 0 AndAlso CveMovimientoAlmacen > 0 Then - e.Row.FCCheckBox("cbAll").Enabled = False - End If - - ''CARGA ALMACEN CONSIGNACION - e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) - e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataBind() - End If - - End Sub - - Protected Sub ddlAlmacen_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) - Dim Ddl As DropDownList = CType(sender, DropDownList) - - For i As Integer = 0 To GvInv.Rows.Count - 1 - GvInv.Rows(i).FCDropDownList("ddlEAlmacen").SelectedValue = Ddl.SelectedValue - Next - - InicializaCargaEvidenciaAlmacen() - - End Sub - 'Protected Sub btnAgregarEq_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click - - - ' Dim eq As New ClsProductosServicios - ' Dim Unidad As String = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString - ' Dim CvePS As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CvePS").ToString.ToEntero - ' Dim CveUM As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM").ToString.ToEntero - ' Dim PU As Double = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("PU").ToString.ToDouble - - ' Dim tCve As Integer = 0 - ' Dim ErrorUM As Boolean = False - - ' If UsuarioActual.Empresa.UsaInventarios And CveUM = 0 Then - ' Dim UM As New ClsUnidadesMedida - ' tCve = UM.AddUnidadMedida(TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) - - ' If tCve > 0 Then - ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM") = tCve - ' Else - ' ErrorUM = True - ' End If - - - ' End If - - ' If Not ErrorUM Then - - ' If eq.AddPSEquivalencias(CvePS, CveUM, txtCantidadEq.Text.ToDecimal, False, PU, UsuarioActual.CveUsuario) Then - ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveEq") = 1 - - ' End If - - - ' End If - - - ' GvPS.DataSource = TmpDT - ' GvPS.DataBind() - - ' eq.Dispose() - - ' txtCantidadEq.Text = "" - 'End Sub - - - 'Protected Sub Enviar_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAdd.Click - - ' If TbCantidadAlm.Text.ToDouble < DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble And TbCantidadAlm.Text.ToDouble > 0 Then - - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad") = DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble - TbCantidadAlm.Text.ToDouble - ' AddDTEnvio(TbCantidadAlm.Text.ToDouble, - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("UM").ToString, - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveUM").ToString.ToEntero, - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CvePS").ToString().ToEntero, - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PS").ToString, - ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PU").ToString.ToDouble, - ' ddlAlmacenAdd.SelectedValue.ToEntero, DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveEq").ToString.ToEntero) - - - ' Else - ' Alert("El campo cantidad es necesario que sea mayor que 0 y menor al registro seleccionado.") - - - ' End If - - ' TbCantidadAlm.Text = "" - ' ddlAlmacenAdd.SelectedIndex = 0 - ' UpINV.Update() - - ' ' Alert(TmpDT.Rows.Count.ToString) - - - - 'End Sub - - - Protected Sub cbAll_CheckedChanged(sender As Object, e As EventArgs) - For i As Integer = 0 To GvInv.Rows.Count - 1 - GvInv.Rows(i).FCCheckBox("cbInv").Checked = GvInv.HeaderRow.FCCheckBox("cbAll").Checked - Next - CalculaTotalPorDevengar() - End Sub - - Private Sub InicializaCargaEvidenciaAlmacen() - - TableAlmacenEvidencia.Visible = False - - If UsuarioActual.CveEmpresa = 13 Then - If GvInv.Rows.Count > 0 AndAlso GvInv.HeaderRow().FCDropDownList("ddlAlmacen").SelectedValue.ToEntero > 0 Then - Dim DrAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow().FCDropDownList("ddlAlmacen").SelectedValue.ToEntero)) - If DrAlmacen("CveTipoAlmacen").ToString = "7" Then - TableAlmacenEvidencia.Visible = True - End If - End If - End If - - UpAlmacenEvidencia.Update() - - End Sub -#End Region +#Region " ALMACEN " + Private Sub CargaGvInv() -#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE" + 'SI ES CONSIGNACION NO LIMITA POR TIPO PS - PARA GLUYAS + If ChkConsignacion.Checked Then + DtInv = TmpDT.Copy + Else + DtInv = TmpDT.FiltraParametros(String.Format("CveTipoPS = 2")).Copy + End If + + GvInv.DataSource = DtInv + GvInv.DataBind() + + 'If (GvInv.Rows.Count > 0) Then + ' GvInv.UseAccessibleHeader = True + ' GvInv.HeaderRow.TableSection = TableRowSection.TableHeader + ' RegistraScript("OrdenarGVInv();") + 'End If + + InicializaCargaEvidenciaAlmacen() + + 'CARGA VALORES YA SELECCIONADOS DE CONSIGNACION + If ChkConsignacion.Checked Then + End If + + UpINV.Update() - Private Sub CargaTipoTransaccion() - DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") - DdlTipoTransaccion.DataBind() - DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) - - DdlTipoTransaccionCaja.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") - DdlTipoTransaccionCaja.DataBind() - DdlTipoTransaccionCaja.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) - End Sub - - Private Sub CargaCuentas() - DdlCuenta.Items.Clear() - DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveTipoCuenta <> 1")) - DdlCuenta.DataBind() - DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlCuentaCaja.Items.Clear() - DdlCuentaCaja.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveTipoCuenta = 1")) - DdlCuentaCaja.DataBind() - DdlCuentaCaja.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub -#End Region + Private Sub CargaFletesAgregados() + CreaDTServicios() + BtnFiltrar_Click(Nothing, Nothing) + End Sub -#Region "FINANCIAMIENTO - AC" + Protected Sub GVINV_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvInv.RowEditing + CargaGvInv() + End Sub + + Protected Sub GVINV_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvInv.RowCancelingEdit + CargaGvInv() + End Sub + + Protected Sub GVINV_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvInv.RowUpdating + Dim Cantidad As Double = DirectCast(GvInv.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDouble + Dim CveUnidadMedida As Integer = DirectCast(GvInv.Rows(e.RowIndex).FindControl("ddlEUnidad"), DropDownList).SelectedValue.ToString.ToEntero + DtInv.Rows.Item(e.RowIndex)("Cantidad") = Cantidad + DtInv.Rows.Item(e.RowIndex)("CveUM") = CveUnidadMedida + + CargaGvInv() + End Sub + + Protected Sub GVINV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + 'SI USA SERIE-LOTE INVENTARIO + If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then + e.Row.FCButton("BtnSerieLote").Visible = True + e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("Cantidad")) + e.Row.FCTextBox("TbCantidad").Enabled = False + e.Row.FCCheckBox("cbInv").Enabled = False + Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", e.Row.DataKey("CvePS"))).Rows.Count + e.Row.FCTextBox("TbCantidad").Text = Contador.ToString + 'e.Row.FCTextBox("TbCantidadF").Text = "0" + Else + e.Row.FCButton("BtnSerieLote").Visible = False + e.Row.FCTextBox("TbCantidad").Enabled = True + e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) + End If + + 'SIEMPRE ENABLED FALSE + e.Row.FCCheckBox("cbInv").Enabled = False + + 'si ya hay cargada una compra + If CveCompra > 0 AndAlso CveMovimientoAlmacen > 0 Then + If e.Row.DBCampo("AlmacenRegistrado").ToString = "1" Then + e.Row.FCCheckBox("cbInv").Checked = True + End If + e.Row.FCCheckBox("cbInv").Enabled = False + End If + + 'CONSIGNACIONES + If ChkConsignacion.Checked Then + e.Row.FCTextBox("TbCantidad").Enabled = False + e.Row.FCCheckBox("cbInv").Enabled = False + + If Not OCVinculada Then + e.Row.Cells(3).Text = e.Row.DBCampo("PSCodigo").ToString + End If + + Else + If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then + e.Row.FCTextBox("TbCantidad").Enabled = False + Else + e.Row.FCTextBox("TbCantidad").Enabled = True + End If + + e.Row.FCCheckBox("cbInv").Enabled = False + End If + + If UsuarioActual.Empresa.UsaAC Then + e.Row.FCCheckBox("cbInv").Enabled = False + End If + + e.Row.FCDropDownList("ddlEAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2,7,14,19)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("ddlEAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) + e.Row.FCDropDownList("ddlEAlmacen").DataBind() + 'e.Row.FCDropDownList("ddlEAlmacen").SelectedValue = If(e.Row.DBCampo("CveAlmacen").ToEntero <= 0, "-1", e.Row.DBCampo("CveAlmacen")) + If UsuarioActual.Empresa.UsaAC Then e.Row.FCDropDownList("ddlEAlmacen").Enabled = False + + If Not e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then + e.Row.FCTextBox("TbCantidad").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF")))) + e.Row.FCTextBox("TbCantidad").Text = If(e.Row.DBCampo("CantidadF").ToString.ToDecimal > e.Row.DBCampo("Cantidad").ToString.ToDecimal, e.Row.DBCampo("Cantidad"), e.Row.DBCampo("CantidadF")) + End If + + 'e.Row.FCImageButton("btnImgDestino").Attributes.Add("onclick", "javascript:$('#DivAlmacen').show(500); PosicionaObjeto(this.id,'DivAlmacen'); CargarValores('" & e.Row.RowIndex & "','" & e.Row.DBCampo("Cantidad") & "','" & e.Row.DBCampo("PS").Replace("'", "\'") & "'); ") + ' e.Row.FCImageButton("btnImgDestino").ID = e.Row.FCImageButton("btnImgDestino").ID.ToString + e.Row.RowIndex.ToString + 'e.Row.Cells(6).ToolTip = "Enviar a otro Almacén." + + If e.Row.DBCampo("Consec").ToEntero = 0 Then + e.Row.BackColor = Drawing.Color.PaleGreen + End If + + If UsuarioActual.CveEmpresa = 66 Then + e.Row.FCDropDownList("DdlRecibirInv").Items.RemoveAt(1) + End If + + 'If isAlmacenistaGluyas() Then + ' Dim dt As DataTable = Nothing + ' dt = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS=2", "PS") + ' e.Row.FCDropDownList("Ddlnewps").DataSource = dt 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + ' e.Row.FCDropDownList("Ddlnewps").DataBind() + ' e.Row.FCDropDownList("Ddlnewps").Items.Insert(0, New ListItem("Seleccione", "-1")) + ' dt.Dispose() + 'End If + + 'Consignaciones + If CveConsignacion > 0 Then + ''CARGA ALMACEN CONSIGNACION + e.Row.FCDropDownList("ddlAlmacenConsignacion").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) + e.Row.FCDropDownList("ddlAlmacenConsignacion").DataBind() + + If e.Row.DBCampo("CveAlmacenConsignacion").ToEntero > 0 Then + e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValueExist(e.Row.DBCampo("CveAlmacenConsignacion")) + End If + + ''CARGA CONSIGNACIONES + e.Row.FCDropDownList("DdlVinculaConsignacion").DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", e.Row.FCDropDownList("ddlAlmacenConsignacion").SelectedValue)) + e.Row.FCDropDownList("DdlVinculaConsignacion").DataBind() + e.Row.FCDropDownList("DdlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) + + If e.Row.DBCampo("NoConsignacion").ToEntero > 0 Then + e.Row.FCDropDownList("DdlVinculaConsignacion").SelectedValueExist(e.Row.DBCampo("NoConsignacion")) + e.Row.FCHiddenField("HdnNoConsignacion").Value = e.Row.DBCampo("NoConsignacion") + End If + + If e.Row.DBCampo("CveConsignacion").ToEntero > 0 Then + e.Row.FCHiddenField("HdnCveConsignacion").Value = e.Row.DBCampo("CveConsignacion") + e.Row.FCHiddenField("HdnPS").Value = e.Row.DBCampo("HdnPS") + e.Row.FCHiddenField("HdnCvePS").Value = e.Row.DBCampo("HdnCvePS") + e.Row.FCHiddenField("HdnClasificacion").Value = e.Row.DBCampo("HdnClasificacion") + e.Row.FCHiddenField("HdnCveClasificacion").Value = e.Row.DBCampo("HdnCveClasificacion") + e.Row.FCHiddenField("HdnCveAlmacen").Value = e.Row.DBCampo("HdnCveAlmacen") + End If + + e.Row.FCTextBox("TxtDividir").Visible = True + Else + e.Row.FCTextBox("TxtDividir").Visible = False + End If + + If Not UsuarioActual.Empresa.UsaAC Then + + + e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirCompra").ClientID)) + + e.Row.FCTextBox("TxtDividir").Text = "" + If e.Row.DBCampo("Cantidad").ToDouble > 0.02 Then + e.Row.FCButton("BtnDividirCompra").CommandArgument = e.Row.RowIndex.ToString + Else + e.Row.FCButton("BtnDividirCompra").Visible = False + e.Row.FCTextBox("TxtDividir").Visible = False + End If + End If + + End If + + 'HEADER GvInv + If e.Row.RowType = DataControlRowType.Header Then + Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2,7,14,19)" + + If UsuarioActual.CveUsuario.Contiene(1397, 1517, 1565) Then ' iliana, horacio, marco, RMF. 2017.03.13 + StrAlmacenes = "CveTipoAlmacen IN (1,2,7,14,12,19)" + End If + e.Row.FCDropDownList("ddlAlmacen").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("ddlAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) + e.Row.FCDropDownList("ddlAlmacen").DataBind() + + 'si ya hay cargada una compra + If CveCompra > 0 AndAlso CveMovimientoAlmacen > 0 Then + e.Row.FCCheckBox("cbAll").Enabled = False + End If + + ''CARGA ALMACEN CONSIGNACION + e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) + e.Row.FCDropDownList("ddlAlmacenConsignacionGeneral").DataBind() + End If + + End Sub + + Protected Sub ddlAlmacen_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) + Dim Ddl As DropDownList = CType(sender, DropDownList) + + For i As Integer = 0 To GvInv.Rows.Count - 1 + GvInv.Rows(i).FCDropDownList("ddlEAlmacen").SelectedValue = Ddl.SelectedValue + Next + + InicializaCargaEvidenciaAlmacen() + + End Sub + 'Protected Sub btnAgregarEq_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click + + + ' Dim eq As New ClsProductosServicios + ' Dim Unidad As String = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString + ' Dim CvePS As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CvePS").ToString.ToEntero + ' Dim CveUM As Integer = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM").ToString.ToEntero + ' Dim PU As Double = TmpDT.Rows.Item(HdnEq.Value.ToEntero)("PU").ToString.ToDouble + + ' Dim tCve As Integer = 0 + ' Dim ErrorUM As Boolean = False + + ' If UsuarioActual.Empresa.UsaInventarios And CveUM = 0 Then + ' Dim UM As New ClsUnidadesMedida + ' tCve = UM.AddUnidadMedida(TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, TmpDT.Rows.Item(HdnEq.Value.ToEntero)("UM").ToString, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) + + ' If tCve > 0 Then + ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveUM") = tCve + ' Else + ' ErrorUM = True + ' End If + + + ' End If + + ' If Not ErrorUM Then + + ' If eq.AddPSEquivalencias(CvePS, CveUM, txtCantidadEq.Text.ToDecimal, False, PU, UsuarioActual.CveUsuario) Then + ' TmpDT.Rows.Item(HdnEq.Value.ToEntero)("CveEq") = 1 + + ' End If + + + ' End If + + + ' GvPS.DataSource = TmpDT + ' GvPS.DataBind() + + ' eq.Dispose() + + ' txtCantidadEq.Text = "" + 'End Sub + + + 'Protected Sub Enviar_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAdd.Click + + ' If TbCantidadAlm.Text.ToDouble < DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble And TbCantidadAlm.Text.ToDouble > 0 Then + + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad") = DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("Cantidad").ToString.ToDouble - TbCantidadAlm.Text.ToDouble + ' AddDTEnvio(TbCantidadAlm.Text.ToDouble, + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("UM").ToString, + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveUM").ToString.ToEntero, + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CvePS").ToString().ToEntero, + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PS").ToString, + ' DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PU").ToString.ToDouble, + ' ddlAlmacenAdd.SelectedValue.ToEntero, DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveEq").ToString.ToEntero) + + + ' Else + ' Alert("El campo cantidad es necesario que sea mayor que 0 y menor al registro seleccionado.") + + + ' End If + + ' TbCantidadAlm.Text = "" + ' ddlAlmacenAdd.SelectedIndex = 0 + ' UpINV.Update() + + ' ' Alert(TmpDT.Rows.Count.ToString) + + + + 'End Sub + + + Protected Sub cbAll_CheckedChanged(sender As Object, e As EventArgs) + For i As Integer = 0 To GvInv.Rows.Count - 1 + GvInv.Rows(i).FCCheckBox("cbInv").Checked = GvInv.HeaderRow.FCCheckBox("cbAll").Checked + Next + CalculaTotalPorDevengar() + End Sub + + Private Sub InicializaCargaEvidenciaAlmacen() + + TableAlmacenEvidencia.Visible = False + + If UsuarioActual.CveEmpresa = 13 Then + If GvInv.Rows.Count > 0 AndAlso GvInv.HeaderRow().FCDropDownList("ddlAlmacen").SelectedValue.ToEntero > 0 Then + Dim DrAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow().FCDropDownList("ddlAlmacen").SelectedValue.ToEntero)) + If DrAlmacen("CveTipoAlmacen").ToString = "7" Then + TableAlmacenEvidencia.Visible = True + End If + End If + End If + + UpAlmacenEvidencia.Update() + + End Sub +#End Region + +#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE" + + Private Sub CargaTipoTransaccion() + DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") + DdlTipoTransaccion.DataBind() + DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + + DdlTipoTransaccionCaja.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") + DdlTipoTransaccionCaja.DataBind() + DdlTipoTransaccionCaja.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + End Sub + + Private Sub CargaCuentas() + DdlCuenta.Items.Clear() + DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveTipoCuenta <> 1")) + DdlCuenta.DataBind() + DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlCuentaCaja.Items.Clear() + DdlCuentaCaja.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveTipoCuenta = 1")) + DdlCuentaCaja.DataBind() + DdlCuentaCaja.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + +#End Region + +#Region "FINANCIAMIENTO - AC" 'Private Sub CreaDtAC() ' DtAC = New DataTable ' DtAC.Columns.Add("IdCuenta", GetType(String)) @@ -11530,418 +11544,418 @@ Partial Class Compras_Compras ' End If 'End Sub -#End Region +#End Region + +#Region "TAB - PERSONAL" + Private Sub CargaGvPersonal() + GvPersonal.DataSource = TmpDT + GvPersonal.DataBind() + UpGvPersonal.Update() + + End Sub + + Protected Sub DdlProyectoPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, DropDownList)).NamingContainer, GridViewRow) + Dim CveProyecto = If(gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero, -1) + gvRow.FCDropDownList("DdlSubProyectoPersonal").Items.Clear() + If CveProyecto > 0 Or UsuarioActual.Empresa.Tipo_CentroCosto.Contiene(1, 2) Then + gvRow.FCDropDownList("DdlSubProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, CveProyecto, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(CveProyecto, -1, UsuarioActual.CveEmpresa, 1)) + End If + gvRow.FCDropDownList("DdlSubProyectoPersonal").DataBind() + gvRow.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + Protected Sub DdlSubProyectoPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, DropDownList)).NamingContainer, GridViewRow) + Dim CveProyecto = If(gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero, -1) + Dim CveSubProyecto = If(gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedValue.ToEntero, -1) + Dim dr1 As DataRow = TmpDT.Rows(gvRow.RowIndex) + dr1("CveProyecto") = CveProyecto + dr1("CveSubProyecto") = CveSubProyecto + dr1("Proyecto") = If(CveProyecto > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedItem.Text, "") + dr1("SubProyecto") = If(CveSubProyecto > 0, gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedItem.Text, "") + TmpDT.AcceptChanges() + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + End Sub + + Private Sub DdlPersonalHeader_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalHeader.SelectedIndexChanged + For Each Gvr As GridViewRow In GvPersonal.Rows + Gvr.FCDropDownList("DdlPersonalGv").SelectedValue = DdlPersonalHeader.SelectedValue + Next + UpGvPersonal.Update() + End Sub + + Private Sub CargaDdlPersonal() + 'DdlPersonalGv.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + 'DdlPersonalGv.DataBind() + + DdlPersonalHeader.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + DdlPersonalHeader.DataBind() + UpGvPersonal.Update() + End Sub + + Private Sub GvPersonal_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPersonal.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCDropDownList("DdlPersonalGv").DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlPersonalGv").DataBind() + + If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Or UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then + e.Row.FCDropDownList("DdlSubProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + e.Row.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) + e.Row.FCDropDownList("DdlSubProyectoPersonal").DataBind() + e.Row.FCDropDownList("DdlProyectoPersonal").Visible = False + Else + e.Row.FCDropDownList("DdlProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) + e.Row.FCDropDownList("DdlProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) + e.Row.FCDropDownList("DdlProyectoPersonal").DataBind() + e.Row.FCDropDownList("DdlProyectoPersonal").SelectedValueExist(e.Row.DBCampo("CveProyecto")) + If e.Row.DBCampo("CveProyecto").ToEntero > 0 Then + e.Row.FCDropDownList("DdlSubProyectoPersonal").DataSource = + If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), + GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, e.Row.DBCampo("CveProyecto").ToEntero, UsuarioActual.CveEmpresa, -1, 1), + GlobalDTSubProyectos(e.Row.DBCampo("CveProyecto").ToEntero, -1, UsuarioActual.CveEmpresa, 1)) + End If + e.Row.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) + e.Row.FCDropDownList("DdlSubProyectoPersonal").DataBind() + End If + e.Row.FCDropDownList("DdlSubProyectoPersonal").SelectedValueExist(e.Row.DBCampo("CveSubProyecto")) + + If CveCompra > 0 Then + If e.Row.DBCampo("CvePersonal").ToEntero <> -1 And e.Row.DBCampo("CvePersonal") <> Nothing Then + e.Row.FCDropDownList("DdlPersonalGv").SelectedValue = e.Row.DBCampo("CvePersonal") + End If + If e.Row.DBCampo("Referencia").ToString <> "" And e.Row.DBCampo("Referencia") <> Nothing Then + e.Row.FCTextBox("TxtReferencia").Text = e.Row.DBCampo("Referencia") + End If + e.Row.FCTextBox("TxtDividir").Enabled = False + End If + e.Row.FCLinkButton("BtnDividirPersonal").Attributes.Add("onclick", String.Format("DividirPersonal('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) + e.Row.FCLinkButton("BtnDividirPersonal").CommandArgument = e.Row.RowIndex.ToString + e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCLinkButton("BtnDividirPersonal").ClientID)) + + + End If + End Sub + + Protected Sub DividirPersonal(sender As Object, e As EventArgs) + Dim index2 As Integer = 0 + + For Each Row As DataRow In TmpDT.Rows + If GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text <> "" Then + Row("Referencia") = GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text + End If + If GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue <> "-1" Then + Row("CvePersonal") = GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue + End If + index2 += 1 + Next + + 'index2 = 0 + 'For Each Row As DataRow In TmpDT.Rows + ' If GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + ' Row("CveActivoFijo") = GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero + ' Row("CodAF") = GvAFCompras.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString + ' Row("TipoAF") = 1 + ' End If + ' index2 += 1 + 'Next + + 'Dim Index As Integer = CType(sender, LinkButton).CommandArgument.ToString.ToEntero + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + Dim Index As Integer = gvRow.RowIndex + Dim Cantidad As String = HdnCantidadPersonal.Value + Dim dr1 As DataRow = TmpDT.Rows(Index) + Dim dr As DataRow = TmpDT.NewRow + dr.ItemArray = dr1.ItemArray + dr1("Cantidad") = (dr1("Cantidad").ToString.ToDouble - Cantidad.ToDouble) + dr1("Total") = dr1("PU").ToString.ToDouble * dr1("Cantidad").ToString.ToDouble + dr1("IVA") = Math.Round(dr1("IVAPorcentaje").ToString.ToDouble * dr1("Total").ToString.ToDouble, 6) + + TmpDT.AcceptChanges() + + dr("CvePersonal") = 0 + dr("Referencia") = "" + dr("CveActivoFijo") = 0 + dr("CodAF") = 0 + dr("Cantidad") = Cantidad.ToDouble + dr("Total") = dr("PU").ToString.ToDouble * Cantidad.ToDouble + dr("IVA") = Math.Round(dr("IVAPorcentaje").ToString.ToDouble * dr("Total").ToString.ToDouble, 6) + TmpDT.Rows.InsertAt(dr, Index) + TmpDT.AcceptChanges() + + index2 = 0 + For Each Row As DataRow In TmpDT.Rows + Row("Consec") = index2 + index2 += 1 + Next + TmpDT.AcceptChanges() + + CargaGvPersonal() + + 'TmpDT = DtAFInsumos.Copy + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + 'Afecta GVINV y GvAF + CargaGvInv() + CargaGVsAF() + CalculaTotales(True) + + index2 = 0 + For Each Row As DataRow In TmpDT.Rows + If Row("Referencia").ToString <> "" Then + GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text = Row("Referencia").ToString + End If + If Row("CvePersonal").ToString <> "" Then + GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue = Row("CvePersonal").ToString + End If + index2 += 1 + Next + -#Region "TAB - PERSONAL" - Private Sub CargaGvPersonal() - GvPersonal.DataSource = TmpDT - GvPersonal.DataBind() - UpGvPersonal.Update() - - End Sub - - Protected Sub DdlProyectoPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, DropDownList)).NamingContainer, GridViewRow) - Dim CveProyecto = If(gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero, -1) - gvRow.FCDropDownList("DdlSubProyectoPersonal").Items.Clear() - If CveProyecto > 0 Or UsuarioActual.Empresa.Tipo_CentroCosto.Contiene(1, 2) Then - gvRow.FCDropDownList("DdlSubProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, CveProyecto, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(CveProyecto, -1, UsuarioActual.CveEmpresa, 1)) - End If - gvRow.FCDropDownList("DdlSubProyectoPersonal").DataBind() - gvRow.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - - Protected Sub DdlSubProyectoPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, DropDownList)).NamingContainer, GridViewRow) - Dim CveProyecto = If(gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedValue.ToEntero, -1) - Dim CveSubProyecto = If(gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedValue.ToEntero > 0, gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedValue.ToEntero, -1) - Dim dr1 As DataRow = TmpDT.Rows(gvRow.RowIndex) - dr1("CveProyecto") = CveProyecto - dr1("CveSubProyecto") = CveSubProyecto - dr1("Proyecto") = If(CveProyecto > 0, gvRow.FCDropDownList("DdlProyectoPersonal").SelectedItem.Text, "") - dr1("SubProyecto") = If(CveSubProyecto > 0, gvRow.FCDropDownList("DdlSubProyectoPersonal").SelectedItem.Text, "") - TmpDT.AcceptChanges() - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - End Sub - - Private Sub DdlPersonalHeader_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalHeader.SelectedIndexChanged - For Each Gvr As GridViewRow In GvPersonal.Rows - Gvr.FCDropDownList("DdlPersonalGv").SelectedValue = DdlPersonalHeader.SelectedValue - Next - UpGvPersonal.Update() - End Sub - - Private Sub CargaDdlPersonal() - 'DdlPersonalGv.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) - 'DdlPersonalGv.DataBind() - - DdlPersonalHeader.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) - DdlPersonalHeader.DataBind() - UpGvPersonal.Update() - End Sub - - Private Sub GvPersonal_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPersonal.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCDropDownList("DdlPersonalGv").DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlPersonalGv").DataBind() - - If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Or UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then - e.Row.FCDropDownList("DdlSubProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - e.Row.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) - e.Row.FCDropDownList("DdlSubProyectoPersonal").DataBind() - e.Row.FCDropDownList("DdlProyectoPersonal").Visible = False - Else - e.Row.FCDropDownList("DdlProyectoPersonal").DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) - e.Row.FCDropDownList("DdlProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) - e.Row.FCDropDownList("DdlProyectoPersonal").DataBind() - e.Row.FCDropDownList("DdlProyectoPersonal").SelectedValueExist(e.Row.DBCampo("CveProyecto")) - If e.Row.DBCampo("CveProyecto").ToEntero > 0 Then - e.Row.FCDropDownList("DdlSubProyectoPersonal").DataSource = - If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), - GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, e.Row.DBCampo("CveProyecto").ToEntero, UsuarioActual.CveEmpresa, -1, 1), - GlobalDTSubProyectos(e.Row.DBCampo("CveProyecto").ToEntero, -1, UsuarioActual.CveEmpresa, 1)) - End If - e.Row.FCDropDownList("DdlSubProyectoPersonal").Items.Insert(0, New ListItem("Seleccione", "-1")) - e.Row.FCDropDownList("DdlSubProyectoPersonal").DataBind() - End If - e.Row.FCDropDownList("DdlSubProyectoPersonal").SelectedValueExist(e.Row.DBCampo("CveSubProyecto")) - - If CveCompra > 0 Then - If e.Row.DBCampo("CvePersonal").ToEntero <> -1 And e.Row.DBCampo("CvePersonal") <> Nothing Then - e.Row.FCDropDownList("DdlPersonalGv").SelectedValue = e.Row.DBCampo("CvePersonal") - End If - If e.Row.DBCampo("Referencia").ToString <> "" And e.Row.DBCampo("Referencia") <> Nothing Then - e.Row.FCTextBox("TxtReferencia").Text = e.Row.DBCampo("Referencia") - End If - e.Row.FCTextBox("TxtDividir").Enabled = False - End If - e.Row.FCLinkButton("BtnDividirPersonal").Attributes.Add("onclick", String.Format("DividirPersonal('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) - e.Row.FCLinkButton("BtnDividirPersonal").CommandArgument = e.Row.RowIndex.ToString - e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCLinkButton("BtnDividirPersonal").ClientID)) - - - End If - End Sub - - Protected Sub DividirPersonal(sender As Object, e As EventArgs) - Dim index2 As Integer = 0 - - For Each Row As DataRow In TmpDT.Rows - If GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text <> "" Then - Row("Referencia") = GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text - End If - If GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue <> "-1" Then - Row("CvePersonal") = GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue - End If - index2 += 1 - Next - - 'index2 = 0 - 'For Each Row As DataRow In TmpDT.Rows - ' If GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - ' Row("CveActivoFijo") = GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero - ' Row("CodAF") = GvAFCompras.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString - ' Row("TipoAF") = 1 - ' End If - ' index2 += 1 - 'Next - - 'Dim Index As Integer = CType(sender, LinkButton).CommandArgument.ToString.ToEntero - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim Index As Integer = gvRow.RowIndex - Dim Cantidad As String = HdnCantidadPersonal.Value - Dim dr1 As DataRow = TmpDT.Rows(Index) - Dim dr As DataRow = TmpDT.NewRow - dr.ItemArray = dr1.ItemArray - dr1("Cantidad") = (dr1("Cantidad").ToString.ToDouble - Cantidad.ToDouble) - dr1("Total") = dr1("PU").ToString.ToDouble * dr1("Cantidad").ToString.ToDouble - dr1("IVA") = Math.Round(dr1("IVAPorcentaje").ToString.ToDouble * dr1("Total").ToString.ToDouble, 6) - - TmpDT.AcceptChanges() - - dr("CvePersonal") = 0 - dr("Referencia") = "" - dr("CveActivoFijo") = 0 - dr("CodAF") = 0 - dr("Cantidad") = Cantidad.ToDouble - dr("Total") = dr("PU").ToString.ToDouble * Cantidad.ToDouble - dr("IVA") = Math.Round(dr("IVAPorcentaje").ToString.ToDouble * dr("Total").ToString.ToDouble, 6) - TmpDT.Rows.InsertAt(dr, Index) - TmpDT.AcceptChanges() - - index2 = 0 - For Each Row As DataRow In TmpDT.Rows - Row("Consec") = index2 - index2 += 1 - Next - TmpDT.AcceptChanges() - - CargaGvPersonal() - - 'TmpDT = DtAFInsumos.Copy - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - 'Afecta GVINV y GvAF - CargaGvInv() - CargaGVsAF() - CalculaTotales(True) - - index2 = 0 - For Each Row As DataRow In TmpDT.Rows - If Row("Referencia").ToString <> "" Then - GvPersonal.Rows(index2).FCTextBox("TxtReferencia").Text = Row("Referencia").ToString - End If - If Row("CvePersonal").ToString <> "" Then - GvPersonal.Rows(index2).FCDropDownList("DdlPersonalGv").SelectedValue = Row("CvePersonal").ToString - End If - index2 += 1 - Next - - End Sub -#End Region +#End Region -#Region "TAB - ACTIVOS FIJOS -AF" - Protected Sub CargarGvActivosFijos(sender As Object, e As EventArgs) - TAB.ActiveTabIndex = 3 - - If GvAFInsumos.Rows.Count > 0 Then - llenaDtsAF() - End If - - CargaGVsAF() - End Sub - Protected Sub llenaDtsAF() - Dim index As Integer = 0 - For Each Row As DataRow In TmpDT.Rows - If Row("TipoAF").ToString.ToEntero = 1 AndAlso GvAFInsumos.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - Row("CveActivoFijo") = GvAFInsumos.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero - Row("CodAF") = If(GvAFInsumos.Rows(index).FCHiddenField("HdnCodAF").Value.ToString = "", "SN", GvAFInsumos.Rows(index).FCHiddenField("HdnCodAF").Value.ToString) - 'Row("TipoAF") = 1 - End If - index += 1 - Next - index = 0 - For Each Row As DataRow In TmpDT.Rows - If Row("TipoAF").ToString.ToEntero = 2 AndAlso GvAFCompras.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - Row("CveActivoFijo") = GvAFCompras.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero - Row("CodAF") = If(GvAFCompras.Rows(index).FCHiddenField("HdnCodAF").Value.ToString = "", "SN", GvAFCompras.Rows(index).FCHiddenField("HdnCodAF").Value.ToString) - 'Row("TipoAF") = 2 - End If - index += 1 - Next - End Sub - Private Sub CargaGVsAF() - GvAFInsumos.DataSource = TmpDT - GvAFInsumos.DataBind() - UPDatosAFInsumos.Update() - - GvAFCompras.DataSource = TmpDT - GvAFCompras.DataBind() - UPDatosAFCompras.Update() - End Sub - Protected Sub GvAFCompras_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAFCompras.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim SinValor = True - - If e.Row.DBCampo("TipoAF").ToEntero = 2 Then - If e.Row.DBCampo("CveActivoFijo").ToEntero > 0 Then - e.Row.FCTextBox("LblCodigo").Text = e.Row.DBCampo("CodAF").ToString - e.Row.FCHiddenField("HdnCveAF").Value = e.Row.DBCampo("CveActivoFijo").ToString - e.Row.FCHiddenField("HdnCodAF").Value = e.Row.DBCampo("CodAF").ToString - SinValor = False - End If - End If - - If SinValor Then - e.Row.FCTextBox("LblCodigo").Text = "" - e.Row.FCHiddenField("HdnCveAF").Value = "0" - e.Row.FCHiddenField("HdnCodAF").Value = "0" - End If - - 'e.Row.FCButton("BtnDividirInsumo").Attributes.Add("onclick", String.Format("DividirInsumo('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) - 'e.Row.FCButton("BtnDividirInsumo").CommandArgument = e.Row.RowIndex.ToString - - e.Row.FCHiddenField("HdnIndex").Value = e.Row.RowIndex.ToString - e.Row.FCHyperLink("HLBuscarAF").Attributes.Add("onclick", String.Format("LimpiaAF(2, '{0}');", e.Row.FCHiddenField("HdnCveConcepto").Value)) - e.Row.FCHyperLink("HLBuscarAF").NavigateUrl = String.Format("javascript:AbrirVentana('/AF/PopUpBuscarAF.aspx?L={0}&H1={1}&H2={2}',730,450,'N');", e.Row.FCTextBox("LblCodigo").ClientID, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID) - 'e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirInsumo").ClientID)) - - e.Row.FCTextBox("LblCodigo").Attributes.Add("onkeyup", String.Format("LimpiaAF(2, '{0}'); EnterAFEdit(event,this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) - e.Row.FCTextBox("LblCodigo").Attributes.Add("onblur", String.Format("LimpiaAF(2, '{0}'); AFBlurEdit(this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) - End If - End Sub - Protected Sub GvAFInsumos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAFInsumos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim SinValor = True - - If e.Row.DBCampo("TipoAF").ToEntero = 1 Then - If e.Row.DBCampo("CveActivoFijo").ToEntero > 0 Then - e.Row.FCTextBox("LblCodigo").Text = e.Row.DBCampo("CodAF").ToString - e.Row.FCLabel("LblValido").Attributes("display") = "" - e.Row.FCHiddenField("HdnCveAF").Value = e.Row.DBCampo("CveActivoFijo").ToString - e.Row.FCHiddenField("HdnCodAF").Value = e.Row.DBCampo("CodAF").ToString - SinValor = False - End If - End If - - If SinValor Then - e.Row.FCTextBox("LblCodigo").Text = "" - e.Row.FCHiddenField("HdnCveAF").Value = "0" - e.Row.FCHiddenField("HdnCodAF").Value = "0" - e.Row.FCLabel("LblValido").Attributes("display") = "none" - End If - - If e.Row.DBCampo("AFTipoMantenimiento").ToEntero > 0 Then - e.Row.FCDropDownList("DdlTipoMantemiento").SelectedValueExist(e.Row.DBCampo("AFTipoMantenimiento")) - - End If - e.Row.FCButton("BtnDividirInsumo").Attributes.Add("onclick", String.Format("DividirInsumo('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) - e.Row.FCButton("BtnDividirInsumo").CommandArgument = e.Row.RowIndex.ToString - - e.Row.FCHiddenField("HdnIndex").Value = e.Row.RowIndex.ToString - e.Row.FCHyperLink("HLBuscarAF").Attributes.Add("onclick", String.Format("LimpiaAF(1, '{0}');", e.Row.FCHiddenField("HdnCveConcepto").Value)) - e.Row.FCHyperLink("HLBuscarAF").NavigateUrl = String.Format("javascript:AbrirVentana('/AF/PopUpBuscarAF.aspx?L={0}&H1={1}&H2={2}',730,450,'N');", e.Row.FCTextBox("LblCodigo").ClientID, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID) - e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirInsumo").ClientID)) - - e.Row.FCTextBox("LblCodigo").Attributes.Add("onkeyup", String.Format("LimpiaAF(1, '{0}'); EnterAFEdit(event,this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) - e.Row.FCTextBox("LblCodigo").Attributes.Add("onblur", String.Format("LimpiaAF(1, '{0}'); AFBlurEdit(this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) - - e.Row.FCTextBox("TxtAFMedida").Attributes.Add("onblur", String.Format("AFInsumosMedida(this,{0});", e.Row.RowIndex)) - - - End If - End Sub - Protected Sub BtnLimpiaAF_Click(sender As Object, e As EventArgs) - LimpiaAF(HdnTipoAF.Value.ToEntero, HdnCveConceptoAF.Value) - End Sub - Protected Sub LimpiaAF(TipoCompra As Integer, CveConcepto As String) - llenaDtsAF() - - For Each Row As DataRow In TmpDT.Rows - If Row("CveConcepto").ToString = CveConcepto Then - Row("TipoAF") = TipoCompra - End If - Next - TmpDT.AcceptChanges() - - llenaDtsAF() - CargaGVsAF() - End Sub - Protected Sub DivirInsumo(sender As Object, e As EventArgs) - Dim index2 As Integer = 0 - - 'LLena el AF vinculado para no perderlo - For Each Row As DataRow In TmpDT.Rows - If GvAFInsumos.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - Row("CveActivoFijo") = GvAFInsumos.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero - Row("CodAF") = GvAFInsumos.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString - Row("TipoAF") = 1 - End If - index2 += 1 - Next - - index2 = 0 - For Each Row As DataRow In TmpDT.Rows - If GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then - Row("CveActivoFijo") = GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero - Row("CodAF") = GvAFCompras.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString - Row("TipoAF") = 1 - End If - index2 += 1 - Next - - Dim Index As Integer = CType(sender, Button).CommandArgument.ToString.ToEntero - Dim Cantidad As String = HdnCantidadInsumo.Value - Dim dr1 As DataRow = TmpDT.Rows(Index) - Dim dr As DataRow = TmpDT.NewRow - dr.ItemArray = dr1.ItemArray - - dr1("Cantidad") = (dr1("Cantidad").ToString.ToDouble - Cantidad.ToDouble) - dr1("Total") = dr1("PU").ToString.ToDouble * dr1("Cantidad").ToString.ToDouble - dr1("IVA") = Math.Round(dr1("IVAPorcentaje").ToString.ToDouble * dr1("Total").ToString.ToDouble, 6) - TmpDT.AcceptChanges() - - - dr("CveActivoFijo") = 0 - dr("CodAF") = "" - dr("Cantidad") = Cantidad.ToDouble - dr("Total") = dr("PU").ToString.ToDouble * Cantidad.ToDouble - dr("IVA") = Math.Round(dr("IVAPorcentaje").ToString.ToDouble * dr("Total").ToString.ToDouble, 6) - - TmpDT.Rows.InsertAt(dr, Index + 1) - - For Index = 0 To TmpDT.Rows.Count - 1 - TmpDT.Rows(Index)("Consec") = Index + 1 - Next - - CargaGVsAF() - - 'TmpDT = DtAFInsumos.Copy - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - 'Afecta GVINV - CargaGvInv() - - CargaGvPersonal() - End Sub - Protected Sub BtnVinculaAFEdit_Click(sender As Object, e As EventArgs) - Dim ObjAF As New ClsAF - Dim Index As Integer = HdnIndexTmpDT.Value.ToEntero() - If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, HdnCodAFEdit.Value, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then - If ObjAF.DtResultados.Rows.Count = 1 Then - 'VERIFICAR QUE EL ACTIVO FIJO ESTE ACTIVO. que no este en baja, inactivo. - If HdnTipoAF.Value.ToEntero = 1 Then - GvAFInsumos.Rows(Index).FCHiddenField("HdnCveAF").Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString - GvAFInsumos.Rows(Index).FCHiddenField("HdnCodAF").Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString - RegistraScript(String.Format("MuestraCheckAF('{0}','');", GvAFInsumos.Rows(Index).FCLabel("LblValido").ClientID), "A2") - ElseIf HdnTipoAF.Value.ToEntero = 2 Then - GvAFCompras.Rows(Index).FCHiddenField("HdnCveAF").Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString - GvAFCompras.Rows(Index).FCHiddenField("HdnCodAF").Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString - RegistraScript(String.Format("MuestraCheckAF('{0}','');", GvAFCompras.Rows(Index).FCLabel("LblValido").ClientID), "A2") - End If - 'COMENTADO IPP 15 JUNIO 2017 - 'RegistraScript(String.Format("EnterAFEditOK('{0}','{1}');", ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString, ObjAF.DtResultados.Rows(0)("Codigo").ToString)) - LimpiaAF(HdnTipoAF.Value.ToEntero, HdnCveConceptoAF.Value) - Else - If HdnTipoAF.Value.ToEntero = 1 Then - GvAFInsumos.Rows(Index).FCHiddenField("HdnCveAF").Value = "-1" - GvAFInsumos.Rows(Index).FCHiddenField("HdnCodAF").Value = "-1" - RegistraScript(String.Format("MuestraCheckAF('{0}','none');", GvAFInsumos.Rows(Index).FCLabel("LblValido").ClientID), "A2") - ElseIf HdnTipoAF.Value.ToEntero = 2 Then - GvAFCompras.Rows(Index).FCHiddenField("HdnCveAF").Value = "-1" - GvAFCompras.Rows(Index).FCHiddenField("HdnCodAF").Value = "-1" - RegistraScript(String.Format("MuestraCheckAF('{0}','none');", GvAFCompras.Rows(Index).FCLabel("LblValido").ClientID), "A2") - End If - - Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) - End If - End If - - ObjAF.Dispose() - End Sub - Protected Sub DdlTipoMantemiento_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim dr = TmpDT.Rows(CType(CType(sender, DropDownList).NamingContainer, GridViewRow).RowIndex) - - dr("AFTipoMantenimiento") = CType(CType(sender, DropDownList).NamingContainer, GridViewRow).FCDropDownList("DdlTipoMantemiento").SelectedValue.ToEntero - - End Sub - Protected Sub BtnAFMedida_Click(sender As Object, e As EventArgs) - TmpDT(HdnIndexTmpDT.Value.ToEntero)("AFMedida") = HdnTxtAFMedida.Value +#Region "TAB - ACTIVOS FIJOS -AF" + Protected Sub CargarGvActivosFijos(sender As Object, e As EventArgs) + TAB.ActiveTabIndex = 3 + + If GvAFInsumos.Rows.Count > 0 Then + llenaDtsAF() + End If + + CargaGVsAF() End Sub -#End Region + Protected Sub llenaDtsAF() + Dim index As Integer = 0 + For Each Row As DataRow In TmpDT.Rows + If Row("TipoAF").ToString.ToEntero = 1 AndAlso GvAFInsumos.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + Row("CveActivoFijo") = GvAFInsumos.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero + Row("CodAF") = If(GvAFInsumos.Rows(index).FCHiddenField("HdnCodAF").Value.ToString = "", "SN", GvAFInsumos.Rows(index).FCHiddenField("HdnCodAF").Value.ToString) + 'Row("TipoAF") = 1 + End If + index += 1 + Next + index = 0 + For Each Row As DataRow In TmpDT.Rows + If Row("TipoAF").ToString.ToEntero = 2 AndAlso GvAFCompras.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + Row("CveActivoFijo") = GvAFCompras.Rows(index).FCHiddenField("HdnCveAF").Value.ToEntero + Row("CodAF") = If(GvAFCompras.Rows(index).FCHiddenField("HdnCodAF").Value.ToString = "", "SN", GvAFCompras.Rows(index).FCHiddenField("HdnCodAF").Value.ToString) + 'Row("TipoAF") = 2 + End If + index += 1 + Next + End Sub + Private Sub CargaGVsAF() + GvAFInsumos.DataSource = TmpDT + GvAFInsumos.DataBind() + UPDatosAFInsumos.Update() -#Region "C O N T R A T O S" + GvAFCompras.DataSource = TmpDT + GvAFCompras.DataBind() + UPDatosAFCompras.Update() + End Sub + Protected Sub GvAFCompras_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAFCompras.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim SinValor = True + + If e.Row.DBCampo("TipoAF").ToEntero = 2 Then + If e.Row.DBCampo("CveActivoFijo").ToEntero > 0 Then + e.Row.FCTextBox("LblCodigo").Text = e.Row.DBCampo("CodAF").ToString + e.Row.FCHiddenField("HdnCveAF").Value = e.Row.DBCampo("CveActivoFijo").ToString + e.Row.FCHiddenField("HdnCodAF").Value = e.Row.DBCampo("CodAF").ToString + SinValor = False + End If + End If + + If SinValor Then + e.Row.FCTextBox("LblCodigo").Text = "" + e.Row.FCHiddenField("HdnCveAF").Value = "0" + e.Row.FCHiddenField("HdnCodAF").Value = "0" + End If + + 'e.Row.FCButton("BtnDividirInsumo").Attributes.Add("onclick", String.Format("DividirInsumo('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) + 'e.Row.FCButton("BtnDividirInsumo").CommandArgument = e.Row.RowIndex.ToString + + e.Row.FCHiddenField("HdnIndex").Value = e.Row.RowIndex.ToString + e.Row.FCHyperLink("HLBuscarAF").Attributes.Add("onclick", String.Format("LimpiaAF(2, '{0}');", e.Row.FCHiddenField("HdnCveConcepto").Value)) + e.Row.FCHyperLink("HLBuscarAF").NavigateUrl = String.Format("javascript:AbrirVentana('/AF/PopUpBuscarAF.aspx?L={0}&H1={1}&H2={2}',730,450,'N');", e.Row.FCTextBox("LblCodigo").ClientID, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID) + 'e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirInsumo").ClientID)) + + e.Row.FCTextBox("LblCodigo").Attributes.Add("onkeyup", String.Format("LimpiaAF(2, '{0}'); EnterAFEdit(event,this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) + e.Row.FCTextBox("LblCodigo").Attributes.Add("onblur", String.Format("LimpiaAF(2, '{0}'); AFBlurEdit(this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) + End If + End Sub + Protected Sub GvAFInsumos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAFInsumos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim SinValor = True + + If e.Row.DBCampo("TipoAF").ToEntero = 1 Then + If e.Row.DBCampo("CveActivoFijo").ToEntero > 0 Then + e.Row.FCTextBox("LblCodigo").Text = e.Row.DBCampo("CodAF").ToString + e.Row.FCLabel("LblValido").Attributes("display") = "" + e.Row.FCHiddenField("HdnCveAF").Value = e.Row.DBCampo("CveActivoFijo").ToString + e.Row.FCHiddenField("HdnCodAF").Value = e.Row.DBCampo("CodAF").ToString + SinValor = False + End If + End If + + If SinValor Then + e.Row.FCTextBox("LblCodigo").Text = "" + e.Row.FCHiddenField("HdnCveAF").Value = "0" + e.Row.FCHiddenField("HdnCodAF").Value = "0" + e.Row.FCLabel("LblValido").Attributes("display") = "none" + End If + + If e.Row.DBCampo("AFTipoMantenimiento").ToEntero > 0 Then + e.Row.FCDropDownList("DdlTipoMantemiento").SelectedValueExist(e.Row.DBCampo("AFTipoMantenimiento")) + + End If + e.Row.FCButton("BtnDividirInsumo").Attributes.Add("onclick", String.Format("DividirInsumo('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) + e.Row.FCButton("BtnDividirInsumo").CommandArgument = e.Row.RowIndex.ToString + + e.Row.FCHiddenField("HdnIndex").Value = e.Row.RowIndex.ToString + e.Row.FCHyperLink("HLBuscarAF").Attributes.Add("onclick", String.Format("LimpiaAF(1, '{0}');", e.Row.FCHiddenField("HdnCveConcepto").Value)) + e.Row.FCHyperLink("HLBuscarAF").NavigateUrl = String.Format("javascript:AbrirVentana('/AF/PopUpBuscarAF.aspx?L={0}&H1={1}&H2={2}',730,450,'N');", e.Row.FCTextBox("LblCodigo").ClientID, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID) + e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividirInsumo").ClientID)) + + e.Row.FCTextBox("LblCodigo").Attributes.Add("onkeyup", String.Format("LimpiaAF(1, '{0}'); EnterAFEdit(event,this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) + e.Row.FCTextBox("LblCodigo").Attributes.Add("onblur", String.Format("LimpiaAF(1, '{0}'); AFBlurEdit(this,{1},{2},{3});", e.Row.FCHiddenField("HdnCveConcepto").Value, e.Row.FCHiddenField("HdnCveAF").ClientID, e.Row.FCHiddenField("HdnCodAF").ClientID, e.Row.RowIndex.ToString)) + + e.Row.FCTextBox("TxtAFMedida").Attributes.Add("onblur", String.Format("AFInsumosMedida(this,{0});", e.Row.RowIndex)) + + + End If + End Sub + Protected Sub BtnLimpiaAF_Click(sender As Object, e As EventArgs) + LimpiaAF(HdnTipoAF.Value.ToEntero, HdnCveConceptoAF.Value) + End Sub + Protected Sub LimpiaAF(TipoCompra As Integer, CveConcepto As String) + llenaDtsAF() + + For Each Row As DataRow In TmpDT.Rows + If Row("CveConcepto").ToString = CveConcepto Then + Row("TipoAF") = TipoCompra + End If + Next + TmpDT.AcceptChanges() + + llenaDtsAF() + CargaGVsAF() + End Sub + Protected Sub DivirInsumo(sender As Object, e As EventArgs) + Dim index2 As Integer = 0 + + 'LLena el AF vinculado para no perderlo + For Each Row As DataRow In TmpDT.Rows + If GvAFInsumos.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + Row("CveActivoFijo") = GvAFInsumos.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero + Row("CodAF") = GvAFInsumos.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString + Row("TipoAF") = 1 + End If + index2 += 1 + Next + + index2 = 0 + For Each Row As DataRow In TmpDT.Rows + If GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero > 0 Then + Row("CveActivoFijo") = GvAFCompras.Rows(index2).FCHiddenField("HdnCveAF").Value.ToEntero + Row("CodAF") = GvAFCompras.Rows(index2).FCHiddenField("HdnCodAF").Value.ToString + Row("TipoAF") = 1 + End If + index2 += 1 + Next + + Dim Index As Integer = CType(sender, Button).CommandArgument.ToString.ToEntero + Dim Cantidad As String = HdnCantidadInsumo.Value + Dim dr1 As DataRow = TmpDT.Rows(Index) + Dim dr As DataRow = TmpDT.NewRow + dr.ItemArray = dr1.ItemArray + + dr1("Cantidad") = (dr1("Cantidad").ToString.ToDouble - Cantidad.ToDouble) + dr1("Total") = dr1("PU").ToString.ToDouble * dr1("Cantidad").ToString.ToDouble + dr1("IVA") = Math.Round(dr1("IVAPorcentaje").ToString.ToDouble * dr1("Total").ToString.ToDouble, 6) + TmpDT.AcceptChanges() + + + dr("CveActivoFijo") = 0 + dr("CodAF") = "" + dr("Cantidad") = Cantidad.ToDouble + dr("Total") = dr("PU").ToString.ToDouble * Cantidad.ToDouble + dr("IVA") = Math.Round(dr("IVAPorcentaje").ToString.ToDouble * dr("Total").ToString.ToDouble, 6) + + TmpDT.Rows.InsertAt(dr, Index + 1) + + For Index = 0 To TmpDT.Rows.Count - 1 + TmpDT.Rows(Index)("Consec") = Index + 1 + Next + + CargaGVsAF() + + 'TmpDT = DtAFInsumos.Copy + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + 'Afecta GVINV + CargaGvInv() + + CargaGvPersonal() + End Sub + Protected Sub BtnVinculaAFEdit_Click(sender As Object, e As EventArgs) + Dim ObjAF As New ClsAF + Dim Index As Integer = HdnIndexTmpDT.Value.ToEntero() + If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, HdnCodAFEdit.Value, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then + If ObjAF.DtResultados.Rows.Count = 1 Then + 'VERIFICAR QUE EL ACTIVO FIJO ESTE ACTIVO. que no este en baja, inactivo. + If HdnTipoAF.Value.ToEntero = 1 Then + GvAFInsumos.Rows(Index).FCHiddenField("HdnCveAF").Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString + GvAFInsumos.Rows(Index).FCHiddenField("HdnCodAF").Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString + RegistraScript(String.Format("MuestraCheckAF('{0}','');", GvAFInsumos.Rows(Index).FCLabel("LblValido").ClientID), "A2") + ElseIf HdnTipoAF.Value.ToEntero = 2 Then + GvAFCompras.Rows(Index).FCHiddenField("HdnCveAF").Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString + GvAFCompras.Rows(Index).FCHiddenField("HdnCodAF").Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString + RegistraScript(String.Format("MuestraCheckAF('{0}','');", GvAFCompras.Rows(Index).FCLabel("LblValido").ClientID), "A2") + End If + 'COMENTADO IPP 15 JUNIO 2017 + 'RegistraScript(String.Format("EnterAFEditOK('{0}','{1}');", ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString, ObjAF.DtResultados.Rows(0)("Codigo").ToString)) + LimpiaAF(HdnTipoAF.Value.ToEntero, HdnCveConceptoAF.Value) + Else + If HdnTipoAF.Value.ToEntero = 1 Then + GvAFInsumos.Rows(Index).FCHiddenField("HdnCveAF").Value = "-1" + GvAFInsumos.Rows(Index).FCHiddenField("HdnCodAF").Value = "-1" + RegistraScript(String.Format("MuestraCheckAF('{0}','none');", GvAFInsumos.Rows(Index).FCLabel("LblValido").ClientID), "A2") + ElseIf HdnTipoAF.Value.ToEntero = 2 Then + GvAFCompras.Rows(Index).FCHiddenField("HdnCveAF").Value = "-1" + GvAFCompras.Rows(Index).FCHiddenField("HdnCodAF").Value = "-1" + RegistraScript(String.Format("MuestraCheckAF('{0}','none');", GvAFCompras.Rows(Index).FCLabel("LblValido").ClientID), "A2") + End If + + Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) + End If + End If + + ObjAF.Dispose() + End Sub + Protected Sub DdlTipoMantemiento_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim dr = TmpDT.Rows(CType(CType(sender, DropDownList).NamingContainer, GridViewRow).RowIndex) + + dr("AFTipoMantenimiento") = CType(CType(sender, DropDownList).NamingContainer, GridViewRow).FCDropDownList("DdlTipoMantemiento").SelectedValue.ToEntero + + End Sub + Protected Sub BtnAFMedida_Click(sender As Object, e As EventArgs) + TmpDT(HdnIndexTmpDT.Value.ToEntero)("AFMedida") = HdnTxtAFMedida.Value + End Sub +#End Region + +#Region "C O N T R A T O S" 'Protected Sub ImgBtnBuscarContrato_Click(sender As Object, e As ImageClickEventArgs) Handles ImgBtnBuscarContrato.Click ' If CveProveedor <= 0 Then ' Alert("Debe de Seleccionar un proveedor") @@ -11986,1718 +12000,1718 @@ Partial Class Compras_Compras ' ObjContratos.Dispose() ' End If 'End Sub -#End Region +#End Region -#Region "TAB ALMACEN - INVENTARIOS ISRAEL PIÑA - 5 FEBRERO 2015" +#Region "TAB ALMACEN - INVENTARIOS ISRAEL PIÑA - 5 FEBRERO 2015" - Protected Sub CalculaTotalPorDevengar() - Dim total = TxtTotal.Text.ToDouble - For Each Gvr As GridViewRow In GvInv.Rows - If Gvr.FCCheckBox("cbInv").Checked = True And Gvr.FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then - total -= Math.Round(Gvr.FCTextBox("TbCantidad").Text.ToDouble * Gvr.DataKey("PU").ToDouble, 4) - End If - Next - 'LbTotalPorDevengar.Text = total.ToString.FormatoNumero - 'UPPM.Update() - End Sub - - Protected Sub CambiaTotalDevengar(sender As Object, e As EventArgs) - CalculaTotalPorDevengar() + Protected Sub CalculaTotalPorDevengar() + Dim total = TxtTotal.Text.ToDouble + For Each Gvr As GridViewRow In GvInv.Rows + If Gvr.FCCheckBox("cbInv").Checked = True And Gvr.FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then + total -= Math.Round(Gvr.FCTextBox("TbCantidad").Text.ToDouble * Gvr.DataKey("PU").ToDouble, 4) + End If + Next + 'LbTotalPorDevengar.Text = total.ToString.FormatoNumero + 'UPPM.Update() End Sub -#End Region + Protected Sub CambiaTotalDevengar(sender As Object, e As EventArgs) + CalculaTotalPorDevengar() + End Sub -#Region " AJUSTA IMPORTES " +#End Region + +#Region " AJUSTA IMPORTES " Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False) 'Dim TempSubTotal = TxtSubTotal.Text.ToDouble Dim Amortizacion As Decimal = 0 If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then Amortizacion = LblAmortizacion.Text.ToDecimal - End If - - If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste - 'Dim ImporteAjuste As Decimal = Total - (SubTotal2 + IVA - RetencionIVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos) - Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1) + End If + + If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste + 'Dim ImporteAjuste As Decimal = Total - (SubTotal2 + IVA - RetencionIVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos) + Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1) Dim tPU As Decimal - If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then - tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal - Else - tPU = 0 - End If - - TmpDT.Rows(Indice)("PU") = TmpDT.Rows(Indice)("PU").ToString.ToDouble + tPU - TmpDT.Rows(Indice)("Total") = TmpDT.Rows(Indice)("Total").ToString.ToDouble + ImporteAjuste - TmpDT.AcceptChanges() - End If - - SubTotal = TmpDT.SUM("Total").ToString.ToDecimal - If Not EsCarga Then - Descuentos = TmpDT.SUM("Descuento").ToString.ToDecimal - End If - TxtSubTotal.Text = (SubTotal + Descuentos).FormatoNumero() - TxtSubTotal2.Text = (SubTotal - Amortizacion).FormatoNumero - TxtDescuento.Text = Descuentos.FormatoNumero() - SubTotalConceptos = SubTotal - GvPS.DataSource = TmpDT : GvPS.DataBind() - - 'If TxtOtrosImpuestos.Text.ToDouble > 0 Then TxtOtrosImpuestos.Text = "" : TrOtrosImpuestos.Visible = False - - 'EN ESPERA DE ALGUN CASO QUE LO NECESITE - IPP 5 DICIEMBRE 2016 - 'TempSubTotal = TempSubTotal - SubTotal - 'If TempSubTotal > 0 Then - ' TxtTotal.Text = TempSubTotal.ToString.FormatoNumero - 'End If - - 'GVAF.DataSource = TmpDT : GVAF.DataBind() - End Sub - - Protected Sub ImgAjustePorcentaje_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAjustePorcentaje.Click - 'realizo el ajuste de los productos - AjustaConceptos() - For Each Row As GridViewRow In GvPS.Rows - If UsuarioActual.TienePermisoProceso(143) Then - Row.FCLinkButton("ImgE").Visible = True - Row.FCLinkButton("ImgD").Visible = True - End If - Next - End Sub - - Private Sub AjustaConceptos(Optional AjusteForzoso As Boolean = False) - 'SE COMENTO POR PORCENTAJE DE DESCUENTO 0.00 - IPP 3 ENERO 2017 - 'If TxtAjustePorcentaje.Text.ToDecimal <> 0 Or AjusteForzoso Then - 'End If - - If TxtAjustePorcentaje.Text.ToDecimal <> 0 Then - For Each Dr As DataRow In TmpDT.Rows - 'Dr("PU") = Dr("PU").ToString.ToDecimal * ((100 - TxtAjustePorcentaje.Text.ToDecimal) / 100) - Dim TotalAnterior = Dr("Total").ToString.ToDecimal - Dr("Total") = Dr("Total").ToString.ToDecimal * ((100 - TxtAjustePorcentaje.Text.ToDecimal) / 100) - Dr("Descuento") = TotalAnterior - Dr("Total").ToString.ToDecimal - Next - - 'TxtDescuento.Text = Descuentos.ToString - End If - - 'verifico las sumas - If TxtSubTotal2.Text.ToDecimal <> TmpDT.SUM("Total") Then - Dim i As Integer = TmpDT.Rows.Count - 1 - 'verifico si el ultimo dato, es diferente de cero, sino tomo el anterior - If TmpDT.Rows(i)("Total").ToString.ToDecimal <= 0 AndAlso i - 1 >= 0 Then i = i - 1 - - 'sino se hizo el ajuste, lo aplico al ultimo registro la diferencia - 'para ajustar el PU, de la diferencia la divido entre la cantidad - TmpDT.Rows(i)("PU") = TmpDT.Rows(i)("PU").ToString.ToDecimal + ((TxtSubTotal2.Text.ToDecimal - TmpDT.SUM("Total")) / TmpDT.Rows(i)("Cantidad").ToString.ToDecimal) - TmpDT.Rows(i)("Total") = TmpDT.Rows(i)("Total").ToString.ToDecimal + TxtSubTotal2.Text.ToDecimal - TmpDT.SUM("Total") - End If - - - TxtSubTotal.Text = (TmpDT.SUM("Total") + TmpDT.SUM("Descuento")).FormatoNumero - TxtSubTotal2.Text = TmpDT.SUM("Total").FormatoNumero - SubTotalOriginal = TmpDT.SUM("Total") + TmpDT.SUM("Descuento") - SubTotal2Original = TmpDT.SUM("Total") - - BtnGuardar.Enabled = True - UpFacturar.Update() - PnlAjusteProductos.Visible = False - 'habilito la busqueda de oc - ImgBtnBuscarOC.Visible = True - TxtOC.Enabled = True - UpParametros.Update() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - End Sub -#End Region + If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then + tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal + Else + tPU = 0 + End If -#Region "DDL'S" - Protected Sub DdlCredito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCredito.SelectedIndexChanged - CargaCreditosDetalle(DdlCredito.SelectedValue.ToEntero) - CargaCreditosDisponibles() - End Sub - Protected Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged - TxtContadoDeudor.Text = "0" - - If DdlDeudor.SelectedValue.ToEntero > 0 Then - Dim Deudores As New ClsMovimientos - - If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then - If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0") - GvDeudores.DataSource = DtDeudoresDetalle - GvDeudores.DataBind() - End If - Else - If Deudores.GetDeudoresComisionesSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0") - GvDeudores.DataSource = DtDeudoresDetalle - GvDeudores.DataBind() - End If - End If - - - If CompraSaldo < TxtTotal.Text.ToDouble Then - RVContadoDeudor.MaximumValue = CompraSaldo.ToString - Else - RVContadoDeudor.MaximumValue = TxtTotal.Text - End If - - UPDeudores.Update() - Deudores.Dispose() - TxtContadoDeudor.Attributes.Add("readonly", "readonly") - End If - End Sub - Protected Sub DdlAcreedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAcreedor.SelectedIndexChanged - If DdlAcreedor.SelectedValue.ToEntero > 0 Then - Dim dr As DataRow - - dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) - 'If EmpresaPrueba Then - ' dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) - 'Else - ' dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlDeudor.SelectedValue)) - 'End If - - - If dr IsNot Nothing Then - Dim tSaldo As Double = dr("Saldo").ToString.ToDouble - RVContadoAcreedor.MaximumValue = tSaldo.ToString - 'si el saldo es mayor de la compra poner el valor de la compra sino el valor del saldo - TxtContadoAcreedor.Text = If(tSaldo > TxtTotal.Text.ToDouble, TxtTotal.Text, tSaldo.ToString).FormatoNumero - - LblDetalle.Visible = True - DdlAcreedorDetalle.Visible = True - - Dim ObjMov As New ClsMovimientos - Dim ObjProveedor As New ClsCompProveedores() - - If ObjMov.GetAcreedoresSaldosDetalles(-1, CveMoneda, UsuarioActual.CveEmpresa) Then - DdlAcreedorDetalle.DataSource = ObjMov.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) - DdlAcreedorDetalle.DataBind() - DdlAcreedorDetalle.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1")) - UpContado.Update() - End If - - If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, DdlAcreedor.SelectedValue.ToEntero, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa) Then - ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor - ViewState("CveCuentaProveedorAcreedores") = ObjProveedor.CveCuentaAcreedor - End If - - - ObjProveedor.Dispose() - ObjMov.Dispose() - - End If - - Else - TxtContadoAcreedor.Text = "0" - End If - End Sub - Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonal.SelectedIndexChanged - ViewState("CvePersonal") = DdlPersonal.SelectedValue - End Sub - Protected Sub DdlCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCajaChica.SelectedIndexChanged - ViewState("CveCajaChica") = DdlCajaChica.SelectedValue - End Sub - Protected Sub DdlTipoCredito_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaCreditos() - - Select Case DdlTipoCredito.SelectedValue.ToEntero - Case 1 - DivCreditoMensualidad.Visible = False - Case 2 - DivCreditoMensualidad.Visible = True - End Select - End Sub - Protected Sub DdlProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedor.SelectedIndexChanged - ViewState("CveProveedor") = DdlProveedor.SelectedValue.ToEntero - HdnCveProveedor.Value = CveProveedor.ToString - CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1", False) - - - - - If DdlPS.ddl.SelectedIndex > 0 Then - DdlPS_SelectedIndexChanged(sender, e) - DdlPS.Focus() - Else - TxtCantidad.Focus() - End If - - If DdlProveedor.SelectedValue.ToEntero > 0 Then - ChkConsignacion.Enabled = True - Else - ChkConsignacion.Enabled = False - End If - - If GlobalDTProveedorSucursales(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then - RowProveedorSucursal.Visible = True - DdlProveedorSucursal.Items.Clear() - DdlProveedorSucursal.DataSource = GlobalDTProveedorSucursales(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) - DdlProveedorSucursal.DataBind() - DdlProveedorSucursal.Items.Insert(0, New ListItem("Selecciona una Sucursal", "-1")) - DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) - Else - DdlProveedorSucursal.Items.Clear() - DdlProveedorSucursal.Items.Insert(0, New ListItem("N/O", "-1")) - DdlProveedorSucursal.DataBind() - RowProveedorSucursal.Visible = False - End If - - UpEstatus.Update() - UpTabs.Update() - - - - - - - - 'DdlProveedor.Attributes.Add("onclick", "CargaProveedores();") - End Sub - Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged - Dim Folio As Long - - Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) - - If dr IsNot Nothing Then - CveMoneda = dr("CveMoneda").ToString.ToEntero - IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero - CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero - IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero - CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero - If dr("UsaTarjeta").ToString = "True" Then - CargaGridTarjetas() - Else - DivTarjeta.Visible = False - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then - Dim Banco As New ClsBancos - Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) - Banco.Dispose() - - TxtDocumentoFolio.Text = Folio.ToString - End If - - End Sub - Protected Sub DdlCuentaCaja_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCaja.SelectedIndexChanged - Dim Folio As Long - - Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaCaja.SelectedValue) - - If dr IsNot Nothing Then - CveMoneda = dr("CveMoneda").ToString.ToEntero - IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero - CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero - End If - - If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then - Dim Banco As New ClsBancos - Folio = Banco.GetNextFolio(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero) - Banco.Dispose() - - TxtDocumentoFolioCaja.Text = Folio.ToString - End If - - End Sub - Protected Sub DdlFuncionarioEmpleado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuncionarioEmpleado.SelectedIndexChanged - If DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then - Dim ObjMovtos As New ClsMovimientos - RowCheque.Visible = True - - ObjMovtos.GetEgresosSinComprobarPersonalDetalle(DdlFuncionarioEmpleado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) - DtCheques = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha") - - 'Limpia Ddl Cheques - DDlCheques.Items.Clear() - - If DtCheques.Rows.Count > 0 Then - DDlCheques.DataSource = DtCheques - End If - - ObjMovtos.Dispose() - DDlCheques.DataBind() - - - DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty) - Else - RowCheque.Visible = False - - lblSaldoFE.Text = "0.00" - End If - - End Sub - Protected Sub DDlCheques_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDlCheques.SelectedIndexChanged - Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal - - TxtDocumentoImporteFE.Text = If(saldo < TxtTotal.Text.ToDouble, saldo.FormatoNumero, TxtTotal.Text) - lblSaldoFE.Text = saldo.FormatoNumero - - RVDocumentoImporteFE.MaximumValue = saldo.ToString - UPCondicionesPago.Update() - - End Sub -#End Region + TmpDT.Rows(Indice)("PU") = TmpDT.Rows(Indice)("PU").ToString.ToDouble + tPU + TmpDT.Rows(Indice)("Total") = TmpDT.Rows(Indice)("Total").ToString.ToDouble + ImporteAjuste + TmpDT.AcceptChanges() + End If -#Region "CHK'S" - Protected Sub RBLCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLCajaChica.SelectedIndexChanged - Select Case RBLCajaChica.SelectedValue - Case "1" : DdlCajaChica.Visible = False : DdlPersonal.Visible = True - Case "2" : DdlCajaChica.Visible = True : DdlPersonal.Visible = False - End Select - - - End Sub - Protected Sub ChkReembolso_CheckedChanged(sender As Object, e As EventArgs) Handles ChkReembolso.CheckedChanged - PnlReemb.Visible = ChkReembolso.Checked - End Sub - Protected Sub RBLPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLPago.SelectedIndexChanged - CambiaTipoPago(True) - End Sub - Private Sub CambiaTipoPago(MostrarModal As Boolean) - DdlPersonalReembolso.Visible = False - DdlCuentaCajaChicaReembolso.Visible = False - - - Select Case RBLPago.SelectedValue - Case "1" 'Credito - PnlContado.Visible = False - - If Not UsuarioActual.Empresa.UsaAC Then - TxtNumeroReembolso.Text = "" - tdNumeroReembolso.Visible = False - End If - EsContado = False - romCreditosTabla.Visible = False - Case "2" 'Contado - PnlContado.Visible = True - - TxtNumeroReembolso.Text = "" - tdNumeroReembolso.Visible = False - - - - RBLContado.Items(0).Enabled = True - RBLContado.Items(3).Enabled = True - RBLContado.Items(4).Enabled = True - RBLContado.Items(5).Enabled = True - - - If UsuarioActual.Empresa.CvePlataforma = 2 Then - RBLContado.Items.Clear() - RBLContado.Items.Insert(0, New ListItem("Bancos", "1")) - RBLContado.Items.Insert(1, New ListItem("Caja Chica", "6")) - RBLContado.Items.Insert(2, New ListItem("Deudores", "4")) - RBLContado.SelectedIndex = 0 - - - 'RBLContado.Items.Item(2).Enabled = False - 'RBLContado.Items.Item(4).Enabled = False - 'RBLContado.Items.Item(5).Enabled = False - End If - - 'If EmpresaPrueba Then - ' RBLContado.Items(5).Enabled = False - 'End If - - EsContado = True - romCreditosTabla.Visible = False - Case "3" 'Reembolso/Comprobacion - PnlContado.Visible = True - - - ''AGARRA VALORES DE SESSION PARA REEMBOLSO -- SI YA ESTA REGISTRADA LA COMPRA IGNORA DATOS DE REEMBOLSO - If Not CveCompra > 0 Then - If UsuarioActual.Sesion("Comp-NumeroReembolso") <> Nothing AndAlso UsuarioActual.Sesion("Comp-NumeroReembolso").ToString <> "" Then - 'RBLPago.SelectedValue = "3" ' [IPP] SE COMENTO POR NO PODER MOSTRAR LO SELECCIONADO - 'RBLPago_SelectedIndexChanged(RBLPago, EventArgs.Empty) - 'CambiaTipoPago(False) - - tdNumeroReembolso.Visible = True - TxtNumeroReembolso.Text = UsuarioActual.Sesion("Comp-NumeroReembolso").ToString - TxtDescripcion.Text = UsuarioActual.Sesion("Comp-Descripcion").ToString - - If UsuarioActual.Sesion("Comp-CveFYE") <> Nothing AndAlso UsuarioActual.Sesion("Comp-CveFYE").ToString.ToEntero > 0 Then - RBLContado.SelectedValue = "2" - RBLContado_SelectedIndexChanged(RBLContado, EventArgs.Empty) - DdlPersonalReembolso.SelectedValueExist(UsuarioActual.Sesion("Comp-CveFYE").ToString) - ViewState("CvePersonal") = UsuarioActual.Sesion("Comp-CveFYE").ToString - Else - RBLContado.SelectedValue = "6" - End If - - Else - UsuarioActual.Sesion("Comp-NumeroReembolso") = "" - UsuarioActual.Sesion("Comp-CveFYE") = "" - UsuarioActual.Sesion("Comp-Descripcion") = "" - - TxtNumeroReembolso.Text = "" - tdNumeroReembolso.Visible = True - RBLContado.SelectedValue = "6" - End If - End If - - - RBLContado.Items(0).Enabled = False - RBLContado.Items(3).Enabled = True - RBLContado.Items(4).Enabled = False - RBLContado.Items(5).Enabled = False - - - EsContado = False - - 'Valida Proceso 118 para ROL Administrador - Si es REEMBOLSO: Selecciona FyE y Relacionado con UsuarioActual cuando tiene CvePersonal - If UsuarioActual.TienePermisoProceso(118) Then - RBLContado.SelectedValue = "2" - RBLContado.Items(1).Enabled = False - End If - - Select Case RBLContado.SelectedValue - Case "2" - DdlPersonalReembolso.Visible = True - Case "6" - DdlCuentaCajaChicaReembolso.Visible = True - End Select - romCreditosTabla.Visible = False - Case "4" - CargaCreditosDisponibles() - Exit Select - End Select - UpGvCreditos.Update() - - If Not RBLPago.SelectedValue = "1" And MostrarModal And RBLPago.SelectedValue <> "4" Then - RegistraScript(String.Format("$('#{0}').modal('show');", "DivContadoModal")) - End If - - LtlTituloPago.Text = If(EsContado, "Contado", "Reembolso") - - DivContado.Visible = EsContado - DivReembolso.Visible = Not EsContado - - CargaContado() - - End Sub - Protected Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged - CargaContado() - End Sub - Private Sub RBLTipoDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLTipoDeudor.SelectedIndexChanged - GvDeudores.DataSource = Nothing - GvDeudores.DataBind() - UpContado.Update() - - CargaDeudores() - End Sub - Private Sub CargaContado() - 'ESCONDE TODO - PnlContadoBancos.Visible = False - PnlContadoFyE.Visible = False - PnlContadoCreditos.Visible = False - PnlContadoDeudores.Visible = False - PnlContadoAcreedores.Visible = False - PnlContadoCajaChica.Visible = False - DdlPersonalReembolso.Visible = False - DdlCuentaCajaChicaReembolso.Visible = False - - If GvDeudores IsNot Nothing Then - GvDeudores.DataSource = Nothing - GvDeudores.DataBind() - UPDeudores.Update() - End If - - 'Reembolsos - If RBLPago.SelectedValue = "3" Then - - Select Case RBLContado.SelectedValue - Case "2" - DdlPersonalReembolso.Visible = True - Case "6" - DdlCuentaCajaChicaReembolso.Visible = True - End Select - - 'Valida Proceso 118 para ROL Administrador - Si es REEMBOLSO: Selecciona FyE y Relacionado con UsuarioActual cuando tiene CvePersonal - If UsuarioActual.TienePermisoProceso(118) Then - If UsuarioActual.CvePersonal > 0 Then - DdlPersonalReembolso.SelectedValueExist(UsuarioActual.CvePersonal.ToString) - ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue - End If - DdlPersonalReembolso.Enabled = False - End If - - End If - - 'CONTADO - Select Case RBLContado.SelectedValue - Case "1" ' Bancos - PnlContadoBancos.Visible = True + SubTotal = TmpDT.SUM("Total").ToString.ToDecimal + If Not EsCarga Then + Descuentos = TmpDT.SUM("Descuento").ToString.ToDecimal + End If + TxtSubTotal.Text = (SubTotal + Descuentos).FormatoNumero() + TxtSubTotal2.Text = (SubTotal - Amortizacion).FormatoNumero + TxtDescuento.Text = Descuentos.FormatoNumero() + SubTotalConceptos = SubTotal + GvPS.DataSource = TmpDT : GvPS.DataBind() + + 'If TxtOtrosImpuestos.Text.ToDouble > 0 Then TxtOtrosImpuestos.Text = "" : TrOtrosImpuestos.Visible = False + + 'EN ESPERA DE ALGUN CASO QUE LO NECESITE - IPP 5 DICIEMBRE 2016 + 'TempSubTotal = TempSubTotal - SubTotal + 'If TempSubTotal > 0 Then + ' TxtTotal.Text = TempSubTotal.ToString.FormatoNumero + 'End If + + 'GVAF.DataSource = TmpDT : GVAF.DataBind() + End Sub + + Protected Sub ImgAjustePorcentaje_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAjustePorcentaje.Click + 'realizo el ajuste de los productos + AjustaConceptos() + For Each Row As GridViewRow In GvPS.Rows + If UsuarioActual.TienePermisoProceso(143) Then + Row.FCLinkButton("ImgE").Visible = True + Row.FCLinkButton("ImgD").Visible = True + End If + Next + End Sub + + Private Sub AjustaConceptos(Optional AjusteForzoso As Boolean = False) + 'SE COMENTO POR PORCENTAJE DE DESCUENTO 0.00 - IPP 3 ENERO 2017 + 'If TxtAjustePorcentaje.Text.ToDecimal <> 0 Or AjusteForzoso Then + 'End If + + If TxtAjustePorcentaje.Text.ToDecimal <> 0 Then + For Each Dr As DataRow In TmpDT.Rows + 'Dr("PU") = Dr("PU").ToString.ToDecimal * ((100 - TxtAjustePorcentaje.Text.ToDecimal) / 100) + Dim TotalAnterior = Dr("Total").ToString.ToDecimal + Dr("Total") = Dr("Total").ToString.ToDecimal * ((100 - TxtAjustePorcentaje.Text.ToDecimal) / 100) + Dr("Descuento") = TotalAnterior - Dr("Total").ToString.ToDecimal + Next + + 'TxtDescuento.Text = Descuentos.ToString + End If + + 'verifico las sumas + If TxtSubTotal2.Text.ToDecimal <> TmpDT.SUM("Total") Then + Dim i As Integer = TmpDT.Rows.Count - 1 + 'verifico si el ultimo dato, es diferente de cero, sino tomo el anterior + If TmpDT.Rows(i)("Total").ToString.ToDecimal <= 0 AndAlso i - 1 >= 0 Then i = i - 1 + + 'sino se hizo el ajuste, lo aplico al ultimo registro la diferencia + 'para ajustar el PU, de la diferencia la divido entre la cantidad + TmpDT.Rows(i)("PU") = TmpDT.Rows(i)("PU").ToString.ToDecimal + ((TxtSubTotal2.Text.ToDecimal - TmpDT.SUM("Total")) / TmpDT.Rows(i)("Cantidad").ToString.ToDecimal) + TmpDT.Rows(i)("Total") = TmpDT.Rows(i)("Total").ToString.ToDecimal + TxtSubTotal2.Text.ToDecimal - TmpDT.SUM("Total") + End If + + + TxtSubTotal.Text = (TmpDT.SUM("Total") + TmpDT.SUM("Descuento")).FormatoNumero + TxtSubTotal2.Text = TmpDT.SUM("Total").FormatoNumero + SubTotalOriginal = TmpDT.SUM("Total") + TmpDT.SUM("Descuento") + SubTotal2Original = TmpDT.SUM("Total") + + BtnGuardar.Enabled = True + UpFacturar.Update() + PnlAjusteProductos.Visible = False + 'habilito la busqueda de oc + ImgBtnBuscarOC.Visible = True + TxtOC.Enabled = True + UpParametros.Update() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + End Sub +#End Region + +#Region "DDL'S" + Protected Sub DdlCredito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCredito.SelectedIndexChanged + CargaCreditosDetalle(DdlCredito.SelectedValue.ToEntero) + CargaCreditosDisponibles() + End Sub + Protected Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged + TxtContadoDeudor.Text = "0" + + If DdlDeudor.SelectedValue.ToEntero > 0 Then + Dim Deudores As New ClsMovimientos + + If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then + If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0") + GvDeudores.DataSource = DtDeudoresDetalle + GvDeudores.DataBind() + End If + Else + If Deudores.GetDeudoresComisionesSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0") + GvDeudores.DataSource = DtDeudoresDetalle + GvDeudores.DataBind() + End If + End If + + + If CompraSaldo < TxtTotal.Text.ToDouble Then + RVContadoDeudor.MaximumValue = CompraSaldo.ToString + Else + RVContadoDeudor.MaximumValue = TxtTotal.Text + End If + + UPDeudores.Update() + Deudores.Dispose() + TxtContadoDeudor.Attributes.Add("readonly", "readonly") + End If + End Sub + Protected Sub DdlAcreedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAcreedor.SelectedIndexChanged + If DdlAcreedor.SelectedValue.ToEntero > 0 Then + Dim dr As DataRow + + dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) + 'If EmpresaPrueba Then + ' dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) + 'Else + ' dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlDeudor.SelectedValue)) + 'End If + + + If dr IsNot Nothing Then + Dim tSaldo As Double = dr("Saldo").ToString.ToDouble + RVContadoAcreedor.MaximumValue = tSaldo.ToString + 'si el saldo es mayor de la compra poner el valor de la compra sino el valor del saldo + TxtContadoAcreedor.Text = If(tSaldo > TxtTotal.Text.ToDouble, TxtTotal.Text, tSaldo.ToString).FormatoNumero + + LblDetalle.Visible = True + DdlAcreedorDetalle.Visible = True + + Dim ObjMov As New ClsMovimientos + Dim ObjProveedor As New ClsCompProveedores() + + If ObjMov.GetAcreedoresSaldosDetalles(-1, CveMoneda, UsuarioActual.CveEmpresa) Then + DdlAcreedorDetalle.DataSource = ObjMov.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) + DdlAcreedorDetalle.DataBind() + DdlAcreedorDetalle.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1")) + UpContado.Update() + End If + + If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, DdlAcreedor.SelectedValue.ToEntero, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa) Then + ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor + ViewState("CveCuentaProveedorAcreedores") = ObjProveedor.CveCuentaAcreedor + End If + + + ObjProveedor.Dispose() + ObjMov.Dispose() + + End If + + Else + TxtContadoAcreedor.Text = "0" + End If + End Sub + Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonal.SelectedIndexChanged + ViewState("CvePersonal") = DdlPersonal.SelectedValue + End Sub + Protected Sub DdlCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCajaChica.SelectedIndexChanged + ViewState("CveCajaChica") = DdlCajaChica.SelectedValue + End Sub + Protected Sub DdlTipoCredito_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaCreditos() + + Select Case DdlTipoCredito.SelectedValue.ToEntero + Case 1 + DivCreditoMensualidad.Visible = False + Case 2 + DivCreditoMensualidad.Visible = True + End Select + End Sub + Protected Sub DdlProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedor.SelectedIndexChanged + ViewState("CveProveedor") = DdlProveedor.SelectedValue.ToEntero + HdnCveProveedor.Value = CveProveedor.ToString + CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1", False) + + + + + If DdlPS.ddl.SelectedIndex > 0 Then + DdlPS_SelectedIndexChanged(sender, e) + DdlPS.Focus() + Else + TxtCantidad.Focus() + End If + + If DdlProveedor.SelectedValue.ToEntero > 0 Then + ChkConsignacion.Enabled = True + Else + ChkConsignacion.Enabled = False + End If + + If GlobalDTProveedorSucursales(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then + RowProveedorSucursal.Visible = True + DdlProveedorSucursal.Items.Clear() + DdlProveedorSucursal.DataSource = GlobalDTProveedorSucursales(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) + DdlProveedorSucursal.DataBind() + DdlProveedorSucursal.Items.Insert(0, New ListItem("Selecciona una Sucursal", "-1")) + DdlProveedorSucursal.Items.Insert(0, New ListItem("Matriz", "0")) + Else + DdlProveedorSucursal.Items.Clear() + DdlProveedorSucursal.Items.Insert(0, New ListItem("N/O", "-1")) + DdlProveedorSucursal.DataBind() + RowProveedorSucursal.Visible = False + End If + + UpEstatus.Update() + UpTabs.Update() + + + + + + + + 'DdlProveedor.Attributes.Add("onclick", "CargaProveedores();") + End Sub + Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged + Dim Folio As Long + + Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) + + If dr IsNot Nothing Then + CveMoneda = dr("CveMoneda").ToString.ToEntero + IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero + CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero + CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero + If dr("UsaTarjeta").ToString = "True" Then + CargaGridTarjetas() + Else + DivTarjeta.Visible = False + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then + Dim Banco As New ClsBancos + Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) + Banco.Dispose() + + TxtDocumentoFolio.Text = Folio.ToString + End If + + End Sub + Protected Sub DdlCuentaCaja_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCaja.SelectedIndexChanged + Dim Folio As Long + + Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaCaja.SelectedValue) + + If dr IsNot Nothing Then + CveMoneda = dr("CveMoneda").ToString.ToEntero + IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero + CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + End If + + If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then + Dim Banco As New ClsBancos + Folio = Banco.GetNextFolio(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero) + Banco.Dispose() + + TxtDocumentoFolioCaja.Text = Folio.ToString + End If + + End Sub + Protected Sub DdlFuncionarioEmpleado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuncionarioEmpleado.SelectedIndexChanged + If DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + Dim ObjMovtos As New ClsMovimientos + RowCheque.Visible = True + + ObjMovtos.GetEgresosSinComprobarPersonalDetalle(DdlFuncionarioEmpleado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) + DtCheques = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha") + + 'Limpia Ddl Cheques + DDlCheques.Items.Clear() + + If DtCheques.Rows.Count > 0 Then + DDlCheques.DataSource = DtCheques + End If + + ObjMovtos.Dispose() + DDlCheques.DataBind() + + + DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty) + Else + RowCheque.Visible = False + + lblSaldoFE.Text = "0.00" + End If + + End Sub + Protected Sub DDlCheques_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDlCheques.SelectedIndexChanged + Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal + + TxtDocumentoImporteFE.Text = If(saldo < TxtTotal.Text.ToDouble, saldo.FormatoNumero, TxtTotal.Text) + lblSaldoFE.Text = saldo.FormatoNumero + + RVDocumentoImporteFE.MaximumValue = saldo.ToString + UPCondicionesPago.Update() + + End Sub +#End Region + +#Region "CHK'S" + Protected Sub RBLCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLCajaChica.SelectedIndexChanged + Select Case RBLCajaChica.SelectedValue + Case "1" : DdlCajaChica.Visible = False : DdlPersonal.Visible = True + Case "2" : DdlCajaChica.Visible = True : DdlPersonal.Visible = False + End Select + + + End Sub + Protected Sub ChkReembolso_CheckedChanged(sender As Object, e As EventArgs) Handles ChkReembolso.CheckedChanged + PnlReemb.Visible = ChkReembolso.Checked + End Sub + Protected Sub RBLPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLPago.SelectedIndexChanged + CambiaTipoPago(True) + End Sub + Private Sub CambiaTipoPago(MostrarModal As Boolean) + DdlPersonalReembolso.Visible = False + DdlCuentaCajaChicaReembolso.Visible = False + + + Select Case RBLPago.SelectedValue + Case "1" 'Credito + PnlContado.Visible = False + + If Not UsuarioActual.Empresa.UsaAC Then + TxtNumeroReembolso.Text = "" + tdNumeroReembolso.Visible = False + End If + EsContado = False + romCreditosTabla.Visible = False + Case "2" 'Contado + PnlContado.Visible = True + + TxtNumeroReembolso.Text = "" + tdNumeroReembolso.Visible = False + + + + RBLContado.Items(0).Enabled = True + RBLContado.Items(3).Enabled = True + RBLContado.Items(4).Enabled = True + RBLContado.Items(5).Enabled = True + + + If UsuarioActual.Empresa.CvePlataforma = 2 Then + RBLContado.Items.Clear() + RBLContado.Items.Insert(0, New ListItem("Bancos", "1")) + RBLContado.Items.Insert(1, New ListItem("Caja Chica", "6")) + RBLContado.Items.Insert(2, New ListItem("Deudores", "4")) + RBLContado.SelectedIndex = 0 + + + 'RBLContado.Items.Item(2).Enabled = False + 'RBLContado.Items.Item(4).Enabled = False + 'RBLContado.Items.Item(5).Enabled = False + End If + + 'If EmpresaPrueba Then + ' RBLContado.Items(5).Enabled = False + 'End If + + EsContado = True + romCreditosTabla.Visible = False + Case "3" 'Reembolso/Comprobacion + PnlContado.Visible = True + + + ''AGARRA VALORES DE SESSION PARA REEMBOLSO -- SI YA ESTA REGISTRADA LA COMPRA IGNORA DATOS DE REEMBOLSO + If Not CveCompra > 0 Then + If UsuarioActual.Sesion("Comp-NumeroReembolso") <> Nothing AndAlso UsuarioActual.Sesion("Comp-NumeroReembolso").ToString <> "" Then + 'RBLPago.SelectedValue = "3" ' [IPP] SE COMENTO POR NO PODER MOSTRAR LO SELECCIONADO + 'RBLPago_SelectedIndexChanged(RBLPago, EventArgs.Empty) + 'CambiaTipoPago(False) + + tdNumeroReembolso.Visible = True + TxtNumeroReembolso.Text = UsuarioActual.Sesion("Comp-NumeroReembolso").ToString + TxtDescripcion.Text = UsuarioActual.Sesion("Comp-Descripcion").ToString + + If UsuarioActual.Sesion("Comp-CveFYE") <> Nothing AndAlso UsuarioActual.Sesion("Comp-CveFYE").ToString.ToEntero > 0 Then + RBLContado.SelectedValue = "2" + RBLContado_SelectedIndexChanged(RBLContado, EventArgs.Empty) + DdlPersonalReembolso.SelectedValueExist(UsuarioActual.Sesion("Comp-CveFYE").ToString) + ViewState("CvePersonal") = UsuarioActual.Sesion("Comp-CveFYE").ToString + Else + RBLContado.SelectedValue = "6" + End If + + Else + UsuarioActual.Sesion("Comp-NumeroReembolso") = "" + UsuarioActual.Sesion("Comp-CveFYE") = "" + UsuarioActual.Sesion("Comp-Descripcion") = "" + + TxtNumeroReembolso.Text = "" + tdNumeroReembolso.Visible = True + RBLContado.SelectedValue = "6" + End If + End If + + + RBLContado.Items(0).Enabled = False + RBLContado.Items(3).Enabled = True + RBLContado.Items(4).Enabled = False + RBLContado.Items(5).Enabled = False + + + EsContado = False + + 'Valida Proceso 118 para ROL Administrador - Si es REEMBOLSO: Selecciona FyE y Relacionado con UsuarioActual cuando tiene CvePersonal + If UsuarioActual.TienePermisoProceso(118) Then + RBLContado.SelectedValue = "2" + RBLContado.Items(1).Enabled = False + End If + + Select Case RBLContado.SelectedValue + Case "2" + DdlPersonalReembolso.Visible = True + Case "6" + DdlCuentaCajaChicaReembolso.Visible = True + End Select + romCreditosTabla.Visible = False + Case "4" + CargaCreditosDisponibles() + Exit Select + End Select + UpGvCreditos.Update() + + If Not RBLPago.SelectedValue = "1" And MostrarModal And RBLPago.SelectedValue <> "4" Then + RegistraScript(String.Format("$('#{0}').modal('show');", "DivContadoModal")) + End If + + LtlTituloPago.Text = If(EsContado, "Contado", "Reembolso") + + DivContado.Visible = EsContado + DivReembolso.Visible = Not EsContado + + CargaContado() + + End Sub + Protected Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged + CargaContado() + End Sub + Private Sub RBLTipoDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLTipoDeudor.SelectedIndexChanged + GvDeudores.DataSource = Nothing + GvDeudores.DataBind() + UpContado.Update() + + CargaDeudores() + End Sub + Private Sub CargaContado() + 'ESCONDE TODO + PnlContadoBancos.Visible = False + PnlContadoFyE.Visible = False + PnlContadoCreditos.Visible = False + PnlContadoDeudores.Visible = False + PnlContadoAcreedores.Visible = False + PnlContadoCajaChica.Visible = False + DdlPersonalReembolso.Visible = False + DdlCuentaCajaChicaReembolso.Visible = False + + If GvDeudores IsNot Nothing Then + GvDeudores.DataSource = Nothing + GvDeudores.DataBind() + UPDeudores.Update() + End If + + 'Reembolsos + If RBLPago.SelectedValue = "3" Then + + Select Case RBLContado.SelectedValue + Case "2" + DdlPersonalReembolso.Visible = True + Case "6" + DdlCuentaCajaChicaReembolso.Visible = True + End Select + + 'Valida Proceso 118 para ROL Administrador - Si es REEMBOLSO: Selecciona FyE y Relacionado con UsuarioActual cuando tiene CvePersonal + If UsuarioActual.TienePermisoProceso(118) Then + If UsuarioActual.CvePersonal > 0 Then + DdlPersonalReembolso.SelectedValueExist(UsuarioActual.CvePersonal.ToString) + ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue + End If + DdlPersonalReembolso.Enabled = False + End If + + End If + + 'CONTADO + Select Case RBLContado.SelectedValue + Case "1" ' Bancos + PnlContadoBancos.Visible = True TxtDocumentoImporte.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero - Case "2" ' F y E - PnlContadoFyE.Visible = True - CargaFuncionariosEmpleados() - Case "3" ' Creditos - PnlContadoCreditos.Visible = True - CargaCreditos() - Case "4" ' Deudores - PnlContadoDeudores.Visible = True - CargaDeudores() - Case "5" ' ACREEDORES - PnlContadoAcreedores.Visible = True - CargaAcreedores() - Case "6" ' Caja Chica - PnlContadoCajaChica.Visible = True - TxtDocumentoImporteCaja.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero - End Select - - UpContado.Update() - End Sub - - Protected Sub RblRembolso_SelectedIndexChanged(sender As Object, e As EventArgs) - TrRembolsoCajaChica.Visible = False - TrRembolsoPersonal.Visible = False - DdlRembolsoCajaChica.SelectedValueExist("-1") - DdlRembolsoPersonal.SelectedValueExist("-1") - If RblRembolso.SelectedValue.ToEntero = 1 Then - TrRembolsoPersonal.Visible = True - ElseIf RblRembolso.SelectedValue.ToEntero = 2 Then - TrRembolsoCajaChica.Visible = True - End If - End Sub -#End Region + Case "2" ' F y E + PnlContadoFyE.Visible = True + CargaFuncionariosEmpleados() + Case "3" ' Creditos + PnlContadoCreditos.Visible = True + CargaCreditos() + Case "4" ' Deudores + PnlContadoDeudores.Visible = True + CargaDeudores() + Case "5" ' ACREEDORES + PnlContadoAcreedores.Visible = True + CargaAcreedores() + Case "6" ' Caja Chica + PnlContadoCajaChica.Visible = True + TxtDocumentoImporteCaja.Text = (TxtTotal.Text.ToDecimal - LblAmortizacion.Text.ToDecimal).FormatoNumero + End Select -#Region "ARMONIZACION CONTABLE - AC - SIMPLIFICADO" - Private Sub CargaPresupuestosEgresos(Optional CargaTodo As Boolean = True) - - 'Seccion Grid - GvPS.Width = 1760 - GvPS.Columns(12).Visible = True - GvPS.Columns(13).Visible = True - GvPS.Columns(14).Visible = True - GvPS.Columns(15).Visible = True - GvPS.Columns(16).Visible = True - - 'Panel General - UpPresupuestosAC.Visible = True - - DdlACGeneral1.Items.Clear() - DdlACGeneral1.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"}) - DdlACGeneral1.DataBind() - - DdlACGeneral2.Items.Clear() - DdlACGeneral2.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"}, Orderby:="UnidadAdministrativa") - DdlACGeneral2.DataBind() - - DdlACGeneral3.Items.Clear() - DdlACGeneral3.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"}, Orderby:="FuenteFinanciamiento") - DdlACGeneral3.DataBind() - - DdlACGeneral4.Items.Clear() - DdlACGeneral4.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"}) - DdlACGeneral4.DataBind() - - DdlACGeneral5.Items.Clear() - DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") - If UsuarioActual.CveEmpresa.Contiene(120) Then - DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") - Else - DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") - End If - DdlACGeneral5.DataBind() - - If CveCompra > 0 Then - RegistraScript("$get('DivPresupuestoEgresosGeneral').style.display = 'none';") - BtnVerPE.Visible = True - End If - - If CargaTodo Then - CalculaSaldoACGeneral() - UpPresupuestosAC.Update() - End If - - End Sub - - Private Sub ConservaAC() - 'Guarda valores AC en TmpDT - Dim Index = 0 - For Each gvr As GridViewRow In GvPS.Rows - TmpDT.Rows(Index)("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero - TmpDT.Rows(Index)("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero - TmpDT.Rows(Index)("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero - TmpDT.Rows(Index)("CveTipoGastoAC") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero - TmpDT.Rows(Index)("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero - Index += 1 - Next - End Sub - - Protected Sub CompruebaSaldoAC(sender As Object, e As EventArgs) - ConservaAC() - - CompruebaAgregar() - End Sub - - Protected Sub CambiaACGeneral(sender As Object, e As EventArgs) - - If ChkACGeneral.Checked Then - - 'CAMBIA LOS COMBOS DE TODOS LOS DETALLES DEL GRID - For Each gvr As GridViewRow In GvPS.Rows - - 'SI VIENE DESDE OC EL PE NO SE MUEVE - If Not gvr.DataKey("CveOrdenCompraDetalle").ToEntero > 0 Then - gvr.FCDropDownList("DdlAC1").SelectedValue = DdlACGeneral1.SelectedValue - gvr.FCDropDownList("DdlAC2").SelectedValue = DdlACGeneral2.SelectedValue - gvr.FCDropDownList("DdlAC3").SelectedValue = DdlACGeneral3.SelectedValue - gvr.FCDropDownList("DdlAC4").SelectedValue = DdlACGeneral4.SelectedValue - gvr.FCDropDownList("DdlAC5").SelectedValue = DdlACGeneral5.SelectedValue - End If - Next - - ConservaAC() - CompruebaAgregar() - UpPS.Update() - - End If - - CalculaSaldoACGeneral() - UpPresupuestosAC.Update() - - End Sub - - Private Sub CalculaSaldoACGeneral() - Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa) - Dim DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", DdlACGeneral1.SelectedValue.ToString, DdlACGeneral2.SelectedValue.ToString, DdlACGeneral3.SelectedValue.ToString, DdlACGeneral4.SelectedValue.ToString, DdlACGeneral5.SelectedValue.ToString)) - If DtPresupuestosTemp.Rows.Count > 0 Then - Dim IdCuenta = If(HdnVCveOC.Value <> "-1", DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero, DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero) - - LbACGeneralSaldo.Text = ContPaq.GetSaldoCuenta(IdCuenta, 0, TxtFecha.Text.ToDate.Year).ToString.FormatoNumero(2) - Else - LbACGeneralSaldo.Text = "0.00" - End If - ContPaq.Dispose() - End Sub - - Private Sub CargaHidendsAC() - Dim DtPresupuestosTemp As DataTable - Dim Filtro As New StringBuilder - - For Each grid As GridViewRow In GvPS.Rows - Filtro.AppendFormat("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", grid.FCDropDownList("DdlAC1").SelectedValue.ToString, grid.FCDropDownList("DdlAC2").SelectedValue.ToString, grid.FCDropDownList("DdlAC3").SelectedValue.ToString, grid.FCDropDownList("DdlAC4").SelectedValue.ToString, grid.FCDropDownList("DdlAC5").SelectedValue.ToString) - DtPresupuestosTemp = DtPresupuestos.FiltraParametros(Filtro.ToString) - Filtro.Clear() - - If DtPresupuestosTemp.Rows.Count > 0 Then - TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaComprometido") = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaPorEjercer") = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaDevengado") = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaMatriz") = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString - Else - Alert("Ocurrió un error al vincular el Presupuesto de Egreso. Por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) - End If - Next - - End Sub - - Private Sub CompruebaAgregar() - Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa) - Dim disponible As Double - Dim ErrorPresupuesto = False - Dim Conceptos As New StringBuilder - - Dim Ddl1 As DropDownList - Dim Ddl2 As DropDownList - Dim Ddl3 As DropDownList - Dim Ddl4 As DropDownList - Dim Ddl5 As DropDownList - Dim Total As Double - - Dim DtPresupuestosTemp As DataTable - Dim Filtro As New StringBuilder - - For Each grid As GridViewRow In GvPS.Rows - Ddl1 = grid.FCDropDownList("DdlAC1") - Ddl2 = grid.FCDropDownList("DdlAC2") - Ddl3 = grid.FCDropDownList("DdlAC3") - Ddl4 = grid.FCDropDownList("DdlAC4") - Ddl5 = grid.FCDropDownList("DdlAC5") - Total = grid.Cells(8).ToString.ToDouble - - Filtro.AppendFormat("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", Ddl1.SelectedValue.ToString, Ddl2.SelectedValue.ToString, Ddl3.SelectedValue.ToString, Ddl4.SelectedValue.ToString, Ddl5.SelectedValue.ToString) - DtPresupuestosTemp = DtPresupuestos.FiltraParametros(Filtro.ToString) - Filtro.Clear() - - If DtPresupuestosTemp IsNot Nothing AndAlso DtPresupuestosTemp.Rows.Count > 0 Then - disponible = ContPaq.GetSaldoCuenta(If(OCVinculada, DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero, DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero), 0, TxtFecha.Text.ToDate.Year) - - If (disponible > 0 AndAlso disponible >= Total) Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - 'Alert("Si hay dinero: ") - - TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaComprometido") = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaPorEjercer") = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaDevengado") = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString - TmpDT.Rows(grid.RowIndex)("IdCuentaMatriz") = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString - - grid.Cells(7).BackColor = Drawing.Color.Green - Else - 'Alert("No hay presupuesto asignado", TipoMensaje.MsgAdvertencia) - Conceptos.AppendFormat("
#{0} - {1} - {2}", grid.RowIndex + 1, grid.DataKey("Clasificacion"), grid.DataKey("PS")) - grid.Cells(7).BackColor = Drawing.Color.Red - ErrorPresupuesto = True - End If - - TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString - - Else - TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = "-1" - 'Alert("No hay presupuesto asignado", TipoMensaje.MsgAdvertencia) - Conceptos.AppendFormat("
#{0} - {1} - {2}", grid.RowIndex + 1, grid.DataKey("Clasificacion"), grid.DataKey("PS")) - grid.Cells(7).BackColor = Drawing.Color.Red - ErrorPresupuesto = True - End If - - Next - - If ErrorPresupuesto Then - Alert(String.Format("No hay presupuesto asignado para los siguientes conceptos: {0}", Conceptos), TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - Else - BtnGuardar.Enabled = True - End If - UpFacturar.Update() - ContPaq.Dispose() - End Sub - - Private Sub GuardaAC() - Dim dr As DataRow - For Each gvr As GridViewRow In GvPS.Rows - dr = TmpDT.Rows(gvr.RowIndex) - - 'DtDetalle.Rows(gvr.RowIndex)("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero - 'DtDetalle.Rows(gvr.RowIndex)("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero - 'DtDetalle.Rows(gvr.RowIndex)("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero - 'DtDetalle.Rows(gvr.RowIndex)("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero - 'DtDetalle.Rows(gvr.RowIndex)("CveTipoGasto") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero - - dr("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero - dr("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero - dr("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero - dr("CveTipoGastoAC") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero - dr("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero - 'dr("CvePresupuestoEgreso") = gvr.FCHiddenField("HdnCvePresupuestoEgreso").Value.ToString.ToEntero - Next - - TmpDT.AcceptChanges() - End Sub - - Protected Sub BtnCambiaFecha_Click(sender As Object, e As EventArgs) - CambiaEjercicioAC() - End Sub - - Private Sub CambiaEjercicioAC(Optional CargaTodo As Boolean = True) - Dim Ejercicio = If(IsDate(TxtFecha.Text), Year(TxtFecha.Text.ToDate), UsuarioActual.Empresa.EjercicioActual) - - If Ejercicio <> EjercicioAC Then - Dim AC As New ClsAC - If AC.GetPresupuestoEgresos(-1, True, Ejercicio, UsuarioActual.CveEmpresa, True) Then - DtPresupuestos = AC.DtResultados.Copy - CargaPresupuestosEgresos(CargaTodo) - - ConservaAC() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - 'CAMBIA LOS COMBOS DE TODOS LOS DETALLES DEL GRID - For Each gvr As GridViewRow In GvPS.Rows - gvr.FCDropDownList("DdlAC1").SelectedValue = DdlACGeneral1.SelectedValue - gvr.FCDropDownList("DdlAC2").SelectedValue = DdlACGeneral2.SelectedValue - gvr.FCDropDownList("DdlAC3").SelectedValue = DdlACGeneral3.SelectedValue - gvr.FCDropDownList("DdlAC4").SelectedValue = DdlACGeneral4.SelectedValue - gvr.FCDropDownList("DdlAC5").SelectedValue = DdlACGeneral5.SelectedValue - Next - - If CargaTodo Then CompruebaAgregar() - - UpPS.Update() - UpPresupuestosAC.Update() - Else - Alert("Ocurrio un error al cargar los Presupuestos. Por favor vuelva a cargar la página") - End If - AC.Dispose() - - EjercicioAC = Ejercicio - End If - + UpContado.Update() End Sub -#End Region - -#Region "E V E N T O - B I T A C O R A" - Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(200) - e.Row.Cells(1).Width = Unit.Pixel(200) - e.Row.Cells(2).Width = Unit.Pixel(100) - e.Row.Cells(3).Width = Unit.Pixel(500) - End If - - If e.Row.DBCampo("Archivo").ToString <> "" Then - e.Row.FCLinkButton("LinkArchivo").Visible = True - e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) - ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione - End If - - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left - - End If - End Sub - - Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click - Dim ObjEventoBitacora As New ClsOIEventos - - Dim FileExtension As String = "-1" - Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos - Dim Filename As String = "" - For Each fileItem As Archivo In Filesgral - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - Filename = fileItem.filename - Next - - - - If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - If Filename <> "" Then - Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) - End If - - GvEB.DataSource = ObjEventoBitacora.DtResultados - TxtEventoDescripcion.Text = "" - Anexo.Text = "[]" - Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion) - RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") - - End If - ObjEventoBitacora.Dispose() - GvEB.DataBind() - - UPEventoBitacora.Update() - CargaEventoBitacora() - UPAddEventoBitacora.Update() - End Sub - - 'Protected Sub CargarArchivo(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AFU.UploadedComplete - ' If AFU.HasFile Then - - - ' Dim UploadFolder As String = String.Format("{0}\Temp\", UsuarioActual.Empresa.Ruta) - ' UploadFolder.DirectoryExistsCreate() - ' Dim Extension As String = System.IO.Path.GetExtension(AFU.PostedFile.FileName) - - ' If File.Exists(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension)) Then File.Delete(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension)) - - ' AFU.SaveAs(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension) - ' Session("FileUpload") = UploadFolder & UsuarioActual.CveUsuario.ToString & Extension - ' Session("FileExtension") = Extension - ' Session("FileFolder") = UploadFolder - ' End If - 'End Sub - Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs) - Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument) - Dim Archivo As New System.IO.FileInfo(filePath) - - HttpContext.Current.Response.Clear() - HttpContext.Current.Response.ClearContent() - HttpContext.Current.Response.ContentType = "application/octet-stream" - HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath)) - HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) - HttpContext.Current.Response.TransmitFile(filePath) - HttpContext.Current.Response.Flush() - HttpContext.Current.Response.End() - - Archivo = Nothing - End Sub - - Private Sub CargaEventoBitacora() - - Dim ObjEventoBitacora As New ClsOIEventos() - If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") - Else - GvEB.DataSource = Nothing - End If - ObjEventoBitacora.Dispose() - GvEB.DataBind() + Protected Sub RblRembolso_SelectedIndexChanged(sender As Object, e As EventArgs) + TrRembolsoCajaChica.Visible = False + TrRembolsoPersonal.Visible = False + DdlRembolsoCajaChica.SelectedValueExist("-1") + DdlRembolsoPersonal.SelectedValueExist("-1") + If RblRembolso.SelectedValue.ToEntero = 1 Then + TrRembolsoPersonal.Visible = True + ElseIf RblRembolso.SelectedValue.ToEntero = 2 Then + TrRembolsoCajaChica.Visible = True + End If End Sub -#End Region +#End Region + +#Region "ARMONIZACION CONTABLE - AC - SIMPLIFICADO" + Private Sub CargaPresupuestosEgresos(Optional CargaTodo As Boolean = True) + + 'Seccion Grid + GvPS.Width = 1760 + GvPS.Columns(12).Visible = True + GvPS.Columns(13).Visible = True + GvPS.Columns(14).Visible = True + GvPS.Columns(15).Visible = True + GvPS.Columns(16).Visible = True + + 'Panel General + UpPresupuestosAC.Visible = True + + DdlACGeneral1.Items.Clear() + DdlACGeneral1.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"}) + DdlACGeneral1.DataBind() + + DdlACGeneral2.Items.Clear() + DdlACGeneral2.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"}, Orderby:="UnidadAdministrativa") + DdlACGeneral2.DataBind() + + DdlACGeneral3.Items.Clear() + DdlACGeneral3.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"}, Orderby:="FuenteFinanciamiento") + DdlACGeneral3.DataBind() + + DdlACGeneral4.Items.Clear() + DdlACGeneral4.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"}) + DdlACGeneral4.DataBind() + + DdlACGeneral5.Items.Clear() + DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") + If UsuarioActual.CveEmpresa.Contiene(120) Then + DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") + Else + DdlACGeneral5.DataSource = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion") + End If + DdlACGeneral5.DataBind() + + If CveCompra > 0 Then + RegistraScript("$get('DivPresupuestoEgresosGeneral').style.display = 'none';") + BtnVerPE.Visible = True + End If + + If CargaTodo Then + CalculaSaldoACGeneral() + UpPresupuestosAC.Update() + End If -#Region " C O N T A B I L I D A D " - Protected Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs) - 'Alert("Hola entre", TipoMensaje.MsgError) - 'Exit Sub - - Dim ObjConta As New ClsContabilidad - Dim Movimientos = ObjConta.GetMovimientosPoliza(IdPoliza, UsuarioActual.CveEmpresa) - - 'Verifica que solo exista 1 compra asociada - If Movimientos = 1 Then - EliminaPoliza() - Else - RegistraScript("ConfirmEliminarPolizaMultiple();") - End If - - ObjConta.Dispose() - End Sub - Protected Sub LBContabilizarAC_Click(sender As Object, e As EventArgs) - Dim ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - Dim ObjCompras As New ClsCompras - Dim ObjProveedores As New ClsCompProveedores(ObjCompras.IniciaTransacSQL()) - Dim ObjAF As New ClsAF(ObjCompras.IniciaTransacSQL()) - Dim ErrorAC = False - Dim IDPolizaComprometido = If(TxtOC.Text.Length > 0, 1, 0) - - ''EMPIEZA: SI USA AC - If UsuarioActual.Empresa.UsaAC Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - - - 'ELIMINA TODOS LOS MOVIMIENTOS DE LA POLIZA - If IdPoliza > 0 Then - ObjContaAC.RemoveAllMovimientos(IdPoliza) - Else - Dim TotalPorDevengar = Math.Round(TxtTotal.Text.ToDouble, 2) - IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) - End If - - 'INSERTA LOS NUEVOS MOVIMIENTOS DE LA POLIZA - If IdPoliza > 0 Then - Dim CuentaAbono As Integer - Dim Importe As Decimal = 0 - Dim TotalDetalle As Decimal = 0 - - 'CUENTA PROVEEDOR - If CtaProveedor <= 0 Then - If ObjContaAC.GetCuentas(-1, "021120000000000000", -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021120000000000000").ToString - ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02112{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) - ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - Dim ConceptoRenglon As String = "" - If Not ErrorAC Then - - Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal - - Dim ipresup As Integer = 0 - - 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS - Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() - Group gvr By Grp = New With { - Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, - Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) - } Into Group - Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, - TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) - Dim Fecha As Date = TxtFecha.Text.ToDate - - 'PresupuestoEgresos - Dim DtPresupuestosTemp As DataTable - Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer - - 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double - tTotalIVA = TxtIVA.Text.ToDecimal - tRetIVA = TxtRetIVA.Text.ToDecimal - tRetISR = TxtRetISR.Text.ToDecimal - - 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR - - tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA - tDiferenciaIVA = tTotalIVA - tIVA = 0 - ipresup = 0 - - 'INVENTARIOS EN AC - Dim CuentaMatrizAlmacen As Integer - Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) - - Dim CtaAlmacen As Integer - If ContadorInventario > 0 Then - Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) - If drr IsNot Nothing Then - CtaAlmacen = drr("IdCtaContable").ToString.ToEntero - End If - End If - Dim DescuentoConIVA As Double - Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) - Dim tAjusteTotal As Decimal = 0 - - For Each grp In Presup - Importe = grp.TotalImporte - TotalDetalle += Importe - ipresup += 1 - If Importe > 0 Then - 'saco la proporcion de iva que le corresponde - tIVA = Math.Round(Importe * tPorIVA, 2) - tDiferenciaIVA -= tIVA - 'identifico si es el ultimo registro, para ver si es necesario un ajuste - If ipresup = Presup.Count Then - If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then - tIVA += tDiferenciaIVA - End If - End If - - 'le sumo el iva al concepto - Importe += tIVA - 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF - If TxtDescuento.Text.ToDouble > 0 Then - Importe = grp.TotalImporte * (1 + tPorIVA) - End If - - tAjusteTotal += Importe - - 'valido que la sumas de lo detalles no exceda al totalgeneral - If Math.Round(tAjusteTotal, 2) > tTotalGral Then - 'le resto la diferencia - Importe -= (tAjusteTotal - tTotalGral) - End If - - 'Presupuesto Egresos - DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) - If DtPresupuestosTemp.Rows.Count <> 1 Then - ErrorAC = True - Exit For - End If - IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero - IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero - IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero - IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero - - 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA - If IDPolizaComprometido = 0 Then - ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - End If - - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - 'DEVENGADO - If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - - - If ContadorInventario > 0 Then - Dim tImporte, ttIVA As Double - - For Each gvr As GridViewRow In GvPS.Rows - 'registra los movimientos del presupuesto asignado, para que no se duplique si hay varios presupeusto dentro de la compra - If gvr.DataKey("CvePresupuestoEgreso").ToEntero = grp.CvePresupuestoEgreso Then - 'saco la proporcion de iva que le corresponde - tImporte = gvr.FCLiteral("LtlTotal").Text.ToDouble - ttIVA = Math.Round(tImporte * tTotalIVA / tTotalGral, 2) - tImporte += ttIVA - End If - - Next - - CuentaMatrizAlmacen = CtaAlmacen - - ElseIf grp.CveActivoFijo > 0 Then - - Dim CtaAF = -1 - Dim AF = "" - Dim CuentaInicial = -1 - - If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then - CtaAF = ObjAF.Cuenta - AF = ObjAF.Descripcion - CuentaInicial = ObjAF.CuentaInicial - Else - ErrorAC = True - Exit For - End If - - If Not CuentaInicial > 0 Then - CuentaInicial = 1241 - End If - - 'CUENTA AF - If CtaAF <= 0 Then - If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then - Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") - If drCuenta IsNot Nothing Then - - CuentaAbono = drCuenta("Id").ToString.ToEntero - Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString - CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) - - ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - CuentaMatrizAlmacen = CtaAF - Else - CuentaMatrizAlmacen = IdCuentaMatriz - End If - - - ''AFECTAR MATRIZ EGRESOS - If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - - ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) - If TxtDescuento.Text.ToDouble > 0 AndAlso CtaProveedorAnticipos > 0 Then - DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16 - - 'Valida que el descuento con iva cuadre en los totales - If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then - DescuentoConIVA = Importe - TxtTotal.Text.ToDouble - ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then - ErrorAC = True - Exit For - End If - - 'actualizo el idcuenta del presupuesto - If ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then - 'agrego a la cuenta contable anticipos - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - Exit For - End If - Else - ErrorAC = True - Exit For - End If - Else - 'actualizo el idcuenta del - - End If - - Else - ErrorAC = True - Exit For - End If - ''TERMINA AFECTAR MATRIZ EGRESOS - - Else - ErrorAC = True - Exit For - End If - - Next - - If Not ErrorAC Then - 'registro un solo movimiento a proveedores - Importe = TxtTotal.Text.ToDecimal - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - End If - End If - - If tRetISR > 0 Then - ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) - If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then - ErrorAC = True - End If - End If - - End If - - Else - ErrorAC = True - End If - - 'CUADRA LA POLIZA - ObjContaAC.AjustaPoliza(IdPoliza) - - End If - ''TERMINA: SI USA AC - - If Not ErrorAC Then - If Not ObjCompras.UpdateCompraPoliza(IdPoliza, CveCompra) Then - ErrorAC = True - End If - End If - - - If ErrorAC Then - - - - Alert("Ocurrió un error al contabilizar la compra. Comuniquese con soporte.", TipoMensaje.MsgError) - ObjContaAC.RollBack() - ObjCompras.RollBack() - Else - ObjContaAC.Commit() - ObjCompras.Commit() - Alert("La Compra se contabilizó correctamente.", TipoMensaje.MsgInformacion) - - HplCompraContabilizada.Text = "Si" - HplCompraContabilizada.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", IdPoliza) - LblCompraEstatus.ForeColor = Drawing.Color.Navy - trContabilizada.Visible = True - UpEstatus.Update() - End If - ObjContaAC.Dispose() - - End Sub - - Protected Sub BtnEliminarPoliza_Click(sender As Object, e As EventArgs) - EliminaPoliza() - End Sub - - Private Sub EliminaPoliza() - Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - - Dim ErrorCompra = False - - 'Elimina la poliza - If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then - If Not ObjAC.RemovePoliza(IdPoliza) Then - ErrorCompra = True - End If - End If - - 'Desasocia la poliza - If Not ErrorCompra Then - If Not ObjConta.DesasociarPoliza(IdPoliza, UsuarioActual.CveEmpresa) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion) - ObjAC.Commit() - ObjConta.Commit() - - Else - Alert("Ocurrió un error al desvincular y/o eliminar la poliza. Por favor intente de nuevo ", TipoMensaje.MsgError) - ObjAC.RollBack() - ObjConta.RollBack() - End If - - ObjAC.Dispose() - ObjConta.Dispose() - - If Not ErrorCompra Then - CargaCompra() - End If End Sub -#End Region - -#Region " REEMBOLSOS NO USA AC " - Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged - ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue - End Sub - Protected Sub DdlCajaChica2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCajaChicaReembolso.SelectedIndexChanged - Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaCajaChicaReembolso.SelectedValue) - - If dr IsNot Nothing Then - CveMoneda = dr("CveMoneda").ToString.ToEntero - IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero - CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero - End If - ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue + Private Sub ConservaAC() + 'Guarda valores AC en TmpDT + Dim Index = 0 + For Each gvr As GridViewRow In GvPS.Rows + TmpDT.Rows(Index)("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero + TmpDT.Rows(Index)("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero + TmpDT.Rows(Index)("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero + TmpDT.Rows(Index)("CveTipoGastoAC") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero + TmpDT.Rows(Index)("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero + Index += 1 + Next End Sub -#End Region -#Region " ALMACEN " + Protected Sub CompruebaSaldoAC(sender As Object, e As EventArgs) + ConservaAC() -#End Region - -#Region " CONSIGNACIONES " - Protected Sub ChkConsignacion_CheckedChanged(sender As Object, e As EventArgs) - - If ChkConsignacion.Checked Then - 'LiConsignacion.Visible = True - GvInv.Columns(7).Visible = True - GvInv.Columns(8).Visible = True - CargaConsignaciones2() - - CargaGvInv() - - GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True - GvInv.HeaderRow.FCCheckBox("cbAll").Enabled = False - - BtnVinculaConsignacion.Visible = True - - BtnGuardar.Enabled = False - UpFacturar.Update() - Else - GvInv.Columns(7).Visible = False - GvInv.Columns(8).Visible = False - 'LiConsignacion.Visible = False - CveConsignacion = -1 - - GvInv.HeaderRow.FCCheckBox("cbAll").Checked = False - GvInv.HeaderRow.FCCheckBox("cbAll").Enabled = True - - BtnVinculaConsignacion.Visible = False - - CargaGvInv() - - BtnGuardar.Enabled = True - UpFacturar.Update() - End If - - cbAll_CheckedChanged(GvInv.HeaderRow.FCCheckBox("cbAll"), EventArgs.Empty) - UpConsignaciones.Update() - End Sub - Private Sub CargaConsignaciones() - If DdlProveedor.SelectedValue.ToEntero > 0 Then - 'Dim ObjInventarios As New ClsInventarios - - 'If ObjInventarios.GetConsignaciones2(-1, UsuarioActual.CveEmpresa) Then - ' DdlConsignacion.DataSource = ObjInventarios.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlProveedor.SelectedValue.ToEntero)) - 'Else - ' DdlConsignacion.DataSource = Nothing - 'End If - - 'ObjInventarios.Dispose() - - 'DdlConsignacion.DataBind() - 'DdlConsignacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - End Sub - Private Sub CargaConsignaciones2() - Dim ObjInventarios As New ClsInventarios - Dim TieneError = False - - CveConsignacion = -1 - - If ObjInventarios.GetConsignacionesDetalleProveedor(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - DtConsignaciones = ObjInventarios.DtResultados - Else - TieneError = True - End If - - If DtConsignaciones IsNot Nothing AndAlso DtConsignaciones.Rows.Count > 0 Then - 'CveConsignacion = DdlConsignacion.SelectedValue.ToEntero - CveConsignacion = 1 - 'CveAlmacenConsignacion = ObjInventarios.DtResultados.Rows(0)("CveAlmacen").ToString.ToEntero - End If - - If TieneError Then - Alert("Ocurrió un error al cargar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError) - DtConsignaciones = Nothing - End If - - ObjInventarios.Dispose() - - CargaGvInv() - End Sub - Protected Sub BtnVinculaConsignacion_Click(sender As Object, e As EventArgs) - Dim ObjInventarios As New ClsInventarios - Dim TieneError = False - - CveConsignacion = -1 - - If ObjInventarios.GetConsignacionesDetalleProveedor(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - DtConsignaciones = ObjInventarios.DtResultados - Else - TieneError = True - End If - - If DtConsignaciones.Rows.Count > 0 Then - 'CveConsignacion = DdlConsignacion.SelectedValue.ToEntero - CveConsignacion = 1 - CveAlmacenConsignacion = ObjInventarios.DtResultados.Rows(0)("CveAlmacen").ToString.ToEntero - End If - - If TieneError Then - Alert("Ocurrió un error al cargar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError) - DtConsignaciones = Nothing - End If - - ObjInventarios.Dispose() - - CargaGvInv() - 'If DtConsignaciones IsNot Nothing Then - ' GvConsignaciones.DataSource = DtConsignaciones - ' GvConsignaciones.DataBind() - 'End If - - 'UpConsignaciones.Update() - End Sub - Protected Sub GvConsignaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) 'Handles GvConsignaciones.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - e.Row.FCDropDownList("DdlVinculaConsignacion").DataSource = TmpDT - e.Row.FCDropDownList("DdlVinculaConsignacion").DataBind() - e.Row.FCDropDownList("DdlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) - - End If - End Sub - Protected Sub DdlVinculaConsignacion_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim Ddl As DropDownList = DirectCast(sender, DropDownList) - Dim gvr As GridViewRow = DirectCast(Ddl.BindingContainer, GridViewRow) - - If Ddl.SelectedValue = "-1" Then - - gvr.FCHiddenField("HdnPS").Value = "-1" - gvr.FCHiddenField("HdnCvePS").Value = "-1" - gvr.FCHiddenField("HdnClasificacion").Value = "-1" - gvr.FCHiddenField("HdnCveClasificacion").Value = "-1" - gvr.FCHiddenField("HdnCveAlmacen").Value = "-1" - - gvr.FCHiddenField("HdnNoConsignacion").Value = "-1" - gvr.FCHiddenField("HdnCveConsignacion").Value = "-1" - - 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) - TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = "-1" - - TmpDT.Rows(gvr.RowIndex)("HdnPS") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = "-1" - Exit Sub - End If - - Dim Row = DtConsignaciones.Rows(Ddl.SelectedValue.ToEntero - 1) - - 'VALIDAMOS CANTIDAD - Dim Cantidad = Row("Cantidad").ToString.ToDecimal - For Each gvr1 As GridViewRow In GvInv.Rows - If gvr1.FCHiddenField("HdnNoConsignacion").Value.ToString = Ddl.SelectedValue Then - Cantidad = Cantidad - gvr1.DataKey("Cantidad").ToString.ToDecimal - End If - Next - - If Cantidad - gvr.DataKey("Cantidad").ToString.ToDecimal < 0 Then - Ddl.SelectedValue = "-1" - - gvr.FCHiddenField("HdnPS").Value = "-1" - gvr.FCHiddenField("HdnCvePS").Value = "-1" - gvr.FCHiddenField("HdnClasificacion").Value = "-1" - gvr.FCHiddenField("HdnCveClasificacion").Value = "-1" - gvr.FCHiddenField("HdnCveAlmacen").Value = "-1" - - gvr.FCHiddenField("HdnNoConsignacion").Value = "-1" - gvr.FCHiddenField("HdnCveConsignacion").Value = "-1" - - 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) - TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = "-1" - - TmpDT.Rows(gvr.RowIndex)("HdnPS") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = "-1" - TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = "-1" - - Alert("El concepto que desea vincular excede la cantidad del inventario de consignación.", TipoMensaje.MsgAdvertencia) - Else - gvr.FCHiddenField("HdnPS").Value = Row("PS").ToString - gvr.FCHiddenField("HdnCvePS").Value = Row("CvePS").ToString - gvr.FCHiddenField("HdnClasificacion").Value = Row("Clasificacion").ToString - gvr.FCHiddenField("HdnCveClasificacion").Value = Row("CveClasificacion").ToString - gvr.FCHiddenField("HdnCveAlmacen").Value = Row("CveAlmacenSalida").ToString - - gvr.FCHiddenField("HdnNoConsignacion").Value = Ddl.SelectedValue.ToEntero.ToString - gvr.FCHiddenField("HdnCveConsignacion").Value = Row("CveConsignacion").ToString - - 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) - TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue.ToEntero - TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = Ddl.SelectedValue.ToEntero - TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = Row("CveConsignacion").ToString - - TmpDT.Rows(gvr.RowIndex)("HdnPS") = Row("PS").ToString - TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = Row("CvePS").ToString - TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = Row("Clasificacion").ToString - TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = Row("CveClasificacion").ToString - TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = Row("CveAlmacenSalida").ToString - End If - - - End Sub - Protected Sub ddlAlmacenConsignacionGeneral_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim DdlAlmacenConsignacionGeneral = CType(sender, DropDownList) - - For Each gvr As GridViewRow In GvInv.Rows - gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue = DdlAlmacenConsignacionGeneral.SelectedValue - - gvr.FCDropDownList("ddlVinculaConsignacion").DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue)) - gvr.FCDropDownList("ddlVinculaConsignacion").DataBind() - gvr.FCDropDownList("ddlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) - Next - - UpINV.Update() - End Sub - Protected Sub ddlAlmacenConsignacion_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim DdlAlmacenConsignacion = CType(sender, DropDownList) - Dim DdlVinculaConsignacion = CType(CType(sender, DropDownList).NamingContainer, GridViewRow).FCDropDownList("DdlVinculaConsignacion") - - ''CARGA CONSIGNACIONES - DdlVinculaConsignacion.DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", DdlAlmacenConsignacion.SelectedValue)) - DdlVinculaConsignacion.DataBind() - DdlVinculaConsignacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - - UpINV.Update() - End Sub - Protected Sub BtnVinculaConsignacion_Click1(sender As Object, e As EventArgs) - - 'VALIDACIONES - For Each gvr As GridViewRow In GvInv.Rows - If gvr.FCDropDownList("DdlVinculaConsignacion").SelectedValue = "-1" Then - Alert("Debe vincular todos los conceptos para realizar la vinculación de consignación.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Next - - 'CambiaPS - For Each gvr As GridViewRow In GvInv.Rows - TmpDT.Rows(gvr.RowIndex)("PS") = gvr.FCHiddenField("HdnPS").Value - TmpDT.Rows(gvr.RowIndex)("CvePS") = gvr.FCHiddenField("HdnCvePS").Value - TmpDT.Rows(gvr.RowIndex)("Clasificacion") = gvr.FCHiddenField("HdnClasificacion").Value - TmpDT.Rows(gvr.RowIndex)("CveClasificacion") = gvr.FCHiddenField("HdnCveClasificacion").Value - Next - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - 'Bloqueamos todo para respetar cambios realizados - DtInv = TmpDT - ChkConsignacion.Enabled = False - BtnVinculaConsignacion.Enabled = False - UpConsignaciones.Update() - - GvInv.Enabled = False - UpINV.Update() - GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True - cbAll_CheckedChanged(GvInv.HeaderRow.FCCheckBox("cbAll"), EventArgs.Empty) - - BtnGuardar.Enabled = True - UpFacturar.Update() - + CompruebaAgregar() End Sub -#End Region -#Region " ***** Devoluciones INV ***** " + Protected Sub CambiaACGeneral(sender As Object, e As EventArgs) + + If ChkACGeneral.Checked Then + + 'CAMBIA LOS COMBOS DE TODOS LOS DETALLES DEL GRID + For Each gvr As GridViewRow In GvPS.Rows + + 'SI VIENE DESDE OC EL PE NO SE MUEVE + If Not gvr.DataKey("CveOrdenCompraDetalle").ToEntero > 0 Then + gvr.FCDropDownList("DdlAC1").SelectedValue = DdlACGeneral1.SelectedValue + gvr.FCDropDownList("DdlAC2").SelectedValue = DdlACGeneral2.SelectedValue + gvr.FCDropDownList("DdlAC3").SelectedValue = DdlACGeneral3.SelectedValue + gvr.FCDropDownList("DdlAC4").SelectedValue = DdlACGeneral4.SelectedValue + gvr.FCDropDownList("DdlAC5").SelectedValue = DdlACGeneral5.SelectedValue + End If + Next + + ConservaAC() + CompruebaAgregar() + UpPS.Update() + + End If + + CalculaSaldoACGeneral() + UpPresupuestosAC.Update() + + End Sub + + Private Sub CalculaSaldoACGeneral() + Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa) + Dim DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", DdlACGeneral1.SelectedValue.ToString, DdlACGeneral2.SelectedValue.ToString, DdlACGeneral3.SelectedValue.ToString, DdlACGeneral4.SelectedValue.ToString, DdlACGeneral5.SelectedValue.ToString)) + If DtPresupuestosTemp.Rows.Count > 0 Then + Dim IdCuenta = If(HdnVCveOC.Value <> "-1", DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero, DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero) + + LbACGeneralSaldo.Text = ContPaq.GetSaldoCuenta(IdCuenta, 0, TxtFecha.Text.ToDate.Year).ToString.FormatoNumero(2) + Else + LbACGeneralSaldo.Text = "0.00" + End If + ContPaq.Dispose() + End Sub + + Private Sub CargaHidendsAC() + Dim DtPresupuestosTemp As DataTable + Dim Filtro As New StringBuilder + + For Each grid As GridViewRow In GvPS.Rows + Filtro.AppendFormat("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", grid.FCDropDownList("DdlAC1").SelectedValue.ToString, grid.FCDropDownList("DdlAC2").SelectedValue.ToString, grid.FCDropDownList("DdlAC3").SelectedValue.ToString, grid.FCDropDownList("DdlAC4").SelectedValue.ToString, grid.FCDropDownList("DdlAC5").SelectedValue.ToString) + DtPresupuestosTemp = DtPresupuestos.FiltraParametros(Filtro.ToString) + Filtro.Clear() + + If DtPresupuestosTemp.Rows.Count > 0 Then + TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaComprometido") = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaPorEjercer") = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaDevengado") = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaMatriz") = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString + Else + Alert("Ocurrió un error al vincular el Presupuesto de Egreso. Por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) + End If + Next + + End Sub + + Private Sub CompruebaAgregar() + Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa) + Dim disponible As Double + Dim ErrorPresupuesto = False + Dim Conceptos As New StringBuilder + + Dim Ddl1 As DropDownList + Dim Ddl2 As DropDownList + Dim Ddl3 As DropDownList + Dim Ddl4 As DropDownList + Dim Ddl5 As DropDownList + Dim Total As Double + + Dim DtPresupuestosTemp As DataTable + Dim Filtro As New StringBuilder + + For Each grid As GridViewRow In GvPS.Rows + Ddl1 = grid.FCDropDownList("DdlAC1") + Ddl2 = grid.FCDropDownList("DdlAC2") + Ddl3 = grid.FCDropDownList("DdlAC3") + Ddl4 = grid.FCDropDownList("DdlAC4") + Ddl5 = grid.FCDropDownList("DdlAC5") + Total = grid.Cells(8).ToString.ToDouble + + Filtro.AppendFormat("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", Ddl1.SelectedValue.ToString, Ddl2.SelectedValue.ToString, Ddl3.SelectedValue.ToString, Ddl4.SelectedValue.ToString, Ddl5.SelectedValue.ToString) + DtPresupuestosTemp = DtPresupuestos.FiltraParametros(Filtro.ToString) + Filtro.Clear() + + If DtPresupuestosTemp IsNot Nothing AndAlso DtPresupuestosTemp.Rows.Count > 0 Then + disponible = ContPaq.GetSaldoCuenta(If(OCVinculada, DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero, DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero), 0, TxtFecha.Text.ToDate.Year) + + If (disponible > 0 AndAlso disponible >= Total) Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + 'Alert("Si hay dinero: ") + + TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaComprometido") = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaPorEjercer") = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaDevengado") = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString + TmpDT.Rows(grid.RowIndex)("IdCuentaMatriz") = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString + + grid.Cells(7).BackColor = Drawing.Color.Green + Else + 'Alert("No hay presupuesto asignado", TipoMensaje.MsgAdvertencia) + Conceptos.AppendFormat("
#{0} - {1} - {2}", grid.RowIndex + 1, grid.DataKey("Clasificacion"), grid.DataKey("PS")) + grid.Cells(7).BackColor = Drawing.Color.Red + ErrorPresupuesto = True + End If + + TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString + + Else + TmpDT.Rows(grid.RowIndex)("CvePresupuestoEgreso") = "-1" + 'Alert("No hay presupuesto asignado", TipoMensaje.MsgAdvertencia) + Conceptos.AppendFormat("
#{0} - {1} - {2}", grid.RowIndex + 1, grid.DataKey("Clasificacion"), grid.DataKey("PS")) + grid.Cells(7).BackColor = Drawing.Color.Red + ErrorPresupuesto = True + End If + + Next + + If ErrorPresupuesto Then + Alert(String.Format("No hay presupuesto asignado para los siguientes conceptos: {0}", Conceptos), TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + Else + BtnGuardar.Enabled = True + End If + UpFacturar.Update() + ContPaq.Dispose() + End Sub + + Private Sub GuardaAC() + Dim dr As DataRow + For Each gvr As GridViewRow In GvPS.Rows + dr = TmpDT.Rows(gvr.RowIndex) + + 'DtDetalle.Rows(gvr.RowIndex)("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero + 'DtDetalle.Rows(gvr.RowIndex)("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero + 'DtDetalle.Rows(gvr.RowIndex)("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero + 'DtDetalle.Rows(gvr.RowIndex)("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero + 'DtDetalle.Rows(gvr.RowIndex)("CveTipoGasto") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero + + dr("CveProgramaOperativo") = gvr.FCDropDownList("DdlAC1").SelectedValue.ToEntero + dr("CveUnidadAdministrativa") = gvr.FCDropDownList("DdlAC2").SelectedValue.ToEntero + dr("CveFuenteFinanciamiento") = gvr.FCDropDownList("DdlAC3").SelectedValue.ToEntero + dr("CveTipoGastoAC") = gvr.FCDropDownList("DdlAC4").SelectedValue.ToEntero + dr("CveClasificacionOG") = gvr.FCDropDownList("DdlAC5").SelectedValue.ToEntero + 'dr("CvePresupuestoEgreso") = gvr.FCHiddenField("HdnCvePresupuestoEgreso").Value.ToString.ToEntero + Next + + TmpDT.AcceptChanges() + End Sub + + Protected Sub BtnCambiaFecha_Click(sender As Object, e As EventArgs) + CambiaEjercicioAC() + End Sub + + Private Sub CambiaEjercicioAC(Optional CargaTodo As Boolean = True) + Dim Ejercicio = If(IsDate(TxtFecha.Text), Year(TxtFecha.Text.ToDate), UsuarioActual.Empresa.EjercicioActual) + + If Ejercicio <> EjercicioAC Then + Dim AC As New ClsAC + If AC.GetPresupuestoEgresos(-1, True, Ejercicio, UsuarioActual.CveEmpresa, True) Then + DtPresupuestos = AC.DtResultados.Copy + CargaPresupuestosEgresos(CargaTodo) + + ConservaAC() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + 'CAMBIA LOS COMBOS DE TODOS LOS DETALLES DEL GRID + For Each gvr As GridViewRow In GvPS.Rows + gvr.FCDropDownList("DdlAC1").SelectedValue = DdlACGeneral1.SelectedValue + gvr.FCDropDownList("DdlAC2").SelectedValue = DdlACGeneral2.SelectedValue + gvr.FCDropDownList("DdlAC3").SelectedValue = DdlACGeneral3.SelectedValue + gvr.FCDropDownList("DdlAC4").SelectedValue = DdlACGeneral4.SelectedValue + gvr.FCDropDownList("DdlAC5").SelectedValue = DdlACGeneral5.SelectedValue + Next + + If CargaTodo Then CompruebaAgregar() + + UpPS.Update() + UpPresupuestosAC.Update() + Else + Alert("Ocurrio un error al cargar los Presupuestos. Por favor vuelva a cargar la página") + End If + AC.Dispose() + + EjercicioAC = Ejercicio + End If + + End Sub + +#End Region + +#Region "E V E N T O - B I T A C O R A" + Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).Width = Unit.Pixel(200) + e.Row.Cells(1).Width = Unit.Pixel(200) + e.Row.Cells(2).Width = Unit.Pixel(100) + e.Row.Cells(3).Width = Unit.Pixel(500) + End If + + If e.Row.DBCampo("Archivo").ToString <> "" Then + e.Row.FCLinkButton("LinkArchivo").Visible = True + e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) + ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione + End If + + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left + + End If + End Sub + + Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click + Dim ObjEventoBitacora As New ClsOIEventos + + Dim FileExtension As String = "-1" + Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos + Dim Filename As String = "" + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Filename = fileItem.filename + Next + + + + If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + If Filename <> "" Then + Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) + End If + + GvEB.DataSource = ObjEventoBitacora.DtResultados + TxtEventoDescripcion.Text = "" + Anexo.Text = "[]" + Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") + + End If + ObjEventoBitacora.Dispose() + GvEB.DataBind() + + UPEventoBitacora.Update() + CargaEventoBitacora() + UPAddEventoBitacora.Update() + End Sub + + 'Protected Sub CargarArchivo(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AFU.UploadedComplete + ' If AFU.HasFile Then + + + ' Dim UploadFolder As String = String.Format("{0}\Temp\", UsuarioActual.Empresa.Ruta) + ' UploadFolder.DirectoryExistsCreate() + ' Dim Extension As String = System.IO.Path.GetExtension(AFU.PostedFile.FileName) + + ' If File.Exists(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension)) Then File.Delete(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension)) + + ' AFU.SaveAs(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension) + ' Session("FileUpload") = UploadFolder & UsuarioActual.CveUsuario.ToString & Extension + ' Session("FileExtension") = Extension + ' Session("FileFolder") = UploadFolder + ' End If + 'End Sub + Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs) + Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument) + Dim Archivo As New System.IO.FileInfo(filePath) + + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath)) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(filePath) + HttpContext.Current.Response.Flush() + HttpContext.Current.Response.End() + + Archivo = Nothing + End Sub + + Private Sub CargaEventoBitacora() + + Dim ObjEventoBitacora As New ClsOIEventos() + If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") + Else + GvEB.DataSource = Nothing + End If + ObjEventoBitacora.Dispose() + GvEB.DataBind() + End Sub +#End Region + +#Region " C O N T A B I L I D A D " + Protected Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs) + 'Alert("Hola entre", TipoMensaje.MsgError) + 'Exit Sub + + Dim ObjConta As New ClsContabilidad + Dim Movimientos = ObjConta.GetMovimientosPoliza(IdPoliza, UsuarioActual.CveEmpresa) + + 'Verifica que solo exista 1 compra asociada + If Movimientos = 1 Then + EliminaPoliza() + Else + RegistraScript("ConfirmEliminarPolizaMultiple();") + End If + + ObjConta.Dispose() + End Sub + Protected Sub LBContabilizarAC_Click(sender As Object, e As EventArgs) + Dim ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + Dim ObjCompras As New ClsCompras + Dim ObjProveedores As New ClsCompProveedores(ObjCompras.IniciaTransacSQL()) + Dim ObjAF As New ClsAF(ObjCompras.IniciaTransacSQL()) + Dim ErrorAC = False + Dim IDPolizaComprometido = If(TxtOC.Text.Length > 0, 1, 0) + + ''EMPIEZA: SI USA AC + If UsuarioActual.Empresa.UsaAC Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + + + 'ELIMINA TODOS LOS MOVIMIENTOS DE LA POLIZA + If IdPoliza > 0 Then + ObjContaAC.RemoveAllMovimientos(IdPoliza) + Else + Dim TotalPorDevengar = Math.Round(TxtTotal.Text.ToDouble, 2) + IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) + End If + + 'INSERTA LOS NUEVOS MOVIMIENTOS DE LA POLIZA + If IdPoliza > 0 Then + Dim CuentaAbono As Integer + Dim Importe As Decimal = 0 + Dim TotalDetalle As Decimal = 0 + + 'CUENTA PROVEEDOR + If CtaProveedor <= 0 Then + If ObjContaAC.GetCuentas(-1, "021120000000000000", -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021120000000000000").ToString + ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02112{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono) + ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor) + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + Dim ConceptoRenglon As String = "" + If Not ErrorAC Then + + Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal + + Dim ipresup As Integer = 0 + + 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS + Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)() + Group gvr By Grp = New With { + Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero, + Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1) + } Into Group + Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, + TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal) + Dim Fecha As Date = TxtFecha.Text.ToDate + + 'PresupuestoEgresos + Dim DtPresupuestosTemp As DataTable + Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer + + 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double + tTotalIVA = TxtIVA.Text.ToDecimal + tRetIVA = TxtRetIVA.Text.ToDecimal + tRetISR = TxtRetISR.Text.ToDecimal + + 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR + + tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA + tDiferenciaIVA = tTotalIVA + tIVA = 0 + ipresup = 0 + + 'INVENTARIOS EN AC + Dim CuentaMatrizAlmacen As Integer + Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) + + Dim CtaAlmacen As Integer + If ContadorInventario > 0 Then + Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero)) + If drr IsNot Nothing Then + CtaAlmacen = drr("IdCtaContable").ToString.ToEntero + End If + End If + Dim DescuentoConIVA As Double + Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA) + Dim tAjusteTotal As Decimal = 0 + + For Each grp In Presup + Importe = grp.TotalImporte + TotalDetalle += Importe + ipresup += 1 + If Importe > 0 Then + 'saco la proporcion de iva que le corresponde + tIVA = Math.Round(Importe * tPorIVA, 2) + tDiferenciaIVA -= tIVA + 'identifico si es el ultimo registro, para ver si es necesario un ajuste + If ipresup = Presup.Count Then + If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then + tIVA += tDiferenciaIVA + End If + End If + + 'le sumo el iva al concepto + Importe += tIVA + 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF + If TxtDescuento.Text.ToDouble > 0 Then + Importe = grp.TotalImporte * (1 + tPorIVA) + End If + + tAjusteTotal += Importe + + 'valido que la sumas de lo detalles no exceda al totalgeneral + If Math.Round(tAjusteTotal, 2) > tTotalGral Then + 'le resto la diferencia + Importe -= (tAjusteTotal - tTotalGral) + End If + + 'Presupuesto Egresos + DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso)) + If DtPresupuestosTemp.Rows.Count <> 1 Then + ErrorAC = True + Exit For + End If + IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero + IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero + IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero + IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero + + 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA + If IDPolizaComprometido = 0 Then + ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + End If + + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + 'DEVENGADO + If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + + + If ContadorInventario > 0 Then + Dim tImporte, ttIVA As Double + + For Each gvr As GridViewRow In GvPS.Rows + 'registra los movimientos del presupuesto asignado, para que no se duplique si hay varios presupeusto dentro de la compra + If gvr.DataKey("CvePresupuestoEgreso").ToEntero = grp.CvePresupuestoEgreso Then + 'saco la proporcion de iva que le corresponde + tImporte = gvr.FCLiteral("LtlTotal").Text.ToDouble + ttIVA = Math.Round(tImporte * tTotalIVA / tTotalGral, 2) + tImporte += ttIVA + End If + + Next + + CuentaMatrizAlmacen = CtaAlmacen + + ElseIf grp.CveActivoFijo > 0 Then + + Dim CtaAF = -1 + Dim AF = "" + Dim CuentaInicial = -1 + + If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then + CtaAF = ObjAF.Cuenta + AF = ObjAF.Descripcion + CuentaInicial = ObjAF.CuentaInicial + Else + ErrorAC = True + Exit For + End If + + If Not CuentaInicial > 0 Then + CuentaInicial = 1241 + End If + + 'CUENTA AF + If CtaAF <= 0 Then + If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then + Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("") + If drCuenta IsNot Nothing Then + + CuentaAbono = drCuenta("Id").ToString.ToEntero + Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString + CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono) + + ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario) + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + CuentaMatrizAlmacen = CtaAF + Else + CuentaMatrizAlmacen = IdCuentaMatriz + End If + + + ''AFECTAR MATRIZ EGRESOS + If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + + ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION) + If TxtDescuento.Text.ToDouble > 0 AndAlso CtaProveedorAnticipos > 0 Then + DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16 + + 'Valida que el descuento con iva cuadre en los totales + If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then + DescuentoConIVA = Importe - TxtTotal.Text.ToDouble + ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then + ErrorAC = True + Exit For + End If + + 'actualizo el idcuenta del presupuesto + If ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then + 'agrego a la cuenta contable anticipos + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + Exit For + End If + Else + ErrorAC = True + Exit For + End If + Else + 'actualizo el idcuenta del + + End If + + Else + ErrorAC = True + Exit For + End If + ''TERMINA AFECTAR MATRIZ EGRESOS + + Else + ErrorAC = True + Exit For + End If + + Next + + If Not ErrorAC Then + 'registro un solo movimiento a proveedores + Importe = TxtTotal.Text.ToDecimal + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + End If + End If + + If tRetISR > 0 Then + ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text) + If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then + ErrorAC = True + End If + End If + + End If + + Else + ErrorAC = True + End If + + 'CUADRA LA POLIZA + ObjContaAC.AjustaPoliza(IdPoliza) + + End If + ''TERMINA: SI USA AC + + If Not ErrorAC Then + If Not ObjCompras.UpdateCompraPoliza(IdPoliza, CveCompra) Then + ErrorAC = True + End If + End If + + + If ErrorAC Then + + + + Alert("Ocurrió un error al contabilizar la compra. Comuniquese con soporte.", TipoMensaje.MsgError) + ObjContaAC.RollBack() + ObjCompras.RollBack() + Else + ObjContaAC.Commit() + ObjCompras.Commit() + Alert("La Compra se contabilizó correctamente.", TipoMensaje.MsgInformacion) + + HplCompraContabilizada.Text = "Si" + HplCompraContabilizada.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", IdPoliza) + LblCompraEstatus.ForeColor = Drawing.Color.Navy + trContabilizada.Visible = True + UpEstatus.Update() + End If + ObjContaAC.Dispose() + + End Sub + + Protected Sub BtnEliminarPoliza_Click(sender As Object, e As EventArgs) + EliminaPoliza() + End Sub + + Private Sub EliminaPoliza() + Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + + Dim ErrorCompra = False + + 'Elimina la poliza + If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then + If Not ObjAC.RemovePoliza(IdPoliza) Then + ErrorCompra = True + End If + End If + + 'Desasocia la poliza + If Not ErrorCompra Then + If Not ObjConta.DesasociarPoliza(IdPoliza, UsuarioActual.CveEmpresa) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion) + ObjAC.Commit() + ObjConta.Commit() + + Else + Alert("Ocurrió un error al desvincular y/o eliminar la poliza. Por favor intente de nuevo ", TipoMensaje.MsgError) + ObjAC.RollBack() + ObjConta.RollBack() + End If + + ObjAC.Dispose() + ObjConta.Dispose() + + If Not ErrorCompra Then + CargaCompra() + End If + End Sub + +#End Region + +#Region " REEMBOLSOS NO USA AC " + Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged + ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue + End Sub + Protected Sub DdlCajaChica2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCajaChicaReembolso.SelectedIndexChanged + Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaCajaChicaReembolso.SelectedValue) + + If dr IsNot Nothing Then + CveMoneda = dr("CveMoneda").ToString.ToEntero + IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero + CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + End If + ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue + End Sub +#End Region + +#Region " ALMACEN " + +#End Region + +#Region " CONSIGNACIONES " + Protected Sub ChkConsignacion_CheckedChanged(sender As Object, e As EventArgs) + + If ChkConsignacion.Checked Then + 'LiConsignacion.Visible = True + GvInv.Columns(7).Visible = True + GvInv.Columns(8).Visible = True + CargaConsignaciones2() + + CargaGvInv() + + GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True + GvInv.HeaderRow.FCCheckBox("cbAll").Enabled = False + + BtnVinculaConsignacion.Visible = True + + BtnGuardar.Enabled = False + UpFacturar.Update() + Else + GvInv.Columns(7).Visible = False + GvInv.Columns(8).Visible = False + 'LiConsignacion.Visible = False + CveConsignacion = -1 + + GvInv.HeaderRow.FCCheckBox("cbAll").Checked = False + GvInv.HeaderRow.FCCheckBox("cbAll").Enabled = True + + BtnVinculaConsignacion.Visible = False + + CargaGvInv() + + BtnGuardar.Enabled = True + UpFacturar.Update() + End If + + cbAll_CheckedChanged(GvInv.HeaderRow.FCCheckBox("cbAll"), EventArgs.Empty) + UpConsignaciones.Update() + End Sub + Private Sub CargaConsignaciones() + If DdlProveedor.SelectedValue.ToEntero > 0 Then + 'Dim ObjInventarios As New ClsInventarios + + 'If ObjInventarios.GetConsignaciones2(-1, UsuarioActual.CveEmpresa) Then + ' DdlConsignacion.DataSource = ObjInventarios.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlProveedor.SelectedValue.ToEntero)) + 'Else + ' DdlConsignacion.DataSource = Nothing + 'End If + + 'ObjInventarios.Dispose() + + 'DdlConsignacion.DataBind() + 'DdlConsignacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + End Sub + Private Sub CargaConsignaciones2() + Dim ObjInventarios As New ClsInventarios + Dim TieneError = False + + CveConsignacion = -1 + + If ObjInventarios.GetConsignacionesDetalleProveedor(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + DtConsignaciones = ObjInventarios.DtResultados + Else + TieneError = True + End If + + If DtConsignaciones IsNot Nothing AndAlso DtConsignaciones.Rows.Count > 0 Then + 'CveConsignacion = DdlConsignacion.SelectedValue.ToEntero + CveConsignacion = 1 + 'CveAlmacenConsignacion = ObjInventarios.DtResultados.Rows(0)("CveAlmacen").ToString.ToEntero + End If + + If TieneError Then + Alert("Ocurrió un error al cargar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + DtConsignaciones = Nothing + End If + + ObjInventarios.Dispose() + + CargaGvInv() + End Sub + Protected Sub BtnVinculaConsignacion_Click(sender As Object, e As EventArgs) + Dim ObjInventarios As New ClsInventarios + Dim TieneError = False + + CveConsignacion = -1 + + If ObjInventarios.GetConsignacionesDetalleProveedor(DdlProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + DtConsignaciones = ObjInventarios.DtResultados + Else + TieneError = True + End If + + If DtConsignaciones.Rows.Count > 0 Then + 'CveConsignacion = DdlConsignacion.SelectedValue.ToEntero + CveConsignacion = 1 + CveAlmacenConsignacion = ObjInventarios.DtResultados.Rows(0)("CveAlmacen").ToString.ToEntero + End If + + If TieneError Then + Alert("Ocurrió un error al cargar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + DtConsignaciones = Nothing + End If + + ObjInventarios.Dispose() + + CargaGvInv() + 'If DtConsignaciones IsNot Nothing Then + ' GvConsignaciones.DataSource = DtConsignaciones + ' GvConsignaciones.DataBind() + 'End If + + 'UpConsignaciones.Update() + End Sub + Protected Sub GvConsignaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) 'Handles GvConsignaciones.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.FCDropDownList("DdlVinculaConsignacion").DataSource = TmpDT + e.Row.FCDropDownList("DdlVinculaConsignacion").DataBind() + e.Row.FCDropDownList("DdlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) + + End If + End Sub + Protected Sub DdlVinculaConsignacion_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim Ddl As DropDownList = DirectCast(sender, DropDownList) + Dim gvr As GridViewRow = DirectCast(Ddl.BindingContainer, GridViewRow) + + If Ddl.SelectedValue = "-1" Then + + gvr.FCHiddenField("HdnPS").Value = "-1" + gvr.FCHiddenField("HdnCvePS").Value = "-1" + gvr.FCHiddenField("HdnClasificacion").Value = "-1" + gvr.FCHiddenField("HdnCveClasificacion").Value = "-1" + gvr.FCHiddenField("HdnCveAlmacen").Value = "-1" + + gvr.FCHiddenField("HdnNoConsignacion").Value = "-1" + gvr.FCHiddenField("HdnCveConsignacion").Value = "-1" + + 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) + TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = "-1" + + TmpDT.Rows(gvr.RowIndex)("HdnPS") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = "-1" + Exit Sub + End If + + Dim Row = DtConsignaciones.Rows(Ddl.SelectedValue.ToEntero - 1) + + 'VALIDAMOS CANTIDAD + Dim Cantidad = Row("Cantidad").ToString.ToDecimal + For Each gvr1 As GridViewRow In GvInv.Rows + If gvr1.FCHiddenField("HdnNoConsignacion").Value.ToString = Ddl.SelectedValue Then + Cantidad = Cantidad - gvr1.DataKey("Cantidad").ToString.ToDecimal + End If + Next + + If Cantidad - gvr.DataKey("Cantidad").ToString.ToDecimal < 0 Then + Ddl.SelectedValue = "-1" + + gvr.FCHiddenField("HdnPS").Value = "-1" + gvr.FCHiddenField("HdnCvePS").Value = "-1" + gvr.FCHiddenField("HdnClasificacion").Value = "-1" + gvr.FCHiddenField("HdnCveClasificacion").Value = "-1" + gvr.FCHiddenField("HdnCveAlmacen").Value = "-1" + + gvr.FCHiddenField("HdnNoConsignacion").Value = "-1" + gvr.FCHiddenField("HdnCveConsignacion").Value = "-1" + + 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) + TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = "-1" + + TmpDT.Rows(gvr.RowIndex)("HdnPS") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = "-1" + TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = "-1" + + Alert("El concepto que desea vincular excede la cantidad del inventario de consignación.", TipoMensaje.MsgAdvertencia) + Else + gvr.FCHiddenField("HdnPS").Value = Row("PS").ToString + gvr.FCHiddenField("HdnCvePS").Value = Row("CvePS").ToString + gvr.FCHiddenField("HdnClasificacion").Value = Row("Clasificacion").ToString + gvr.FCHiddenField("HdnCveClasificacion").Value = Row("CveClasificacion").ToString + gvr.FCHiddenField("HdnCveAlmacen").Value = Row("CveAlmacenSalida").ToString + + gvr.FCHiddenField("HdnNoConsignacion").Value = Ddl.SelectedValue.ToEntero.ToString + gvr.FCHiddenField("HdnCveConsignacion").Value = Row("CveConsignacion").ToString + + 'GUARDA VALORES POR UNA RECARGA (DIVISION DE CONCEPTO) + TmpDT.Rows(gvr.RowIndex)("CveAlmacenConsignacion") = gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue.ToEntero + TmpDT.Rows(gvr.RowIndex)("NoConsignacion") = Ddl.SelectedValue.ToEntero + TmpDT.Rows(gvr.RowIndex)("CveConsignacion") = Row("CveConsignacion").ToString + + TmpDT.Rows(gvr.RowIndex)("HdnPS") = Row("PS").ToString + TmpDT.Rows(gvr.RowIndex)("HdnCvePS") = Row("CvePS").ToString + TmpDT.Rows(gvr.RowIndex)("HdnClasificacion") = Row("Clasificacion").ToString + TmpDT.Rows(gvr.RowIndex)("HdnCveClasificacion") = Row("CveClasificacion").ToString + TmpDT.Rows(gvr.RowIndex)("HdnCveAlmacen") = Row("CveAlmacenSalida").ToString + End If + + + End Sub + Protected Sub ddlAlmacenConsignacionGeneral_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim DdlAlmacenConsignacionGeneral = CType(sender, DropDownList) + + For Each gvr As GridViewRow In GvInv.Rows + gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue = DdlAlmacenConsignacionGeneral.SelectedValue + + gvr.FCDropDownList("ddlVinculaConsignacion").DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", gvr.FCDropDownList("ddlAlmacenConsignacion").SelectedValue)) + gvr.FCDropDownList("ddlVinculaConsignacion").DataBind() + gvr.FCDropDownList("ddlVinculaConsignacion").Items.Insert(0, New ListItem("Seleccione", "-1")) + Next + + UpINV.Update() + End Sub + Protected Sub ddlAlmacenConsignacion_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim DdlAlmacenConsignacion = CType(sender, DropDownList) + Dim DdlVinculaConsignacion = CType(CType(sender, DropDownList).NamingContainer, GridViewRow).FCDropDownList("DdlVinculaConsignacion") + + ''CARGA CONSIGNACIONES + DdlVinculaConsignacion.DataSource = DtConsignaciones.FiltraParametros(String.Format("CveAlmacenSalida = {0} OR {0} = '-1'", DdlAlmacenConsignacion.SelectedValue)) + DdlVinculaConsignacion.DataBind() + DdlVinculaConsignacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + + UpINV.Update() + End Sub + Protected Sub BtnVinculaConsignacion_Click1(sender As Object, e As EventArgs) + + 'VALIDACIONES + For Each gvr As GridViewRow In GvInv.Rows + If gvr.FCDropDownList("DdlVinculaConsignacion").SelectedValue = "-1" Then + Alert("Debe vincular todos los conceptos para realizar la vinculación de consignación.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + + 'CambiaPS + For Each gvr As GridViewRow In GvInv.Rows + TmpDT.Rows(gvr.RowIndex)("PS") = gvr.FCHiddenField("HdnPS").Value + TmpDT.Rows(gvr.RowIndex)("CvePS") = gvr.FCHiddenField("HdnCvePS").Value + TmpDT.Rows(gvr.RowIndex)("Clasificacion") = gvr.FCHiddenField("HdnClasificacion").Value + TmpDT.Rows(gvr.RowIndex)("CveClasificacion") = gvr.FCHiddenField("HdnCveClasificacion").Value + Next + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + 'Bloqueamos todo para respetar cambios realizados + DtInv = TmpDT + ChkConsignacion.Enabled = False + BtnVinculaConsignacion.Enabled = False + UpConsignaciones.Update() + + GvInv.Enabled = False + UpINV.Update() + GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True + cbAll_CheckedChanged(GvInv.HeaderRow.FCCheckBox("cbAll"), EventArgs.Empty) + + BtnGuardar.Enabled = True + UpFacturar.Update() + + End Sub +#End Region + +#Region " ***** Devoluciones INV ***** " '*se envia true si hubo un error*' - Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Double, Fecha As Date) As Boolean - Dim ErrorMovInv As Boolean = False - Dim CveAlmacen As Integer - Dim subtotaldevolucion As Double = 0 - Dim realizadevolucion As Boolean = False - 'Calculo los subtotales para comparar con la NC - Dim cantidad As Double = 0.0 - For Each Dr As GridViewRow In GVDevolucion.Rows - CveAlmacen = Dr.DataKey("CveAlmacen").ToString.ToEntero - cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble - If cantidad > 0 Then - realizadevolucion = True - subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad - End If - Next - 'si no esta vinculado a nc simplemente me lo brinco - If realizadevolucion Then - - 'si el subtotal es iwal a la nc lo guardo si no marco error - If subtotal > subtotaldevolucion - 1 AndAlso subtotal < subtotaldevolucion + 1 Then - - Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G") - If CveMovimientoEntrada <= 0 Then - ErrorMovInv = True - Else - For Each Dr As GridViewRow In GVDevolucion.Rows - If Dr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDouble, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then - ErrorMovInv = True - Exit For - End If - End If - Next - End If - Else - ErrorMovInv = True - Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia) - End If - End If - Return ErrorMovInv - End Function - - - Private Sub cargaddldevoluciones(CveProveedor As Integer, SubTotal As Double) - Dim objcompras As New ClsCompras() - If objcompras.GetCompraParaDevolucion(CveProveedor, UsuarioActual.CveEmpresa, SubTotal) Then - DDLDevolucion.Items.Clear() - DDLDevolucion.DataSource = objcompras.DtResultados - DDLDevolucion.DataBind() - DDLDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - objcompras.Dispose() - UPDevolucion.Update() - - End Sub - - - Protected Sub DDLDevolucion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLDevolucion.SelectedIndexChanged - Dim objcompras As New ClsCompras() - If objcompras.GetCompraDetallealmacen(DDLDevolucion.SelectedValue.ToEntero) Then - GVDevolucion.DataSource = objcompras.DtResultados - GVDevolucion.DataBind() - End If - objcompras.Dispose() - UPDevolucion.Update() - End Sub - 'Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click - ' cargaddldevoluciones(CveProveedor, TextBox1.Text.ToDouble) - 'End Sub - 'Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click - ' Dim ObjInventario As New ClsInventarios() - ' Dim cvecompra As Integer = 5221 - ' Dim subtotal As Double = TextBox1.Text.ToDouble - ' guardardevolucion(ObjInventario, cvecompra, subtotal, Now.ToDate) - 'End Sub - Protected Sub BtnVinculaDevolucion_Click(sender As Object, e As EventArgs) + Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Double, Fecha As Date) As Boolean + Dim ErrorMovInv As Boolean = False + Dim CveAlmacen As Integer + Dim subtotaldevolucion As Double = 0 + Dim realizadevolucion As Boolean = False + 'Calculo los subtotales para comparar con la NC + Dim cantidad As Double = 0.0 + For Each Dr As GridViewRow In GVDevolucion.Rows + CveAlmacen = Dr.DataKey("CveAlmacen").ToString.ToEntero + cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble + If cantidad > 0 Then + realizadevolucion = True + subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad + End If + Next + 'si no esta vinculado a nc simplemente me lo brinco + If realizadevolucion Then + + 'si el subtotal es iwal a la nc lo guardo si no marco error + If subtotal > subtotaldevolucion - 1 AndAlso subtotal < subtotaldevolucion + 1 Then + + Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 13, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, Modulo:="Comp/G") + If CveMovimientoEntrada <= 0 Then + ErrorMovInv = True + Else + For Each Dr As GridViewRow In GVDevolucion.Rows + If Dr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDouble, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then + ErrorMovInv = True + Exit For + End If + End If + Next + End If + Else + ErrorMovInv = True + Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia) + End If + End If + Return ErrorMovInv + End Function + + + Private Sub cargaddldevoluciones(CveProveedor As Integer, SubTotal As Double) + Dim objcompras As New ClsCompras() + If objcompras.GetCompraParaDevolucion(CveProveedor, UsuarioActual.CveEmpresa, SubTotal) Then + DDLDevolucion.Items.Clear() + DDLDevolucion.DataSource = objcompras.DtResultados + DDLDevolucion.DataBind() + DDLDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + objcompras.Dispose() + UPDevolucion.Update() + + End Sub + + + Protected Sub DDLDevolucion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLDevolucion.SelectedIndexChanged + Dim objcompras As New ClsCompras() + If objcompras.GetCompraDetallealmacen(DDLDevolucion.SelectedValue.ToEntero) Then + GVDevolucion.DataSource = objcompras.DtResultados + GVDevolucion.DataBind() + End If + objcompras.Dispose() + UPDevolucion.Update() + End Sub + 'Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + ' cargaddldevoluciones(CveProveedor, TextBox1.Text.ToDouble) + 'End Sub + 'Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click + ' Dim ObjInventario As New ClsInventarios() + ' Dim cvecompra As Integer = 5221 + ' Dim subtotal As Double = TextBox1.Text.ToDouble + ' guardardevolucion(ObjInventario, cvecompra, subtotal, Now.ToDate) + 'End Sub + Protected Sub BtnVinculaDevolucion_Click(sender As Object, e As EventArgs) Try Dim subtotaldevolucion As Double = 0 Dim realizadevolucion As Boolean = False @@ -13729,13 +13743,13 @@ Partial Class Compras_Compras End If Catch ex As Exception OnError("Ocurrió un error al realizar la vinculación", ex) - End Try - - - End Sub - - Private Sub VinculaDevolucion() - 'LIMPIAR PARTIDAS DE LA COMPRA PARA AGREGAR NUEVAS + End Try + + + End Sub + + Private Sub VinculaDevolucion() + 'LIMPIAR PARTIDAS DE LA COMPRA PARA AGREGAR NUEVAS TmpDT.Clear() Dim SubTotalCompra As Decimal = TxtSubTotal.Text.ToDecimal() @@ -13747,1246 +13761,1246 @@ Partial Class Compras_Compras 'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra - Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2) - - 'Iteramos el GridView de la OC - For Each gvr As GridViewRow In GVDevolucion.Rows + Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2) + + 'Iteramos el GridView de la OC + For Each gvr As GridViewRow In GVDevolucion.Rows If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) - Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal - Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero - Dim UM As String = gvr.DataKey("UM").ToString - Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero - Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString - Dim PS As String = gvr.DataKey("PS").ToString - Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero - Dim CveSubProyectoContrato As String = "-1" - Dim CveProyecto As String = "-1" - Dim SubProyecto As String = "Seleccione" - Dim Proyecto As String = "Seleccione" - Dim Obs As String = "" - Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal - Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal - Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2) - Dim Descuento As Decimal = 0 - - AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False) - - End If - Next - - AddPS2() - - BtnGuardar.Enabled = True - If Not CierrePeriodo Then - BtnGuardar.Visible = True - End If - AlmacenCambiaPS.Visible = False - UpFacturar.Update() - - TabGenerales.Enabled = True - TAB.ActiveTabIndex = 0 - UpTabs.Update() - - ImgClasificacion.Visible = False - LbAgregar.Visible = False - UpPSS.Update() - - CargaGvInv() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - CargaGVsAF() - - CargaTipoCentroCostoOC() - GvOC1.DataSource = DTOCTemp - - Dim DTCVEOCS As DataTable = DTOCTemp.FiltraParametros("", "", {"CveOrdenCompra"}) - If DTCVEOCS IsNot Nothing AndAlso DTCVEOCS.Rows.Count > 1 Then - GvOC1.Columns(0).Visible = True - Else - GvOC1.Columns(0).Visible = False - End If - - - - - GvOC1.DataBind() - - ' TmpDT = OrdenarTablas("CvePS", DTOCTemp, TmpDT) - GvOC2.DataSource = TmpDT - GvOC2.DataBind() - - - UpGvOC1.Update() - NCDevolucion = True - - ''Bloquea cambio de proyecto - 'DdlProyecto.Enabled = False - 'DdlSubProyecto.Enabled = False - 'UPPProyecto.Update() - - 'Bloquea cambio de OC ya que se concluyo alguna vinculacion - TxtOC.Enabled = False - ImgBtnBuscarOC.Visible = False - UpParametros.Update() - UpPSS.Update() - End Sub -#End Region + Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal + Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero + Dim UM As String = gvr.DataKey("UM").ToString + Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString + Dim PS As String = gvr.DataKey("PS").ToString + Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero + Dim CveSubProyectoContrato As String = "-1" + Dim CveProyecto As String = "-1" + Dim SubProyecto As String = "Seleccione" + Dim Proyecto As String = "Seleccione" + Dim Obs As String = "" + Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal + Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal + Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2) + Dim Descuento As Decimal = 0 -#Region " REFACTURACION " - Private Sub ValidaRefacturacion() - If Not CveCompra > 0 AndAlso DdlTipoComprobante.SelectedValue = "Fac" And UsuarioActual.Empresa.CvePlataforma <> 2 Then - VerRefacturacion.Visible = True - End If - End Sub - Protected Sub BtnRefacturacionVer_Click(sender As Object, e As EventArgs) Handles BtnRefacturacionVer.Click - Dim Opcion As Integer = 1 - - If UsuarioActual.CveEmpresa.Contiene(119, 72) Then Opcion = 2 - - Dim ObjCompras As New ClsCompras - - DdlRefacturacionFacturas.Items.Clear() - If ObjCompras.GetRefacturacion(CveProveedor, TxtSubTotal.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtTotal.Text.ToDecimal, Opcion, UsuarioActual.CveEmpresa) Then - DtRefacturacion = ObjCompras.DtResultados - DdlRefacturacionFacturas.DataSource = DtRefacturacion - Else - Alert("Ocurrió un error al obtener las facturas para refacturación. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - ObjCompras.Dispose() - DivRefacturacion.Visible = True - - DdlRefacturacionFacturas.DataBind() - DdlRefacturacionFacturas.SelectedValueExist(CveCompraRefacturacion) - DdlRefacturacionFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) - RegistraScript(String.Format("$('#{0}').modal('show')", DivRefacturacion.ClientID)) - UpRefacturacion.Update() - - End Sub - Protected Sub BtnRefacturacionAplicaFactura_Click(sender As Object, e As EventArgs) Handles BtnRefacturacionAplicaFactura.Click - TxtDescripcion.Text = String.Format("Refacturacion: {0}", DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("Descripcion")) - TxtFechaPago.Text = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("FechaVencimiento").ToString.ToDate.ToShortDateString - - For Each Dr As DataRow In TmpDT.Rows - Dr("CveSubProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveSubProyecto").ToString.ToEntero - Dr("SubProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("SubProyecto").ToString - Dr("CveProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveProyecto").ToString.ToEntero - Dr("Proyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("Proyecto").ToString - Next - - TrFacturaRefacturar.Visible = True - LtFacturaRefacturar.Text = DdlRefacturacionFacturas.SelectedItem.Text - - CveCompraRefacturacion = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveCompra").ToString.ToEntero - - GvPS.DataSource = TmpDT - GvPS.DataBind() - - 'LIMPIA ALMACEN - For Each gvr As GridViewRow In GvInv.Rows - gvr.FCCheckBox("cbInv").Checked = False - Next - TabAlmacen.Enabled = False - - UpRefacturacion.Update() - UpParametros.Update() - UpPS.Update() - UPCondicionesPago.Update() - UpTabs.Update() - RegistraScript(String.Format("$('#{0}').modal('hide')", DivRefacturacion.ClientID)) - End Sub - - Private Function GuardaRefacturacion(ByRef ObjCompra As ClsCompras, ByRef ObjEventos As ClsOIEventos, CvePrePoliza As Integer) As Boolean - Dim dr As DataRow = Nothing - Dim ErrorBitacora = False - Dim IdPolizaAnterior = -1 - Dim TotalRefact As Decimal = 0 - - 'SI NO TIENE POLIZA NI PAGOS NO HACE NADA - 'If ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - ' If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count = 1 Then - ' Dim drc As DataRow = ObjCompra.DtResultados.Rows(0) - ' TotalRefact = drc("Total").ToString.ToDecimal - ' If drc("IdPoliza").ToString.ToEntero <= 0 AndAlso drc("Saldo").ToString.ToDecimal = drc("Total").ToString.ToDecimal AndAlso drc("CveMovimiento").ToString.ToEntero <= 0 Then - ' Alert("La factura a refacturar no esta contabilizada ni tiene pagos ni movimientos de almacen. No se puede refacturar, debera eliminar la factura anterior y agregar esta factura de forma normal.", TipoMensaje.MsgAdvertencia) - ' Return True - ' End If - ' End If - 'End If - - 'GUARDA ADJUNTOS Y LIGA EN BITACORA (RELACION DE FACTURA NUEVA Y VIEJA) - ErrorBitacora = GuardaRefacturacionBitacora(ObjCompra, ObjEventos) - - If ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - dr = ObjCompra.DtResultados.Rows(0) - IdPolizaAnterior = dr("IdPoliza").ToString.ToEntero - End If - End If - - Dim Tipo As Integer = 1 - If ChkRefacNC.Checked Then Tipo = 2 - - 'CONTABILIZA REFACTURACION - If Not ObjCompra.Refacturacion(CveCompraRefacturacion, CveCompra, UsuarioActual.CveEmpresa, Tipo) Then - ErrorBitacora = True - End If - - - - 'Return True - Return ErrorBitacora - End Function - - Private Function GuardaRefacturacionBitacora(ObjCompra As ClsCompras, ObjEventos As ClsOIEventos) As Boolean - Dim dr As DataRow = Nothing - Dim ErrorBitacora = False - Dim Archivo = "" - Dim Folio = "" - Dim Extension = "" - Dim Ruta = "" - - 'CARGA COMPRA REFACTURADA - If CveCompra > 0 AndAlso ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - dr = ObjCompra.DtResultados.Rows(0) - - 'ADJUNTAMOS ARCHIVO XML - If Not ErrorBitacora Then - Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("XML")) - If File.Exists(Archivo) Then - Extension = Path.GetExtension(Archivo) - If Extension <> "" Then - If ObjEventos.AddEventoBitacora("XML de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - - 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA - Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) - Ruta.DirectoryExistsCreate() - - 'COPIAMOS EL ARCHIVO A OI - System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) - Else - ErrorBitacora = True - End If - End If - End If - End If - - - 'ADJUNTAMOS ARCHIVO PDF - If Not ErrorBitacora Then - Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("PDF")) - If File.Exists(Archivo) Then - Extension = Path.GetExtension(Archivo) - If Extension <> "" Then - If ObjEventos.AddEventoBitacora("PDF de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - - 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA - Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) - Ruta.DirectoryExistsCreate() - - 'COPIAMOS EL ARCHIVO A OI - System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) - - Else - ErrorBitacora = True - End If - End If - End If - End If - - 'LIGA AL FOLIO/COMPRA DE REFACTURACION - If Not ErrorBitacora Then - If Not ObjEventos.AddEventoBitacora(String.Format("Refacturación de:
{1}", CveCompraRefacturacion, dr("Folio").ToString), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - ErrorBitacora = True - End If - End If - - End If - End If - - 'CARGA COMPRA ACTUAL - If Not ErrorBitacora Then - If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - dr = ObjCompra.DtResultados.Rows(0) - - 'ADJUNTAMOS ARCHIVO XML - If Not ErrorBitacora Then - Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("XML")) - If File.Exists(Archivo) Then - Extension = Path.GetExtension(Archivo) - If Extension <> "" Then - If ObjEventos.AddEventoBitacora("XML de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - - 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA - Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) - Ruta.DirectoryExistsCreate() - - 'COPIAMOS EL ARCHIVO A OI - System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) - Else - ErrorBitacora = True - End If - End If - End If - End If - - 'ADJUNTAMOS ARCHIVO PDF - If Not ErrorBitacora Then - Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("PDF")) - If File.Exists(Archivo) Then - Extension = Path.GetExtension(Archivo) - If Extension <> "" Then - If ObjEventos.AddEventoBitacora("PDF de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - - 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA - Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) - Ruta.DirectoryExistsCreate() - - 'COPIAMOS EL ARCHIVO A OI - System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) - - Else - ErrorBitacora = True - End If - End If - End If - End If - - 'LIGA AL FOLIO/COMPRA EN REFACTURACION - If Not ErrorBitacora Then - If Not ObjEventos.AddEventoBitacora(String.Format("Refacturación en: {1}", CveCompra, dr("Folio").ToString), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompraRefacturacion) Then - ErrorBitacora = True - End If - End If - - End If - End If - End If - - Return ErrorBitacora + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False) + + End If + Next + + AddPS2() + + BtnGuardar.Enabled = True + If Not CierrePeriodo Then + BtnGuardar.Visible = True + End If + AlmacenCambiaPS.Visible = False + UpFacturar.Update() + + TabGenerales.Enabled = True + TAB.ActiveTabIndex = 0 + UpTabs.Update() + + ImgClasificacion.Visible = False + LbAgregar.Visible = False + UpPSS.Update() + + CargaGvInv() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + CargaGVsAF() + + CargaTipoCentroCostoOC() + GvOC1.DataSource = DTOCTemp + + Dim DTCVEOCS As DataTable = DTOCTemp.FiltraParametros("", "", {"CveOrdenCompra"}) + If DTCVEOCS IsNot Nothing AndAlso DTCVEOCS.Rows.Count > 1 Then + GvOC1.Columns(0).Visible = True + Else + GvOC1.Columns(0).Visible = False + End If + + + + + GvOC1.DataBind() + + ' TmpDT = OrdenarTablas("CvePS", DTOCTemp, TmpDT) + GvOC2.DataSource = TmpDT + GvOC2.DataBind() + + + UpGvOC1.Update() + NCDevolucion = True + + ''Bloquea cambio de proyecto + 'DdlProyecto.Enabled = False + 'DdlSubProyecto.Enabled = False + 'UPPProyecto.Update() + + 'Bloquea cambio de OC ya que se concluyo alguna vinculacion + TxtOC.Enabled = False + ImgBtnBuscarOC.Visible = False + UpParametros.Update() + UpPSS.Update() + End Sub +#End Region + +#Region " REFACTURACION " + Private Sub ValidaRefacturacion() + If Not CveCompra > 0 AndAlso DdlTipoComprobante.SelectedValue = "Fac" And UsuarioActual.Empresa.CvePlataforma <> 2 Then + VerRefacturacion.Visible = True + End If + End Sub + Protected Sub BtnRefacturacionVer_Click(sender As Object, e As EventArgs) Handles BtnRefacturacionVer.Click + Dim Opcion As Integer = 1 + + If UsuarioActual.CveEmpresa.Contiene(119, 72) Then Opcion = 2 + + Dim ObjCompras As New ClsCompras + + DdlRefacturacionFacturas.Items.Clear() + If ObjCompras.GetRefacturacion(CveProveedor, TxtSubTotal.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtTotal.Text.ToDecimal, Opcion, UsuarioActual.CveEmpresa) Then + DtRefacturacion = ObjCompras.DtResultados + DdlRefacturacionFacturas.DataSource = DtRefacturacion + Else + Alert("Ocurrió un error al obtener las facturas para refacturación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + ObjCompras.Dispose() + DivRefacturacion.Visible = True + + DdlRefacturacionFacturas.DataBind() + DdlRefacturacionFacturas.SelectedValueExist(CveCompraRefacturacion) + DdlRefacturacionFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) + RegistraScript(String.Format("$('#{0}').modal('show')", DivRefacturacion.ClientID)) + UpRefacturacion.Update() + + End Sub + Protected Sub BtnRefacturacionAplicaFactura_Click(sender As Object, e As EventArgs) Handles BtnRefacturacionAplicaFactura.Click + TxtDescripcion.Text = String.Format("Refacturacion: {0}", DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("Descripcion")) + TxtFechaPago.Text = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("FechaVencimiento").ToString.ToDate.ToShortDateString + + For Each Dr As DataRow In TmpDT.Rows + Dr("CveSubProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveSubProyecto").ToString.ToEntero + Dr("SubProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("SubProyecto").ToString + Dr("CveProyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveProyecto").ToString.ToEntero + Dr("Proyecto") = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("Proyecto").ToString + Next + + TrFacturaRefacturar.Visible = True + LtFacturaRefacturar.Text = DdlRefacturacionFacturas.SelectedItem.Text + + CveCompraRefacturacion = DtRefacturacion.Rows(DdlRefacturacionFacturas.SelectedIndex - 1)("CveCompra").ToString.ToEntero + + GvPS.DataSource = TmpDT + GvPS.DataBind() + + 'LIMPIA ALMACEN + For Each gvr As GridViewRow In GvInv.Rows + gvr.FCCheckBox("cbInv").Checked = False + Next + TabAlmacen.Enabled = False + + UpRefacturacion.Update() + UpParametros.Update() + UpPS.Update() + UPCondicionesPago.Update() + UpTabs.Update() + RegistraScript(String.Format("$('#{0}').modal('hide')", DivRefacturacion.ClientID)) + End Sub + + Private Function GuardaRefacturacion(ByRef ObjCompra As ClsCompras, ByRef ObjEventos As ClsOIEventos, CvePrePoliza As Integer) As Boolean + Dim dr As DataRow = Nothing + Dim ErrorBitacora = False + Dim IdPolizaAnterior = -1 + Dim TotalRefact As Decimal = 0 + + 'SI NO TIENE POLIZA NI PAGOS NO HACE NADA + 'If ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + ' If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count = 1 Then + ' Dim drc As DataRow = ObjCompra.DtResultados.Rows(0) + ' TotalRefact = drc("Total").ToString.ToDecimal + ' If drc("IdPoliza").ToString.ToEntero <= 0 AndAlso drc("Saldo").ToString.ToDecimal = drc("Total").ToString.ToDecimal AndAlso drc("CveMovimiento").ToString.ToEntero <= 0 Then + ' Alert("La factura a refacturar no esta contabilizada ni tiene pagos ni movimientos de almacen. No se puede refacturar, debera eliminar la factura anterior y agregar esta factura de forma normal.", TipoMensaje.MsgAdvertencia) + ' Return True + ' End If + ' End If + 'End If + + 'GUARDA ADJUNTOS Y LIGA EN BITACORA (RELACION DE FACTURA NUEVA Y VIEJA) + ErrorBitacora = GuardaRefacturacionBitacora(ObjCompra, ObjEventos) + + If ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + dr = ObjCompra.DtResultados.Rows(0) + IdPolizaAnterior = dr("IdPoliza").ToString.ToEntero + End If + End If + + Dim Tipo As Integer = 1 + If ChkRefacNC.Checked Then Tipo = 2 + + 'CONTABILIZA REFACTURACION + If Not ObjCompra.Refacturacion(CveCompraRefacturacion, CveCompra, UsuarioActual.CveEmpresa, Tipo) Then + ErrorBitacora = True + End If + + + + 'Return True + Return ErrorBitacora End Function -#End Region + Private Function GuardaRefacturacionBitacora(ObjCompra As ClsCompras, ObjEventos As ClsOIEventos) As Boolean + Dim dr As DataRow = Nothing + Dim ErrorBitacora = False + Dim Archivo = "" + Dim Folio = "" + Dim Extension = "" + Dim Ruta = "" + + 'CARGA COMPRA REFACTURADA + If CveCompra > 0 AndAlso ObjCompra.GetCompras(CveCompraRefacturacion, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + dr = ObjCompra.DtResultados.Rows(0) + + 'ADJUNTAMOS ARCHIVO XML + If Not ErrorBitacora Then + Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("XML")) + If File.Exists(Archivo) Then + Extension = Path.GetExtension(Archivo) + If Extension <> "" Then + If ObjEventos.AddEventoBitacora("XML de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + + 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA + Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) + Ruta.DirectoryExistsCreate() + + 'COPIAMOS EL ARCHIVO A OI + System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) + Else + ErrorBitacora = True + End If + End If + End If + End If + + + 'ADJUNTAMOS ARCHIVO PDF + If Not ErrorBitacora Then + Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("PDF")) + If File.Exists(Archivo) Then + Extension = Path.GetExtension(Archivo) + If Extension <> "" Then + If ObjEventos.AddEventoBitacora("PDF de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + + 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA + Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) + Ruta.DirectoryExistsCreate() + + 'COPIAMOS EL ARCHIVO A OI + System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) + + Else + ErrorBitacora = True + End If + End If + End If + End If + + 'LIGA AL FOLIO/COMPRA DE REFACTURACION + If Not ErrorBitacora Then + If Not ObjEventos.AddEventoBitacora(String.Format("Refacturación de: {1}", CveCompraRefacturacion, dr("Folio").ToString), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + ErrorBitacora = True + End If + End If + + End If + End If + + 'CARGA COMPRA ACTUAL + If Not ErrorBitacora Then + If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + dr = ObjCompra.DtResultados.Rows(0) + + 'ADJUNTAMOS ARCHIVO XML + If Not ErrorBitacora Then + Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("XML")) + If File.Exists(Archivo) Then + Extension = Path.GetExtension(Archivo) + If Extension <> "" Then + If ObjEventos.AddEventoBitacora("XML de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + + 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA + Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) + Ruta.DirectoryExistsCreate() + + 'COPIAMOS EL ARCHIVO A OI + System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) + Else + ErrorBitacora = True + End If + End If + End If + End If + + 'ADJUNTAMOS ARCHIVO PDF + If Not ErrorBitacora Then + Archivo = String.Format("/Empresas/{0}/Compras/{1}/{2}", dr("CveEmpresa"), dr("RFC"), dr("PDF")) + If File.Exists(Archivo) Then + Extension = Path.GetExtension(Archivo) + If Extension <> "" Then + If ObjEventos.AddEventoBitacora("PDF de Refacturación:", Extension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + + 'OBTENEMOS RUTA DONDE GUARDAR | OPCIONAL: CREAMOS CARPETA + Ruta = String.Format("{0}OI", UsuarioActual.Empresa.Ruta) + Ruta.DirectoryExistsCreate() + + 'COPIAMOS EL ARCHIVO A OI + System.IO.File.Copy(Archivo, String.Format("{0}\OI{1}{2}", Ruta, ObjEventos.CveEvento.ToString, Extension)) + + Else + ErrorBitacora = True + End If + End If + End If + End If + + 'LIGA AL FOLIO/COMPRA EN REFACTURACION + If Not ErrorBitacora Then + If Not ObjEventos.AddEventoBitacora(String.Format("Refacturación en: {1}", CveCompra, dr("Folio").ToString), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompraRefacturacion) Then + ErrorBitacora = True + End If + End If + + End If + End If + End If + + Return ErrorBitacora + End Function + +#End Region + +#Region " CANCELAR COMPRA " + Private Sub ValidaCancelarCompra() + If UsuarioActual.TienePermisoProceso(140) Then + If CveMovimientoAlmacen > 0 And EstatusAlmacen = 2 Then + BtnCancelarCompra.Visible = True + ElseIf CveMovimientoAlmacen = 0 Then + BtnCancelarCompra.Visible = True + End If + End If + End Sub + Protected Sub BtnCancelarCompra2_Click(sender As Object, e As EventArgs) + RegistraScript("$('#DivCancelarCompra').modal('hide');") + + Dim ObjAC As ClsContPAQi = Nothing + If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then + ObjAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + End If + + Dim ObjCompras As New ClsCompras + Dim ObjContabilidad As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) + + Dim ErrorCancelar = False + Dim IdPolizaNueva = -1 + Dim FolioPolizaNueva = -1 + Dim CvePrePolizaNueva = -1 + Dim dt As DataTable + + + ' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS) + If TxtFecha.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFecha.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Or DdlTipoComprobante.SelectedValue.Contiene("NC") Then + + 'CREA POLIZA NEGATIVA + If IdPoliza > 0 AndAlso ObjAC IsNot Nothing Then + If ObjAC.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then + dt = ObjAC.DtResultados + + IdPolizaNueva = ObjAC.AddPoliza(dt.Rows(0)("CodigoTipoPoliza").ToString.ToEntero, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaCancelacion.Text.ToDate) + If IdPolizaNueva > 0 Then + FolioPolizaNueva = ObjAC.Folio + For Each dr As DataRow In dt.Rows + If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, "") Then + ErrorCancelar = True : Exit For + End If + Next + + 'AJUSTA POLIZA + If Not ErrorCancelar Then + If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then + ErrorCancelar = True + End If + End If + Else + ErrorCancelar = True + End If + Else + ErrorCancelar = True + End If + End If + + 'CREA PRE-POLIZA NEGATIVA + If DdlTipoComprobante.SelectedValue.Contiene("NC") Then + If ObjCompras.GetCancelarNC(CveCompra, UsuarioActual.CveEmpresa) Then + dt = ObjCompras.DtResultados + + CvePrePolizaNueva = ObjContabilidad.AddPrePolizas("Compras/Cancelar", dt.Rows(0)("CvePlantillaPoliza").ToString.ToEntero, dt.Rows(0)("Cargos").ToString.ToDouble * -1, dt.Rows(0)("Abonos").ToString.ToDouble * -1, dt.Rows(0)("CveMoneda").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, String.Format("Cancelación: {0}", dt.Rows(0)("Concepto").ToString), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePolizaNueva > 0 Then + For Each dr As DataRow In dt.Rows + If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePolizaNueva, CBool(dr("TipoMovto").ToString), dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, dr("CveConceptoContable").ToString.ToEntero, + dr("Concepto").ToString, TxtFechaCancelacion.Text.ToDate, dr("IdCtaContable").ToString.ToEntero, dr("IdSegmentoNegocio").ToString.ToEntero, dr("CveIE").ToString.ToEntero, + dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, + dr("CveMovimientoAlmacen").ToString.ToEntero, dr("CveActivoFijo").ToString.ToEntero, dr("CveAcreedor").ToString.ToEntero, dr("CveColectiva").ToString.ToEntero, dr("CveCreditoDetalle").ToString.ToEntero, CveCuenta:=dr("CveCuenta").ToString.ToEntero, + ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero, + CveCompraAmortizacion:=dr("CveCompraAmortizacion").ToString.ToEntero) Then + ErrorCancelar = True + Exit For + End If + Next + Else + ErrorCancelar = True + End If + Else + ErrorCancelar = True + End If + Else + If CvePrePoliza > 0 Then + If ObjContabilidad.GetPrePolizasDetalle(CvePrePoliza) Then + dt = ObjContabilidad.DtResultados + + CvePrePolizaNueva = ObjContabilidad.AddPrePolizas("Compras/Cancelar", dt.Rows(0)("CvePlantillaPoliza").ToString.ToEntero, dt.Rows(0)("Cargos").ToString.ToDouble * -1, dt.Rows(0)("Abonos").ToString.ToDouble * -1, dt.Rows(0)("CveMoneda").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, String.Format("Cancelación: {0}", dt.Rows(0)("Concepto").ToString), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePolizaNueva > 0 Then + For Each dr As DataRow In dt.Rows + If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePolizaNueva, CBool(dr("TipoMovto").ToString), dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, dr("CveConceptoContable").ToString.ToEntero, + dr("Concepto").ToString, TxtFechaCancelacion.Text.ToDate, dr("IdCtaContable").ToString.ToEntero, dr("IdSegmentoNegocio").ToString.ToEntero, dr("CveIE").ToString.ToEntero, + dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, + dr("CveMovimientoAlmacen").ToString.ToEntero, dr("CveActivoFijo").ToString.ToEntero, dr("CveAcreedor").ToString.ToEntero, dr("CveColectiva").ToString.ToEntero, dr("CveCreditoDetalle").ToString.ToEntero, CveCuenta:=dr("CveCuenta").ToString.ToEntero, + ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero) Then + ErrorCancelar = True + Exit For + End If + Next + Else + ErrorCancelar = True + End If + Else + ErrorCancelar = True + End If + End If + End If + + 'MES ACTUAL + Else + + 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS + If IdPoliza > 0 AndAlso ObjAC IsNot Nothing Then + If ObjAC.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then + dt = ObjAC.DtResultados + + For Each dr As DataRow In dt.Rows + If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then + ErrorCancelar = True : Exit For + End If + Next + + 'AJUSTA POLIZA + If Not ErrorCancelar Then + If Not ObjAC.AjustaPoliza(IdPoliza) Then + ErrorCancelar = True + End If + End If + + Else + ErrorCancelar = True + End If + End If + + 'LIMPIA PRE-POLIZA PONIENDO IMPORTE EN CEROS + If CvePrePoliza > 0 Then + If ObjContabilidad.GetPrePolizasDetalle(CvePrePoliza) Then + dt = ObjContabilidad.DtResultados + + For Each dr As DataRow In dt.Rows + If Not ObjContabilidad.UpdatePrepolizasDetalle(dr("CvePrePolizaDetalle").ToString.ToEntero, dr("Concepto").ToString, dr("CveSubProyecto").ToString.ToEntero, dr("IdCtaContable").ToString.ToEntero, CBool(dr("TipoMovto").ToString), 0) Then + ErrorCancelar = True : Exit For + End If + Next + Else + ErrorCancelar = True + End If + End If + + End If + + + 'CANCELA COMPRA + If Not ErrorCancelar Then + If Not ObjCompras.UpdateEstatusCompra(CveCompra, -2) Then + ErrorCancelar = True + End If + End If + + + If Not ErrorCancelar Then + If ObjAC IsNot Nothing Then + ObjAC.Commit() + End If + ObjCompras.Commit() + Dim Msg As New StringBuilder + Msg.Append("La compra se cancelo correctamente.") + + If IdPolizaNueva > 0 Then Msg.AppendFormat("

Ver Póliza de cancelación", IdPolizaNueva) + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + Else + If ObjAC IsNot Nothing Then + ObjAC.RollBack() + End If + ObjCompras.RollBack() + Alert("La compra no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + ObjCompras.Dispose() + If ObjAC IsNot Nothing Then + ObjAC.Dispose() + End If -#Region " CANCELAR COMPRA " - Private Sub ValidaCancelarCompra() - If UsuarioActual.TienePermisoProceso(140) Then - If CveMovimientoAlmacen > 0 And EstatusAlmacen = 2 Then - BtnCancelarCompra.Visible = True - ElseIf CveMovimientoAlmacen = 0 Then - BtnCancelarCompra.Visible = True - End If - End If - End Sub - Protected Sub BtnCancelarCompra2_Click(sender As Object, e As EventArgs) - RegistraScript("$('#DivCancelarCompra').modal('hide');") - - Dim ObjAC As ClsContPAQi = Nothing - If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then - ObjAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - End If - - Dim ObjCompras As New ClsCompras - Dim ObjContabilidad As New ClsContabilidad(ObjCompras.IniciaTransacSQL()) - - Dim ErrorCancelar = False - Dim IdPolizaNueva = -1 - Dim FolioPolizaNueva = -1 - Dim CvePrePolizaNueva = -1 - Dim dt As DataTable - - - ' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS) - If TxtFecha.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFecha.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Or DdlTipoComprobante.SelectedValue.Contiene("NC") Then - - 'CREA POLIZA NEGATIVA - If IdPoliza > 0 AndAlso ObjAC IsNot Nothing Then - If ObjAC.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then - dt = ObjAC.DtResultados - - IdPolizaNueva = ObjAC.AddPoliza(dt.Rows(0)("CodigoTipoPoliza").ToString.ToEntero, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaCancelacion.Text.ToDate) - If IdPolizaNueva > 0 Then - FolioPolizaNueva = ObjAC.Folio - For Each dr As DataRow In dt.Rows - If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, "") Then - ErrorCancelar = True : Exit For - End If - Next - - 'AJUSTA POLIZA - If Not ErrorCancelar Then - If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then - ErrorCancelar = True - End If - End If - Else - ErrorCancelar = True - End If - Else - ErrorCancelar = True - End If - End If - - 'CREA PRE-POLIZA NEGATIVA - If DdlTipoComprobante.SelectedValue.Contiene("NC") Then - If ObjCompras.GetCancelarNC(CveCompra, UsuarioActual.CveEmpresa) Then - dt = ObjCompras.DtResultados - - CvePrePolizaNueva = ObjContabilidad.AddPrePolizas("Compras/Cancelar", dt.Rows(0)("CvePlantillaPoliza").ToString.ToEntero, dt.Rows(0)("Cargos").ToString.ToDouble * -1, dt.Rows(0)("Abonos").ToString.ToDouble * -1, dt.Rows(0)("CveMoneda").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, String.Format("Cancelación: {0}", dt.Rows(0)("Concepto").ToString), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePolizaNueva > 0 Then - For Each dr As DataRow In dt.Rows - If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePolizaNueva, CBool(dr("TipoMovto").ToString), dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, dr("CveConceptoContable").ToString.ToEntero, - dr("Concepto").ToString, TxtFechaCancelacion.Text.ToDate, dr("IdCtaContable").ToString.ToEntero, dr("IdSegmentoNegocio").ToString.ToEntero, dr("CveIE").ToString.ToEntero, - dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, - dr("CveMovimientoAlmacen").ToString.ToEntero, dr("CveActivoFijo").ToString.ToEntero, dr("CveAcreedor").ToString.ToEntero, dr("CveColectiva").ToString.ToEntero, dr("CveCreditoDetalle").ToString.ToEntero, CveCuenta:=dr("CveCuenta").ToString.ToEntero, - ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero, - CveCompraAmortizacion:=dr("CveCompraAmortizacion").ToString.ToEntero) Then - ErrorCancelar = True - Exit For - End If - Next - Else - ErrorCancelar = True - End If - Else - ErrorCancelar = True - End If - Else - If CvePrePoliza > 0 Then - If ObjContabilidad.GetPrePolizasDetalle(CvePrePoliza) Then - dt = ObjContabilidad.DtResultados - - CvePrePolizaNueva = ObjContabilidad.AddPrePolizas("Compras/Cancelar", dt.Rows(0)("CvePlantillaPoliza").ToString.ToEntero, dt.Rows(0)("Cargos").ToString.ToDouble * -1, dt.Rows(0)("Abonos").ToString.ToDouble * -1, dt.Rows(0)("CveMoneda").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, String.Format("Cancelación: {0}", dt.Rows(0)("Concepto").ToString), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePolizaNueva > 0 Then - For Each dr As DataRow In dt.Rows - If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePolizaNueva, CBool(dr("TipoMovto").ToString), dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, dr("CveConceptoContable").ToString.ToEntero, - dr("Concepto").ToString, TxtFechaCancelacion.Text.ToDate, dr("IdCtaContable").ToString.ToEntero, dr("IdSegmentoNegocio").ToString.ToEntero, dr("CveIE").ToString.ToEntero, - dr("CveVenta").ToString.ToEntero, dr("CveCompra").ToString.ToEntero, dr("CveSubProyecto").ToString.ToEntero, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, - dr("CveMovimientoAlmacen").ToString.ToEntero, dr("CveActivoFijo").ToString.ToEntero, dr("CveAcreedor").ToString.ToEntero, dr("CveColectiva").ToString.ToEntero, dr("CveCreditoDetalle").ToString.ToEntero, CveCuenta:=dr("CveCuenta").ToString.ToEntero, - ImporteMX:=dr("Importe").ToString.ToDecimal * -1, ImporteME:=dr("Importe").ToString.ToDecimal * -1, CveTipoGasto:=dr("CveTipoGasto").ToString.ToEntero, CveClasificacion:=dr("CveClasificacion").ToString.ToEntero, CveOCDetalle:=dr("CveOCDetalle").ToString.ToEntero) Then - ErrorCancelar = True - Exit For - End If - Next - Else - ErrorCancelar = True - End If - Else - ErrorCancelar = True - End If - End If - End If - - 'MES ACTUAL - Else - - 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS - If IdPoliza > 0 AndAlso ObjAC IsNot Nothing Then - If ObjAC.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then - dt = ObjAC.DtResultados - - For Each dr As DataRow In dt.Rows - If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then - ErrorCancelar = True : Exit For - End If - Next - - 'AJUSTA POLIZA - If Not ErrorCancelar Then - If Not ObjAC.AjustaPoliza(IdPoliza) Then - ErrorCancelar = True - End If - End If - - Else - ErrorCancelar = True - End If - End If - - 'LIMPIA PRE-POLIZA PONIENDO IMPORTE EN CEROS - If CvePrePoliza > 0 Then - If ObjContabilidad.GetPrePolizasDetalle(CvePrePoliza) Then - dt = ObjContabilidad.DtResultados - - For Each dr As DataRow In dt.Rows - If Not ObjContabilidad.UpdatePrepolizasDetalle(dr("CvePrePolizaDetalle").ToString.ToEntero, dr("Concepto").ToString, dr("CveSubProyecto").ToString.ToEntero, dr("IdCtaContable").ToString.ToEntero, CBool(dr("TipoMovto").ToString), 0) Then - ErrorCancelar = True : Exit For - End If - Next - Else - ErrorCancelar = True - End If - End If - - End If - - - 'CANCELA COMPRA - If Not ErrorCancelar Then - If Not ObjCompras.UpdateEstatusCompra(CveCompra, -2) Then - ErrorCancelar = True - End If - End If - - - If Not ErrorCancelar Then - If ObjAC IsNot Nothing Then - ObjAC.Commit() - End If - ObjCompras.Commit() - Dim Msg As New StringBuilder - Msg.Append("La compra se cancelo correctamente.") - - If IdPolizaNueva > 0 Then Msg.AppendFormat("

Ver Póliza de cancelación", IdPolizaNueva) - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - Else - If ObjAC IsNot Nothing Then - ObjAC.RollBack() - End If - ObjCompras.RollBack() - Alert("La compra no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - ObjCompras.Dispose() - If ObjAC IsNot Nothing Then - ObjAC.Dispose() - End If - - End Sub - - Private Sub btnProrateo_Click(sender As Object, e As EventArgs) Handles btnProrateo.Click, btnProrateo2.Click - Dim IvaOriginal As Double = TxtIVA.Text.ToDouble - - Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString - Select Case CuentaContable - Case "Compras" - StringProrrateo = UsuarioActual.Empresa.Funcionalidad(117) - Case "Nomina" - StringProrrateo = UsuarioActual.Empresa.Funcionalidad(303) - End Select - - Dim porcentajes As String() = StringProrrateo.Split(New Char() {";"c}) - - Dim prtDT As DataTable = TmpDT.Copy - Dim GBSP As DataTable = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToString.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa) - - TmpDT.Clear() - Dim subtotal As Decimal = TxtSubTotal.Text.ToDecimal - Dim subtotal2 As Decimal = TxtSubTotal2.Text.ToDecimal - Dim des As Decimal = TxtDescuento.Text.ToDecimal - Dim ivaa As Decimal = TxtIVA.Text.ToDecimal - - TxtSubTotal.Text = "0.00" - TxtSubTotal2.Text = "0.00" - If CveFactura = 0 Then - TxtDescuento.Text = "0.00" - TxtIVA.Text = "0.00" - End If - - For Each dr As DataRow In prtDT.Rows - Dim CveUM As Integer = dr("CveUM").ToString.ToEntero - Dim UM As String = dr("UM").ToString - Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero - Dim Clasificacion As String = dr("Clasificacion").ToString - Dim CvePS As Integer = dr("CvePS").ToString.ToEntero - Dim PS As String = dr("PS").ToString - Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero - Dim Proyecto As String = dr("Proyecto").ToString - Dim Obs As String = dr("Obs").ToString - Dim PU As Double = dr("PU").ToString.ToDouble - Dim IVA As Double = dr("IVA").ToString.ToDouble - Dim RetIVA As Double = dr("RetIVA").ToString.ToDouble - Dim RetISR As Double = dr("RetISR").ToString.ToDouble - Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDouble - Dim IEPSPSIVA As Double = If(dr("IEPSGrabaIVA").ToString = "True", dr("IEPSPorcentaje").ToString.ToDouble, 0) - Dim Descuento As Double = dr("Descuento").ToString.ToDouble - Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero - - For Each cadena As String In porcentajes - - Dim valores As String() = cadena.Split(New Char() {","c}) - Dim Cantidad As Double = dr("Cantidad").ToString.ToDouble * (valores(1).ToDouble / 100) - Dim CveSubProyectoContrato As String = valores(0) - Dim CveProyecto As String = valores(0) - Dim Total As Double = Cantidad * PU - Dim drT As DataRow = GBSP.FiltroPrimero(String.Format("CveSubProyecto = {0} ", CveSubProyectoContrato)) - Dim drq As DataRow = GBSP.FiltroPrimero(String.Format("CveProyecto = {0} ", CveProyecto)) - Dim SubProyecto As String = drT("SubProyecto").ToString - - AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle:=CveOrdenCompraDetalle) - Next - Next - - AddPS2() - - AjustaImporteUltimoConcepto(subtotal2 - TmpDT.SUM("Total").ToString.ToDecimal) - TxtIVA.Text = IvaOriginal.ToString - CalculaTotales(True) - - LbAgregar.Visible = False - UpPSS.Update() - prtDT = TmpDT.Copy - prtDT.Clear() - - End Sub - - - - Private Sub BtnValesCombustibleVer_Click(sender As Object, e As EventArgs) Handles BtnValesCombustibleVer.Click - - Dim AF As New ClsAF - - If AF.GetValesCombustible(-1, -1, -1, CveProveedor, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, -1, -1) Then - GvVales.DataSource = AF.DtResultados - End If - - AF.Dispose() - GvVales.DataBind() - DivValesCombustible.Visible = True - RegistraScript(String.Format("$('#{0}').modal('show')", DivValesCombustible.ClientID)) - UPPValesCombustible.Update() End Sub -#End Region + Private Sub btnProrateo_Click(sender As Object, e As EventArgs) Handles btnProrateo.Click, btnProrateo2.Click + Dim IvaOriginal As Double = TxtIVA.Text.ToDouble + + Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString + Select Case CuentaContable + Case "Compras" + StringProrrateo = UsuarioActual.Empresa.Funcionalidad(117) + Case "Nomina" + StringProrrateo = UsuarioActual.Empresa.Funcionalidad(303) + End Select + + Dim porcentajes As String() = StringProrrateo.Split(New Char() {";"c}) + + Dim prtDT As DataTable = TmpDT.Copy + Dim GBSP As DataTable = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToString.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa) + + TmpDT.Clear() + Dim subtotal As Decimal = TxtSubTotal.Text.ToDecimal + Dim subtotal2 As Decimal = TxtSubTotal2.Text.ToDecimal + Dim des As Decimal = TxtDescuento.Text.ToDecimal + Dim ivaa As Decimal = TxtIVA.Text.ToDecimal + + TxtSubTotal.Text = "0.00" + TxtSubTotal2.Text = "0.00" + If CveFactura = 0 Then + TxtDescuento.Text = "0.00" + TxtIVA.Text = "0.00" + End If + + For Each dr As DataRow In prtDT.Rows + Dim CveUM As Integer = dr("CveUM").ToString.ToEntero + Dim UM As String = dr("UM").ToString + Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = dr("Clasificacion").ToString + Dim CvePS As Integer = dr("CvePS").ToString.ToEntero + Dim PS As String = dr("PS").ToString + Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero + Dim Proyecto As String = dr("Proyecto").ToString + Dim Obs As String = dr("Obs").ToString + Dim PU As Double = dr("PU").ToString.ToDouble + Dim IVA As Double = dr("IVA").ToString.ToDouble + Dim RetIVA As Double = dr("RetIVA").ToString.ToDouble + Dim RetISR As Double = dr("RetISR").ToString.ToDouble + Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDouble + Dim IEPSPSIVA As Double = If(dr("IEPSGrabaIVA").ToString = "True", dr("IEPSPorcentaje").ToString.ToDouble, 0) + Dim Descuento As Double = dr("Descuento").ToString.ToDouble + Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero + + For Each cadena As String In porcentajes + + Dim valores As String() = cadena.Split(New Char() {","c}) + Dim Cantidad As Double = dr("Cantidad").ToString.ToDouble * (valores(1).ToDouble / 100) + Dim CveSubProyectoContrato As String = valores(0) + Dim CveProyecto As String = valores(0) + Dim Total As Double = Cantidad * PU + Dim drT As DataRow = GBSP.FiltroPrimero(String.Format("CveSubProyecto = {0} ", CveSubProyectoContrato)) + Dim drq As DataRow = GBSP.FiltroPrimero(String.Format("CveProyecto = {0} ", CveProyecto)) + Dim SubProyecto As String = drT("SubProyecto").ToString + + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle:=CveOrdenCompraDetalle) + Next + Next + + AddPS2() + + AjustaImporteUltimoConcepto(subtotal2 - TmpDT.SUM("Total").ToString.ToDecimal) + TxtIVA.Text = IvaOriginal.ToString + CalculaTotales(True) + + LbAgregar.Visible = False + UpPSS.Update() + prtDT = TmpDT.Copy + prtDT.Clear() -#Region " VALES COMBUSTIBLES " - Protected Sub BtnValesVincular_Click(sender As Object, e As EventArgs) - IdVale = New List(Of Integer) - - For Each row As GridViewRow In GvVales.Rows - If row.FCCheckBox("ChkVale").Checked Then - IdVale.Add(row.DataKey("CveVale").ToEntero) - End If - Next - - If IdVale.Count <= 0 Then - Alert("Debe elegir por lo menos un vale de combustible. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Else - Alert("Los vales selecciondos están listos para vincular") - RegistraScript(String.Format("$('#{0}').modal('hide')", DivValesCombustible.ClientID)) - 'For Each cve In IdVale - ' Alert(cve.ToString) - 'Next - End If End Sub -#End Region -#Region " VINCULAR OC " - Private Sub InicializaOC() - 'BORRAR OC - 'TabOC.Visible = False - - TabOC.Visible = False - - EmpresasOC = New List(Of Integer) - - ''TODAS LAS EMPRESAS LO TIENEN Y LA 66 SOLO LOS USUARIOS DE ABAJO - EMPRESA QUE ESTE EN LA LISTA NO TENDRA NUEVO ESQUEMA - 'If UsuarioActual.CveEmpresa = 66 AndAlso Not UsuarioActual.CveUsuario.Contiene(1434, 1436, 1337, 1440) Then - ' EmpresasOC.Add(UsuarioActual.CveEmpresa) - 'End If - - 'If Not EmpresasOC.Contains(UsuarioActual.CveEmpresa) Then - TabOC.Visible = True - 'Else - 'TabOC.Visible = True - 'End If - - If Not UsuarioActual.TienePermisoProceso(242) Then - DdlOCVinculaInv.Items.RemoveAt(2) - DdlOCVinculaInv.Items.RemoveAt(3) - End If - - End Sub - Protected Sub BtnBuscarOC_Click(sender As Object, e As EventArgs) Handles BtnBuscarOC.Click - PopUpOC = False - CargaOC() - End Sub - Protected Sub CargaVOC(sender As Object, e As EventArgs) - PopUpOC = True - CargaOC() - End Sub - Private Sub CargaOC() - Dim EntregaDirecta = 0 - DivOCSolicitudAnticipo.Visible = False - DivOCSolicitudAnticipoModal.Visible = False - - If CveProveedor <= 0 Then - Alert("Debe de Seleccionar un proveedor") - Exit Sub - End If - - 'BANDERA DE SURTIDO - If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then - GvOC1.Columns(1).Visible = True - End If - - Dim CvesOC = "" - - - If PopUpOC Then - CvesOC = HdnVCveOC.Value - End If - - HdnVCveOC.Value = "" - HdnCveEstatusOC.Value = "" - - Dim OC As New ClsOC - If PopUpOC Then - Dim ArrayCveOC As String() = CvesOC.Split(New Char() {","c}) - For i As Integer = 0 To ArrayCveOC.Count - 1 - If OC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, ArrayCveOC(i).ToEntero, CveProveedor, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then - If OC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) - HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) - EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) - End If - End If - Next - Else - Dim TextoErrorOC = "" - Dim ArrayCveOC As String() = TxtOC.Text.Split(New Char() {","c}) - For i As Integer = 0 To ArrayCveOC.Count - 1 - If OC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, -1, CveProveedor, ArrayCveOC(i).ToEntero, -1, -1, UsuarioActual.CveEmpresa, -1) Then - If OC.DtResultados.Rows.Count > 1 Then - TextoErrorOC += $"
El folio {ArrayCveOC(i).ToEntero} no se pudo identificar." - End If - If OC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then - HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) - HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) - EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) - End If - End If - Next - If TextoErrorOC <> "" Then - Alert($"Las siguientes Ordenes de Compra no se pudieron vincular automaticamente:
{TextoErrorOC}

Sera necesario vincular de manera manual mediante busqueda (lupia).", TipoMensaje.MsgAdvertencia) - TxtOC.Text = "" - Exit Sub - End If - End If - OC.Dispose() - PopUpOC = False - - - If HdnVCveOC.Value <> "" Then - If HdnCveEstatusOC.Value = "" Then - Alert("No se tiene especificado el siguiente estatus de la Orden(es) de Compra. Por favor verifique los estatus y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - VinculaOC() - - If EntregaDirecta > 0 Then - Alert("Se identificó una Orden de Compra con entrega directa, por lo cual no se podra recibir en almacén desde este modulo, para esto es necesario recibir la mercancía desde la Orden de Compra.", TipoMensaje.MsgAdvertencia) - TabAlmacen.Visible = False - DivOCEntregaDirecta.Visible = True - End If - - BtnGuardar.Enabled = False - TxtOC.Enabled = False - ImgBtnBuscarOC.Enabled = False - UpFacturar.Update() - - Else - Alert("No se encontro ninguna Orden de Compra con el folio especificado.", TipoMensaje.MsgAdvertencia) - End If - - UPPOC.Update() - UpPS.Update() - End Sub - Protected Sub BtnVOC_Click(sender As Object, e As EventArgs) - VinculaOC() - End Sub - Private Sub VinculaOC() - If TxtOC.Text <> "" Then - - 'VARIABLES - Dim TextoObservaciones = "" - LtOCPromocion.Text = "" - IvaAcumulado = 0 - DTOCTemp = New DataTable - - 'SI NO ES UNA COMPRA REGISTRADA = ENABLE FALSE TAB GENERALES, ACTIVE TAB OC - If Not CveCompra > 0 Then - TabGenerales.Enabled = False - TAB.ActiveTabIndex = 2 - UpTabs.Update() - End If - - 'CARGAMOS LOS DATOS DE LAS OC - Dim ObjOC As New ClsOC - Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) - Dim FoliosOCAnticipo = "", FoliosOCAnticipoIE = "" - Dim StrPromos As New StringBuilder - - For Each CveOCItem As String In ArrayCveOC.Distinct - If ObjOC.GetOrdenesDetalle(CveOCItem.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then - If IsNothing(DTOCTemp) Then - DTOCTemp = ObjOC.DtResultados.Copy - Else - DTOCTemp.Merge(ObjOC.DtResultados) - End If - - IvaAcumulado += ObjOC.DtResultados.Rows(0)("IVA").ToString.ToDouble - TextoObservaciones += ObjOC.DtResultados.Rows(0)("Descripcion").ToString - - If ObjOC.DtResultados.Rows.Count > 0 Then - - ''MONEDA DIFERENTE - If ObjOC.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero <> DdlMoneda.SelectedValue.ToEntero Then - DivTipoCambioOC.Visible = True - TxtTipoCambioOC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString - BtnVincularOCCompleta.Visible = False - BtnVincularOC.Visible = False - End If - - ''SOLICITUD DE ANTICIPO - If ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero > 0 Then - FoliosOCAnticipo += $"{ObjOC.DtResultados.Rows(0)("FolioOC").ToString}," - FoliosOCAnticipoIE += $"{ObjOC.DtResultados.Rows(0)("FolioIEAnticipo").ToString}," - DivOCSolicitudAnticipo.Visible = True - DivOCSolicitudAnticipoModal.Visible = True - End If - - 'PROMOCIONES - Dim Promocion = ObjOC.DtResultados.Rows(0)("Promocion").ToString - If Not String.IsNullOrEmpty(Promocion) Then - Dim FolioOC = ObjOC.DtResultados.Rows(0)("FolioOC").ToString - StrPromos.Append($"OC #{FolioOC} {Promocion}
") - StrPromos.AppendLine() - End If - End If - - Else - Alert("Ocurrio un Error al cargar la(s) Orden(es) de Compra", TipoMensaje.MsgError) - If DTOCTemp IsNot Nothing Then DTOCTemp.Rows.Clear() - TextoObservaciones = "" - Exit Sub - End If - Next - ObjOC.Dispose() - - 'MOVIMIENTOS DE ALMACÉN - Dim ObjInventarios As New ClsInventarios - Dim FoliosOCAlmacen = "" - For Each CveOCItem As String In ArrayCveOC.Distinct - If ObjInventarios.GetMovimientosOC(CveOCItem.ToEntero, UsuarioActual.CveEmpresa) Then - If ObjInventarios.DtResultados.Rows.Count > 0 Then - FoliosOCAlmacen = $"{ObjInventarios.DtResultados.FiltroPrimeroValor("FolioOC")}," - End If - Else - Alert("Ocurrió un error al cargar los movimientos de almacén de la orden de compra", TipoMensaje.MsgError) - ObjInventarios.Dispose() - Exit Sub - End If - Next - ObjInventarios.Dispose() - If FoliosOCAlmacen.Length > 0 Then - DivOCAlmacen.Visible = True - LtOCAlmacen.Text = FoliosOCAlmacen.Substring(0, FoliosOCAlmacen.Length - 1) - End If - - 'SI PUEDE RECIBIR POR OC Y COMPRA - If UsuarioActual.CveEmpresa.Contiene(119) Then - If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - DivOCVinculaInv.Visible = True - End If - End If - - - 'TIPO CAMBIO - If CveCompra > 0 Then - DivTipoCambioOC.Visible = False - End If - - DTOCTemp.Columns.Add("PUTC", GetType(Double)) - DTOCTemp.Columns.Add("TotalTC", GetType(Double)) - DTOCTemp.Columns.Add("DescuentoTC", GetType(Double)) - DTOCTemp.Columns.Add("IVATC", GetType(Double)) - DTOCTemp.Columns.Add("IEPSPSTC", GetType(Double)) - DTOCTemp.Columns.Add("IEPSPSIVATC", GetType(Double)) - DTOCTemp.Columns.Add("RetIVATC", GetType(Double)) - DTOCTemp.Columns.Add("RetISRTC", GetType(Double)) - DTOCTemp.Columns.Add("FolioAlmacen", GetType(String)) - For Each Dr As DataRow In DTOCTemp.Rows - Dr("PUTC") = Dr("Importe") - Dr("DescuentoTC") = Dr("Descuento") - Dr("IVATC") = Dr("IVA") - Dr("IEPSPSTC") = Dr("IEPSPS") - Dr("IEPSPSIVATC") = Dr("IEPSPSIVA") - Dr("RetIVATC") = Dr("RetIVA") - Dr("RetISRTC") = Dr("RetISR") - Dr("TotalTC") = Dr("ImporteAjustadoDescuento") - - '[IPP] - JAMEntregaAdelantado | AJUSTE DE CANITDAD POR RECIBIR EN BASE A SALDOS DE INV-COMPRAS - 'If UsuarioActual.CveUsuario = 100 Then - 'If Dr("CveTipoPS").ToString.ToEntero = 2 And UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - ' Dr("CantidadDisponible") = If(Dr("CantidadDisponible").ToString.ToDouble > Dr("CantidadPendienteVincular").ToString.ToDouble, Dr("CantidadPendienteVincular"), Dr("CantidadDisponible")) - 'End If - 'End If - Next - - 'DESCRIPCION DE OC CUANDO NO ES COMPRA REGISTRADA - If Not CveCompra > 0 Then TxtDescripcion.Text = TextoObservaciones - - 'SOLICITUD DE ANTICIPO - If DivOCSolicitudAnticipo.Visible And FoliosOCAnticipo.Length > 0 Then - LtSolicitudAnticipoFoliosOC.Text = $"La(s) siguiente(s) OC: {FoliosOCAnticipo.Substring(0, FoliosOCAnticipo.Length - 1)}. tienen vinculado un anticipo" - LtSolicitudAnticipoFoliosIE.Text = $" {FoliosOCAnticipoIE.Substring(0, FoliosOCAnticipoIE.Length - 1)}" - End If - - 'PROMOCIONES - LtOCPromocion.Text = StrPromos.ToString - If LtOCPromocion.Text.Length > 0 And UsuarioActual.CveEmpresa = 119 Then - DivOCPromocion.Visible = True - End If - - 'CARGA DATOS DE OC - CargaVinculacionOC(True) - - End If - End Sub - Protected Sub DdlOCVinculaInv_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaVinculacionOC() - End Sub - Private Sub CargaVinculacionOC(Optional CargaInicial As Boolean = False) - 'FILTRAMOS SOLO PENDIENTES POR SURTIR - DTOCGV = DTOCTemp.FiltraParametros("CantidadDisponible > 0", "CveOrdenCompra").Copy - - 'SI PUEDE RECIBIR POR OC Y COMPRA - If UsuarioActual.CveEmpresa.Contiene(119) Then - If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - Select Case DdlOCVinculaInv.SelectedValue.ToEntero - Case 176 - DTOCGV = DTOCGV.FiltraParametros("((EstatusInventario IN (3,5) AND CveTipoPS = 2) OR CveTipoPS = 1) AND CantidadPorAdelantado > 0") - Case 205 - DTOCGV = DTOCGV.FiltraParametros("(EstatusInventario IN (1,2) AND CveTipoPS = 2) OR CveTipoPS = 1") - End Select - End If - End If - - If DTOCGV.Rows.Count = 0 Then - Alert("La orden de compra no tiene nada pendiente por vincular. En caso de ser Entrega Directa por favor verifique el estatus de facturación.", TipoMensaje.MsgAdvertencia) - End If - - CargaGvsOC() - - CargaTotalesOC() - - 'Diferencia permitida $ entre OC y Compra - Dim DiferenciaPermitida = 1 - - 'VINCULACION TOTAL - If CargaInicial And DivTipoCambioOC.Visible = False Then - If LbTotalOC1.Text = LbTotalOC2.Text AndAlso (UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 48, 13, 66, 72, 80, 145)) AndAlso CveCompra <= 0 Then - BtnVincularOCCompleta.Visible = Not DivTipoCambioOC.Visible - Else - BtnVincularOCCompleta.Visible = False - End If - Else - If LbTotalOC1.Text = LbTotalOC2.Text AndAlso (UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 48, 13, 66, 72, 80, 145)) AndAlso CveCompra <= 0 Then - BtnVincularOCCompleta.Visible = Not DivTipoCambioOC.Visible - Else - BtnVincularOCCompleta.Visible = False - End If - End If - - UpOC.Update() - - ' If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(237, 240) Then CargaModalFletesImportaciones() - - End Sub - - Private Sub CargaTipoCentroCostoOC() - If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then - GvOC1.Columns(5).HeaderText = "Sucursal" - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then - GvOC1.Columns(5).HeaderText = "Proyecto" - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then - GvOC1.Columns(5).HeaderText = "Sucursal
Proyecto" - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then - GvOC1.Columns(5).HeaderText = "Proyecto
Sucursal" - End If - End Sub - Private Sub CargaGvsOC() - - 'SI ES MAS DE UNA OC ORDENA POR PRODUCTO - Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) - DTOCGV = If(ArrayCveOC.Length > 1, DTOCGV.FiltraParametros("", "Producto"), DTOCGV) - - CargaTipoCentroCostoOC() - GvOC1.DataSource = DTOCGV - GvOC1.DataBind() - - Dim DTCVEOGV As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) - If DTCVEOGV.Rows.Count > 1 Then - GvOC1.Columns(0).Visible = True - Else - GvOC1.Columns(0).Visible = False - End If - - Dim Cont As Integer = 0 - For Each gvr As GridViewRow In GvOC1.Rows - RegistraScript($"CalculaTotalOCEdit('{gvr.DataKey("PS").Replace("'", "")}', {gvr.DataKey("CantidadDisponible").ToString.ToDouble}, {gvr.FCTextBox("TxtCantidad").ClientID}, {gvr.FCTextBox("TxtPU").ClientID}, {gvr.FCTextBox("TxtTotalOC1").ClientID}, {gvr.DataKey("IEPSPS").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {gvr.DataKey("IVA").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IVA").ClientID},{gvr.DataKey("RetIVA").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1RetIVA").ClientID},{gvr.DataKey("RetISR").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1RetISR").ClientID},{gvr.DataKey("IEPSPS").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IEPSIVA").ClientID},{gvr.DataKey("Descuento")},{gvr.FCHiddenField("HdnOC1Descuento").ClientID},{gvr.DataKey("IVAPorcentaje").ToString.ToDouble},{gvr.DataKey("RetIVAPorcentaje").ToString.ToDouble},{gvr.DataKey("RetISRPorcentaje").ToString.ToDouble},{gvr.DataKey("IEPSPSPorcentaje").ToString.ToDouble},{gvr.DataKey("IEPSPSIVAPorcentaje").ToString.ToDouble});", $"Gv{Cont}") - Cont += 1 - Next - - UpGvOC1.Update() - - TmpDT = TmpDT.FiltraParametros("", "PU") - - - GvOC2.DataSource = TmpDT - GvOC2.DataBind() - UpGvOC2.Update() - End Sub - Protected Sub GvOC1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOC1.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - Dim JSCambiaScript = $"CalculaTotalOCEdit('{e.Row.DBCampo("PS").Replace("'", "")}', {e.Row.DBCampo("CantidadDisponible").ToString.ToDouble}, {e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID}, {e.Row.FCTextBox("TxtTotalOC1").ClientID}, {e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {e.Row.DBCampo("IVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IVA").ClientID},{e.Row.DBCampo("RetIVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetIVA").ClientID},{e.Row.DBCampo("RetISR").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetISR").ClientID},{e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSIVA").ClientID},{e.Row.DBCampo("Descuento")},{e.Row.FCHiddenField("HdnOC1Descuento").ClientID},{e.Row.DBCampo("IVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetIVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetISRPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSIVAPorcentaje").ToString.ToDouble});" - e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"LimitaCantidadOC({e.Row.DBCampo("CantidadDisponible")}, this);{JSCambiaScript}") - e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", JSCambiaScript) - - e.Row.FCTextBox("TxtCantidad").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") - e.Row.FCTextBox("TxtPU").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") - - - RegistraScript(JSCambiaScript) - - - If e.Row.DataKey("FolioREQ").ToString.Trim.Length > 0 Then - Dim LblOC As Label = e.Row.FCLabel("LblOC") - LblOC.Attributes.Add("data-toggle", "tooltip") - LblOC.Attributes.Add("data-placement", "top") - LblOC.Attributes.Add("title", "REQ: " & e.Row.DataKey("FolioREQ").ToString) - End If - - - - If e.Row.DBCampo("CveTipoPS").ToEntero = 2 And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then - Select Case e.Row.DBCampo("EstatusInventario").ToEntero - Case 1 - e.Row.FCLabel("LbEstatusInv").Text = "" - e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Red - Case 2 - e.Row.FCLabel("LbEstatusInv").Text = "" - e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.DarkOrange - Case 3 - e.Row.FCLabel("LbEstatusInv").Text = "" - e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Green - Case Else - e.Row.FCLabel("LbEstatusInv").Text = "ERR" - End Select - ElseIf e.Row.DBCampo("CveTipoPS").ToEntero = 1 And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then - e.Row.FCLabel("LbEstatusInv").Text = "NA" - End If - - If Version = "3.3" Then - CargaPSSAT(e.Row.FCDropDownLost("DdlSATPS")) - If e.Row.DBCampo("CveSATPS").ToEntero > 0 Then - e.Row.FCDropDownLost("DdlSATPS").SelectedValue = e.Row.DBCampo("CveSATPS") - e.Row.FCDropDownLost("DdlSATPS").SelectedText = $"{e.Row.DBCampo("SATClaveProductoServicio")}" - End If - End If - - End If - End Sub - - Private Sub CargaPSSAT(Objeto As ADServerControl.Dropdownlost) - Objeto.setEsWebService(True) - Objeto.ddlWS.Attributes.Add("data-metodo", "getpssat") - End Sub - - Private Sub CargaTotalesOC() - - Dim TotalOC = 0.0D - For Each gvr As GridViewRow In GvOC1.Rows - TotalOC += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal - Next - - 'SUBTOTAL OC - LbSubTotalOC1Mod.Text = (TotalOC + DTOCGV.SUM("Descuento")).FormatoNumero - LbSubTotalOC1.Text = (TotalOC + DTOCGV.SUM("Descuento")).FormatoNumero - - 'SUBTOTAL2 OC - LbSubTotal2OC1Mod.Text = TotalOC.FormatoNumero - LbSubTotal2OC1.Text = TotalOC.FormatoNumero - - 'IVA OC - LbIVAOC1Mod.Text = (DTOCGV.SUM("IVA").ToString.ToDouble + DTOCGV.SUM("IEPSPSIVA").ToString.ToDouble).FormatoNumero - LbIVAOC1.Text = (DTOCGV.SUM("IVA").ToString.ToDouble + DTOCGV.SUM("IEPSPSIVA").ToString.ToDouble).FormatoNumero - - 'DESCUENTO OC - LbDescuentoOC1Mod.Text = DTOCGV.SUM("Descuento").FormatoNumero - LbDescuentoOC1.Text = DTOCGV.SUM("Descuento").FormatoNumero - If LbDescuentoOC1.Text.ToDecimal > 0 Then - TrDescuentosOC1.Visible = True - End If - - 'IEPS OC - LbIEPSOCMod1.Text = DTOCGV.SUM("IEPSPS").FormatoNumero - LbIEPSOC1.Text = DTOCGV.SUM("IEPSPS").FormatoNumero - If LbIEPSOC1.Text.ToDecimal > 0 Then - TrIEPSOC1.Visible = True - End If - - 'RET IVA OC - LblRetIVAOC1Mod.Text = DTOCGV.SUM("RetIVA").ToString.FormatoNumero - LblRetIVAOC1.Text = DTOCGV.SUM("RetIVA").ToString.FormatoNumero - If LblRetIVAOC1.Text.ToDecimal > 0 Then - TrRetIVAOC1.Visible = True - End If - - 'RET ISR OC - LblRetISROC1Mod.Text = DTOCGV.SUM("RetISR").ToString.FormatoNumero - LblRetISROC1.Text = DTOCGV.SUM("RetISR").ToString.FormatoNumero - If LblRetISROC1.Text.ToDecimal > 0 Then - TrRetISROC1.Visible = True - End If - - 'TOTAL OC - TotalOC = TotalOC + LbIVAOC1.Text.ToDecimal + LbIEPSOC1.Text.ToDecimal - LblRetIVAOC1.Text.ToDecimal - LblRetISROC1.Text.ToDecimal - LbTotalOC1.Text = TotalOC.FormatoNumero - LbTotalOC1Mod.Text = TotalOC.FormatoNumero - - 'SUBTOTAL COMPRA - LbSubTotalOC2.Text = TxtSubTotal.Text - - 'SUBTOTAL2 COMPRA - LblSubTotal2OC2.Text = TxtSubTotal2.Text - - 'IVA COMPRA - LbIVAOC2.Text = TxtIVA.Text - - 'IEPS COMPRA - LbIEPSOC2.Text = TxtIEPS.Text - If LbIEPSOC2.Text.ToDecimal > 0 Then - TrIEPSOC2.Visible = True - End If - - 'DESCUENTO COMPRA - LblDescuentoOC2.Text = TxtDescuento.Text - If LblDescuentoOC2.Text.ToDecimal > 0 Then - TrDescuentosOC2.Visible = True - End If - - 'RET IVA COMPRA - LblRetIVAOC2.Text = TxtRetIVA.Text - If LblRetIVAOC2.Text.ToDecimal > 0 Then - TrRetIVAOC2.Visible = True - End If - - 'RET ISR COMPRA - LblRetISROC2.Text = TxtRetISR.Text - If LblRetISROC2.Text.ToDecimal > 0 Then - TrRetISROC2.Visible = True - End If - - 'ANTICIPOS COMPRA - Dim ImporteAnticipo As Decimal = 0 - If ArrAnticipos.Count > 0 Then - For Each Ant As Compras_Compras.Anticipos In ArrAnticipos - ImporteAnticipo += Ant.Importe - Next - End If - - If ImporteAnticipo > 0 Then - TrAnticiposOC.Visible = True - LbAnticiposOC2.Text = ImporteAnticipo.ToString.FormatoNumero - End If - - 'TOTAL COMPRA - LbTotalOC2.Text = (TxtTotal.Text.ToDouble - ImporteAnticipo).FormatoNumero - 'LbTotalOC2.Text = TxtTotal.Text - - - RegistraScript("CalculaTotalesOC();") - - End Sub - Protected Sub BtnVincularOC_Click(sender As Object, e As EventArgs) - 'If DdlOCVinculaInv.SelectedValue.ToEntero = 237 And Not CveFlete > 0 Then Alert("Necesita vincular un flete si selecciona Factura de Flete", TipoMensaje.MsgAdvertencia) : Exit Sub - 'If DdlOCVinculaInv.SelectedValue.ToEntero = 240 And Not CveImportacion > 0 Then Alert("Necesita vincular una Importación si selecciona Factura de Importación", TipoMensaje.MsgAdvertencia) : Exit Sub - + + + Private Sub BtnValesCombustibleVer_Click(sender As Object, e As EventArgs) Handles BtnValesCombustibleVer.Click + + Dim AF As New ClsAF + + If AF.GetValesCombustible(-1, -1, -1, CveProveedor, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, -1, -1) Then + GvVales.DataSource = AF.DtResultados + End If + + AF.Dispose() + GvVales.DataBind() + DivValesCombustible.Visible = True + RegistraScript(String.Format("$('#{0}').modal('show')", DivValesCombustible.ClientID)) + UPPValesCombustible.Update() + End Sub + +#End Region + +#Region " VALES COMBUSTIBLES " + Protected Sub BtnValesVincular_Click(sender As Object, e As EventArgs) + IdVale = New List(Of Integer) + + For Each row As GridViewRow In GvVales.Rows + If row.FCCheckBox("ChkVale").Checked Then + IdVale.Add(row.DataKey("CveVale").ToEntero) + End If + Next + + If IdVale.Count <= 0 Then + Alert("Debe elegir por lo menos un vale de combustible. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Else + Alert("Los vales selecciondos están listos para vincular") + RegistraScript(String.Format("$('#{0}').modal('hide')", DivValesCombustible.ClientID)) + 'For Each cve In IdVale + ' Alert(cve.ToString) + 'Next + End If + End Sub +#End Region + +#Region " VINCULAR OC " + Private Sub InicializaOC() + 'BORRAR OC + 'TabOC.Visible = False + + TabOC.Visible = False + + EmpresasOC = New List(Of Integer) + + ''TODAS LAS EMPRESAS LO TIENEN Y LA 66 SOLO LOS USUARIOS DE ABAJO - EMPRESA QUE ESTE EN LA LISTA NO TENDRA NUEVO ESQUEMA + 'If UsuarioActual.CveEmpresa = 66 AndAlso Not UsuarioActual.CveUsuario.Contiene(1434, 1436, 1337, 1440) Then + ' EmpresasOC.Add(UsuarioActual.CveEmpresa) + 'End If + + 'If Not EmpresasOC.Contains(UsuarioActual.CveEmpresa) Then + TabOC.Visible = True + 'Else + 'TabOC.Visible = True + 'End If + + If Not UsuarioActual.TienePermisoProceso(242) Then + DdlOCVinculaInv.Items.RemoveAt(2) + DdlOCVinculaInv.Items.RemoveAt(3) + End If + + End Sub + Protected Sub BtnBuscarOC_Click(sender As Object, e As EventArgs) Handles BtnBuscarOC.Click + PopUpOC = False + CargaOC() + End Sub + Protected Sub CargaVOC(sender As Object, e As EventArgs) + PopUpOC = True + CargaOC() + End Sub + Private Sub CargaOC() + Dim EntregaDirecta = 0 + DivOCSolicitudAnticipo.Visible = False + DivOCSolicitudAnticipoModal.Visible = False + + If CveProveedor <= 0 Then + Alert("Debe de Seleccionar un proveedor") + Exit Sub + End If + + 'BANDERA DE SURTIDO + If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then + GvOC1.Columns(1).Visible = True + End If + + Dim CvesOC = "" + + + If PopUpOC Then + CvesOC = HdnVCveOC.Value + End If + + HdnVCveOC.Value = "" + HdnCveEstatusOC.Value = "" + + Dim OC As New ClsOC + If PopUpOC Then + Dim ArrayCveOC As String() = CvesOC.Split(New Char() {","c}) + For i As Integer = 0 To ArrayCveOC.Count - 1 + If OC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, ArrayCveOC(i).ToEntero, CveProveedor, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then + If OC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) + HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) + EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + End If + End If + Next + Else + Dim TextoErrorOC = "" + Dim ArrayCveOC As String() = TxtOC.Text.Split(New Char() {","c}) + For i As Integer = 0 To ArrayCveOC.Count - 1 + If OC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, -1, CveProveedor, ArrayCveOC(i).ToEntero, -1, -1, UsuarioActual.CveEmpresa, -1) Then + If OC.DtResultados.Rows.Count > 1 Then + TextoErrorOC += $"
El folio {ArrayCveOC(i).ToEntero} no se pudo identificar." + End If + If OC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Or DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + HdnVCveOC.Value += String.Format("{0}{1}", If(HdnVCveOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveOrdenCompra").ToString) + HdnCveEstatusOC.Value += String.Format("{0}{1}", If(HdnCveEstatusOC.Value <> "", ",", ""), OC.DtResultados.Rows(0)("CveEstatusSiguiente").ToString) + EntregaDirecta += If(OC.DtResultados.Rows(0)("EntregaDirecta").ToString = "True", 1, 0) + End If + End If + Next + If TextoErrorOC <> "" Then + Alert($"Las siguientes Ordenes de Compra no se pudieron vincular automaticamente:
{TextoErrorOC}

Sera necesario vincular de manera manual mediante busqueda (lupia).", TipoMensaje.MsgAdvertencia) + TxtOC.Text = "" + Exit Sub + End If + End If + OC.Dispose() + PopUpOC = False + + + If HdnVCveOC.Value <> "" Then + If HdnCveEstatusOC.Value = "" Then + Alert("No se tiene especificado el siguiente estatus de la Orden(es) de Compra. Por favor verifique los estatus y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + VinculaOC() + + If EntregaDirecta > 0 Then + Alert("Se identificó una Orden de Compra con entrega directa, por lo cual no se podra recibir en almacén desde este modulo, para esto es necesario recibir la mercancía desde la Orden de Compra.", TipoMensaje.MsgAdvertencia) + TabAlmacen.Visible = False + DivOCEntregaDirecta.Visible = True + End If + + BtnGuardar.Enabled = False + TxtOC.Enabled = False + ImgBtnBuscarOC.Enabled = False + UpFacturar.Update() + + Else + Alert("No se encontro ninguna Orden de Compra con el folio especificado.", TipoMensaje.MsgAdvertencia) + End If + + UPPOC.Update() + UpPS.Update() + End Sub + Protected Sub BtnVOC_Click(sender As Object, e As EventArgs) + VinculaOC() + End Sub + Private Sub VinculaOC() + If TxtOC.Text <> "" Then + + 'VARIABLES + Dim TextoObservaciones = "" + LtOCPromocion.Text = "" + IvaAcumulado = 0 + DTOCTemp = New DataTable + + 'SI NO ES UNA COMPRA REGISTRADA = ENABLE FALSE TAB GENERALES, ACTIVE TAB OC + If Not CveCompra > 0 Then + TabGenerales.Enabled = False + TAB.ActiveTabIndex = 2 + UpTabs.Update() + End If + + 'CARGAMOS LOS DATOS DE LAS OC + Dim ObjOC As New ClsOC + Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) + Dim FoliosOCAnticipo = "", FoliosOCAnticipoIE = "" + Dim StrPromos As New StringBuilder + + For Each CveOCItem As String In ArrayCveOC.Distinct + If ObjOC.GetOrdenesDetalle(CveOCItem.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then + If IsNothing(DTOCTemp) Then + DTOCTemp = ObjOC.DtResultados.Copy + Else + DTOCTemp.Merge(ObjOC.DtResultados) + End If + + IvaAcumulado += ObjOC.DtResultados.Rows(0)("IVA").ToString.ToDouble + TextoObservaciones += ObjOC.DtResultados.Rows(0)("Descripcion").ToString + + If ObjOC.DtResultados.Rows.Count > 0 Then + + ''MONEDA DIFERENTE + If ObjOC.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero <> DdlMoneda.SelectedValue.ToEntero Then + DivTipoCambioOC.Visible = True + TxtTipoCambioOC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString + BtnVincularOCCompleta.Visible = False + BtnVincularOC.Visible = False + End If + + ''SOLICITUD DE ANTICIPO + If ObjOC.DtResultados.Rows(0)("CveIEAnticipo").ToString.ToEntero > 0 Then + FoliosOCAnticipo += $"{ObjOC.DtResultados.Rows(0)("FolioOC").ToString}," + FoliosOCAnticipoIE += $"{ObjOC.DtResultados.Rows(0)("FolioIEAnticipo").ToString}," + DivOCSolicitudAnticipo.Visible = True + DivOCSolicitudAnticipoModal.Visible = True + End If + + 'PROMOCIONES + Dim Promocion = ObjOC.DtResultados.Rows(0)("Promocion").ToString + If Not String.IsNullOrEmpty(Promocion) Then + Dim FolioOC = ObjOC.DtResultados.Rows(0)("FolioOC").ToString + StrPromos.Append($"OC #{FolioOC} {Promocion}
") + StrPromos.AppendLine() + End If + End If + + Else + Alert("Ocurrio un Error al cargar la(s) Orden(es) de Compra", TipoMensaje.MsgError) + If DTOCTemp IsNot Nothing Then DTOCTemp.Rows.Clear() + TextoObservaciones = "" + Exit Sub + End If + Next + ObjOC.Dispose() + + 'MOVIMIENTOS DE ALMACÉN + Dim ObjInventarios As New ClsInventarios + Dim FoliosOCAlmacen = "" + For Each CveOCItem As String In ArrayCveOC.Distinct + If ObjInventarios.GetMovimientosOC(CveOCItem.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjInventarios.DtResultados.Rows.Count > 0 Then + FoliosOCAlmacen = $"{ObjInventarios.DtResultados.FiltroPrimeroValor("FolioOC")}," + End If + Else + Alert("Ocurrió un error al cargar los movimientos de almacén de la orden de compra", TipoMensaje.MsgError) + ObjInventarios.Dispose() + Exit Sub + End If + Next + ObjInventarios.Dispose() + If FoliosOCAlmacen.Length > 0 Then + DivOCAlmacen.Visible = True + LtOCAlmacen.Text = FoliosOCAlmacen.Substring(0, FoliosOCAlmacen.Length - 1) + End If + + 'SI PUEDE RECIBIR POR OC Y COMPRA + If UsuarioActual.CveEmpresa.Contiene(119) Then + If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then + DivOCVinculaInv.Visible = True + End If + End If + + + 'TIPO CAMBIO + If CveCompra > 0 Then + DivTipoCambioOC.Visible = False + End If + + DTOCTemp.Columns.Add("PUTC", GetType(Double)) + DTOCTemp.Columns.Add("TotalTC", GetType(Double)) + DTOCTemp.Columns.Add("DescuentoTC", GetType(Double)) + DTOCTemp.Columns.Add("IVATC", GetType(Double)) + DTOCTemp.Columns.Add("IEPSPSTC", GetType(Double)) + DTOCTemp.Columns.Add("IEPSPSIVATC", GetType(Double)) + DTOCTemp.Columns.Add("RetIVATC", GetType(Double)) + DTOCTemp.Columns.Add("RetISRTC", GetType(Double)) + DTOCTemp.Columns.Add("FolioAlmacen", GetType(String)) + For Each Dr As DataRow In DTOCTemp.Rows + Dr("PUTC") = Dr("Importe") + Dr("DescuentoTC") = Dr("Descuento") + Dr("IVATC") = Dr("IVA") + Dr("IEPSPSTC") = Dr("IEPSPS") + Dr("IEPSPSIVATC") = Dr("IEPSPSIVA") + Dr("RetIVATC") = Dr("RetIVA") + Dr("RetISRTC") = Dr("RetISR") + Dr("TotalTC") = Dr("ImporteAjustadoDescuento") + + '[IPP] - JAMEntregaAdelantado | AJUSTE DE CANITDAD POR RECIBIR EN BASE A SALDOS DE INV-COMPRAS + 'If UsuarioActual.CveUsuario = 100 Then + 'If Dr("CveTipoPS").ToString.ToEntero = 2 And UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then + ' Dr("CantidadDisponible") = If(Dr("CantidadDisponible").ToString.ToDouble > Dr("CantidadPendienteVincular").ToString.ToDouble, Dr("CantidadPendienteVincular"), Dr("CantidadDisponible")) + 'End If + 'End If + Next + + 'DESCRIPCION DE OC CUANDO NO ES COMPRA REGISTRADA + If Not CveCompra > 0 Then TxtDescripcion.Text = TextoObservaciones + + 'SOLICITUD DE ANTICIPO + If DivOCSolicitudAnticipo.Visible And FoliosOCAnticipo.Length > 0 Then + LtSolicitudAnticipoFoliosOC.Text = $"La(s) siguiente(s) OC: {FoliosOCAnticipo.Substring(0, FoliosOCAnticipo.Length - 1)}. tienen vinculado un anticipo" + LtSolicitudAnticipoFoliosIE.Text = $" {FoliosOCAnticipoIE.Substring(0, FoliosOCAnticipoIE.Length - 1)}" + End If + + 'PROMOCIONES + LtOCPromocion.Text = StrPromos.ToString + If LtOCPromocion.Text.Length > 0 And UsuarioActual.CveEmpresa = 119 Then + DivOCPromocion.Visible = True + End If + + 'CARGA DATOS DE OC + CargaVinculacionOC(True) + + End If + End Sub + Protected Sub DdlOCVinculaInv_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaVinculacionOC() + End Sub + Private Sub CargaVinculacionOC(Optional CargaInicial As Boolean = False) + 'FILTRAMOS SOLO PENDIENTES POR SURTIR + DTOCGV = DTOCTemp.FiltraParametros("CantidadDisponible > 0", "CveOrdenCompra").Copy + + 'SI PUEDE RECIBIR POR OC Y COMPRA + If UsuarioActual.CveEmpresa.Contiene(119) Then + If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then + Select Case DdlOCVinculaInv.SelectedValue.ToEntero + Case 176 + DTOCGV = DTOCGV.FiltraParametros("((EstatusInventario IN (3,5) AND CveTipoPS = 2) OR CveTipoPS = 1)") + Case 205 + DTOCGV = DTOCGV.FiltraParametros("(EstatusInventario IN (1,2) AND CveTipoPS = 2) OR CveTipoPS = 1") + End Select + End If + End If + + If DTOCGV.Rows.Count = 0 Then + Alert("La orden de compra no tiene nada pendiente por vincular. En caso de ser Entrega Directa por favor verifique el estatus de facturación.", TipoMensaje.MsgAdvertencia) + End If + + CargaGvsOC() + + CargaTotalesOC() + + 'Diferencia permitida $ entre OC y Compra + Dim DiferenciaPermitida = 1 + + 'VINCULACION TOTAL + If CargaInicial And DivTipoCambioOC.Visible = False Then + If LbTotalOC1.Text = LbTotalOC2.Text AndAlso (UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 48, 13, 66, 72, 80, 145)) AndAlso CveCompra <= 0 Then + BtnVincularOCCompleta.Visible = Not DivTipoCambioOC.Visible + Else + BtnVincularOCCompleta.Visible = False + End If + Else + If LbTotalOC1.Text = LbTotalOC2.Text AndAlso (UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 48, 13, 66, 72, 80, 145)) AndAlso CveCompra <= 0 Then + BtnVincularOCCompleta.Visible = Not DivTipoCambioOC.Visible + Else + BtnVincularOCCompleta.Visible = False + End If + End If + + UpOC.Update() + + ' If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(237, 240) Then CargaModalFletesImportaciones() + + End Sub + + Private Sub CargaTipoCentroCostoOC() + If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then + GvOC1.Columns(5).HeaderText = "Sucursal" + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then + GvOC1.Columns(5).HeaderText = "Proyecto" + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then + GvOC1.Columns(5).HeaderText = "Sucursal
Proyecto" + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then + GvOC1.Columns(5).HeaderText = "Proyecto
Sucursal" + End If + End Sub + Private Sub CargaGvsOC() + + 'SI ES MAS DE UNA OC ORDENA POR PRODUCTO + Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c}) + DTOCGV = If(ArrayCveOC.Length > 1, DTOCGV.FiltraParametros("", "Producto"), DTOCGV) + + CargaTipoCentroCostoOC() + GvOC1.DataSource = DTOCGV + GvOC1.DataBind() + + Dim DTCVEOGV As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) + If DTCVEOGV.Rows.Count > 1 Then + GvOC1.Columns(0).Visible = True + Else + GvOC1.Columns(0).Visible = False + End If + + Dim Cont As Integer = 0 + For Each gvr As GridViewRow In GvOC1.Rows + RegistraScript($"CalculaTotalOCEdit('{gvr.DataKey("PS").Replace("'", "")}', {gvr.DataKey("CantidadDisponible").ToString.ToDouble}, {gvr.FCTextBox("TxtCantidad").ClientID}, {gvr.FCTextBox("TxtPU").ClientID}, {gvr.FCTextBox("TxtTotalOC1").ClientID}, {gvr.DataKey("IEPSPS").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {gvr.DataKey("IVA").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IVA").ClientID},{gvr.DataKey("RetIVA").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1RetIVA").ClientID},{gvr.DataKey("RetISR").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1RetISR").ClientID},{gvr.DataKey("IEPSPS").ToString.ToDouble},{gvr.FCHiddenField("HdnOC1IEPSIVA").ClientID},{gvr.DataKey("Descuento")},{gvr.FCHiddenField("HdnOC1Descuento").ClientID},{gvr.DataKey("IVAPorcentaje").ToString.ToDouble},{gvr.DataKey("RetIVAPorcentaje").ToString.ToDouble},{gvr.DataKey("RetISRPorcentaje").ToString.ToDouble},{gvr.DataKey("IEPSPSPorcentaje").ToString.ToDouble},{gvr.DataKey("IEPSPSIVAPorcentaje").ToString.ToDouble});", $"Gv{Cont}") + Cont += 1 + Next + + UpGvOC1.Update() + + TmpDT = TmpDT.FiltraParametros("", "PU") + + + GvOC2.DataSource = TmpDT + GvOC2.DataBind() + UpGvOC2.Update() + End Sub + Protected Sub GvOC1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOC1.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim JSCambiaScript = $"CalculaTotalOCEdit('{e.Row.DBCampo("PS").Replace("'", "")}', {e.Row.DBCampo("CantidadDisponible").ToString.ToDouble}, {e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID}, {e.Row.FCTextBox("TxtTotalOC1").ClientID}, {e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSImporte").ClientID}, {e.Row.DBCampo("IVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IVA").ClientID},{e.Row.DBCampo("RetIVA").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetIVA").ClientID},{e.Row.DBCampo("RetISR").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1RetISR").ClientID},{e.Row.DBCampo("IEPSPS").ToString.ToDouble},{e.Row.FCHiddenField("HdnOC1IEPSIVA").ClientID},{e.Row.DBCampo("Descuento")},{e.Row.FCHiddenField("HdnOC1Descuento").ClientID},{e.Row.DBCampo("IVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetIVAPorcentaje").ToString.ToDouble},{e.Row.DBCampo("RetISRPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSPorcentaje").ToString.ToDouble},{e.Row.DBCampo("IEPSPSIVAPorcentaje").ToString.ToDouble});" + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"LimitaCantidadOC({e.Row.DBCampo("CantidadDisponible")}, this);{JSCambiaScript}") + e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", JSCambiaScript) + + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") + e.Row.FCTextBox("TxtPU").Attributes.Add("onblur", $"ValidaImporteCero('{e.Row.DBCampo("PS").Replace("'", "")}',{e.Row.FCTextBox("TxtCantidad").ClientID}, {e.Row.FCTextBox("TxtPU").ClientID});") + + + RegistraScript(JSCambiaScript) + + + If e.Row.DataKey("FolioREQ").ToString.Trim.Length > 0 Then + Dim LblOC As Label = e.Row.FCLabel("LblOC") + LblOC.Attributes.Add("data-toggle", "tooltip") + LblOC.Attributes.Add("data-placement", "top") + LblOC.Attributes.Add("title", "REQ: " & e.Row.DataKey("FolioREQ").ToString) + End If + + + + If e.Row.DBCampo("CveTipoPS").ToEntero = 2 And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then + Select Case e.Row.DBCampo("EstatusInventario").ToEntero + Case 1 + e.Row.FCLabel("LbEstatusInv").Text = "" + e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Red + Case 2 + e.Row.FCLabel("LbEstatusInv").Text = "" + e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.DarkOrange + Case 3 + e.Row.FCLabel("LbEstatusInv").Text = "" + e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Green + Case Else + e.Row.FCLabel("LbEstatusInv").Text = "ERR" + End Select + ElseIf e.Row.DBCampo("CveTipoPS").ToEntero = 1 And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then + e.Row.FCLabel("LbEstatusInv").Text = "NA" + End If + + If Version = "3.3" Then + CargaPSSAT(e.Row.FCDropDownLost("DdlSATPS")) + If e.Row.DBCampo("CveSATPS").ToEntero > 0 Then + e.Row.FCDropDownLost("DdlSATPS").SelectedValue = e.Row.DBCampo("CveSATPS") + e.Row.FCDropDownLost("DdlSATPS").SelectedText = $"{e.Row.DBCampo("SATClaveProductoServicio")}" + End If + End If + + End If + End Sub + + Private Sub CargaPSSAT(Objeto As ADServerControl.Dropdownlost) + Objeto.setEsWebService(True) + Objeto.ddlWS.Attributes.Add("data-metodo", "getpssat") + End Sub + + Private Sub CargaTotalesOC() + + Dim TotalOC = 0.0D + For Each gvr As GridViewRow In GvOC1.Rows + TotalOC += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal + Next + + 'SUBTOTAL OC + LbSubTotalOC1Mod.Text = (TotalOC + DTOCGV.SUM("Descuento")).FormatoNumero + LbSubTotalOC1.Text = (TotalOC + DTOCGV.SUM("Descuento")).FormatoNumero + + 'SUBTOTAL2 OC + LbSubTotal2OC1Mod.Text = TotalOC.FormatoNumero + LbSubTotal2OC1.Text = TotalOC.FormatoNumero + + 'IVA OC + LbIVAOC1Mod.Text = (DTOCGV.SUM("IVA").ToString.ToDouble + DTOCGV.SUM("IEPSPSIVA").ToString.ToDouble).FormatoNumero + LbIVAOC1.Text = (DTOCGV.SUM("IVA").ToString.ToDouble + DTOCGV.SUM("IEPSPSIVA").ToString.ToDouble).FormatoNumero + + 'DESCUENTO OC + LbDescuentoOC1Mod.Text = DTOCGV.SUM("Descuento").FormatoNumero + LbDescuentoOC1.Text = DTOCGV.SUM("Descuento").FormatoNumero + If LbDescuentoOC1.Text.ToDecimal > 0 Then + TrDescuentosOC1.Visible = True + End If + + 'IEPS OC + LbIEPSOCMod1.Text = DTOCGV.SUM("IEPSPS").FormatoNumero + LbIEPSOC1.Text = DTOCGV.SUM("IEPSPS").FormatoNumero + If LbIEPSOC1.Text.ToDecimal > 0 Then + TrIEPSOC1.Visible = True + End If + + 'RET IVA OC + LblRetIVAOC1Mod.Text = DTOCGV.SUM("RetIVA").ToString.FormatoNumero + LblRetIVAOC1.Text = DTOCGV.SUM("RetIVA").ToString.FormatoNumero + If LblRetIVAOC1.Text.ToDecimal > 0 Then + TrRetIVAOC1.Visible = True + End If + + 'RET ISR OC + LblRetISROC1Mod.Text = DTOCGV.SUM("RetISR").ToString.FormatoNumero + LblRetISROC1.Text = DTOCGV.SUM("RetISR").ToString.FormatoNumero + If LblRetISROC1.Text.ToDecimal > 0 Then + TrRetISROC1.Visible = True + End If + + 'TOTAL OC + TotalOC = TotalOC + LbIVAOC1.Text.ToDecimal + LbIEPSOC1.Text.ToDecimal - LblRetIVAOC1.Text.ToDecimal - LblRetISROC1.Text.ToDecimal + LbTotalOC1.Text = TotalOC.FormatoNumero + LbTotalOC1Mod.Text = TotalOC.FormatoNumero + + 'SUBTOTAL COMPRA + LbSubTotalOC2.Text = TxtSubTotal.Text + + 'SUBTOTAL2 COMPRA + LblSubTotal2OC2.Text = TxtSubTotal2.Text + + 'IVA COMPRA + LbIVAOC2.Text = TxtIVA.Text + + 'IEPS COMPRA + LbIEPSOC2.Text = TxtIEPS.Text + If LbIEPSOC2.Text.ToDecimal > 0 Then + TrIEPSOC2.Visible = True + End If + + 'DESCUENTO COMPRA + LblDescuentoOC2.Text = TxtDescuento.Text + If LblDescuentoOC2.Text.ToDecimal > 0 Then + TrDescuentosOC2.Visible = True + End If + + 'RET IVA COMPRA + LblRetIVAOC2.Text = TxtRetIVA.Text + If LblRetIVAOC2.Text.ToDecimal > 0 Then + TrRetIVAOC2.Visible = True + End If + + 'RET ISR COMPRA + LblRetISROC2.Text = TxtRetISR.Text + If LblRetISROC2.Text.ToDecimal > 0 Then + TrRetISROC2.Visible = True + End If + + 'ANTICIPOS COMPRA + Dim ImporteAnticipo As Decimal = 0 + If ArrAnticipos.Count > 0 Then + For Each Ant As Compras_Compras.Anticipos In ArrAnticipos + ImporteAnticipo += Ant.Importe + Next + End If + + If ImporteAnticipo > 0 Then + TrAnticiposOC.Visible = True + LbAnticiposOC2.Text = ImporteAnticipo.ToString.FormatoNumero + End If + + 'TOTAL COMPRA + LbTotalOC2.Text = (TxtTotal.Text.ToDouble - ImporteAnticipo).FormatoNumero + 'LbTotalOC2.Text = TxtTotal.Text + + + RegistraScript("CalculaTotalesOC();") + + End Sub + Protected Sub BtnVincularOC_Click(sender As Object, e As EventArgs) + 'If DdlOCVinculaInv.SelectedValue.ToEntero = 237 And Not CveFlete > 0 Then Alert("Necesita vincular un flete si selecciona Factura de Flete", TipoMensaje.MsgAdvertencia) : Exit Sub + 'If DdlOCVinculaInv.SelectedValue.ToEntero = 240 And Not CveImportacion > 0 Then Alert("Necesita vincular una Importación si selecciona Factura de Importación", TipoMensaje.MsgAdvertencia) : Exit Sub + Dim SubTotalGV = 0.0D - Dim Amortizacion As Decimal = TmpDT.SUMD("Total") - If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then - Amortizacion = TmpDT.SUMD("ImporteSinImpuestos") - End If - Dim SubTotalCompra As Decimal = Amortizacion - Dim DiferenciaPermitida = 1 - Dim Cont = 0 - For Each gvr As GridViewRow In GvOC1.Rows - SubTotalGV += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal - If Cont = 0 Then DdlProveedorSucursal.SelectedValueExist(gvr.DataKey("CveProveedorSucursal").ToEntero()) - Cont = 1 - Next - - If Math.Abs(SubTotalGV - SubTotalCompra) < DiferenciaPermitida Then - LbSubTotalDif.Visible = False - Vinculacion() - ElseIf Math.Abs(SubTotalGV - (SubTotalCompra - LbAnticiposOC2.Text.ToDecimal)) < DiferenciaPermitida Then - LbSubTotalDif.Visible = False - Vinculacion() - ElseIf Math.Abs(LbTotalOC1.Text.ToDecimal - (LbTotalOC2.Text.ToDecimal)) < DiferenciaPermitida Then - LbSubTotalDif.Visible = False - Vinculacion() - ElseIf Math.Abs(LbSubTotalOC2.Text.ToDecimal - (LbSubTotalOC1.Text.ToDecimal - LbAnticiposOC2.Text.ToDecimal)) < DiferenciaPermitida Then - LbSubTotalDif.Visible = False - Vinculacion() - Else - LbSubTotalDif.Visible = True - LbSubTotalDif.Text = (SubTotalCompra - SubTotalGV).FormatoNumero - Alert("Los SubTotales de la vinculación no coinciden. Rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia,,) - RegistraScript("CalculaTotalesOC();") - End If - - UpEstatus.Update() - End Sub - Protected Sub BtnVincularOCCompleta_Click(sender As Object, e As EventArgs) - Vinculacion(True) - End Sub - Private Sub Vinculacion(Optional VinculacionCompleta As Boolean = False) - - - 'SI PUEDE RECIBIR POR OC Y COMPRA - If UsuarioActual.CveEmpresa.Contiene(119) Then - If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - If DdlOCVinculaInv.SelectedValue.ToEntero <= 0 Then - Alert("El campo Tipo de recepción almacén es necesario. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If - - If Math.Abs(HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal) > 0.05 AndAlso UsuarioActual.CveEmpresa.Contiene(119) Then - Alert($"Hay una diferencia de IEPS entre la factura y la OC. Dif: {HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'PSCodigo DE XML IP - Dim DtTemporalXML = TmpDT.Copy - Dim IndexTmpOriginal = 0 - - 'Borramos el TmpDT - CreaDTCompras() - - 'Iteramos el GridView de la OC - Dim dr As DataRow - Dim Index = 0 - Dim MensajeCostoCero As New StringBuilder - Dim TotalRows As Integer = 0 - For Each gvr As GridViewRow In GvOC1.Rows - If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then - TotalRows += 1 - End If + Dim Amortizacion As Decimal = TmpDT.SUMD("Total") + If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then + Amortizacion = TmpDT.SUMD("ImporteSinImpuestos") + End If + Dim SubTotalCompra As Decimal = Amortizacion + Dim DiferenciaPermitida = 1 + Dim Cont = 0 + For Each gvr As GridViewRow In GvOC1.Rows + SubTotalGV += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal + If Cont = 0 Then DdlProveedorSucursal.SelectedValueExist(gvr.DataKey("CveProveedorSucursal").ToEntero()) + Cont = 1 + Next + + If Math.Abs(SubTotalGV - SubTotalCompra) < DiferenciaPermitida Then + LbSubTotalDif.Visible = False + Vinculacion() + ElseIf Math.Abs(SubTotalGV - (SubTotalCompra - LbAnticiposOC2.Text.ToDecimal)) < DiferenciaPermitida Then + LbSubTotalDif.Visible = False + Vinculacion() + ElseIf Math.Abs(LbTotalOC1.Text.ToDecimal - (LbTotalOC2.Text.ToDecimal)) < DiferenciaPermitida Then + LbSubTotalDif.Visible = False + Vinculacion() + ElseIf Math.Abs(LbSubTotalOC2.Text.ToDecimal - (LbSubTotalOC1.Text.ToDecimal - LbAnticiposOC2.Text.ToDecimal)) < DiferenciaPermitida Then + LbSubTotalDif.Visible = False + Vinculacion() + Else + LbSubTotalDif.Visible = True + LbSubTotalDif.Text = (SubTotalCompra - SubTotalGV).FormatoNumero + Alert("Los SubTotales de la vinculación no coinciden. Rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia,,) + RegistraScript("CalculaTotalesOC();") + End If + + UpEstatus.Update() + End Sub + Protected Sub BtnVincularOCCompleta_Click(sender As Object, e As EventArgs) + Vinculacion(True) + End Sub + Private Sub Vinculacion(Optional VinculacionCompleta As Boolean = False) + + + 'SI PUEDE RECIBIR POR OC Y COMPRA + If UsuarioActual.CveEmpresa.Contiene(119) Then + If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then + If DdlOCVinculaInv.SelectedValue.ToEntero <= 0 Then + Alert("El campo Tipo de recepción almacén es necesario. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + + If Math.Abs(HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal) > 0.05 AndAlso UsuarioActual.CveEmpresa.Contiene(119) Then + Alert($"Hay una diferencia de IEPS entre la factura y la OC. Dif: {HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal}", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'PSCodigo DE XML IP + Dim DtTemporalXML = TmpDT.Copy + Dim IndexTmpOriginal = 0 + + 'Borramos el TmpDT + CreaDTCompras() + + 'Iteramos el GridView de la OC + Dim dr As DataRow + Dim Index = 0 + Dim MensajeCostoCero As New StringBuilder + Dim TotalRows As Integer = 0 + For Each gvr As GridViewRow In GvOC1.Rows + If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then + TotalRows += 1 + End If Next Dim TieneAmortizacion As Boolean = False @@ -14995,921 +15009,921 @@ Partial Class Compras_Compras TieneAmortizacion = True End If - For Each gvr As GridViewRow In GvOC1.Rows - If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then - dr = DTOCGV.Rows(gvr.RowIndex) - - Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal 'dr("Cantidad").ToString.ToDouble - Dim CantidadF As Decimal = gvr.DataKey("CantidadF").ToString.ToDecimal 'dr("Cantidad").ToString.ToDouble - Dim CveUM As Integer = dr("CveUM").ToString.ToEntero - Dim UM As String = dr("UM").ToString - Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero - Dim Clasificacion As String = dr("Clasificacion").ToString - Dim CvePS As Integer = dr("CvePS").ToString.ToEntero - Dim PS As String = dr("PS").ToString - Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero - Dim CveSubProyectoContrato As String = dr("CveSubProyecto").ToString - Dim CveProyecto As String = dr("CveProyecto").ToString - Dim SubProyecto As String = dr("SubProyecto").ToString - Dim Proyecto As String = dr("Proyecto").ToString - Dim Obs As String = dr("Obs").ToString - Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal - Dim Total As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Math.Round((gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) - (TxtDescuento.Text.ToDouble / TotalRows).ToDecimal, 2), gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal) - 'Dim Total As Decimal = gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal - 'Dim IVA As Decimal = gvr.FCHiddenField("HdnOC1IVA").Value.ToDecimal - 'Dim RetIVA As Double = gvr.FCHiddenField("HdnOC1RetIVA").Value.ToDecimal - 'Dim RetISR As Double = gvr.FCHiddenField("HdnOC1RetISR").Value.ToDecimal - 'Dim IEPSPS As Double = gvr.FCHiddenField("HdnOC1IEPSImporte").Value.ToDecimal - 'Dim IEPSPSIVA As Double = gvr.FCHiddenField("HdnOC1IEPSIVA").Value.ToDecimal - Dim IVA As Decimal = dr("IVAPorcentaje").ToString.ToDecimal - Dim RetIVA As Double = dr("RetIVAPorcentaje").ToString.ToDecimal - Dim RetISR As Double = dr("RetISRPorcentaje").ToString.ToDecimal - Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDecimal - Dim IEPSPSIVA As Double = dr("IEPSPSIVAPorcentaje").ToString.ToDecimal - Dim Descuento As Double = If(TieneAmortizacion, TxtDescuento.Text.ToDouble / TotalRows, gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal) - 'Dim Descuento As Double = gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal - Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero - Dim EntregaDirecta As Integer = dr("EntregaDirecta").ToString.ToEntero - Dim CveSATPS As Integer = gvr.FCDropDownLost("DdlSATPS").SelectedValue.ToEntero - Dim CveTipoGasto As Integer = -1 - Dim TipoGasto As String = "" - - '[IPP] PROVISIONAL PARA TIPO GASTO - If GlobalDTTiposGastos(UsuarioActual.CveEmpresa) IsNot Nothing AndAlso GlobalDTTiposGastos(UsuarioActual.CveEmpresa).Rows.Count = 1 Then - Dim DrTipoGasto = GlobalDTTiposGastos(UsuarioActual.CveEmpresa).FiltroPrimero("") - If DrTipoGasto IsNot Nothing Then - CveTipoGasto = DrTipoGasto("CveTipoGasto").ToString.ToEntero - TipoGasto = DrTipoGasto("TipoGasto").ToString - End If - End If - - AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle, False, CantidadF:=CantidadF, EntregaDirecta:=EntregaDirecta, CveSATPS:=CveSATPS, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) - - 'CARGA PE - Index = TmpDT.Rows.Count - 1 - TmpDT.Rows(Index)("CvePresupuestoEgreso") = dr("CvePresupuestoEgreso").ToString.ToEntero - TmpDT.Rows(Index)("CveProgramaOperativo") = dr("CveProgramaOperativo").ToString.ToEntero - TmpDT.Rows(Index)("CveUnidadAdministrativa") = dr("CveUnidadAdministrativa").ToString.ToEntero - TmpDT.Rows(Index)("CveFuenteFinanciamiento") = dr("CveFuenteFinanciamiento").ToString.ToEntero - TmpDT.Rows(Index)("CveTipoGastoAC") = dr("CveTipoGasto").ToString.ToEntero - TmpDT.Rows(Index)("CveClasificacionOG") = dr("CveClasificacionOG").ToString.ToEntero - - 'TmpDT.Rows(Index)("PSCodigo") = DtTemporalXML.Rows(IndexTmpOriginal)("PSCodigo") - TmpDT.Rows(Index)("PSCodigo") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("PSCodigo", "").ToString - - Dim CveAF As String = dr("CveActivoFijo").ToString - If CveAF <> "" AndAlso CveAF <> "-1" Then - TmpDT.Rows(Index)("CveActivoFijo") = CveAF.ToEntero - TmpDT.Rows(Index)("CodAF") = dr("CodigoAF").ToString - TmpDT.Rows(Index)("TipoAF") = 1 - End If - 'actualizo los movimientos registrados - DTOCGV.Rows(gvr.RowIndex)("CantidadDisponible") = Cantidad - DTOCGV.Rows(gvr.RowIndex)("Importe") = PU - DTOCGV.Rows(gvr.RowIndex)("Total") = Total - - End If - IndexTmpOriginal += 1 - Next - - AddPS2(False) - - 'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE + For Each gvr As GridViewRow In GvOC1.Rows + If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then + dr = DTOCGV.Rows(gvr.RowIndex) + + Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal 'dr("Cantidad").ToString.ToDouble + Dim CantidadF As Decimal = gvr.DataKey("CantidadF").ToString.ToDecimal 'dr("Cantidad").ToString.ToDouble + Dim CveUM As Integer = dr("CveUM").ToString.ToEntero + Dim UM As String = dr("UM").ToString + Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = dr("Clasificacion").ToString + Dim CvePS As Integer = dr("CvePS").ToString.ToEntero + Dim PS As String = dr("PS").ToString + Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero + Dim CveSubProyectoContrato As String = dr("CveSubProyecto").ToString + Dim CveProyecto As String = dr("CveProyecto").ToString + Dim SubProyecto As String = dr("SubProyecto").ToString + Dim Proyecto As String = dr("Proyecto").ToString + Dim Obs As String = dr("Obs").ToString + Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal + Dim Total As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Math.Round((gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) - (TxtDescuento.Text.ToDouble / TotalRows).ToDecimal, 2), gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal) + 'Dim Total As Decimal = gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal + 'Dim IVA As Decimal = gvr.FCHiddenField("HdnOC1IVA").Value.ToDecimal + 'Dim RetIVA As Double = gvr.FCHiddenField("HdnOC1RetIVA").Value.ToDecimal + 'Dim RetISR As Double = gvr.FCHiddenField("HdnOC1RetISR").Value.ToDecimal + 'Dim IEPSPS As Double = gvr.FCHiddenField("HdnOC1IEPSImporte").Value.ToDecimal + 'Dim IEPSPSIVA As Double = gvr.FCHiddenField("HdnOC1IEPSIVA").Value.ToDecimal + Dim IVA As Decimal = dr("IVAPorcentaje").ToString.ToDecimal + Dim RetIVA As Double = dr("RetIVAPorcentaje").ToString.ToDecimal + Dim RetISR As Double = dr("RetISRPorcentaje").ToString.ToDecimal + Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDecimal + Dim IEPSPSIVA As Double = dr("IEPSPSIVAPorcentaje").ToString.ToDecimal + Dim Descuento As Double = If(TieneAmortizacion, TxtDescuento.Text.ToDouble / TotalRows, gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal) + 'Dim Descuento As Double = gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal + Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero + Dim EntregaDirecta As Integer = dr("EntregaDirecta").ToString.ToEntero + Dim CveSATPS As Integer = gvr.FCDropDownLost("DdlSATPS").SelectedValue.ToEntero + Dim CveTipoGasto As Integer = -1 + Dim TipoGasto As String = "" + + '[IPP] PROVISIONAL PARA TIPO GASTO + If GlobalDTTiposGastos(UsuarioActual.CveEmpresa) IsNot Nothing AndAlso GlobalDTTiposGastos(UsuarioActual.CveEmpresa).Rows.Count = 1 Then + Dim DrTipoGasto = GlobalDTTiposGastos(UsuarioActual.CveEmpresa).FiltroPrimero("") + If DrTipoGasto IsNot Nothing Then + CveTipoGasto = DrTipoGasto("CveTipoGasto").ToString.ToEntero + TipoGasto = DrTipoGasto("TipoGasto").ToString + End If + End If + + AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle, False, CantidadF:=CantidadF, EntregaDirecta:=EntregaDirecta, CveSATPS:=CveSATPS, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) + + 'CARGA PE + Index = TmpDT.Rows.Count - 1 + TmpDT.Rows(Index)("CvePresupuestoEgreso") = dr("CvePresupuestoEgreso").ToString.ToEntero + TmpDT.Rows(Index)("CveProgramaOperativo") = dr("CveProgramaOperativo").ToString.ToEntero + TmpDT.Rows(Index)("CveUnidadAdministrativa") = dr("CveUnidadAdministrativa").ToString.ToEntero + TmpDT.Rows(Index)("CveFuenteFinanciamiento") = dr("CveFuenteFinanciamiento").ToString.ToEntero + TmpDT.Rows(Index)("CveTipoGastoAC") = dr("CveTipoGasto").ToString.ToEntero + TmpDT.Rows(Index)("CveClasificacionOG") = dr("CveClasificacionOG").ToString.ToEntero + + 'TmpDT.Rows(Index)("PSCodigo") = DtTemporalXML.Rows(IndexTmpOriginal)("PSCodigo") + TmpDT.Rows(Index)("PSCodigo") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("PSCodigo", "").ToString + + Dim CveAF As String = dr("CveActivoFijo").ToString + If CveAF <> "" AndAlso CveAF <> "-1" Then + TmpDT.Rows(Index)("CveActivoFijo") = CveAF.ToEntero + TmpDT.Rows(Index)("CodAF") = dr("CodigoAF").ToString + TmpDT.Rows(Index)("TipoAF") = 1 + End If + 'actualizo los movimientos registrados + DTOCGV.Rows(gvr.RowIndex)("CantidadDisponible") = Cantidad + DTOCGV.Rows(gvr.RowIndex)("Importe") = PU + DTOCGV.Rows(gvr.RowIndex)("Total") = Total + + End If + IndexTmpOriginal += 1 + Next + + AddPS2(False) + + 'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE AjustaImporteUltimoConcepto((If(TieneAmortizacion, TmpDT.SUMD("ImporteSinImpuestos"), TxtSubTotal2.Text.ToDouble) + TxtOtrosImpuestos.Text.ToDouble).ToDecimal - If(TieneAmortizacion, TmpDT.SUM("ImporteSinImpuestos").ToString.ToDecimal, TmpDT.SUM("Total").ToString.ToDecimal)) 'AjustaImporteUltimoConcepto(TxtSubTotal2.Text.ToDecimal + TxtOtrosImpuestos.Text.ToDecimal - (TmpDT.SUM("Total").ToString.ToDecimal)) - BtnGuardar.Enabled = True - If Not CierrePeriodo Then - BtnGuardar.Visible = True - End If - AlmacenCambiaPS.Visible = False - UpFacturar.Update() - - TabGenerales.Enabled = True - TAB.ActiveTabIndex = 0 - UpTabs.Update() - - - ImgClasificacion.Visible = False - ImgSubProyecto.Visible = False - LbAgregar.Visible = False - OCVinculada = True - UpPSS.Update() - - AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) - - If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) - - CargaGvInv() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - CargaGVsAF() - - CargaTipoCentroCostoOC() - GvOC1.DataSource = DTOCGV - GvOC1.DataBind() - - Dim DTCVEOCS As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) - If DTCVEOCS.Rows.Count > 1 Then - GvOC1.Columns(0).Visible = True - Else - GvOC1.Columns(0).Visible = False - End If - - - GvOC2.DataSource = TmpDT - GvOC2.DataBind() - - LbSubTotalOC1.Text = LbSubTotalOC2.Text - LbSubTotal2OC1.Text = LblSubTotal2OC2.Text - LbIVAOC1.Text = LbIVAOC2.Text - LbIEPSOC1.Text = LbIEPSOC2.Text - LblRetIVAOC1.Text = LblRetIVAOC2.Text - LblRetISROC1.Text = LblRetISROC2.Text - LbDescuentoOC1.Text = LblDescuentoOC2.Text - LbTotalOC1.Text = LbTotalOC2.Text - - UpGvOC1.Update() - - 'Bloquea cambio de proyecto - DdlProyecto.Enabled = False - DdlSubProyecto.Enabled = False - DdlAsignarProyecto.Enabled = False - DdlAsignaSubProyecto.Enabled = False - UPPProyecto.Update() - - 'Bloquea cambio de OC ya que se concluyo alguna vinculacion - TxtOC.Enabled = False - UpParametros.Update() - - 'VERIFICA PE - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - - CargaGvPersonal() - - - 'ANTICIPO OC - If DivOCSolicitudAnticipo.Visible Then - RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") - UpAnticipos.Update() - End If - - CalculaTotales() - - End Sub - - Private Sub VinculacionAsync(Optional VinculacionCompleta As Boolean = False) - - 'LIMPIAMOS TMPDT - CreaDTCompras() - - Dim tasks As New List(Of Task)() - For Each gvr As GridViewRow In GvOC1.Rows - If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then - tasks.Add(AgregaConceptoOC(DTOCGV.Rows(gvr.RowIndex), gvr)) - End If - Next - Task.WaitAll(tasks.ToArray()) - - AddPS2(False) - - 'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE - AjustaImporteUltimoConcepto((TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal) - - BtnGuardar.Enabled = True - If Not CierrePeriodo Then - BtnGuardar.Visible = True - End If - AlmacenCambiaPS.Visible = False - UpFacturar.Update() - - TabGenerales.Enabled = True - TAB.ActiveTabIndex = 0 - UpTabs.Update() - - ImgClasificacion.Visible = False - ImgSubProyecto.Visible = False - LbAgregar.Visible = False - OCVinculada = True - UpPSS.Update() - - AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) - - CargaGvInv() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - CargaGVsAF() - - CargaTipoCentroCostoOC() - GvOC1.DataSource = DTOCGV - GvOC1.DataBind() - - Dim DTCVEOCS As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) - If DTCVEOCS.Rows.Count > 1 Then - GvOC1.Columns(0).Visible = True - Else - GvOC1.Columns(0).Visible = False - End If - - GvOC2.DataSource = TmpDT - GvOC2.DataBind() - - LbSubTotalOC1.Text = LbSubTotalOC2.Text - LbSubTotal2OC1.Text = LblSubTotal2OC2.Text - LbIVAOC1.Text = LbIVAOC2.Text - LbIEPSOC1.Text = LbIEPSOC2.Text - LblRetIVAOC1.Text = LblRetIVAOC2.Text - LblRetISROC1.Text = LblRetISROC2.Text - LbDescuentoOC1.Text = LblDescuentoOC2.Text - LbTotalOC1.Text = LbTotalOC2.Text - - UpGvOC1.Update() - - 'Bloquea cambio de proyecto - DdlProyecto.Enabled = False - DdlSubProyecto.Enabled = False - DdlAsignarProyecto.Enabled = False - DdlAsignaSubProyecto.Enabled = False - UPPProyecto.Update() - - 'Bloquea cambio de OC ya que se concluyo alguna vinculacion - TxtOC.Enabled = False - UpParametros.Update() - - 'VERIFICA PE - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - - CargaGvPersonal() - - 'ANTICIPO OC - If DivOCSolicitudAnticipo.Visible Then - RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") - UpAnticipos.Update() - End If - - CalculaTotales() - - End Sub - - Private Function AgregaConceptoOC(dr As DataRow, gvr As GridViewRow) As Task - Return Task.Factory.StartNew(Sub() AgregaConceptoOCHilo(dr, gvr)) - End Function - Private Sub AgregaConceptoOCHilo(dr As DataRow, gvr As GridViewRow) - Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal - Dim CantidadF As Decimal = gvr.DataKey("CantidadF").ToString.ToDecimal - Dim CveUM As Integer = dr("CveUM").ToString.ToEntero - Dim UM As String = dr("UM").ToString - Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero - Dim Clasificacion As String = dr("Clasificacion").ToString - Dim CvePS As Integer = dr("CvePS").ToString.ToEntero - Dim PS As String = dr("PS").ToString - Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero - Dim CveSubProyectoContrato As String = dr("CveSubProyecto").ToString - Dim CveProyecto As String = dr("CveProyecto").ToString - Dim SubProyecto As String = dr("SubProyecto").ToString - Dim Proyecto As String = dr("Proyecto").ToString - Dim Obs As String = dr("Obs").ToString - Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal - Dim Total As Decimal = gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal - - Dim IVA As Decimal = dr("IVAPorcentaje").ToString.ToDecimal - Dim RetIVA As Double = dr("RetIVAPorcentaje").ToString.ToDecimal - Dim RetISR As Double = dr("RetISRPorcentaje").ToString.ToDecimal - Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDecimal - Dim IEPSPSIVA As Double = dr("IEPSPSIVAPorcentaje").ToString.ToDecimal - Dim Descuento As Double = gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal - Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero - Dim EntregaDirecta As Integer = dr("EntregaDirecta").ToString.ToEntero - Dim CveSATPS As Integer = gvr.FCDropDownLost("DdlSATPS").SelectedValue.ToEntero - Dim CveTipoGasto As Integer = -1 - Dim TipoGasto As String = "" - - '[IPP] PROVISIONAL PARA TIPO GASTO - If GlobalDTTiposGastos(UsuarioActual.CveEmpresa) IsNot Nothing AndAlso GlobalDTTiposGastos(UsuarioActual.CveEmpresa).Rows.Count = 1 Then - Dim DrTipoGasto = GlobalDTTiposGastos(UsuarioActual.CveEmpresa).FiltroPrimero("") - If DrTipoGasto IsNot Nothing Then - CveTipoGasto = DrTipoGasto("CveTipoGasto").ToString.ToEntero - TipoGasto = DrTipoGasto("TipoGasto").ToString - End If - End If - - 'AGREGA PS - Dim IndexVinculacionOC = AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle, False, CantidadF:=CantidadF, EntregaDirecta:=EntregaDirecta, CveSATPS:=CveSATPS, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) - - 'CARGA PE - TmpDT.Rows(IndexVinculacionOC)("CvePresupuestoEgreso") = dr("CvePresupuestoEgreso").ToString.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CveProgramaOperativo") = dr("CveProgramaOperativo").ToString.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CveUnidadAdministrativa") = dr("CveUnidadAdministrativa").ToString.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CveFuenteFinanciamiento") = dr("CveFuenteFinanciamiento").ToString.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CveTipoGastoAC") = dr("CveTipoGasto").ToString.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CveClasificacionOG") = dr("CveClasificacionOG").ToString.ToEntero - - TmpDT.Rows(IndexVinculacionOC)("PSCodigo") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("PSCodigo", "").ToString - - Dim CveAF As String = dr("CveActivoFijo").ToString - If CveAF <> "" AndAlso CveAF <> "-1" Then - TmpDT.Rows(IndexVinculacionOC)("CveActivoFijo") = CveAF.ToEntero - TmpDT.Rows(IndexVinculacionOC)("CodAF") = dr("CodigoAF").ToString - TmpDT.Rows(IndexVinculacionOC)("TipoAF") = 1 - End If - 'actualizo los movimientos registrados - DTOCGV.Rows(gvr.RowIndex)("CantidadDisponible") = Cantidad - DTOCGV.Rows(gvr.RowIndex)("Importe") = PU - DTOCGV.Rows(gvr.RowIndex)("Total") = Total - End Sub - - - Protected Sub BtnTipoCambioOC_Click(sender As Object, e As EventArgs) - - If TxtTipoCambioOC.Text.ToDecimal = 0 Then - Alert("El tipo de cambio debe ser mayor a cero. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - For Each Dr As DataRow In DTOCTemp.Rows - - 'OC - COMPRA - 'DOLARES A PESOS - If DdlMoneda.SelectedValue.ToEntero = 1 Then - Dr("Importe") = Dr("PUTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("Descuento") = Dr("DescuentoTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("IVA") = Dr("IVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("IEPSPS") = Dr("IEPSPSTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("IEPSPSIVA") = Dr("IEPSPSIVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("RetIVA") = Dr("RetIVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("RetISR") = Dr("RetISRTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - Dr("ImporteAjustadoDescuento") = Dr("TotalTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal - End If - - 'OC - COMPRA - 'PESOS A DOLARES - If DdlMoneda.SelectedValue.ToEntero = 2 Then - Dr("Importe") = Dr("PUTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("Descuento") = Dr("DescuentoTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("IVA") = Dr("IVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("IEPSPS") = Dr("IEPSPSTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("IEPSPSIVA") = Dr("IEPSPSIVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("RetIVA") = Dr("RetIVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("RetISR") = Dr("RetISRTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - Dr("ImporteAjustadoDescuento") = Dr("TotalTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal - End If - - Dr.AcceptChanges() - Next - - TipoCambioOC = TxtTipoCambioOC.Text.ToDecimal - BtnVincularOC.Visible = True - CargaVinculacionOC() - End Sub - Protected Sub BtnDividirCompra_Click(sender As Object, e As EventArgs) - Dim Cantidad = CType(CType(sender, Button).NamingContainer, GridViewRow).FCTextBox("TxtDividir").Text.ToDouble - - If Cantidad < 0.1 Then - Exit Sub - End If - - Dim dr = TmpDT.Rows(CType(CType(sender, Button).NamingContainer, GridViewRow).RowIndex) - Dim drNuevo = TmpDT.NewRow - - drNuevo.ItemArray = dr.ItemArray - drNuevo("Cantidad") = Cantidad - drNuevo("Total") = drNuevo("Cantidad").ToString.ToEntero * drNuevo("PU").ToString.ToDouble - - dr("Cantidad") = dr("Cantidad").ToString.ToEntero - Cantidad - dr("Total") = dr("Cantidad").ToString.ToEntero * dr("PU").ToString.ToDouble - - TmpDT.Rows.InsertAt(drNuevo, CType(CType(sender, Button).NamingContainer, GridViewRow).RowIndex) - - If TxtOC.Text.Trim <> "" Then - 'If EmpresasOC.Contains(UsuarioActual.CveEmpresa) Then - ' GvOC1.DataSource = TmpDT - ' GvOC1.DataBind() - ' UpGvOC1.Update() - 'Else - GvOC2.DataSource = TmpDT - GvOC2.DataBind() - UpGvOC2.Update() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - 'End If - Else - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - End If - - CargaGvInv() - - End Sub - Protected Sub BtnAlertaPUCero_Click(sender As Object, e As EventArgs) - Dim Argumentos = HdnAlertaPUCero.Value.Split("|"c) - Dim PS = Argumentos(0) - Dim Cantidad = Argumentos(1) - 'Alert($"El concepto tiene especificada una cantidad pero con costo de cero ($0).
br /<> b > En caso de vincular la OC de esta manera la cantidad especificada sera considerada como recibida.

De ser correcto Continue o de lo contrario rectifique.", TipoMensaje.MsgAdvertencia) - - - Alert($"El concepto {PS} tiene especificada la cantidad {Cantidad} pero un costo de cero ($0).

En caso de vincular la OC de esta manera la cantidad especificada sera considerada como recibida.

De ser correcto Continue o de lo contrario rectifique.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = True + If Not CierrePeriodo Then + BtnGuardar.Visible = True + End If + AlmacenCambiaPS.Visible = False + UpFacturar.Update() + + TabGenerales.Enabled = True + TAB.ActiveTabIndex = 0 + UpTabs.Update() + + + ImgClasificacion.Visible = False + ImgSubProyecto.Visible = False + LbAgregar.Visible = False + OCVinculada = True + UpPSS.Update() + + AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) + + CargaGvInv() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + CargaGVsAF() + + CargaTipoCentroCostoOC() + GvOC1.DataSource = DTOCGV + GvOC1.DataBind() + + Dim DTCVEOCS As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) + If DTCVEOCS.Rows.Count > 1 Then + GvOC1.Columns(0).Visible = True + Else + GvOC1.Columns(0).Visible = False + End If + + + GvOC2.DataSource = TmpDT + GvOC2.DataBind() + + LbSubTotalOC1.Text = LbSubTotalOC2.Text + LbSubTotal2OC1.Text = LblSubTotal2OC2.Text + LbIVAOC1.Text = LbIVAOC2.Text + LbIEPSOC1.Text = LbIEPSOC2.Text + LblRetIVAOC1.Text = LblRetIVAOC2.Text + LblRetISROC1.Text = LblRetISROC2.Text + LbDescuentoOC1.Text = LblDescuentoOC2.Text + LbTotalOC1.Text = LbTotalOC2.Text + + UpGvOC1.Update() + + 'Bloquea cambio de proyecto + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + DdlAsignarProyecto.Enabled = False + DdlAsignaSubProyecto.Enabled = False + UPPProyecto.Update() + + 'Bloquea cambio de OC ya que se concluyo alguna vinculacion + TxtOC.Enabled = False + UpParametros.Update() + + 'VERIFICA PE + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + + CargaGvPersonal() + + + 'ANTICIPO OC + If DivOCSolicitudAnticipo.Visible Then + RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") + UpAnticipos.Update() + End If + + CalculaTotales() + End Sub -#End Region -#Region "F L E T E S Y S E R V I C I O S" + Private Sub VinculacionAsync(Optional VinculacionCompleta As Boolean = False) - Public Sub CreaDTFacturas() - - Dim dt As New DataTable - - dt.Columns.Add("CveCompra", Type.GetType("System.Int32")) - dt.Columns.Add("Folio", Type.GetType("System.String")) - dt.Columns.Add("Fecha", Type.GetType("System.String")) - - DtFacturas = dt - End Sub - - Public Sub CreaDTServicios() - - Dim dt As New DataTable - - dt.Columns.Add("Total", Type.GetType("System.Double")) - dt.Columns.Add("PS", Type.GetType("System.String")) - dt.Columns.Add("Consec", Type.GetType("System.Int32")) - dt.Columns.Add("CvePS", Type.GetType("System.Int32")) - - DtServicios = dt - End Sub - - - - Protected Sub LbServicios_Click(sender As Object, e As EventArgs) - RegistraScript("$('#DivFletesYServicios').modal();") - CreaDTFacturas() - CreaDTServicios() - - End Sub - - Protected Sub BtnFiltrar_Click(sender As Object, e As EventArgs) - If DdlTipo.SelectedValue.ToEntero = 1 Then - - 'POR SI LLEGARA A TRONAR - If DtServicios Is Nothing Then CreaDTServicios() - DtServicios.Rows.Clear() - - Dim objps As New ClsProductosServicios - Dim dr As DataRow - dvFacturas.Visible = False - GvFacturas.Visible = False - - For Each DrGv As DataRow In TmpDT.Rows - If DrGv("CvePS").ToString.ToEntero > 0 Then - If objps.GetPS(DrGv("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then - If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then - dr = DtServicios.NewRow() - dr("Consec") = DrGv("Consec").ToString.ToEntero - dr("Total") = DrGv("Total").ToString.ToDecimal - dr("CvePS") = DrGv("CvePS").ToString.ToEntero - dr("PS") = DrGv("PS").ToString - DtServicios.Rows.Add(dr) - End If - End If - End If - Next - - '[IPP] COMENTADO - MIRAS DE ELIMINAR - 8/FEBRERO/2018 - 'For Each gvr As GridViewRow In GvPS.Rows - ' If objps.GetPS(gvr.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) Then - ' If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then - ' dr = DtServicios.NewRow() - ' dr("Consec") = gvr.FCLabel("LtlConsecutivo").Text.ToEntero - ' dr("Total") = gvr.FCLiteral("LtlTotal").Text.ToDecimal - ' dr("PS") = gvr.DataKey("PS").ToString - ' DtServicios.Rows.Add(dr) - ' End If - ' End If - 'Next - objps.Dispose() - - If DtServicios.Rows.Count > 0 Then - GVServicios.DataSource = DtServicios - GVServicios.DataBind() - GVServicios.Visible = True - Else - GVServicios.DataSource = Nothing - GVServicios.DataBind() - End If - - UpGVServicios.Update() - UpFacturas.Update() - UPGVFacturas.Update() - - ElseIf DdlTipo.SelectedValue.ToEntero = 2 Then - GVServicios.Visible = False - dvFacturas.Visible = True - DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - DdlProveedores.DataBind() - DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpFacturas.Update() - UpGVServicios.Update() - - - End If - - End Sub - - Public Sub btnAgregarFlete_Click(sender As Object, e As EventArgs) Handles BtnAgregarFlete.Click - - Dim ListaConsecutivas As New List(Of String) 'Almacena los consecutivos que pertenecen al almacen - Dim CostoIndirectoTotal As Decimal = 0 'Suma los costos indirectos calculados - Dim IndiceFila As Integer = 0 'Alamcena la fila actual iterada del TmpDT - Dim IndiceActualizar As Integer = -1 'Almacena el ultimo indice perteneciente a Almacen - - TotalFlete = 0 - TotalAlmacen = 0 - - 'Obtenemos el total del flete y marcamos los conceptos que pertenecen a flete - For Each gvr As GridViewRow In GVServicios.Rows - If gvr.FCCheckBox("chkServicios").Checked Then - Dim Dtr As DataRow = TmpDT.Select($"Consec = {gvr.FCLabel("LblConsec").Text.ToEntero}")(0) - Dtr("AplicaCostoIndirecto") = 1 - TotalFlete += Math.Round(gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal, 2) - End If - Next - - 'Obtenemos el total del almacen y guardamos las consecutivas pertenecientes al mismo - For Each Dr As DataRow In DtInv.Rows - TotalAlmacen += Math.Round(Dr("Total").ToString.ToDecimal, 2) - ListaConsecutivas.Add(Dr("Consec").ToString) - Next - - 'Asignamos los costos indirectos y los indices - For Each Drt As DataRow In TmpDT.Rows - If ListaConsecutivas.Contains(Drt("Consec").ToString) Then - Dim CostoIndirecto As Decimal = CalculaCostoIndirectoFlete(Drt("Total").ToString.ToDecimal) - CostoIndirectoTotal += CostoIndirecto - Drt("CostoIndirectoAlmacen") = CostoIndirecto - Drt("OtrosGastos") = CostoIndirecto - IndiceActualizar = IndiceFila - End If - IndiceFila += 1 - Next - - 'Si los costosindirectos no suman el total exacto del flete ajustamos el ultimo concepto - If CostoIndirectoTotal <> TotalFlete AndAlso IndiceActualizar >= 0 Then - Dim Diferencia = TotalFlete - CostoIndirectoTotal - TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen") = TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen").ToString.ToDouble + Diferencia - TmpDT.Rows(IndiceActualizar)("OtrosGastos") = TmpDT.Rows(IndiceActualizar)("OtrosGastos").ToString.ToDouble + Diferencia - End If - - TmpDT.AcceptChanges() - CargaGvInv() - DdlTipoCompra.SelectedValueExist("8") - UpEstatus.Update() - - ''Marcamos todos los almacenes como check - 'GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True - 'cbAll_CheckedChanged(Nothing, Nothing) - - End Sub - - Private Sub CargaGastosServicios(CvePS As Integer) - 'POR SI LLEGARA A TRONAR - If DtServicios Is Nothing Then CreaDTServicios() - DtServicios.Rows.Clear() - - Dim objps As New ClsProductosServicios - Dim dr As DataRow - dvFacturas.Visible = False - GvFacturas.Visible = False - - For Each DrGv As DataRow In TmpDT.Rows - If DrGv("CvePS").ToString.ToEntero > 0 Then - If objps.GetPS(DrGv("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then - If objps.DtResultados IsNot Nothing AndAlso objps.DtResultados.Rows.Count > 0 AndAlso objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then - dr = DtServicios.NewRow() - dr("Consec") = DrGv("Consec").ToString.ToEntero - dr("Total") = DrGv("Total").ToString.ToDecimal - dr("CvePS") = DrGv("CvePS").ToString.ToEntero - dr("PS") = DrGv("PS").ToString - DtServicios.Rows.Add(dr) - End If - End If - End If - Next - - '[IPP] COMENTADO - MIRAS DE ELIMINAR - 8/FEBRERO/2018 - 'For Each gvr As GridViewRow In GvPS.Rows - ' If objps.GetPS(gvr.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) Then - ' If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then - ' dr = DtServicios.NewRow() - ' dr("Consec") = gvr.FCLabel("LtlConsecutivo").Text.ToEntero - ' dr("Total") = gvr.FCLiteral("LtlTotal").Text.ToDecimal - ' dr("PS") = gvr.DataKey("PS").ToString - ' DtServicios.Rows.Add(dr) - ' End If - ' End If - 'Next - objps.Dispose() - - If DtServicios.Rows.Count > 0 Then - GVServicios.DataSource = DtServicios - GVServicios.DataBind() - GVServicios.Visible = True - Else - GVServicios.DataSource = Nothing - GVServicios.DataBind() - End If - - UpGVServicios.Update() - UpFacturas.Update() - UPGVFacturas.Update() - - - Dim ListaConsecutivas As New List(Of String) 'Almacena los consecutivos que pertenecen al almacen - Dim CostoIndirectoTotal As Decimal = 0 'Suma los costos indirectos calculados - Dim IndiceFila As Integer = 0 'Alamcena la fila actual iterada del TmpDT - Dim IndiceActualizar As Integer = -1 'Almacena el ultimo indice perteneciente a Almacen - - TotalFlete = 0 - TotalAlmacen = 0 - - If DtInv IsNot Nothing Then - 'Obtenemos el total del almacen y guardamos las consecutivas pertenecientes al mismo - For Each Dr2 As DataRow In DtInv.Rows - TotalAlmacen += Math.Round(Dr2("Total").ToString.ToDecimal, 2) - ListaConsecutivas.Add(Dr2("Consec").ToString) - Next - End If - - 'sino hay producto en almacen para aplciarle un servicio, no se debe de amrcar como costo indirecto - 'esto aplica cuando la factura solo trae un concepto, y es el de servicio - If TotalAlmacen = 0 Then Exit Sub - - 'Obtenemos el total del flete y marcamos los conceptos que pertenecen a flete - For Each gvr As GridViewRow In GVServicios.Rows - If gvr.DataKey("CvePS").ToEntero = CvePS Or gvr.FCCheckBox("chkServicios").Checked Then - Dim Dtr As DataRow = TmpDT.Select($"Consec = {gvr.FCLabel("LblConsec").Text.ToEntero}")(0) - Dtr("AplicaCostoIndirecto") = 1 - TotalFlete += Math.Round(gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal, 2) - gvr.FCCheckBox("chkServicios").Checked = True - End If - Next - UpGVServicios.Update() - - - If Not TotalFlete > 0 Then Exit Sub - - - 'Asignamos los costos indirectos y los indices - For Each Drt As DataRow In TmpDT.Rows - If ListaConsecutivas.Contains(Drt("Consec").ToString) Then - Dim CostoIndirecto As Decimal = CalculaCostoIndirectoFlete(Drt("Total").ToString.ToDecimal) - CostoIndirectoTotal += CostoIndirecto - Drt("CostoIndirectoAlmacen") = CostoIndirecto - Drt("OtrosGastos") = CostoIndirecto - IndiceActualizar = IndiceFila - End If - IndiceFila += 1 - Next - - 'Si los costosindirectos no suman el total exacto del flete ajustamos el ultimo concepto - If CostoIndirectoTotal <> TotalFlete AndAlso IndiceActualizar >= 0 Then - Dim Diferencia = TotalFlete - CostoIndirectoTotal - TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen") = TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen").ToString.ToDouble + Diferencia - TmpDT.Rows(IndiceActualizar)("OtrosGastos") = TmpDT.Rows(IndiceActualizar)("OtrosGastos").ToString.ToDouble + Diferencia - End If - - TmpDT.AcceptChanges() - CargaGvInv() - DdlTipoCompra.SelectedValueExist("8") - UpEstatus.Update() - - ''Marcamos todos los almacenes como check - 'GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True - 'cbAll_CheckedChanged(Nothing, Nothing) - End Sub - - - Protected Sub GVServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVServicios.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {e.Row.FCLabel("LblConsec").Text}")(0) - If TmpDr("AplicaCostoIndirecto").ToString = "1" Then - e.Row.FCCheckBox("chkServicios").Checked = True - e.Row.FCCheckBox("chkServicios").Enabled = Not CveCompra > 0 - End If - End If - End Sub - - Private Function CalculaCostoIndirectoFlete(ImporteAlmacen As Decimal) As Decimal - Dim CostoIndirecto As Decimal - CostoIndirecto = (ImporteAlmacen * TotalFlete) / TotalAlmacen - Return Math.Round(CostoIndirecto, 2) - End Function - - Protected Sub BtnAgregaFactura_Click(sender As Object, e As EventArgs) - Dim ObjComp As New ClsCompras - If ObjComp.GetCompras(DdlFacturas.SelectedValue.ToEntero, "-1", DdlFacturas.SelectedItem.ToString, -1, -1, 1) Then - - Dim dr As DataRow = DtFacturas.NewRow() - dr("CveCompra") = ObjComp.DtResultados(0)("CveCompra").ToString - dr("Folio") = ObjComp.DtResultados(0)("Folio").ToString - dr("Fecha") = ObjComp.DtResultados(0)("Fecha").ToString.ToDate.ToString("dd/MM/yyyy") - DtFacturas.Rows.Add(dr) - - If GvFacturas.Visible = False Then - GvFacturas.Visible = True - End If - - GvFacturas.DataSource = DtFacturas - GvFacturas.DataBind() - - Else - Alert("No se encontró la factura", TipoMensaje.MsgAdvertencia) - End If - - UPGVFacturas.Update() - ObjComp.Dispose() - End Sub - - Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) - CargarFacturas() - End Sub - - Private Sub CargarFacturas() - Dim objCompras As New ClsCompras - If objCompras.GetCompras(-1, "-1", "-1", DdlProveedores.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then - DdlFacturas.DataSource = objCompras.DtResultados - Else - DdlFacturas.DataSource = Nothing - Alert("No se encontraron folios con el proveedor seleccionado.", TipoMensaje.MsgAdvertencia) - End If - DdlFacturas.DataBind() - DdlFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) - - objCompras.Dispose() - End Sub - - Protected Sub GvFacturas_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvFacturas.RowDeleting - - DtFacturas.Rows.RemoveAt(e.RowIndex) - GvFacturas.DataSource = DtFacturas - GvFacturas.DataBind() - UPGVFacturas.Update() - UpFacturas.Update() - - - - End Sub - - Public Sub ValidaFletesServicios() - - If Not UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then - dvFacturas.Visible = False - GvFacturas.Visible = False - GVServicios.Visible = False - End If - - If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.CvePlataforma <> 2 Then - liServicios.Visible = True - liFletesImportaciones.Visible = True - End If - - End Sub - - Public Function AplicarCostoIndirecto(ObjInv As ClsInventarios, ObjCompras As ClsCompras) As Boolean - Return False - - Dim HayError As Boolean - - Dim dtTemporal As New DataTable - dtTemporal = Nothing - - If GvFacturas.Visible AndAlso GvFacturas.Rows.Count > 0 Then - - Dim IdCompras = New List(Of Integer) - Dim TotalServicios As Decimal = 0 - - TotalServicios = TxtSubTotal.Text.ToString.ToDecimal - If TotalServicios > 0 Then - - For Each row As GridViewRow In GvFacturas.Rows - IdCompras.Add(row.DataKey("CveCompra").ToEntero) - Next - For Each value As Integer In IdCompras - If ObjInv.GetMovimientosDetalle(-1, UsuarioActual.CveEmpresa, value) AndAlso ObjInv.DtResultados.Rows.Count > 0 Then - If dtTemporal Is Nothing Then - dtTemporal = ObjInv.DtResultados - Else - dtTemporal.Merge(ObjInv.DtResultados) - End If - End If - Next - - 'Dim DtProductos As New DataTable - ' DtProductos = ObjInv.DtResultados.DefaultView.ToTable(True, "CveMovimiento", "CvePS", "Cantidad", "PU", "Total") - 'Dim total As Decimal = 0 - 'For Each row As DataRow In DtProductos.Rows - ' total = total + row("Total").ToString.ToDecimal - 'Next - 'If total > 0 Then - - If dtTemporal IsNot Nothing Then - Dim TotalFacturas = dtTemporal.SUM("Total").ToString.ToDecimal - For Each row As DataRow In dtTemporal.Rows - Dim prorrateo As Decimal - prorrateo = (row("PU").ToString.ToDecimal * TotalServicios) / TotalFacturas - If Not ObjInv.UpdateCostoIndirectoMovimientoDetalle(row("CveMovimientoDetalle").ToString.ToEntero, prorrateo) Then - HayError = True - Exit For - - End If - Next - End If - Else - Alert("El total de los servicios a vincular debe ser mayor a $0.00", TipoMensaje.MsgError) - Return True - End If - - ElseIf GVServicios.Visible AndAlso GVServicios.Rows.Count > 0 Then - - Dim Dtcompra As New DataTable - Dim TotalServicios As Decimal = 0 - - Dim chk As Boolean = False - For Each gvr As GridViewRow In GVServicios.Rows - If gvr.FCCheckBox("chkServicios").Checked Then - TotalServicios += gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal - chk = True - End If - Next - - If chk = False Then - Alert("Debe Seleccionar un Servicio", TipoMensaje.MsgInformacion) - Return False - Else - - If ObjCompras.GetCompraDetalle(CveCompra) Then - If ObjInv.GetMovimientosDetalle(-1, UsuarioActual.CveEmpresa, CveCompra) Then - Dtcompra = ObjInv.DtResultados - Dim TotalProductos = Dtcompra.SUM("Total").ToString.ToDecimal - If TotalProductos > 0 Then - For Each row As DataRow In Dtcompra.Rows - Dim prorrateo As Decimal - prorrateo = (row("PU").ToString.ToDecimal * TotalServicios) / TotalProductos - If Not ObjInv.UpdateCostoIndirectoMovimientoDetalle(row("CveMovimientoDetalle").ToString.ToEntero, prorrateo) Then - HayError = True - Exit For - - End If - Next - Else - Alert("No existen productos de inventario en esta factura", TipoMensaje.MsgError) - End If - End If - End If - - End If - Else - Return False - End If - - If HayError = True And ObjInv IsNot Nothing Then - Alert("Ocurrió un error al vincular un flete o servicio") - HayError = True - End If - - Return HayError - End Function - - Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) - 'dvFacturas.Visible = False - 'GvFacturas.Visible = False - 'GVServicios.Visible = False - 'UpFacturas.Update() - 'UPGVFacturas.Update() - 'UpGVServicios.Update() - End Sub - - Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs) - If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - If DdlTipoComprobante.SelectedValue = "NC" Then - DivReembolso.Visible = False - RBLPago.Items(2).Enabled = False - Else - DivReembolso.Visible = True - RBLPago.Items(2).Enabled = True - End If - ImgAnticiposPendientes.Visible = False + 'LIMPIAMOS TMPDT + CreaDTCompras() + + Dim tasks As New List(Of Task)() + For Each gvr As GridViewRow In GvOC1.Rows + If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then + tasks.Add(AgregaConceptoOC(DTOCGV.Rows(gvr.RowIndex), gvr)) + End If + Next + Task.WaitAll(tasks.ToArray()) + + AddPS2(False) + + 'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE + AjustaImporteUltimoConcepto((TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal) + + BtnGuardar.Enabled = True + If Not CierrePeriodo Then + BtnGuardar.Visible = True + End If + AlmacenCambiaPS.Visible = False + UpFacturar.Update() + + TabGenerales.Enabled = True + TAB.ActiveTabIndex = 0 + UpTabs.Update() + + ImgClasificacion.Visible = False + ImgSubProyecto.Visible = False + LbAgregar.Visible = False + OCVinculada = True + UpPSS.Update() + + AsignaValoresOriginales(TxtSubTotal.Text.ToDouble, TxtSubTotal2.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtTotal.Text.ToDouble) + + CargaGvInv() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + CargaGVsAF() + + CargaTipoCentroCostoOC() + GvOC1.DataSource = DTOCGV + GvOC1.DataBind() + + Dim DTCVEOCS As DataTable = DTOCGV.FiltraParametros("", "", {"CveOrdenCompra"}) + If DTCVEOCS.Rows.Count > 1 Then + GvOC1.Columns(0).Visible = True + Else + GvOC1.Columns(0).Visible = False + End If + + GvOC2.DataSource = TmpDT + GvOC2.DataBind() + + LbSubTotalOC1.Text = LbSubTotalOC2.Text + LbSubTotal2OC1.Text = LblSubTotal2OC2.Text + LbIVAOC1.Text = LbIVAOC2.Text + LbIEPSOC1.Text = LbIEPSOC2.Text + LblRetIVAOC1.Text = LblRetIVAOC2.Text + LblRetISROC1.Text = LblRetISROC2.Text + LbDescuentoOC1.Text = LblDescuentoOC2.Text + LbTotalOC1.Text = LbTotalOC2.Text + + UpGvOC1.Update() + + 'Bloquea cambio de proyecto + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + DdlAsignarProyecto.Enabled = False + DdlAsignaSubProyecto.Enabled = False + UPPProyecto.Update() + + 'Bloquea cambio de OC ya que se concluyo alguna vinculacion + TxtOC.Enabled = False + UpParametros.Update() + + 'VERIFICA PE + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + + CargaGvPersonal() + + 'ANTICIPO OC + If DivOCSolicitudAnticipo.Visible Then + RegistraScript("MuestraAnticipos();", "MuestaAnticiposOC") + UpAnticipos.Update() + End If + + CalculaTotales() + + End Sub + + Private Function AgregaConceptoOC(dr As DataRow, gvr As GridViewRow) As Task + Return Task.Factory.StartNew(Sub() AgregaConceptoOCHilo(dr, gvr)) + End Function + Private Sub AgregaConceptoOCHilo(dr As DataRow, gvr As GridViewRow) + Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal + Dim CantidadF As Decimal = gvr.DataKey("CantidadF").ToString.ToDecimal + Dim CveUM As Integer = dr("CveUM").ToString.ToEntero + Dim UM As String = dr("UM").ToString + Dim CveClasificacion As Integer = dr("CveClasificacion").ToString.ToEntero + Dim Clasificacion As String = dr("Clasificacion").ToString + Dim CvePS As Integer = dr("CvePS").ToString.ToEntero + Dim PS As String = dr("PS").ToString + Dim CveTipoPS As Integer = dr("CveTipoPS").ToString.ToEntero + Dim CveSubProyectoContrato As String = dr("CveSubProyecto").ToString + Dim CveProyecto As String = dr("CveProyecto").ToString + Dim SubProyecto As String = dr("SubProyecto").ToString + Dim Proyecto As String = dr("Proyecto").ToString + Dim Obs As String = dr("Obs").ToString + Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal + Dim Total As Decimal = gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal + + Dim IVA As Decimal = dr("IVAPorcentaje").ToString.ToDecimal + Dim RetIVA As Double = dr("RetIVAPorcentaje").ToString.ToDecimal + Dim RetISR As Double = dr("RetISRPorcentaje").ToString.ToDecimal + Dim IEPSPS As Double = dr("IEPSPSPorcentaje").ToString.ToDecimal + Dim IEPSPSIVA As Double = dr("IEPSPSIVAPorcentaje").ToString.ToDecimal + Dim Descuento As Double = gvr.FCHiddenField("HdnOC1Descuento").Value.ToDecimal + Dim CveOrdenCompraDetalle As Integer = dr("CveOrdenCompraDetalle").ToString.ToEntero + Dim EntregaDirecta As Integer = dr("EntregaDirecta").ToString.ToEntero + Dim CveSATPS As Integer = gvr.FCDropDownLost("DdlSATPS").SelectedValue.ToEntero + Dim CveTipoGasto As Integer = -1 + Dim TipoGasto As String = "" + + '[IPP] PROVISIONAL PARA TIPO GASTO + If GlobalDTTiposGastos(UsuarioActual.CveEmpresa) IsNot Nothing AndAlso GlobalDTTiposGastos(UsuarioActual.CveEmpresa).Rows.Count = 1 Then + Dim DrTipoGasto = GlobalDTTiposGastos(UsuarioActual.CveEmpresa).FiltroPrimero("") + If DrTipoGasto IsNot Nothing Then + CveTipoGasto = DrTipoGasto("CveTipoGasto").ToString.ToEntero + TipoGasto = DrTipoGasto("TipoGasto").ToString + End If + End If + + 'AGREGA PS + Dim IndexVinculacionOC = AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, RetIVA, RetISR, IEPSPS, IEPSPSIVA, Descuento, CveOrdenCompraDetalle, False, CantidadF:=CantidadF, EntregaDirecta:=EntregaDirecta, CveSATPS:=CveSATPS, CveTipoGasto:=CveTipoGasto, TipoGasto:=TipoGasto) + + 'CARGA PE + TmpDT.Rows(IndexVinculacionOC)("CvePresupuestoEgreso") = dr("CvePresupuestoEgreso").ToString.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CveProgramaOperativo") = dr("CveProgramaOperativo").ToString.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CveUnidadAdministrativa") = dr("CveUnidadAdministrativa").ToString.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CveFuenteFinanciamiento") = dr("CveFuenteFinanciamiento").ToString.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CveTipoGastoAC") = dr("CveTipoGasto").ToString.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CveClasificacionOG") = dr("CveClasificacionOG").ToString.ToEntero + + TmpDT.Rows(IndexVinculacionOC)("PSCodigo") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("PSCodigo", "").ToString + + Dim CveAF As String = dr("CveActivoFijo").ToString + If CveAF <> "" AndAlso CveAF <> "-1" Then + TmpDT.Rows(IndexVinculacionOC)("CveActivoFijo") = CveAF.ToEntero + TmpDT.Rows(IndexVinculacionOC)("CodAF") = dr("CodigoAF").ToString + TmpDT.Rows(IndexVinculacionOC)("TipoAF") = 1 + End If + 'actualizo los movimientos registrados + DTOCGV.Rows(gvr.RowIndex)("CantidadDisponible") = Cantidad + DTOCGV.Rows(gvr.RowIndex)("Importe") = PU + DTOCGV.Rows(gvr.RowIndex)("Total") = Total + End Sub + + + Protected Sub BtnTipoCambioOC_Click(sender As Object, e As EventArgs) + + If TxtTipoCambioOC.Text.ToDecimal = 0 Then + Alert("El tipo de cambio debe ser mayor a cero. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + For Each Dr As DataRow In DTOCTemp.Rows + + 'OC - COMPRA + 'DOLARES A PESOS + If DdlMoneda.SelectedValue.ToEntero = 1 Then + Dr("Importe") = Dr("PUTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("Descuento") = Dr("DescuentoTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("IVA") = Dr("IVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("IEPSPS") = Dr("IEPSPSTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("IEPSPSIVA") = Dr("IEPSPSIVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("RetIVA") = Dr("RetIVATC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("RetISR") = Dr("RetISRTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + Dr("ImporteAjustadoDescuento") = Dr("TotalTC").ToString.ToDecimal * TxtTipoCambioOC.Text.ToDecimal + End If + + 'OC - COMPRA + 'PESOS A DOLARES + If DdlMoneda.SelectedValue.ToEntero = 2 Then + Dr("Importe") = Dr("PUTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("Descuento") = Dr("DescuentoTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("IVA") = Dr("IVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("IEPSPS") = Dr("IEPSPSTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("IEPSPSIVA") = Dr("IEPSPSIVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("RetIVA") = Dr("RetIVATC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("RetISR") = Dr("RetISRTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + Dr("ImporteAjustadoDescuento") = Dr("TotalTC").ToString.ToDecimal / TxtTipoCambioOC.Text.ToDecimal + End If + + Dr.AcceptChanges() + Next + + TipoCambioOC = TxtTipoCambioOC.Text.ToDecimal + BtnVincularOC.Visible = True + CargaVinculacionOC() + End Sub + Protected Sub BtnDividirCompra_Click(sender As Object, e As EventArgs) + Dim Cantidad = CType(CType(sender, Button).NamingContainer, GridViewRow).FCTextBox("TxtDividir").Text.ToDouble + + If Cantidad < 0.1 Then + Exit Sub + End If + + Dim dr = TmpDT.Rows(CType(CType(sender, Button).NamingContainer, GridViewRow).RowIndex) + Dim drNuevo = TmpDT.NewRow + + drNuevo.ItemArray = dr.ItemArray + drNuevo("Cantidad") = Cantidad + drNuevo("Total") = drNuevo("Cantidad").ToString.ToEntero * drNuevo("PU").ToString.ToDouble + + dr("Cantidad") = dr("Cantidad").ToString.ToEntero - Cantidad + dr("Total") = dr("Cantidad").ToString.ToEntero * dr("PU").ToString.ToDouble + + TmpDT.Rows.InsertAt(drNuevo, CType(CType(sender, Button).NamingContainer, GridViewRow).RowIndex) + + If TxtOC.Text.Trim <> "" Then + 'If EmpresasOC.Contains(UsuarioActual.CveEmpresa) Then + ' GvOC1.DataSource = TmpDT + ' GvOC1.DataBind() + ' UpGvOC1.Update() + 'Else + GvOC2.DataSource = TmpDT + GvOC2.DataBind() + UpGvOC2.Update() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + 'End If + Else + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + End If + + CargaGvInv() + + End Sub + Protected Sub BtnAlertaPUCero_Click(sender As Object, e As EventArgs) + Dim Argumentos = HdnAlertaPUCero.Value.Split("|"c) + Dim PS = Argumentos(0) + Dim Cantidad = Argumentos(1) + 'Alert($"El concepto tiene especificada una cantidad pero con costo de cero ($0).
br /<> b > En caso de vincular la OC de esta manera la cantidad especificada sera considerada como recibida.

De ser correcto Continue o de lo contrario rectifique.", TipoMensaje.MsgAdvertencia) + + + Alert($"El concepto {PS} tiene especificada la cantidad {Cantidad} pero un costo de cero ($0).

En caso de vincular la OC de esta manera la cantidad especificada sera considerada como recibida.

De ser correcto Continue o de lo contrario rectifique.", TipoMensaje.MsgAdvertencia) + End Sub +#End Region + +#Region "F L E T E S Y S E R V I C I O S" + + Public Sub CreaDTFacturas() + + Dim dt As New DataTable + + dt.Columns.Add("CveCompra", Type.GetType("System.Int32")) + dt.Columns.Add("Folio", Type.GetType("System.String")) + dt.Columns.Add("Fecha", Type.GetType("System.String")) + + DtFacturas = dt + End Sub + + Public Sub CreaDTServicios() + + Dim dt As New DataTable + + dt.Columns.Add("Total", Type.GetType("System.Double")) + dt.Columns.Add("PS", Type.GetType("System.String")) + dt.Columns.Add("Consec", Type.GetType("System.Int32")) + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + + DtServicios = dt + End Sub + + + + Protected Sub LbServicios_Click(sender As Object, e As EventArgs) + RegistraScript("$('#DivFletesYServicios').modal();") + CreaDTFacturas() + CreaDTServicios() + + End Sub + + Protected Sub BtnFiltrar_Click(sender As Object, e As EventArgs) + If DdlTipo.SelectedValue.ToEntero = 1 Then + + 'POR SI LLEGARA A TRONAR + If DtServicios Is Nothing Then CreaDTServicios() + DtServicios.Rows.Clear() + + Dim objps As New ClsProductosServicios + Dim dr As DataRow + dvFacturas.Visible = False + GvFacturas.Visible = False + + For Each DrGv As DataRow In TmpDT.Rows + If DrGv("CvePS").ToString.ToEntero > 0 Then + If objps.GetPS(DrGv("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then + If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then + dr = DtServicios.NewRow() + dr("Consec") = DrGv("Consec").ToString.ToEntero + dr("Total") = DrGv("Total").ToString.ToDecimal + dr("CvePS") = DrGv("CvePS").ToString.ToEntero + dr("PS") = DrGv("PS").ToString + DtServicios.Rows.Add(dr) + End If + End If + End If + Next + + '[IPP] COMENTADO - MIRAS DE ELIMINAR - 8/FEBRERO/2018 + 'For Each gvr As GridViewRow In GvPS.Rows + ' If objps.GetPS(gvr.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) Then + ' If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then + ' dr = DtServicios.NewRow() + ' dr("Consec") = gvr.FCLabel("LtlConsecutivo").Text.ToEntero + ' dr("Total") = gvr.FCLiteral("LtlTotal").Text.ToDecimal + ' dr("PS") = gvr.DataKey("PS").ToString + ' DtServicios.Rows.Add(dr) + ' End If + ' End If + 'Next + objps.Dispose() + + If DtServicios.Rows.Count > 0 Then + GVServicios.DataSource = DtServicios + GVServicios.DataBind() + GVServicios.Visible = True + Else + GVServicios.DataSource = Nothing + GVServicios.DataBind() + End If + + UpGVServicios.Update() + UpFacturas.Update() + UPGVFacturas.Update() + + ElseIf DdlTipo.SelectedValue.ToEntero = 2 Then + GVServicios.Visible = False + dvFacturas.Visible = True + DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + DdlProveedores.DataBind() + DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) + UpFacturas.Update() + UpGVServicios.Update() + + + End If + + End Sub + + Public Sub btnAgregarFlete_Click(sender As Object, e As EventArgs) Handles BtnAgregarFlete.Click + + Dim ListaConsecutivas As New List(Of String) 'Almacena los consecutivos que pertenecen al almacen + Dim CostoIndirectoTotal As Decimal = 0 'Suma los costos indirectos calculados + Dim IndiceFila As Integer = 0 'Alamcena la fila actual iterada del TmpDT + Dim IndiceActualizar As Integer = -1 'Almacena el ultimo indice perteneciente a Almacen + + TotalFlete = 0 + TotalAlmacen = 0 + + 'Obtenemos el total del flete y marcamos los conceptos que pertenecen a flete + For Each gvr As GridViewRow In GVServicios.Rows + If gvr.FCCheckBox("chkServicios").Checked Then + Dim Dtr As DataRow = TmpDT.Select($"Consec = {gvr.FCLabel("LblConsec").Text.ToEntero}")(0) + Dtr("AplicaCostoIndirecto") = 1 + TotalFlete += Math.Round(gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal, 2) + End If + Next + + 'Obtenemos el total del almacen y guardamos las consecutivas pertenecientes al mismo + For Each Dr As DataRow In DtInv.Rows + TotalAlmacen += Math.Round(Dr("Total").ToString.ToDecimal, 2) + ListaConsecutivas.Add(Dr("Consec").ToString) + Next + + 'Asignamos los costos indirectos y los indices + For Each Drt As DataRow In TmpDT.Rows + If ListaConsecutivas.Contains(Drt("Consec").ToString) Then + Dim CostoIndirecto As Decimal = CalculaCostoIndirectoFlete(Drt("Total").ToString.ToDecimal) + CostoIndirectoTotal += CostoIndirecto + Drt("CostoIndirectoAlmacen") = CostoIndirecto + Drt("OtrosGastos") = CostoIndirecto + IndiceActualizar = IndiceFila + End If + IndiceFila += 1 + Next + + 'Si los costosindirectos no suman el total exacto del flete ajustamos el ultimo concepto + If CostoIndirectoTotal <> TotalFlete AndAlso IndiceActualizar >= 0 Then + Dim Diferencia = TotalFlete - CostoIndirectoTotal + TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen") = TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen").ToString.ToDouble + Diferencia + TmpDT.Rows(IndiceActualizar)("OtrosGastos") = TmpDT.Rows(IndiceActualizar)("OtrosGastos").ToString.ToDouble + Diferencia + End If + + TmpDT.AcceptChanges() + CargaGvInv() + DdlTipoCompra.SelectedValueExist("8") + UpEstatus.Update() + + ''Marcamos todos los almacenes como check + 'GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True + 'cbAll_CheckedChanged(Nothing, Nothing) + + End Sub + + Private Sub CargaGastosServicios(CvePS As Integer) + 'POR SI LLEGARA A TRONAR + If DtServicios Is Nothing Then CreaDTServicios() + DtServicios.Rows.Clear() + + Dim objps As New ClsProductosServicios + Dim dr As DataRow + dvFacturas.Visible = False + GvFacturas.Visible = False + + For Each DrGv As DataRow In TmpDT.Rows + If DrGv("CvePS").ToString.ToEntero > 0 Then + If objps.GetPS(DrGv("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then + If objps.DtResultados IsNot Nothing AndAlso objps.DtResultados.Rows.Count > 0 AndAlso objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then + dr = DtServicios.NewRow() + dr("Consec") = DrGv("Consec").ToString.ToEntero + dr("Total") = DrGv("Total").ToString.ToDecimal + dr("CvePS") = DrGv("CvePS").ToString.ToEntero + dr("PS") = DrGv("PS").ToString + DtServicios.Rows.Add(dr) + End If + End If + End If + Next + + '[IPP] COMENTADO - MIRAS DE ELIMINAR - 8/FEBRERO/2018 + 'For Each gvr As GridViewRow In GvPS.Rows + ' If objps.GetPS(gvr.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) Then + ' If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then + ' dr = DtServicios.NewRow() + ' dr("Consec") = gvr.FCLabel("LtlConsecutivo").Text.ToEntero + ' dr("Total") = gvr.FCLiteral("LtlTotal").Text.ToDecimal + ' dr("PS") = gvr.DataKey("PS").ToString + ' DtServicios.Rows.Add(dr) + ' End If + ' End If + 'Next + objps.Dispose() + + If DtServicios.Rows.Count > 0 Then + GVServicios.DataSource = DtServicios + GVServicios.DataBind() + GVServicios.Visible = True + Else + GVServicios.DataSource = Nothing + GVServicios.DataBind() + End If + + UpGVServicios.Update() + UpFacturas.Update() + UPGVFacturas.Update() + + + Dim ListaConsecutivas As New List(Of String) 'Almacena los consecutivos que pertenecen al almacen + Dim CostoIndirectoTotal As Decimal = 0 'Suma los costos indirectos calculados + Dim IndiceFila As Integer = 0 'Alamcena la fila actual iterada del TmpDT + Dim IndiceActualizar As Integer = -1 'Almacena el ultimo indice perteneciente a Almacen + + TotalFlete = 0 + TotalAlmacen = 0 + + If DtInv IsNot Nothing Then + 'Obtenemos el total del almacen y guardamos las consecutivas pertenecientes al mismo + For Each Dr2 As DataRow In DtInv.Rows + TotalAlmacen += Math.Round(Dr2("Total").ToString.ToDecimal, 2) + ListaConsecutivas.Add(Dr2("Consec").ToString) + Next + End If + + 'sino hay producto en almacen para aplciarle un servicio, no se debe de amrcar como costo indirecto + 'esto aplica cuando la factura solo trae un concepto, y es el de servicio + If TotalAlmacen = 0 Then Exit Sub + + 'Obtenemos el total del flete y marcamos los conceptos que pertenecen a flete + For Each gvr As GridViewRow In GVServicios.Rows + If gvr.DataKey("CvePS").ToEntero = CvePS Or gvr.FCCheckBox("chkServicios").Checked Then + Dim Dtr As DataRow = TmpDT.Select($"Consec = {gvr.FCLabel("LblConsec").Text.ToEntero}")(0) + Dtr("AplicaCostoIndirecto") = 1 + TotalFlete += Math.Round(gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal, 2) + gvr.FCCheckBox("chkServicios").Checked = True + End If + Next + UpGVServicios.Update() + + + If Not TotalFlete > 0 Then Exit Sub + + + 'Asignamos los costos indirectos y los indices + For Each Drt As DataRow In TmpDT.Rows + If ListaConsecutivas.Contains(Drt("Consec").ToString) Then + Dim CostoIndirecto As Decimal = CalculaCostoIndirectoFlete(Drt("Total").ToString.ToDecimal) + CostoIndirectoTotal += CostoIndirecto + Drt("CostoIndirectoAlmacen") = CostoIndirecto + Drt("OtrosGastos") = CostoIndirecto + IndiceActualizar = IndiceFila + End If + IndiceFila += 1 + Next + + 'Si los costosindirectos no suman el total exacto del flete ajustamos el ultimo concepto + If CostoIndirectoTotal <> TotalFlete AndAlso IndiceActualizar >= 0 Then + Dim Diferencia = TotalFlete - CostoIndirectoTotal + TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen") = TmpDT.Rows(IndiceActualizar)("CostoIndirectoAlmacen").ToString.ToDouble + Diferencia + TmpDT.Rows(IndiceActualizar)("OtrosGastos") = TmpDT.Rows(IndiceActualizar)("OtrosGastos").ToString.ToDouble + Diferencia + End If + + TmpDT.AcceptChanges() + CargaGvInv() + DdlTipoCompra.SelectedValueExist("8") + UpEstatus.Update() + + ''Marcamos todos los almacenes como check + 'GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True + 'cbAll_CheckedChanged(Nothing, Nothing) + End Sub + + + Protected Sub GVServicios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVServicios.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim TmpDr As DataRow = TmpDT.Select($"Consec = {e.Row.FCLabel("LblConsec").Text}")(0) + If TmpDr("AplicaCostoIndirecto").ToString = "1" Then + e.Row.FCCheckBox("chkServicios").Checked = True + e.Row.FCCheckBox("chkServicios").Enabled = Not CveCompra > 0 + End If + End If + End Sub + + Private Function CalculaCostoIndirectoFlete(ImporteAlmacen As Decimal) As Decimal + Dim CostoIndirecto As Decimal + CostoIndirecto = (ImporteAlmacen * TotalFlete) / TotalAlmacen + Return Math.Round(CostoIndirecto, 2) + End Function + + Protected Sub BtnAgregaFactura_Click(sender As Object, e As EventArgs) + Dim ObjComp As New ClsCompras + If ObjComp.GetCompras(DdlFacturas.SelectedValue.ToEntero, "-1", DdlFacturas.SelectedItem.ToString, -1, -1, 1) Then + + Dim dr As DataRow = DtFacturas.NewRow() + dr("CveCompra") = ObjComp.DtResultados(0)("CveCompra").ToString + dr("Folio") = ObjComp.DtResultados(0)("Folio").ToString + dr("Fecha") = ObjComp.DtResultados(0)("Fecha").ToString.ToDate.ToString("dd/MM/yyyy") + DtFacturas.Rows.Add(dr) + + If GvFacturas.Visible = False Then + GvFacturas.Visible = True + End If + + GvFacturas.DataSource = DtFacturas + GvFacturas.DataBind() + + Else + Alert("No se encontró la factura", TipoMensaje.MsgAdvertencia) + End If + + UPGVFacturas.Update() + ObjComp.Dispose() + End Sub + + Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) + CargarFacturas() + End Sub + + Private Sub CargarFacturas() + Dim objCompras As New ClsCompras + If objCompras.GetCompras(-1, "-1", "-1", DdlProveedores.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then + DdlFacturas.DataSource = objCompras.DtResultados + Else + DdlFacturas.DataSource = Nothing + Alert("No se encontraron folios con el proveedor seleccionado.", TipoMensaje.MsgAdvertencia) + End If + DdlFacturas.DataBind() + DdlFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) + + objCompras.Dispose() + End Sub + + Protected Sub GvFacturas_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvFacturas.RowDeleting + + DtFacturas.Rows.RemoveAt(e.RowIndex) + GvFacturas.DataSource = DtFacturas + GvFacturas.DataBind() + UPGVFacturas.Update() + UpFacturas.Update() + + + + End Sub + + Public Sub ValidaFletesServicios() + + If Not UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then + dvFacturas.Visible = False + GvFacturas.Visible = False + GVServicios.Visible = False + End If + + If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.CvePlataforma <> 2 Then + liServicios.Visible = True + liFletesImportaciones.Visible = True + End If + + End Sub + + Public Function AplicarCostoIndirecto(ObjInv As ClsInventarios, ObjCompras As ClsCompras) As Boolean + Return False + + Dim HayError As Boolean + + Dim dtTemporal As New DataTable + dtTemporal = Nothing + + If GvFacturas.Visible AndAlso GvFacturas.Rows.Count > 0 Then + + Dim IdCompras = New List(Of Integer) + Dim TotalServicios As Decimal = 0 + + TotalServicios = TxtSubTotal.Text.ToString.ToDecimal + If TotalServicios > 0 Then + + For Each row As GridViewRow In GvFacturas.Rows + IdCompras.Add(row.DataKey("CveCompra").ToEntero) + Next + For Each value As Integer In IdCompras + If ObjInv.GetMovimientosDetalle(-1, UsuarioActual.CveEmpresa, value) AndAlso ObjInv.DtResultados.Rows.Count > 0 Then + If dtTemporal Is Nothing Then + dtTemporal = ObjInv.DtResultados + Else + dtTemporal.Merge(ObjInv.DtResultados) + End If + End If + Next + + 'Dim DtProductos As New DataTable + ' DtProductos = ObjInv.DtResultados.DefaultView.ToTable(True, "CveMovimiento", "CvePS", "Cantidad", "PU", "Total") + 'Dim total As Decimal = 0 + 'For Each row As DataRow In DtProductos.Rows + ' total = total + row("Total").ToString.ToDecimal + 'Next + 'If total > 0 Then + + If dtTemporal IsNot Nothing Then + Dim TotalFacturas = dtTemporal.SUM("Total").ToString.ToDecimal + For Each row As DataRow In dtTemporal.Rows + Dim prorrateo As Decimal + prorrateo = (row("PU").ToString.ToDecimal * TotalServicios) / TotalFacturas + If Not ObjInv.UpdateCostoIndirectoMovimientoDetalle(row("CveMovimientoDetalle").ToString.ToEntero, prorrateo) Then + HayError = True + Exit For + + End If + Next + End If + Else + Alert("El total de los servicios a vincular debe ser mayor a $0.00", TipoMensaje.MsgError) + Return True + End If + + ElseIf GVServicios.Visible AndAlso GVServicios.Rows.Count > 0 Then + + Dim Dtcompra As New DataTable + Dim TotalServicios As Decimal = 0 + + Dim chk As Boolean = False + For Each gvr As GridViewRow In GVServicios.Rows + If gvr.FCCheckBox("chkServicios").Checked Then + TotalServicios += gvr.FCLiteral("LtlTotalmodal").Text.ToDecimal + chk = True + End If + Next + + If chk = False Then + Alert("Debe Seleccionar un Servicio", TipoMensaje.MsgInformacion) + Return False + Else + + If ObjCompras.GetCompraDetalle(CveCompra) Then + If ObjInv.GetMovimientosDetalle(-1, UsuarioActual.CveEmpresa, CveCompra) Then + Dtcompra = ObjInv.DtResultados + Dim TotalProductos = Dtcompra.SUM("Total").ToString.ToDecimal + If TotalProductos > 0 Then + For Each row As DataRow In Dtcompra.Rows + Dim prorrateo As Decimal + prorrateo = (row("PU").ToString.ToDecimal * TotalServicios) / TotalProductos + If Not ObjInv.UpdateCostoIndirectoMovimientoDetalle(row("CveMovimientoDetalle").ToString.ToEntero, prorrateo) Then + HayError = True + Exit For + + End If + Next + Else + Alert("No existen productos de inventario en esta factura", TipoMensaje.MsgError) + End If + End If + End If + + End If + Else + Return False + End If + + If HayError = True And ObjInv IsNot Nothing Then + Alert("Ocurrió un error al vincular un flete o servicio") + HayError = True + End If + + Return HayError + End Function + + Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) + 'dvFacturas.Visible = False + 'GvFacturas.Visible = False + 'GVServicios.Visible = False + 'UpFacturas.Update() + 'UPGVFacturas.Update() + 'UpGVServicios.Update() + End Sub + + Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs) + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + If DdlTipoComprobante.SelectedValue = "NC" Then + DivReembolso.Visible = False + RBLPago.Items(2).Enabled = False + Else + DivReembolso.Visible = True + RBLPago.Items(2).Enabled = True + End If + ImgAnticiposPendientes.Visible = False If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then paneldevolucion.Visible = True Pnlalmaceninventarios.Visible = False @@ -15919,216 +15933,216 @@ Partial Class Compras_Compras RBLPago.Items(2).Enabled = False UpPS.Update() - End If - End If - UPCondicionesPago.Update() + End If + End If + UPCondicionesPago.Update() End Sub -#Region " ENVIA CORREO NOTICIACION - VENDEDOR " - Private Sub MandaCorreoOCVendedores(CveCompra As Integer) - - 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC - If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then - Exit Sub - End If - - Dim DTCorreos As New DataTable - Dim DTMovimientos As New DataTable - Dim strBody As New StringBuilder - Dim Asunto, Para, ArrayCC, Body As String - - Dim ObjOC As New ClsOC - ObjOC.GetOrdenesCompraCorreo(CveCompra) - DTCorreos = ObjOC.DtResultados - ObjOC.GetOrdenesCompraMovimiento(CveCompra) - DTMovimientos = ObjOC.DtResultados - ObjOC.Dispose() - - - For Each row As DataRow In DTCorreos.Rows - - strBody.Clear() - - 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO - If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then - Continue For - End If - - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append("") - strBody.Append("

Vinculación de orden de compra a factura

") - strBody.Append("

") - strBody.AppendFormat(" Se ha vinculado la OC # {0} {1}.", row("Folio"), If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) - strBody.Append("
") - strBody.Append(" Con los siguientes productos:") - strBody.Append("

") - - 'DETALLES - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - - For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) - strBody.AppendFormat(" ", RowM("UnidadMedida")) - strBody.AppendFormat(" ", RowM("Codigo")) - strBody.AppendFormat(" ", RowM("PS")) - strBody.AppendFormat(" ") - Next - - strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") - strBody.Append("") - strBody.Append("") - - - '' ENVIO DEL CORREO - Asunto = "Vinculación de factura de OC " - Para = row("Correo").ToString - ArrayCC = "" - Body = strBody.ToString - Dim Mail As New ClsSisMail() - Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) - Next - - - End Sub - Private Sub MandaCorreoOCVendedoresRecepcionAlmacen(CveCompra As Integer, CveMovimiento As Integer) - - - 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC - If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then - Exit Sub - End If - - Dim DTCorreos As New DataTable - Dim DTMovimientos As New DataTable - Dim strBody As New StringBuilder - Dim Asunto, Para, ArrayCC, Body As String - - Dim ObjOC As New ClsOC - ObjOC.GetOrdenesCompraCorreo(CveCompra, CveMovimiento:=CveMovimiento) - DTCorreos = ObjOC.DtResultados - ObjOC.GetOrdenesCompraMovimiento(CveCompra, CveMovimiento:=CveMovimiento) - DTMovimientos = ObjOC.DtResultados - ObjOC.Dispose() - - - For Each row As DataRow In DTCorreos.Rows - - strBody.Clear() - - 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO - If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then - Continue For - End If - - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append("") - strBody.Append("

Notificación de recepción de material

") - strBody.Append("

") - strBody.AppendFormat(" Se confirma recepción de material en almacén {0} vinculado la OC # {1} {2}.", DTMovimientos.FiltroPrimeroValor("Almacen"), row("Folio").ToString, If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) - strBody.Append("
") - strBody.Append(" Con los siguientes productos:") - strBody.Append("

") - - 'DETALLES - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - - For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) - strBody.AppendFormat(" ", RowM("UnidadMedida")) - strBody.AppendFormat(" ", RowM("Codigo")) - strBody.AppendFormat(" ", RowM("PS")) - strBody.AppendFormat(" ") - Next - - strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") - strBody.Append("") - strBody.Append("") - - '' ENVIO DEL CORREO - Asunto = "Recepción de Material de OC " - Para = row("Correo").ToString - ArrayCC = row("CorreoAsistente").ToString - Body = strBody.ToString - Dim Mail As New ClsSisMail() - Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) - Next - - +#Region " ENVIA CORREO NOTICIACION - VENDEDOR " + Private Sub MandaCorreoOCVendedores(CveCompra As Integer) + + 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC + If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then + Exit Sub + End If + + Dim DTCorreos As New DataTable + Dim DTMovimientos As New DataTable + Dim strBody As New StringBuilder + Dim Asunto, Para, ArrayCC, Body As String + + Dim ObjOC As New ClsOC + ObjOC.GetOrdenesCompraCorreo(CveCompra) + DTCorreos = ObjOC.DtResultados + ObjOC.GetOrdenesCompraMovimiento(CveCompra) + DTMovimientos = ObjOC.DtResultados + ObjOC.Dispose() + + + For Each row As DataRow In DTCorreos.Rows + + strBody.Clear() + + 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO + If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then + Continue For + End If + + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append("") + strBody.Append("

Vinculación de orden de compra a factura

") + strBody.Append("

") + strBody.AppendFormat(" Se ha vinculado la OC # {0} {1}.", row("Folio"), If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) + strBody.Append("
") + strBody.Append(" Con los siguientes productos:") + strBody.Append("

") + + 'DETALLES + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + + For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) + strBody.AppendFormat(" ", RowM("UnidadMedida")) + strBody.AppendFormat(" ", RowM("Codigo")) + strBody.AppendFormat(" ", RowM("PS")) + strBody.AppendFormat(" ") + Next + + strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") + strBody.Append("") + strBody.Append("") + + + '' ENVIO DEL CORREO + Asunto = "Vinculación de factura de OC " + Para = row("Correo").ToString + ArrayCC = "" + Body = strBody.ToString + Dim Mail As New ClsSisMail() + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) + Next + + + End Sub + Private Sub MandaCorreoOCVendedoresRecepcionAlmacen(CveCompra As Integer, CveMovimiento As Integer) + + + 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC + If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then + Exit Sub + End If + + Dim DTCorreos As New DataTable + Dim DTMovimientos As New DataTable + Dim strBody As New StringBuilder + Dim Asunto, Para, ArrayCC, Body As String + + Dim ObjOC As New ClsOC + ObjOC.GetOrdenesCompraCorreo(CveCompra, CveMovimiento:=CveMovimiento) + DTCorreos = ObjOC.DtResultados + ObjOC.GetOrdenesCompraMovimiento(CveCompra, CveMovimiento:=CveMovimiento) + DTMovimientos = ObjOC.DtResultados + ObjOC.Dispose() + + + For Each row As DataRow In DTCorreos.Rows + + strBody.Clear() + + 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO + If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then + Continue For + End If + + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append("") + strBody.Append("

Notificación de recepción de material

") + strBody.Append("

") + strBody.AppendFormat(" Se confirma recepción de material en almacén {0} vinculado la OC # {1} {2}.", DTMovimientos.FiltroPrimeroValor("Almacen"), row("Folio").ToString, If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) + strBody.Append("
") + strBody.Append(" Con los siguientes productos:") + strBody.Append("

") + + 'DETALLES + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + + For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) + strBody.AppendFormat(" ", RowM("UnidadMedida")) + strBody.AppendFormat(" ", RowM("Codigo")) + strBody.AppendFormat(" ", RowM("PS")) + strBody.AppendFormat(" ") + Next + + strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") + strBody.Append("") + strBody.Append("") + + '' ENVIO DEL CORREO + Asunto = "Recepción de Material de OC " + Para = row("Correo").ToString + ArrayCC = row("CorreoAsistente").ToString + Body = strBody.ToString + Dim Mail As New ClsSisMail() + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) + Next + + End Sub 'VIEJO - COMENTADO IPP 12 JULIO 2017 @@ -16182,1485 +16196,1485 @@ Partial Class Compras_Compras ' Next 'End Sub -#End Region +#End Region -#End Region +#End Region -#Region " CIERRE PERIODO " - Private Function ValidaCierrePeriodo() As Boolean - 'solo se permiten, mes actual, mes anterior <= #dias - Dim mesesTrans As Integer = DateDiff(DateInterval.Month, TxtFecha.Text.ToDate, Now).ToEntero - - If mesesTrans = 0 OrElse (mesesTrans = 1 AndAlso Day(Now) <= UsuarioActual.Empresa.Funcionalidad(123).ToEntero) Then - Return True - End If - Return False - - 'Dim mesesTrans As Integer = DateDiff(DateInterval.Month, TxtFecha.Text.ToDate, Now).ToEntero - 'If mesesTrans > 1 OrElse Day(Now) >= UsuarioActual.Empresa.Funcionalidad(123).ToEntero Then - ' Return True - 'End If - 'Return False +#Region " CIERRE PERIODO " + Private Function ValidaCierrePeriodo() As Boolean + 'solo se permiten, mes actual, mes anterior <= #dias + Dim mesesTrans As Integer = DateDiff(DateInterval.Month, TxtFecha.Text.ToDate, Now).ToEntero + + If mesesTrans = 0 OrElse (mesesTrans = 1 AndAlso Day(Now) <= UsuarioActual.Empresa.Funcionalidad(123).ToEntero) Then + Return True + End If + Return False + + 'Dim mesesTrans As Integer = DateDiff(DateInterval.Month, TxtFecha.Text.ToDate, Now).ToEntero + 'If mesesTrans > 1 OrElse Day(Now) >= UsuarioActual.Empresa.Funcionalidad(123).ToEntero Then + ' Return True + 'End If + 'Return False End Function -#End Region +#End Region -#Region " AGREGA POR SERIE/LOTE " - Private Sub CreaDtDetalle() - If DtDatosDetalle Is Nothing Then - DtDatosDetalle = New DataTable - DtDatosDetalle.Columns.Add("CvePS", GetType(Integer)) - DtDatosDetalle.Columns.Add("CveUM", GetType(Integer)) - DtDatosDetalle.Columns.Add("PU", GetType(Decimal)) - DtDatosDetalle.Columns.Add("Serie", GetType(String)) - DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) - DtDatosDetalle.Columns.Add("CvePersonal", GetType(Integer)) - End If - End Sub - Private Sub CargaSerie() - - Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).Rows(0)("AplicaCaducidad").ToString = "True", True, False) - End If - - If AplicaCaducidad Then - GvSerie.Columns(1).Visible = True - TdCaducidad1.Visible = True - TdCaducidad2.Visible = True - Else - GvSerie.Columns(1).Visible = False - TdCaducidad1.Visible = False - TdCaducidad2.Visible = False - End If - - GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)) - GvSerie.DataBind() - - 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows.Count < LbCantidadSerie.Text.ToEntero Then - BtnAgregarPS.Enabled = False - Else - BtnAgregarPS.Enabled = True - End If - - 'SI TIENE ENTRADA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD - Dim Contador = 0 - For Each Gvr As GridViewRow In GvInv.Rows - Gvr.FCTextBox("TbCantidad").Enabled = False - If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then - Contador = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Gvr.DataKey("CvePS"))).Rows.Count - If DtDatosDetalle IsNot Nothing AndAlso Contador > 0 Then - Gvr.FCCheckBox("cbInv").Enabled = False - 'Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidad").Enabled = False - Gvr.FCTextBox("TbCantidad").Text = Contador.ToString - Else - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCTextBox("TbCantidad").Enabled = False - Gvr.FCTextBox("TbCantidad").Text = "0" - End If - End If - Next - - UpINV.Update() - UpSerie.Update() - TxtSerieLote.Focus() - RegistraScript(String.Format("$('#DivSerie').on('shown.bs.modal', function () {{$('#DivSerie').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivSerie').modal('show'); ", TxtSerieLote.ClientID)) - - End Sub - Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) - Dim SerieLote = TxtSerieLote.Text.Replace(" ", String.Empty) - Dim AplicaCaducidad = False - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltroPrimero("", "PS") - If dr IsNot Nothing Then AplicaCaducidad = dr("AplicaCaducidad").ToString = "True" - - 'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS - If SerieLote <> "" And (SerieLote = dr("Codigo").ToString.ToUpper Or SerieLote = dr("CodigoBarras").ToString.ToUpper) Then - Alert($"La serie indicada {SerieLote} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim Row = DtDatosDetalle.NewRow - Row("CvePS") = CvePSSerieLote - Row("CveUM") = CveUMSerieLote - Row("PU") = PUSerieLote - Row("Serie") = SerieLote - Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString) - DtDatosDetalle.Rows.Add(Row) - - TxtSerieLote.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString - - CargaSerie() - End Sub - Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs) - - Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) - - LbProducto.Text = Argumentos(3) - LbCantidadSerie.Text = Argumentos(4) - - CvePSSerieLote = Argumentos(0).ToEntero - CveUMSerieLote = Argumentos(1).ToEntero - PUSerieLote = Argumentos(2).ToDecimal - - - CargaSerie() - End Sub - Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting - DtDatosDetalle.Rows.Remove(DtDatosDetalle.Rows(e.RowIndex)) - CargaSerie() +#Region " AGREGA POR SERIE/LOTE " + Private Sub CreaDtDetalle() + If DtDatosDetalle Is Nothing Then + DtDatosDetalle = New DataTable + DtDatosDetalle.Columns.Add("CvePS", GetType(Integer)) + DtDatosDetalle.Columns.Add("CveUM", GetType(Integer)) + DtDatosDetalle.Columns.Add("PU", GetType(Decimal)) + DtDatosDetalle.Columns.Add("Serie", GetType(String)) + DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) + DtDatosDetalle.Columns.Add("CvePersonal", GetType(Integer)) + End If End Sub -#End Region + Private Sub CargaSerie() + + Dim AplicaCaducidad = False + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).Rows(0) IsNot Nothing Then + AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).Rows(0)("AplicaCaducidad").ToString = "True", True, False) + End If + + If AplicaCaducidad Then + GvSerie.Columns(1).Visible = True + TdCaducidad1.Visible = True + TdCaducidad2.Visible = True + Else + GvSerie.Columns(1).Visible = False + TdCaducidad1.Visible = False + TdCaducidad2.Visible = False + End If + + GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)) + GvSerie.DataBind() + + 'VALIDA QUE SIGA AGREGANDO + If Not DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows.Count < LbCantidadSerie.Text.ToEntero Then + BtnAgregarPS.Enabled = False + Else + BtnAgregarPS.Enabled = True + End If + + 'SI TIENE ENTRADA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD + Dim Contador = 0 + For Each Gvr As GridViewRow In GvInv.Rows + Gvr.FCTextBox("TbCantidad").Enabled = False + If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then + Contador = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Gvr.DataKey("CvePS"))).Rows.Count + If DtDatosDetalle IsNot Nothing AndAlso Contador > 0 Then + Gvr.FCCheckBox("cbInv").Enabled = False + 'Gvr.FCCheckBox("cbInv").Checked = True + Gvr.FCTextBox("TbCantidad").Enabled = False + Gvr.FCTextBox("TbCantidad").Text = Contador.ToString + Else + Gvr.FCCheckBox("cbInv").Enabled = False + Gvr.FCTextBox("TbCantidad").Enabled = False + Gvr.FCTextBox("TbCantidad").Text = "0" + End If + End If + Next + + UpINV.Update() + UpSerie.Update() + TxtSerieLote.Focus() + RegistraScript(String.Format("$('#DivSerie').on('shown.bs.modal', function () {{$('#DivSerie').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivSerie').modal('show'); ", TxtSerieLote.ClientID)) -#Region " TIPO CAMBIO " - Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) - CambiaMoneda() - End Sub - Private Sub CambiaMoneda(Optional RecargaTipoCambio As Boolean = True) - TxtFecha.Attributes.Remove("onblur") - - If DdlMoneda.SelectedValue.ToEntero > 1 Then - TipoCambio = If(RecargaTipoCambio, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) - LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) - TxtTC.Text = TipoCambio.ToString("N4") - If UsuarioActual.Empresa.UsaAC Then - TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") - Else - TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") - End If - - If CveCompra <= 0 Then 'And CveFactura <= 0 [IPP] 11Junio2018 - DivTC.Visible = True - LblTC.Visible = False - Else - DivTC.Visible = False - LblTC.Visible = True - End If - - Else - - If UsuarioActual.CveEmpresa.Contiene({4, 7, 11, 12, 145}) Then - RegistraScript("$('#ModalPesos').modal('show');") - TxtConvertirPesos.Text = If(TipoCambio > 0, TipoCambio, GlobalTipoCambio(TxtFecha.Text.ToDate)).ToString.FormatoNumero - End If - - TipoCambio = 1 - LblTC.Text = "" - TxtTC.Text = "" - If UsuarioActual.Empresa.UsaAC Then - TxtFecha.Attributes.Add("onblur", "CambiaFecha()") - End If - End If - - CargaCuentas() - End Sub - Protected Sub BtnCambiaFechaTC_Click(sender As Object, e As EventArgs) - LblTC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.FormatoNumero(4) - TxtTC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.FormatoNumero(4) End Sub -#End Region + Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) + Dim SerieLote = TxtSerieLote.Text.Replace(" ", String.Empty) + Dim AplicaCaducidad = False + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltroPrimero("", "PS") + If dr IsNot Nothing Then AplicaCaducidad = dr("AplicaCaducidad").ToString = "True" -#Region " CONVERTIR PESOS " - Protected Sub BtnConvertirPesos_Click(sender As Object, e As EventArgs) - Dim TipoCambioTemp = TxtConvertirPesos.Text.ToDouble - - If TipoCambioTemp <= 0 Then - Exit Sub - End If - - For Each Dr As DataRow In TmpDT.Rows - Dr("PU") = Dr("PU").ToString.ToDecimal * TipoCambioTemp - Dr("IVA") = Dr("IVA").ToString.ToDecimal * TipoCambioTemp - Dr("RetIVA") = Dr("RetIVA").ToString.ToDecimal * TipoCambioTemp - Dr("RetISR") = Dr("RetISR").ToString.ToDecimal * TipoCambioTemp - Dr("IEPSPS") = Dr("IEPSPS").ToString.ToDecimal * TipoCambioTemp - Dr("Descuento") = Dr("Descuento").ToString.ToDecimal * TipoCambioTemp - Dr("OtrosGastos") = Dr("OtrosGastos").ToString.ToDecimal * TipoCambioTemp - - Dim Total = (Dr("Cantidad").ToString.ToDecimal * Dr("PU").ToString.ToDecimal) - Dr("Descuento").ToString.ToDecimal + Dr("OtrosGastos").ToString.ToDecimal - Dr("Total") = Total - Next - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - - TxtSubTotal.Text = (TmpDT.SUMD("Total") + TmpDT.SUMD("Descuento")).FormatoNumero - TxtSubTotal2.Text = TmpDT.SUMD("Total").FormatoNumero() - TxtIVA.Text = TmpDT.SUMD("IVA").FormatoNumero() - - 'IPP CAMBIADO - 5 DICIEMBRE 2016 - 'TxtTotal.Text = (TxtSubTotal2.Text.ToDouble + TxtIVA.Text.ToDouble).ToString.FormatoNumero.Replace(","c, "") - TxtTotal.Text = (TmpDT.SUMD("Total") + TmpDT.SUMD("IVA") + TmpDT.SUMD("IEPSPS") - TmpDT.SUMD("RetIVA") - TmpDT.SUMD("RetISR")).FormatoNumero - - - SubTotalOriginal = TxtSubTotal.Text.ToDouble - SubTotal2Original = TxtSubTotal2.Text.ToDouble - - If TrDescuento.Visible Then TxtDescuento.Text = (TmpDT.SUMD("Descuento")).ToString.FormatoNumero - If TrRetIVA.Visible Then TxtRetIVA.Text = (TmpDT.SUMD("RetIVA")).ToString.FormatoNumero - If TrRetISR.Visible Then TxtRetISR.Text = (TmpDT.SUMD("RetISR")).ToString.FormatoNumero - If TrIEPS.Visible Then TxtIEPS.Text = (TmpDT.SUMD("IEPSPS")).ToString.FormatoNumero - If TrOtrosImpuestos.Visible Then TxtOtrosImpuestos.Text = (TmpDT.SUMD("OtrosGastos")).ToString.FormatoNumero - If TrRedondeo.Visible Then TxtRedondeo.Text = (TxtRedondeo.Text.ToDouble * TipoCambioTemp).ToString.FormatoNumero.Replace(","c, "") - - - If TxtSubTotal2.Text.ToDouble <> TmpDT.SUM("Total") Then - AjustaImporteUltimoConcepto((TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal) - End If - - DdlMoneda.Enabled = False - RegistraScript("$('#ModalPesos').modal('hide');") + 'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS + If SerieLote <> "" And (SerieLote = dr("Codigo").ToString.ToUpper Or SerieLote = dr("CodigoBarras").ToString.ToUpper) Then + Alert($"La serie indicada {SerieLote} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim Row = DtDatosDetalle.NewRow + Row("CvePS") = CvePSSerieLote + Row("CveUM") = CveUMSerieLote + Row("PU") = PUSerieLote + Row("Serie") = SerieLote + Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString) + DtDatosDetalle.Rows.Add(Row) + + TxtSerieLote.Text = "" + TxtFechaCaducidad.Text = Now.ToShortDateString + + CargaSerie() End Sub -#End Region + Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs) -#Region " TOTALES: VALIDA Y CALCULA " - Private Sub AsignaValoresOriginales(SubTotal As Double, SubTotal2 As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double) - SubTotalOriginal = SubTotal - SubTotal2Original = SubTotal2 - IVAOriginal = IVA - RetIVAOriginal = RetIVA - RetISROriginal = RetISR - TotalOriginal = Total - End Sub - Private Sub CalculaTotales(Optional CalculaIVA As Boolean = False, Optional EsNoDeducible As Boolean = False) - 'VARIABLES DE CALCULO - Dim SubTotal, Descuentos, Amortizacion, IVA, SubTotal2, RetIVA, RetISR, IEPSPS, Total, SubTotalIVA, SubTotalIEPSIVA As Double - - 'SE ACTUALIZA EL IVA DEL DtDetalle SI ES QUE AHORA SE VA A TOMAR EN CUENTA EL IVA - 'For Each Row As DataRow In TmpDT.Rows - ' If CalculaIVA Then - ' Row("IVA") = Row("IVAPorcentaje").ToString.ToDouble * Row("Total").ToString.ToDouble - ' Else - ' Row("IVA") = 0 - ' End If - 'Next - - 'HACEMOS CALCULOS - SubTotalIVA = TmpDT.SUM("IVA") - SubTotalIEPSIVA = TmpDT.SUM("IEPSPSIVA") - SubTotal = TmpDT.SUM("Total") + TmpDT.SUM("Descuento") - RetIVA = TmpDT.SUM("RetIVA") - RetISR = TmpDT.SUM("RetISR") - IEPSPS = TmpDT.SUM("IEPSPS") - IVA = If(TmpDT.SUM("IVA") > 0, SubTotalIVA + SubTotalIEPSIVA, 0) - 'If CalculaIVA Then IVA = TxtIVA.Text.ToDouble - Descuentos = TmpDT.SUM("Descuento") - - '[IPP] SI YA ES COMPRA REGISTRADA NO CONSIDERA LA AMORTIZACIÓN PARA EL CALCULO DE TOTAL - If Not CveCompra > 0 Then - Amortizacion = LblAmortizacion.Text.Trim.ToDouble - End If - - 'RETENCIONES - Dim Retenciones = 0D - Retenciones = TxtRetIVA.Text.ToDecimal - Retenciones += TxtRetISR.Text.ToDecimal - - - SubTotal2 = SubTotal - Descuentos ' - Amortizacion '[IPP] COMENTADO CASO JAM 12653 CON NC 27122 | 23/MAYO/2018 - Total = SubTotal2 + IVA + IEPSPS - Retenciones - - 'ASIGNAMOS VALORES A VISTA - If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then - TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() - TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() - TxtDescuento.Text = Descuentos.ToString.FormatoNumero() - If EsNoDeducible Then - TxtIVA.Text = IVA.ToString.FormatoNumero() - TxtRetIVA.Text = RetIVA.ToString.FormatoNumero() - If TxtRetIVA.Text.ToDouble > 0 Then TrRetIVA.Visible = True - TxtRetISR.Text = RetISR.ToString.FormatoNumero() - If TxtRetISR.Text.ToDouble > 0 Then TrRetISR.Visible = True - TxtIEPS.Text = IEPSPS.ToString.FormatoNumero() - If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True - End If - If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True - If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Then TxtTotal.Text = Total.ToString.FormatoNumero() - Else - TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() - TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() - TxtIVA.Text = IVA.ToString.FormatoNumero() - TxtDescuento.Text = Descuentos.ToString.FormatoNumero() - If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True - TxtRetIVA.Text = RetIVA.ToString.FormatoNumero() - If TxtRetIVA.Text.ToDouble > 0 Then TrRetIVA.Visible = True - TxtRetISR.Text = RetISR.ToString.FormatoNumero() - If TxtRetISR.Text.ToDouble > 0 Then TrRetISR.Visible = True - TxtIEPS.Text = IEPSPS.ToString.FormatoNumero() - If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True - TxtTotal.Text = Total.ToString.FormatoNumero() - - 'VALORES PROPIEDAD - CompraSaldo = Total - HfTotalCompra.Value = Total.ToString - End If - - 'CUANDO SEA COMPRA, FACTURA O VENGA DE VINCULACIÓN OC NO SE MODIFICAN VALORES - 'SE VERIFICA SI ALGUN DATO ES DIFERENTE PARA MOSTRAR COLUMNA CON VALORES ORIGINALES - If (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) And Not EsNoDeducible Then - If SubTotal <> SubTotalOriginal Then - OriginalesVisible(True) - LbSubTotalOriginal.Text = SubTotalOriginal.ToString.FormatoNumero(2) - Else - OriginalesVisible(False) - End If - End If - - LblRetIVA.Text = (If(SubTotal2 > 0, (RetIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%" - LblRetISR.Text = (If(SubTotal2 > 0, (RetISR / SubTotal2), 0) * 100).FormatoNumero(3) - - 'IMPORTES DE RESTRICCION - TxtDocumentoImporteFE.Text = Total.ToString.FormatoNumero(2) - RVDocumentoImporte.MaximumValue = Total.ToString.FormatoNumero(2) - RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - - CargaRetIVAConcepto() + Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) + + LbProducto.Text = Argumentos(3) + LbCantidadSerie.Text = Argumentos(4) + + CvePSSerieLote = Argumentos(0).ToEntero + CveUMSerieLote = Argumentos(1).ToEntero + PUSerieLote = Argumentos(2).ToDecimal + + + CargaSerie() + End Sub + Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting + DtDatosDetalle.Rows.Remove(DtDatosDetalle.Rows(e.RowIndex)) + CargaSerie() + End Sub +#End Region + +#Region " TIPO CAMBIO " + Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) + CambiaMoneda() + End Sub + Private Sub CambiaMoneda(Optional RecargaTipoCambio As Boolean = True) + TxtFecha.Attributes.Remove("onblur") + + If DdlMoneda.SelectedValue.ToEntero > 1 Then + TipoCambio = If(RecargaTipoCambio, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) + LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) + TxtTC.Text = TipoCambio.ToString("N4") + If UsuarioActual.Empresa.UsaAC Then + TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") + Else + TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") + End If + + If CveCompra <= 0 Then 'And CveFactura <= 0 [IPP] 11Junio2018 + DivTC.Visible = True + LblTC.Visible = False + Else + DivTC.Visible = False + LblTC.Visible = True + End If + + Else + + If UsuarioActual.CveEmpresa.Contiene({4, 7, 11, 12, 145}) Then + RegistraScript("$('#ModalPesos').modal('show');") + TxtConvertirPesos.Text = If(TipoCambio > 0, TipoCambio, GlobalTipoCambio(TxtFecha.Text.ToDate)).ToString.FormatoNumero + End If + + TipoCambio = 1 + LblTC.Text = "" + TxtTC.Text = "" + If UsuarioActual.Empresa.UsaAC Then + TxtFecha.Attributes.Add("onblur", "CambiaFecha()") + End If + End If + + CargaCuentas() + End Sub + Protected Sub BtnCambiaFechaTC_Click(sender As Object, e As EventArgs) + LblTC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.FormatoNumero(4) + TxtTC.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.FormatoNumero(4) + End Sub +#End Region + +#Region " CONVERTIR PESOS " + Protected Sub BtnConvertirPesos_Click(sender As Object, e As EventArgs) + Dim TipoCambioTemp = TxtConvertirPesos.Text.ToDouble + + If TipoCambioTemp <= 0 Then + Exit Sub + End If + + For Each Dr As DataRow In TmpDT.Rows + Dr("PU") = Dr("PU").ToString.ToDecimal * TipoCambioTemp + Dr("IVA") = Dr("IVA").ToString.ToDecimal * TipoCambioTemp + Dr("RetIVA") = Dr("RetIVA").ToString.ToDecimal * TipoCambioTemp + Dr("RetISR") = Dr("RetISR").ToString.ToDecimal * TipoCambioTemp + Dr("IEPSPS") = Dr("IEPSPS").ToString.ToDecimal * TipoCambioTemp + Dr("Descuento") = Dr("Descuento").ToString.ToDecimal * TipoCambioTemp + Dr("OtrosGastos") = Dr("OtrosGastos").ToString.ToDecimal * TipoCambioTemp + + Dim Total = (Dr("Cantidad").ToString.ToDecimal * Dr("PU").ToString.ToDecimal) - Dr("Descuento").ToString.ToDecimal + Dr("OtrosGastos").ToString.ToDecimal + Dr("Total") = Total + Next + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + + TxtSubTotal.Text = (TmpDT.SUMD("Total") + TmpDT.SUMD("Descuento")).FormatoNumero + TxtSubTotal2.Text = TmpDT.SUMD("Total").FormatoNumero() + TxtIVA.Text = TmpDT.SUMD("IVA").FormatoNumero() + + 'IPP CAMBIADO - 5 DICIEMBRE 2016 + 'TxtTotal.Text = (TxtSubTotal2.Text.ToDouble + TxtIVA.Text.ToDouble).ToString.FormatoNumero.Replace(","c, "") + TxtTotal.Text = (TmpDT.SUMD("Total") + TmpDT.SUMD("IVA") + TmpDT.SUMD("IEPSPS") - TmpDT.SUMD("RetIVA") - TmpDT.SUMD("RetISR")).FormatoNumero + + + SubTotalOriginal = TxtSubTotal.Text.ToDouble + SubTotal2Original = TxtSubTotal2.Text.ToDouble + + If TrDescuento.Visible Then TxtDescuento.Text = (TmpDT.SUMD("Descuento")).ToString.FormatoNumero + If TrRetIVA.Visible Then TxtRetIVA.Text = (TmpDT.SUMD("RetIVA")).ToString.FormatoNumero + If TrRetISR.Visible Then TxtRetISR.Text = (TmpDT.SUMD("RetISR")).ToString.FormatoNumero + If TrIEPS.Visible Then TxtIEPS.Text = (TmpDT.SUMD("IEPSPS")).ToString.FormatoNumero + If TrOtrosImpuestos.Visible Then TxtOtrosImpuestos.Text = (TmpDT.SUMD("OtrosGastos")).ToString.FormatoNumero + If TrRedondeo.Visible Then TxtRedondeo.Text = (TxtRedondeo.Text.ToDouble * TipoCambioTemp).ToString.FormatoNumero.Replace(","c, "") + + + If TxtSubTotal2.Text.ToDouble <> TmpDT.SUM("Total") Then + AjustaImporteUltimoConcepto((TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal) + End If + + DdlMoneda.Enabled = False + RegistraScript("$('#ModalPesos').modal('hide');") + End Sub +#End Region + +#Region " TOTALES: VALIDA Y CALCULA " + Private Sub AsignaValoresOriginales(SubTotal As Double, SubTotal2 As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double) + SubTotalOriginal = SubTotal + SubTotal2Original = SubTotal2 + IVAOriginal = IVA + RetIVAOriginal = RetIVA + RetISROriginal = RetISR + TotalOriginal = Total + End Sub + Private Sub CalculaTotales(Optional CalculaIVA As Boolean = False, Optional EsNoDeducible As Boolean = False) + 'VARIABLES DE CALCULO + Dim SubTotal, Descuentos, Amortizacion, IVA, SubTotal2, RetIVA, RetISR, IEPSPS, Total, SubTotalIVA, SubTotalIEPSIVA As Double + + 'SE ACTUALIZA EL IVA DEL DtDetalle SI ES QUE AHORA SE VA A TOMAR EN CUENTA EL IVA + 'For Each Row As DataRow In TmpDT.Rows + ' If CalculaIVA Then + ' Row("IVA") = Row("IVAPorcentaje").ToString.ToDouble * Row("Total").ToString.ToDouble + ' Else + ' Row("IVA") = 0 + ' End If + 'Next + + 'HACEMOS CALCULOS + SubTotalIVA = TmpDT.SUM("IVA") + SubTotalIEPSIVA = TmpDT.SUM("IEPSPSIVA") + SubTotal = TmpDT.SUM("Total") + TmpDT.SUM("Descuento") + RetIVA = TmpDT.SUM("RetIVA") + RetISR = TmpDT.SUM("RetISR") + IEPSPS = TmpDT.SUM("IEPSPS") + IVA = If(TmpDT.SUM("IVA") > 0, SubTotalIVA + SubTotalIEPSIVA, 0) + 'If CalculaIVA Then IVA = TxtIVA.Text.ToDouble + Descuentos = TmpDT.SUM("Descuento") + + '[IPP] SI YA ES COMPRA REGISTRADA NO CONSIDERA LA AMORTIZACIÓN PARA EL CALCULO DE TOTAL + If Not CveCompra > 0 Then + Amortizacion = LblAmortizacion.Text.Trim.ToDouble + End If + + 'RETENCIONES + Dim Retenciones = 0D + Retenciones = TxtRetIVA.Text.ToDecimal + Retenciones += TxtRetISR.Text.ToDecimal + + + SubTotal2 = SubTotal - Descuentos ' - Amortizacion '[IPP] COMENTADO CASO JAM 12653 CON NC 27122 | 23/MAYO/2018 + Total = SubTotal2 + IVA + IEPSPS - Retenciones + + 'ASIGNAMOS VALORES A VISTA + If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then + TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() + TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() + TxtDescuento.Text = Descuentos.ToString.FormatoNumero() + If EsNoDeducible Then + TxtIVA.Text = IVA.ToString.FormatoNumero() + TxtRetIVA.Text = RetIVA.ToString.FormatoNumero() + If TxtRetIVA.Text.ToDouble > 0 Then TrRetIVA.Visible = True + TxtRetISR.Text = RetISR.ToString.FormatoNumero() + If TxtRetISR.Text.ToDouble > 0 Then TrRetISR.Visible = True + TxtIEPS.Text = IEPSPS.ToString.FormatoNumero() + If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True + End If + If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True + If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Then TxtTotal.Text = Total.ToString.FormatoNumero() + Else + TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() + TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() + TxtIVA.Text = IVA.ToString.FormatoNumero() + TxtDescuento.Text = Descuentos.ToString.FormatoNumero() + If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True + TxtRetIVA.Text = RetIVA.ToString.FormatoNumero() + If TxtRetIVA.Text.ToDouble > 0 Then TrRetIVA.Visible = True + TxtRetISR.Text = RetISR.ToString.FormatoNumero() + If TxtRetISR.Text.ToDouble > 0 Then TrRetISR.Visible = True + TxtIEPS.Text = IEPSPS.ToString.FormatoNumero() + If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True + TxtTotal.Text = Total.ToString.FormatoNumero() + + 'VALORES PROPIEDAD + CompraSaldo = Total + HfTotalCompra.Value = Total.ToString + End If + + 'CUANDO SEA COMPRA, FACTURA O VENGA DE VINCULACIÓN OC NO SE MODIFICAN VALORES + 'SE VERIFICA SI ALGUN DATO ES DIFERENTE PARA MOSTRAR COLUMNA CON VALORES ORIGINALES + If (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) And Not EsNoDeducible Then + If SubTotal <> SubTotalOriginal Then + OriginalesVisible(True) + LbSubTotalOriginal.Text = SubTotalOriginal.ToString.FormatoNumero(2) + Else + OriginalesVisible(False) + End If + End If + + LblRetIVA.Text = (If(SubTotal2 > 0, (RetIVA / SubTotal2), 0) * 100).FormatoNumero(3) + "%" + LblRetISR.Text = (If(SubTotal2 > 0, (RetISR / SubTotal2), 0) * 100).FormatoNumero(3) + + 'IMPORTES DE RESTRICCION + TxtDocumentoImporteFE.Text = Total.ToString.FormatoNumero(2) + RVDocumentoImporte.MaximumValue = Total.ToString.FormatoNumero(2) + RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + + CargaRetIVAConcepto() CargaRetISRConcepto() - End Sub - Private Sub OriginalesVisible(Accion As Boolean) - tdT0.Visible = Accion - tdT1.Visible = Accion - tdT2.Visible = Accion - tdT3.Visible = Accion - tdT4.Visible = Accion - tdT5.Visible = Accion - tdT6.Visible = Accion - tdT7.Visible = Accion - tdT8.Visible = Accion - tdT9.Visible = Accion - tdT10.Visible = Accion - tdT11.Visible = Accion - End Sub - - Private Function ValidaTotalesGuardar() As Boolean - Dim EsValido = True - - 'VALIDA IMPORTES - 'VALIDA TOTAL CON LOS IMPORTES TOTALES - Dim TempSubTotal, TempDescuentos, TempIVA, TempSubTotal2, TempRetIVA, TempRetISR, TempTotal, DifTotales, TempIEPS As Double - 'Dim TempPorcentajeRetIVA = LblRetIVA.Text.ToDouble / 100 - 'Dim TempPorcentajeRetISR = LblRetISR.Text.ToDouble / 100 - Dim Amortizacion As Decimal = 0 + End Sub + Private Sub OriginalesVisible(Accion As Boolean) + tdT0.Visible = Accion + tdT1.Visible = Accion + tdT2.Visible = Accion + tdT3.Visible = Accion + tdT4.Visible = Accion + tdT5.Visible = Accion + tdT6.Visible = Accion + tdT7.Visible = Accion + tdT8.Visible = Accion + tdT9.Visible = Accion + tdT10.Visible = Accion + tdT11.Visible = Accion + End Sub + + Private Function ValidaTotalesGuardar() As Boolean + Dim EsValido = True + + 'VALIDA IMPORTES + 'VALIDA TOTAL CON LOS IMPORTES TOTALES + Dim TempSubTotal, TempDescuentos, TempIVA, TempSubTotal2, TempRetIVA, TempRetISR, TempTotal, DifTotales, TempIEPS As Double + 'Dim TempPorcentajeRetIVA = LblRetIVA.Text.ToDouble / 100 + 'Dim TempPorcentajeRetISR = LblRetISR.Text.ToDouble / 100 + Dim Amortizacion As Decimal = 0 If UsuarioActual.CveEmpresa = 119 Then Amortizacion = LblAmortizacion.Text.Trim.ToDecimal TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString - End If - + End If + Dim TieneAmortizacion As Boolean = False If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then TieneAmortizacion = True - End If - + End If + If CveCompra < 0 AndAlso Not TieneAmortizacion Then LblAmortizacion.Text = "0.00" - End If - - TempSubTotal = TxtSubTotal.Text.ToDouble - SubTotalOriginal = TxtSubTotal.Text.ToDouble - SubTotal2Original = TxtSubTotal2.Text.ToDouble - TempDescuentos = TxtDescuento.Text.Trim.ToDouble + Amortizacion - TempSubTotal2 = TempSubTotal - TempDescuentos - TempIVA = TxtIVA.Text.ToDouble - TempIEPS = TxtIEPS.Text.ToDouble - TempRetIVA = TxtRetIVA.Text.ToDouble - TempRetISR = TxtRetISR.Text.ToDouble - TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR - TxtOtrosImpuestos.Text.ToDouble - Amortizacion, 2) - DifTotales = TxtTotal.Text.ToDouble - TempTotal - Dim DiferenciaPermitida = 0.6 - - If Math.Abs(DifTotales) > DiferenciaPermitida Then - Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - EsValido = False - ElseIf DifTotales <> 0 Then - TxtSubTotal2.Text = (TxtSubTotal2.Text.ToDouble + DifTotales).ToString - TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + DifTotales).ToString - SubTotalOriginal = TxtSubTotal.Text.ToDouble - SubTotal2Original = TxtSubTotal2.Text.ToDouble - End If - - Dim DiferenciaSubtotales = 0.0D - If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then - - If SubTotalOriginal = Nothing Then - SubTotalOriginal = 0 - End If - - If SubTotal2Original = Nothing Then - SubTotal2Original = 0 - End If - - DiferenciaSubtotales = SubTotal2Original.ToString.ToDecimal - TmpDT.SUM("Total").ToString.ToDecimal - '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 - If CveFactura = 286290 Then - DiferenciaSubtotales += TxtDescuento.Text.ToDecimal - End If - If Math.Abs(DiferenciaSubtotales) > 1 And Not EsNoDeducible Then - Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - EsValido = False - Else - AjustaImporteUltimoConcepto(DiferenciaSubtotales) - End If - Else - DiferenciaSubtotales = (TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal - If Math.Abs(DiferenciaSubtotales) > 1 Then - Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - EsValido = False - Else - AjustaImporteUltimoConcepto(DiferenciaSubtotales) - End If - End If - - Return EsValido - End Function - - Private Sub LnkAcarreo_Click(sender As Object, e As EventArgs) Handles LnkAcarreo.Click - VerificarAcarreo() - End Sub - - Private Sub VerificarAcarreo() - RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAcarreo")) - End Sub - - Private Sub BtnAgregarAcarreo_Click(sender As Object, e As EventArgs) Handles BtnAgregarAcarreo.Click - - tDTAcarreos.Clear() - TotAcarreos = 0 - For Each Gvr As GridViewRow In GvAcarreo.Rows - If CType(Gvr.FindControl("ChkRow"), System.Web.UI.WebControls.CheckBox).Checked = True Then - Dim Row As DataRow = Nothing - Row = tDTAcarreos.NewRow - Row("CvePreEstimacion") = Gvr.DataKey("CvePreEstimacion") - Row("Importe") = Gvr.DataKey("Importe") - tDTAcarreos.Rows.Add(Row) - TotAcarreos = TotAcarreos + Gvr.DataKey("Importe").ToDouble - - End If - Next - UpPS.Update() - RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAcarreo")) + End If + + TempSubTotal = TxtSubTotal.Text.ToDouble + SubTotalOriginal = TxtSubTotal.Text.ToDouble + SubTotal2Original = TxtSubTotal2.Text.ToDouble + TempDescuentos = TxtDescuento.Text.Trim.ToDouble + Amortizacion + TempSubTotal2 = TempSubTotal - TempDescuentos + TempIVA = TxtIVA.Text.ToDouble + TempIEPS = TxtIEPS.Text.ToDouble + TempRetIVA = TxtRetIVA.Text.ToDouble + TempRetISR = TxtRetISR.Text.ToDouble + TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR - TxtOtrosImpuestos.Text.ToDouble - Amortizacion, 2) + DifTotales = TxtTotal.Text.ToDouble - TempTotal + Dim DiferenciaPermitida = 0.6 + + If Math.Abs(DifTotales) > DiferenciaPermitida Then + Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + EsValido = False + ElseIf DifTotales <> 0 Then + TxtSubTotal2.Text = (TxtSubTotal2.Text.ToDouble + DifTotales).ToString + TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + DifTotales).ToString + SubTotalOriginal = TxtSubTotal.Text.ToDouble + SubTotal2Original = TxtSubTotal2.Text.ToDouble + End If + + Dim DiferenciaSubtotales = 0.0D + If CveCompra > 0 Or CveFactura > 0 Or OCVinculada Then + + If SubTotalOriginal = Nothing Then + SubTotalOriginal = 0 + End If + + If SubTotal2Original = Nothing Then + SubTotal2Original = 0 + End If + + DiferenciaSubtotales = SubTotal2Original.ToString.ToDecimal - TmpDT.SUM("Total").ToString.ToDecimal + '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 + If CveFactura = 286290 Then + DiferenciaSubtotales += TxtDescuento.Text.ToDecimal + End If + If Math.Abs(DiferenciaSubtotales) > 1 And Not EsNoDeducible Then + Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + Else + DiferenciaSubtotales = (TxtSubTotal2.Text.ToDouble - TmpDT.SUM("Total")).ToString.ToDecimal + If Math.Abs(DiferenciaSubtotales) > 1 Then + Alert("Los importes de los conceptos (Productos/Servicios) no cuadran con el total. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + EsValido = False + Else + AjustaImporteUltimoConcepto(DiferenciaSubtotales) + End If + End If + + Return EsValido + End Function + + Private Sub LnkAcarreo_Click(sender As Object, e As EventArgs) Handles LnkAcarreo.Click + VerificarAcarreo() End Sub -#End Region -#Region "Historial de Modificacion" - Private Sub CargaGvBitacora() - ' COMENTADO POR IPP PARA SUBIR 5 ABRIL 2017 - Dim ObjGral As New ClsGenerales() - If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, CveCompra, -1, UsuarioActual.CveEmpresa) Then - GvBitacora.DataSource = ObjGral.DtResultados - GvBitacora.DataBind() - End If - ObjGral.Dispose() + Private Sub VerificarAcarreo() + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAcarreo")) End Sub -#End Region -#Region " FLETES " + Private Sub BtnAgregarAcarreo_Click(sender As Object, e As EventArgs) Handles BtnAgregarAcarreo.Click - Private Sub CargaFletes() - - If UsuarioActual.CveEmpresa <> 125 Or CveCompra > 0 Then - Exit Sub - End If - - HLModalFletes.Visible = True - - Dim ObjVentas As New ClsVentas - - If ObjVentas.GetFletes(UsuarioActual.CveEmpresa) Then - GVFletes.DataSource = ObjVentas.DtResultados - GVFletes.DataBind() - End If - - UpFletes.Update() - - ObjVentas.Dispose() + tDTAcarreos.Clear() + TotAcarreos = 0 + For Each Gvr As GridViewRow In GvAcarreo.Rows + If CType(Gvr.FindControl("ChkRow"), System.Web.UI.WebControls.CheckBox).Checked = True Then + Dim Row As DataRow = Nothing + Row = tDTAcarreos.NewRow + Row("CvePreEstimacion") = Gvr.DataKey("CvePreEstimacion") + Row("Importe") = Gvr.DataKey("Importe") + tDTAcarreos.Rows.Add(Row) + TotAcarreos = TotAcarreos + Gvr.DataKey("Importe").ToDouble + + End If + Next + UpPS.Update() + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAcarreo")) + End Sub +#End Region + +#Region "Historial de Modificacion" + Private Sub CargaGvBitacora() + ' COMENTADO POR IPP PARA SUBIR 5 ABRIL 2017 + Dim ObjGral As New ClsGenerales() + If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, CveCompra, -1, UsuarioActual.CveEmpresa) Then + GvBitacora.DataSource = ObjGral.DtResultados + GvBitacora.DataBind() + End If + ObjGral.Dispose() + End Sub +#End Region + +#Region " FLETES " + + Private Sub CargaFletes() + + If UsuarioActual.CveEmpresa <> 125 Or CveCompra > 0 Then + Exit Sub + End If + + HLModalFletes.Visible = True + + Dim ObjVentas As New ClsVentas + + If ObjVentas.GetFletes(UsuarioActual.CveEmpresa) Then + GVFletes.DataSource = ObjVentas.DtResultados + GVFletes.DataBind() + End If + + UpFletes.Update() + + ObjVentas.Dispose() End Sub -#End Region +#End Region -#Region "I M P R I M I R D E S G L O S E" +#Region "I M P R I M I R D E S G L O S E" - Private Sub LnkExportaGv_Click(sender As Object, e As EventArgs) Handles LnkExportaGv.Click - Dim dt As New DataTable - dt.Columns.Add("Consecutivo", GetType(Integer)) - dt.Columns.Add("Cantidad", GetType(Double)) - dt.Columns.Add("PS", GetType(String)) - dt.Columns.Add("Observacion", GetType(String)) - dt.Columns.Add("UM", GetType(String)) - dt.Columns.Add("Referencia", GetType(String)) - dt.Columns.Add("Personal", GetType(String)) - - For Each Gv As GridViewRow In GvPersonal.Rows - Dim Row As DataRow = Nothing - Row = dt.NewRow() - Row("Consecutivo") = Gv.FCLabel("LtlConsecutivo").Text - Row("Cantidad") = Gv.FCLiteral("LtlCantidad").Text.ToDouble - Row("UM") = Gv.FCLabel("LtlUnidadMedida").Text - Row("PS") = Gv.FCHyperLink("HplPS").Text - Row("Observacion") = Gv.Cells(4).Text - Row("Referencia") = Gv.FCTextBox("TxtReferencia").Text - Row("Personal") = Gv.FCDropDownList("DdlPersonalGv").SelectedItem - dt.Rows.Add(Row) - Next - ExportToExcel(dt, "Desglose") + Private Sub LnkExportaGv_Click(sender As Object, e As EventArgs) Handles LnkExportaGv.Click + Dim dt As New DataTable + dt.Columns.Add("Consecutivo", GetType(Integer)) + dt.Columns.Add("Cantidad", GetType(Double)) + dt.Columns.Add("PS", GetType(String)) + dt.Columns.Add("Observacion", GetType(String)) + dt.Columns.Add("UM", GetType(String)) + dt.Columns.Add("Referencia", GetType(String)) + dt.Columns.Add("Personal", GetType(String)) + + For Each Gv As GridViewRow In GvPersonal.Rows + Dim Row As DataRow = Nothing + Row = dt.NewRow() + Row("Consecutivo") = Gv.FCLabel("LtlConsecutivo").Text + Row("Cantidad") = Gv.FCLiteral("LtlCantidad").Text.ToDouble + Row("UM") = Gv.FCLabel("LtlUnidadMedida").Text + Row("PS") = Gv.FCHyperLink("HplPS").Text + Row("Observacion") = Gv.Cells(4).Text + Row("Referencia") = Gv.FCTextBox("TxtReferencia").Text + Row("Personal") = Gv.FCDropDownList("DdlPersonalGv").SelectedItem + dt.Rows.Add(Row) + Next + ExportToExcel(dt, "Desglose") End Sub -#End Region +#End Region 'DE AQUI PARA ABAJO SE ESTAN REORDENANDO REGIONES --- FAVOR DE SI SE MUEVE UNA COSITA O SE HACE UNA NUEVA FUNCION/METODO AGRUPARLO EN LA REGION CORRECTA O GENERAR UNA EN CASO DE NO EXISTIR -#Region " MODAL ADD PS - AGREGAR Y EDITAR PS (PARTIDA-CONCEPTO) " - Private Sub HabilitaEdicionManualAgregar() - If Not (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) Then - DdlIVA.Enabled = True - TxtRetIVAModal.Enabled = True - TxtRetISRModal.Enabled = True - TxtIEPSModal.Enabled = True - End If - End Sub - - Private Sub LnkAddPS_Click(sender As Object, e As EventArgs) Handles LnkAddPS.Click - Modalidad = "A" - LimpiaAgregar() - ChkAgregar.Checked = True - divagregrarotrops.Visible = True - - UpPSS.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "divAddProducto")) - End Sub - Private Sub LimpiaAgregar() - - 'VALORES ESCONDIDOS - HdnUnidadMedida.Value = "-1" - LblUnidadMedida.Text = "UM" - HdnClasificacion.Value = "-1" - HdnPS.Value = "-1" - ViewState("IVAPS") = -1 - ViewState("RetIVA") = -1 - ViewState("RetISR") = -1 - ViewState("IEPSPS") = -1 - ViewState("IEPSPSIVA") = -1 - ChkEsNoDeduciblePS.Checked = False - - 'FORMULARIO - TxtCantidad.Text = "" - DdlClasificacion.SelectedValueExist(-1) - CargaPS(-1) - If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then - DdlPS.SelectedValue = "-1" - Else - DdlPS.SelectedValue = "" - DdlPS.SelectedText = "" - End If - ddlUM.Items.Clear() - TxtObsPS.Text = "" - DdlProyecto.SelectedValueExist(-1) - CargaSubProyecto() - DdlSubProyecto.SelectedValueExist(-1) - DdlTipoGasto.SelectedValueExist(-1) - - TxtPrecio.Text = "" - LblTotalPS.Text = "" - DdlIVA.SelectedValueExist("1") - DdlIVA.Enabled = If(CveCompra > 0 Or CveFactura > 0 Or OCVinculada, False, True) - TxtRetIVAModal.Text = "" - TxtRetISRModal.Text = "" - TxtIEPSModal.Text = "" - TxtDescuentoModal.Text = "" - TxtOtrosGastos.Text = "" - - DivAddProductoAliasPS.Visible = False - - LbAgregar.Text = "Agregar" - - UPPClasificacion.Update() - UpPSS.Update() - End Sub - Public Sub Edit_Click(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - Con = GvRow.DataKey("Consec").ToEntero - Index = Con - - 'MODALIDAD UPDATE - Modalidad = "U" - LbAgregar.Text = "Actualizar" - H1.InnerText = "Actualizar Concepto" - DivAddProductoAliasPS.Visible = False - - - 'CARGA VALROES DEL CONCEPTO - TxtCantidad.Text = GvRow.DataKey("Cantidad") - DdlClasificacion.SelectedValueExist(If(GvRow.DataKey("CveClasificacion") = "0", "-1", GvRow.DataKey("CveClasificacion"))) - DdlClasificacionChange() - - If GvRow.DataKey("CvePS") = "0" Then - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPS.SelectedValue = GvRow.DataKey("CvePS") - DdlPS.SelectedText = GvRow.DataKey("PS") - Else - DdlPS.ddl.Items.Insert(0, New ListItem(GvRow.DataKey("PS"), "0")) - End If - 'DivAddProductoAliasPS.Visible = True - Else - - 'Si el PS esta inactivo se lo inserto manual - If GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltroPrimeroValor("CveEstado", $"CvePS = '{GvRow.DataKey("CvePS")}'") <> "True" Then - DdlPS.ddl.Items.Insert(0, New ListItem(GvRow.DataKey("PS"), "0")) - Else - DdlPS.SelectedValue = GvRow.DataKey("CvePS") - End If - - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPS.SelectedText = GvRow.DataKey("PS") - End If - End If - - ddlUM.Items.Clear() - If UsuarioActual.Empresa.UsaInventarios Then - ddlUM.DataSource = GlobalDTProductosServiciosEquivalencias(GvRow.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) - Else - ddlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - End If - ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) - ddlUM.SelectedValue = "-1" - ddlUM.DataBind() - - ddlUM.SelectedValueExist(GvRow.DataKey("CveUM")) - If ddlUM.SelectedValue <> GvRow.DataKey("CveUM") Then - ddlUM.Items.Insert(1, New ListItem(GvRow.DataKey("UM"), GvRow.DataKey("CveUM"))) - ddlUM.SelectedValueExist(GvRow.DataKey("CveUM")) - End If - TxtObsPS.Text = GvRow.DataKey("Obs") - - If UsuarioActual.Empresa.Tipo_CentroCosto <> 1 And UsuarioActual.Empresa.Tipo_CentroCosto <> 2 Then - DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto")) - End If - - - CargaSubProyecto() - - - 'DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto")) - - DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto")) - DdlTipoGasto.SelectedValueExist(GvRow.DataKey("CveTipoGasto")) - - Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") - DdlIVA.Enabled = True - ChkEsNoDeduciblePS.Checked = If(GvRow.DataKey("NoDeducible").ToUpper().Contiene("TRUE", "1"), True, False) - - If PS IsNot Nothing Then - If PS("IVA").ToString.ToEntero() <> -1 Then - ' DdlIVA.Enabled = False - Else - - 'DdlIVA.Enabled = If(CveCompra > 0 Or CveFactura > 0 Or OCVinculada, False, True) - End If - End If - - Select Case GvRow.DataKey("IVAPorcentaje").ToDouble - Case 0 - DdlIVA.SelectedValue = "1" - Case 0.16 - DdlIVA.SelectedValue = "1.16" - Case 0.08 - DdlIVA.SelectedValue = "1.08" - End Select - - - - 'TxtIVAModal.Text = FormatoNumero(GvRow.DataKey("IVAPorcentaje").ToDouble * 100, 0) - TxtRetIVAModal.Text = FormatoNumero(GvRow.DataKey("RetIVAPorcentaje").ToDouble * 100, 0) - TxtRetISRModal.Text = FormatoNumero(GvRow.DataKey("RetISRPorcentaje").ToDouble * 100, 0) - TxtIEPSModal.Text = FormatoNumero(GvRow.DataKey("IEPSPSPorcentaje").ToDouble * 100, 0) - - TxtPrecio.Text = GvRow.DataKey("PU").FormatoNumero(6) - TxtDescuentoModal.Text = GvRow.DataKey("Descuento").FormatoNumero(6) - TxtOtrosGastos.Text = GvRow.DataKey("OtrosGastos").FormatoNumero - LblTotalPS.Text = GvRow.DataKey("Total").FormatoNumero - - 'FUNCIONALIDAD DE SEGUIR AGREGANDO (NO CERRAR MODAL) - ChkAgregar.Checked = False - divagregrarotrops.Visible = False - - UpPSS.Update() - RegistraScript("$('#divAddProducto').modal('show');") - End Sub - Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged - DdlClasificacionChange() - End Sub - Private Sub DdlClasificacionChange() - CargaPS(DdlClasificacion.SelectedValue.ToEntero) - - If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - Dim ObjConta As New ClsContabilidad - If ObjConta.GetRetCuenta(6, DdlClasificacion.SelectedValue.ToEntero) AndAlso ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then - Else - Alert("La clasificacion no tiene una cuenta contable asignada.", TipoMensaje.MsgAdvertencia) - End If - ObjConta.Dispose() - End If - - UPPClasificacion.Update() - End Sub - Private Sub CargaPS(CveClasificacion As Integer) - DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) - DdlPS.SelectedText = "" - DdlPS.SelectedValue = "-1" - Else - DdlPS.ddl.Items.Clear() - DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion) - DdlPS.ddl.DataBind() - DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) - End If - - End Sub - Protected Sub DdlPS_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlPS.selectedindexchange - DdlPSChange() - End Sub - Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) - If Modalidad <> "U" Or Not CveFactura > 0 Then +#Region " MODAL ADD PS - AGREGAR Y EDITAR PS (PARTIDA-CONCEPTO) " + Private Sub HabilitaEdicionManualAgregar() + If Not (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) Then + DdlIVA.Enabled = True + TxtRetIVAModal.Enabled = True + TxtRetISRModal.Enabled = True + TxtIEPSModal.Enabled = True + End If + End Sub + + Private Sub LnkAddPS_Click(sender As Object, e As EventArgs) Handles LnkAddPS.Click + Modalidad = "A" + LimpiaAgregar() + ChkAgregar.Checked = True + divagregrarotrops.Visible = True + + UpPSS.Update() + RegistraScript(String.Format("$('#{0}').modal('show');", "divAddProducto")) + End Sub + Private Sub LimpiaAgregar() + + 'VALORES ESCONDIDOS + HdnUnidadMedida.Value = "-1" + LblUnidadMedida.Text = "UM" + HdnClasificacion.Value = "-1" + HdnPS.Value = "-1" + ViewState("IVAPS") = -1 + ViewState("RetIVA") = -1 + ViewState("RetISR") = -1 + ViewState("IEPSPS") = -1 + ViewState("IEPSPSIVA") = -1 + ChkEsNoDeduciblePS.Checked = False + + 'FORMULARIO + TxtCantidad.Text = "" + DdlClasificacion.SelectedValueExist(-1) + CargaPS(-1) + If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then + DdlPS.SelectedValue = "-1" + Else + DdlPS.SelectedValue = "" + DdlPS.SelectedText = "" + End If + ddlUM.Items.Clear() + TxtObsPS.Text = "" + DdlProyecto.SelectedValueExist(-1) + CargaSubProyecto() + DdlSubProyecto.SelectedValueExist(-1) + DdlTipoGasto.SelectedValueExist(-1) + + TxtPrecio.Text = "" + LblTotalPS.Text = "" + DdlIVA.SelectedValueExist("1") + DdlIVA.Enabled = If(CveCompra > 0 Or CveFactura > 0 Or OCVinculada, False, True) + TxtRetIVAModal.Text = "" + TxtRetISRModal.Text = "" + TxtIEPSModal.Text = "" + TxtDescuentoModal.Text = "" + TxtOtrosGastos.Text = "" + + DivAddProductoAliasPS.Visible = False + + LbAgregar.Text = "Agregar" + + UPPClasificacion.Update() + UpPSS.Update() + End Sub + Public Sub Edit_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Con = GvRow.DataKey("Consec").ToEntero + Index = Con + + 'MODALIDAD UPDATE + Modalidad = "U" + LbAgregar.Text = "Actualizar" + H1.InnerText = "Actualizar Concepto" + DivAddProductoAliasPS.Visible = False + + + 'CARGA VALROES DEL CONCEPTO + TxtCantidad.Text = GvRow.DataKey("Cantidad") + DdlClasificacion.SelectedValueExist(If(GvRow.DataKey("CveClasificacion") = "0", "-1", GvRow.DataKey("CveClasificacion"))) + DdlClasificacionChange() + + If GvRow.DataKey("CvePS") = "0" Then + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.SelectedValue = GvRow.DataKey("CvePS") + DdlPS.SelectedText = GvRow.DataKey("PS") + Else + DdlPS.ddl.Items.Insert(0, New ListItem(GvRow.DataKey("PS"), "0")) + End If + 'DivAddProductoAliasPS.Visible = True + Else + + 'Si el PS esta inactivo se lo inserto manual + If GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltroPrimeroValor("CveEstado", $"CvePS = '{GvRow.DataKey("CvePS")}'") <> "True" Then + DdlPS.ddl.Items.Insert(0, New ListItem(GvRow.DataKey("PS"), "0")) + Else + DdlPS.SelectedValue = GvRow.DataKey("CvePS") + End If + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.SelectedText = GvRow.DataKey("PS") + End If + End If + + ddlUM.Items.Clear() + If UsuarioActual.Empresa.UsaInventarios Then + ddlUM.DataSource = GlobalDTProductosServiciosEquivalencias(GvRow.DataKey("CvePS").ToEntero, -1, UsuarioActual.CveEmpresa) + Else + ddlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + End If + ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) + ddlUM.SelectedValue = "-1" + ddlUM.DataBind() + + ddlUM.SelectedValueExist(GvRow.DataKey("CveUM")) + If ddlUM.SelectedValue <> GvRow.DataKey("CveUM") Then + ddlUM.Items.Insert(1, New ListItem(GvRow.DataKey("UM"), GvRow.DataKey("CveUM"))) + ddlUM.SelectedValueExist(GvRow.DataKey("CveUM")) + End If + TxtObsPS.Text = GvRow.DataKey("Obs") + + If UsuarioActual.Empresa.Tipo_CentroCosto <> 1 And UsuarioActual.Empresa.Tipo_CentroCosto <> 2 Then + DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto")) + End If + + + CargaSubProyecto() + + + 'DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto")) + + DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto")) + DdlTipoGasto.SelectedValueExist(GvRow.DataKey("CveTipoGasto")) + + Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") + DdlIVA.Enabled = True + ChkEsNoDeduciblePS.Checked = If(GvRow.DataKey("NoDeducible").ToUpper().Contiene("TRUE", "1"), True, False) + + If PS IsNot Nothing Then + If PS("IVA").ToString.ToEntero() <> -1 Then + ' DdlIVA.Enabled = False + Else + + 'DdlIVA.Enabled = If(CveCompra > 0 Or CveFactura > 0 Or OCVinculada, False, True) + End If + End If + + Select Case GvRow.DataKey("IVAPorcentaje").ToDouble + Case 0 + DdlIVA.SelectedValue = "1" + Case 0.16 + DdlIVA.SelectedValue = "1.16" + Case 0.08 + DdlIVA.SelectedValue = "1.08" + End Select + + + + 'TxtIVAModal.Text = FormatoNumero(GvRow.DataKey("IVAPorcentaje").ToDouble * 100, 0) + TxtRetIVAModal.Text = FormatoNumero(GvRow.DataKey("RetIVAPorcentaje").ToDouble * 100, 0) + TxtRetISRModal.Text = FormatoNumero(GvRow.DataKey("RetISRPorcentaje").ToDouble * 100, 0) + TxtIEPSModal.Text = FormatoNumero(GvRow.DataKey("IEPSPSPorcentaje").ToDouble * 100, 0) + + TxtPrecio.Text = GvRow.DataKey("PU").FormatoNumero(6) + TxtDescuentoModal.Text = GvRow.DataKey("Descuento").FormatoNumero(6) + TxtOtrosGastos.Text = GvRow.DataKey("OtrosGastos").FormatoNumero + LblTotalPS.Text = GvRow.DataKey("Total").FormatoNumero + + 'FUNCIONALIDAD DE SEGUIR AGREGANDO (NO CERRAR MODAL) + ChkAgregar.Checked = False + divagregrarotrops.Visible = False + + UpPSS.Update() + RegistraScript("$('#divAddProducto').modal('show');") + End Sub + Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged + DdlClasificacionChange() + End Sub + Private Sub DdlClasificacionChange() + CargaPS(DdlClasificacion.SelectedValue.ToEntero) + + If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + Dim ObjConta As New ClsContabilidad + If ObjConta.GetRetCuenta(6, DdlClasificacion.SelectedValue.ToEntero) AndAlso ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then + Else + Alert("La clasificacion no tiene una cuenta contable asignada.", TipoMensaje.MsgAdvertencia) + End If + ObjConta.Dispose() + End If + + UPPClasificacion.Update() + End Sub + Private Sub CargaPS(CveClasificacion As Integer) + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + DdlPS.SelectedText = "" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion) + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + + End Sub + Protected Sub DdlPS_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlPS.selectedindexchange + DdlPSChange() + End Sub + Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + If Modalidad <> "U" Or Not CveFactura > 0 Then DdlPSChange() - End If - End Sub - Private Sub DdlPSChange() - If CveProveedor > 0 Then - If DdlPS.SelectedValue.ToEntero > 0 Then - Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") - - If PS IsNot Nothing Then - HdnClasificacion.Value = PS("Clasificacion").ToString - HdnUnidadMedida.Value = PS("CveUM").ToString - HdnTipoPS.Value = PS("CveTipoPS").ToString - HdnPS.Value = PS("PS").ToString - LblUnidadMedida.Text = PS("UnidadMedida").ToString - - - ddlUM.Items.Clear() - If UsuarioActual.Empresa.UsaInventarios Then - ddlUM.DataSource = GlobalDTProductosServiciosEquivalencias(PS("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) - Else - ddlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - End If - ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) - ddlUM.SelectedValue = "-1" - ddlUM.DataBind() - ddlUM.SelectedValueExist(PS("CveUnidadMedida").ToString) - - 'HdnIVAPS.Value = If(PS.Rows(0)("IVA").ToString = "-1", ViewState("IVA"), PS.Rows(0)("IVA").ToString).ToString - ViewState("IVAPS") = PS("IVA").ToString - If ViewState("IVAPS").ToString.ToEntero() = -1 Then - Dim Drr As DataRow = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero())(0) - ViewState("IVAPS") = Drr("IVA").ToString().ToDouble() + End If + End Sub + Private Sub DdlPSChange() + If CveProveedor > 0 Then + If DdlPS.SelectedValue.ToEntero > 0 Then + Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") + + If PS IsNot Nothing Then + HdnClasificacion.Value = PS("Clasificacion").ToString + HdnUnidadMedida.Value = PS("CveUM").ToString + HdnTipoPS.Value = PS("CveTipoPS").ToString + HdnPS.Value = PS("PS").ToString + LblUnidadMedida.Text = PS("UnidadMedida").ToString + + + ddlUM.Items.Clear() + If UsuarioActual.Empresa.UsaInventarios Then + ddlUM.DataSource = GlobalDTProductosServiciosEquivalencias(PS("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) + Else + ddlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + End If + ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) + ddlUM.SelectedValue = "-1" + ddlUM.DataBind() + ddlUM.SelectedValueExist(PS("CveUnidadMedida").ToString) + + 'HdnIVAPS.Value = If(PS.Rows(0)("IVA").ToString = "-1", ViewState("IVA"), PS.Rows(0)("IVA").ToString).ToString + ViewState("IVAPS") = PS("IVA").ToString + If ViewState("IVAPS").ToString.ToEntero() = -1 Then + Dim Drr As DataRow = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero())(0) + ViewState("IVAPS") = Drr("IVA").ToString().ToDouble() DdlProyecto.SelectedValueExist(Drr("CveProyecto")) 'DdlIVA.Enabled = True - If Not Modalidad = "U" Then - - Select Case ViewState("IVAPS").ToString().ToDouble - Case 0 - DdlIVA.SelectedValue = "1" - Case 0.16 - DdlIVA.SelectedValue = "1.16" - Case 0.08 - DdlIVA.SelectedValue = "1.08" - End Select - - End If - - - - Else - 'DdlIVA.SelectedValue = "1" - ' DdlIVA.Enabled = False - End If - - ViewState("RetIVA") = If(PS("RetIVA").ToString = "-1", ViewState("RetIVA"), PS("RetIVA").ToString).ToString - ViewState("RetISR") = If(PS("RetISR").ToString = "-1", ViewState("RetISR"), PS("RetISR").ToString).ToString - ViewState("IEPSPS") = If(PS("IEPSPorcentaje").ToString = "-1", ViewState("IEPSPS"), PS("IEPSPorcentaje").ToString).ToString - ViewState("IEPSPSIVA") = If(PS("IEPSGrabaIVA").ToString = "True", PS("IEPSPorcentaje").ToString.ToDouble, 0) - - - 'TxtIVAModal.Text = FormatoNumero(ViewState("IVAPS").ToString().ToDouble * 100, 0) - TxtRetIVAModal.Text = FormatoNumero(ViewState("RetIVA").ToString().ToDouble * 100, 0) - TxtRetISRModal.Text = FormatoNumero(ViewState("RetISR").ToString().ToDouble * 100, 0) - TxtIEPSModal.Text = FormatoNumero(ViewState("IEPSPS").ToString().ToDouble * 100, 0) - - UpIVA.Update() - - If DdlClasificacion.SelectedIndex = 0 Then - If PS("CveClasificacion").ToString IsNot Nothing Then - DdlClasificacion.SelectedValueExist(PS("CveClasificacion").ToString) - Else - Alert("El Productos/Servicio no tiene asignada una Clasificación.") - End If - - End If - UPPUM.Update() - UpPSS.Update() - End If - Else - 'SI ES UN PS NO REGISTRADO INSERTAMOS SELECCIONE - ddlUM.Items.Clear() - ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) - ddlUM.SelectedValue = "-1" - End If - Else - Alert("Es necesario seleccionar el Proveedor al cual se le va a capturar.", TipoMensaje.MsgAdvertencia, "AbrirVentana(""/Compras/PopUpBuscarProveedor.aspx?Opt=Fact"", 800, 547, ""N"", ""PopUpBuscar"")") - End If - End Sub - Private Sub CargaProyecto() - DdlProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) - - 'DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1) - DdlProyecto.DataBind() - End Sub - Protected Sub DdlProyectoAsignado_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargaSubProyecto() - End Sub - Private Sub CargaSubProyecto() - Dim CveProyecto = If(DdlProyecto.SelectedValue.ToEntero > 0, DdlProyecto.SelectedValue.ToEntero, -1) - DdlSubProyecto.Items.Clear() - If CveProyecto > 0 Or UsuarioActual.Empresa.Tipo_CentroCosto.Contiene(1, 2) Then - DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, CveProyecto, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(CveProyecto, -1, UsuarioActual.CveEmpresa, 1)) - End If - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click - - 'VALIDACIONES - If Not DdlPS.SelectedValue.ToEntero > 0 Then - Alert("Es necesario seleccionar un Producto o Servicio registrado en el sistema.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.Empresa.Tipo_CentroCosto = 3 Or UsuarioActual.Empresa.Tipo_CentroCosto = 4 Or UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then - If Not DdlProyecto.SelectedValue.ToEntero > 0 Then - Alert("Es necesario seleccionar un proyecto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - If Not DdlSubProyecto.SelectedValue.ToEntero > 0 Then - Alert("Es necesario seleccionar un subproyecto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not CveProveedor > 0 Then - Alert("Es necesario seleccionar el proveedor al cual se le va a facturar.", TipoMensaje.MsgAdvertencia, "AbrirVentana('/Compras/PopUpBuscarProveedor.aspx?Opt=Fact', 800, 547, 'N', 'PopUpBuscar')") - Exit Sub - End If - - If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then - If Not DdlTipoGasto.SelectedValue.ToEntero > 0 Then - Alert("Es necesario seleccionar un tipo de gasto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Select Case Modalidad - Case "A" - If Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> TmpDT.MAX("IVAPorcentaje").ToDouble And TmpDT.MAX("IVAPorcentaje").ToDouble <> 0 And Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> 0 And TmpDT.Rows.Count > 0 Then - Alert("No puede haber dos tipos de IVA en la compra.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Case "U" - If Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> TmpDT.FiltraParametros($"Consec <> {Index}").MAX("IVAPorcentaje").ToDouble And TmpDT.FiltraParametros($"Consec <> {Index}").MAX("IVAPorcentaje").ToDouble <> 0 And Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> 0 And TmpDT.FiltraParametros($"Consec <> {Index}").Rows.Count > 0 Then - Alert("No puede haber dos tipos de IVA en la compra.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End Select - - - Dim Total As Decimal = (TxtCantidad.Text.ToDecimal * TxtPrecio.Text.ToDecimal) - TxtDescuentoModal.Text.ToDecimal + TxtOtrosGastos.Text.ToDecimal - - If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then - Dim ObjCon As New ClsContratos - Dim CvePresupuesto As Integer = 0 - Dim Autorizado As Double = 0 - Dim Ejercido As Double = 0 - If ObjCon.GetPresupuestos(-1, "-1", DdlSubProyecto.SelectedValue.ToEntero, 2, -1, UsuarioActual.CveEmpresa) Then - If ObjCon.DtResultados.Rows.Count > 0 Then - CvePresupuesto = ObjCon.DtResultados.Rows(0)("CvePresupuesto").ToString.ToEntero - If CvePresupuesto > 0 Then - If ObjCon.GetPresupuestosDetalle(CvePresupuesto, -1, UsuarioActual.CveEmpresa) Then - If ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows.Count > 0 Then - Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows(0)("Importe").ToString.ToDouble - End If - End If - If ObjCon.GetPresupuestosRep(CvePresupuesto, DdlTipoGasto.SelectedValue.ToEntero, 1, $"01/09/{DateTime.Now.Year - 1}".ToDate, Now, UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, - DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlClasificacion.SelectedValue.ToEntero) Then - If ObjCon.DtResultados.Rows.Count > 0 Then - Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDouble - End If - End If - End If - End If - End If - ObjCon.Dispose() - - If CvePresupuesto > 0 And Autorizado > 0 Then - Dim Diferencia As Double = (Ejercido + Total) - Autorizado - If Diferencia > 0 Then - Alert($"No hay presupuesto disponible en el subproyecto {DdlSubProyecto.SelectedItem.Text} con la clasificación {DdlClasificacion.SelectedItem.Text} y el tipo de gasto {DdlTipoGasto.SelectedItem.Text}. Se excede por {Diferencia.FormatoNumero}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If - - ActualizaTotales = True - Select Case Modalidad - Case "A" 'ADD - AddPS(TxtCantidad.Text.Trim.ToDouble, ddlUM.SelectedValue.ToEntero, ddlUM.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, HdnTipoPS.Value.ToEntero, - DdlSubProyecto.SelectedValue.ToString, DdlSubProyecto.SelectedItem.Text, DdlProyecto.SelectedItem.Text, DdlProyecto.SelectedValue.ToString, TxtObsPS.Text.Trim, TxtPrecio.Text.Trim.ToDouble, Total, Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2), TxtRetIVAModal.Text.ToDouble / 100, TxtRetISRModal.Text.ToDouble / 100, TxtIEPSModal.Text.ToDouble / 100, 0, TxtDescuentoModal.Text.ToDouble, OtrosGastos:=TxtOtrosGastos.Text.ToDouble, CveTipoGasto:=DdlTipoGasto.SelectedValue.ToEntero, TipoGasto:=DdlTipoGasto.SelectedItem.Text, NoDeducible:=ChkEsNoDeduciblePS.Checked) - - AddPS2() - LimpiaAgregar() - - If ChkAgregar.Checked = True And Modalidad = "A" Then - RegistraScript("displayToastr(1);", "display") - Else - RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProducto")) - End If - - Case "U" 'UPDATE - UpdatePS() - Alert("Concepto actualizado Correctamente.", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProducto")) - End Select - ActualizaTotales = False - - If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) - - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - GuardaAC() - End If - + If Not Modalidad = "U" Then + + Select Case ViewState("IVAPS").ToString().ToDouble + Case 0 + DdlIVA.SelectedValue = "1" + Case 0.16 + DdlIVA.SelectedValue = "1.16" + Case 0.08 + DdlIVA.SelectedValue = "1.08" + End Select + + End If + + + + Else + 'DdlIVA.SelectedValue = "1" + ' DdlIVA.Enabled = False + End If + + ViewState("RetIVA") = If(PS("RetIVA").ToString = "-1", ViewState("RetIVA"), PS("RetIVA").ToString).ToString + ViewState("RetISR") = If(PS("RetISR").ToString = "-1", ViewState("RetISR"), PS("RetISR").ToString).ToString + ViewState("IEPSPS") = If(PS("IEPSPorcentaje").ToString = "-1", ViewState("IEPSPS"), PS("IEPSPorcentaje").ToString).ToString + ViewState("IEPSPSIVA") = If(PS("IEPSGrabaIVA").ToString = "True", PS("IEPSPorcentaje").ToString.ToDouble, 0) + + + 'TxtIVAModal.Text = FormatoNumero(ViewState("IVAPS").ToString().ToDouble * 100, 0) + TxtRetIVAModal.Text = FormatoNumero(ViewState("RetIVA").ToString().ToDouble * 100, 0) + TxtRetISRModal.Text = FormatoNumero(ViewState("RetISR").ToString().ToDouble * 100, 0) + TxtIEPSModal.Text = FormatoNumero(ViewState("IEPSPS").ToString().ToDouble * 100, 0) + + UpIVA.Update() + + If DdlClasificacion.SelectedIndex = 0 Then + If PS("CveClasificacion").ToString IsNot Nothing Then + DdlClasificacion.SelectedValueExist(PS("CveClasificacion").ToString) + Else + Alert("El Productos/Servicio no tiene asignada una Clasificación.") + End If + + End If + UPPUM.Update() + UpPSS.Update() + End If + Else + 'SI ES UN PS NO REGISTRADO INSERTAMOS SELECCIONE + ddlUM.Items.Clear() + ddlUM.Items.Insert(0, New ListItem("Seleccione", "-1")) + ddlUM.SelectedValue = "-1" + End If + Else + Alert("Es necesario seleccionar el Proveedor al cual se le va a capturar.", TipoMensaje.MsgAdvertencia, "AbrirVentana(""/Compras/PopUpBuscarProveedor.aspx?Opt=Fact"", 800, 547, ""N"", ""PopUpBuscar"")") + End If + End Sub + Private Sub CargaProyecto() + DdlProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) + + 'DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1) + DdlProyecto.DataBind() + End Sub + Protected Sub DdlProyectoAsignado_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged + CargaSubProyecto() + End Sub + Private Sub CargaSubProyecto() + Dim CveProyecto = If(DdlProyecto.SelectedValue.ToEntero > 0, DdlProyecto.SelectedValue.ToEntero, -1) + DdlSubProyecto.Items.Clear() + If CveProyecto > 0 Or UsuarioActual.Empresa.Tipo_CentroCosto.Contiene(1, 2) Then + DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, CveProyecto, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(CveProyecto, -1, UsuarioActual.CveEmpresa, 1)) + End If + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click + + 'VALIDACIONES + If Not DdlPS.SelectedValue.ToEntero > 0 Then + Alert("Es necesario seleccionar un Producto o Servicio registrado en el sistema.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.Empresa.Tipo_CentroCosto = 3 Or UsuarioActual.Empresa.Tipo_CentroCosto = 4 Or UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then + If Not DdlProyecto.SelectedValue.ToEntero > 0 Then + Alert("Es necesario seleccionar un proyecto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + If Not DdlSubProyecto.SelectedValue.ToEntero > 0 Then + Alert("Es necesario seleccionar un subproyecto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not CveProveedor > 0 Then + Alert("Es necesario seleccionar el proveedor al cual se le va a facturar.", TipoMensaje.MsgAdvertencia, "AbrirVentana('/Compras/PopUpBuscarProveedor.aspx?Opt=Fact', 800, 547, 'N', 'PopUpBuscar')") + Exit Sub + End If + + If UsuarioActual.Empresa.Funcionalidad(527) = "1" Then + If Not DdlTipoGasto.SelectedValue.ToEntero > 0 Then + Alert("Es necesario seleccionar un tipo de gasto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Select Case Modalidad + Case "A" + If Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> TmpDT.MAX("IVAPorcentaje").ToDouble And TmpDT.MAX("IVAPorcentaje").ToDouble <> 0 And Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> 0 And TmpDT.Rows.Count > 0 Then + Alert("No puede haber dos tipos de IVA en la compra.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Case "U" + If Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> TmpDT.FiltraParametros($"Consec <> {Index}").MAX("IVAPorcentaje").ToDouble And TmpDT.FiltraParametros($"Consec <> {Index}").MAX("IVAPorcentaje").ToDouble <> 0 And Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) <> 0 And TmpDT.FiltraParametros($"Consec <> {Index}").Rows.Count > 0 Then + Alert("No puede haber dos tipos de IVA en la compra.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End Select + + + Dim Total As Decimal = (TxtCantidad.Text.ToDecimal * TxtPrecio.Text.ToDecimal) - TxtDescuentoModal.Text.ToDecimal + TxtOtrosGastos.Text.ToDecimal + + If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then + Dim ObjCon As New ClsContratos + Dim CvePresupuesto As Integer = 0 + Dim Autorizado As Double = 0 + Dim Ejercido As Double = 0 + If ObjCon.GetPresupuestos(-1, "-1", DdlSubProyecto.SelectedValue.ToEntero, 2, -1, UsuarioActual.CveEmpresa) Then + If ObjCon.DtResultados.Rows.Count > 0 Then + CvePresupuesto = ObjCon.DtResultados.Rows(0)("CvePresupuesto").ToString.ToEntero + If CvePresupuesto > 0 Then + If ObjCon.GetPresupuestosDetalle(CvePresupuesto, -1, UsuarioActual.CveEmpresa) Then + If ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows.Count > 0 Then + Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} AND CveTipoGasto = {DdlTipoGasto.SelectedValue.ToEntero} AND Importe > 0").Rows(0)("Importe").ToString.ToDouble + End If + End If + If ObjCon.GetPresupuestosRep(CvePresupuesto, DdlTipoGasto.SelectedValue.ToEntero, 1, $"01/09/{DateTime.Now.Year - 1}".ToDate, Now, UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, + DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlClasificacion.SelectedValue.ToEntero) Then + If ObjCon.DtResultados.Rows.Count > 0 Then + Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDouble + End If + End If + End If + End If + End If + ObjCon.Dispose() + + If CvePresupuesto > 0 And Autorizado > 0 Then + Dim Diferencia As Double = (Ejercido + Total) - Autorizado + If Diferencia > 0 Then + Alert($"No hay presupuesto disponible en el subproyecto {DdlSubProyecto.SelectedItem.Text} con la clasificación {DdlClasificacion.SelectedItem.Text} y el tipo de gasto {DdlTipoGasto.SelectedItem.Text}. Se excede por {Diferencia.FormatoNumero}", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + + ActualizaTotales = True + Select Case Modalidad + Case "A" 'ADD + AddPS(TxtCantidad.Text.Trim.ToDouble, ddlUM.SelectedValue.ToEntero, ddlUM.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, HdnTipoPS.Value.ToEntero, + DdlSubProyecto.SelectedValue.ToString, DdlSubProyecto.SelectedItem.Text, DdlProyecto.SelectedItem.Text, DdlProyecto.SelectedValue.ToString, TxtObsPS.Text.Trim, TxtPrecio.Text.Trim.ToDouble, Total, Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2), TxtRetIVAModal.Text.ToDouble / 100, TxtRetISRModal.Text.ToDouble / 100, TxtIEPSModal.Text.ToDouble / 100, 0, TxtDescuentoModal.Text.ToDouble, OtrosGastos:=TxtOtrosGastos.Text.ToDouble, CveTipoGasto:=DdlTipoGasto.SelectedValue.ToEntero, TipoGasto:=DdlTipoGasto.SelectedItem.Text, NoDeducible:=ChkEsNoDeduciblePS.Checked) + + AddPS2() + LimpiaAgregar() + + If ChkAgregar.Checked = True And Modalidad = "A" Then + RegistraScript("displayToastr(1);", "display") + Else + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProducto")) + End If + + Case "U" 'UPDATE + UpdatePS() + Alert("Concepto actualizado Correctamente.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProducto")) + End Select + ActualizaTotales = False + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) + + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + GuardaAC() + End If + If UsuarioActual.Empresa.Funcionalidad(577).ToString = "1" Then 'If UsuarioActual.CveRol = 1 Then ' Alert($"Ok funcionalidad 577 RetencionIVA { RetencionIVA} IVAOriginal {IVAOriginal}") 'End If - If RetencionIVA = 0 And IVAOriginal > 0 Then - For Each dRow As DataRow In TmpDT.Rows + If RetencionIVA = 0 And IVAOriginal > 0 Then + For Each dRow As DataRow In TmpDT.Rows If dRow("CveTipoPS").ToString.ToEntero = 1 Then 'Comnetado para reubicar el boton 'tdIVA6.Visible = True - Exit For - End If - Next - End If - - End If - - - - UpPS.Update() - CargaGvPersonal() - End Sub - ''' - ''' Regresa el INDEX del row que acaba de agregar en el TMPDT - ''' - ''' - Private Function AddPS(Cantidad As Double, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveTipoPS As Integer, CveSubProyectoContrato As String, SubProyecto As String, Proyecto As String, CveProyecto As String, - Obs As String, PU As Double, Total As Double, IVA As Double, RetIVA As Double, RetISR As Double, IEPSPS As Double, IEPSPSIVA As Double, Descuento As Double, Optional CveOrdenCompraDetalle As Integer = -1, Optional TCalculaTotales As Boolean = True, - Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Double = 0, - Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Double = 0, - Optional PorcentajeIEPS As Double = 0, Optional PorcentajeRetIVA As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional NoDeducible As Boolean = False) As Integer - - Dim Row As DataRow = Nothing - - Row = TmpDT.NewRow() - Dim Retorno As Integer = 0 - Dim CveContrato = -1 - Dim CveSubProyecto = -1 - Dim Valores As String() - - ''CONTRATOS - If CveSubProyectoContrato.Contains("|"c) Then - Valores = CveSubProyectoContrato.Split("|"c) - CveContrato = Valores(1).ToEntero - CveSubProyecto = Valores(0).ToEntero - Else - CveSubProyecto = CveSubProyectoContrato.ToEntero - End If - - 'DR PS - Dim DrPS As DataRow = Nothing - If CvePS > 0 Then - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) - End If - - If DrPS IsNot Nothing Then - Row("PSCodigo") = If(PSCodigo = "", DrPS("PSCodigo").ToString, PSCodigo) - Row("CveMetodoInventario") = DrPS("Inv_CveMetodoInventario").ToString.ToEntero - Else - Row("PSCodigo") = PSCodigo - Row("CveMetodoInventario") = 0 - End If - - If Modalidad = "U" Then - Row("Consec") = Con - Else - Row("Consec") = TmpDT.Rows.Count + 1 - End If - - If Version = "3.3" And CveSATPS > 0 Then - Dim DrPSSAT As DataRow = Nothing - If CargaXml Then - If GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows.Count > 0 Then - DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows(0) - End If - Else - If GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows.Count > 0 Then - DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows(0) - End If - End If - If DrPSSAT IsNot Nothing Then - Row("SATClaveProductoServicio") = DrPSSAT("SATClaveProductoServicio").ToString - Row("CveSATPS") = DrPSSAT("CveSATPS").ToString - End If - End If - - Dim DecimalesPermitidos = 6 - - Row("CveConcepto") = TmpDT.Rows.Count + 1 - Row("Cantidad") = Math.Round(Cantidad, DecimalesPermitidos) - Row("CantidadF") = If(CantidadF = -1, Math.Round(Cantidad, DecimalesPermitidos), Math.Round(CantidadF, DecimalesPermitidos)) - Row("CveUM") = CveUM - Row("UM") = UM - Row("CveClasificacion") = CveClasificacion - Row("CveClasificacionActualizar") = CveClasificacion - Row("Clasificacion") = Clasificacion - Row("CvePS") = CvePS - Row("PS") = PS - Row("CveTipoPS") = CveTipoPS - - Row("PSDescripcion") = PSDescripcion - Row("CveSubProyecto") = CveSubProyecto.ToEntero - Row("CveProyecto") = CveProyecto.ToEntero - Row("CveContrato") = CveContrato.ToEntero - Row("SubProyecto") = If(SubProyecto = "Seleccione", "Sin Sub Proyecto", SubProyecto) - Row("Proyecto") = If(Proyecto = "Seleccione", "Sin Proyecto", Proyecto) - Row("CveActivoFijo") = -1 - Row("Obs") = Obs - Row("CveActivoFijo") = -1 - Row("CodAF") = "-1" - Row("TipoAF") = -1 - Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle - Row("EntregaDirecta") = EntregaDirecta - 'If GlobalDTProductosServiciosEquivalencias(CvePS, CveUM).Rows.Count = 0 Then Row("CveEq") = 1 Else Row("CveEq") = 0 - Row("NoDeducible") = NoDeducible - - Row("PU") = Math.Round(PU, DecimalesPermitidos) - If CargaXml And Version = "3.3" Then - Row("IVA") = Math.Round(IVA, DecimalesPermitidos) - Row("IVAPorcentaje") = PorcentajeIVA - Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos) - Row("RetIVAPorcentaje") = PorcentajeRetIVA - Row("RetISR") = Math.Round(RetISR, DecimalesPermitidos) - Row("RetISRPorcentaje") = PorcentajeRetISR - Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos) - Row("IEPSPSPorcentaje") = PorcentajeIEPS - Else - 'If DdlIVA.SelectedValue.ToDouble = 0 Then Row("IVA") = 0 Else Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) - Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) - Row("IVAPorcentaje") = IVA - Row("RetIVA") = Math.Round(RetIVA * Total, DecimalesPermitidos) - Row("RetIVAPorcentaje") = RetIVA - Row("RetISR") = Math.Round(RetISR * Total, DecimalesPermitidos) - Row("RetISRPorcentaje") = RetISR - Row("IEPSPS") = Math.Round(IEPSPS * Total, DecimalesPermitidos) - Row("IEPSPSPorcentaje") = IEPSPS - End If - Row("ImporteConImpuestos") = (Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble) + Row("IVA").ToString.ToDouble + Row("IEPSPS").ToString.ToDouble - (Row("RetIVA").ToString.ToDouble + Row("RetISR").ToString.ToDouble) - Row("ImporteSinImpuestos") = Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble - - Row("IEPSPSIVA") = Math.Round(IEPSPSIVA * Total, DecimalesPermitidos) - Row("IEPSPSIVAPorcentaje") = IEPSPSIVA - Row("Descuento") = Math.Round(Descuento, DecimalesPermitidos) - Row("OtrosGastos") = Math.Round(OtrosGastos, DecimalesPermitidos) - Row("Total") = Math.Round(Total, DecimalesPermitidos) - - Row("CveTipoGasto") = CveTipoGasto - Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "") - - If UsuarioActual.Empresa.UsaAC Then - Row("CveProgramaOperativo") = DdlACGeneral1.SelectedValue.ToEntero - Row("CveUnidadAdministrativa") = DdlACGeneral2.SelectedValue.ToEntero - Row("CveFuenteFinanciamiento") = DdlACGeneral3.SelectedValue.ToEntero - Row("CveTipoGastoAC") = DdlACGeneral4.SelectedValue.ToEntero - Row("CveClasificacionOG") = DdlACGeneral5.SelectedValue.ToEntero - End If - - - - TmpDT.Rows.Add(Row) - TmpDT.Rows.IndexOf(Row) - - If TCalculaTotales Then - CalculaTotales(True) - End If - - Return Retorno - End Function - Private Sub AddPS2(Optional pCalculaTotales As Boolean = True, Optional EsNoDeducible As Boolean = False) - Dim view As DataView = New DataView(TmpDT) - view.Sort = "Consec" - GvPS.DataSource = view - 'GvPS.DataSource = TmpDT - GvPS.DataBind() - CargaGvInv() - - If pCalculaTotales Then - CalculaTotales(True, EsNoDeducible) - End If - - End Sub - Private Sub UpdatePS() - Dim DrPS As DataRow = Nothing - Try - DrPS = TmpDT.Select($"Consec = {Index}")(0) - If DrPS Is Nothing Then - Alert("Ocurrió un error al editar el concepto.", TipoMensaje.MsgError) - Exit Sub - End If - Catch ex As Exception - Alert("Ocurrió un error al intentar editar el concepto.", TipoMensaje.MsgError) - Exit Sub - End Try - - - 'BANDERA - Dim AplicaCalculaTotales = False - - 'DATOS GENERALES - DrPS("Obs") = TxtObsPS.Text.Trim - DrPS("Proyecto") = DdlProyecto.SelectedItem.Text - DrPS("CveProyecto") = DdlProyecto.SelectedValue.ToEntero - DrPS("SubProyecto") = DdlSubProyecto.SelectedItem.Text - DrPS("CveSubProyecto") = DdlSubProyecto.SelectedValue.ToEntero - - 'IMPORTES - [CANTIDAD Y PRECIO] - Dim Cantidad = DrPS("Cantidad").ToString.ToDouble - Dim PU = DrPS("PU").ToString.ToDouble - Dim Descuento = DrPS("Descuento").ToString.ToDouble - Dim OtrosGastos = DrPS("OtrosGastos").ToString.ToDouble - Dim Total = (Cantidad * PU) - Descuento + OtrosGastos - DrPS("NoDeducible") = ChkEsNoDeduciblePS.Checked - - - If Cantidad <> TxtCantidad.Text.Trim.ToDouble OrElse PU <> TxtPrecio.Text.Trim.ToDouble OrElse Descuento <> TxtDescuentoModal.Text.ToDouble OrElse OtrosGastos <> TxtOtrosGastos.Text.ToDouble Then - Cantidad = TxtCantidad.Text.Trim.ToDouble - PU = TxtPrecio.Text.Trim.ToDouble - Descuento = TxtDescuentoModal.Text.ToDouble - OtrosGastos = TxtOtrosGastos.Text.ToDouble - Total = (Cantidad * PU) - Descuento + OtrosGastos - DrPS("Cantidad") = Cantidad - DrPS("PU") = PU - DrPS("Descuento") = Descuento - DrPS("OtrosGastos") = OtrosGastos - DrPS("Total") = Total - AplicaCalculaTotales = True - End If - - 'PS - CLASIFICACION - If DdlPS.SelectedValue.ToEntero > 0 Then - Dim PSRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") - If PSRow IsNot Nothing Then - DrPS("CveClasificacion") = PSRow("CveClasificacion").ToString - DrPS("Clasificacion") = PSRow("Clasificacion").ToString - DrPS("CvePS") = DdlPS.SelectedValue - DrPS("PS") = PSRow("PS").ToString - DrPS("CveTipoPS") = PSRow("CveTipoPS").ToString.ToEntero - DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero - DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString - - 'RESPETAR VALORES DE LA PANTALLA - 'IVA = PSRow("IVA").ToString.ToDouble - 'If IVA = -1 Then - ' IVA = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero()).FiltroPrimeroValor("IVA").ToDouble - 'End If - 'RetIVA = If(PSRow("RetIVA").ToString = "-1", ViewState("RetIVA"), PSRow("RetIVA").ToString).ToString.ToDouble - 'RetISR = If(PSRow("RetISR").ToString = "-1", ViewState("RetISR"), PSRow("RetISR").ToString).ToString.ToDouble - 'IEPSPS = If(PSRow("IEPSPorcentaje").ToString = "-1", ViewState("IEPSPS"), PSRow("IEPSPorcentaje").ToString).ToString.ToDouble - 'IEPSPSIVA = If(PSRow("IEPSGrabaIVA").ToString = "True", PSRow("IEPSPorcentaje").ToString.ToDouble, 0) - End If - End If - - 'UM - DrPS("CveUM") = ddlUM.SelectedValue.ToEntero - DrPS("UM") = ddlUM.SelectedItem.Text - - 'TIPO DE GASTO - DrPS("CveTipoGasto") = DdlTipoGasto.SelectedValue.ToEntero - DrPS("TipoGasto") = If(DdlTipoGasto.SelectedValue.ToEntero > 0, DdlTipoGasto.SelectedItem.Text, "") - - If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then - DrPS("AplicaCostoIndirecto") = "0" - End If - - 'IMPUESTOS: SI ES COMPRA, FACUTRA O CON OC, NO MODIFICA IMPUESTOS!! - 'Dim IVA = (TxtIVAModal.Text.ToDouble / 100) - Dim IVA = Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) - Dim RetISR = (TxtRetISRModal.Text.ToDouble / 100) - Dim RetIVA = (TxtRetIVAModal.Text.ToDouble / 100) - Dim IEPSPS = (TxtIEPSModal.Text.ToDouble / 100) - Dim IEPSPSIVA = 0 - - If Not (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) Then - 'If DdlIVA.SelectedValue.ToDouble = 0 Then DrPS("IVA") = 0 Else DrPS("IVA") = IVA * Total - DrPS("IVA") = IVA * Total - DrPS("IVAPorcentaje") = IVA - DrPS("RetIVA") = RetIVA * Total - DrPS("RetIVAPorcentaje") = RetIVA - DrPS("RetISR") = RetISR * Total - DrPS("RetISRPorcentaje") = RetISR - DrPS("IEPSPS") = IEPSPS * Total - DrPS("IEPSPSPorcentaje") = IEPSPS - DrPS("IEPSPSIVA") = IEPSPSIVA * Total - DrPS("IEPSPSIVAPorcentaje") = IEPSPSIVA - AplicaCalculaTotales = True - End If - - TmpDT.AcceptChanges() - - AddPS2(AplicaCalculaTotales) - CargaGvInv() - + Exit For + End If + Next + End If + + End If + + + + UpPS.Update() + CargaGvPersonal() End Sub -#End Region + ''' + ''' Regresa el INDEX del row que acaba de agregar en el TMPDT + ''' + ''' + Private Function AddPS(Cantidad As Double, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveTipoPS As Integer, CveSubProyectoContrato As String, SubProyecto As String, Proyecto As String, CveProyecto As String, + Obs As String, PU As Double, Total As Double, IVA As Double, RetIVA As Double, RetISR As Double, IEPSPS As Double, IEPSPSIVA As Double, Descuento As Double, Optional CveOrdenCompraDetalle As Integer = -1, Optional TCalculaTotales As Boolean = True, + Optional PSCodigo As String = "-", Optional PSDescripcion As String = "-", Optional CantidadF As Double = -1, Optional EntregaDirecta As Integer = -1, Optional OtrosGastos As Double = 0, + Optional CveSATPS As Integer = -1, Optional CargaXml As Boolean = False, Optional CveTipoGasto As Integer = -1, Optional TipoGasto As String = "", Optional PorcentajeIVA As Double = 0, + Optional PorcentajeIEPS As Double = 0, Optional PorcentajeRetIVA As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional NoDeducible As Boolean = False) As Integer + + Dim Row As DataRow = Nothing + + Row = TmpDT.NewRow() + Dim Retorno As Integer = 0 + Dim CveContrato = -1 + Dim CveSubProyecto = -1 + Dim Valores As String() + + ''CONTRATOS + If CveSubProyectoContrato.Contains("|"c) Then + Valores = CveSubProyectoContrato.Split("|"c) + CveContrato = Valores(1).ToEntero + CveSubProyecto = Valores(0).ToEntero + Else + CveSubProyecto = CveSubProyectoContrato.ToEntero + End If + + 'DR PS + Dim DrPS As DataRow = Nothing + If CvePS > 0 Then + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) + End If + + If DrPS IsNot Nothing Then + Row("PSCodigo") = If(PSCodigo = "", DrPS("PSCodigo").ToString, PSCodigo) + Row("CveMetodoInventario") = DrPS("Inv_CveMetodoInventario").ToString.ToEntero + Else + Row("PSCodigo") = PSCodigo + Row("CveMetodoInventario") = 0 + End If + + If Modalidad = "U" Then + Row("Consec") = Con + Else + Row("Consec") = TmpDT.Rows.Count + 1 + End If + + If Version = "3.3" And CveSATPS > 0 Then + Dim DrPSSAT As DataRow = Nothing + If CargaXml Then + If GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows.Count > 0 Then + DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows(0) + End If + Else + If GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows.Count > 0 Then + DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows(0) + End If + End If + If DrPSSAT IsNot Nothing Then + Row("SATClaveProductoServicio") = DrPSSAT("SATClaveProductoServicio").ToString + Row("CveSATPS") = DrPSSAT("CveSATPS").ToString + End If + End If + + Dim DecimalesPermitidos = 6 + + Row("CveConcepto") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Math.Round(Cantidad, DecimalesPermitidos) + Row("CantidadF") = If(CantidadF = -1, Math.Round(Cantidad, DecimalesPermitidos), Math.Round(CantidadF, DecimalesPermitidos)) + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("CveClasificacionActualizar") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("PS") = PS + Row("CveTipoPS") = CveTipoPS + + Row("PSDescripcion") = PSDescripcion + Row("CveSubProyecto") = CveSubProyecto.ToEntero + Row("CveProyecto") = CveProyecto.ToEntero + Row("CveContrato") = CveContrato.ToEntero + Row("SubProyecto") = If(SubProyecto = "Seleccione", "Sin Sub Proyecto", SubProyecto) + Row("Proyecto") = If(Proyecto = "Seleccione", "Sin Proyecto", Proyecto) + Row("CveActivoFijo") = -1 + Row("Obs") = Obs + Row("CveActivoFijo") = -1 + Row("CodAF") = "-1" + Row("TipoAF") = -1 + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("EntregaDirecta") = EntregaDirecta + 'If GlobalDTProductosServiciosEquivalencias(CvePS, CveUM).Rows.Count = 0 Then Row("CveEq") = 1 Else Row("CveEq") = 0 + Row("NoDeducible") = NoDeducible + + Row("PU") = Math.Round(PU, DecimalesPermitidos) + If CargaXml And Version = "3.3" Then + Row("IVA") = Math.Round(IVA, DecimalesPermitidos) + Row("IVAPorcentaje") = PorcentajeIVA + Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos) + Row("RetIVAPorcentaje") = PorcentajeRetIVA + Row("RetISR") = Math.Round(RetISR, DecimalesPermitidos) + Row("RetISRPorcentaje") = PorcentajeRetISR + Row("IEPSPS") = Math.Round(IEPSPS, DecimalesPermitidos) + Row("IEPSPSPorcentaje") = PorcentajeIEPS + Else + 'If DdlIVA.SelectedValue.ToDouble = 0 Then Row("IVA") = 0 Else Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) + Row("IVA") = Math.Round(IVA * Total, DecimalesPermitidos) + Row("IVAPorcentaje") = IVA + Row("RetIVA") = Math.Round(RetIVA * Total, DecimalesPermitidos) + Row("RetIVAPorcentaje") = RetIVA + Row("RetISR") = Math.Round(RetISR * Total, DecimalesPermitidos) + Row("RetISRPorcentaje") = RetISR + Row("IEPSPS") = Math.Round(IEPSPS * Total, DecimalesPermitidos) + Row("IEPSPSPorcentaje") = IEPSPS + End If + Row("ImporteConImpuestos") = (Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble) + Row("IVA").ToString.ToDouble + Row("IEPSPS").ToString.ToDouble - (Row("RetIVA").ToString.ToDouble + Row("RetISR").ToString.ToDouble) + Row("ImporteSinImpuestos") = Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble + + Row("IEPSPSIVA") = Math.Round(IEPSPSIVA * Total, DecimalesPermitidos) + Row("IEPSPSIVAPorcentaje") = IEPSPSIVA + Row("Descuento") = Math.Round(Descuento, DecimalesPermitidos) + Row("OtrosGastos") = Math.Round(OtrosGastos, DecimalesPermitidos) + Row("Total") = Math.Round(Total, DecimalesPermitidos) + + Row("CveTipoGasto") = CveTipoGasto + Row("TipoGasto") = If(CveTipoGasto > 0, TipoGasto, "") + + If UsuarioActual.Empresa.UsaAC Then + Row("CveProgramaOperativo") = DdlACGeneral1.SelectedValue.ToEntero + Row("CveUnidadAdministrativa") = DdlACGeneral2.SelectedValue.ToEntero + Row("CveFuenteFinanciamiento") = DdlACGeneral3.SelectedValue.ToEntero + Row("CveTipoGastoAC") = DdlACGeneral4.SelectedValue.ToEntero + Row("CveClasificacionOG") = DdlACGeneral5.SelectedValue.ToEntero + End If + + + + TmpDT.Rows.Add(Row) + TmpDT.Rows.IndexOf(Row) + + If TCalculaTotales Then + CalculaTotales(True) + End If + + Return Retorno + End Function + Private Sub AddPS2(Optional pCalculaTotales As Boolean = True, Optional EsNoDeducible As Boolean = False) + Dim view As DataView = New DataView(TmpDT) + view.Sort = "Consec" + GvPS.DataSource = view + 'GvPS.DataSource = TmpDT + GvPS.DataBind() + CargaGvInv() + + If pCalculaTotales Then + CalculaTotales(True, EsNoDeducible) + End If + + End Sub + Private Sub UpdatePS() + Dim DrPS As DataRow = Nothing + Try + DrPS = TmpDT.Select($"Consec = {Index}")(0) + If DrPS Is Nothing Then + Alert("Ocurrió un error al editar el concepto.", TipoMensaje.MsgError) + Exit Sub + End If + Catch ex As Exception + Alert("Ocurrió un error al intentar editar el concepto.", TipoMensaje.MsgError) + Exit Sub + End Try + + + 'BANDERA + Dim AplicaCalculaTotales = False + + 'DATOS GENERALES + DrPS("Obs") = TxtObsPS.Text.Trim + DrPS("Proyecto") = DdlProyecto.SelectedItem.Text + DrPS("CveProyecto") = DdlProyecto.SelectedValue.ToEntero + DrPS("SubProyecto") = DdlSubProyecto.SelectedItem.Text + DrPS("CveSubProyecto") = DdlSubProyecto.SelectedValue.ToEntero + + 'IMPORTES - [CANTIDAD Y PRECIO] + Dim Cantidad = DrPS("Cantidad").ToString.ToDouble + Dim PU = DrPS("PU").ToString.ToDouble + Dim Descuento = DrPS("Descuento").ToString.ToDouble + Dim OtrosGastos = DrPS("OtrosGastos").ToString.ToDouble + Dim Total = (Cantidad * PU) - Descuento + OtrosGastos + DrPS("NoDeducible") = ChkEsNoDeduciblePS.Checked + + + If Cantidad <> TxtCantidad.Text.Trim.ToDouble OrElse PU <> TxtPrecio.Text.Trim.ToDouble OrElse Descuento <> TxtDescuentoModal.Text.ToDouble OrElse OtrosGastos <> TxtOtrosGastos.Text.ToDouble Then + Cantidad = TxtCantidad.Text.Trim.ToDouble + PU = TxtPrecio.Text.Trim.ToDouble + Descuento = TxtDescuentoModal.Text.ToDouble + OtrosGastos = TxtOtrosGastos.Text.ToDouble + Total = (Cantidad * PU) - Descuento + OtrosGastos + DrPS("Cantidad") = Cantidad + DrPS("PU") = PU + DrPS("Descuento") = Descuento + DrPS("OtrosGastos") = OtrosGastos + DrPS("Total") = Total + AplicaCalculaTotales = True + End If + + 'PS - CLASIFICACION + If DdlPS.SelectedValue.ToEntero > 0 Then + Dim PSRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") + If PSRow IsNot Nothing Then + DrPS("CveClasificacion") = PSRow("CveClasificacion").ToString + DrPS("Clasificacion") = PSRow("Clasificacion").ToString + DrPS("CvePS") = DdlPS.SelectedValue + DrPS("PS") = PSRow("PS").ToString + DrPS("CveTipoPS") = PSRow("CveTipoPS").ToString.ToEntero + DrPS("CveSATPS") = PSRow("CveSATPS").ToString.ToEntero + DrPS("SATClaveProductoServicio") = PSRow("SATClaveProductoServicio").ToString + + 'RESPETAR VALORES DE LA PANTALLA + 'IVA = PSRow("IVA").ToString.ToDouble + 'If IVA = -1 Then + ' IVA = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero()).FiltroPrimeroValor("IVA").ToDouble + 'End If + 'RetIVA = If(PSRow("RetIVA").ToString = "-1", ViewState("RetIVA"), PSRow("RetIVA").ToString).ToString.ToDouble + 'RetISR = If(PSRow("RetISR").ToString = "-1", ViewState("RetISR"), PSRow("RetISR").ToString).ToString.ToDouble + 'IEPSPS = If(PSRow("IEPSPorcentaje").ToString = "-1", ViewState("IEPSPS"), PSRow("IEPSPorcentaje").ToString).ToString.ToDouble + 'IEPSPSIVA = If(PSRow("IEPSGrabaIVA").ToString = "True", PSRow("IEPSPorcentaje").ToString.ToDouble, 0) + End If + End If + + 'UM + DrPS("CveUM") = ddlUM.SelectedValue.ToEntero + DrPS("UM") = ddlUM.SelectedItem.Text + + 'TIPO DE GASTO + DrPS("CveTipoGasto") = DdlTipoGasto.SelectedValue.ToEntero + DrPS("TipoGasto") = If(DdlTipoGasto.SelectedValue.ToEntero > 0, DdlTipoGasto.SelectedItem.Text, "") + + If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then + DrPS("AplicaCostoIndirecto") = "0" + End If + + 'IMPUESTOS: SI ES COMPRA, FACUTRA O CON OC, NO MODIFICA IMPUESTOS!! + 'Dim IVA = (TxtIVAModal.Text.ToDouble / 100) + Dim IVA = Math.Round(DdlIVA.SelectedValue.ToDouble - 1, 2) + Dim RetISR = (TxtRetISRModal.Text.ToDouble / 100) + Dim RetIVA = (TxtRetIVAModal.Text.ToDouble / 100) + Dim IEPSPS = (TxtIEPSModal.Text.ToDouble / 100) + Dim IEPSPSIVA = 0 + + If Not (CveCompra > 0 Or CveFactura > 0 Or OCVinculada) Then + 'If DdlIVA.SelectedValue.ToDouble = 0 Then DrPS("IVA") = 0 Else DrPS("IVA") = IVA * Total + DrPS("IVA") = IVA * Total + DrPS("IVAPorcentaje") = IVA + DrPS("RetIVA") = RetIVA * Total + DrPS("RetIVAPorcentaje") = RetIVA + DrPS("RetISR") = RetISR * Total + DrPS("RetISRPorcentaje") = RetISR + DrPS("IEPSPS") = IEPSPS * Total + DrPS("IEPSPSPorcentaje") = IEPSPS + DrPS("IEPSPSIVA") = IEPSPSIVA * Total + DrPS("IEPSPSIVAPorcentaje") = IEPSPSIVA + AplicaCalculaTotales = True + End If + + TmpDT.AcceptChanges() + + AddPS2(AplicaCalculaTotales) + CargaGvInv() + + End Sub +#End Region + +#Region " RECLASIFICA PARTIDAS - CLASIFICACION - SUBPROYECTO " + Private Sub CargaClasificaciones() + If UsuarioActual.Empresa.UsaAC Then + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + DdlAplicaClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + Else + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + DdlAplicaClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + End If + DdlClasificacion.DataBind() + DdlAplicaClasificacion.DataBind() + End Sub + Private Sub BtnAplicarClasificacion_Click(sender As Object, e As EventArgs) Handles BtnAplicarClasificacion.Click + ReclasificaClasificacion() + End Sub + Protected Sub DdlAplicaClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) + ReclasificaClasificacion() + End Sub + Private Sub ReclasificaClasificacion() + + + If Not DdlAplicaClasificacion.SelectedValue.ToEntero > 0 Then + Exit Sub + End If + + Dim ErrorPS = False + + 'Actualiza Clasificacion directamente a la DB cuando ya se tiene alguna clasificacion + 'Solo cuando el PS ya esta registrado + If UsuarioActual.TienePermisoProceso(104) Then + Dim ObjPS As New ClsProductosServicios + For Each gvr As GridViewRow In GvPS.Rows + If gvr.FCCheckBox("CheckClasificacion").Checked AndAlso gvr.DataKey("CvePS").ToString.ToEntero > 0 Then + If Not ObjPS.UpdateClasificacionPS(DdlAplicaClasificacion.SelectedValue.ToEntero, UsuarioActual.CveUsuario, gvr.DataKey("CvePS").ToString.ToEntero) Then + ErrorPS = True + Exit For + End If + End If + Next + ObjPS.Dispose() + End If + + If Not ErrorPS Then + Dim index = 0 + For Each Dr As DataRow In TmpDT.Rows + If Dr("CvePS").ToString.ToEntero = 0 OrElse Dr("CveClasificacion").ToString.ToEntero <= 0 Then + 'Dr("CveClasificacion") = DdlClasificacion.SelectedValue.ToEntero + Dr("Clasificacion") = DdlAplicaClasificacion.SelectedItem.Text + Dr("CveClasificacionActualizar") = DdlAplicaClasificacion.SelectedValue.ToEntero + ElseIf UsuarioActual.TienePermisoProceso(104) AndAlso GvPS.Rows(index).FCCheckBox("CheckClasificacion").Checked Then + Dr("Clasificacion") = DdlAplicaClasificacion.SelectedItem.Text + Dr("CveClasificacionActualizar") = DdlAplicaClasificacion.SelectedValue.ToEntero + End If + index += 1 + Next + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + Alert("La Clasificacion ha sido aplicada correctamente.", TipoMensaje.MsgInformacion) + + 'Para validar AC + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + Else + Alert("Ocurrio un error al actualizar la Clasificación de los Productos/Servicios") + End If + -#Region " RECLASIFICA PARTIDAS - CLASIFICACION - SUBPROYECTO " - Private Sub CargaClasificaciones() - If UsuarioActual.Empresa.UsaAC Then - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - DdlAplicaClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - Else - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - DdlAplicaClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - End If - DdlClasificacion.DataBind() - DdlAplicaClasificacion.DataBind() - End Sub - Private Sub BtnAplicarClasificacion_Click(sender As Object, e As EventArgs) Handles BtnAplicarClasificacion.Click - ReclasificaClasificacion() - End Sub - Protected Sub DdlAplicaClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) - ReclasificaClasificacion() - End Sub - Private Sub ReclasificaClasificacion() - - - If Not DdlAplicaClasificacion.SelectedValue.ToEntero > 0 Then - Exit Sub - End If - - Dim ErrorPS = False - - 'Actualiza Clasificacion directamente a la DB cuando ya se tiene alguna clasificacion - 'Solo cuando el PS ya esta registrado - If UsuarioActual.TienePermisoProceso(104) Then - Dim ObjPS As New ClsProductosServicios - For Each gvr As GridViewRow In GvPS.Rows - If gvr.FCCheckBox("CheckClasificacion").Checked AndAlso gvr.DataKey("CvePS").ToString.ToEntero > 0 Then - If Not ObjPS.UpdateClasificacionPS(DdlAplicaClasificacion.SelectedValue.ToEntero, UsuarioActual.CveUsuario, gvr.DataKey("CvePS").ToString.ToEntero) Then - ErrorPS = True - Exit For - End If - End If - Next - ObjPS.Dispose() - End If - - If Not ErrorPS Then - Dim index = 0 - For Each Dr As DataRow In TmpDT.Rows - If Dr("CvePS").ToString.ToEntero = 0 OrElse Dr("CveClasificacion").ToString.ToEntero <= 0 Then - 'Dr("CveClasificacion") = DdlClasificacion.SelectedValue.ToEntero - Dr("Clasificacion") = DdlAplicaClasificacion.SelectedItem.Text - Dr("CveClasificacionActualizar") = DdlAplicaClasificacion.SelectedValue.ToEntero - ElseIf UsuarioActual.TienePermisoProceso(104) AndAlso GvPS.Rows(index).FCCheckBox("CheckClasificacion").Checked Then - Dr("Clasificacion") = DdlAplicaClasificacion.SelectedItem.Text - Dr("CveClasificacionActualizar") = DdlAplicaClasificacion.SelectedValue.ToEntero - End If - index += 1 - Next - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - Alert("La Clasificacion ha sido aplicada correctamente.", TipoMensaje.MsgInformacion) - - 'Para validar AC - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - Else - Alert("Ocurrio un error al actualizar la Clasificación de los Productos/Servicios") - End If - - - End Sub - - Protected Sub DdlAsignarProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlAsignarProyecto.SelectedIndexChanged - CargaSubProyectoAsignado() - End Sub - Private Sub CargaProyectoAsignado() - DdlAsignarProyecto.Items.Clear() - DdlAsignarProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) - DdlAsignarProyecto.DataBind() - DdlAsignarProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpReclasificarSubProyecto.Update() - End Sub - Private Sub CargaSubProyectoAsignado() - DdlAsignaSubProyecto.Items.Clear() - If DdlAsignarProyecto.SelectedValue.ToEntero > 0 Then - DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, DdlAsignarProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(DdlAsignarProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, 1)) - End If - DdlAsignaSubProyecto.DataBind() - DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpReclasificarSubProyecto.Update() - End Sub - Protected Sub DdlAsignaSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) - ReclasificaSubProyecto() - End Sub - Private Sub BtnAsignarSubProyecto_Click(sender As Object, e As EventArgs) Handles BtnAsignarSubProyecto.Click - ReclasificaSubProyecto() - End Sub - Private Sub ReclasificaSubProyecto() - - If Not GvPS.Rows.Count > 0 Then - Alert("No hay partidas para reclasificar el SubProyecto", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlAsignaSubProyecto.SelectedValue.ToEntero > 0 Then - Exit Sub - End If - - - Dim CveSubProyecto As Integer - Dim CveProyecto As Integer - If DdlAsignaSubProyecto.SelectedValue.Contains("|") Then - CveSubProyecto = DdlAsignaSubProyecto.SelectedValue.Split("|"c)(0).ToString.ToEntero - Else - CveSubProyecto = DdlAsignaSubProyecto.SelectedValue.ToEntero() - End If - - If DdlAsignarProyecto.SelectedValue.Contains("|") Then - CveProyecto = DdlAsignarProyecto.SelectedValue.Split("|"c)(0).ToString.ToEntero - Else - CveProyecto = DdlAsignarProyecto.SelectedValue.ToEntero() - End If - - For Each Dr As DataRow In TmpDT.Rows - Dr("CveProyecto") = CveProyecto - Dr("Proyecto") = If(CveSubProyecto = -1, "SE", DdlAsignarProyecto.SelectedItem.Text) - Dr("CveSubProyecto") = CveSubProyecto - Dr("SubProyecto") = If(CveSubProyecto = -1, "SE", DdlAsignaSubProyecto.SelectedItem.Text) - Next - - GvPS.DataSource = TmpDT.FiltraParametros("", "Consec") - GvPS.DataBind() - UpPS.Update() - CargaGvPersonal() - - 'Para validar AC - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - - Alert("SubProyectos cambiados correctamente", TipoMensaje.MsgInformacion) - - End Sub - - - Protected Sub DdlTipoGastoAsignar_SelectedIndexChanged(sender As Object, e As EventArgs) - If Not GvPS.Rows.Count > 0 Then - Alert("No hay partidas para reclasificar el tipo de gasto", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlTipoGastoAsignar.SelectedValue.ToEntero > 0 Then - Exit Sub - End If - - If DdlTipoGastoAsignar.SelectedValue.ToEntero > 0 Then - For Each Dr As DataRow In TmpDT.Rows - Dr("CveTipoGasto") = DdlTipoGastoAsignar.SelectedValue.ToEntero - Dr("TipoGasto") = DdlTipoGastoAsignar.SelectedItem.Text - Next - GvPS.DataSource = TmpDT.FiltraParametros("", "Consec") - GvPS.DataBind() - UpPS.Update() - End If - - If UsuarioActual.Empresa.UsaAC Then - CompruebaAgregar() - End If - - Alert("Los tipos de gastos han sido cambiados correctamente", TipoMensaje.MsgInformacion) - End Sub -#End Region + Protected Sub DdlAsignarProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlAsignarProyecto.SelectedIndexChanged + CargaSubProyectoAsignado() + End Sub + Private Sub CargaProyectoAsignado() + DdlAsignarProyecto.Items.Clear() + DdlAsignarProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"}), GlobalDTProyectos(UsuarioActual.CveEmpresa, -1).FiltraParametros("", "", {"CveProyecto", "Proyecto"})) + DdlAsignarProyecto.DataBind() + DdlAsignarProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + UpReclasificarSubProyecto.Update() + End Sub + Private Sub CargaSubProyectoAsignado() + DdlAsignaSubProyecto.Items.Clear() + If DdlAsignarProyecto.SelectedValue.ToEntero > 0 Then + DdlAsignaSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, DdlAsignarProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(DdlAsignarProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, 1)) + End If + DdlAsignaSubProyecto.DataBind() + DdlAsignaSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + UpReclasificarSubProyecto.Update() + End Sub + Protected Sub DdlAsignaSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + ReclasificaSubProyecto() + End Sub + Private Sub BtnAsignarSubProyecto_Click(sender As Object, e As EventArgs) Handles BtnAsignarSubProyecto.Click + ReclasificaSubProyecto() + End Sub + Private Sub ReclasificaSubProyecto() -#Region " PS ALIAS " - Protected Sub DdlPSAlias_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPSAlias2.selectedindexchange - If Not DdlPSAlias2.SelectedValue = "" Then - Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSAlias2.SelectedValue.ToEntero).FiltroPrimero("") - If DrPS IsNot Nothing Then - DdlUnidadAlias.DataSource = GlobalDTProductosServiciosEquivalencias(DdlPSAlias2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) - DdlUnidadAlias.DataBind() - HdnPSAliasCveClasificacion.Value = DrPS("CveClasificacion").ToString - HdnPSAliasClasificacion.Value = DrPS("Clasificacion").ToString - End If - End If - UpPSAlias.Update() - End Sub - Protected Sub BtnAddPSAlias_Click(sender As Object, e As EventArgs) Handles BtnAddPSAlias.Click - Dim PS As New ClsProductosServicios - Dim CvePS = -1 - Dim tPS = "" - - CvePS = DdlPSAlias2.SelectedValue.ToEntero - tPS = DdlPSAlias2.SelectedText - - If PS.AddPSAlias(TxtPSAlias.Text.Trim, CvePS) Then - GlobalDTProductosServiciosAlias(-1) = PS.DtResultados - - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CvePS") = CvePS - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("PS") = tPS - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("UM") = DdlUnidadAlias.SelectedItem.Text - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Clasificacion") = HdnPSAliasClasificacion.Value - TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim - - 'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE + If Not GvPS.Rows.Count > 0 Then + Alert("No hay partidas para reclasificar el SubProyecto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlAsignaSubProyecto.SelectedValue.ToEntero > 0 Then + Exit Sub + End If + + + Dim CveSubProyecto As Integer + Dim CveProyecto As Integer + If DdlAsignaSubProyecto.SelectedValue.Contains("|") Then + CveSubProyecto = DdlAsignaSubProyecto.SelectedValue.Split("|"c)(0).ToString.ToEntero + Else + CveSubProyecto = DdlAsignaSubProyecto.SelectedValue.ToEntero() + End If + + If DdlAsignarProyecto.SelectedValue.Contains("|") Then + CveProyecto = DdlAsignarProyecto.SelectedValue.Split("|"c)(0).ToString.ToEntero + Else + CveProyecto = DdlAsignarProyecto.SelectedValue.ToEntero() + End If + + For Each Dr As DataRow In TmpDT.Rows + Dr("CveProyecto") = CveProyecto + Dr("Proyecto") = If(CveSubProyecto = -1, "SE", DdlAsignarProyecto.SelectedItem.Text) + Dr("CveSubProyecto") = CveSubProyecto + Dr("SubProyecto") = If(CveSubProyecto = -1, "SE", DdlAsignaSubProyecto.SelectedItem.Text) + Next + + GvPS.DataSource = TmpDT.FiltraParametros("", "Consec") + GvPS.DataBind() + UpPS.Update() + CargaGvPersonal() + + 'Para validar AC + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + + Alert("SubProyectos cambiados correctamente", TipoMensaje.MsgInformacion) + + End Sub + + + Protected Sub DdlTipoGastoAsignar_SelectedIndexChanged(sender As Object, e As EventArgs) + If Not GvPS.Rows.Count > 0 Then + Alert("No hay partidas para reclasificar el tipo de gasto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlTipoGastoAsignar.SelectedValue.ToEntero > 0 Then + Exit Sub + End If + + If DdlTipoGastoAsignar.SelectedValue.ToEntero > 0 Then + For Each Dr As DataRow In TmpDT.Rows + Dr("CveTipoGasto") = DdlTipoGastoAsignar.SelectedValue.ToEntero + Dr("TipoGasto") = DdlTipoGastoAsignar.SelectedItem.Text + Next + GvPS.DataSource = TmpDT.FiltraParametros("", "Consec") + GvPS.DataBind() + UpPS.Update() + End If + + If UsuarioActual.Empresa.UsaAC Then + CompruebaAgregar() + End If + + Alert("Los tipos de gastos han sido cambiados correctamente", TipoMensaje.MsgInformacion) + + End Sub + +#End Region + +#Region " PS ALIAS " + Protected Sub DdlPSAlias_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPSAlias2.selectedindexchange + If Not DdlPSAlias2.SelectedValue = "" Then + Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSAlias2.SelectedValue.ToEntero).FiltroPrimero("") + If DrPS IsNot Nothing Then + DdlUnidadAlias.DataSource = GlobalDTProductosServiciosEquivalencias(DdlPSAlias2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidadAlias.DataBind() + HdnPSAliasCveClasificacion.Value = DrPS("CveClasificacion").ToString + HdnPSAliasClasificacion.Value = DrPS("Clasificacion").ToString + End If + End If + UpPSAlias.Update() + End Sub + Protected Sub BtnAddPSAlias_Click(sender As Object, e As EventArgs) Handles BtnAddPSAlias.Click + Dim PS As New ClsProductosServicios + Dim CvePS = -1 + Dim tPS = "" + + CvePS = DdlPSAlias2.SelectedValue.ToEntero + tPS = DdlPSAlias2.SelectedText + + If PS.AddPSAlias(TxtPSAlias.Text.Trim, CvePS) Then + GlobalDTProductosServiciosAlias(-1) = PS.DtResultados + + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CvePS") = CvePS + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("PS") = tPS + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("UM") = DdlUnidadAlias.SelectedItem.Text + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Clasificacion") = HdnPSAliasClasificacion.Value + TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim + + 'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE If UsuarioActual.CveEmpresa <> 141 Then For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") drt("CvePS") = CvePS @@ -17671,193 +17685,193 @@ Partial Class Compras_Compras drt("Clasificacion") = HdnPSAliasClasificacion.Value drt("Obs") = TxtPSAlias.Text.Trim Next - End If - - TmpDT.AcceptChanges() - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - Alert("Registro actualizado con exito.", TipoMensaje.MsgInformacion) - - RegistraScript("$('#ModalPSAlias').modal('hide');", "ModalPSAliasHide") - End If - PS.Dispose() - - - - End Sub - - Private Sub RecargaGlobalEquivalencias() - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalEquivalencias) - 'Hilo.Start() - GeneraGlobalEquivalencias() - End Sub - Private Sub GeneraGlobalEquivalencias() - GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing - 'Dim ObjPS = New ClsProductosServicios - 'If ObjPS.GetPSEquivalencias(-1, -1) Then - ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - 'ObjPS.Dispose() - End Sub -#End Region + End If -#Region " UM: ALIAS - EQUIVALENCIAS " - Private Sub CargarUMAlias() - DdlUMAlias.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - DdlUMAlias.DataBind() - DdlUMAlias.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpUMAlias.Update() - End Sub - Protected Sub DdlUMAlias_SelectedIndexChanged(sender As Object, e As EventArgs) - If GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then - RegistraScript("$('#RowUMEquivalencia').addClass('hidden')", "RowUMEquivalenciaShow") - Else - RegistraScript("$('#RowUMEquivalencia').removeClass('hidden')", "RowUMEquivalenciaHide") - End If - RegistraScript("$('#RowUMAlias').removeClass('hidden');$('#LtUMAlias').text('Registrar Unidad de Medida Alias'); $('#BtnUMAlias').val('Registrar Alias'); SetTextEquivalencia(1);", "RowUMAliasHide") - End Sub - Protected Sub BtnUMAlias_Click(sender As Object, e As EventArgs) - Dim ObjUM As New ClsUnidadesMedida - Dim ObjPS As New ClsProductosServicios(ObjUM.IniciaTransacSQL()) - - Dim TieneError = False - Dim DtEquivalencia = GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) - Dim CveUM = -1 - Dim UM = "" - Dim Equivalencia = 0.0 - - - Select Case HdnUMAliasModalidad.Value.ToEntero - Case 1 'AGREGA ALIAS - If Not ObjUM.AddUnidadMedidaAlias(TxtUMAlias.Text.Trim, DdlUMAlias.SelectedValue.ToEntero, If(HdnUMAliasCveSATUM.Value.ToEntero > 0, HdnUMAliasCveSATUM.Value.ToEntero, -1)) Then - TieneError = True - End If - - 'SI NO TIENE EQUIVALENCIA DEL PS - AGREGA LA EQUIVALENCIA - If Not TieneError Then - If Not GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then - If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then - TieneError = True - End If - End If - End If - - 'CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero - 'UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") - CveUM = DdlUMAlias.SelectedValue.ToEntero - UM = TxtUMAlias.Text.Trim - Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble - - Case 2 - - Case 3 'AGREGA EQUIVALENCIA - CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero - UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") - Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble - If Not TieneError Then - If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CveUM").ToString.ToEntero, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then - TieneError = True - End If - End If - Case 4 'AGREGA UNIDAD DE MEDIDA - - CveUM = ObjUM.AddUnidadMedida(TxtUMAlias.Text.Trim, TxtUMAbreviatura.Text.Trim, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, If(HdnUMAliasCveSATUM.Value.ToEntero > 0, HdnUMAliasCveSATUM.Value.ToEntero, -1)) - UM = TxtUMAlias.Text.Trim - Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble - - If Not CveUM > 0 Then - TieneError = True - End If - - 'AGREGA LA EQUIVALENCIA - If Not TieneError Then - If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, CveUM, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then - TieneError = True - End If - End If - - 'AGREGA ALIAS SI ES DIFERENTE EL TEXTO AL QUE VIENE EN EL XML - If Not TieneError And TxtUMAlias.Text.Trim <> HdnUMAlias.Value Then - If Not ObjUM.AddUnidadMedidaAlias(HdnUMAlias.Value, CveUM) Then - TieneError = True - End If - End If - - 'CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero - 'UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") - - Case Else - - End Select - - If Not TieneError Then - ObjPS.Commit() - Alert("Unidad de medida actualizada correctamente.", TipoMensaje.MsgInformacion) - - 'ACTUALIZA DIRECTO DT - Dim Dr = TmpDT.Rows(HdnUMAliasInd.Value.ToEntero) - Dim CvePSModificado = Dr("CvePS").ToString.ToEntero - Dim CveUMModificada = Dr("CveUM").ToString.ToEntero - Dim UMModificada = Dr("UM").ToString - - For Each DrUM As DataRow In TmpDT.Rows - If DrUM("CveUM").ToString.ToEntero = CveUMModificada And DrUM("UM").ToString = UMModificada Then - DrUM("CveUM") = CveUM - DrUM("UM") = UM - If Equivalencia > 0 Then - DrUM("Cantidad") = DrUM("Cantidad").ToString.ToDouble * Equivalencia - DrUM("PU") = DrUM("PU").ToString.ToDouble / Equivalencia - End If - TmpDT.AcceptChanges() - End If - Next - - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - - RegistraScript("$('#ModalUMAlias').modal('hide');", "ModalUMAliasHide") - DdlUMAlias.SelectedValue = "-1" - UpUMAlias.Update() - - RecargaGlobalUM() - Else - ObjPS.RollBack() - Alert("Ocurrió un error al guardar la unidad de medida", TipoMensaje.MsgError) - End If - - ObjPS.Dispose() - End Sub - Protected Sub LBAplicarEquivalencia_Click(sender As Object, e As EventArgs) - Dim Dr = TmpDT.Rows(CType(CType(sender, LinkButton).NamingContainer, GridViewRow).RowIndex) - Dim DtEquivalencia = GlobalDTProductosServiciosEquivalencias(Dr("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) - Dim Equivalencia = DtEquivalencia.FiltroPrimeroValor("Cantidad", $"CveUM = {Dr("CveUM")}").ToDouble - - If Equivalencia > 0 Then - Dr("CveUM") = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1") - Dr("UM") = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") - Dr("Cantidad") = Dr("Cantidad").ToString.ToDouble * Equivalencia - Dr("PU") = Math.Round(Dr("PU").ToString.ToDouble / Equivalencia, 6) - - TmpDT.AcceptChanges() - GvPS.DataSource = TmpDT - GvPS.DataBind() - UpPS.Update() - Else - Alert("La cantidad de equivalencia de la unidad de medida debe ser mayor a 0", TipoMensaje.MsgAdvertencia) - End If - - End Sub - Private Sub RecargaGlobalUM() - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalUM) - 'Hilo.Start() - GeneraGlobalUM() - End Sub + TmpDT.AcceptChanges() + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + Alert("Registro actualizado con exito.", TipoMensaje.MsgInformacion) + + RegistraScript("$('#ModalPSAlias').modal('hide');", "ModalPSAliasHide") + End If + PS.Dispose() + + + + End Sub + + Private Sub RecargaGlobalEquivalencias() + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalEquivalencias) + 'Hilo.Start() + GeneraGlobalEquivalencias() + End Sub + Private Sub GeneraGlobalEquivalencias() + GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing + 'Dim ObjPS = New ClsProductosServicios + 'If ObjPS.GetPSEquivalencias(-1, -1) Then + ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + 'ObjPS.Dispose() + End Sub +#End Region + +#Region " UM: ALIAS - EQUIVALENCIAS " + Private Sub CargarUMAlias() + DdlUMAlias.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUMAlias.DataBind() + DdlUMAlias.Items.Insert(0, New ListItem("Seleccione", "-1")) + UpUMAlias.Update() + End Sub + Protected Sub DdlUMAlias_SelectedIndexChanged(sender As Object, e As EventArgs) + If GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then + RegistraScript("$('#RowUMEquivalencia').addClass('hidden')", "RowUMEquivalenciaShow") + Else + RegistraScript("$('#RowUMEquivalencia').removeClass('hidden')", "RowUMEquivalenciaHide") + End If + RegistraScript("$('#RowUMAlias').removeClass('hidden');$('#LtUMAlias').text('Registrar Unidad de Medida Alias'); $('#BtnUMAlias').val('Registrar Alias'); SetTextEquivalencia(1);", "RowUMAliasHide") + End Sub + Protected Sub BtnUMAlias_Click(sender As Object, e As EventArgs) + Dim ObjUM As New ClsUnidadesMedida + Dim ObjPS As New ClsProductosServicios(ObjUM.IniciaTransacSQL()) + + Dim TieneError = False + Dim DtEquivalencia = GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) + Dim CveUM = -1 + Dim UM = "" + Dim Equivalencia = 0.0 + + + Select Case HdnUMAliasModalidad.Value.ToEntero + Case 1 'AGREGA ALIAS + If Not ObjUM.AddUnidadMedidaAlias(TxtUMAlias.Text.Trim, DdlUMAlias.SelectedValue.ToEntero, If(HdnUMAliasCveSATUM.Value.ToEntero > 0, HdnUMAliasCveSATUM.Value.ToEntero, -1)) Then + TieneError = True + End If + + 'SI NO TIENE EQUIVALENCIA DEL PS - AGREGA LA EQUIVALENCIA + If Not TieneError Then + If Not GlobalDTProductosServiciosEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows.Count > 0 Then + If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, DdlUMAlias.SelectedValue.ToEntero, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then + TieneError = True + End If + End If + End If + + 'CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero + 'UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") + CveUM = DdlUMAlias.SelectedValue.ToEntero + UM = TxtUMAlias.Text.Trim + Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble + + Case 2 + + Case 3 'AGREGA EQUIVALENCIA + CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero + UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") + Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble + If Not TieneError Then + If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CveUM").ToString.ToEntero, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then + TieneError = True + End If + End If + Case 4 'AGREGA UNIDAD DE MEDIDA + + CveUM = ObjUM.AddUnidadMedida(TxtUMAlias.Text.Trim, TxtUMAbreviatura.Text.Trim, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, If(HdnUMAliasCveSATUM.Value.ToEntero > 0, HdnUMAliasCveSATUM.Value.ToEntero, -1)) + UM = TxtUMAlias.Text.Trim + Equivalencia = TxtUMEquivalenciaCantidad.Text.ToDouble + + If Not CveUM > 0 Then + TieneError = True + End If + + 'AGREGA LA EQUIVALENCIA + If Not TieneError Then + If Not ObjPS.AddPSEquivalencias(TmpDT.Rows(HdnUMAliasInd.Value.ToEntero)("CvePS").ToString.ToEntero, CveUM, TxtUMEquivalenciaCantidad.Text.ToDecimal, False, 0, UsuarioActual.CveUsuario) Then + TieneError = True + End If + End If + + 'AGREGA ALIAS SI ES DIFERENTE EL TEXTO AL QUE VIENE EN EL XML + If Not TieneError And TxtUMAlias.Text.Trim <> HdnUMAlias.Value Then + If Not ObjUM.AddUnidadMedidaAlias(HdnUMAlias.Value, CveUM) Then + TieneError = True + End If + End If + + 'CveUM = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1").ToEntero + 'UM = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") + + Case Else + + End Select + + If Not TieneError Then + ObjPS.Commit() + Alert("Unidad de medida actualizada correctamente.", TipoMensaje.MsgInformacion) + + 'ACTUALIZA DIRECTO DT + Dim Dr = TmpDT.Rows(HdnUMAliasInd.Value.ToEntero) + Dim CvePSModificado = Dr("CvePS").ToString.ToEntero + Dim CveUMModificada = Dr("CveUM").ToString.ToEntero + Dim UMModificada = Dr("UM").ToString + + For Each DrUM As DataRow In TmpDT.Rows + If DrUM("CveUM").ToString.ToEntero = CveUMModificada And DrUM("UM").ToString = UMModificada Then + DrUM("CveUM") = CveUM + DrUM("UM") = UM + If Equivalencia > 0 Then + DrUM("Cantidad") = DrUM("Cantidad").ToString.ToDouble * Equivalencia + DrUM("PU") = DrUM("PU").ToString.ToDouble / Equivalencia + End If + TmpDT.AcceptChanges() + End If + Next + + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + + RegistraScript("$('#ModalUMAlias').modal('hide');", "ModalUMAliasHide") + DdlUMAlias.SelectedValue = "-1" + UpUMAlias.Update() + + RecargaGlobalUM() + Else + ObjPS.RollBack() + Alert("Ocurrió un error al guardar la unidad de medida", TipoMensaje.MsgError) + End If + + ObjPS.Dispose() + End Sub + Protected Sub LBAplicarEquivalencia_Click(sender As Object, e As EventArgs) + Dim Dr = TmpDT.Rows(CType(CType(sender, LinkButton).NamingContainer, GridViewRow).RowIndex) + Dim DtEquivalencia = GlobalDTProductosServiciosEquivalencias(Dr("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) + Dim Equivalencia = DtEquivalencia.FiltroPrimeroValor("Cantidad", $"CveUM = {Dr("CveUM")}").ToDouble + + If Equivalencia > 0 Then + Dr("CveUM") = DtEquivalencia.FiltroPrimeroValor("CveUM", "UnidadBase = 1") + Dr("UM") = DtEquivalencia.FiltroPrimeroValor("UM", "UnidadBase = 1") + Dr("Cantidad") = Dr("Cantidad").ToString.ToDouble * Equivalencia + Dr("PU") = Math.Round(Dr("PU").ToString.ToDouble / Equivalencia, 6) + + TmpDT.AcceptChanges() + GvPS.DataSource = TmpDT + GvPS.DataBind() + UpPS.Update() + Else + Alert("La cantidad de equivalencia de la unidad de medida debe ser mayor a 0", TipoMensaje.MsgAdvertencia) + End If + + End Sub + Private Sub RecargaGlobalUM() + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalUM) + 'Hilo.Start() + GeneraGlobalUM() + End Sub Private Sub GeneraGlobalUM() - GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing + GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing GlobalDTUnidadesMedidaAlias(UsuarioActual.CveEmpresa) = Nothing 'Dim ObjPS = New ClsProductosServicios 'Dim OjbUM As New ClsUnidadesMedida @@ -17874,55 +17888,55 @@ Partial Class Compras_Compras 'OjbUM.Dispose() End Sub -#End Region +#End Region -#Region " COMPLEMENTOS PAGO " +#Region " COMPLEMENTOS PAGO " + + Private Sub CargaComplementosPago() + + Dim ObjCompras As New ClsCompras + + If ObjCompras.GetCompraComplementoPago(CveCompra, UsuarioActual.CveEmpresa) Then + GvComplementoPagos.DataSource = ObjCompras.DtResultados + LnkCompleplementos.Visible = ObjCompras.DtResultados.Rows.Count > 0 + Else + GvComplementoPagos.DataSource = Nothing + LnkCompleplementos.Visible = False + End If + + If UsuarioActual.TienePermisoProceso(272) Then + GvComplementoPagos.Columns(5).Visible = True + End If + + ObjCompras.Dispose() + + GvComplementoPagos.DataBind() + UpComplementoPagos.Update() - Private Sub CargaComplementosPago() - - Dim ObjCompras As New ClsCompras - - If ObjCompras.GetCompraComplementoPago(CveCompra, UsuarioActual.CveEmpresa) Then - GvComplementoPagos.DataSource = ObjCompras.DtResultados - LnkCompleplementos.Visible = ObjCompras.DtResultados.Rows.Count > 0 - Else - GvComplementoPagos.DataSource = Nothing - LnkCompleplementos.Visible = False - End If - - If UsuarioActual.TienePermisoProceso(272) Then - GvComplementoPagos.Columns(5).Visible = True - End If - - ObjCompras.Dispose() - - GvComplementoPagos.DataBind() - UpComplementoPagos.Update() - - End Sub - Protected Sub GvComplementoPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvComplementoPagos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.Cells(3).Text = String.Format("", Encripta(String.Format("OP=Fact&EXT=xml&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo(("RFCde").ToString.Replace("&", "%26%"))))) - e.Row.Cells(4).Text = String.Format("", Encripta(String.Format("OP=Fact&EXT=pdf&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo("RFCde").ToString.Replace("&", "%26%")))) - End If End Sub -#End Region + Protected Sub GvComplementoPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvComplementoPagos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.Cells(3).Text = String.Format("", Encripta(String.Format("OP=Fact&EXT=xml&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo(("RFCde").ToString.Replace("&", "%26%"))))) + e.Row.Cells(4).Text = String.Format("", Encripta(String.Format("OP=Fact&EXT=pdf&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo("RFCde").ToString.Replace("&", "%26%")))) + End If + End Sub +#End Region -#Region " OTROS GASTOS " +#Region " OTROS GASTOS " - Protected Sub LnkAddOtrosGastos_Click(sender As Object, e As EventArgs) - DdlOrdenCorte.SelectedIndex = 0 - DdlOrdenCorte.SelectedValueExist(CveOrdenCorte) - UpOtrosGastos.Update() - RegistraScript("$('#DivOtrosGastos').modal();") - End Sub - - Protected Sub BtnAddOtrosGastos_Click(sender As Object, e As EventArgs) - CveOrdenCorte = DdlOrdenCorte.SelectedValue.ToEntero() - RegistraScript("$('#DivOtrosGastos').modal('hide');") + Protected Sub LnkAddOtrosGastos_Click(sender As Object, e As EventArgs) + DdlOrdenCorte.SelectedIndex = 0 + DdlOrdenCorte.SelectedValueExist(CveOrdenCorte) + UpOtrosGastos.Update() + RegistraScript("$('#DivOtrosGastos').modal();") End Sub -#End Region + Protected Sub BtnAddOtrosGastos_Click(sender As Object, e As EventArgs) + CveOrdenCorte = DdlOrdenCorte.SelectedValue.ToEntero() + RegistraScript("$('#DivOtrosGastos').modal('hide');") + End Sub + +#End Region '#Region " DROPDOWN IVA " ' 'Protected Sub DdlIVA_SelectedIndexChanged(sender As Object, e As EventArgs) @@ -17930,1099 +17944,1099 @@ Partial Class Compras_Compras ' 'End Sub '#End Region -#Region " APLICA NC " +#Region " APLICA NC " - Private Sub InicializaAplicaNCFact() - HLAplicaNCFact.Visible = True - LblTotalNC.Text = TxtTotal.Text.FormatoNumero - CargaCuentasXPagar() - End Sub - - Private Sub CargaCuentasXPagar() - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, "-1", "-1") Then - GvFacturaNC.DataSource = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0") - TmpCXP = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0") - End If - ObjMovtos.Dispose() - GvFacturaNC.DataBind() - UpFacturaNC.Update() - End Sub - Protected Sub GvFacturaNC_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - If Not e.Row.DBCampo("CveCompra").ToEntero > 0 Then - e.Row.CssClass = "Totales" - e.Row.Cells(0).Text = "" - e.Row.Cells(4).Text = "" - Else - e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaCantidadNC({e.Row.DBCampo("Saldo").ToDouble},{TxtTotal.Text.ToDouble}, this);") - e.Row.FCCheckBox("ChkFacturaNC").Attributes.Add("onclick", $"FnCambiaFacturaNC({e.Row.DBCampo("Saldo").ToDouble},{e.Row.FCTextBox("TxtImporte").ClientID},{TxtTotal.Text.ToDouble},{LblAplicado.ClientID}, this);") - End If - End If + Private Sub InicializaAplicaNCFact() + HLAplicaNCFact.Visible = True + LblTotalNC.Text = TxtTotal.Text.FormatoNumero + CargaCuentasXPagar() End Sub -#End Region - -#Region " DEVOLUCION DE ALMACEN - DEVOLUCION AL PROVEEDOR " - Private Sub InicializaDevolucionAlmacen() - If Not GvInv.Rows.Count > 0 Or LblCompraEstatus.Text = "CANCELADA" Then - Exit Sub - End If - - If CveCompra > 0 Then - 'If CveVenta > 0 And DdlTipoComprobante.SelectedValue.Contiene({"Rem", "Ped"}) Then - - If Not EstatusAlmacen = 2 Then - LiDevolucionAlmacen.Visible = True - End If - - If EstatusAlmacen = 1 Then - LBDevolucionAlmacen.Text = " Cancelar Devolución Almacén" - LBDevolucionAlmacen.ToolTip = "¿Está seguro de Cancelar la Devolución de Almacén?" - Else - LBDevolucionAlmacen.Text = " Solicitar Devolución Almacén" - LBDevolucionAlmacen.ToolTip = "¿Está seguro de Solicitar la Devolución de Almacén?" - End If - - End If - - 'UpInvDev.Update() - End Sub - Protected Sub LBDevolucionAlmacen_Click(sender As Object, e As EventArgs) - Dim ObjCompras As New ClsCompras - - If ObjCompras.UpdateEstatusAlmacen(CveCompra, If(EstatusAlmacen = 1, 0, 1)) Then - EstatusAlmacen = If(EstatusAlmacen = 1, 0, 1) - Alert(If(EstatusAlmacen = 1, "La solicitud de devolución de almacen se guardo correctamente.", "La solicitud de almacen se canceló correctamente.")) - End If - - ObjCompras.Dispose() - - InicializaDevolucionAlmacen() - End Sub - - Private Sub HabilitaNCInv() - - If Not UsuarioActual.CveUsuario = 100 Then - If Not UsuarioActual.CveEmpresa.Contiene(72, 119, 80) Then - Exit Sub - End If - End If - - - If CveCompra > 0 And GvInvMov.Rows.Count > 0 Then - - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.RecepcionAlmacenGet(CveCompra, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then - DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros("CantidadF > 0").Copy - End If - ObjInventarios.Dispose() - - If DtPendientesAlmacen IsNot Nothing AndAlso DtPendientesAlmacen.Rows.Count > 0 Then - ChkNCInv.Visible = True - GVNCInv.DataSource = DtPendientesAlmacen - GVNCInv.DataBind() - End If - - End If - End Sub - Protected Sub ChkNCInv_CheckedChanged(sender As Object, e As EventArgs) - CargaAnticipos(CveProveedor, If(ChkNCInv.Checked, "NC", "-1")) - UpAnticipos.Update() - End Sub - Private Sub CargaNCINV() - - Dim SaldoAnticipo = 0.0 - Dim CveCompras As String = "" - If ChkNCInvNC.Checked Then - For Each gvr As GridViewRow In GvFacturaNC.Rows - If gvr.FCCheckBox("ChkFacturaNC") IsNot Nothing AndAlso gvr.FCCheckBox("ChkFacturaNC").Checked Then - SaldoAnticipo += gvr.FCTextBox("TxtImporte").Text.ToDouble - If CveCompras <> "" Then - CveCompras = $"{CveCompras},{gvr.DataKey("CveCompra").ToString}" - Else - CveCompras = gvr.DataKey("CveCompra").ToString - End If - End If - Next - Else - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - SaldoAnticipo += gvr.FCTextBox("TxtAnticipo").Text.ToDouble - End If - Next - End If - - - If SaldoAnticipo <= 0 Then - Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - LbNCInvSaldo.Text = SaldoAnticipo.FormatoNumero() - - If ChkNCInvNC.Checked Then - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Rows.Count > 0 Then - DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Copy - End If - ObjInventarios.Dispose() - End If - - If (DtPendientesAlmacen IsNot Nothing AndAlso DtPendientesAlmacen.Rows.Count > 0) Then - If ChkNCInvNC.Checked Then - GVNCInv.DataSource = DtPendientesAlmacen - GVNCInv.DataBind() - UpNCInv.Update() - RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC") - End If - RegistraScript("$('#ModalNCInv').modal('show');", "ModalNCInv") - Else - If ChkNCInvNC.Checked Then - Alert("Niguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia) - ChkNCInvNC.Checked = False - UpChkNCInvNC.Update() - Exit Sub - Else - RegistraScript("$('#ModalNCConfirmación').modal('show');", "ModalNCInv") - End If - End If - - UpNCInv.Update() - - End Sub - Protected Sub GVNCInv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInv.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - 'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);") - e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);") - End If - End Sub - Protected Sub BtnNCInv_Click(sender As Object, e As EventArgs) - - If ChkNCInvNC.Checked Then - RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") - RegistraScript("$('#DivAnticipos').modal('hide');", "FacturaNC") - Exit Sub - End If - - Dim Contador = 0 - Dim CveCompraNC = -1 - For Each gvr As GridViewRow In GVAnticipos.Rows - If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then - Contador += 1 - CveCompraNC = gvr.DataKey("CveCompra").ToString.ToEntero - End If - Next - - If Contador <> 1 Then - Alert("Debe seleccionar por lo menos una NC a aplicar.", TipoMensaje.MsgAdvertencia) - RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") - RegistraScript("$('#DivAnticipos').modal('hide');", "ModalAnticipos") - Exit Sub - End If - - If Not CveCompraNC > 0 Then - Alert("Ocurrió un error al guardar la cancelación de inventarios. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) - Exit Sub - End If - - - Dim ObjCompras As New ClsCompras - Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL) - Dim TieneError = False - - For Each Gvr As GridViewRow In GVNCInv.Rows - If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then - If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompraNC, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then - TieneError = True - Exit For - End If - End If - Next - - If Not TieneError Then - GuardaAnticipos(ObjCompras, ObjConta) - Else - ObjCompras.RollBack() - End If - - ObjCompras.Dispose() - RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") - RegistraScript("$('#DivAnticipos').modal('hide');", "ModalAnticipos") - - End Sub - Protected Sub BtnNCConfirmacion_Click(sender As Object, e As EventArgs) - GuardaAnticipos(Nothing, Nothing) + Private Sub CargaCuentasXPagar() + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, "-1", "-1") Then + GvFacturaNC.DataSource = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0") + TmpCXP = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0") + End If + ObjMovtos.Dispose() + GvFacturaNC.DataBind() + UpFacturaNC.Update() + End Sub + Protected Sub GvFacturaNC_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If Not e.Row.DBCampo("CveCompra").ToEntero > 0 Then + e.Row.CssClass = "Totales" + e.Row.Cells(0).Text = "" + e.Row.Cells(4).Text = "" + Else + e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaCantidadNC({e.Row.DBCampo("Saldo").ToDouble},{TxtTotal.Text.ToDouble}, this);") + e.Row.FCCheckBox("ChkFacturaNC").Attributes.Add("onclick", $"FnCambiaFacturaNC({e.Row.DBCampo("Saldo").ToDouble},{e.Row.FCTextBox("TxtImporte").ClientID},{TxtTotal.Text.ToDouble},{LblAplicado.ClientID}, this);") + End If + End If End Sub -#End Region -#Region " INVENTARIO: MOVIMIENTOS DE LA COMPRA " - Private Sub InventarioMov() - Dim ObjVentas As New ClsInventarios - - If ObjVentas.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) Then - If ObjVentas.DtResultados.Rows.Count > 0 Then - GvInvMov.DataSource = ObjVentas.DtResultados - End If - End If - GvInvMov.DataBind() - GvInvMov.Visible = True - - ObjVentas.Dispose() - UpINV.Update() - End Sub - Private Sub GvInvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInvMov.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("CvePS") = "" Then - e.Row.FCLiteral("LtlPS").Text = String.Format("Folio: {1} Fecha: {2} {3} {4}", e.Row.DBCampo("CveMovimiento"), e.Row.DBCampo("Folio"), e.Row.DBCampo("Fecha").ToString.ToDate.ToShortDateString, e.Row.DBCampo("Almacen").ToString, e.Row.DBCampo("Concepto").ToString) - - If e.Row.DataKey("Origen").ToEntero > 0 Then - e.Row.CssClass = "SubTotales" - Else - e.Row.BackColor = Drawing.Color.FromArgb(224, 130, 131) - e.Row.ForeColor = Drawing.Color.White - e.Row.Font.Bold = True - End If - Else - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left - End If - End If - End Sub - - Private Sub GvAcarreo_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcarreo.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCLiteral("LtlImporte").Text = "$" + FormatNumber(e.Row.FCLiteral("LtlImporte").Text.ToDouble, 2, , , TriState.True) - End If +#End Region + +#Region " DEVOLUCION DE ALMACEN - DEVOLUCION AL PROVEEDOR " + Private Sub InicializaDevolucionAlmacen() + If Not GvInv.Rows.Count > 0 Or LblCompraEstatus.Text = "CANCELADA" Then + Exit Sub + End If + + If CveCompra > 0 Then + 'If CveVenta > 0 And DdlTipoComprobante.SelectedValue.Contiene({"Rem", "Ped"}) Then + + If Not EstatusAlmacen = 2 Then + LiDevolucionAlmacen.Visible = True + End If + + If EstatusAlmacen = 1 Then + LBDevolucionAlmacen.Text = " Cancelar Devolución Almacén" + LBDevolucionAlmacen.ToolTip = "¿Está seguro de Cancelar la Devolución de Almacén?" + Else + LBDevolucionAlmacen.Text = " Solicitar Devolución Almacén" + LBDevolucionAlmacen.ToolTip = "¿Está seguro de Solicitar la Devolución de Almacén?" + End If + + End If + + 'UpInvDev.Update() + End Sub + Protected Sub LBDevolucionAlmacen_Click(sender As Object, e As EventArgs) + Dim ObjCompras As New ClsCompras + + If ObjCompras.UpdateEstatusAlmacen(CveCompra, If(EstatusAlmacen = 1, 0, 1)) Then + EstatusAlmacen = If(EstatusAlmacen = 1, 0, 1) + Alert(If(EstatusAlmacen = 1, "La solicitud de devolución de almacen se guardo correctamente.", "La solicitud de almacen se canceló correctamente.")) + End If + + ObjCompras.Dispose() + + InicializaDevolucionAlmacen() + End Sub + + Private Sub HabilitaNCInv() + + If Not UsuarioActual.CveUsuario = 100 Then + If Not UsuarioActual.CveEmpresa.Contiene(72, 119, 80) Then + Exit Sub + End If + End If + + + If CveCompra > 0 And GvInvMov.Rows.Count > 0 Then + + Dim ObjInventarios As New ClsInventarios + If ObjInventarios.RecepcionAlmacenGet(CveCompra, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then + DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros("CantidadF > 0").Copy + End If + ObjInventarios.Dispose() + + If DtPendientesAlmacen IsNot Nothing AndAlso DtPendientesAlmacen.Rows.Count > 0 Then + ChkNCInv.Visible = True + GVNCInv.DataSource = DtPendientesAlmacen + GVNCInv.DataBind() + End If + + End If + End Sub + Protected Sub ChkNCInv_CheckedChanged(sender As Object, e As EventArgs) + CargaAnticipos(CveProveedor, If(ChkNCInv.Checked, "NC", "-1")) + UpAnticipos.Update() + End Sub + Private Sub CargaNCINV() + + Dim SaldoAnticipo = 0.0 + Dim CveCompras As String = "" + If ChkNCInvNC.Checked Then + For Each gvr As GridViewRow In GvFacturaNC.Rows + If gvr.FCCheckBox("ChkFacturaNC") IsNot Nothing AndAlso gvr.FCCheckBox("ChkFacturaNC").Checked Then + SaldoAnticipo += gvr.FCTextBox("TxtImporte").Text.ToDouble + If CveCompras <> "" Then + CveCompras = $"{CveCompras},{gvr.DataKey("CveCompra").ToString}" + Else + CveCompras = gvr.DataKey("CveCompra").ToString + End If + End If + Next + Else + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + SaldoAnticipo += gvr.FCTextBox("TxtAnticipo").Text.ToDouble + End If + Next + End If + + + If SaldoAnticipo <= 0 Then + Alert("No hay movimientos seleccionados para aplicar", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + LbNCInvSaldo.Text = SaldoAnticipo.FormatoNumero() + + If ChkNCInvNC.Checked Then + Dim ObjInventarios As New ClsInventarios + If ObjInventarios.RecepcionAlmacenGet(-1, -1, UsuarioActual.CveEmpresa, CveProveedor) AndAlso ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Rows.Count > 0 Then + DtPendientesAlmacen = ObjInventarios.DtResultados.FiltraParametros($"CveCompra IN ({CveCompras}) AND CantidadF > 0").Copy + End If + ObjInventarios.Dispose() + End If + + If (DtPendientesAlmacen IsNot Nothing AndAlso DtPendientesAlmacen.Rows.Count > 0) Then + If ChkNCInvNC.Checked Then + GVNCInv.DataSource = DtPendientesAlmacen + GVNCInv.DataBind() + UpNCInv.Update() + RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC") + End If + RegistraScript("$('#ModalNCInv').modal('show');", "ModalNCInv") + Else + If ChkNCInvNC.Checked Then + Alert("Niguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia) + ChkNCInvNC.Checked = False + UpChkNCInvNC.Update() + Exit Sub + Else + RegistraScript("$('#ModalNCConfirmación').modal('show');", "ModalNCInv") + End If + End If + + UpNCInv.Update() + + End Sub + Protected Sub GVNCInv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNCInv.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + 'e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", "FnCambiaInvNC(this);") + e.Row.FCTextBox("TxtCantidadNCInv").Attributes.Add("onkeyup", $"ValidarCantidad(this,{e.Row.DBCampo("CantidadF")});FnCambiaInvNC(this);") + End If + End Sub + Protected Sub BtnNCInv_Click(sender As Object, e As EventArgs) + + If ChkNCInvNC.Checked Then + RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") + RegistraScript("$('#DivAnticipos').modal('hide');", "FacturaNC") + Exit Sub + End If + + Dim Contador = 0 + Dim CveCompraNC = -1 + For Each gvr As GridViewRow In GVAnticipos.Rows + If gvr.FCCheckBox("Chk") IsNot Nothing AndAlso gvr.FCCheckBox("Chk").Checked Then + Contador += 1 + CveCompraNC = gvr.DataKey("CveCompra").ToString.ToEntero + End If + Next + + If Contador <> 1 Then + Alert("Debe seleccionar por lo menos una NC a aplicar.", TipoMensaje.MsgAdvertencia) + RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") + RegistraScript("$('#DivAnticipos').modal('hide');", "ModalAnticipos") + Exit Sub + End If + + If Not CveCompraNC > 0 Then + Alert("Ocurrió un error al guardar la cancelación de inventarios. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) + Exit Sub + End If + + + Dim ObjCompras As New ClsCompras + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL) + Dim TieneError = False + + For Each Gvr As GridViewRow In GVNCInv.Rows + If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then + If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompraNC, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then + TieneError = True + Exit For + End If + End If + Next + + If Not TieneError Then + GuardaAnticipos(ObjCompras, ObjConta) + Else + ObjCompras.RollBack() + End If + + ObjCompras.Dispose() + RegistraScript("$('#ModalNCInv').modal('hide');", "ModalNCInv") + RegistraScript("$('#DivAnticipos').modal('hide');", "ModalAnticipos") + + End Sub + Protected Sub BtnNCConfirmacion_Click(sender As Object, e As EventArgs) + GuardaAnticipos(Nothing, Nothing) + End Sub +#End Region + +#Region " INVENTARIO: MOVIMIENTOS DE LA COMPRA " + Private Sub InventarioMov() + Dim ObjVentas As New ClsInventarios + + If ObjVentas.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) Then + If ObjVentas.DtResultados.Rows.Count > 0 Then + GvInvMov.DataSource = ObjVentas.DtResultados + End If + End If + GvInvMov.DataBind() + GvInvMov.Visible = True + + ObjVentas.Dispose() + UpINV.Update() + End Sub + Private Sub GvInvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInvMov.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CvePS") = "" Then + e.Row.FCLiteral("LtlPS").Text = String.Format("Folio: {1} Fecha: {2} {3} {4}", e.Row.DBCampo("CveMovimiento"), e.Row.DBCampo("Folio"), e.Row.DBCampo("Fecha").ToString.ToDate.ToShortDateString, e.Row.DBCampo("Almacen").ToString, e.Row.DBCampo("Concepto").ToString) + + If e.Row.DataKey("Origen").ToEntero > 0 Then + e.Row.CssClass = "SubTotales" + Else + e.Row.BackColor = Drawing.Color.FromArgb(224, 130, 131) + e.Row.ForeColor = Drawing.Color.White + e.Row.Font.Bold = True + End If + Else + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left + End If + End If + End Sub + + Private Sub GvAcarreo_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcarreo.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCLiteral("LtlImporte").Text = "$" + FormatNumber(e.Row.FCLiteral("LtlImporte").Text.ToDouble, 2, , , TriState.True) + End If End Sub -#End Region +#End Region -#Region " REGENERA PREPOLIZA " - Protected Sub BtnRegenerarPrePolizaAlmacen_Click(sender As Object, e As EventArgs) - 'RegeneraPrePoliza() - - Dim ObjCompra As New ClsCompras - Dim ObjContabilidad As New ClsContabilidad(ObjCompra.IniciaTransacSQL) - - Dim Estatus = ActualizarPrePoliza(ObjContabilidad, ObjCompra) - - If Estatus Then - ObjCompra.Commit() - Alert("La PrePoliza se regeneró correctamente.", TipoMensaje.MsgInformacion) - Else - ObjCompra.RollBack() - Alert("Ocurrió un error al regenerar la PrePoliza.", TipoMensaje.MsgError) - End If - ObjCompra.Dispose() - - End Sub - - Private Sub RegeneraPrePoliza() - 'Alert($"CvePrePoliza de la compra: {CvePrePoliza}", TipoMensaje.MsgInformacion) - - 'MOVIMIENTOS DE ALMACEN DE LA COMPRA - Dim ObjInventarios As New ClsInventarios - Dim DtInv As New DataTable - If ObjInventarios.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then - DtInv = ObjInventarios.DtResultados - End If - ObjInventarios.Dispose() - - Dim DtTemporal = TmpDT.Copy - DtTemporal.Columns.Add("ImporteEnAlmacen", GetType(Decimal)) - - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - Dim TieneError = True - - 'ELIMINA DETALLES DE [AF - INV - GASTO] - If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) Then - If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then - If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then - TieneError = False - End If - End If - End If - - 'INGRESAMOS DETALLES - If Not TieneError Then - - 'CONFIGURACIONES - Dim CuentasContablesInvalidas As New StringBuilder - Dim CuentasContablesInvalidasSIG As New StringBuilder - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - Dim CveProveedorConcepto = 0 - Dim Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) - - Dim ImporteMovimiento = 0.0D - Dim importeMN = 0.0D - - Dim TipoCambioActual = 0.0D - Dim TipoCambioPago = 0.0D - Dim FechaMovimiento As Date = TxtFecha.Text.ToDate - - 'TIPO CAMBIO - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then - TipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal - TipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal - Else - TipoCambioActual = 1 - TipoCambioPago = 1 - End If - - 'CTA PROVEEDOR - Select Case RBLContado.SelectedValue - Case "4" ' Deudores - CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero - Case "5" ' Acreedores - CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero - Case Else ' Proveedores - F y E - Doctos - CveProveedorConcepto = CveProveedor - End Select - - - 'INGRESA DETALLE DE AF(49) - TipoAF 2 es para las compras - Dim DT = DtTemporal.FiltraParametros("ISNULL(TipoAF,0) = 2") - If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" Then - For Each Row2 As DataRow In DT.Rows - ImporteMovimiento = Row2("Total").ToString.ToDecimal * Multiplicador - importeMN = ImporteMovimiento * TipoCambioActual - If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero - End If - End If - If ImporteMovimiento <> 0 Then - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) - End If - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then - TieneError = True - End If - End If - Next - End If - - ImporteMovimiento = 0 - IdCtaContable = 0 - - 'INGRESA DETALLE DE ALMACÉN(68) - Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - Dim CveMovimientoInventario = -1 - Dim ModalidadAlmacen = -1 - Dim DtMovtosAlmacen As New DataTable - DtMovtosAlmacen.Columns.Add("CveMovimiento", GetType(Integer)) - DtMovtosAlmacen.Columns.Add("IdCtaContable", GetType(Integer)) - DtMovtosAlmacen.Columns.Add("CveCuenta", GetType(Integer)) - DtMovtosAlmacen.Columns.Add("Importe", GetType(Decimal)) - - If DtTemporal.FiltraParametros("ISNULL(TipoAF,0) <> 2").Rows.Count > 0 Then - For Each Row2 As DataRow In DtTemporal.FiltraParametros("ISNULL(TipoAF,0) <> 2").Rows - 'VALIDAMOS TIPO ALMACEN DE LA COMPRA DETALLE - SI ES TIPO "SOLO EXISTENCIA" (0) SKIPEAMOS - ModalidadAlmacen = DtInv.MIN("ModalidadAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToEntero - If ModalidadAlmacen = 0 Then - Continue For - End If - CveMovimientoInventario = DtInv.MAX("CveMovimiento", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToEntero - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DtInv.MIN("CveAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}")}").ToEntero - CveCuenta = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DtInv.MIN("CveAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}")}").ToEntero - - ImporteMovimiento = DtInv.SUM(If(DdlMoneda.SelectedValue = "1", "Total", "TotalExtranjero"), $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToDecimal - ImporteMovimiento = If(ImporteMovimiento > Row2("Total").ToString.ToDecimal, Row2("Total").ToString.ToDecimal, ImporteMovimiento) * Multiplicador - - 'VALIDA QUE CUANDO SEA DOLARES TENGA PUEXTRANJERO EN EL MOVTO DE ALMACEN - If DdlMoneda.SelectedValue = "2" And ImporteMovimiento = 0 And DtInv.SUM("Total", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToDecimal > 0 Then - TieneError = True - Exit For - End If - - Dim DrInv = DtMovtosAlmacen.NewRow - DrInv("CveMovimiento") = CveMovimientoInventario - DrInv("IdCtaContable") = IdCtaContable - DrInv("CveCuenta") = CveCuenta - DrInv("Importe") = ImporteMovimiento - DtMovtosAlmacen.Rows.Add(DrInv) - - If ImporteMovimiento <> 0 Then - Row2("ImporteEnAlmacen") = ImporteMovimiento - End If - Next - - For Each Row As DataRow In DtMovtosAlmacen.FiltraParametros("", "", {"CveMovimiento", "IdCtaContable"}).Rows - ImporteMovimiento = DtMovtosAlmacen.SUM("Importe", $"CveMovimiento = {Row("CveMovimiento").ToString.ToEntero} AND IdCtaContable = {Row("IdCtaContable").ToString.ToEntero}").ToString.ToDecimal - importeMN = ImporteMovimiento * TipoCambioActual - If ImporteMovimiento <> 0 Then - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - End If - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Concepto, 68, Concepto, FechaMovimiento, Row("IdCtaContable").ToString.ToEntero, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveMovimientoAlmacen:=Row("CveMovimiento").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=Row("CveCuenta").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - End If - - ImporteMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - - 'INGRESA DETALLE DE GASTO(6) - DT = DtTemporal - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - For Each Dr As DataRow In DT.Rows - Dr("CveAlmacen") = DtInv.MIN("ModalidadAlmacen", $"CveCompraDetalle = {Dr("CveCompraDetalle")}").ToEntero - Dr.AcceptChanges() - Next - DT.AcceptChanges() - - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - DT = DT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto"}) - Else - DT = DT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto"}) - End If - - If DT.Rows.Count > 0 Then - Dim ImporteAlmacen = 0.0D - For Each Row2 As DataRow In DT.Rows - If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - ImporteMovimiento = DtTemporal.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal - ImporteAlmacen = DtTemporal.SUM("ImporteEnAlmacen", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal - Else - ImporteMovimiento = DtTemporal.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal - ImporteAlmacen = DtTemporal.SUM("ImporteEnAlmacen", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal - End If - ImporteMovimiento = (ImporteMovimiento - ImporteAlmacen) * Multiplicador - importeMN = ImporteMovimiento * TipoCambioActual - If Row2("CveClasificacion").ToString.ToEntero > 0 Then - If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero) Then - If ObjConta.DtResultados.Rows.Count > 0 AndAlso (ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Or ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero > 0) Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero - End If - End If - End If - Dim IdSegmentoNegocio As Integer = -1 - Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto"))) - If drT IsNot Nothing Then - IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero - End If - If ImporteMovimiento <> 0 Then - If IdCtaContable = 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - End If - If CveCuenta = 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) - End If - Dim tcvecon As Integer = 6 - Dim tidctacon As Integer = 6 - tidctacon = IdCtaContable - If DdlTipoComprobante.SelectedValue = "Ant" Then - tcvecon = 264 - tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero - If DdlMoneda.SelectedValue = "2" Then - tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero - End If - End If - - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Concepto, tcvecon, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then - TieneError = True - End If - - End If - Next - End If - - End If - - - If Not TieneError Then - ObjConta.Commit() - Alert("La PrePoliza se regeneró correctamente.", TipoMensaje.MsgInformacion) - Else - ObjConta.RollBack() - Alert("Ocurrió un error al regenerar la PrePoliza. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - ObjConta.Dispose() - - End Sub -#End Region +#Region " REGENERA PREPOLIZA " + Protected Sub BtnRegenerarPrePolizaAlmacen_Click(sender As Object, e As EventArgs) + 'RegeneraPrePoliza() -#Region " ACTUALIZAR TIPO CAMBIO PREPOLIZA " - Private Sub InicializaActualizarTC() - If CveCompra > 0 And DdlMoneda.SelectedValue.ToEntero = 2 And CvePrePoliza > 0 Then - TxtActualizarTC_TCActual.Text = TipoCambio.FormatoNumero(4) - TxtActualizarTC_TCActualizar.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).FormatoNumero(4) - HLModalActualizarTC.Visible = True - End If - End Sub - Protected Sub BtnActualizarTC_Click(sender As Object, e As EventArgs) - Dim ObjContabilidad As New ClsContabilidad - Dim ObjCompras As New ClsCompras(ObjContabilidad.IniciaTransacSQL()) - Dim ObjEventos As New ClsOIEventos(ObjContabilidad.IniciaTransacSQL()) - Dim TieneError = False - Dim MensajeError = "" - - If ObjEventos.AddEventoBitacora($"Se actualizó el Tipo de Cambio de la compra. TC anterior: {TxtActualizarTC_TCActual.Text.FormatoNumero(4)} | TC actual: {TxtActualizarTC_TCActualizar.Text.FormatoNumero(4)}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - If ObjCompras.UpdateCompraTipoCambio(TxtActualizarTC_TCActualizar.Text.ToDouble, CveCompra, CvePrePoliza, UsuarioActual.CveEmpresa) Then - If Not ObjContabilidad.ReconstruirPP_Compra(CveCompra) Then - TieneError = True - MensajeError = "Ocurrió un error al actualizar el Tipo de Cambio al documento" - End If - Else - TieneError = True - MensajeError = "Ocurrió un error al actualizar el asiento contable" - End If - Else - TieneError = True - MensajeError = "Ocurrió un error al guardar el historal al actualizar el Tipo de Cambio al documento" - End If - - If Not TieneError Then - ObjContabilidad.Commit() - Alert("Se actualizó correctamente el tipo de cambio del documento.", TipoMensaje.MsgInformacion) - RegistraScript("$('#ModalActualizarTC').modal('hide');") - Else - ObjContabilidad.RollBack() - Alert(MensajeError, TipoMensaje.MsgError) - End If - - ObjContabilidad.Dispose() - End Sub -#End Region + Dim ObjCompra As New ClsCompras + Dim ObjContabilidad As New ClsContabilidad(ObjCompra.IniciaTransacSQL) -#Region "PAQUETERIAS GUIAS" - Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs) - '' 25/05/2018 - Se agrega Link a Modulo Paqueterias Guias - RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveCompra={0}',800,620);", CveCompra)) - End Sub -#End Region + Dim Estatus = ActualizarPrePoliza(ObjContabilidad, ObjCompra) -#Region "DEDUCCIONES IEPS / OTROS IMPUESTOS" - Protected Sub CargaProductos(Ddl As DropDownList, CvePS As Integer) - Ddl.DataSource = TmpDT - Ddl.DataBind() - Ddl.Items.Insert(0, New ListItem("Seleccione un concepto", "-1")) - Ddl.SelectedValueExist("-1") - - If CvePS > 0 Then - Ddl.Items.Insert(1, New ListItem(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("PS"), CvePS.ToString)) - End If - - 'Ddl.Items.Insert(1, New ListItem(Concepto, "-1")) - End Sub - - Protected Sub BtnAgregarIEPS_Click(sender As Object, e As EventArgs) - TrasladoIEPS = TxtIEPS.Text.ToDecimal - OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal - - If ChkIEPS.Checked Then IEPSGasto = True - If ChkOtrosI.Checked Then OtrosImpuestosGasto = True - - If IEPSGasto Or OtrosImpuestosGasto Then - - 'AGREGA IEPS COMO CONCEPTO - If IEPSGasto Then - Dim CvePS As Integer = DdlConceptoIEPS.SelectedValue.ToEntero - ' If CvePS = -1 Then CvePS = UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero - AgregarConceptoIEPS(TrasladoIEPS, CvePS) - TrasladoIEPS = 0 - TxtIEPS.Text = 0.ToString.FormatoNumero - TrIEPS.Visible = False - For Each Dr As DataRow In TmpDT.Rows - Dr("IEPSPS") = 0 - Dr("IEPSPSPorcentaje") = 0 - Next - TmpDT.AcceptChanges() - End If - 'AGREGA OTROS IMPUESTOS COMO CONCEPTO - If OtrosImpuestosGasto Then - Dim CvePS As Integer = DdlConceptoOI.SelectedValue.ToEntero - 'If CvePS = -1 Then CvePS = UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero - AgregarConceptoIEPS(OtrosImpuestos, CvePS) - OtrosImpuestos = 0 - TxtOtrosImpuestos.Text = 0.ToString.FormatoNumero - TrOtrosImpuestos.Visible = False - End If - - CargaGvPersonal() - UpPS.Update() - RegistraScript("$('#ModalIEPS').modal('hide');") - Else - Alert("Debe seleccionar al menos un impuesto", TipoMensaje.MsgAdvertencia) - End If - - End Sub -#End Region + If Estatus Then + ObjCompra.Commit() + Alert("La PrePoliza se regeneró correctamente.", TipoMensaje.MsgInformacion) + Else + ObjCompra.RollBack() + Alert("Ocurrió un error al regenerar la PrePoliza.", TipoMensaje.MsgError) + End If + ObjCompra.Dispose() -#Region "C R E D I T O S" - - Private Sub ChkCreditoMultiple_CheckedChanged(sender As Object, e As EventArgs) Handles ChkCreditoMultiple.CheckedChanged - - If ChkCreditoMultiple.Checked Then - - romCreditosTabla.Visible = True - Dim ObjBancos As New ClsBancos - - If ObjBancos.GetCreditosDetalleCompras(UsuarioActual.CveEmpresa, CveProveedor, -1, -1, -1) Then - GvCreditos.DataSource = ObjBancos.DtResultados - Else - GvCreditos.DataSource = Nothing - End If - - ObjBancos.Dispose() - GvCreditos.DataBind() - - End If - End Sub - - Private Sub GvCreditos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCreditos.RowDataBound - - If e.Row.RowType = DataControlRowType.DataRow Then - - Dim TxtCapital As TextBox = e.Row.FCTextBox("TxtCapital") - Dim TxtInteres As TextBox = e.Row.FCTextBox("TxtInteres") - Dim TxtAmbos As TextBox = e.Row.FCTextBox("TxtAmbos") - Dim CveCreditoDetalle As Integer = e.Row.DataKey("CveCreditoDetalle").ToEntero - - Dim CveCompraCapital As Integer = e.Row.DataKey("CveCompra").ToEntero - Dim CveCompraInteres As Integer = e.Row.DataKey("CveCompraInteres").ToEntero - - If CveCompraCapital > 0 Then - TxtCapital.Enabled = False - TxtAmbos.Enabled = False - End If - - If CveCompraInteres > 0 Then - TxtInteres.Enabled = False - TxtAmbos.Enabled = False - End If - - TxtCapital.Attributes.Add("class", $"CsCreGlobal CsSelCapital{CveCreditoDetalle}") - TxtCapital.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},1)") - 'TxtCapital.Attributes.Add("data-CD", CveCreditoDetalle.ToString) - - TxtInteres.Attributes.Add("class", $"CsCreGlobal CsSelInteres{CveCreditoDetalle}") - TxtInteres.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},1)") - 'TxtInteres.Attributes.Add("data-CD", CveCreditoDetalle.ToString) - - TxtAmbos.Attributes.Add("class", $"CsCreGlobal CsSelAmbos{CveCreditoDetalle}") - TxtAmbos.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},2)") - 'TxtAmbos.Attributes.Add("data-CD", CveCreditoDetalle.ToString) - - - - End If - End Sub - - Private Sub CargaCreditosDisponibles() - - - If RBLPago.SelectedValue.ToEntero = 4 Then - - Dim ObjBancos As New ClsBancos - If ObjBancos.GetCreditosDetalleCompras(UsuarioActual.CveEmpresa, CveProveedor, -1, -1, -1) Then - - GvCreditos.DataSource = ObjBancos.DtResultados - Else - GvCreditos.DataSource = Nothing - End If - ObjBancos.Dispose() - romCreditosTabla.Visible = True - GvCreditos.DataBind() - - Else - romCreditosTabla.Visible = False - End If - - UpGvCreditos.Update() - - End Sub -#End Region - -#Region "FLETES / IMPORTACIONES" - Private Sub CargaFolio() - Dim ObjFolios As New ClsGralFolios - If ObjFolios.GetFolios("FLE", UsuarioActual.CveEmpresa) Then - If ObjFolios.DtResultados.Rows.Count > 0 Then - LblFolioModalFletes.Text = ObjFolios.DtResultados(0)("FActual").ToString - BtnCrearFleteImportacion.Enabled = True - Else - Alert("Necesita registrar un folio de fletes", TipoMensaje.MsgAdvertencia) - BtnCrearFleteImportacion.Enabled = False - End If - End If - ObjFolios.Dispose() - End Sub - Protected Sub BtnGuardarModalFletesImportaciones_Click(sender As Object, e As EventArgs) - If DdlFleteImportacion.SelectedValue.ToEntero = 237 And Not DdlFletes.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar un flete", TipoMensaje.MsgAdvertencia) : Exit Sub - If DdlFleteImportacion.SelectedValue.ToEntero = 240 And Not DdlImportaciones.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar una importación", TipoMensaje.MsgAdvertencia) : Exit Sub - If DdlFletes.SelectedValue.ToEntero > 0 Then - Dim ObjInventario As New ClsInventarios - Dim Dr As DataRow = Nothing - If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, DdlFletes.SelectedValue.ToEntero) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - Dr = ObjInventario.DtResultados.Rows(0) - End If - End If - If Dr IsNot Nothing Then - If Dr("CveCompra").ToString.ToEntero > 0 And RblFleteImportacionOpcion.SelectedValue.ToEntero = 1 Then - Alert("Este flete ya tiene compra asignada", TipoMensaje.MsgAdvertencia) - ObjInventario.Dispose() - Exit Sub - End If - End If - ObjInventario.Dispose() - End If - - If DdlFleteImportacion.SelectedValue.ToEntero = 237 Then DdlTipoCompra.SelectedValueExist("4") : UpEstatus.Update() - If DdlFleteImportacion.SelectedValue.ToEntero = 240 Then DdlTipoCompra.SelectedValueExist("5") : UpEstatus.Update() - - CveImportacion = DdlImportaciones.SelectedValue.ToEntero - CveFlete = DdlFletes.SelectedValue.ToEntero - FleteImportacionOpcion = RblFleteImportacionOpcion.SelectedValue.ToEntero - CveConceptoContableAlmacen = DdlFleteImportacion.SelectedValue.ToEntero - - - If CveCompra > 0 AndAlso (CveImportacion > 0 Or CveFlete > 0) Then - Dim ObjCompras As New ClsCompras - Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL) - Dim ObjInventario As New ClsInventarios(ObjCompras.IniciaTransacSQL) - Dim ErrorTrans As Boolean = False - - Select Case CveConceptoContableAlmacen - Case 237 - Select Case FleteImportacionOpcion - Case 1 - Dim Dr As DataRow = Nothing - If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - Dr = ObjInventario.DtResultados.Rows(0) - End If - End If - If Dr IsNot Nothing Then - If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then - ErrorTrans = True - End If - Else - ErrorTrans = True - End If - Case 2 - If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then - ErrorTrans = True - End If - 'actualiza la compra para que no se surta en almacen. sino por el flete o importación - If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then - ErrorTrans = True - End If - End Select - Case 240 - Select Case FleteImportacionOpcion - Case 1 - If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then - ErrorTrans = True - End If - Case 2 - If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then - ErrorTrans = True - End If - 'actualiza la compra para que no se surta en almacen. sino por el flete o importación - If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then - ErrorTrans = True - End If - End Select - End Select - - 'Removemos los conceptos de la prepoliza - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then ErrorTrans = False 'GASTO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then ErrorTrans = False 'ALMACEN - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) Then ErrorTrans = False 'AF - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 205, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 230, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 231, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 176, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 228, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO - If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 229, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO - - Dim ConceptoContabilizacion As Integer = CveConceptoContableAlmacen - Dim ConceptoContabilizacionME As Integer = -1 - Dim ConceptoContabilizacionMEComp As Integer = -1 - Dim importeMovimiento As Decimal = 0 - Dim importeMN As Decimal = 0 - Dim IdCtaContable As Integer = -1 - Dim IdCtaContableME As Integer = -1 - Dim IdCtaContableMEComp As Integer = -1 - Dim tipoCambioActual As Decimal = 0 - Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) - - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then - tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal - tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual) - Else - tipoCambioActual = 1 - End If - - Select Case ConceptoContabilizacion - Case 237 - ConceptoContabilizacionME = 238 - ConceptoContabilizacionMEComp = 239 - importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) - importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO - Case 240 - ConceptoContabilizacionME = 241 - ConceptoContabilizacionMEComp = 242 - importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) - importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO - End Select - - If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - - If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - - If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero - End If - Dim Concepto As String = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If DdlMoneda.SelectedValue.ToEntero <> 1 Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Concepto, ConceptoContabilizacionME, Concepto, TxtFecha.Text.ToDate, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Concepto, ConceptoContabilizacionMEComp, Concepto, TxtFecha.Text.ToDate, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then - ErrorTrans = True - End If - Else - ErrorTrans = True - End If - Else - - If importeMN <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN, Concepto, ConceptoContabilizacion, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then - ErrorTrans = True - End If - End If - - If Not ErrorTrans Then - ObjCompras.Commit() - Else - ObjCompras.RollBack() - End If - ObjCompras.Dispose() - ObjConta.Dispose() - ObjInventario.Dispose() - - End If - - - RegistraScript("$('#ModalFletesImportaciones').modal('hide')") - End Sub - - Private Sub CargaModalFletesImportaciones() - - TxtFechaModalImportacionesFletes.Text = Now.ToShortDateString - TxtDescripcionModalFletesImportacion.Text = "" - TxtPedimento.Text = "" - RblTipo.SelectedValue = "1" - RblFleteImportacionOpcion.SelectedValue = "1" - CargaCombosFletesImportaciones() - CambiaTipo() - DdlFletes.SelectedValueExist(CveFlete) - DdlImportaciones.SelectedValueExist(CveImportacion) - If FleteImportacionOpcion > 0 Then RblFleteImportacionOpcion.SelectedValue = FleteImportacionOpcion.ToString - RegistraScript("$('#ModalFletesImportaciones').modal()") - UpModalFletesImportaciones.Update() - End Sub - Protected Sub RblTipo_SelectedIndexChanged(sender As Object, e As EventArgs) - CambiaTipo() - UpModalFletesImportaciones.Update() - End Sub - - Private Sub CambiaTipo() - Select Case RblTipo.SelectedValue.ToEntero - Case 1 - DivVinculacion.Visible = True - DivCrear.Visible = False - Select Case DdlFleteImportacion.SelectedValue.ToEntero - Case 237 - LblTitulo.Text = "Costo Indirecto" - DivFletes.Visible = True - DivImportaciones.Visible = False - Case 240 - LblTitulo.Text = "Importación" - DivFletes.Visible = False - DivImportaciones.Visible = True - End Select - Case 2 - DivVinculacion.Visible = False - DivCrear.Visible = True - Select Case DdlFleteImportacion.SelectedValue.ToEntero - Case 237 - LblTitulo.Text = "Costo Indirecto" - DivLblFolio.Visible = True - DivPedimento.Visible = False - CargaFolio() - Case 240 - LblTitulo.Text = "Importación" - DivLblFolio.Visible = False - DivPedimento.Visible = True - End Select - End Select - End Sub - Protected Sub BtnCrearFleteImportacion_Click(sender As Object, e As EventArgs) - Dim CveFlete As Integer = 0 - Dim CveImportacion As Integer = 0 - Select Case DdlFleteImportacion.SelectedValue.ToEntero - Case 237 - Dim ObjInv As New ClsInventarios - If ObjInv.AddFlete(LblFolioModalFletes.Text, TxtDescripcionModalFletesImportacion.Text.Trim, TxtFechaModalImportacionesFletes.Text.ToDate, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - CveFlete = ObjInv.CveFlete - Alert("Costo indirecto creado correctamente") - End If - ObjInv.Dispose() - Case 240 - Dim ObjCompras As New ClsCompras - CveImportacion = ObjCompras.AddImportacion(TxtPedimento.Text.Trim, TxtDescripcionModalFletesImportacion.Text.Trim, CveProveedor, -1, TxtFechaModalImportacionesFletes.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - ObjCompras.Dispose() - If CveImportacion > 0 Then Alert("Importación creada correctamente") - End Select - If CveFlete > 0 Or CveImportacion > 0 Then - RblTipo.SelectedValue = "1" - CambiaTipo() - CargaCombosFletesImportaciones() - Select Case DdlFleteImportacion.SelectedValue.ToEntero - Case 237 - DdlFletes.SelectedValueExist(CveFlete) - Case 240 - DdlImportaciones.SelectedValueExist(CveImportacion) - End Select - TxtFechaModalImportacionesFletes.Text = Now.ToShortDateString - TxtDescripcionModalFletesImportacion.Text = "" - TxtPedimento.Text = "" - UpModalFletesImportaciones.Update() - End If - End Sub - - Private Sub CargaCombosFletesImportaciones() - DdlFletes.Items.Clear() - DdlImportaciones.Items.Clear() - - Dim ObjCompras As New ClsCompras - If ObjCompras.GetImportaciones(-1, -1, -1, "-1", "-1", UsuarioActual.CveEmpresa) Then - DdlImportaciones.DataSource = ObjCompras.DtResultados - DdlImportaciones.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - ObjCompras.Dispose() - - Dim ObjInv As New ClsInventarios - If ObjInv.GetFletes(UsuarioActual.CveEmpresa) Then - DdlFletes.DataSource = ObjInv.DtResultados - DdlFletes.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - ObjInv.Dispose() - - DdlImportaciones.DataBind() - DdlFletes.DataBind() - - End Sub - - Private Sub LnkFletesImportaciones_Click(sender As Object, e As EventArgs) Handles LnkFletesImportaciones.Click - CargaModalFletesImportaciones() - End Sub - - - Protected Sub DdlFleteImportacion_SelectedIndexChanged1(sender As Object, e As EventArgs) - CambiaTipo() - UpModalFletesImportaciones.Update() End Sub -#End Region + Private Sub RegeneraPrePoliza() + If CvePrePoliza <= 0 Then Alert($"CvePrePoliza de la compra: {CvePrePoliza}", TipoMensaje.MsgInformacion) - Private Function AjustarPrePolizaVinculacionOC(ByRef OC As ClsOC, ByRef OCBitacora As ClsOIEventos, ByRef ObjInventarios As ClsInventarios, ByRef ObjConta As ClsContabilidad, ByRef ObjAC As ClsContPAQi) As Boolean - - 'VARIABLES - Dim CveProveedorSucursal As Integer = -1 - Dim CveProveedorContacto As Integer = -1 - Dim Retorno As Boolean = True - Dim CveProveedor As Integer = -1 - Dim GeneraReq = False - Dim IDPoliza As Integer = 0 - - - 'EMPIEZA OBJETOS Y TRANSACCIONES - 'Dim OC As New ClsOC - 'Dim OCBitacora As New ClsOIEventos(OC.IniciaTransacSQL()) - 'Dim ObjInventarios As New ClsInventarios(OC.IniciaTransacSQL()) - 'Dim ObjConta As New ClsContabilidad(OC.IniciaTransacSQL()) - - - - Dim DtInvOC As New DataTable - Dim DtInvOCDiferencias As New DataTable 'Actualizado con diferencia - DtInvOCDiferencias.Columns.Add("CveOrdenCompra", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("Diferencia", GetType(Decimal)) - DtInvOCDiferencias.Columns.Add("PUCompra", GetType(Decimal)) - DtInvOCDiferencias.Columns.Add("CveMoneda", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("FolioOC", GetType(String)) - DtInvOCDiferencias.Columns.Add("CveProveedor", GetType(Integer)) - 'DtInvOCDiferencias.Columns.Add("ImporteMovto", GetType(Double)) - 'DtInvOCDiferencias.Columns.Add("ImporteMovtoDLLS", GetType(Double)) - DtInvOCDiferencias.Columns.Add("CveAlmacen", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("CveMovimiento", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("FolioAlmacen", GetType(String)) - DtInvOCDiferencias.Columns.Add("TipoCambioAjuste", GetType(Double)) - DtInvOCDiferencias.Columns.Add("ConceptoSalida", GetType(Integer)) - DtInvOCDiferencias.Columns.Add("PS", GetType(String)) - - - Dim dr2 As DataRow - For Each gvr As GridViewRow In GvOC1.Rows - If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then - dr2 = DTOCGV.Rows(gvr.RowIndex) - - Dim diferencia As Decimal = (dr2("PU").ToString.ToDecimal - gvr.FCTextBox("TxtPU").Text.ToDecimal) * gvr.FCTextBox("TxtCantidad").Text.ToDecimal - - Dim DrInvOCDiferencias As DataRow - If diferencia <> 0 Then 'And DtInvOC.Rows.Count > 0 - DrInvOCDiferencias = DtInvOCDiferencias.NewRow - DrInvOCDiferencias("CveOrdenCompra") = dr2("CveOrdenCompra").ToString.ToEntero - DrInvOCDiferencias("CveOrdenCompraDetalle") = dr2("CveOrdenCompraDetalle").ToString.ToEntero - DrInvOCDiferencias("Diferencia") = diferencia.RoundSQL() - DrInvOCDiferencias("PUCompra") = Math.Round(gvr.FCTextBox("TxtPU").Text.ToDecimal, 6) - DrInvOCDiferencias("CveMoneda") = dr2("CveMoneda").ToString.ToEntero - DrInvOCDiferencias("FolioOC") = dr2("FolioOC").ToString - DrInvOCDiferencias("CveProveedor") = dr2("CveProveedorOC").ToString.ToEntero - DrInvOCDiferencias("PS") = dr2("PS").ToString - DrInvOCDiferencias("FolioAlmacen") = dr2("FolioAlmacen").ToString - - If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(205) Then - DrInvOCDiferencias("TipoCambioAjuste") = 0 - DrInvOCDiferencias("CveAlmacen") = 0 - DrInvOCDiferencias("CveMovimiento") = 0 - DrInvOCDiferencias("ConceptoSalida") = 0 - DtInvOCDiferencias.Rows.Add(DrInvOCDiferencias) - Else - If ObjInventarios.GetMovimientosOC(dr2("CveOrdenCompra").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - DtInvOC = ObjInventarios.DtResultados.FiltraParametros($"CvePS > 0 AND CveOrdenCompraDetalle = {dr2("CveOrdenCompraDetalle").ToString.ToEntero}").Copy - End If - Dim drInv As DataRow = DtInvOC.FiltroPrimero("") + 'MOVIMIENTOS DE ALMACEN DE LA COMPRA + Dim ObjInventarios As New ClsInventarios + Dim DtInv As New DataTable + If ObjInventarios.GetInv_ComprasMov(CveCompra, UsuarioActual.CveEmpresa) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then + DtInv = ObjInventarios.DtResultados + End If + ObjInventarios.Dispose() + + Dim DtTemporal = TmpDT.Copy + DtTemporal.Columns.Add("ImporteEnAlmacen", GetType(Decimal)) + + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + Dim TieneError = True + + 'ELIMINA DETALLES DE [AF - INV - GASTO] + If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) Then + If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then + If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then + TieneError = False + End If + End If + End If + + 'INGRESAMOS DETALLES + If Not TieneError Then + + 'CONFIGURACIONES + Dim CuentasContablesInvalidas As New StringBuilder + Dim CuentasContablesInvalidasSIG As New StringBuilder + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim CveProveedorConcepto = 0 + Dim Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) + + Dim ImporteMovimiento = 0.0D + Dim importeMN = 0.0D + + Dim TipoCambioActual = 0.0D + Dim TipoCambioPago = 0.0D + Dim FechaMovimiento As Date = TxtFecha.Text.ToDate + + 'TIPO CAMBIO + If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then + TipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal + TipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal + Else + TipoCambioActual = 1 + TipoCambioPago = 1 + End If + + 'CTA PROVEEDOR + Select Case RBLContado.SelectedValue + Case "4" ' Deudores + CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero + Case "5" ' Acreedores + CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero + Case Else ' Proveedores - F y E - Doctos + CveProveedorConcepto = CveProveedor + End Select + + + 'INGRESA DETALLE DE AF(49) - TipoAF 2 es para las compras + Dim DT = DtTemporal.FiltraParametros("ISNULL(TipoAF,0) = 2") + If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" Then + For Each Row2 As DataRow In DT.Rows + ImporteMovimiento = Row2("Total").ToString.ToDecimal * Multiplicador + importeMN = ImporteMovimiento * TipoCambioActual + If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero + End If + End If + If ImporteMovimiento <> 0 Then + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) + End If + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString) + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then + TieneError = True + End If + End If + Next + End If + + ImporteMovimiento = 0 + IdCtaContable = 0 + + 'INGRESA DETALLE DE ALMACÉN(68) + Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + Dim CveMovimientoInventario = -1 + Dim ModalidadAlmacen = -1 + Dim DtMovtosAlmacen As New DataTable + DtMovtosAlmacen.Columns.Add("CveMovimiento", GetType(Integer)) + DtMovtosAlmacen.Columns.Add("IdCtaContable", GetType(Integer)) + DtMovtosAlmacen.Columns.Add("CveCuenta", GetType(Integer)) + DtMovtosAlmacen.Columns.Add("Importe", GetType(Decimal)) + + If DtTemporal.FiltraParametros("ISNULL(TipoAF,0) <> 2").Rows.Count > 0 Then + For Each Row2 As DataRow In DtTemporal.FiltraParametros("ISNULL(TipoAF,0) <> 2").Rows + 'VALIDAMOS TIPO ALMACEN DE LA COMPRA DETALLE - SI ES TIPO "SOLO EXISTENCIA" (0) SKIPEAMOS + ModalidadAlmacen = DtInv.MIN("ModalidadAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToEntero + If ModalidadAlmacen = 0 Then + Continue For + End If + CveMovimientoInventario = DtInv.MAX("CveMovimiento", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToEntero + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DtInv.MIN("CveAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}")}").ToEntero + CveCuenta = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DtInv.MIN("CveAlmacen", $"CveCompraDetalle = {Row2("CveCompraDetalle")}")}").ToEntero + + ImporteMovimiento = DtInv.SUM(If(DdlMoneda.SelectedValue = "1", "Total", "TotalExtranjero"), $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToDecimal + ImporteMovimiento = If(ImporteMovimiento > Row2("Total").ToString.ToDecimal, Row2("Total").ToString.ToDecimal, ImporteMovimiento) * Multiplicador + + 'VALIDA QUE CUANDO SEA DOLARES TENGA PUEXTRANJERO EN EL MOVTO DE ALMACEN + If DdlMoneda.SelectedValue = "2" And ImporteMovimiento = 0 And DtInv.SUM("Total", $"CveCompraDetalle = {Row2("CveCompraDetalle")}").ToDecimal > 0 Then + TieneError = True + Exit For + End If + + Dim DrInv = DtMovtosAlmacen.NewRow + DrInv("CveMovimiento") = CveMovimientoInventario + DrInv("IdCtaContable") = IdCtaContable + DrInv("CveCuenta") = CveCuenta + DrInv("Importe") = ImporteMovimiento + DtMovtosAlmacen.Rows.Add(DrInv) + + If ImporteMovimiento <> 0 Then + Row2("ImporteEnAlmacen") = ImporteMovimiento + End If + Next + + For Each Row As DataRow In DtMovtosAlmacen.FiltraParametros("", "", {"CveMovimiento", "IdCtaContable"}).Rows + ImporteMovimiento = DtMovtosAlmacen.SUM("Importe", $"CveMovimiento = {Row("CveMovimiento").ToString.ToEntero} AND IdCtaContable = {Row("IdCtaContable").ToString.ToEntero}").ToString.ToDecimal + importeMN = ImporteMovimiento * TipoCambioActual + If ImporteMovimiento <> 0 Then + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + End If + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString) + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Concepto, 68, Concepto, FechaMovimiento, Row("IdCtaContable").ToString.ToEntero, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveMovimientoAlmacen:=Row("CveMovimiento").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=Row("CveCuenta").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + End If + + ImporteMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + + 'INGRESA DETALLE DE GASTO(6) + DT = DtTemporal + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + For Each Dr As DataRow In DT.Rows + Dr("CveAlmacen") = DtInv.MIN("ModalidadAlmacen", $"CveCompraDetalle = {Dr("CveCompraDetalle")}").ToEntero + Dr.AcceptChanges() + Next + DT.AcceptChanges() + + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + DT = DT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto"}) + Else + DT = DT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto"}) + End If + + If DT.Rows.Count > 0 Then + Dim ImporteAlmacen = 0.0D + For Each Row2 As DataRow In DT.Rows + If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + ImporteMovimiento = DtTemporal.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal + ImporteAlmacen = DtTemporal.SUM("ImporteEnAlmacen", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal + Else + ImporteMovimiento = DtTemporal.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal + ImporteAlmacen = DtTemporal.SUM("ImporteEnAlmacen", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal + End If + ImporteMovimiento = (ImporteMovimiento - ImporteAlmacen) * Multiplicador + importeMN = ImporteMovimiento * TipoCambioActual + If Row2("CveClasificacion").ToString.ToEntero > 0 Then + If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero) Then + If ObjConta.DtResultados.Rows.Count > 0 AndAlso (ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Or ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero > 0) Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero + End If + End If + End If + Dim IdSegmentoNegocio As Integer = -1 + Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto"))) + If drT IsNot Nothing Then + IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero + End If + If ImporteMovimiento <> 0 Then + If IdCtaContable = 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + End If + If CveCuenta = 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString) + End If + Dim tcvecon As Integer = 6 + Dim tidctacon As Integer = 6 + tidctacon = IdCtaContable + If DdlTipoComprobante.SelectedValue = "Ant" Then + tcvecon = 264 + tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero + If DdlMoneda.SelectedValue = "2" Then + tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero + End If + End If + + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, Concepto, tcvecon, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(TipoCambioActual = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta) Then + TieneError = True + End If + + End If + Next + End If + + End If + + + If Not TieneError Then + ObjConta.Commit() + Alert("La PrePoliza se regeneró correctamente.", TipoMensaje.MsgInformacion) + Else + ObjConta.RollBack() + Alert("Ocurrió un error al regenerar la PrePoliza. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + ObjConta.Dispose() + + End Sub +#End Region + +#Region " ACTUALIZAR TIPO CAMBIO PREPOLIZA " + Private Sub InicializaActualizarTC() + If CveCompra > 0 And DdlMoneda.SelectedValue.ToEntero = 2 And CvePrePoliza > 0 Then + TxtActualizarTC_TCActual.Text = TipoCambio.FormatoNumero(4) + TxtActualizarTC_TCActualizar.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).FormatoNumero(4) + HLModalActualizarTC.Visible = True + End If + End Sub + Protected Sub BtnActualizarTC_Click(sender As Object, e As EventArgs) + Dim ObjContabilidad As New ClsContabilidad + Dim ObjCompras As New ClsCompras(ObjContabilidad.IniciaTransacSQL()) + Dim ObjEventos As New ClsOIEventos(ObjContabilidad.IniciaTransacSQL()) + Dim TieneError = False + Dim MensajeError = "" + + If ObjEventos.AddEventoBitacora($"Se actualizó el Tipo de Cambio de la compra. TC anterior: {TxtActualizarTC_TCActual.Text.FormatoNumero(4)} | TC actual: {TxtActualizarTC_TCActualizar.Text.FormatoNumero(4)}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + If ObjCompras.UpdateCompraTipoCambio(TxtActualizarTC_TCActualizar.Text.ToDouble, CveCompra, CvePrePoliza, UsuarioActual.CveEmpresa) Then + If Not ObjContabilidad.ReconstruirPP_Compra(CveCompra) Then + TieneError = True + MensajeError = "Ocurrió un error al actualizar el Tipo de Cambio al documento" + End If + Else + TieneError = True + MensajeError = "Ocurrió un error al actualizar el asiento contable" + End If + Else + TieneError = True + MensajeError = "Ocurrió un error al guardar el historal al actualizar el Tipo de Cambio al documento" + End If + + If Not TieneError Then + ObjContabilidad.Commit() + Alert("Se actualizó correctamente el tipo de cambio del documento.", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalActualizarTC').modal('hide');") + Else + ObjContabilidad.RollBack() + Alert(MensajeError, TipoMensaje.MsgError) + End If + + ObjContabilidad.Dispose() + End Sub +#End Region + +#Region "PAQUETERIAS GUIAS" + Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs) + '' 25/05/2018 - Se agrega Link a Modulo Paqueterias Guias + RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveCompra={0}',800,620);", CveCompra)) + End Sub +#End Region + +#Region "DEDUCCIONES IEPS / OTROS IMPUESTOS" + Protected Sub CargaProductos(Ddl As DropDownList, CvePS As Integer) + Ddl.DataSource = TmpDT + Ddl.DataBind() + Ddl.Items.Insert(0, New ListItem("Seleccione un concepto", "-1")) + Ddl.SelectedValueExist("-1") + + If CvePS > 0 Then + Ddl.Items.Insert(1, New ListItem(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("PS"), CvePS.ToString)) + End If + + 'Ddl.Items.Insert(1, New ListItem(Concepto, "-1")) + End Sub + + Protected Sub BtnAgregarIEPS_Click(sender As Object, e As EventArgs) + TrasladoIEPS = TxtIEPS.Text.ToDecimal + OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal + + If ChkIEPS.Checked Then IEPSGasto = True + If ChkOtrosI.Checked Then OtrosImpuestosGasto = True + + If IEPSGasto Or OtrosImpuestosGasto Then + + 'AGREGA IEPS COMO CONCEPTO + If IEPSGasto Then + Dim CvePS As Integer = DdlConceptoIEPS.SelectedValue.ToEntero + ' If CvePS = -1 Then CvePS = UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero + AgregarConceptoIEPS(TrasladoIEPS, CvePS) + TrasladoIEPS = 0 + TxtIEPS.Text = 0.ToString.FormatoNumero + TrIEPS.Visible = False + For Each Dr As DataRow In TmpDT.Rows + Dr("IEPSPS") = 0 + Dr("IEPSPSPorcentaje") = 0 + Next + TmpDT.AcceptChanges() + End If + 'AGREGA OTROS IMPUESTOS COMO CONCEPTO + If OtrosImpuestosGasto Then + Dim CvePS As Integer = DdlConceptoOI.SelectedValue.ToEntero + 'If CvePS = -1 Then CvePS = UsuarioActual.Empresa.Funcionalidad(305).ToString.ToEntero + AgregarConceptoIEPS(OtrosImpuestos, CvePS) + OtrosImpuestos = 0 + TxtOtrosImpuestos.Text = 0.ToString.FormatoNumero + TrOtrosImpuestos.Visible = False + End If + + CargaGvPersonal() + UpPS.Update() + RegistraScript("$('#ModalIEPS').modal('hide');") + Else + Alert("Debe seleccionar al menos un impuesto", TipoMensaje.MsgAdvertencia) + End If + + End Sub +#End Region + +#Region "C R E D I T O S" + + Private Sub ChkCreditoMultiple_CheckedChanged(sender As Object, e As EventArgs) Handles ChkCreditoMultiple.CheckedChanged + + If ChkCreditoMultiple.Checked Then + + romCreditosTabla.Visible = True + Dim ObjBancos As New ClsBancos + + If ObjBancos.GetCreditosDetalleCompras(UsuarioActual.CveEmpresa, CveProveedor, -1, -1, -1) Then + GvCreditos.DataSource = ObjBancos.DtResultados + Else + GvCreditos.DataSource = Nothing + End If + + ObjBancos.Dispose() + GvCreditos.DataBind() + + End If + End Sub + + Private Sub GvCreditos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCreditos.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim TxtCapital As TextBox = e.Row.FCTextBox("TxtCapital") + Dim TxtInteres As TextBox = e.Row.FCTextBox("TxtInteres") + Dim TxtAmbos As TextBox = e.Row.FCTextBox("TxtAmbos") + Dim CveCreditoDetalle As Integer = e.Row.DataKey("CveCreditoDetalle").ToEntero + + Dim CveCompraCapital As Integer = e.Row.DataKey("CveCompra").ToEntero + Dim CveCompraInteres As Integer = e.Row.DataKey("CveCompraInteres").ToEntero + + If CveCompraCapital > 0 Then + TxtCapital.Enabled = False + TxtAmbos.Enabled = False + End If + + If CveCompraInteres > 0 Then + TxtInteres.Enabled = False + TxtAmbos.Enabled = False + End If + + TxtCapital.Attributes.Add("class", $"CsCreGlobal CsSelCapital{CveCreditoDetalle}") + TxtCapital.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},1)") + 'TxtCapital.Attributes.Add("data-CD", CveCreditoDetalle.ToString) + + TxtInteres.Attributes.Add("class", $"CsCreGlobal CsSelInteres{CveCreditoDetalle}") + TxtInteres.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},1)") + 'TxtInteres.Attributes.Add("data-CD", CveCreditoDetalle.ToString) + + TxtAmbos.Attributes.Add("class", $"CsCreGlobal CsSelAmbos{CveCreditoDetalle}") + TxtAmbos.Attributes.Add("onkeyup", $"ValidaCredito(this,event,{CveCreditoDetalle},2)") + 'TxtAmbos.Attributes.Add("data-CD", CveCreditoDetalle.ToString) + + + + End If + End Sub + + Private Sub CargaCreditosDisponibles() + + + If RBLPago.SelectedValue.ToEntero = 4 Then + + Dim ObjBancos As New ClsBancos + If ObjBancos.GetCreditosDetalleCompras(UsuarioActual.CveEmpresa, CveProveedor, -1, -1, -1) Then + + GvCreditos.DataSource = ObjBancos.DtResultados + Else + GvCreditos.DataSource = Nothing + End If + ObjBancos.Dispose() + romCreditosTabla.Visible = True + GvCreditos.DataBind() + + Else + romCreditosTabla.Visible = False + End If + + UpGvCreditos.Update() + + End Sub +#End Region + +#Region "FLETES / IMPORTACIONES" + Private Sub CargaFolio() + Dim ObjFolios As New ClsGralFolios + If ObjFolios.GetFolios("FLE", UsuarioActual.CveEmpresa) Then + If ObjFolios.DtResultados.Rows.Count > 0 Then + LblFolioModalFletes.Text = ObjFolios.DtResultados(0)("FActual").ToString + BtnCrearFleteImportacion.Enabled = True + Else + Alert("Necesita registrar un folio de fletes", TipoMensaje.MsgAdvertencia) + BtnCrearFleteImportacion.Enabled = False + End If + End If + ObjFolios.Dispose() + End Sub + Protected Sub BtnGuardarModalFletesImportaciones_Click(sender As Object, e As EventArgs) + If DdlFleteImportacion.SelectedValue.ToEntero = 237 And Not DdlFletes.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar un flete", TipoMensaje.MsgAdvertencia) : Exit Sub + If DdlFleteImportacion.SelectedValue.ToEntero = 240 And Not DdlImportaciones.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar una importación", TipoMensaje.MsgAdvertencia) : Exit Sub + If DdlFletes.SelectedValue.ToEntero > 0 Then + Dim ObjInventario As New ClsInventarios + Dim Dr As DataRow = Nothing + If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, DdlFletes.SelectedValue.ToEntero) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + Dr = ObjInventario.DtResultados.Rows(0) + End If + End If + If Dr IsNot Nothing Then + If Dr("CveCompra").ToString.ToEntero > 0 And RblFleteImportacionOpcion.SelectedValue.ToEntero = 1 Then + Alert("Este flete ya tiene compra asignada", TipoMensaje.MsgAdvertencia) + ObjInventario.Dispose() + Exit Sub + End If + End If + ObjInventario.Dispose() + End If + + If DdlFleteImportacion.SelectedValue.ToEntero = 237 Then DdlTipoCompra.SelectedValueExist("4") : UpEstatus.Update() + If DdlFleteImportacion.SelectedValue.ToEntero = 240 Then DdlTipoCompra.SelectedValueExist("5") : UpEstatus.Update() + + CveImportacion = DdlImportaciones.SelectedValue.ToEntero + CveFlete = DdlFletes.SelectedValue.ToEntero + FleteImportacionOpcion = RblFleteImportacionOpcion.SelectedValue.ToEntero + CveConceptoContableAlmacen = DdlFleteImportacion.SelectedValue.ToEntero + + + If CveCompra > 0 AndAlso (CveImportacion > 0 Or CveFlete > 0) Then + Dim ObjCompras As New ClsCompras + Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL) + Dim ObjInventario As New ClsInventarios(ObjCompras.IniciaTransacSQL) + Dim ErrorTrans As Boolean = False + + Select Case CveConceptoContableAlmacen + Case 237 + Select Case FleteImportacionOpcion + Case 1 + Dim Dr As DataRow = Nothing + If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + Dr = ObjInventario.DtResultados.Rows(0) + End If + End If + If Dr IsNot Nothing Then + If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then + ErrorTrans = True + End If + Else + ErrorTrans = True + End If + Case 2 + If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then + ErrorTrans = True + End If + 'actualiza la compra para que no se surta en almacen. sino por el flete o importación + If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then + ErrorTrans = True + End If + End Select + Case 240 + Select Case FleteImportacionOpcion + Case 1 + If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then + ErrorTrans = True + End If + Case 2 + If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then + ErrorTrans = True + End If + 'actualiza la compra para que no se surta en almacen. sino por el flete o importación + If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then + ErrorTrans = True + End If + End Select + End Select + + 'Removemos los conceptos de la prepoliza + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then ErrorTrans = False 'GASTO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then ErrorTrans = False 'ALMACEN + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) Then ErrorTrans = False 'AF + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 205, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 230, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 231, CveCompra, 1) Then ErrorTrans = False 'PS YA RECIBIDO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 176, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 228, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 229, CveCompra, 1) Then ErrorTrans = False 'PS NO RECIBIDO + + Dim ConceptoContabilizacion As Integer = CveConceptoContableAlmacen + Dim ConceptoContabilizacionME As Integer = -1 + Dim ConceptoContabilizacionMEComp As Integer = -1 + Dim importeMovimiento As Decimal = 0 + Dim importeMN As Decimal = 0 + Dim IdCtaContable As Integer = -1 + Dim IdCtaContableME As Integer = -1 + Dim IdCtaContableMEComp As Integer = -1 + Dim tipoCambioActual As Decimal = 0 + Dim Multiplicador = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) + + If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then + tipoCambioActual = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString.ToDecimal + tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual) + Else + tipoCambioActual = 1 + End If + + Select Case ConceptoContabilizacion + Case 237 + ConceptoContabilizacionME = 238 + ConceptoContabilizacionMEComp = 239 + importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) + importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO + Case 240 + ConceptoContabilizacionME = 241 + ConceptoContabilizacionMEComp = 242 + importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")) + importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO + End Select + + If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + + If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + + If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero + End If + Dim Concepto As String = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If DdlMoneda.SelectedValue.ToEntero <> 1 Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Concepto, ConceptoContabilizacionME, Concepto, TxtFecha.Text.ToDate, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Concepto, ConceptoContabilizacionMEComp, Concepto, TxtFecha.Text.ToDate, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then + ErrorTrans = True + End If + Else + ErrorTrans = True + End If + Else + + If importeMN <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN, Concepto, ConceptoContabilizacion, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then + ErrorTrans = True + End If + End If + + If Not ErrorTrans Then + ObjCompras.Commit() + Else + ObjCompras.RollBack() + End If + ObjCompras.Dispose() + ObjConta.Dispose() + ObjInventario.Dispose() + + End If + + + RegistraScript("$('#ModalFletesImportaciones').modal('hide')") + End Sub + + Private Sub CargaModalFletesImportaciones() + + TxtFechaModalImportacionesFletes.Text = Now.ToShortDateString + TxtDescripcionModalFletesImportacion.Text = "" + TxtPedimento.Text = "" + RblTipo.SelectedValue = "1" + RblFleteImportacionOpcion.SelectedValue = "1" + CargaCombosFletesImportaciones() + CambiaTipo() + DdlFletes.SelectedValueExist(CveFlete) + DdlImportaciones.SelectedValueExist(CveImportacion) + If FleteImportacionOpcion > 0 Then RblFleteImportacionOpcion.SelectedValue = FleteImportacionOpcion.ToString + RegistraScript("$('#ModalFletesImportaciones').modal()") + UpModalFletesImportaciones.Update() + End Sub + Protected Sub RblTipo_SelectedIndexChanged(sender As Object, e As EventArgs) + CambiaTipo() + UpModalFletesImportaciones.Update() + End Sub + + Private Sub CambiaTipo() + Select Case RblTipo.SelectedValue.ToEntero + Case 1 + DivVinculacion.Visible = True + DivCrear.Visible = False + Select Case DdlFleteImportacion.SelectedValue.ToEntero + Case 237 + LblTitulo.Text = "Costo Indirecto" + DivFletes.Visible = True + DivImportaciones.Visible = False + Case 240 + LblTitulo.Text = "Importación" + DivFletes.Visible = False + DivImportaciones.Visible = True + End Select + Case 2 + DivVinculacion.Visible = False + DivCrear.Visible = True + Select Case DdlFleteImportacion.SelectedValue.ToEntero + Case 237 + LblTitulo.Text = "Costo Indirecto" + DivLblFolio.Visible = True + DivPedimento.Visible = False + CargaFolio() + Case 240 + LblTitulo.Text = "Importación" + DivLblFolio.Visible = False + DivPedimento.Visible = True + End Select + End Select + End Sub + Protected Sub BtnCrearFleteImportacion_Click(sender As Object, e As EventArgs) + Dim CveFlete As Integer = 0 + Dim CveImportacion As Integer = 0 + Select Case DdlFleteImportacion.SelectedValue.ToEntero + Case 237 + Dim ObjInv As New ClsInventarios + If ObjInv.AddFlete(LblFolioModalFletes.Text, TxtDescripcionModalFletesImportacion.Text.Trim, TxtFechaModalImportacionesFletes.Text.ToDate, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + CveFlete = ObjInv.CveFlete + Alert("Costo indirecto creado correctamente") + End If + ObjInv.Dispose() + Case 240 + Dim ObjCompras As New ClsCompras + CveImportacion = ObjCompras.AddImportacion(TxtPedimento.Text.Trim, TxtDescripcionModalFletesImportacion.Text.Trim, CveProveedor, -1, TxtFechaModalImportacionesFletes.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + ObjCompras.Dispose() + If CveImportacion > 0 Then Alert("Importación creada correctamente") + End Select + If CveFlete > 0 Or CveImportacion > 0 Then + RblTipo.SelectedValue = "1" + CambiaTipo() + CargaCombosFletesImportaciones() + Select Case DdlFleteImportacion.SelectedValue.ToEntero + Case 237 + DdlFletes.SelectedValueExist(CveFlete) + Case 240 + DdlImportaciones.SelectedValueExist(CveImportacion) + End Select + TxtFechaModalImportacionesFletes.Text = Now.ToShortDateString + TxtDescripcionModalFletesImportacion.Text = "" + TxtPedimento.Text = "" + UpModalFletesImportaciones.Update() + End If + End Sub + + Private Sub CargaCombosFletesImportaciones() + DdlFletes.Items.Clear() + DdlImportaciones.Items.Clear() + + Dim ObjCompras As New ClsCompras + If ObjCompras.GetImportaciones(-1, -1, -1, "-1", "-1", UsuarioActual.CveEmpresa) Then + DdlImportaciones.DataSource = ObjCompras.DtResultados + DdlImportaciones.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + ObjCompras.Dispose() + + Dim ObjInv As New ClsInventarios + If ObjInv.GetFletes(UsuarioActual.CveEmpresa) Then + DdlFletes.DataSource = ObjInv.DtResultados + DdlFletes.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + ObjInv.Dispose() + + DdlImportaciones.DataBind() + DdlFletes.DataBind() + + End Sub + + Private Sub LnkFletesImportaciones_Click(sender As Object, e As EventArgs) Handles LnkFletesImportaciones.Click + CargaModalFletesImportaciones() + End Sub + + + Protected Sub DdlFleteImportacion_SelectedIndexChanged1(sender As Object, e As EventArgs) + CambiaTipo() + UpModalFletesImportaciones.Update() + End Sub + +#End Region + + Private Function AjustarPrePolizaVinculacionOC(ByRef OC As ClsOC, ByRef OCBitacora As ClsOIEventos, ByRef ObjInventarios As ClsInventarios, ByRef ObjConta As ClsContabilidad, ByRef ObjAC As ClsContPAQi) As Boolean + + 'VARIABLES + Dim CveProveedorSucursal As Integer = -1 + Dim CveProveedorContacto As Integer = -1 + Dim Retorno As Boolean = True + Dim CveProveedor As Integer = -1 + Dim GeneraReq = False + Dim IDPoliza As Integer = 0 + + + 'EMPIEZA OBJETOS Y TRANSACCIONES + 'Dim OC As New ClsOC + 'Dim OCBitacora As New ClsOIEventos(OC.IniciaTransacSQL()) + 'Dim ObjInventarios As New ClsInventarios(OC.IniciaTransacSQL()) + 'Dim ObjConta As New ClsContabilidad(OC.IniciaTransacSQL()) + + + + Dim DtInvOC As New DataTable + Dim DtInvOCDiferencias As New DataTable 'Actualizado con diferencia + DtInvOCDiferencias.Columns.Add("CveOrdenCompra", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("Diferencia", GetType(Decimal)) + DtInvOCDiferencias.Columns.Add("PUCompra", GetType(Decimal)) + DtInvOCDiferencias.Columns.Add("CveMoneda", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("FolioOC", GetType(String)) + DtInvOCDiferencias.Columns.Add("CveProveedor", GetType(Integer)) + 'DtInvOCDiferencias.Columns.Add("ImporteMovto", GetType(Double)) + 'DtInvOCDiferencias.Columns.Add("ImporteMovtoDLLS", GetType(Double)) + DtInvOCDiferencias.Columns.Add("CveAlmacen", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("CveMovimiento", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("FolioAlmacen", GetType(String)) + DtInvOCDiferencias.Columns.Add("TipoCambioAjuste", GetType(Double)) + DtInvOCDiferencias.Columns.Add("ConceptoSalida", GetType(Integer)) + DtInvOCDiferencias.Columns.Add("PS", GetType(String)) + + + Dim dr2 As DataRow + For Each gvr As GridViewRow In GvOC1.Rows + If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then + dr2 = DTOCGV.Rows(gvr.RowIndex) + + Dim diferencia As Decimal = (dr2("PU").ToString.ToDecimal - gvr.FCTextBox("TxtPU").Text.ToDecimal) * gvr.FCTextBox("TxtCantidad").Text.ToDecimal + + Dim DrInvOCDiferencias As DataRow + If diferencia <> 0 Then 'And DtInvOC.Rows.Count > 0 + DrInvOCDiferencias = DtInvOCDiferencias.NewRow + DrInvOCDiferencias("CveOrdenCompra") = dr2("CveOrdenCompra").ToString.ToEntero + DrInvOCDiferencias("CveOrdenCompraDetalle") = dr2("CveOrdenCompraDetalle").ToString.ToEntero + DrInvOCDiferencias("Diferencia") = diferencia.RoundSQL() + DrInvOCDiferencias("PUCompra") = Math.Round(gvr.FCTextBox("TxtPU").Text.ToDecimal, 6) + DrInvOCDiferencias("CveMoneda") = dr2("CveMoneda").ToString.ToEntero + DrInvOCDiferencias("FolioOC") = dr2("FolioOC").ToString + DrInvOCDiferencias("CveProveedor") = dr2("CveProveedorOC").ToString.ToEntero + DrInvOCDiferencias("PS") = dr2("PS").ToString + DrInvOCDiferencias("FolioAlmacen") = dr2("FolioAlmacen").ToString + + If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(205) Then + DrInvOCDiferencias("TipoCambioAjuste") = 0 + DrInvOCDiferencias("CveAlmacen") = 0 + DrInvOCDiferencias("CveMovimiento") = 0 + DrInvOCDiferencias("ConceptoSalida") = 0 + DtInvOCDiferencias.Rows.Add(DrInvOCDiferencias) + Else + If ObjInventarios.GetMovimientosOC(dr2("CveOrdenCompra").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + DtInvOC = ObjInventarios.DtResultados.FiltraParametros($"CvePS > 0 AND CveOrdenCompraDetalle = {dr2("CveOrdenCompraDetalle").ToString.ToEntero}").Copy + End If + Dim drInv As DataRow = DtInvOC.FiltroPrimero("") If drInv IsNot Nothing Then 'sino existe no hay problema, porque puede ser le producto un servicio DrInvOCDiferencias("TipoCambioAjuste") = drInv("TipoCambioAjuste").ToString.ToDecimal DrInvOCDiferencias("Diferencia") = ((gvr.FCTextBox("TxtPU").Text.ToDecimal * drInv("TipoCambioAjuste").ToString.ToDecimal) - drInv("PU").ToString.ToDecimal) * gvr.FCTextBox("TxtCantidad").Text.ToDecimal 'diferencia * drInv("TipoCambioAjuste").ToString.ToDecimal ' @@ -19036,118 +19050,118 @@ Partial Class Compras_Compras End If End If - End If - Next - - If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(205) Then - If DtInvOCDiferencias.Rows.Count > 0 Then - For Each DrDiferencias As DataRow In DtInvOCDiferencias.Rows - Dim CveOrdenCompra As Integer = DrDiferencias("CveOrdenCompra").ToString.ToEntero - Dim CveOCDetalle As Integer = DrDiferencias("CveOrdenCompraDetalle").ToString.ToEntero - Dim PUCompra As Decimal = DrDiferencias("PUCompra").ToString.ToDecimal - Dim DiferenciaInvOC As Decimal = DrDiferencias("Diferencia").ToString.ToDecimal - If DiferenciaInvOC.RoundSQL() <> 0 Then - If Not OC.UpdateOrdenCompraDetalleAjuste(CveOrdenCompra, CveOCDetalle, PUCompra) Then - Retorno = False - Exit For - End If - End If - Next - End If - Else - 'PREPOLIZA DE AJUSTE ALMACEN POR ADELANTADO - If DtInvOCDiferencias.Rows.Count > 0 Then - - 'VARIABLES - Dim CveOrdenCompra = -1 - Dim DiferenciaInvOC = 0.0D - Dim CveMovimientoAlmacen = -1 - Dim CveOCDetalle = -1 - Dim CveAlmacen = -1 - Dim IdCtaContableAlmacen As Integer = -1 - Dim CveCuentaAlmacen As Integer = -1 - Dim IdCtaContableRecepcionOC = -1 - Dim IdCtaContableRecepcionOCME = -1 - Dim IdCtaContableRecepcionOCComplementaria = -1 - Dim IdCtaContableRecepcionOCER = -1 - Dim IdCtaContableRecepcionOCERME = -1 - Dim IdCtaContableRecepcionOCERComplementaria = -1 - Dim Fecha As Date = Now - Dim CveProveedorInvOC As Integer = -1 - Dim ProveedorNombre As String = "" - Dim SerieFolio As String = "" - Dim CvePrePoliza As Integer = -1 - Dim ConceptoSalida = -1 - Dim TCInvOC = 0.0D - Dim ImporteME = 0.0D - Dim ImporteMEComp = 0.0D - Dim SumatoriaMN = 0.0D - Dim SumatoriaME = 0.0D - Dim SumatoriaMEComp = 0.0D - Dim PUCompra = 0.0D - Dim CveMoneda As Integer = 1 - Dim PS As String = "" - - If ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOC = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If ObjConta.GetRetCuenta(228, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOCME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If ObjConta.GetRetCuenta(229, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOCComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If ObjConta.GetRetCuenta(177, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOCER = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If ObjConta.GetRetCuenta(232, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOCERME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If ObjConta.GetRetCuenta(233, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableRecepcionOCERComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - 'AJUSTES EN PREPOLIZA - SALIDA CONTABLE (CON SALIDA DE VENTA O SIN SALIDA) - For Each DrDiferencias As DataRow In DtInvOCDiferencias.FiltraParametros("ConceptoSalida IN (0,1)").Rows - CveOrdenCompra = DrDiferencias("CveOrdenCompra").ToString.ToEntero - CveOCDetalle = DrDiferencias("CveOrdenCompraDetalle").ToString.ToEntero - CveMoneda = DrDiferencias("CveMoneda").ToString.ToEntero - DiferenciaInvOC = DrDiferencias("Diferencia").ToString.ToDecimal.RoundSQL() - PUCompra = DrDiferencias("PUCompra").ToString.ToDecimal - PS = DrDiferencias("PS").ToString - - Fecha = Now - SerieFolio = $"OC: {DrDiferencias("FolioOC").ToString}" - CveProveedor = DrDiferencias("CveProveedor").ToString.ToEntero - ProveedorNombre = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", $"CveProveedor = {CveProveedor}").ToString - Dim ConceptoPartida As String = String.Format("{0} OC: {1} Inv: {2}", ProveedorNombre, DrDiferencias("FolioOC"), DrDiferencias("FolioAlmacen")) - - ConceptoSalida = DrDiferencias("ConceptoSalida").ToString.ToEntero - CveAlmacen = DrDiferencias("CveAlmacen").ToString.ToEntero - CveMovimientoAlmacen = DrDiferencias("CveMovimiento").ToString.ToEntero - TCInvOC = DrDiferencias("TipoCambioAjuste").ToString.ToDecimal - - IdCtaContableAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero - CveCuentaAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero - + End If + Next + + If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(205) Then + If DtInvOCDiferencias.Rows.Count > 0 Then + For Each DrDiferencias As DataRow In DtInvOCDiferencias.Rows + Dim CveOrdenCompra As Integer = DrDiferencias("CveOrdenCompra").ToString.ToEntero + Dim CveOCDetalle As Integer = DrDiferencias("CveOrdenCompraDetalle").ToString.ToEntero + Dim PUCompra As Decimal = DrDiferencias("PUCompra").ToString.ToDecimal + Dim DiferenciaInvOC As Decimal = DrDiferencias("Diferencia").ToString.ToDecimal + If DiferenciaInvOC.RoundSQL() <> 0 Then + If Not OC.UpdateOrdenCompraDetalleAjuste(CveOrdenCompra, CveOCDetalle, PUCompra) Then + Retorno = False + Exit For + End If + End If + Next + End If + Else + 'PREPOLIZA DE AJUSTE ALMACEN POR ADELANTADO + If DtInvOCDiferencias.Rows.Count > 0 Then + + 'VARIABLES + Dim CveOrdenCompra = -1 + Dim DiferenciaInvOC = 0.0D + Dim CveMovimientoAlmacen = -1 + Dim CveOCDetalle = -1 + Dim CveAlmacen = -1 + Dim IdCtaContableAlmacen As Integer = -1 + Dim CveCuentaAlmacen As Integer = -1 + Dim IdCtaContableRecepcionOC = -1 + Dim IdCtaContableRecepcionOCME = -1 + Dim IdCtaContableRecepcionOCComplementaria = -1 + Dim IdCtaContableRecepcionOCER = -1 + Dim IdCtaContableRecepcionOCERME = -1 + Dim IdCtaContableRecepcionOCERComplementaria = -1 + Dim Fecha As Date = Now + Dim CveProveedorInvOC As Integer = -1 + Dim ProveedorNombre As String = "" + Dim SerieFolio As String = "" + Dim CvePrePoliza As Integer = -1 + Dim ConceptoSalida = -1 + Dim TCInvOC = 0.0D + Dim ImporteME = 0.0D + Dim ImporteMEComp = 0.0D + Dim SumatoriaMN = 0.0D + Dim SumatoriaME = 0.0D + Dim SumatoriaMEComp = 0.0D + Dim PUCompra = 0.0D + Dim CveMoneda As Integer = 1 + Dim PS As String = "" + + If ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOC = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If ObjConta.GetRetCuenta(228, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOCME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If ObjConta.GetRetCuenta(229, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOCComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If ObjConta.GetRetCuenta(177, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOCER = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If ObjConta.GetRetCuenta(232, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOCERME = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If ObjConta.GetRetCuenta(233, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableRecepcionOCERComplementaria = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + 'AJUSTES EN PREPOLIZA - SALIDA CONTABLE (CON SALIDA DE VENTA O SIN SALIDA) + For Each DrDiferencias As DataRow In DtInvOCDiferencias.FiltraParametros("ConceptoSalida IN (0,1)").Rows + CveOrdenCompra = DrDiferencias("CveOrdenCompra").ToString.ToEntero + CveOCDetalle = DrDiferencias("CveOrdenCompraDetalle").ToString.ToEntero + CveMoneda = DrDiferencias("CveMoneda").ToString.ToEntero + DiferenciaInvOC = DrDiferencias("Diferencia").ToString.ToDecimal.RoundSQL() + PUCompra = DrDiferencias("PUCompra").ToString.ToDecimal + PS = DrDiferencias("PS").ToString + + Fecha = Now + SerieFolio = $"OC: {DrDiferencias("FolioOC").ToString}" + CveProveedor = DrDiferencias("CveProveedor").ToString.ToEntero + ProveedorNombre = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", $"CveProveedor = {CveProveedor}").ToString + Dim ConceptoPartida As String = String.Format("{0} OC: {1} Inv: {2}", ProveedorNombre, DrDiferencias("FolioOC"), DrDiferencias("FolioAlmacen")) + + ConceptoSalida = DrDiferencias("ConceptoSalida").ToString.ToEntero + CveAlmacen = DrDiferencias("CveAlmacen").ToString.ToEntero + CveMovimientoAlmacen = DrDiferencias("CveMovimiento").ToString.ToEntero + TCInvOC = DrDiferencias("TipoCambioAjuste").ToString.ToDecimal + + IdCtaContableAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero + CveCuentaAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DrDiferencias("CveAlmacen").ToString.ToEntero}").ToEntero + Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero Dim IdCtaContable69 As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero '' CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero - If DiferenciaInvOC.RoundSQL() <> 0 Then - CvePrePoliza = ObjConta.AddPrePolizas("Compras/OC-(OCAlmacen)", 74, DiferenciaInvOC, DiferenciaInvOC, 1, Fecha, ConceptoPartida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePoliza > 0 Then - - If CveMoneda = 2 And UsuarioActual.CveEmpresa.Contiene(119) Then - ImporteME = (DiferenciaInvOC / TCInvOC).RoundSQL() - ImporteMEComp = ((ImporteME * TCInvOC) - ImporteME).RoundSQL() - + If DiferenciaInvOC.RoundSQL() <> 0 Then + CvePrePoliza = ObjConta.AddPrePolizas("Compras/OC-(OCAlmacen)", 74, DiferenciaInvOC, DiferenciaInvOC, 1, Fecha, ConceptoPartida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePoliza > 0 Then + + If CveMoneda = 2 And UsuarioActual.CveEmpresa.Contiene(119) Then + ImporteME = (DiferenciaInvOC / TCInvOC).RoundSQL() + ImporteMEComp = ((ImporteME * TCInvOC) - ImporteME).RoundSQL() + Dim DifImporte As Decimal = DiferenciaInvOC - (ImporteME + ImporteMEComp) @@ -19172,234 +19186,234 @@ Partial Class Compras_Compras End If Else '2018.11.24 se cambia concepto 177, de cargo a abono negativo., petición MALL - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), ConceptoPartida, Fecha, If(ConceptoSalida = 0, IdCtaContableAlmacen, IdCtaContableRecepcionOCER), -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveCuenta:=CveCuentaAlmacen, CveOCDetalle:=CveOCDetalle) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaInvOC, SerieFolio, 176, ConceptoPartida, Fecha, IdCtaContableRecepcionOC, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DiferenciaInvOC, CveOCDetalle:=CveOCDetalle) Then - Retorno = False - Exit For - End If - Else - Retorno = False - Exit For - End If - End If - If Not OC.UpdateOrdenCompraDetalleAjuste(CveOrdenCompra, CveOCDetalle, PUCompra) Then - Retorno = False - Exit For - End If - - If Retorno Then - - If Not OCBitacora.AddEventoBitacora(String.Format("Se registró una póliza de ajuste por cambio de precio en producto: {0}", PS), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveOC:=CveOrdenCompra) Then - Retorno = False - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ObjAC IsNot Nothing Then - If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then - Retorno = False - End If - End If - End If - End If - Next - - - End If - End If - - - Return Retorno + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -DiferenciaInvOC, SerieFolio, If(ConceptoSalida = 0, 177, 177), ConceptoPartida, Fecha, If(ConceptoSalida = 0, IdCtaContableAlmacen, IdCtaContableRecepcionOCER), -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=-DiferenciaInvOC, CveCuenta:=CveCuentaAlmacen, CveOCDetalle:=CveOCDetalle) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaInvOC, SerieFolio, 176, ConceptoPartida, Fecha, IdCtaContableRecepcionOC, -1, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimientoAlmacen, CveOC:=CveOrdenCompra, ImporteMX:=DiferenciaInvOC, CveOCDetalle:=CveOCDetalle) Then + Retorno = False + Exit For + End If + Else + Retorno = False + Exit For + End If + End If + If Not OC.UpdateOrdenCompraDetalleAjuste(CveOrdenCompra, CveOCDetalle, PUCompra) Then + Retorno = False + Exit For + End If + + If Retorno Then + + If Not OCBitacora.AddEventoBitacora(String.Format("Se registró una póliza de ajuste por cambio de precio en producto: {0}", PS), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveOC:=CveOrdenCompra) Then + Retorno = False + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ObjAC IsNot Nothing Then + If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then + Retorno = False + End If + End If + End If + End If + Next + + + End If + End If + + + Return Retorno End Function -#Region "A G R E G A R - P R O D U C T O S S E R V I C I O S" - Private Sub CargaDatosAgregarPS() - DdlClasificacionPS.Items.Clear() - If UsuarioActual.Empresa.UsaAC Then - DdlClasificacionPS.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, -1, -1)).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - Else - DdlClasificacionPS.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, -1, -1)).FiltraParametros("", Orderby:="Clasificacion") - End If - DdlClasificacionPS.DataBind() - DdlClasificacionPS.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlUnidadMedida.Items.Clear() - DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - DdlUnidadMedida.DataBind() - - End Sub - - Protected Sub BtnAgregarPSNuevo_Click(sender As Object, e As EventArgs) - - Dim PS As New Modelos.MProductoServicio() - PS.Codigo = TxtCodigoPS.Text - PS.PS = TxtPS.Text - PS.CveUnidadMedida = DdlUnidadMedida.SelectedValue.ToEntero() - PS.CveClasificacion = DdlClasificacionPS.SelectedValue.ToEntero() - PS.CveTipoPS = DdlTipoPS.SelectedValue.ToEntero() - PS.AplicaParaVenta = True - PS.CveUsuario = UsuarioActual.CveUsuario - PS.CveEmpresa = UsuarioActual.CveEmpresa - - Dim ObjPS As New ClsProductosServicios - If ObjPS.AddPSSimplificado(PS) > 0 Then - Alert("El P/S fue agregado correctamente.") - GeneraGlobalDT(Nothing) - End If - ObjPS.Dispose() - - TxtPS.Text = "" - TxtCodigoPS.Text = "" - DdlUnidadMedida.SelectedValueExist(-1) - DdlClasificacionPS.SelectedValueExist(-1) - DdlTipoPS.SelectedValueExist(-1) - - UpAgregarPS.Update() - +#Region "A G R E G A R - P R O D U C T O S S E R V I C I O S" + Private Sub CargaDatosAgregarPS() + DdlClasificacionPS.Items.Clear() + If UsuarioActual.Empresa.UsaAC Then + DdlClasificacionPS.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, -1, -1)).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + Else + DdlClasificacionPS.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, -1, -1)).FiltraParametros("", Orderby:="Clasificacion") + End If + DdlClasificacionPS.DataBind() + DdlClasificacionPS.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlUnidadMedida.Items.Clear() + DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUnidadMedida.DataBind() + + End Sub + + Protected Sub BtnAgregarPSNuevo_Click(sender As Object, e As EventArgs) + + Dim PS As New Modelos.MProductoServicio() + PS.Codigo = TxtCodigoPS.Text + PS.PS = TxtPS.Text + PS.CveUnidadMedida = DdlUnidadMedida.SelectedValue.ToEntero() + PS.CveClasificacion = DdlClasificacionPS.SelectedValue.ToEntero() + PS.CveTipoPS = DdlTipoPS.SelectedValue.ToEntero() + PS.AplicaParaVenta = True + PS.CveUsuario = UsuarioActual.CveUsuario + PS.CveEmpresa = UsuarioActual.CveEmpresa + + Dim ObjPS As New ClsProductosServicios + If ObjPS.AddPSSimplificado(PS) > 0 Then + Alert("El P/S fue agregado correctamente.") + GeneraGlobalDT(Nothing) + End If + ObjPS.Dispose() + + TxtPS.Text = "" + TxtCodigoPS.Text = "" + DdlUnidadMedida.SelectedValueExist(-1) + DdlClasificacionPS.SelectedValueExist(-1) + DdlTipoPS.SelectedValueExist(-1) + + UpAgregarPS.Update() + RegistraScript("$('#DivAgregarPS').modal('hide');") End Sub -#End Region +#End Region -#Region "TIPO DE COMPRA" +#Region "TIPO DE COMPRA" + + Protected Sub DdlTipoCompra_SelectedIndexChanged(sender As Object, e As EventArgs) - Protected Sub DdlTipoCompra_SelectedIndexChanged(sender As Object, e As EventArgs) - End Sub -#End Region +#End Region - Protected Sub BtnFacturaNC_Click(sender As Object, e As EventArgs) - If ChkNCInvNC.Checked Then - CargaNCINV() - Else - RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC") - End If + Protected Sub BtnFacturaNC_Click(sender As Object, e As EventArgs) + If ChkNCInvNC.Checked Then + CargaNCINV() + Else + RegistraScript("$('#FacturaNC').modal('hide');", "FacturaNC") + End If End Sub -#Region "ES NO DEDUCIBLE" - Protected Sub ChkEsNoDeducible_CheckedChanged1(sender As Object, e As EventArgs) - If ChkEsNoDeducible.Checked Then - EsNoDeducible = True - dvNoDeducible.Visible = True - GvPS.Columns(10).Visible = True - UpEsNoDeduciblePS.Visible = True - Else - EsNoDeducible = False - dvNoDeducible.Visible = False - GvPS.Columns(10).Visible = False - UpEsNoDeduciblePS.Visible = False - End If - 'DivEsNoDeducible.Visible = False - 'For Each Dr As DataRow In TmpDT.Rows - ' Dim Total As Double = Dr("IVA").ToString.ToDouble - (Dr("RetIVA").ToString.ToDouble + Dr("RetISR").ToString.ToDouble) + Dr("IEPSPS").ToString.ToDouble + Dr("IEPSPSIVA").ToString.ToDouble - ' Dr("Total") = Dr("Total").ToString.ToDouble + Total - ' Dr("PU") = Dr("Total").ToString.ToDouble / Dr("Cantidad").ToString.ToDouble - ' Dr("IVA") = 0 - ' Dr("IVAPorcentaje") = 0 - ' Dr("RetIVA") = 0 - ' Dr("RetIVAPorcentaje") = 0 - ' Dr("RetISR") = 0 - ' Dr("RetISRPorcentaje") = 0 - ' Dr("IEPSPS") = 0 - ' Dr("IEPSPSPorcentaje") = 0 - ' Dr("IEPSPSIVA") = 0 - ' Dr("IEPSPSIVAPorcentaje") = 0 - 'Next - 'TmpDT.AcceptChanges() - AddPS2(EsNoDeducible:=EsNoDeducible) - UpPS.Update() +#Region "ES NO DEDUCIBLE" + Protected Sub ChkEsNoDeducible_CheckedChanged1(sender As Object, e As EventArgs) + If ChkEsNoDeducible.Checked Then + EsNoDeducible = True + dvNoDeducible.Visible = True + GvPS.Columns(10).Visible = True + UpEsNoDeduciblePS.Visible = True + Else + EsNoDeducible = False + dvNoDeducible.Visible = False + GvPS.Columns(10).Visible = False + UpEsNoDeduciblePS.Visible = False + End If + 'DivEsNoDeducible.Visible = False + 'For Each Dr As DataRow In TmpDT.Rows + ' Dim Total As Double = Dr("IVA").ToString.ToDouble - (Dr("RetIVA").ToString.ToDouble + Dr("RetISR").ToString.ToDouble) + Dr("IEPSPS").ToString.ToDouble + Dr("IEPSPSIVA").ToString.ToDouble + ' Dr("Total") = Dr("Total").ToString.ToDouble + Total + ' Dr("PU") = Dr("Total").ToString.ToDouble / Dr("Cantidad").ToString.ToDouble + ' Dr("IVA") = 0 + ' Dr("IVAPorcentaje") = 0 + ' Dr("RetIVA") = 0 + ' Dr("RetIVAPorcentaje") = 0 + ' Dr("RetISR") = 0 + ' Dr("RetISRPorcentaje") = 0 + ' Dr("IEPSPS") = 0 + ' Dr("IEPSPSPorcentaje") = 0 + ' Dr("IEPSPSIVA") = 0 + ' Dr("IEPSPSIVAPorcentaje") = 0 + 'Next + 'TmpDT.AcceptChanges() + AddPS2(EsNoDeducible:=EsNoDeducible) + UpPS.Update() End Sub -#End Region +#End Region - Public Sub LnkDesVincularComplemento_Click(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim CveFacturaComplemento As Integer = GvRow.DataKey("CveFactura").ToEntero - - Dim ObjCompra As New ClsCompras - - If ObjCompra.RemoveComplementoPagoDesVincular(CveFacturaComplemento, UsuarioActual.CveEmpresa) Then - RegistraScript("$('#ModalComplementoPagos').modal('hide');") - Alert("Complemento des vinculado correctamente.") - End If - ObjCompra.Dispose() - - End Sub - - - Protected Sub LnkCompleplementos_Click(sender As Object, e As EventArgs) - 'ModalComplementoPagos - - CargaComplementosPago() - RegistraScript("$('#ModalComplementoPagos').modal('show');") - - End Sub - Protected Sub ChkEsNoDeduciblePS_CheckedChanged(sender As Object, e As EventArgs) - - Dim Chk As CheckBox = CType(sender, CheckBox) - Dim gvr As GridViewRow = CType(Chk.BindingContainer, GridViewRow) - - For Each drt As DataRow In TmpDT.Select("Consec = " & gvr.RowIndex + 1) - drt("NoDeducible") = Chk.Checked - Next - - TmpDT.AcceptChanges() - Alert((TmpDT.Select("Consec = " & gvr.RowIndex + 1)(0))("NoDeducible").ToString()) - AddPS2(EsNoDeducible:=EsNoDeducible) - - End Sub - Protected Sub LnkUpdateFechaPago_Click(sender As Object, e As EventArgs) - Dim ObjComp As New ClsCompras - Dim FechaPagoAnterior As String = "" - - If ObjComp.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjComp.DtResultados.Rows.Count > 0 Then - FechaPagoAnterior = ObjComp.DtResultados.Rows(0)("FechaVencimiento").ToString.ToDate.ToShortDateString - End If - End If - - If FechaPagoAnterior = TxtFechaPago.Text Then - Alert("La fecha de pago seleccionada es igual que la anterior.", TipoMensaje.MsgAdvertencia) - ObjComp.Dispose() - Exit Sub - End If - - If ObjComp.UpdateFechaVencimientoCompra(CveCompra, TxtFechaPago.Text.ToDate, UsuarioActual.CveEmpresa) Then - Alert("Fecha de pago actualizada correctamente.") - End If - - ObjComp.Dispose() + Public Sub LnkDesVincularComplemento_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveFacturaComplemento As Integer = GvRow.DataKey("CveFactura").ToEntero + + Dim ObjCompra As New ClsCompras + + If ObjCompra.RemoveComplementoPagoDesVincular(CveFacturaComplemento, UsuarioActual.CveEmpresa) Then + RegistraScript("$('#ModalComplementoPagos').modal('hide');") + Alert("Complemento des vinculado correctamente.") + End If + ObjCompra.Dispose() + + End Sub + + + Protected Sub LnkCompleplementos_Click(sender As Object, e As EventArgs) + 'ModalComplementoPagos + + CargaComplementosPago() + RegistraScript("$('#ModalComplementoPagos').modal('show');") + + End Sub + Protected Sub ChkEsNoDeduciblePS_CheckedChanged(sender As Object, e As EventArgs) + + Dim Chk As CheckBox = CType(sender, CheckBox) + Dim gvr As GridViewRow = CType(Chk.BindingContainer, GridViewRow) + + For Each drt As DataRow In TmpDT.Select("Consec = " & gvr.RowIndex + 1) + drt("NoDeducible") = Chk.Checked + Next + + TmpDT.AcceptChanges() + Alert((TmpDT.Select("Consec = " & gvr.RowIndex + 1)(0))("NoDeducible").ToString()) + AddPS2(EsNoDeducible:=EsNoDeducible) + + End Sub + Protected Sub LnkUpdateFechaPago_Click(sender As Object, e As EventArgs) + Dim ObjComp As New ClsCompras + Dim FechaPagoAnterior As String = "" + + If ObjComp.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjComp.DtResultados.Rows.Count > 0 Then + FechaPagoAnterior = ObjComp.DtResultados.Rows(0)("FechaVencimiento").ToString.ToDate.ToShortDateString + End If + End If + + If FechaPagoAnterior = TxtFechaPago.Text Then + Alert("La fecha de pago seleccionada es igual que la anterior.", TipoMensaje.MsgAdvertencia) + ObjComp.Dispose() + Exit Sub + End If + + If ObjComp.UpdateFechaVencimientoCompra(CveCompra, TxtFechaPago.Text.ToDate, UsuarioActual.CveEmpresa) Then + Alert("Fecha de pago actualizada correctamente.") + End If + + ObjComp.Dispose() End Sub Protected Sub btnpruebas_Click(sender As Object, e As EventArgs) - Dim GuardaNoDeducibles As Boolean = False - If ChkEsNoDeducible.Checked Then - For Each Row As DataRow In TmpDT.Rows - If Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1") Then - GuardaNoDeducibles = True - End If - - Next - If GuardaNoDeducibles = False Then - Alert("Si la compra es No Deducible, mínimo se debe registrar un producto No Deducible", TipoMensaje.MsgAdvertencia) + Dim GuardaNoDeducibles As Boolean = False + If ChkEsNoDeducible.Checked Then + For Each Row As DataRow In TmpDT.Rows + If Row("NoDeducible").ToString().ToUpper().Contiene("TRUE", "1") Then + GuardaNoDeducibles = True + End If + + Next + If GuardaNoDeducibles = False Then + Alert("Si la compra es No Deducible, mínimo se debe registrar un producto No Deducible", TipoMensaje.MsgAdvertencia) Exit Sub - Else - Alert("todo bien!", TipoMensaje.MsgInformacion) - - End If + Else + Alert("todo bien!", TipoMensaje.MsgInformacion) + + End If End If End Sub #Region "PAGAR CON DIFERENTE MONEDA" Protected Sub ChkPagarConPesos_CheckedChanged(sender As Object, e As EventArgs) CargaAnticipos(CveProveedor) - UpAnticipos.Update() + UpAnticipos.Update() End Sub Protected Sub ChkPagarConDolares_CheckedChanged(sender As Object, e As EventArgs) CargaAnticipos(CveProveedor) - UpAnticipos.Update() + UpAnticipos.Update() End Sub #End Region diff --git a/Compras/PopUpVerFactura.aspx b/Compras/PopUpVerFactura.aspx index 4270e8dce..5f063d646 100644 --- a/Compras/PopUpVerFactura.aspx +++ b/Compras/PopUpVerFactura.aspx @@ -12,7 +12,7 @@ - + diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index cef5c28f6..9ac0d338f 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2621,7 +2621,7 @@ Partial Class Inventarios_RecepcionUsados Private Sub CargaFolioAjuste() DdlFolioGarantia.Items.Clear() Dim ObjAcum As New ClsAcumuladores - If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa) Then + If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, Area:=2) Then DdlFolioGarantia.DataSource = ObjAcum.DtResultados DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1")) End If From 84a63520d21d30dfbf68ed8797b7371009c3ea2b Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Tue, 17 Mar 2020 17:47:58 -0700 Subject: [PATCH 04/24] kj --- GPS/Trayectos.aspx.vb | 2 +- vwd.webinfo | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GPS/Trayectos.aspx.vb b/GPS/Trayectos.aspx.vb index 8e0b5654e..55d9f0f9e 100644 --- a/GPS/Trayectos.aspx.vb +++ b/GPS/Trayectos.aspx.vb @@ -185,7 +185,7 @@ Partial Class GPS_Trayectos Try Dim CveTrayecto As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente, EnviarNotificacion:=ChkNotificacion.Checked, - CorreosNotificacion:=TxtCorreoNot.Text, Intervalo:=If(ChkNotificacion.Checked, 0, DdlIntervalo.SelectedValue.ToEntero()), + CorreosNotificacion:=TxtCorreoNot.Text, Intervalo:=If(ChkNotificacion.Checked, DdlIntervalo.SelectedValue.ToEntero(), 0), EnviarLiga:=ChkEnviarLiga.Checked) If CveTrayecto > 0 Then diff --git a/vwd.webinfo b/vwd.webinfo index a280964b8..93df9a232 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -21,6 +21,10 @@ + + + + From abc6952bce4701ddf502a8156b630a87ad47655a Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 17 Mar 2020 18:00:33 -0700 Subject: [PATCH 05/24] - tiempo de refrescar --- Inventarios/RecepcionAlmacen.aspx | 2 +- Inventarios/RecepcionEntrega.aspx | 2 +- vwd.webinfo | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Inventarios/RecepcionAlmacen.aspx b/Inventarios/RecepcionAlmacen.aspx index 0adad806e..0c9fa6b71 100644 --- a/Inventarios/RecepcionAlmacen.aspx +++ b/Inventarios/RecepcionAlmacen.aspx @@ -256,7 +256,7 @@ - + diff --git a/Inventarios/RecepcionEntrega.aspx b/Inventarios/RecepcionEntrega.aspx index e6bf45a69..a426c9852 100644 --- a/Inventarios/RecepcionEntrega.aspx +++ b/Inventarios/RecepcionEntrega.aspx @@ -283,7 +283,7 @@ - + diff --git a/vwd.webinfo b/vwd.webinfo index 93df9a232..3f67b239f 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -26,6 +26,8 @@ + + From b7256ba33b7e2a09dee426e8685621e237f98bd8 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Tue, 17 Mar 2020 18:17:43 -0700 Subject: [PATCH 06/24] last postaback en usuarios --- App_Code/ClsPaginas.vb | 4 +++- App_Code/Usuario.vb | 17 ++++++++++++++++- Sistemas/SessionesActivas.aspx | 12 +++++++++++- Sistemas/SessionesActivas.aspx.vb | 4 ++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 023ae689e..3e646964b 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -3502,7 +3502,9 @@ Public Class ClsPaginas End If If UsuarioActual.CveEmpresa = 42 Then Me.MasterPageFile = "~/Masters/Site42.master" - End If + End If + + ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.CambiarModulo, Nothing, -1, "", Request.Url.ToString()) 'If Me.Request.ServerVariables("http_user_agent").ToLower.Contains("safari") AndAlso Page.ClientTarget <> "uplevel" Then Page.ClientTarget = "uplevel" 'Código agregado para que muestre bién el menu, en chrome End If End Sub diff --git a/App_Code/Usuario.vb b/App_Code/Usuario.vb index 39b921fe9..11d6e8718 100644 --- a/App_Code/Usuario.vb +++ b/App_Code/Usuario.vb @@ -115,6 +115,7 @@ Namespace ADSSession getListasession = 3 'solo lectura CambiarEmpresa = 4 getSession = 5 + CambiarModulo = 6 End Enum Public Enum OpcionHub As Integer agregar = 1 @@ -158,7 +159,7 @@ Namespace ADSSession HttpContext.Current.Session(strsessionDpage) = value End Set End Property - Public Shared Function SessionManager(opcion As OpcionSession, Optional obj As ADSSessionObj = Nothing, Optional CveEmpresa As Integer = -1, Optional SessionID As String = Nothing) As Object + Public Shared Function SessionManager(opcion As OpcionSession, Optional obj As ADSSessionObj = Nothing, Optional CveEmpresa As Integer = -1, Optional SessionID As String = Nothing, Optional modulo As String = "") As Object SyncLock strsessionid 'todo el codigo que este dentro de este corchete no se ejecutara mas de una vez al mismo tiempo en el servidor If _dicSessionobj Is Nothing Then _dicSessionobj = New ConcurrentDictionary(Of String, ADSSessionObj) @@ -194,6 +195,18 @@ Namespace ADSSession obj.CveEmpresa = CveEmpresa End If retorno = obj + + Case OpcionSession.CambiarModulo + If Not IsNothing(HttpContext.Current) AndAlso Not IsNothing(HttpContext.Current.Session) AndAlso Not IsNothing(HttpContext.Current.Session(strsessionid)) Then + obj = DirectCast(HttpContext.Current.Session(strsessionid), ADSSessionObj) + obj.Modulo = modulo + obj.LastPostback = DateTime.Now + If _dicSessionobj.TryGetValue(obj.SessionID, obj) Then + obj.Modulo = modulo + obj.LastPostback = DateTime.Now + End If + retorno = obj + End If End Select Catch ex As Exception retorno = Nothing @@ -227,6 +240,8 @@ Namespace ADSSession End Sub Public Property CveUsuario As Integer Public Property CveEmpresa As Integer + Public Property Modulo As String + Public Property LastPostback As DateTime Protected Property _SessionID As String Private Property _ipAdrres As String Public ReadOnly Property IpAddres As String diff --git a/Sistemas/SessionesActivas.aspx b/Sistemas/SessionesActivas.aspx index 61e8ea10d..b8ba50c2f 100644 --- a/Sistemas/SessionesActivas.aspx +++ b/Sistemas/SessionesActivas.aspx @@ -67,7 +67,7 @@
- + @@ -75,6 +75,16 @@ + + + + + + + + + + diff --git a/Sistemas/SessionesActivas.aspx.vb b/Sistemas/SessionesActivas.aspx.vb index d75f57267..2139cef5a 100644 --- a/Sistemas/SessionesActivas.aspx.vb +++ b/Sistemas/SessionesActivas.aspx.vb @@ -33,6 +33,8 @@ Partial Class SessionesActivas Dim dtU As DataTable = objUsuarios.DtResultados dtU.Columns.Add("FechaSLogin", System.Type.GetType("System.DateTime")) dtU.Columns.Add("RemoteIpAddres", System.Type.GetType("System.String")) + dtU.Columns.Add("LastPostback", System.Type.GetType("System.DateTime")) + dtU.Columns.Add("Modulo", System.Type.GetType("System.String")) Dim dtF As DataTable = dtU.Clone Dim objlist As List(Of ADSSession.ADSSessionObj) = ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.getListasession) @@ -41,6 +43,8 @@ Partial Class SessionesActivas If Not IsNothing(row) Then row("FechaSLogin") = user.FechaLogin row("RemoteIpAddres") = user.IpAddres + row("LastPostback") = user.LastPostback + row("Modulo") = user.Modulo dtF.Rows.Add(row.ItemArray()) End If Next From a250b19a7f3d8b8c7230a9fdf0bb3b09ff9105a8 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 17 Mar 2020 20:10:14 -0700 Subject: [PATCH 07/24] -cambio en texto --- Compras/Compras.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 80d869dbf..497f49e32 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -18093,7 +18093,7 @@ Partial Class Compras_Compras RegistraScript("$('#ModalNCInv').modal('show');", "ModalNCInv") Else If ChkNCInvNC.Checked Then - Alert("Niguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia) + Alert("Ninguna de las facturas seleccionadas cuenta con productos pendientes de darles entrada.", TipoMensaje.MsgAdvertencia) ChkNCInvNC.Checked = False UpChkNCInvNC.Update() Exit Sub From 8d3f61263b6ab3c064b6e8dad5dcfb6ed02c1248 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Wed, 18 Mar 2020 13:22:49 -0700 Subject: [PATCH 08/24] --- App_Code/ClsPaginas.vb | 15 +++++++++++-- App_Code/ClsSisUsuarios.vb | 4 +++- App_Code/LogicNominas.vb | 1 + Sistemas/SessionesActivas.aspx | 2 +- Sistemas/SessionesActivas.aspx.vb | 37 +++++++++++++++++++++++++++++++ vwd.webinfo | 2 ++ 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 3e646964b..8e27bde3e 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -3421,7 +3421,11 @@ Public Class ClsPaginas pages.Add("/Compras/PopUpVerFactura.aspx") Return pages End Function - Protected Overridable Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.PreInit + Dim sw As Diagnostics.Stopwatch + Protected Overridable Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.PreInit + + sw = New Diagnostics.Stopwatch + sw.Start() If Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing Then Dim AuthorizeRequest As Boolean = False Dim HuboError = False @@ -4921,7 +4925,14 @@ Public Class ClsPaginas Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout) End If End Sub - Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender + Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender + If sw IsNot Nothing AndAlso Not (Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing) Then + + sw.Stop() + Using ObjUsuario As New ClsSisUsuarios + ObjUsuario.AddBitacora(CveModulo, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Request.Url.ToString(), sw.ElapsedMilliseconds) + End Using + End If If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro") ViewState("strToastMsglargonoreplace") = Nothing diff --git a/App_Code/ClsSisUsuarios.vb b/App_Code/ClsSisUsuarios.vb index 2b70e5370..5781c70cf 100644 --- a/App_Code/ClsSisUsuarios.vb +++ b/App_Code/ClsSisUsuarios.vb @@ -891,7 +891,7 @@ Public Class ClsSisUsuarios Return Retorno End Function - Public Function AddBitacora(CveModulo As Integer, Accion As String, Resultado As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function AddBitacora(CveModulo As Integer, Accion As String, Resultado As String, CveUsuario As Integer, CveEmpresa As Integer, Optional URL As String = "-1", Optional TiempodeEjecucion As Long = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Sis_UsuariosBitacoraAdd") @@ -901,6 +901,8 @@ Public Class ClsSisUsuarios .Add("@Resultado", SqlDbType.VarChar).Value = Resultado .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@URL", SqlDbType.VarChar).Value = URL + .Add("@TiempodeEjecucion", SqlDbType.BigInt).Value = TiempodeEjecucion End With Try diff --git a/App_Code/LogicNominas.vb b/App_Code/LogicNominas.vb index c27ade4b3..542714a52 100644 --- a/App_Code/LogicNominas.vb +++ b/App_Code/LogicNominas.vb @@ -17,6 +17,7 @@ Public Class LogicNominas Dim sw As Diagnostics.Stopwatch = Nothing If guardarLogTimbrado Then sw = New Diagnostics.Stopwatch + sw.Start() End If Dim cfdi As CFDITimbre = PreTimbrar(CveNomina, UsuarioActual) 'CvePersonal, CvePeriodo, diff --git a/Sistemas/SessionesActivas.aspx b/Sistemas/SessionesActivas.aspx index b8ba50c2f..a4fe89c50 100644 --- a/Sistemas/SessionesActivas.aspx +++ b/Sistemas/SessionesActivas.aspx @@ -82,7 +82,7 @@ - + diff --git a/Sistemas/SessionesActivas.aspx.vb b/Sistemas/SessionesActivas.aspx.vb index 2139cef5a..81abedfe0 100644 --- a/Sistemas/SessionesActivas.aspx.vb +++ b/Sistemas/SessionesActivas.aspx.vb @@ -14,9 +14,46 @@ Partial Class SessionesActivas ViewState("RCveUsuario") = value End Set End Property + + ReadOnly Property UsuarioActual() As Usuario + Get + Try + 'UsuarioActual = DirectCast(Session("UsuarioSIG"), Usuario) + UsuarioActual = CType(Context.Session("UsuarioSIG"), Usuario) + Catch ex As Exception + Usuario.CerrarSession() + Return Nothing + End Try + End Get + End Property Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then + If Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing Then + Dim AuthorizeRequest As Boolean = False + Dim HuboError = False + Dim statusCode = 401 + AuthorizeRequest = False + + Response.StatusCode = statusCode + If Not AuthorizeRequest Then + Usuario.CerrarSession() + Response.End() + End If + End If + If UsuarioActual.CveRol <> 1 Then + + Dim AuthorizeRequest As Boolean = False + Dim HuboError = False + Dim statusCode = 401 + AuthorizeRequest = False + + Response.StatusCode = statusCode + If Not AuthorizeRequest Then + Usuario.CerrarSession() + Response.End() + End If + End If ' Dim listacve As New List(Of String) ' listacve.Add("1815") ' Notificaciones.AlertaVentana("notificacion", listacve, timeoutseconds:=0) diff --git a/vwd.webinfo b/vwd.webinfo index 93df9a232..3f67b239f 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -26,6 +26,8 @@ + + From e34cf6cf5e94e645e0f6458856cfec2bb3626f5b Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Wed, 18 Mar 2020 13:24:32 -0700 Subject: [PATCH 09/24] --- App_Code/ClsPaginas.vb | 14904 +++++++++++++++++++-------------------- 1 file changed, 7452 insertions(+), 7452 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 03e004735..7a55ed2b4 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -1,1218 +1,1218 @@ -Option Strict On -Option Explicit On - -Imports System -Imports System.Data -Imports System.Security.Cryptography -Imports Extensiones -Imports System.Web.Security -Imports System.Web -Imports System.IO -Imports Microsoft.Reporting.WebForms -Imports iTextSharp.text.pdf -Imports CrystalDecisions.CrystalReports.Engine -Imports CrystalDecisions.Shared -Imports CrystalDecisions.ReportSource -Imports Stimulsoft.Report -Imports Stimulsoft.Report.Dictionary -Imports Stimulsoft.Report.MobileDesign -Imports System.Linq -Imports Stimulsoft.Report.Export -Imports System.Xml - - -'NOTA AD TEAM -'COLOR PARA ROW TOTAL EN REPORT VIEWER: #67809F (AZULITO) - - - -Public Class ClsPaginas - Inherits System.Web.UI.Page - - Public Const CveUsuarioAsistencia As Integer = 100 - Public Const ContraseñaPredeterminada = "-acceso-" - Public Const ContraseñaPredeterminadaEncriptada = "aQDyjiv2NgoTct4c84VnLQ==" ' "-acceso-" - Private Shared EncryptKey() As Byte = {} - Private Shared ReadOnly IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF} - Private Const SEncryptionKey As String = "__sig__$gj7+5&j__sig__" - Public Shared UrlParametros As System.Collections.Hashtable - - Public Shared Property EmpresaNotificaciones() As Empresa - -#Region "Propiedades" - - Public Shared ReadOnly Property UrlSitio As String - Get - If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlSitio")) Then - Return "" - Else - Return System.Configuration.ConfigurationManager.AppSettings("UrlSitio").ToString() - End If - End Get - End Property - Public Shared ReadOnly Property UrlDirecciones As String - Get - If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlDirecciones")) Then - Return "" - Else - Return System.Configuration.ConfigurationManager.AppSettings("UrlDirecciones").ToString() - End If - End Get - End Property - ReadOnly Property UsuarioActual() As Usuario - Get - Try - 'UsuarioActual = DirectCast(Session("UsuarioSIG"), Usuario) - UsuarioActual = CType(Context.Session("UsuarioSIG"), Usuario) - Catch ex As Exception - Usuario.CerrarSession() - Return Nothing - End Try - End Get - End Property - Public Property CveModulo As Integer - Get - Try - CveModulo = DirectCast(Master.FindControl("CveModulomasterpage"), Label).Text.ToEntero - Catch ex As Exception - CveModulo = 0 - End Try - End Get - Set(value As Integer) - Try - DirectCast(Master.FindControl("CveModulomasterpage"), Label).Text = value.ToString - Catch ex As Exception - End Try - End Set - End Property - - - Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double - Get - If GlobalTipoCambio <= 0 Then - 'sino tiene dato lo recargo por si ya esta insertado - If Fecha = MinFecha Then Fecha = Now - - Dim ObjGral As New ClsGenerales - If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then - - Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble - Else - Application("GlobalTipoCambio") = 0 - End If - ObjGral.Dispose() - - End If - - Return Application("GlobalTipoCambio").ToString.ToDouble - End Get - Set(value As Double) - Application("GlobalTipoCambio") = value - End Set - - End Property - Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double - Get - If GlobalTipoCambioEuro <= 0 Then - 'sino tiene dato lo recargo por si ya esta insertado - If Fecha = MinFecha Then Fecha = Now - - Dim ObjGral As New ClsGenerales - If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then - - Application("GlobalTipoCambioEuro") = ObjGral.DtResultados.Rows(0)("TipoCambioEuro").ToString.ToDouble - Else - Application("GlobalTipoCambioEuro") = 0 - End If - ObjGral.Dispose() - - End If - - Return Application("GlobalTipoCambioEuro").ToString.ToDouble - End Get - Set(value As Double) - Application("GlobalTipoCambioEuro") = value - End Set - - End Property - 'Property GlobalValidarCFDI As Boolean - ' Get - ' GlobalValidarCFDI = CBool(Application("GlobalValidarCFDI")) - ' End Get - ' Set(value As Boolean) - ' Application("GlobalValidarCFDI") = value - ' End Set - 'End Property - Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable - Get - Dim Str As New StringBuilder - If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) - If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa) - If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) - If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor) - - If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTUsuarios") = value - End Set - End Property - Property GlobalDTNomConceptos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTNomConceptos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTNomConceptos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTNomConceptos = DirectCast(Application("GlobalDTNomConceptos"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTNomConceptos") = value - End Set - End Property - Property GlobalDTTiposGastos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTTiposGastos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTiposGastos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTiposGastos = DirectCast(Application("GlobalDTTiposGastos"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTTiposGastos") = value - End Set - End Property - Property GlobalDTMFActividad(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveActividad As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetActividad(CveActividad, CveEmpresa, Estatus) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFActividad = dt - - End Get - Set(value As DataTable) - Application("GlobalDTActividad") = value - End Set - End Property - Property GlobalDTMFOperador(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveOperador As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetOperador(CveOperador, CveEmpresa, Estatus) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFOperador = dt - - End Get - Set(value As DataTable) - Application("GlobalDTOperador") = value - End Set - End Property - Property GlobalDTMFEstatus(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetEstatus(CveEstatus, Estatus, CveEmpresa) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFEstatus = dt - - End Get - Set(value As DataTable) - Application("GlobalDTEstatus") = value - End Set - End Property - Property DtFacturaDefault() As DataTable - Get - DtFacturaDefault = DirectCast(Application("DtFacturaDefault"), DataTable) - End Get - Set(value As DataTable) - Application("DtFacturaDefault") = value - End Set - End Property - Property Directorio() As String - Get - Directorio = DirectCast(Application("Directorio"), String) - End Get - Set(value As String) - Application("Directorio") = value - End Set - End Property - Property GlobalDTPSATPS() As DataTable - Get - GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable - End Get - Set(value As DataTable) - Application("GlobalDTPSATPS") = value - End Set - End Property - -#Region "GLOBALES DE SAT COMERCIO EXTERIOR" - - Property GlobalDTClavePedimento() As DataTable - Get - GlobalDTClavePedimento = DirectCast(Application("GlobalDTClavePedimento"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTClavePedimento") = value - End Set - End Property - - Property GlobalDTFraccionArancelaria() As DataTable - Get - GlobalDTFraccionArancelaria = DirectCast(Application("GlobalDTFraccionArancelaria"), EnumerableRowCollection(Of DataRow)).CopyToDataTable - End Get - Set(value As DataTable) - Application("GlobalDTFraccionArancelaria") = value - End Set - End Property - - Property GlobalDTIncoterm() As DataTable - Get - GlobalDTIncoterm = DirectCast(Application("GlobalDTIncoterm"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTIncoterm") = value - End Set - End Property - - Property GlobalDTTipoOperacion() As DataTable - Get - GlobalDTTipoOperacion = DirectCast(Application("GlobalDTTipoOperacion"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTipoOperacion") = value - End Set - End Property - - Property GlobalDTSATMotivoTraslado() As DataTable - Get - GlobalDTSATMotivoTraslado = DirectCast(Application("GlobalDTSATMotivoTraslado"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTSATMotivoTraslado") = value - End Set - End Property - - Property GlobalDTUnidadAduana() As DataTable - Get - GlobalDTUnidadAduana = DirectCast(Application("GlobalDTUnidadAduana"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTUnidadAduana") = value - End Set - End Property - - Property GlobalDTPais() As DataTable - Get - GlobalDTPais = DirectCast(Application("GlobalDTPais"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTPais") = value - End Set - End Property - - Property GlobalDTEstado(ClaveSATPais As String) As DataTable - Get - If ClaveSATPais <> "-1" Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTEstado"), DataTable), String.Format("ClaveSATPais = '{0}'", ClaveSATPais), "", DataViewRowState.CurrentRows) - GlobalDTEstado = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEstado = DirectCast(Application("GlobalDTEstado"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTEstado") = value - End Set - End Property - - Property GlobalDTMunicipio(ClaveSATEstado As String) As DataTable - Get - If ClaveSATEstado <> "-1" Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTMunicipio"), DataTable), String.Format("ClaveSATEstado = '{0}'", ClaveSATEstado), "", DataViewRowState.CurrentRows) - GlobalDTMunicipio = Dv.ToTable - Dv.Dispose() - Else - GlobalDTMunicipio = DirectCast(Application("GlobalDTMunicipio"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTMunicipio") = value - End Set - End Property - - Property GlobalDTColonia(ClaveSATMunicipio As String) As DataTable - Get - If ClaveSATMunicipio <> "-1" Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTColonia"), DataTable), String.Format("ClaveSATMunicipio = '{0}'", ClaveSATMunicipio), "", DataViewRowState.CurrentRows) - GlobalDTColonia = Dv.ToTable - Dv.Dispose() - Else - GlobalDTColonia = DirectCast(Application("GlobalDTColonia"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTColonia") = value - End Set - End Property - -#End Region - - Property GlobalDTPSATUM() As DataTable - Get - - 'System.Data.EnumerableRowCollection - If Not IsNothing(Application("GlobalDTPSATUM")) Then - If Application("GlobalDTPSATUM").GetType().IsSubclassOf(GetType(EnumerableRowCollection)) Then - Return DirectCast(Application("GlobalDTPSATUM"), EnumerableRowCollection(Of DataRow)).CopyToDataTable() - Else - Return DirectCast(Application("GlobalDTPSATUM"), DataTable) - End If - Else - Return Nothing - End If - End Get - Set(value As DataTable) - Application("GlobalDTPSATUM") = value - End Set - End Property - Property GlobalDTNomConceptosFunciones() As DataTable - Get - GlobalDTNomConceptosFunciones = DirectCast(Application("GlobalDTNomConceptosFunciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTNomConceptosFunciones") = value - End Set - End Property - Property GlobalDTUsuarioResponsable() As DataTable - Get - GlobalDTUsuarioResponsable = DirectCast(Application("GlobalDTUsuarioResponsable"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTUsuarioResponsable") = value - End Set - End Property - Property GlobalDTProveedoresCuentas(CveProveedor As Integer, Estatus As Boolean) As DataTable - Get - GlobalDTProveedoresCuentas = DirectCast(Application("GlobalDTProveedoresCuentas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTProveedoresCuentas") = value - End Set - End Property - Property GlobalDTProveedorClasificacion(CveEmpresa As Integer) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTProveedorClasificacion{0}", CveEmpresa) - 'sino existe, recarga los datos - If DirectCast(Application(AppNombre), DataTable) Is Nothing Then - Dim P As New ClsCompProveedores +Option Strict On +Option Explicit On + +Imports System +Imports System.Data +Imports System.Security.Cryptography +Imports Extensiones +Imports System.Web.Security +Imports System.Web +Imports System.IO +Imports Microsoft.Reporting.WebForms +Imports iTextSharp.text.pdf +Imports CrystalDecisions.CrystalReports.Engine +Imports CrystalDecisions.Shared +Imports CrystalDecisions.ReportSource +Imports Stimulsoft.Report +Imports Stimulsoft.Report.Dictionary +Imports Stimulsoft.Report.MobileDesign +Imports System.Linq +Imports Stimulsoft.Report.Export +Imports System.Xml + + +'NOTA AD TEAM +'COLOR PARA ROW TOTAL EN REPORT VIEWER: #67809F (AZULITO) + + + +Public Class ClsPaginas + Inherits System.Web.UI.Page + + Public Const CveUsuarioAsistencia As Integer = 100 + Public Const ContraseñaPredeterminada = "-acceso-" + Public Const ContraseñaPredeterminadaEncriptada = "aQDyjiv2NgoTct4c84VnLQ==" ' "-acceso-" + Private Shared EncryptKey() As Byte = {} + Private Shared ReadOnly IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF} + Private Const SEncryptionKey As String = "__sig__$gj7+5&j__sig__" + Public Shared UrlParametros As System.Collections.Hashtable + + Public Shared Property EmpresaNotificaciones() As Empresa + +#Region "Propiedades" + + Public Shared ReadOnly Property UrlSitio As String + Get + If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlSitio")) Then + Return "" + Else + Return System.Configuration.ConfigurationManager.AppSettings("UrlSitio").ToString() + End If + End Get + End Property + Public Shared ReadOnly Property UrlDirecciones As String + Get + If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlDirecciones")) Then + Return "" + Else + Return System.Configuration.ConfigurationManager.AppSettings("UrlDirecciones").ToString() + End If + End Get + End Property + ReadOnly Property UsuarioActual() As Usuario + Get + Try + 'UsuarioActual = DirectCast(Session("UsuarioSIG"), Usuario) + UsuarioActual = CType(Context.Session("UsuarioSIG"), Usuario) + Catch ex As Exception + Usuario.CerrarSession() + Return Nothing + End Try + End Get + End Property + Public Property CveModulo As Integer + Get + Try + CveModulo = DirectCast(Master.FindControl("CveModulomasterpage"), Label).Text.ToEntero + Catch ex As Exception + CveModulo = 0 + End Try + End Get + Set(value As Integer) + Try + DirectCast(Master.FindControl("CveModulomasterpage"), Label).Text = value.ToString + Catch ex As Exception + End Try + End Set + End Property + + + Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double + Get + If GlobalTipoCambio <= 0 Then + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + + Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble + Else + Application("GlobalTipoCambio") = 0 + End If + ObjGral.Dispose() + + End If + + Return Application("GlobalTipoCambio").ToString.ToDouble + End Get + Set(value As Double) + Application("GlobalTipoCambio") = value + End Set + + End Property + Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double + Get + If GlobalTipoCambioEuro <= 0 Then + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + + Application("GlobalTipoCambioEuro") = ObjGral.DtResultados.Rows(0)("TipoCambioEuro").ToString.ToDouble + Else + Application("GlobalTipoCambioEuro") = 0 + End If + ObjGral.Dispose() + + End If + + Return Application("GlobalTipoCambioEuro").ToString.ToDouble + End Get + Set(value As Double) + Application("GlobalTipoCambioEuro") = value + End Set + + End Property + 'Property GlobalValidarCFDI As Boolean + ' Get + ' GlobalValidarCFDI = CBool(Application("GlobalValidarCFDI")) + ' End Get + ' Set(value As Boolean) + ' Application("GlobalValidarCFDI") = value + ' End Set + 'End Property + Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable + Get + Dim Str As New StringBuilder + If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) + If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa) + If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) + If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor) + + If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTUsuarios") = value + End Set + End Property + Property GlobalDTNomConceptos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTNomConceptos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTNomConceptos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTNomConceptos = DirectCast(Application("GlobalDTNomConceptos"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTNomConceptos") = value + End Set + End Property + Property GlobalDTTiposGastos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTTiposGastos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTiposGastos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTiposGastos = DirectCast(Application("GlobalDTTiposGastos"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTTiposGastos") = value + End Set + End Property + Property GlobalDTMFActividad(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveActividad As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetActividad(CveActividad, CveEmpresa, Estatus) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFActividad = dt + + End Get + Set(value As DataTable) + Application("GlobalDTActividad") = value + End Set + End Property + Property GlobalDTMFOperador(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveOperador As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetOperador(CveOperador, CveEmpresa, Estatus) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFOperador = dt + + End Get + Set(value As DataTable) + Application("GlobalDTOperador") = value + End Set + End Property + Property GlobalDTMFEstatus(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetEstatus(CveEstatus, Estatus, CveEmpresa) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFEstatus = dt + + End Get + Set(value As DataTable) + Application("GlobalDTEstatus") = value + End Set + End Property + Property DtFacturaDefault() As DataTable + Get + DtFacturaDefault = DirectCast(Application("DtFacturaDefault"), DataTable) + End Get + Set(value As DataTable) + Application("DtFacturaDefault") = value + End Set + End Property + Property Directorio() As String + Get + Directorio = DirectCast(Application("Directorio"), String) + End Get + Set(value As String) + Application("Directorio") = value + End Set + End Property + Property GlobalDTPSATPS() As DataTable + Get + GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + End Get + Set(value As DataTable) + Application("GlobalDTPSATPS") = value + End Set + End Property + +#Region "GLOBALES DE SAT COMERCIO EXTERIOR" + + Property GlobalDTClavePedimento() As DataTable + Get + GlobalDTClavePedimento = DirectCast(Application("GlobalDTClavePedimento"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTClavePedimento") = value + End Set + End Property + + Property GlobalDTFraccionArancelaria() As DataTable + Get + GlobalDTFraccionArancelaria = DirectCast(Application("GlobalDTFraccionArancelaria"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + End Get + Set(value As DataTable) + Application("GlobalDTFraccionArancelaria") = value + End Set + End Property + + Property GlobalDTIncoterm() As DataTable + Get + GlobalDTIncoterm = DirectCast(Application("GlobalDTIncoterm"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTIncoterm") = value + End Set + End Property + + Property GlobalDTTipoOperacion() As DataTable + Get + GlobalDTTipoOperacion = DirectCast(Application("GlobalDTTipoOperacion"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTipoOperacion") = value + End Set + End Property + + Property GlobalDTSATMotivoTraslado() As DataTable + Get + GlobalDTSATMotivoTraslado = DirectCast(Application("GlobalDTSATMotivoTraslado"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTSATMotivoTraslado") = value + End Set + End Property + + Property GlobalDTUnidadAduana() As DataTable + Get + GlobalDTUnidadAduana = DirectCast(Application("GlobalDTUnidadAduana"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTUnidadAduana") = value + End Set + End Property + + Property GlobalDTPais() As DataTable + Get + GlobalDTPais = DirectCast(Application("GlobalDTPais"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTPais") = value + End Set + End Property + + Property GlobalDTEstado(ClaveSATPais As String) As DataTable + Get + If ClaveSATPais <> "-1" Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTEstado"), DataTable), String.Format("ClaveSATPais = '{0}'", ClaveSATPais), "", DataViewRowState.CurrentRows) + GlobalDTEstado = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEstado = DirectCast(Application("GlobalDTEstado"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTEstado") = value + End Set + End Property + + Property GlobalDTMunicipio(ClaveSATEstado As String) As DataTable + Get + If ClaveSATEstado <> "-1" Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTMunicipio"), DataTable), String.Format("ClaveSATEstado = '{0}'", ClaveSATEstado), "", DataViewRowState.CurrentRows) + GlobalDTMunicipio = Dv.ToTable + Dv.Dispose() + Else + GlobalDTMunicipio = DirectCast(Application("GlobalDTMunicipio"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTMunicipio") = value + End Set + End Property + + Property GlobalDTColonia(ClaveSATMunicipio As String) As DataTable + Get + If ClaveSATMunicipio <> "-1" Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTColonia"), DataTable), String.Format("ClaveSATMunicipio = '{0}'", ClaveSATMunicipio), "", DataViewRowState.CurrentRows) + GlobalDTColonia = Dv.ToTable + Dv.Dispose() + Else + GlobalDTColonia = DirectCast(Application("GlobalDTColonia"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTColonia") = value + End Set + End Property + +#End Region + + Property GlobalDTPSATUM() As DataTable + Get + + 'System.Data.EnumerableRowCollection + If Not IsNothing(Application("GlobalDTPSATUM")) Then + If Application("GlobalDTPSATUM").GetType().IsSubclassOf(GetType(EnumerableRowCollection)) Then + Return DirectCast(Application("GlobalDTPSATUM"), EnumerableRowCollection(Of DataRow)).CopyToDataTable() + Else + Return DirectCast(Application("GlobalDTPSATUM"), DataTable) + End If + Else + Return Nothing + End If + End Get + Set(value As DataTable) + Application("GlobalDTPSATUM") = value + End Set + End Property + Property GlobalDTNomConceptosFunciones() As DataTable + Get + GlobalDTNomConceptosFunciones = DirectCast(Application("GlobalDTNomConceptosFunciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTNomConceptosFunciones") = value + End Set + End Property + Property GlobalDTUsuarioResponsable() As DataTable + Get + GlobalDTUsuarioResponsable = DirectCast(Application("GlobalDTUsuarioResponsable"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTUsuarioResponsable") = value + End Set + End Property + Property GlobalDTProveedoresCuentas(CveProveedor As Integer, Estatus As Boolean) As DataTable + Get + GlobalDTProveedoresCuentas = DirectCast(Application("GlobalDTProveedoresCuentas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTProveedoresCuentas") = value + End Set + End Property + Property GlobalDTProveedorClasificacion(CveEmpresa As Integer) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTProveedorClasificacion{0}", CveEmpresa) + 'sino existe, recarga los datos + If DirectCast(Application(AppNombre), DataTable) Is Nothing Then + Dim P As New ClsCompProveedores If P.GetProveedorClasificacion(CveEmpresa) Then Application(AppNombre) = P.DtResultados P.Dispose() End If - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa ={0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProveedorClasificacion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProveedorClasificacion = DirectCast(Application(AppNombre), DataTable) - End If - - End Get - Set(value As DataTable) + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa ={0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProveedorClasificacion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProveedorClasificacion = DirectCast(Application(AppNombre), DataTable) + End If + + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTProveedorClasificacion{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTProveedorSucursales(CveProveedor As Integer, CveEmpresa As Integer) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTProveedorSucursales{0}", CveEmpresa) - 'sino existe, recarga los datos - If DirectCast(Application(AppNombre), DataTable) Is Nothing Then - Dim P As New ClsCompProveedores + End Set + End Property + Property GlobalDTProveedorSucursales(CveProveedor As Integer, CveEmpresa As Integer) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTProveedorSucursales{0}", CveEmpresa) + 'sino existe, recarga los datos + If DirectCast(Application(AppNombre), DataTable) Is Nothing Then + Dim P As New ClsCompProveedores If P.GetSucursales(-1, CveEmpresa) Then Application(AppNombre) = P.DtResultados P.Dispose() End If - - If CveProveedor <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveProveedor = {0}", CveProveedor), "", DataViewRowState.CurrentRows) - GlobalDTProveedorSucursales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProveedorSucursales = DirectCast(Application(AppNombre), DataTable) - End If - - End Get - Set(value As DataTable) + + If CveProveedor <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveProveedor = {0}", CveProveedor), "", DataViewRowState.CurrentRows) + GlobalDTProveedorSucursales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProveedorSucursales = DirectCast(Application(AppNombre), DataTable) + End If + + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTProveedorSucursales{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTRoles(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTRoles"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTRoles = Dv.ToTable - Dv.Dispose() - Else - GlobalDTRoles = DirectCast(Application("GlobalDTRoles"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - Application("GlobalDTRoles") = value - End Set - End Property - Property GlobalDTNomSatBancos() As DataTable - Get - GlobalDTNomSatBancos = DirectCast(Application("GlobalDTNomSatBancos"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTNomSatBancos") = value - End Set - End Property - Property GlobalDTNomSatConceptos() As DataTable - Get - GlobalDTNomSatConceptos = DirectCast(Application("GlobalDTNomSatConceptos"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTNomSatConceptos") = value - End Set - End Property - Property GlobalDTNomSatRegimenContratacion() As DataTable - Get - GlobalDTNomSatRegimenContratacion = DirectCast(Application("GlobalDTNomSatRegimenContratacion"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTNomSatRegimenContratacion") = value - End Set - End Property - Property GlobalDTNomSatRiesgoPuesto() As DataTable - Get - GlobalDTNomSatRiesgoPuesto = DirectCast(Application("GlobalDTNomSatRiesgoPuesto"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTNomSatRiesgoPuesto") = value - End Set - End Property - Property GlobalDTNomSatTipoIncapacidad() As DataTable - Get - GlobalDTNomSatTipoIncapacidad = DirectCast(Application("GlobalDTNomSatTipoIncapacidad"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTNomSatTipoIncapacidad") = value - End Set - End Property - Property GlobalDTEmpresas(Optional CveEmpresa As Integer = -1) As DataTable - Get - - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTEmpresas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTEmpresas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEmpresas = DirectCast(Application("GlobalDTEmpresas"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - Application("GlobalDTEmpresas") = value - End Set - End Property - Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable + End Set + End Property + Property GlobalDTRoles(CveEmpresa As Integer) As DataTable Get - Dim AppNombre As String = String.Format("GlobalDTClasificaciones{0}", CveEmpresa) - 'sino existe, recarga los datos - If Application(AppNombre) Is Nothing Then - Dim ObjClasificaciones As New ClsClasificaciones + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTRoles"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTRoles = Dv.ToTable + Dv.Dispose() + Else + GlobalDTRoles = DirectCast(Application("GlobalDTRoles"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + Application("GlobalDTRoles") = value + End Set + End Property + Property GlobalDTNomSatBancos() As DataTable + Get + GlobalDTNomSatBancos = DirectCast(Application("GlobalDTNomSatBancos"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTNomSatBancos") = value + End Set + End Property + Property GlobalDTNomSatConceptos() As DataTable + Get + GlobalDTNomSatConceptos = DirectCast(Application("GlobalDTNomSatConceptos"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTNomSatConceptos") = value + End Set + End Property + Property GlobalDTNomSatRegimenContratacion() As DataTable + Get + GlobalDTNomSatRegimenContratacion = DirectCast(Application("GlobalDTNomSatRegimenContratacion"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTNomSatRegimenContratacion") = value + End Set + End Property + Property GlobalDTNomSatRiesgoPuesto() As DataTable + Get + GlobalDTNomSatRiesgoPuesto = DirectCast(Application("GlobalDTNomSatRiesgoPuesto"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTNomSatRiesgoPuesto") = value + End Set + End Property + Property GlobalDTNomSatTipoIncapacidad() As DataTable + Get + GlobalDTNomSatTipoIncapacidad = DirectCast(Application("GlobalDTNomSatTipoIncapacidad"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTNomSatTipoIncapacidad") = value + End Set + End Property + Property GlobalDTEmpresas(Optional CveEmpresa As Integer = -1) As DataTable + Get + + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTEmpresas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTEmpresas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEmpresas = DirectCast(Application("GlobalDTEmpresas"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + Application("GlobalDTEmpresas") = value + End Set + End Property + Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTClasificaciones{0}", CveEmpresa) + 'sino existe, recarga los datos + If Application(AppNombre) Is Nothing Then + Dim ObjClasificaciones As New ClsClasificaciones If ObjClasificaciones.GetClasificaciones(CveEmpresa) Then Application(AppNombre) = ObjClasificaciones.DtResultados ObjClasificaciones.Dispose() - End If - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + End If + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) If UsoClasificacion <> -1 Then Str.AppendFormat(" AND UsoClasificacion IN ({0},3) ", UsoClasificacion) - If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificaciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificaciones = DirectCast(Application(AppNombre), DataTable) - End If - - - - End Get + If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificaciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificaciones = DirectCast(Application(AppNombre), DataTable) + End If + + + + End Get Set(value As DataTable) - Dim AppNombre As String = String.Format("GlobalDTClasificaciones{0}", CveEmpresa) - Application(AppNombre) = value - End Set - End Property - Property GlobalDTClasificaciones2(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificaciones2"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificaciones2 = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificaciones2 = DirectCast(Application("GlobalDTClasificaciones2"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTClasificaciones2") = value - End Set - End Property - Property GlobalDTClasificacionesSubProyectos(Optional CveClasificacion As Integer = -1, Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesSubProyecto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesSubProyectos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesSubProyectos = DirectCast(Application("GlobalDTClasificacionesSubProyecto"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTClasificacionesSubProyecto") = value - End Set - End Property - Property GlobalDTACClasificadorObjetoGasto(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTACClasificadorObjetoGasto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTACClasificadorObjetoGasto = Dv.ToTable - Dv.Dispose() - Else - GlobalDTACClasificadorObjetoGasto = DirectCast(Application("GlobalDTACClasificadorObjetoGasto"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTACClasificadorObjetoGasto") = value - End Set - End Property - Property GlobalDTClasificacionesDetalle(Optional CveEmpresa As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) - Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesDetalle"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesDetalle = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesDetalle = DirectCast(Application("GlobalDTClasificacionesDetalle"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTClasificacionesDetalle") = value - End Set - End Property - Property GlobalDTSubFamilias(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTSubFamilias"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTSubFamilias = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTSubFamilias = DirectCast(Application("GlobalDTSubFamilias"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTSubFamilias") = value - End Set - End Property - Property GlobalDTFamilias(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTFamilias"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTFamilias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTFamilias = DirectCast(Application("GlobalDTFamilias"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTFamilias") = value - End Set - End Property - Property GlobalDTClasificacionesPresupuestos(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesPresupuestos"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesPresupuestos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesPresupuestos = DirectCast(Application("GlobalDTClasificacionesPresupuestos"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTClasificacionesPresupuestos") = value - End Set - End Property - Property GlobalDTMetodosPago() As DataTable - Get - GlobalDTMetodosPago = DirectCast(Application("GlobalDTMetodosPago"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMetodosPago") = value - End Set - End Property - Property GlobalDTModulos() As DataTable - Get - GlobalDTModulos = DirectCast(Application("GlobalDTModulos"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTModulos") = value - End Set - End Property - Property GlobalDTMonedas() As DataTable - Get - GlobalDTMonedas = DirectCast(Application("GlobalDTMonedas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMonedas") = value - End Set - End Property - Property GlobalDTMonedasAlias() As DataTable - Get - GlobalDTMonedasAlias = DirectCast(Application("GlobalDTMonedasAlias"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMonedasAlias") = value - End Set - End Property - Property GlobalDTSucursales(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTSucursales"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " Sucursal", DataViewRowState.CurrentRows) - GlobalDTSucursales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSucursales = DirectCast(Application("GlobalDTSucursales"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTSucursales") = value - End Set - End Property - Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable - Get - If EsPersonaFisica <> -1 Then - Dim Tipo As String = "" - If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1" - - Dim Dv As New DataView(DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows) - GlobalDTSATUsosCFDI = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSATUsosCFDI = DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - Application("GlobalDTSATUsosCFDI") = value - End Set - End Property - Public Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable + Dim AppNombre As String = String.Format("GlobalDTClasificaciones{0}", CveEmpresa) + Application(AppNombre) = value + End Set + End Property + Property GlobalDTClasificaciones2(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable Get - Dim AppNombre As String = String.Format("GlobalDTUnidadesMedida{0}", CveEmpresa) - 'sino existe, recarga los datos + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificaciones2"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificaciones2 = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificaciones2 = DirectCast(Application("GlobalDTClasificaciones2"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTClasificaciones2") = value + End Set + End Property + Property GlobalDTClasificacionesSubProyectos(Optional CveClasificacion As Integer = -1, Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesSubProyecto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesSubProyectos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesSubProyectos = DirectCast(Application("GlobalDTClasificacionesSubProyecto"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTClasificacionesSubProyecto") = value + End Set + End Property + Property GlobalDTACClasificadorObjetoGasto(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTACClasificadorObjetoGasto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTACClasificadorObjetoGasto = Dv.ToTable + Dv.Dispose() + Else + GlobalDTACClasificadorObjetoGasto = DirectCast(Application("GlobalDTACClasificadorObjetoGasto"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTACClasificadorObjetoGasto") = value + End Set + End Property + Property GlobalDTClasificacionesDetalle(Optional CveEmpresa As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) + Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesDetalle"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesDetalle = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesDetalle = DirectCast(Application("GlobalDTClasificacionesDetalle"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTClasificacionesDetalle") = value + End Set + End Property + Property GlobalDTSubFamilias(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTSubFamilias"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTSubFamilias = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTSubFamilias = DirectCast(Application("GlobalDTSubFamilias"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTSubFamilias") = value + End Set + End Property + Property GlobalDTFamilias(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTFamilias"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTFamilias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTFamilias = DirectCast(Application("GlobalDTFamilias"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTFamilias") = value + End Set + End Property + Property GlobalDTClasificacionesPresupuestos(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionesPresupuestos"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesPresupuestos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesPresupuestos = DirectCast(Application("GlobalDTClasificacionesPresupuestos"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTClasificacionesPresupuestos") = value + End Set + End Property + Property GlobalDTMetodosPago() As DataTable + Get + GlobalDTMetodosPago = DirectCast(Application("GlobalDTMetodosPago"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMetodosPago") = value + End Set + End Property + Property GlobalDTModulos() As DataTable + Get + GlobalDTModulos = DirectCast(Application("GlobalDTModulos"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTModulos") = value + End Set + End Property + Property GlobalDTMonedas() As DataTable + Get + GlobalDTMonedas = DirectCast(Application("GlobalDTMonedas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMonedas") = value + End Set + End Property + Property GlobalDTMonedasAlias() As DataTable + Get + GlobalDTMonedasAlias = DirectCast(Application("GlobalDTMonedasAlias"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMonedasAlias") = value + End Set + End Property + Property GlobalDTSucursales(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTSucursales"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " Sucursal", DataViewRowState.CurrentRows) + GlobalDTSucursales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSucursales = DirectCast(Application("GlobalDTSucursales"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTSucursales") = value + End Set + End Property + Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable + Get + If EsPersonaFisica <> -1 Then + Dim Tipo As String = "" + If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1" + + Dim Dv As New DataView(DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows) + GlobalDTSATUsosCFDI = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSATUsosCFDI = DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + Application("GlobalDTSATUsosCFDI") = value + End Set + End Property + Public Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTUnidadesMedida{0}", CveEmpresa) + 'sino existe, recarga los datos If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then Dim ObjUnidadesMedida As New ClsUnidadesMedida() If ObjUnidadesMedida.GetUnidadesMedida(CveEmpresa) Then Application(AppNombre) = ObjUnidadesMedida.DtResultados ObjUnidadesMedida.Dispose() End If - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows) - GlobalDTUnidadesMedida = Dv.ToTable - Dv.Dispose() - Else - GlobalDTUnidadesMedida = DirectCast(Application(AppNombre), DataTable) - End If - End Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows) + GlobalDTUnidadesMedida = Dv.ToTable + Dv.Dispose() + Else + GlobalDTUnidadesMedida = DirectCast(Application(AppNombre), DataTable) + End If + End Get Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTUnidadesMedida{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTUnidadesMedidaAlias(Optional CveEmpresa As Integer = -1) As DataTable + End Set + End Property + Property GlobalDTUnidadesMedidaAlias(Optional CveEmpresa As Integer = -1) As DataTable Get - Dim AppNombre As String = String.Format("GlobalDTUnidadesMedidaAlias{0}", CveEmpresa) - 'sino existe, recarga los datos + Dim AppNombre As String = String.Format("GlobalDTUnidadesMedidaAlias{0}", CveEmpresa) + 'sino existe, recarga los datos If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then Dim ObjUnidadesMedida As New ClsUnidadesMedida() If ObjUnidadesMedida.GetUnidadesMedidaAlias(CveEmpresa, -1) Then Application(AppNombre) = ObjUnidadesMedida.DtResultados ObjUnidadesMedida.Dispose() - End If - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTUnidadesMedidaAlias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTUnidadesMedidaAlias = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) + End If + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTUnidadesMedidaAlias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTUnidadesMedidaAlias = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTUnidadesMedidaAlias{0}", CveEmpresa) Application(AppNombre) = value 'Dim ObjUnidadesMedida As New ClsUnidadesMedida() 'If ObjUnidadesMedida.GetUnidadesMedidaAlias(CveEmpresa, -1) Then Application(AppNombre) = ObjUnidadesMedida.DtResultados - 'ObjUnidadesMedida.Dispose() - End Set - End Property - Property GlobalDTEstatusOrdenCompra() As DataTable - Get - GlobalDTEstatusOrdenCompra = DirectCast(Application("GlobalDTEstatusOrdenCompra"), DataTable) - End Get - Set(ByVal value As DataTable) - Application("GlobalDTEstatusOrdenCompra") = value - End Set - End Property - Property GlobalDTLeyendasFiscales() As DataTable - Get - GlobalDTLeyendasFiscales = DirectCast(Application("GlobalDTLeyendasFiscales"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTLeyendasFiscales") = value - End Set - End Property - Property GlobalDTFolios() As DataTable - Get - GlobalDTFolios = DirectCast(Application("GlobalDTFolios"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTFolios") = value - End Set - End Property - Property GlobalDTEstatusFactura() As DataTable - Get - GlobalDTEstatusFactura = DirectCast(Application("GlobalDTEstatusFactura"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEstatusFactura") = value - End Set - End Property - Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable - Get - - If DirectCast(Application("GlobalDTProyectos"), DataTable) Is Nothing Or (DirectCast(Application("GlobalDTProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(Application("GlobalDTProyectos"), DataTable).Rows.Count = 0) Then - Dim P As New ClsProyectos - If P.GetProyectos Then - Application("GlobalDTProyectos") = P.DtResultados - End If - P.Dispose() - - Dim msg As String = "aqui no se carga proyectos" - If Request IsNot Nothing Then - msg = msg & Request.ServerVariables("URL") - End If - msg.GuardaLog() - - End If - - If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1 - - Dim StrSQL As New StringBuilder - If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - ' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto) - If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProyectos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProyectos = DirectCast(Application("GlobalDTProyectos"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - Dim msg As String = "aqui no se carga proyectos" - If Request IsNot Nothing Then - msg = msg & Request.ServerVariables("URL") - End If - msg.GuardaLog() - - End If - Application("GlobalDTProyectos") = value - End Set - End Property - Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTSubProyectos{0}", CveEmpresa) - 'sino existe, recarga los datos - If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then - Dim P As New ClsSubProyectos + 'ObjUnidadesMedida.Dispose() + End Set + End Property + Property GlobalDTEstatusOrdenCompra() As DataTable + Get + GlobalDTEstatusOrdenCompra = DirectCast(Application("GlobalDTEstatusOrdenCompra"), DataTable) + End Get + Set(ByVal value As DataTable) + Application("GlobalDTEstatusOrdenCompra") = value + End Set + End Property + Property GlobalDTLeyendasFiscales() As DataTable + Get + GlobalDTLeyendasFiscales = DirectCast(Application("GlobalDTLeyendasFiscales"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTLeyendasFiscales") = value + End Set + End Property + Property GlobalDTFolios() As DataTable + Get + GlobalDTFolios = DirectCast(Application("GlobalDTFolios"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTFolios") = value + End Set + End Property + Property GlobalDTEstatusFactura() As DataTable + Get + GlobalDTEstatusFactura = DirectCast(Application("GlobalDTEstatusFactura"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEstatusFactura") = value + End Set + End Property + Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable + Get + + If DirectCast(Application("GlobalDTProyectos"), DataTable) Is Nothing Or (DirectCast(Application("GlobalDTProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(Application("GlobalDTProyectos"), DataTable).Rows.Count = 0) Then + Dim P As New ClsProyectos + If P.GetProyectos Then + Application("GlobalDTProyectos") = P.DtResultados + End If + P.Dispose() + + Dim msg As String = "aqui no se carga proyectos" + If Request IsNot Nothing Then + msg = msg & Request.ServerVariables("URL") + End If + msg.GuardaLog() + + End If + + If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1 + + Dim StrSQL As New StringBuilder + If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + ' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto) + If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProyectos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProyectos = DirectCast(Application("GlobalDTProyectos"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + If value Is Nothing OrElse value.Rows.Count = 0 Then + Dim msg As String = "aqui no se carga proyectos" + If Request IsNot Nothing Then + msg = msg & Request.ServerVariables("URL") + End If + msg.GuardaLog() + + End If + Application("GlobalDTProyectos") = value + End Set + End Property + Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTSubProyectos{0}", CveEmpresa) + 'sino existe, recarga los datos + If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then + Dim P As New ClsSubProyectos If P.GetSubProyectos(CveEmpresa:=CveEmpresa) Then Application(AppNombre) = P.DtResultados - P.Dispose() - - Dim msg As String = "aqui no se carga subproyectos" - If Request IsNot Nothing Then - msg = msg & Request.ServerVariables("URL") - End If - msg.GuardaLog() - - End If - - If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then - Dim StrSQL As New StringBuilder - If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) - If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) - If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTSubProyectos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTSubProyectos = DirectCast(Application(AppNombre), DataTable) - End If - - End Get + P.Dispose() + + Dim msg As String = "aqui no se carga subproyectos" + If Request IsNot Nothing Then + msg = msg & Request.ServerVariables("URL") + End If + msg.GuardaLog() + + End If + + If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) + If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTSubProyectos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTSubProyectos = DirectCast(Application(AppNombre), DataTable) + End If + + End Get Set(ByVal value As DataTable) Dim AppNombre As String = String.Format("GlobalDTSubProyectos{0}", CveEmpresa) - Application(AppNombre) = value - End Set - End Property - Property GlobalDTSubProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable + Application(AppNombre) = value + End Set + End Property + Property GlobalDTSubProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable Get - Dim AppNombre As String = String.Format("GlobalDTSubProyectosUsuarios{0}", CveEmpresa) - If Application(AppNombre) Is Nothing Then - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios(CveEmpresa:=CveEmpresa) Then Application(AppNombre) = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) - ObjSubProyectos.Dispose() - End If - - If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then - Dim StrSQL As New StringBuilder - If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) - If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) - If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTSubProyectosUsuarios = Dv.ToTable - Dv.Dispose() - - 'Dim ObjSubProyectos As New ClsSubProyectos() - 'If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then - ' GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados - 'Else - ' GlobalDTSubProyectosUsuarios = Nothing - 'End If - 'ObjSubProyectos.Dispose() - - Else - GlobalDTSubProyectosUsuarios = DirectCast(Application(AppNombre), DataTable) - End If - - End Get - Set(ByVal value As DataTable) Dim AppNombre As String = String.Format("GlobalDTSubProyectosUsuarios{0}", CveEmpresa) - Application(AppNombre) = value - End Set - End Property - Property GlobalDTProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, CveEstatus As Integer) As DataTable - Get - - If Application("GlobalDTProyectosUsuarios") Is Nothing AndAlso DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable).Rows.Count = 0 Then - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios Then Application("GlobalDTProyectosUsuarios") = ObjSubProyectos.DtResultados.FiltraParametros("", "", {"Proyecto", "CveProyecto", "CveUsuario", "CveEmpresa", "CveEstatusProyecto"}) Else Alert("Ocurrió un error al cargar los Proyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) - ObjSubProyectos.Dispose() - GuardaLog("Se Cargo GlobalDTProyectosUsuarios") - End If - - If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then - Dim StrSQL As New StringBuilder - If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) - If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatusProyecto = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTProyectosUsuarios = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProyectosUsuarios = DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - Dim msg As String = "aqui no se carga proyectos" - If Request IsNot Nothing Then - msg = msg & Request.ServerVariables("URL") - End If - msg.GuardaLog() - - End If - Application("GlobalDTProyectosUsuarios") = value - End Set - End Property - Property GlobalDTPrecioListas(CveEmpresa As Integer) As DataTable - Get - GlobalDTPrecioListas = DirectCast(Application("GlobalDTPrecioListas"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) - End Get - Set(value As DataTable) - Application("GlobalDTPrecioListas") = value - End Set - End Property - Property GlobalDTMesas() As DataTable - Get - GlobalDTMesas = DirectCast(Application("GlobalDTMesas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMesas") = value - End Set - End Property - Property GlobalDTTipoOrdenServicios(CveEmpresa As Integer) As DataTable - Get - GlobalDTTipoOrdenServicios = DirectCast(Application("GlobalDTTipoOrdenServicios"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) - End Get - Set(value As DataTable) - Application("GlobalDTTipoOrdenServicios") = value - End Set - End Property - Property GlobalDTSubTipoOrdenServicios() As DataTable - Get - GlobalDTSubTipoOrdenServicios = DirectCast(Application("GlobalDTSubTipoOrdenServicios"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTSubTipoOrdenServicios") = value - End Set - End Property - Property GlobalDTCaracteristicasOrdenServicios() As DataTable - Get - GlobalDTCaracteristicasOrdenServicios = DirectCast(Application("GlobalDTCaracteristicasOrdenServicios"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTCaracteristicasOrdenServicios") = value - End Set - End Property - Property GlobalDTOrdenesServiciosCaracteristicas() As DataTable - Get - GlobalDTOrdenesServiciosCaracteristicas = DirectCast(Application("GlobalDTOrdenesServiciosCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTOrdenesServiciosCaracteristicas") = value - End Set - End Property - Property GlobalDTCaracteristicasOpciones() As DataTable - Get - GlobalDTCaracteristicasOpciones = DirectCast(Application("GlobalDTCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTCaracteristicasOpciones") = value - End Set - End Property - Property GlobalDTTipoCuentasEquipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquipos = DirectCast(Application("GlobalDTTipoCuentasEquipos"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTTipoCuentasEquipos") = value - End Set - End Property - Property GlobalDTTipoCuentasEquiposCaracteristicas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquiposCaracteristicas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquiposCaracteristicas = DirectCast(Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTTipoCuentasEquiposCaracteristicas") = value - End Set - End Property - Property GlobalDTTipoCuentasEquiposOpciones(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquiposOpciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquiposOpciones = DirectCast(Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTTipoCuentasEquiposOpciones") = value - End Set - End Property - ''Property GlobalDTProductosServicios(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional Estatus As Integer = 1, - ' Optional CvePS As Integer = -1, Optional AplicaParaVenta As Integer = -1, Optional CveTipoPS As Integer = -1, Optional SATClavePS As String = "-1") As DataTable - ' Get - - ' If CveEmpresa = -1 Then - ' GlobalDTProductosServicios = DirectCast(Application("GlobalDTProductosServicios"), EnumerableRowCollection(Of DataRow)).CopyToDataTable - ' Else - - ' Dim Cons = DirectCast(Application("GlobalDTProductosServicios"), EnumerableRowCollection(Of DataRow)) - ' Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa)) - ' If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion)) - ' If CveClasificacionCosto >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacionCosto) = CveClasificacionCosto)) - ' If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus)) - ' If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS)) - ' If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta)) - ' If CveTipoPS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = CveTipoPS)) - ' If SATClavePS <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!SATClavePS) = SATClavePS)) - - ' 'Try, generado para cuando el resultado no tiene valores(The source contains no DataRows.), no detenga la ejecucion, no se le puso un count previo, porque el costo se duplica, al preguntar y luego ordenar y convertir a datatable - ' Try - ' GlobalDTProductosServicios = Cons.OrderBy(Function(a) a!PS).CopyToDataTable - ' Catch ex As Exception - ' GlobalDTProductosServicios = New DataTable - ' End Try - - ' 'Cons.CopyToDataTable.FiltraParametros("", "PS") 'Dv.ToTable() - - - ' 'VIEJO AGOSTO 2016 - ' 'Dim StrSQL As New StringBuilder - ' 'StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - ' 'If CveClasificacion >= 0 Then StrSQL.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) - ' 'If CveClasificacionCosto >= 0 Then StrSQL.AppendFormat(" AND CveClasificacionCosto = {0}", CveClasificacionCosto) - ' 'If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstado = {0} ", Estatus) - ' 'If CvePS >= 0 Then StrSQL.AppendFormat(" AND CvePS = {0} ", CvePS) - - ' ' Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServicios"), DataTable), StrSQL.ToString, "CveEmpresa,PS", DataViewRowState.CurrentRows) - - ' 'Dim Dvr As DataRowView() = Dv.FindRows(StrSQL.ToString) - ' 'Dim returnRows As New List(Of DataRow)() - ' 'For Each drv As DataRowView In Dvr - ' ' returnRows.Add(drv.Row) - ' 'Next - - ' 'GlobalDTProductosServicios = Dv.ToTable() - ' 'Dv.Dispose() - - ' End If - - ' End Get - ' Set(value As DataTable) - ' Application("GlobalDTProductosServicios") = value - ' End Set - 'End Property - ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1) As DataTable - Get - Dim ObjPS As New ClsProductosServicios - - If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta) Then - GlobalDTPS = ObjPS.DtResultados - Else - GlobalDTPS = Nothing - End If - - ObjPS.Dispose() - End Get - End Property - Public Property GlobalDTPSSimplificado(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional PSCodigo As String = "-1", Optional Estatus As Integer = 1, Optional AplicaParaVenta As Integer = -1) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTPSSimplificado{0}", CveEmpresa) + If Application(AppNombre) Is Nothing Then + Dim ObjSubProyectos As New ClsSubProyectos() + If ObjSubProyectos.GetSubProyectosUsuarios(CveEmpresa:=CveEmpresa) Then Application(AppNombre) = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) + ObjSubProyectos.Dispose() + End If + + If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) + If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTSubProyectosUsuarios = Dv.ToTable + Dv.Dispose() + + 'Dim ObjSubProyectos As New ClsSubProyectos() + 'If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then + ' GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados + 'Else + ' GlobalDTSubProyectosUsuarios = Nothing + 'End If + 'ObjSubProyectos.Dispose() + + Else + GlobalDTSubProyectosUsuarios = DirectCast(Application(AppNombre), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + Dim AppNombre As String = String.Format("GlobalDTSubProyectosUsuarios{0}", CveEmpresa) + Application(AppNombre) = value + End Set + End Property + Property GlobalDTProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, CveEstatus As Integer) As DataTable + Get + + If Application("GlobalDTProyectosUsuarios") Is Nothing AndAlso DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable).Rows.Count = 0 Then + Dim ObjSubProyectos As New ClsSubProyectos() + If ObjSubProyectos.GetSubProyectosUsuarios Then Application("GlobalDTProyectosUsuarios") = ObjSubProyectos.DtResultados.FiltraParametros("", "", {"Proyecto", "CveProyecto", "CveUsuario", "CveEmpresa", "CveEstatusProyecto"}) Else Alert("Ocurrió un error al cargar los Proyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) + ObjSubProyectos.Dispose() + GuardaLog("Se Cargo GlobalDTProyectosUsuarios") + End If + + If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) + If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatusProyecto = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTProyectosUsuarios = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProyectosUsuarios = DirectCast(Application("GlobalDTProyectosUsuarios"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + If value Is Nothing OrElse value.Rows.Count = 0 Then + Dim msg As String = "aqui no se carga proyectos" + If Request IsNot Nothing Then + msg = msg & Request.ServerVariables("URL") + End If + msg.GuardaLog() + + End If + Application("GlobalDTProyectosUsuarios") = value + End Set + End Property + Property GlobalDTPrecioListas(CveEmpresa As Integer) As DataTable + Get + GlobalDTPrecioListas = DirectCast(Application("GlobalDTPrecioListas"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) + End Get + Set(value As DataTable) + Application("GlobalDTPrecioListas") = value + End Set + End Property + Property GlobalDTMesas() As DataTable + Get + GlobalDTMesas = DirectCast(Application("GlobalDTMesas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMesas") = value + End Set + End Property + Property GlobalDTTipoOrdenServicios(CveEmpresa As Integer) As DataTable + Get + GlobalDTTipoOrdenServicios = DirectCast(Application("GlobalDTTipoOrdenServicios"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) + End Get + Set(value As DataTable) + Application("GlobalDTTipoOrdenServicios") = value + End Set + End Property + Property GlobalDTSubTipoOrdenServicios() As DataTable + Get + GlobalDTSubTipoOrdenServicios = DirectCast(Application("GlobalDTSubTipoOrdenServicios"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTSubTipoOrdenServicios") = value + End Set + End Property + Property GlobalDTCaracteristicasOrdenServicios() As DataTable + Get + GlobalDTCaracteristicasOrdenServicios = DirectCast(Application("GlobalDTCaracteristicasOrdenServicios"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTCaracteristicasOrdenServicios") = value + End Set + End Property + Property GlobalDTOrdenesServiciosCaracteristicas() As DataTable + Get + GlobalDTOrdenesServiciosCaracteristicas = DirectCast(Application("GlobalDTOrdenesServiciosCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTOrdenesServiciosCaracteristicas") = value + End Set + End Property + Property GlobalDTCaracteristicasOpciones() As DataTable + Get + GlobalDTCaracteristicasOpciones = DirectCast(Application("GlobalDTCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTCaracteristicasOpciones") = value + End Set + End Property + Property GlobalDTTipoCuentasEquipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquipos = DirectCast(Application("GlobalDTTipoCuentasEquipos"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTTipoCuentasEquipos") = value + End Set + End Property + Property GlobalDTTipoCuentasEquiposCaracteristicas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquiposCaracteristicas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquiposCaracteristicas = DirectCast(Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTTipoCuentasEquiposCaracteristicas") = value + End Set + End Property + Property GlobalDTTipoCuentasEquiposOpciones(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquiposOpciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquiposOpciones = DirectCast(Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTTipoCuentasEquiposOpciones") = value + End Set + End Property + ''Property GlobalDTProductosServicios(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional Estatus As Integer = 1, + ' Optional CvePS As Integer = -1, Optional AplicaParaVenta As Integer = -1, Optional CveTipoPS As Integer = -1, Optional SATClavePS As String = "-1") As DataTable + ' Get + + ' If CveEmpresa = -1 Then + ' GlobalDTProductosServicios = DirectCast(Application("GlobalDTProductosServicios"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + ' Else + + ' Dim Cons = DirectCast(Application("GlobalDTProductosServicios"), EnumerableRowCollection(Of DataRow)) + ' Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa)) + ' If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion)) + ' If CveClasificacionCosto >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacionCosto) = CveClasificacionCosto)) + ' If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus)) + ' If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS)) + ' If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta)) + ' If CveTipoPS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = CveTipoPS)) + ' If SATClavePS <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!SATClavePS) = SATClavePS)) + + ' 'Try, generado para cuando el resultado no tiene valores(The source contains no DataRows.), no detenga la ejecucion, no se le puso un count previo, porque el costo se duplica, al preguntar y luego ordenar y convertir a datatable + ' Try + ' GlobalDTProductosServicios = Cons.OrderBy(Function(a) a!PS).CopyToDataTable + ' Catch ex As Exception + ' GlobalDTProductosServicios = New DataTable + ' End Try + + ' 'Cons.CopyToDataTable.FiltraParametros("", "PS") 'Dv.ToTable() + + + ' 'VIEJO AGOSTO 2016 + ' 'Dim StrSQL As New StringBuilder + ' 'StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + ' 'If CveClasificacion >= 0 Then StrSQL.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) + ' 'If CveClasificacionCosto >= 0 Then StrSQL.AppendFormat(" AND CveClasificacionCosto = {0}", CveClasificacionCosto) + ' 'If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstado = {0} ", Estatus) + ' 'If CvePS >= 0 Then StrSQL.AppendFormat(" AND CvePS = {0} ", CvePS) + + ' ' Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServicios"), DataTable), StrSQL.ToString, "CveEmpresa,PS", DataViewRowState.CurrentRows) + + ' 'Dim Dvr As DataRowView() = Dv.FindRows(StrSQL.ToString) + ' 'Dim returnRows As New List(Of DataRow)() + ' 'For Each drv As DataRowView In Dvr + ' ' returnRows.Add(drv.Row) + ' 'Next + + ' 'GlobalDTProductosServicios = Dv.ToTable() + ' 'Dv.Dispose() + + ' End If + + ' End Get + ' Set(value As DataTable) + ' Application("GlobalDTProductosServicios") = value + ' End Set + 'End Property + ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1) As DataTable + Get + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta) Then + GlobalDTPS = ObjPS.DtResultados + Else + GlobalDTPS = Nothing + End If + + ObjPS.Dispose() + End Get + End Property + Public Property GlobalDTPSSimplificado(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional PSCodigo As String = "-1", Optional Estatus As Integer = 1, Optional AplicaParaVenta As Integer = -1) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTPSSimplificado{0}", CveEmpresa) If CveEmpresa <> -1 Then 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjPS As New ClsProductosServicios If ObjPS.GetPSSimplificado(CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados.AsEnumerable() - ObjPS.Dispose() + ObjPS.Dispose() End If - - Dim Cons = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow)) - - Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa)) - If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion)) - If PSCodigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!PSCodigo) = PSCodigo)) - If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus)) - If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta)) - - Try - GlobalDTPSSimplificado = Cons.OrderBy(Function(a) a!PSCodigo).CopyToDataTable - Catch ex As Exception - GlobalDTPSSimplificado = New DataTable - End Try - - Else - GlobalDTPSSimplificado = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow)).CopyToDataTable - End If - End Get - Set(value As DataTable) + + Dim Cons = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow)) + + Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa)) + If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion)) + If PSCodigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!PSCodigo) = PSCodigo)) + If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus)) + If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta)) + + Try + GlobalDTPSSimplificado = Cons.OrderBy(Function(a) a!PSCodigo).CopyToDataTable + Catch ex As Exception + GlobalDTPSSimplificado = New DataTable + End Try + + Else + GlobalDTPSSimplificado = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow)).CopyToDataTable + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTPSSimplificado{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTProductosServiciosAlias(CveEmpresa As Integer, Optional Estatus As Integer = 1) As DataTable - Get + End Set + End Property + Property GlobalDTProductosServiciosAlias(CveEmpresa As Integer, Optional Estatus As Integer = 1) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTProductosServiciosAlias{0}", CveEmpresa) 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then @@ -1222,27 +1222,27 @@ Public Class ClsPaginas End If - If CveEmpresa <> -1 Then - - Dim StrSQL As New StringBuilder - StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstado = {0} ", Estatus) - - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProductosServiciosAlias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProductosServiciosAlias = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) + If CveEmpresa <> -1 Then + + Dim StrSQL As New StringBuilder + StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstado = {0} ", Estatus) + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProductosServiciosAlias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProductosServiciosAlias = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTProductosServiciosAlias{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Public Property GlobalDTProductosServiciosEquivalencias(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTProductosServiciosEquivalencias{0}", CveEmpresa) + End Set + End Property + Public Property GlobalDTProductosServiciosEquivalencias(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTProductosServiciosEquivalencias{0}", CveEmpresa) If CveEmpresa <> -1 Then 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then @@ -1250,122 +1250,122 @@ Public Class ClsPaginas If ObjPS.GetPSEquivalencias(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados ObjPS.Dispose() End If - End If - - If CvePS <> -1 OrElse CveUM <> -1 Then - Dim StrSQL As New StringBuilder - If CvePS <> -1 Then StrSQL.AppendFormat(" AND CvePS = {0}", CvePS) + End If + + If CvePS <> -1 OrElse CveUM <> -1 Then + Dim StrSQL As New StringBuilder + If CvePS <> -1 Then StrSQL.AppendFormat(" AND CvePS = {0}", CvePS) If CveUM <> -1 Then StrSQL.AppendFormat(" AND CveUM = {0}", CveUM) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTProductosServiciosEquivalencias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProductosServiciosEquivalencias = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTProductosServiciosEquivalencias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProductosServiciosEquivalencias = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTProductosServiciosEquivalencias{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTProductosServiciosCaracteristicas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServiciosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProductosServiciosCaracteristicas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProductosServiciosCaracteristicas = DirectCast(Application("GlobalDTProductosServiciosCaracteristicas"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProductosServiciosCaracteristicas") = value - End Set - End Property - - Property GlobalDTPSAdicionales(CvePS As Integer, CveEmpresa As Integer) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTPSAdicionales{0}", CveEmpresa) + End Set + End Property + Property GlobalDTProductosServiciosCaracteristicas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServiciosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProductosServiciosCaracteristicas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProductosServiciosCaracteristicas = DirectCast(Application("GlobalDTProductosServiciosCaracteristicas"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProductosServiciosCaracteristicas") = value + End Set + End Property + + Property GlobalDTPSAdicionales(CvePS As Integer, CveEmpresa As Integer) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTPSAdicionales{0}", CveEmpresa) If CveEmpresa <> -1 Then 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjPS As New ClsProductosServicios If ObjPS.GetPSAdicionales(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados - ObjPS.Dispose() + ObjPS.Dispose() End If End If - Dim Str As New StringBuilder - If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) - If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) - - If CvePS > 0 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTPSAdicionales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTPSAdicionales = DirectCast(Application(AppNombre), DataTable) - End If - End Get + Dim Str As New StringBuilder + If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) + If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) + + If CvePS > 0 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTPSAdicionales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTPSAdicionales = DirectCast(Application(AppNombre), DataTable) + End If + End Get Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTPSAdicionales{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTProductosServiciosCaracteristicasOpciones(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServiciosCaracteristicasOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProductosServiciosCaracteristicasOpciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProductosServiciosCaracteristicasOpciones = DirectCast(Application("GlobalDTProductosServiciosCaracteristicasOpciones"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProductosServiciosCaracteristicasOpciones") = value - End Set - End Property - Property GlobalDTInvMetodosInventario() As DataTable - Get - GlobalDTInvMetodosInventario = DirectCast(Application("GlobalDTInvMetodosInventario"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTInvMetodosInventario") = value - End Set - End Property - Property GlobalDTAFCaracteristicasOpciones() As DataTable - Get - GlobalDTAFCaracteristicasOpciones = DirectCast(Application("GlobalDTAFCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAFCaracteristicasOpciones") = value - End Set - End Property - Property GlobalDTAFCaracteristicas() As DataTable - Get - GlobalDTAFCaracteristicas = DirectCast(Application("GlobalDTAFCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAFCaracteristicas") = value - End Set - End Property - Property GlobalDTAFCaracteristicasClasificaciones() As DataTable - Get - GlobalDTAFCaracteristicasClasificaciones = DirectCast(Application("GlobalDTAFCaracteristicasClasificaciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAFCaracteristicasClasificaciones") = value - End Set - End Property - Property GlobalDTImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As DataTable - Get + End Set + End Property + Property GlobalDTProductosServiciosCaracteristicasOpciones(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTProductosServiciosCaracteristicasOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProductosServiciosCaracteristicasOpciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProductosServiciosCaracteristicasOpciones = DirectCast(Application("GlobalDTProductosServiciosCaracteristicasOpciones"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProductosServiciosCaracteristicasOpciones") = value + End Set + End Property + Property GlobalDTInvMetodosInventario() As DataTable + Get + GlobalDTInvMetodosInventario = DirectCast(Application("GlobalDTInvMetodosInventario"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTInvMetodosInventario") = value + End Set + End Property + Property GlobalDTAFCaracteristicasOpciones() As DataTable + Get + GlobalDTAFCaracteristicasOpciones = DirectCast(Application("GlobalDTAFCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAFCaracteristicasOpciones") = value + End Set + End Property + Property GlobalDTAFCaracteristicas() As DataTable + Get + GlobalDTAFCaracteristicas = DirectCast(Application("GlobalDTAFCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAFCaracteristicas") = value + End Set + End Property + Property GlobalDTAFCaracteristicasClasificaciones() As DataTable + Get + GlobalDTAFCaracteristicasClasificaciones = DirectCast(Application("GlobalDTAFCaracteristicasClasificaciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAFCaracteristicasClasificaciones") = value + End Set + End Property + Property GlobalDTImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTImpuestosLocales{0}", CveEmpresa) 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then @@ -1373,146 +1373,146 @@ Public Class ClsPaginas If ObjPS.GetPSImpuestosLocales(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados ObjPS.Dispose() - End If - Dim Str As New StringBuilder - If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) - If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) - - If CvePS > 0 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTImpuestosLocales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTImpuestosLocales = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) + End If + Dim Str As New StringBuilder + If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) + If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) + + If CvePS > 0 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTImpuestosLocales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTImpuestosLocales = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTImpuestosLocales{0}", CveEmpresa) Application(AppNombre) = value 'Dim ObjPS As New ClsProductosServicios 'If ObjPS.GetPSImpuestosLocales(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados - 'ObjPS.Dispose() - End Set - End Property - 'Bancos - Property GlobalDTBancos() As DataTable - Get - GlobalDTBancos = DirectCast(Application("GlobalDTBancos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTBancos") = value - End Set - End Property - 'Property GlobalDTBancosCuentas(CveUsuario As Integer) As DataTable - ' Get - ' Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) - ' If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario ={1}", Str, CveUsuario) - - ' Dim Dv As New DataView(DirectCast(Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) - ' GlobalDTBancosCuentas = Dv.ToTable - ' Dv.Dispose() - - ' End Get - ' Set(value As DataTable) - ' Application("GlobalDTBancosCuentas") = value - ' End Set - 'End Property - Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1) As DataTable - Get - - Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) - If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario = {1}", Str, CveUsuario) - If CveCuenta > -1 Then Str = String.Format("{0} AND CveCuenta = {1}", Str, CveCuenta) - If Estatus > -1 Then Str = String.Format("{0} AND Estatus = '{1}'", Str, If(Estatus = 1, "Activo", "Inactivo")) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) - GlobalDTBancosCuentas = Dv.ToTable - Dv.Dispose() - 'GlobalDTBancosCuentas = DirectCast(Application("GlobalDTBancosCuentas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTBancosCuentas") = value - End Set - End Property - Property GlobalDTTipoTransacciones() As DataTable - Get - If UsuarioActual.CveEmpresa = 66 Then - GlobalDTTipoTransacciones = DirectCast(Application("GlobalDTTipoTransacciones"), DataTable).FiltraParametros("Estatus = 1") - Else - GlobalDTTipoTransacciones = DirectCast(Application("GlobalDTTipoTransacciones"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTTipoTransacciones") = value - End Set - End Property - Property GlobalDTBancosEstatusIE() As DataTable - Get - GlobalDTBancosEstatusIE = DirectCast(Application("GlobalDTBancosEstatusIE"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTBancosEstatusIE") = value - End Set - End Property - Property GlobalDTBancosIE() As DataTable - Get - GlobalDTBancosIE = DirectCast(Application("GlobalDTBancosIE"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTBancosIE") = value - End Set - End Property - Property GlobalDTTipoCuenta() As DataTable - Get - GlobalDTTipoCuenta = DirectCast(Application("GlobalDTTipoCuenta"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTipoCuenta") = value - End Set - End Property - 'Fin Bancos - - 'Fin EstadoCIvil - 'TipoPerioso - Property GlobalDTTipoPeriodo() As DataTable - Get - GlobalDTTipoPeriodo = DirectCast(Application("GlobalDTTipoPeriodo"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTipoPeriodo") = value - End Set - End Property - 'Fin TipoPeriodo - - 'Periodos - Property GlobalDTNominasPeriodos(CveTipoPeriodo As Integer, CvePeriodo As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveTipoPeriodo <> -1 Then Str.AppendFormat(" {0} CveTipoPeriodo = {1}", If(Str.Length > 0, "AND", ""), CveTipoPeriodo) - If CvePeriodo <> -1 Then Str.AppendFormat(" {0} CvePeriodo = {1}", If(Str.Length > 0, "AND", ""), CvePeriodo) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTNominasPeriodos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTNominasPeriodos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTNominasPeriodos = DirectCast(Application("GlobalDTNominasPeriodos"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTNominasPeriodos") = value - End Set - End Property - 'Fin Periodos - - 'Fin Ruta - 'Cliente - Property GlobalDTCliente(CveEmpresa As Integer, Optional Estatus As Integer = 1, Optional CveCliente As Integer = -1) As DataTable + 'ObjPS.Dispose() + End Set + End Property + 'Bancos + Property GlobalDTBancos() As DataTable + Get + GlobalDTBancos = DirectCast(Application("GlobalDTBancos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTBancos") = value + End Set + End Property + 'Property GlobalDTBancosCuentas(CveUsuario As Integer) As DataTable + ' Get + ' Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) + ' If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario ={1}", Str, CveUsuario) + + ' Dim Dv As New DataView(DirectCast(Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) + ' GlobalDTBancosCuentas = Dv.ToTable + ' Dv.Dispose() + + ' End Get + ' Set(value As DataTable) + ' Application("GlobalDTBancosCuentas") = value + ' End Set + 'End Property + Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1) As DataTable + Get + + Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) + If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario = {1}", Str, CveUsuario) + If CveCuenta > -1 Then Str = String.Format("{0} AND CveCuenta = {1}", Str, CveCuenta) + If Estatus > -1 Then Str = String.Format("{0} AND Estatus = '{1}'", Str, If(Estatus = 1, "Activo", "Inactivo")) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) + GlobalDTBancosCuentas = Dv.ToTable + Dv.Dispose() + 'GlobalDTBancosCuentas = DirectCast(Application("GlobalDTBancosCuentas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTBancosCuentas") = value + End Set + End Property + Property GlobalDTTipoTransacciones() As DataTable + Get + If UsuarioActual.CveEmpresa = 66 Then + GlobalDTTipoTransacciones = DirectCast(Application("GlobalDTTipoTransacciones"), DataTable).FiltraParametros("Estatus = 1") + Else + GlobalDTTipoTransacciones = DirectCast(Application("GlobalDTTipoTransacciones"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTTipoTransacciones") = value + End Set + End Property + Property GlobalDTBancosEstatusIE() As DataTable + Get + GlobalDTBancosEstatusIE = DirectCast(Application("GlobalDTBancosEstatusIE"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTBancosEstatusIE") = value + End Set + End Property + Property GlobalDTBancosIE() As DataTable + Get + GlobalDTBancosIE = DirectCast(Application("GlobalDTBancosIE"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTBancosIE") = value + End Set + End Property + Property GlobalDTTipoCuenta() As DataTable + Get + GlobalDTTipoCuenta = DirectCast(Application("GlobalDTTipoCuenta"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTipoCuenta") = value + End Set + End Property + 'Fin Bancos + + 'Fin EstadoCIvil + 'TipoPerioso + Property GlobalDTTipoPeriodo() As DataTable + Get + GlobalDTTipoPeriodo = DirectCast(Application("GlobalDTTipoPeriodo"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTipoPeriodo") = value + End Set + End Property + 'Fin TipoPeriodo + + 'Periodos + Property GlobalDTNominasPeriodos(CveTipoPeriodo As Integer, CvePeriodo As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveTipoPeriodo <> -1 Then Str.AppendFormat(" {0} CveTipoPeriodo = {1}", If(Str.Length > 0, "AND", ""), CveTipoPeriodo) + If CvePeriodo <> -1 Then Str.AppendFormat(" {0} CvePeriodo = {1}", If(Str.Length > 0, "AND", ""), CvePeriodo) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTNominasPeriodos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTNominasPeriodos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTNominasPeriodos = DirectCast(Application("GlobalDTNominasPeriodos"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTNominasPeriodos") = value + End Set + End Property + 'Fin Periodos + + 'Fin Ruta + 'Cliente + Property GlobalDTCliente(CveEmpresa As Integer, Optional Estatus As Integer = 1, Optional CveCliente As Integer = -1) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTCliente{0}", CveEmpresa) - 'sino existe, recarga los datos + 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjClientes As New ClsClientes If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, Estatus:=-1) Then Application(AppNombre) = ObjClientes.DtResultados @@ -1520,10 +1520,10 @@ Public Class ClsPaginas End If - If CveEmpresa <> -1 Then - - Dim StrSQL As New StringBuilder - StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEmpresa <> -1 Then + + Dim StrSQL As New StringBuilder + StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) If Estatus >= 0 Then StrSQL.AppendFormat(" AND EstatusBool = {0} ", Estatus) If CveCliente >= 0 Then StrSQL.AppendFormat(" AND CveCliente = {0} ", CveCliente) @@ -1531,143 +1531,143 @@ Public Class ClsPaginas GlobalDTCliente = Dv.ToTable Dv.Dispose() - Else - GlobalDTCliente = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) + Else + GlobalDTCliente = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTCliente{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTClienteClasificaciones(CveEmpresa As Integer) As DataTable - Get + End Set + End Property + Property GlobalDTClienteClasificaciones(CveEmpresa As Integer) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTClienteClasificaciones{0}", CveEmpresa) - 'sino existe, recarga los datos + 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjClientes As New ClsClientes If ObjClientes.GetClienteClasificacion(CveEmpresa) Then Application(AppNombre) = ObjClientes.DtResultados ObjClientes.Dispose() - End If - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTClienteClasificaciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClienteClasificaciones = DirectCast(Application(AppNombre), DataTable) - End If - End Get + End If + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTClienteClasificaciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClienteClasificaciones = DirectCast(Application(AppNombre), DataTable) + End If + End Get Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTClienteClasificaciones{0}", CveEmpresa) Application(AppNombre) = value - End Set - End Property - Property GlobalDTEstatusOrdenServicios(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTEstatusOrdenServicios"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTEstatusOrdenServicios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEstatusOrdenServicios = DirectCast(Application("GlobalDTEstatusOrdenServicios"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTEstatusOrdenServicios") = value - End Set - End Property - 'Variables para Ventas - Property GlobalDTVendedores(CveEmpresa As Integer, Optional Estatus As Boolean = True, Optional VendedorTipo As Integer = 1) As DataTable - Get + End Set + End Property + Property GlobalDTEstatusOrdenServicios(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTEstatusOrdenServicios"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTEstatusOrdenServicios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEstatusOrdenServicios = DirectCast(Application("GlobalDTEstatusOrdenServicios"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTEstatusOrdenServicios") = value + End Set + End Property + 'Variables para Ventas + Property GlobalDTVendedores(CveEmpresa As Integer, Optional Estatus As Boolean = True, Optional VendedorTipo As Integer = 1) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTVendedores{0}", CveEmpresa) - 'sino existe, recarga los datos + 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjVendedores As New ClsVtaVendedores If ObjVendedores.GetVendedores(-1) Then Application(AppNombre) = ObjVendedores.DtResultados ObjVendedores.Dispose() - End If - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0} AND CveEstatus = {1} AND VendedorTipo = {2}", CveEmpresa, If(Estatus, 1, 0), VendedorTipo), "", DataViewRowState.CurrentRows) - GlobalDTVendedores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTVendedores = DirectCast(Application(AppNombre), DataTable) - End If - End Get - Set(value As DataTable) - Dim AppNombre As String = String.Format("GlobalDTVendedores{0}", CveEmpresa) - Application(AppNombre) = value - End Set - End Property - Property GlobalDTClientesCorporativo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTClientesCorporativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTClientesCorporativo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClientesCorporativo = DirectCast(Application("GlobalDTClientesCorporativo"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTClientesCorporativo") = value - End Set - End Property - Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable - Get + End If + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0} AND CveEstatus = {1} AND VendedorTipo = {2}", CveEmpresa, If(Estatus, 1, 0), VendedorTipo), "", DataViewRowState.CurrentRows) + GlobalDTVendedores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTVendedores = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) + Dim AppNombre As String = String.Format("GlobalDTVendedores{0}", CveEmpresa) + Application(AppNombre) = value + End Set + End Property + Property GlobalDTClientesCorporativo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTClientesCorporativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTClientesCorporativo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClientesCorporativo = DirectCast(Application("GlobalDTClientesCorporativo"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTClientesCorporativo") = value + End Set + End Property + Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTCompProveedores{0}", CveEmpresa) - 'sino existe, recarga los datos + 'sino existe, recarga los datos If Application(AppNombre) Is Nothing Then Dim ObjProveedores As New ClsCompProveedores If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaGlobalDT, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then Application(AppNombre) = ObjProveedores.DtResultados ObjProveedores.Dispose() End If - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTCompProveedores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTCompProveedores = DirectCast(Application(AppNombre), DataTable) - End If - - End Get - Set(value As DataTable) + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTCompProveedores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTCompProveedores = DirectCast(Application(AppNombre), DataTable) + End If + + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTCompProveedores{0}", CveEmpresa) Application(AppNombre) = value 'Dim ObjProveedores As New ClsCompProveedores 'If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaGlobalDT, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then Application(AppNombre) = ObjProveedores.DtResultados - 'ObjProveedores.Dispose() - End Set - End Property - 'EstatusFactura - Property GlobalDTCompEstatusFactura() As DataTable - Get - GlobalDTCompEstatusFactura = DirectCast(Application("GlobalDTCompEstatusFactura"), DataTable).FiltraParametros("Estatus = 'Activo'") - End Get - Set(value As DataTable) - Application("GlobalDTCompEstatusFactura") = value - End Set - End Property - Property GlobalDTContratosSecciones() As DataTable - Get - GlobalDTContratosSecciones = DirectCast(Application("GlobalDTContratosSecciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTContratosSecciones") = value - End Set - End Property - Property GlobalDTContratos() As DataTable - Get - GlobalDTContratos = DirectCast(Application("GlobalDTContratos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTContratos") = value - End Set - End Property - Property GlobalDTContratosTipos(CveEmpresa As Integer) As DataTable - Get + 'ObjProveedores.Dispose() + End Set + End Property + 'EstatusFactura + Property GlobalDTCompEstatusFactura() As DataTable + Get + GlobalDTCompEstatusFactura = DirectCast(Application("GlobalDTCompEstatusFactura"), DataTable).FiltraParametros("Estatus = 'Activo'") + End Get + Set(value As DataTable) + Application("GlobalDTCompEstatusFactura") = value + End Set + End Property + Property GlobalDTContratosSecciones() As DataTable + Get + GlobalDTContratosSecciones = DirectCast(Application("GlobalDTContratosSecciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTContratosSecciones") = value + End Set + End Property + Property GlobalDTContratos() As DataTable + Get + GlobalDTContratos = DirectCast(Application("GlobalDTContratos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTContratos") = value + End Set + End Property + Property GlobalDTContratosTipos(CveEmpresa As Integer) As DataTable + Get Dim AppNombre As String = String.Format("GlobalDTContratosTipos{0}", CveEmpresa) 'sino existe, recarga los datos @@ -1679,1605 +1679,1605 @@ Public Class ClsPaginas GlobalDTContratosTipos = DirectCast(Application(AppNombre), DataTable) - End Get - Set(value As DataTable) + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTContratosTipos{0}", CveEmpresa) - Application(AppNombre) = value - End Set - End Property - Property GlobalDTTipoAlmacen(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoAlmacen = DirectCast(Application("GlobalDTTipoAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTTipoAlmacen") = value - End Set - End Property - Property GlobalDTInvConceptos() As DataTable - Get - - Return DirectCast(Application("GlobalDTInvConceptos"), DataTable) - - End Get - Set(value As DataTable) - Application("GlobalDTInvConceptos") = value - End Set - End Property - Property GlobalDTSeccionAlmacen(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTSeccionAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTSeccionAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSeccionAlmacen = DirectCast(Application("GlobalDTSeccionAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTSeccionAlmacen") = value - End Set - End Property - Property GlobalDTAlmacen(CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = -1, Optional CveEstatus As Integer = 1) As DataTable - Get + Application(AppNombre) = value + End Set + End Property + Property GlobalDTTipoAlmacen(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoAlmacen = DirectCast(Application("GlobalDTTipoAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTTipoAlmacen") = value + End Set + End Property + Property GlobalDTInvConceptos() As DataTable + Get + + Return DirectCast(Application("GlobalDTInvConceptos"), DataTable) + + End Get + Set(value As DataTable) + Application("GlobalDTInvConceptos") = value + End Set + End Property + Property GlobalDTSeccionAlmacen(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTSeccionAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTSeccionAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSeccionAlmacen = DirectCast(Application("GlobalDTSeccionAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTSeccionAlmacen") = value + End Set + End Property + Property GlobalDTAlmacen(CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = -1, Optional CveEstatus As Integer = 1) As DataTable + Get If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat(" CveEmpresa = {0} ", CveEmpresa) - If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) - If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTAlmacen"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAlmacen = DirectCast(Application("GlobalDTAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAlmacen") = value - End Set - End Property - Property GlobalDTAlmacenUsuarios(CveUsuario As Integer, CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = 1, Optional CveEstatus As Integer = 1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveUsuario = {0} AND CveEmpresa = {1} ", CveUsuario, CveEmpresa) - If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) - If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTAlmacenUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTAlmacenUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAlmacenUsuarios = DirectCast(Application("GlobalDTAlmacenUsuarios"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAlmacenUsuarios") = value - End Set - End Property - Property GlobalDTNom_Periodos() As DataTable - Get - GlobalDTNom_Periodos = DirectCast(Application("GlobalDTNom_Periodos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTNom_Periodos") = value - End Set - End Property - Public Property GlobalDTVtaFormaPago() As DataTable - Get - GlobalDTVtaFormaPago = DirectCast(Application("GlobalDTVtaFormaPago"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTVtaFormaPago") = value - End Set - End Property - Property GlobalDTVtaMetodoPago() As DataTable - Get - GlobalDTVtaMetodoPago = DirectCast(Application("GlobalDTVtaMetodoPago"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTVtaMetodoPago") = value - End Set - End Property - Property GlobalDTVtaTiposRelacion() As DataTable - Get - GlobalDTVtaTiposRelacion = DirectCast(Application("GlobalDTVtaTiposRelacion"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTVtaTiposRelacion") = value - End Set - End Property - Property GlobalDTTiposDocumentos() As DataTable - Get - GlobalDTTiposDocumentos = DirectCast(Application("GlobalDTTiposDocumentos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTiposDocumentos") = value - End Set - End Property - Property GlobalDTCobranzaEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTVtaCobranzaEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTCobranzaEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTCobranzaEstatus = DirectCast(Application("GlobalDTVtaCobranzaEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTVtaCobranzaEstatus") = value - End Set - End Property - - -#Region "***********************************************************************DT EVENTOS****************************************************************************************" - Property GlobalDTTiposEventos() As DataTable - Get - GlobalDTTiposEventos = DirectCast(Application("GlobalDTTiposEventos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTiposEventos") = value - End Set - End Property - - Property GlobalDTEventos() As DataTable - Get - GlobalDTEventos = DirectCast(Application("GlobalDTEventos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEventos") = value - End Set - End Property - - Property GlobalDTOIEventoTarea() As DataTable - Get - GlobalDTOIEventoTarea = DirectCast(Application("GlobalDTOIEventoTarea"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTOIEventoTarea") = value - End Set - End Property - - Property GlobalDTOIEstatusEventos() As DataTable - Get - GlobalDTOIEstatusEventos = DirectCast(Application("GlobalDTOIEstatusEventos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTOIEstatusEventos") = value - End Set - End Property -#End Region - -#Region " **********************************************************************DT PROSPECTOS*************************************************************************************" - Property GlobalDTProspectosCaracteristicasClasificaciones() As DataTable - Get - GlobalDTProspectosCaracteristicasClasificaciones = DirectCast(Application("GlobalDTProspectosCaracteristicasClasificaciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTProspectosCaracteristicasClasificaciones") = value - End Set - End Property - Property GlobalDTProspectosTiposCaracteristicas() As DataTable - Get - GlobalDTProspectosTiposCaracteristicas = DirectCast(Application("GlobalDTProspectosTiposCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTProspectosTiposCaracteristicas") = value - End Set - End Property - Property GlobalDTProspectosCaracteristicas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosCaracteristicas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosCaracteristicas = DirectCast(Application("GlobalDTProspectosCaracteristicas"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosCaracteristicas") = value - End Set - End Property - - Property GlobalDTProspectosCaracteristicasOpciones() As DataTable - Get - GlobalDTProspectosCaracteristicasOpciones = DirectCast(Application("GlobalDTProspectosCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTProspectosCaracteristicasOpciones") = value - End Set - End Property -#End Region - -#Region "***********************************************************************DT ACTIVOS FIJOS**********************************************************************************" - Property GlobalDTActivoFijos(CveEmpresa As Integer, Optional CveSubTipoActivoFijo As Integer = -1, Optional CveActivoFijo As Integer = -1) As DataTable - Get - Dim dt As DataTable = Nothing - 'Dim Str As New StringBuilder - 'Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - 'If CveSubTipoActivoFijo <> -1 Then Str.AppendFormat(" AND CveSubTipoActivoFijo = {0}", CveSubTipoActivoFijo) - - Dim ObjAF As New ClsAF - 'If ObjAF.GetActivosFijos(CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, -1, "-1", -1, -1, -1, -1, -1) Then - If ObjAF.GetActivosFijos(CveActivoFijo, CveEmpresa, "-1", "-1", -1, CveSubTipoActivoFijo, "-1", -1, -1, -1, -1, -1, "", -1) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTActivoFijos = dt - - End Get - Set(ByVal value As DataTable) - Application("GlobalDTActivoFijos") = value - End Set - End Property - Property GlobalDTEstadoActivoFijo() As DataTable - Get - GlobalDTEstadoActivoFijo = DirectCast(Application("GlobalDTEstadoActivoFijo"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEstadoActivoFijo") = value - End Set - End Property - Property GlobalDTMarcaActivoFijo(CveEmpresa As Integer) As DataTable - Get - Dim dt As DataTable = Nothing - - Dim ObjAF As New ClsAF - - If ObjAF.GetMarcasActivosFijos(CveEmpresa) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTMarcaActivoFijo = dt - End Get - Set(value As DataTable) - Application("GlobalDTMarcaActivoFijo") = value - End Set - End Property - Property GlobalDTModeloActivoFijo(CveEmpresa As Integer, CveMarca As Integer) As DataTable - Get - Dim dt As DataTable = Nothing - - Dim ObjAF As New ClsAF - - If ObjAF.GetModelosActivosFijos(CveEmpresa, CveMarca) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTModeloActivoFijo = dt - End Get - Set(value As DataTable) - Application("GlobalDTModeloActivoFijo") = value - End Set - End Property - - Property GlobalDTSubTipoActivoFijo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTSubTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTSubTipoActivoFijo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSubTipoActivoFijo = DirectCast(Application("GlobalDTSubTipoActivoFijo"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTSubTipoActivoFijo") = value - End Set - End Property - Property GlobalDTTipoActivoFijo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoActivoFijo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoActivoFijo = DirectCast(Application("GlobalDTTipoActivoFijo"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTTipoActivoFijo") = value - End Set - End Property - -#End Region - -#Region "***********************************************************************DT GENERALES**************************************************************************************" - Property GlobalDTGralPaises() As DataTable - Get - GlobalDTGralPaises = DirectCast(Application("GlobalDTGralPaises"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTGralPaises") = value - End Set - End Property - Property GlobalDTGralEstados(CvePais As Integer) As DataTable - Get - GlobalDTGralEstados = DirectCast(Application("GlobalDTGralEstados"), DataTable).FiltraParametros(String.Format("CvePais ={0}", CvePais)) - End Get - Set(value As DataTable) - Application("GlobalDTGralEstados") = value - End Set - End Property - Property GlobalDTGralMunicipios(CveEstado As Integer) As DataTable - Get - GlobalDTGralMunicipios = DirectCast(Application("GlobalDTGralMunicipios"), DataTable).FiltraParametros(String.Format("CveEstado ={0}", CveEstado)) - End Get - Set(value As DataTable) - Application("GlobalDTGralMunicipios") = value - End Set - End Property - - Property GlobalDTGralPoblaciones() As DataTable - Get - GlobalDTGralPoblaciones = DirectCast(Application("GlobalDTGralPoblaciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTGralPoblaciones") = value - End Set - End Property - Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralCategorias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralCategorias = DirectCast(Application("GlobalDTGralCategorias"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTGralCategorias") = value - End Set - End Property - Property GlobalDTGralCategorias2(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTCategorias2"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralCategorias2 = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralCategorias2 = DirectCast(Application("GlobalDTCategorias2"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTCategorias2") = value - End Set - End Property - - Property GlobalDTGralEscolaridades() As DataTable - Get - GlobalDTGralEscolaridades = DirectCast(Application("GlobalDTGralEscolaridades"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTGralEscolaridades") = value - End Set - End Property - - Property GlobalDTGralColectivas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTGralColectivas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralColectivas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralColectivas = DirectCast(Application("GlobalDTGralColectivas"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTGralColectivas") = value - End Set - End Property - -#End Region - -#Region "***********************************************************************DT PROSPECTOS*************************************************************************************" - Property GlobalDTProspectosSupervisores(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSupervisores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSupervisores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSupervisores = DirectCast(Application("GlobalDTProspectosSupervisores"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosSupervisores") = value - End Set - End Property - Property GlobalDTProspectosCoordinadores(CveSupervisor As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveSupervisor <> -1 Then Str.AppendFormat(" {0} CveSupervisor = {1}", If(Str.Length > 0, "AND", ""), CveSupervisor) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosCoordinadores"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosCoordinadores = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosCoordinadores = DirectCast(Application("GlobalDTProspectosCoordinadores"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosCoordinadores") = value - End Set - End Property - Property GlobalDTProspectosApoyos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosApoyos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosApoyos = DirectCast(Application("GlobalDTProspectosApoyos"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosApoyos") = value - End Set - End Property - Property GlobalDTProspectosClasificaciones(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosClasificaciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosClasificaciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosClasificaciones = DirectCast(Application("GlobalDTProspectosClasificaciones"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosClasificaciones") = value - End Set - End Property - Property GlobalDTProspectosEventosTipo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEventosTipo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosEventosTipo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEventosTipo = DirectCast(Application("GlobalDTProspectosEventosTipo"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosEventosTipo") = value - End Set - End Property - Property GlobalDTProspectosEvento(CveEventoTipo As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEventoTipo <> -1 Then Str.AppendFormat(" {0} CveEventoTipo = {1}", If(Str.Length > 0, "AND", ""), CveEventoTipo) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEvento"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEvento = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEvento = DirectCast(Application("GlobalDTProspectosEvento"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosEvento") = value - End Set - End Property - Property GlobalDTProspectosEstatus(CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEstatus"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEstatus = DirectCast(Application("GlobalDTProspectosEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosEstatus") = value - End Set - End Property - Property GlobalDTProspectosApoyosTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosApoyosTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosApoyosTipos = DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosApoyosTipos") = value - End Set - End Property - Property GlobalDTProspectosApoyosTipos() As DataTable - Get - GlobalDTProspectosApoyosTipos = DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTProspectosApoyosTipos") = value - End Set - End Property - Property GlobalDTProspectosEncuestas(CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestas = DirectCast(Application("GlobalDTProspectosEncuestas"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosEncuestas") = value - End Set - End Property - Property GlobalDTProspectosEncuestasPreguntas(CveEncuesta As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) - - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestasPreguntas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestasPreguntas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestasPreguntas = DirectCast(Application("GlobalDTProspectosEncuestasPreguntas"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosEncuestasPreguntas") = value - End Set - End Property - Property GlobalDTProspectosEncuestasRespuestas(CvePregunta As Integer, CveEncuesta As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) - If CvePregunta <> -1 Then Str.AppendFormat(" {0} CvePregunta = {1}", If(Str.Length > 0, "AND", ""), CvePregunta) - - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestasRespuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestasRespuestas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestasRespuestas = DirectCast(Application("GlobalDTProspectosEncuestasRespuestas"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosEncuestasRespuestas") = value - End Set - End Property - Property GlobalDTProspectosTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosTipos = DirectCast(Application("GlobalDTProspectosTipos"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosTipos") = value - End Set - End Property - -#Region " DT PROSPECTOS SOLICITUDES" - Property GlobalDTProspectosSolicitudes(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudes"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudes = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudes = DirectCast(Application("GlobalDTProspectosSolicitudes"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosSolicitudes") = value - End Set - End Property - Property GlobalDTProspectosSolicitudesEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesEstatus = DirectCast(Application("GlobalDTProspectosSolicitudesEstatus"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosSolicitudesEstatus") = value - End Set - End Property - Property GlobalDTProspectosSolicitudesTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesTipos = DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable) - End If - End Get - - Set(value As DataTable) - Application("GlobalDTProspectosSolicitudesTipos") = value - End Set - End Property - 'Property GlobalDTProspectosSolicitudesTipos() As DataTable - ' Get - ' GlobalDTProspectosSolicitudesTipos = DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable) - ' End Get - ' Set(value As DataTable) - ' Application("GlobalDTProspectosSolicitudesTipos") = value - ' End Set - 'End Property - Property GlobalDTProspectosSolicitudesApoyos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesApoyos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesApoyos = DirectCast(Application("GlobalDTProspectosSolicitudesApoyos"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTProspectosSolicitudesApoyos") = value - End Set - End Property - -#End Region -#End Region - -#Region "**********************************************DT AMORTIZACIÓN CONTABLE PLAN DE DESARROLLO********************************************************************************" - -#Region "***********************************************************************DT AMORTIZACIÓN CONTABLE*********************************************************************************************" - - Property GlobalDTAC_RubrosIngreso() As DataTable - Get - GlobalDTAC_RubrosIngreso = DirectCast(Application("GlobalDTAC_RubrosIngreso"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_RubrosIngreso") = value - End Set - End Property - Property GlobalDTAC_FuentesRecaudacion(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_FuentesRecaudacion"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_FuentesRecaudacion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_FuentesRecaudacion = DirectCast(Application("GlobalDTAC_FuentesRecaudacion"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_FuentesRecaudacion") = value - End Set - End Property - - Property GlobalDTAC_FuentesFinanciamiento() As DataTable - Get - GlobalDTAC_FuentesFinanciamiento = DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_FuentesFinanciamiento") = value - End Set - End Property - Property GlobalDTAC_OG() As DataTable - Get - GlobalDTAC_OG = DirectCast(Application("GlobalDTAC_OG"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_OG") = value - End Set - End Property - 'Property GlobalDTAC_ClasificadorOG(CveEmpresa As Integer) As DataTable - ' Get - ' If CveEmpresa <> -1 Then - ' Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - ' Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificadorOG"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - ' GlobalDTAC_ClasificadorOG = Dv.ToTable - ' Dv.Dispose() - ' Else - ' GlobalDTAC_ClasificadorOG = DirectCast(Application("GlobalDTAC_ClasificadorOG"), DataTable) - ' End If - ' End Get - ' Set(value As DataTable) - ' Application("GlobalDTAC_ClasificadorOG") = value - ' End Set - 'End Property - Property GlobalDTAC_Ubicaciones() As DataTable - Get - GlobalDTAC_Ubicaciones = DirectCast(Application("GlobalDTAC_Ubicaciones"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_Ubicaciones") = value - End Set - End Property - Property GlobalDTAC_UnidadesAdministrativas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_UnidadesAdministrativas"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_UnidadesAdministrativas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_UnidadesAdministrativas = DirectCast(Application("GlobalDTAC_UnidadesAdministrativas"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_UnidadesAdministrativas") = value - End Set - End Property - Property GlobalDTAC_ClasificacionFuncional(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionFuncional"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionFuncional = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionFuncional = DirectCast(Application("GlobalDTAC_ClasificacionFuncional"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_ClasificacionFuncional") = value - End Set - End Property - Property GlobalDTAC_ClasificacionGeografica(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionGeografica"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionGeografica = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionGeografica = DirectCast(Application("GlobalDTAC_ClasificacionGeografica"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_ClasificacionGeografica") = value - End Set - End Property - Property GlobalDTAC_Cuentas() As DataTable - Get - GlobalDTAC_Cuentas = DirectCast(Application("GlobalDTAC_Cuentas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_Cuentas") = value - End Set - End Property - Property GlobalDTAC_Finalidad() As DataTable - Get - GlobalDTAC_Finalidad = DirectCast(Application("GlobalDTAC_Finalidad"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_Finalidad") = value - End Set - End Property - 'Property GlobalDTAC_FuenteFinanciamiento() As DataTable - ' Get - ' GlobalDTAC_FuenteFinanciamiento = DirectCast(Application("GlobalDTAC_FuenteFinanciamiento"), DataTable) - ' End Get - ' Set(value As DataTable) - ' Application("GlobalDTAC_FuenteFinanciamiento") = value - ' End Set - 'End Property - Property GlobalDTAC_FuentesFinanciamiento(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_FuentesFinanciamiento = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_FuentesFinanciamiento = DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_FuentesFinanciamiento") = value - End Set - End Property - Property GlobalDTAC_FuentesFinanciamientoCONAC() As DataTable - Get - GlobalDTAC_FuentesFinanciamientoCONAC = DirectCast(Application("GlobalDTAC_FuentesFinanciamientoCONAC"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_FuentesFinanciamientoCONAC") = value - End Set - End Property - Property GlobalDTAC_Funcion() As DataTable - Get - GlobalDTAC_Funcion = DirectCast(Application("GlobalDTAC_Funcion"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_Funcion") = value - End Set - End Property - Property GlobalDTAC_Programas() As DataTable - Get - GlobalDTAC_Programas = DirectCast(Application("GlobalDTAC_Programas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_Programas") = value - End Set - End Property - Property GlobalDTAC_ProgramasCONAC() As DataTable - Get - GlobalDTAC_ProgramasCONAC = DirectCast(Application("GlobalDTAC_ProgramasCONAC"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_ProgramasCONAC") = value - End Set - End Property - Property GlobalDTAC_ProyectosProceso() As DataTable - Get - GlobalDTAC_ProyectosProceso = DirectCast(Application("GlobalDTAC_ProyectosProceso"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_ProyectosProceso") = value - End Set - End Property - Property GlobalDTAC_SubFuncion() As DataTable - Get - GlobalDTAC_SubFuncion = DirectCast(Application("GlobalDTAC_SubFuncion"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_SubFuncion") = value - End Set - End Property - Property GlobalDTAC_SubProgramas() As DataTable - Get - GlobalDTAC_SubProgramas = DirectCast(Application("GlobalDTAC_SubProgramas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_SubProgramas") = value - End Set - End Property - Property GlobalDTAC_ClasificacionAdministrativa(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionAdministrativa = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionAdministrativa = DirectCast(Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_ClasificacionAdministrativa") = value - End Set - End Property - Property GlobalDTAC_TipoGasto() As DataTable - Get - GlobalDTAC_TipoGasto = DirectCast(Application("GlobalDTAC_TipoGasto"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_TipoGasto") = value - End Set - End Property - - Property GlobalDTAC_ProgramaOperativo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ProgramaOperativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ProgramaOperativo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ProgramaOperativo = DirectCast(Application("GlobalDTAC_ProgramaOperativo"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTAC_ProgramaOperativo") = value - End Set - End Property - - Property GlobalDTAC_MatrizIngresos() As DataTable - Get - GlobalDTAC_MatrizIngresos = DirectCast(Application("GlobalDTAC_MatrizIngresos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_MatrizIngresos") = value - End Set - End Property - - Property GlobalDTAC_MatrizEgresos() As DataTable - Get - GlobalDTAC_MatrizEgresos = DirectCast(Application("GlobalDTAC_MatrizEgresos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAC_MatrizEgresos") = value - End Set - End Property - - -#End Region - - Property GlobalDTAC_PD_EjeRector(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_EjeRector"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_EjeRector = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_EjeRector = DirectCast(Application("GlobalDTAC_PD_EjeRector"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAC_PD_EjeRector") = value - End Set - End Property - - Property GlobalDTAC_PD_Programas(CveEjeRector As Integer) As DataTable - Get - If CveEjeRector <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Programas"), DataTable), String.Format("CveEjeRector = {0}", CveEjeRector), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Programas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Programas = DirectCast(Application("GlobalDTAC_PD_Programas"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAC_PD_Programas") = value - End Set - End Property - - Property GlobalDTAC_PD_Estrategias(CveProgramas As Integer) As DataTable - Get - If CveProgramas <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Estrategias"), DataTable), String.Format("CvePrograma = {0}", CveProgramas), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Estrategias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Estrategias = DirectCast(Application("GlobalDTAC_PD_Estrategias"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAC_PD_Estrategias") = value - End Set - End Property - - Property GlobalDTAC_PD_LineasAccion(CveEstrategias As Integer) As DataTable - Get - If CveEstrategias <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_LineasAccion"), DataTable), String.Format("CveEstrategia = {0}", CveEstrategias), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_LineasAccion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_LineasAccion = DirectCast(Application("GlobalDTAC_PD_LineasAccion"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAC_PD_LineasAccion") = value - End Set - End Property - - Property GlobalDTAC_PD_Metas(CveLineasAccion As Integer) As DataTable - Get - If CveLineasAccion <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Metas"), DataTable), String.Format("CveLineaAccion = {0}", CveLineasAccion), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Metas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Metas = DirectCast(Application("GlobalDTAC_PD_Metas"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTAC_PD_Metas") = value - End Set - End Property -#End Region - -#Region "***********************************************************************GLOBAL DT ORDENES DE COMPRA***********************************************************************" - Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTOCEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOCEstatus = DirectCast(Application("GlobalDTOCEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTOCEstatus") = value - End Set - End Property - Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable - Get - If CveEmpresa <> -1 Then - Dim filtro As New StringBuilder - filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa) - If CveUsuario > 0 Then - filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario) - End If - If Tipo <> "" Then - filtro.AppendFormat(" AND Tipo='{0}'", Tipo) - End If - Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) - GlobalDTOCEstatusUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOCEstatusUsuarios = DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTOCEstatusUsuarios") = value - End Set - End Property - - -#End Region - -#Region "F I N A N Z A S " - Property GlobalDTFinan_RazonesFinancieras() As DataTable - Get - GlobalDTFinan_RazonesFinancieras = DirectCast(Application("GlobalDTFinan_RazonesFinancieras"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTFinan_RazonesFinancieras") = value - End Set - End Property -#End Region - - -#Region "***********************************************************************GLOBAL DT CONTABILIDAD****************************************************************************" - Property GlobalDTContaPlantillasPolizas(CveEmpresa As Integer, Optional TipoPlantilla As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Or TipoPlantilla <> -1 Then - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If TipoPlantilla <> -1 Then Str.AppendFormat(" AND TipoPlantilla = {0}", TipoPlantilla) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTContaPlantillasPolizas"), DataTable), Str.ToString.Substring(5), "", DataViewRowState.CurrentRows) - GlobalDTContaPlantillasPolizas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaPlantillasPolizas = DirectCast(Application("GlobalDTContaPlantillasPolizas"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTContaPlantillasPolizas") = value - End Set - End Property - - Property GlobalDTContaPlantillasPolizasDetalle(CvePlantillaPoliza As Integer) As DataTable - Get - If CvePlantillaPoliza <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) - GlobalDTContaPlantillasPolizasDetalle = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaPlantillasPolizasDetalle = DirectCast(Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTContaPlantillasPolizasDetalle") = value - End Set - End Property - - - - Property GlobalDTContaConceptosContables(CvePlantillaPoliza As Integer) As DataTable - Get - If CvePlantillaPoliza <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTContaConceptosContables"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) - GlobalDTContaConceptosContables = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaConceptosContables = DirectCast(Application("GlobalDTContaConceptosContables"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTContaConceptosContables") = value - End Set - End Property -#End Region - -#Region "**********************************************************************GLOBAL DT RH (RECURSOS HUMANOS)********************************************************************" - Property GlobalDTAsistenciaDetalle() As DataTable - Get - GlobalDTAsistenciaDetalle = DirectCast(Application("GlobalDTAsistenciaDetalle"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAsistenciaDetalle") = value - End Set - End Property - Property GlobalDTAsistenciasInasistencias() As DataTable - Get - GlobalDTAsistenciasInasistencias = DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAsistenciasInasistencias") = value - End Set - End Property - Property GlobalDTEstatusPersonal() As DataTable - Get - GlobalDTEstatusPersonal = DirectCast(Application("GlobalDTEstatusPersonal"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEstatusPersonal") = value - End Set - End Property - + Dim Str As New StringBuilder + Str.AppendFormat(" CveEmpresa = {0} ", CveEmpresa) + If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) + If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTAlmacen"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAlmacen = DirectCast(Application("GlobalDTAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAlmacen") = value + End Set + End Property + Property GlobalDTAlmacenUsuarios(CveUsuario As Integer, CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = 1, Optional CveEstatus As Integer = 1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveUsuario = {0} AND CveEmpresa = {1} ", CveUsuario, CveEmpresa) + If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) + If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTAlmacenUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTAlmacenUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAlmacenUsuarios = DirectCast(Application("GlobalDTAlmacenUsuarios"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAlmacenUsuarios") = value + End Set + End Property + Property GlobalDTNom_Periodos() As DataTable + Get + GlobalDTNom_Periodos = DirectCast(Application("GlobalDTNom_Periodos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTNom_Periodos") = value + End Set + End Property + Public Property GlobalDTVtaFormaPago() As DataTable + Get + GlobalDTVtaFormaPago = DirectCast(Application("GlobalDTVtaFormaPago"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTVtaFormaPago") = value + End Set + End Property + Property GlobalDTVtaMetodoPago() As DataTable + Get + GlobalDTVtaMetodoPago = DirectCast(Application("GlobalDTVtaMetodoPago"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTVtaMetodoPago") = value + End Set + End Property + Property GlobalDTVtaTiposRelacion() As DataTable + Get + GlobalDTVtaTiposRelacion = DirectCast(Application("GlobalDTVtaTiposRelacion"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTVtaTiposRelacion") = value + End Set + End Property + Property GlobalDTTiposDocumentos() As DataTable + Get + GlobalDTTiposDocumentos = DirectCast(Application("GlobalDTTiposDocumentos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTiposDocumentos") = value + End Set + End Property + Property GlobalDTCobranzaEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTVtaCobranzaEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTCobranzaEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTCobranzaEstatus = DirectCast(Application("GlobalDTVtaCobranzaEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTVtaCobranzaEstatus") = value + End Set + End Property + + +#Region "***********************************************************************DT EVENTOS****************************************************************************************" + Property GlobalDTTiposEventos() As DataTable + Get + GlobalDTTiposEventos = DirectCast(Application("GlobalDTTiposEventos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTiposEventos") = value + End Set + End Property + + Property GlobalDTEventos() As DataTable + Get + GlobalDTEventos = DirectCast(Application("GlobalDTEventos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEventos") = value + End Set + End Property + + Property GlobalDTOIEventoTarea() As DataTable + Get + GlobalDTOIEventoTarea = DirectCast(Application("GlobalDTOIEventoTarea"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTOIEventoTarea") = value + End Set + End Property + + Property GlobalDTOIEstatusEventos() As DataTable + Get + GlobalDTOIEstatusEventos = DirectCast(Application("GlobalDTOIEstatusEventos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTOIEstatusEventos") = value + End Set + End Property +#End Region + +#Region " **********************************************************************DT PROSPECTOS*************************************************************************************" + Property GlobalDTProspectosCaracteristicasClasificaciones() As DataTable + Get + GlobalDTProspectosCaracteristicasClasificaciones = DirectCast(Application("GlobalDTProspectosCaracteristicasClasificaciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTProspectosCaracteristicasClasificaciones") = value + End Set + End Property + Property GlobalDTProspectosTiposCaracteristicas() As DataTable + Get + GlobalDTProspectosTiposCaracteristicas = DirectCast(Application("GlobalDTProspectosTiposCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTProspectosTiposCaracteristicas") = value + End Set + End Property + Property GlobalDTProspectosCaracteristicas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosCaracteristicas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosCaracteristicas = DirectCast(Application("GlobalDTProspectosCaracteristicas"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosCaracteristicas") = value + End Set + End Property + + Property GlobalDTProspectosCaracteristicasOpciones() As DataTable + Get + GlobalDTProspectosCaracteristicasOpciones = DirectCast(Application("GlobalDTProspectosCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTProspectosCaracteristicasOpciones") = value + End Set + End Property +#End Region + +#Region "***********************************************************************DT ACTIVOS FIJOS**********************************************************************************" + Property GlobalDTActivoFijos(CveEmpresa As Integer, Optional CveSubTipoActivoFijo As Integer = -1, Optional CveActivoFijo As Integer = -1) As DataTable + Get + Dim dt As DataTable = Nothing + 'Dim Str As New StringBuilder + 'Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + 'If CveSubTipoActivoFijo <> -1 Then Str.AppendFormat(" AND CveSubTipoActivoFijo = {0}", CveSubTipoActivoFijo) + + Dim ObjAF As New ClsAF + 'If ObjAF.GetActivosFijos(CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, -1, "-1", -1, -1, -1, -1, -1) Then + If ObjAF.GetActivosFijos(CveActivoFijo, CveEmpresa, "-1", "-1", -1, CveSubTipoActivoFijo, "-1", -1, -1, -1, -1, -1, "", -1) Then + dt = ObjAF.DtResultados + End If + + ObjAF.Dispose() + GlobalDTActivoFijos = dt + + End Get + Set(ByVal value As DataTable) + Application("GlobalDTActivoFijos") = value + End Set + End Property + Property GlobalDTEstadoActivoFijo() As DataTable + Get + GlobalDTEstadoActivoFijo = DirectCast(Application("GlobalDTEstadoActivoFijo"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEstadoActivoFijo") = value + End Set + End Property + Property GlobalDTMarcaActivoFijo(CveEmpresa As Integer) As DataTable + Get + Dim dt As DataTable = Nothing + + Dim ObjAF As New ClsAF + + If ObjAF.GetMarcasActivosFijos(CveEmpresa) Then + dt = ObjAF.DtResultados + End If + + ObjAF.Dispose() + GlobalDTMarcaActivoFijo = dt + End Get + Set(value As DataTable) + Application("GlobalDTMarcaActivoFijo") = value + End Set + End Property + Property GlobalDTModeloActivoFijo(CveEmpresa As Integer, CveMarca As Integer) As DataTable + Get + Dim dt As DataTable = Nothing + + Dim ObjAF As New ClsAF + + If ObjAF.GetModelosActivosFijos(CveEmpresa, CveMarca) Then + dt = ObjAF.DtResultados + End If + + ObjAF.Dispose() + GlobalDTModeloActivoFijo = dt + End Get + Set(value As DataTable) + Application("GlobalDTModeloActivoFijo") = value + End Set + End Property + + Property GlobalDTSubTipoActivoFijo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTSubTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTSubTipoActivoFijo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSubTipoActivoFijo = DirectCast(Application("GlobalDTSubTipoActivoFijo"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTSubTipoActivoFijo") = value + End Set + End Property + Property GlobalDTTipoActivoFijo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoActivoFijo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoActivoFijo = DirectCast(Application("GlobalDTTipoActivoFijo"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTTipoActivoFijo") = value + End Set + End Property + +#End Region + +#Region "***********************************************************************DT GENERALES**************************************************************************************" + Property GlobalDTGralPaises() As DataTable + Get + GlobalDTGralPaises = DirectCast(Application("GlobalDTGralPaises"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTGralPaises") = value + End Set + End Property + Property GlobalDTGralEstados(CvePais As Integer) As DataTable + Get + GlobalDTGralEstados = DirectCast(Application("GlobalDTGralEstados"), DataTable).FiltraParametros(String.Format("CvePais ={0}", CvePais)) + End Get + Set(value As DataTable) + Application("GlobalDTGralEstados") = value + End Set + End Property + Property GlobalDTGralMunicipios(CveEstado As Integer) As DataTable + Get + GlobalDTGralMunicipios = DirectCast(Application("GlobalDTGralMunicipios"), DataTable).FiltraParametros(String.Format("CveEstado ={0}", CveEstado)) + End Get + Set(value As DataTable) + Application("GlobalDTGralMunicipios") = value + End Set + End Property + + Property GlobalDTGralPoblaciones() As DataTable + Get + GlobalDTGralPoblaciones = DirectCast(Application("GlobalDTGralPoblaciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTGralPoblaciones") = value + End Set + End Property + Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralCategorias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralCategorias = DirectCast(Application("GlobalDTGralCategorias"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTGralCategorias") = value + End Set + End Property + Property GlobalDTGralCategorias2(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTCategorias2"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralCategorias2 = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralCategorias2 = DirectCast(Application("GlobalDTCategorias2"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTCategorias2") = value + End Set + End Property + + Property GlobalDTGralEscolaridades() As DataTable + Get + GlobalDTGralEscolaridades = DirectCast(Application("GlobalDTGralEscolaridades"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTGralEscolaridades") = value + End Set + End Property + + Property GlobalDTGralColectivas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTGralColectivas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralColectivas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralColectivas = DirectCast(Application("GlobalDTGralColectivas"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTGralColectivas") = value + End Set + End Property + +#End Region + +#Region "***********************************************************************DT PROSPECTOS*************************************************************************************" + Property GlobalDTProspectosSupervisores(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSupervisores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSupervisores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSupervisores = DirectCast(Application("GlobalDTProspectosSupervisores"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosSupervisores") = value + End Set + End Property + Property GlobalDTProspectosCoordinadores(CveSupervisor As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveSupervisor <> -1 Then Str.AppendFormat(" {0} CveSupervisor = {1}", If(Str.Length > 0, "AND", ""), CveSupervisor) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosCoordinadores"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosCoordinadores = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosCoordinadores = DirectCast(Application("GlobalDTProspectosCoordinadores"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosCoordinadores") = value + End Set + End Property + Property GlobalDTProspectosApoyos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosApoyos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosApoyos = DirectCast(Application("GlobalDTProspectosApoyos"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosApoyos") = value + End Set + End Property + Property GlobalDTProspectosClasificaciones(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosClasificaciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosClasificaciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosClasificaciones = DirectCast(Application("GlobalDTProspectosClasificaciones"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosClasificaciones") = value + End Set + End Property + Property GlobalDTProspectosEventosTipo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEventosTipo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosEventosTipo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEventosTipo = DirectCast(Application("GlobalDTProspectosEventosTipo"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosEventosTipo") = value + End Set + End Property + Property GlobalDTProspectosEvento(CveEventoTipo As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEventoTipo <> -1 Then Str.AppendFormat(" {0} CveEventoTipo = {1}", If(Str.Length > 0, "AND", ""), CveEventoTipo) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEvento"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEvento = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEvento = DirectCast(Application("GlobalDTProspectosEvento"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosEvento") = value + End Set + End Property + Property GlobalDTProspectosEstatus(CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEstatus"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEstatus = DirectCast(Application("GlobalDTProspectosEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosEstatus") = value + End Set + End Property + Property GlobalDTProspectosApoyosTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosApoyosTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosApoyosTipos = DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosApoyosTipos") = value + End Set + End Property + Property GlobalDTProspectosApoyosTipos() As DataTable + Get + GlobalDTProspectosApoyosTipos = DirectCast(Application("GlobalDTProspectosApoyosTipos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTProspectosApoyosTipos") = value + End Set + End Property + Property GlobalDTProspectosEncuestas(CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestas = DirectCast(Application("GlobalDTProspectosEncuestas"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosEncuestas") = value + End Set + End Property + Property GlobalDTProspectosEncuestasPreguntas(CveEncuesta As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) + + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestasPreguntas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestasPreguntas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestasPreguntas = DirectCast(Application("GlobalDTProspectosEncuestasPreguntas"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosEncuestasPreguntas") = value + End Set + End Property + Property GlobalDTProspectosEncuestasRespuestas(CvePregunta As Integer, CveEncuesta As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) + If CvePregunta <> -1 Then Str.AppendFormat(" {0} CvePregunta = {1}", If(Str.Length > 0, "AND", ""), CvePregunta) + + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosEncuestasRespuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestasRespuestas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestasRespuestas = DirectCast(Application("GlobalDTProspectosEncuestasRespuestas"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosEncuestasRespuestas") = value + End Set + End Property + Property GlobalDTProspectosTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosTipos = DirectCast(Application("GlobalDTProspectosTipos"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosTipos") = value + End Set + End Property + +#Region " DT PROSPECTOS SOLICITUDES" + Property GlobalDTProspectosSolicitudes(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudes"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudes = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudes = DirectCast(Application("GlobalDTProspectosSolicitudes"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosSolicitudes") = value + End Set + End Property + Property GlobalDTProspectosSolicitudesEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesEstatus = DirectCast(Application("GlobalDTProspectosSolicitudesEstatus"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosSolicitudesEstatus") = value + End Set + End Property + Property GlobalDTProspectosSolicitudesTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesTipos = DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable) + End If + End Get + + Set(value As DataTable) + Application("GlobalDTProspectosSolicitudesTipos") = value + End Set + End Property + 'Property GlobalDTProspectosSolicitudesTipos() As DataTable + ' Get + ' GlobalDTProspectosSolicitudesTipos = DirectCast(Application("GlobalDTProspectosSolicitudesTipos"), DataTable) + ' End Get + ' Set(value As DataTable) + ' Application("GlobalDTProspectosSolicitudesTipos") = value + ' End Set + 'End Property + Property GlobalDTProspectosSolicitudesApoyos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTProspectosSolicitudesApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesApoyos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesApoyos = DirectCast(Application("GlobalDTProspectosSolicitudesApoyos"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTProspectosSolicitudesApoyos") = value + End Set + End Property + +#End Region +#End Region + +#Region "**********************************************DT AMORTIZACIÓN CONTABLE PLAN DE DESARROLLO********************************************************************************" + +#Region "***********************************************************************DT AMORTIZACIÓN CONTABLE*********************************************************************************************" + + Property GlobalDTAC_RubrosIngreso() As DataTable + Get + GlobalDTAC_RubrosIngreso = DirectCast(Application("GlobalDTAC_RubrosIngreso"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_RubrosIngreso") = value + End Set + End Property + Property GlobalDTAC_FuentesRecaudacion(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_FuentesRecaudacion"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_FuentesRecaudacion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_FuentesRecaudacion = DirectCast(Application("GlobalDTAC_FuentesRecaudacion"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_FuentesRecaudacion") = value + End Set + End Property + + Property GlobalDTAC_FuentesFinanciamiento() As DataTable + Get + GlobalDTAC_FuentesFinanciamiento = DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_FuentesFinanciamiento") = value + End Set + End Property + Property GlobalDTAC_OG() As DataTable + Get + GlobalDTAC_OG = DirectCast(Application("GlobalDTAC_OG"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_OG") = value + End Set + End Property + 'Property GlobalDTAC_ClasificadorOG(CveEmpresa As Integer) As DataTable + ' Get + ' If CveEmpresa <> -1 Then + ' Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + ' Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificadorOG"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + ' GlobalDTAC_ClasificadorOG = Dv.ToTable + ' Dv.Dispose() + ' Else + ' GlobalDTAC_ClasificadorOG = DirectCast(Application("GlobalDTAC_ClasificadorOG"), DataTable) + ' End If + ' End Get + ' Set(value As DataTable) + ' Application("GlobalDTAC_ClasificadorOG") = value + ' End Set + 'End Property + Property GlobalDTAC_Ubicaciones() As DataTable + Get + GlobalDTAC_Ubicaciones = DirectCast(Application("GlobalDTAC_Ubicaciones"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_Ubicaciones") = value + End Set + End Property + Property GlobalDTAC_UnidadesAdministrativas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_UnidadesAdministrativas"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_UnidadesAdministrativas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_UnidadesAdministrativas = DirectCast(Application("GlobalDTAC_UnidadesAdministrativas"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_UnidadesAdministrativas") = value + End Set + End Property + Property GlobalDTAC_ClasificacionFuncional(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionFuncional"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionFuncional = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionFuncional = DirectCast(Application("GlobalDTAC_ClasificacionFuncional"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_ClasificacionFuncional") = value + End Set + End Property + Property GlobalDTAC_ClasificacionGeografica(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionGeografica"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionGeografica = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionGeografica = DirectCast(Application("GlobalDTAC_ClasificacionGeografica"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_ClasificacionGeografica") = value + End Set + End Property + Property GlobalDTAC_Cuentas() As DataTable + Get + GlobalDTAC_Cuentas = DirectCast(Application("GlobalDTAC_Cuentas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_Cuentas") = value + End Set + End Property + Property GlobalDTAC_Finalidad() As DataTable + Get + GlobalDTAC_Finalidad = DirectCast(Application("GlobalDTAC_Finalidad"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_Finalidad") = value + End Set + End Property + 'Property GlobalDTAC_FuenteFinanciamiento() As DataTable + ' Get + ' GlobalDTAC_FuenteFinanciamiento = DirectCast(Application("GlobalDTAC_FuenteFinanciamiento"), DataTable) + ' End Get + ' Set(value As DataTable) + ' Application("GlobalDTAC_FuenteFinanciamiento") = value + ' End Set + 'End Property + Property GlobalDTAC_FuentesFinanciamiento(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_FuentesFinanciamiento = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_FuentesFinanciamiento = DirectCast(Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_FuentesFinanciamiento") = value + End Set + End Property + Property GlobalDTAC_FuentesFinanciamientoCONAC() As DataTable + Get + GlobalDTAC_FuentesFinanciamientoCONAC = DirectCast(Application("GlobalDTAC_FuentesFinanciamientoCONAC"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_FuentesFinanciamientoCONAC") = value + End Set + End Property + Property GlobalDTAC_Funcion() As DataTable + Get + GlobalDTAC_Funcion = DirectCast(Application("GlobalDTAC_Funcion"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_Funcion") = value + End Set + End Property + Property GlobalDTAC_Programas() As DataTable + Get + GlobalDTAC_Programas = DirectCast(Application("GlobalDTAC_Programas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_Programas") = value + End Set + End Property + Property GlobalDTAC_ProgramasCONAC() As DataTable + Get + GlobalDTAC_ProgramasCONAC = DirectCast(Application("GlobalDTAC_ProgramasCONAC"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_ProgramasCONAC") = value + End Set + End Property + Property GlobalDTAC_ProyectosProceso() As DataTable + Get + GlobalDTAC_ProyectosProceso = DirectCast(Application("GlobalDTAC_ProyectosProceso"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_ProyectosProceso") = value + End Set + End Property + Property GlobalDTAC_SubFuncion() As DataTable + Get + GlobalDTAC_SubFuncion = DirectCast(Application("GlobalDTAC_SubFuncion"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_SubFuncion") = value + End Set + End Property + Property GlobalDTAC_SubProgramas() As DataTable + Get + GlobalDTAC_SubProgramas = DirectCast(Application("GlobalDTAC_SubProgramas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_SubProgramas") = value + End Set + End Property + Property GlobalDTAC_ClasificacionAdministrativa(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionAdministrativa = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionAdministrativa = DirectCast(Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_ClasificacionAdministrativa") = value + End Set + End Property + Property GlobalDTAC_TipoGasto() As DataTable + Get + GlobalDTAC_TipoGasto = DirectCast(Application("GlobalDTAC_TipoGasto"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_TipoGasto") = value + End Set + End Property + + Property GlobalDTAC_ProgramaOperativo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_ProgramaOperativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ProgramaOperativo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ProgramaOperativo = DirectCast(Application("GlobalDTAC_ProgramaOperativo"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTAC_ProgramaOperativo") = value + End Set + End Property + + Property GlobalDTAC_MatrizIngresos() As DataTable + Get + GlobalDTAC_MatrizIngresos = DirectCast(Application("GlobalDTAC_MatrizIngresos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_MatrizIngresos") = value + End Set + End Property + + Property GlobalDTAC_MatrizEgresos() As DataTable + Get + GlobalDTAC_MatrizEgresos = DirectCast(Application("GlobalDTAC_MatrizEgresos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAC_MatrizEgresos") = value + End Set + End Property + + +#End Region + + Property GlobalDTAC_PD_EjeRector(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_EjeRector"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_EjeRector = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_EjeRector = DirectCast(Application("GlobalDTAC_PD_EjeRector"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAC_PD_EjeRector") = value + End Set + End Property + + Property GlobalDTAC_PD_Programas(CveEjeRector As Integer) As DataTable + Get + If CveEjeRector <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Programas"), DataTable), String.Format("CveEjeRector = {0}", CveEjeRector), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Programas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Programas = DirectCast(Application("GlobalDTAC_PD_Programas"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAC_PD_Programas") = value + End Set + End Property + + Property GlobalDTAC_PD_Estrategias(CveProgramas As Integer) As DataTable + Get + If CveProgramas <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Estrategias"), DataTable), String.Format("CvePrograma = {0}", CveProgramas), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Estrategias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Estrategias = DirectCast(Application("GlobalDTAC_PD_Estrategias"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAC_PD_Estrategias") = value + End Set + End Property + + Property GlobalDTAC_PD_LineasAccion(CveEstrategias As Integer) As DataTable + Get + If CveEstrategias <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_LineasAccion"), DataTable), String.Format("CveEstrategia = {0}", CveEstrategias), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_LineasAccion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_LineasAccion = DirectCast(Application("GlobalDTAC_PD_LineasAccion"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAC_PD_LineasAccion") = value + End Set + End Property + + Property GlobalDTAC_PD_Metas(CveLineasAccion As Integer) As DataTable + Get + If CveLineasAccion <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTAC_PD_Metas"), DataTable), String.Format("CveLineaAccion = {0}", CveLineasAccion), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Metas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Metas = DirectCast(Application("GlobalDTAC_PD_Metas"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTAC_PD_Metas") = value + End Set + End Property +#End Region + +#Region "***********************************************************************GLOBAL DT ORDENES DE COMPRA***********************************************************************" + Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTOCEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOCEstatus = DirectCast(Application("GlobalDTOCEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTOCEstatus") = value + End Set + End Property + Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable + Get + If CveEmpresa <> -1 Then + Dim filtro As New StringBuilder + filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa) + If CveUsuario > 0 Then + filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario) + End If + If Tipo <> "" Then + filtro.AppendFormat(" AND Tipo='{0}'", Tipo) + End If + Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) + GlobalDTOCEstatusUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOCEstatusUsuarios = DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTOCEstatusUsuarios") = value + End Set + End Property + + +#End Region + +#Region "F I N A N Z A S " + Property GlobalDTFinan_RazonesFinancieras() As DataTable + Get + GlobalDTFinan_RazonesFinancieras = DirectCast(Application("GlobalDTFinan_RazonesFinancieras"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTFinan_RazonesFinancieras") = value + End Set + End Property +#End Region + + +#Region "***********************************************************************GLOBAL DT CONTABILIDAD****************************************************************************" + Property GlobalDTContaPlantillasPolizas(CveEmpresa As Integer, Optional TipoPlantilla As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Or TipoPlantilla <> -1 Then + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If TipoPlantilla <> -1 Then Str.AppendFormat(" AND TipoPlantilla = {0}", TipoPlantilla) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTContaPlantillasPolizas"), DataTable), Str.ToString.Substring(5), "", DataViewRowState.CurrentRows) + GlobalDTContaPlantillasPolizas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaPlantillasPolizas = DirectCast(Application("GlobalDTContaPlantillasPolizas"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTContaPlantillasPolizas") = value + End Set + End Property + + Property GlobalDTContaPlantillasPolizasDetalle(CvePlantillaPoliza As Integer) As DataTable + Get + If CvePlantillaPoliza <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) + GlobalDTContaPlantillasPolizasDetalle = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaPlantillasPolizasDetalle = DirectCast(Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTContaPlantillasPolizasDetalle") = value + End Set + End Property + + + + Property GlobalDTContaConceptosContables(CvePlantillaPoliza As Integer) As DataTable + Get + If CvePlantillaPoliza <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTContaConceptosContables"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) + GlobalDTContaConceptosContables = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaConceptosContables = DirectCast(Application("GlobalDTContaConceptosContables"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTContaConceptosContables") = value + End Set + End Property +#End Region + +#Region "**********************************************************************GLOBAL DT RH (RECURSOS HUMANOS)********************************************************************" + Property GlobalDTAsistenciaDetalle() As DataTable + Get + GlobalDTAsistenciaDetalle = DirectCast(Application("GlobalDTAsistenciaDetalle"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAsistenciaDetalle") = value + End Set + End Property + Property GlobalDTAsistenciasInasistencias() As DataTable + Get + GlobalDTAsistenciasInasistencias = DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAsistenciasInasistencias") = value + End Set + End Property + Property GlobalDTEstatusPersonal() As DataTable + Get + GlobalDTEstatusPersonal = DirectCast(Application("GlobalDTEstatusPersonal"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEstatusPersonal") = value + End Set + End Property + Property GlobalDTRHPersonal(CveEmpresa As Integer, Optional CvePersonal As Integer = -1) As DataTable - Get - Dim AppNombre As String = String.Format("GlobalDTRHPersonal{0}", CveEmpresa) - 'sino existe, recarga los datos + Get + Dim AppNombre As String = String.Format("GlobalDTRHPersonal{0}", CveEmpresa) + 'sino existe, recarga los datos If DirectCast(Application(AppNombre), DataTable) Is Nothing Then Dim ObjPersonal As New ClsRH If ObjPersonal.GetPersonal(-1, CveEmpresa) Then Application(AppNombre) = ObjPersonal.DtResultados ObjPersonal.Dispose() End If - If CveEmpresa <> -1 Or CvePersonal <> -1 Then + If CveEmpresa <> -1 Or CvePersonal <> -1 Then Dim Str As StringBuilder = New StringBuilder() If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) If CvePersonal <> -1 Then Str.AppendFormat(" {0} CvePersonal = {1}", If(Str.Length > 0, "AND", ""), CvePersonal) - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTRHPersonal = Dv.ToTable - Dv.Dispose() - Else - GlobalDTRHPersonal = DirectCast(Application(AppNombre), DataTable) - End If - - End Get - Set(value As DataTable) + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTRHPersonal = Dv.ToTable + Dv.Dispose() + Else + GlobalDTRHPersonal = DirectCast(Application(AppNombre), DataTable) + End If + + End Get + Set(value As DataTable) Dim AppNombre As String = String.Format("GlobalDTRHPersonal{0}", CveEmpresa) Application(AppNombre) = value End Set - End Property - - - Property GlobalDTDepartamentos() As DataTable - Get - GlobalDTDepartamentos = DirectCast(Application("GlobalDTDepartamentos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTDepartamentos") = value - End Set - End Property - Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTRHPuestos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTRHPuestos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTRHPuestos = DirectCast(Application("GlobalDTRHPuestos"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTRHPuestos") = value - End Set - End Property - Property GlobalDTEscolaridad() As DataTable - Get - GlobalDTEscolaridad = DirectCast(Application("GlobalDTEscolaridad"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEscolaridad") = value - End Set - End Property - Property GlobalDTEstadoCivil() As DataTable - Get - GlobalDTEstadoCivil = DirectCast(Application("GlobalDTEstadoCivil"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTEstadoCivil") = value - End Set - End Property - Property GlobalDTDocumentos() As DataTable - Get - GlobalDTDocumentos = DirectCast(Application("GlobalDTDocumentos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTDocumentos") = value - End Set - End Property - Property GlobalDTGenero() As DataTable - Get - GlobalDTGenero = DirectCast(Application("GlobalDTGenero"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTGenero") = value - End Set - End Property - Property GlobalDTMotivoBaja() As DataTable - Get - GlobalDTMotivoBaja = DirectCast(Application("GlobalDTMotivoBaja"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMotivoBaja") = value - End Set - End Property - Property GlobalDTTiposContrato() As DataTable - Get - GlobalDTTiposContrato = DirectCast(Application("GlobalDTTiposContrato"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTiposContrato") = value - End Set - End Property - Property GlobalDTRutas() As DataTable - Get - GlobalDTRutas = DirectCast(Application("GlobalDTRutas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTRutas") = value - End Set - End Property - Property GlobalDTTurno() As DataTable - Get - GlobalDTTurno = DirectCast(Application("GlobalDTTurno"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTurno") = value - End Set - End Property - Property GlobalDTJornadas() As DataTable - Get - GlobalDTJornadas = DirectCast(Application("GlobalDTJornadas"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTJornadas") = value - End Set - End Property - Property GlobalDTMotivosHorasExtras() As DataTable - Get - GlobalDTMotivosHorasExtras = DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMotivosHorasExtras") = value - End Set - End Property - Property GlobalDTTipoBuzon() As DataTable - Get - GlobalDTTipoBuzon = DirectCast(Application("GlobalDTTipoBuzon"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTipoBuzon") = value - End Set - End Property -#End Region - -#Region "*********** D T - C O M B U S T I B L E S ***********" - - - - Property GlobalDTCombustibles(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As New StringBuilder - StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTCombustibles"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTCombustibles = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTCombustibles = DirectCast(Application("GlobalDTCombustibles"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTCombustibles") = value - End Set - End Property - - Property GlobalDTCombustiblesTipos(Optional CveCombustibleTipo As Integer = -1) As DataTable - Get - - If CveCombustibleTipo <> -1 Then - - Dim StrSQL As New StringBuilder - If CveCombustibleTipo <> -1 Then StrSQL.AppendFormat("CveCombustibleTipo = {0}", CveCombustibleTipo) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTCombustiblesTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTCombustiblesTipos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTCombustiblesTipos = DirectCast(Application("GlobalDTCombustiblesTipos"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - Application("GlobalDTCombustiblesTipos") = value - End Set - End Property -#End Region - -#Region "*********** D T - M A N T E N I M I E N T O S ***********" - - Property GlobalDTMantenimientosTipos() As DataTable - Get - GlobalDTMantenimientosTipos = DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMantenimientosTipos") = value - End Set - End Property - - Property GlobalDTMantenimientos() As DataTable - Get - GlobalDTMantenimientos = DirectCast(Application("GlobalDTMantenimientos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTMantenimientos") = value - End Set - End Property - - Property GlobalDTMantenimientosTipos(Optional CveMantenimientoTipo As Integer = -1) As DataTable - Get - - If CveMantenimientoTipo <> -1 Then - - Dim StrSQL As New StringBuilder - If CveMantenimientoTipo <> -1 Then StrSQL.AppendFormat("CveMantenimientoTipo = {0}", CveMantenimientoTipo) - - Dim Dv As New DataView(DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTMantenimientosTipos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTMantenimientosTipos = DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - - Application("GlobalDTMantenimientosTipos") = value - End Set - End Property - -#End Region - - -#Region "*********** D T - T A L L E R E S ***********" - - Property GlobalDTTalleresTipos() As DataTable - Get - GlobalDTTalleresTipos = DirectCast(Application("GlobalDTTalleresTipos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTalleresTipos") = value - End Set - End Property - - Property GlobalDTTalleres() As DataTable - Get - GlobalDTTalleres = DirectCast(Application("GlobalDTTalleres"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTTalleres") = value - End Set - End Property - -#End Region - -#Region "*********** D T - D I S T R I B U I D O R E S ***********" - - Property GlobalDTDistribuidoresTipos() As DataTable - Get - GlobalDTDistribuidoresTipos = DirectCast(Application("GlobalDTDistribuidoresTipos"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTDistribuidoresTipos") = value - End Set - End Property - - Property GlobalDTDistribuidores() As DataTable - Get - GlobalDTDistribuidores = DirectCast(Application("GlobalDTDistribuidores"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTDistribuidores") = value - End Set - End Property - -#End Region - - Public Class SisParametro - Public Property CveParametro As Integer - Public Property CveModulo As Integer - Public Property Descripcion As String - Public Property Cadena1 As String - Public Property Cadena2 As String - Public Property Numero1 As Integer - Public Property Numero2 As Integer - Public Property Fecha1 As DateTime - Public Property Fecha2 As DateTime - Public Property FechaVencimiento As DateTime - End Class - - ReadOnly Property GlobalDTParametros(CveParametro As SisParametros) As SisParametro - Get - - Dim dr As DataRow = DirectCast(Application("GlobalDTParametros"), DataTable).FiltroPrimero("CveParametro =" & CveParametro, "") - - If dr IsNot Nothing Then - Dim Par As New SisParametro - Par.CveParametro = dr("CveParametro").ToString.ToEntero - Par.CveModulo = dr("CveModulo").ToString.ToEntero - Par.Descripcion = dr("Descripcion").ToString - Par.Cadena1 = dr("StrValor1").ToString - Par.Cadena2 = dr("StrValor2").ToString - Par.Numero1 = dr("NumValor1").ToString.ToEntero - Par.Numero2 = dr("NumValor2").ToString.ToEntero - Par.Fecha1 = dr("DTValor1").ToString.ToDate - Par.Fecha2 = dr("DTValor2").ToString.ToDate - Par.FechaVencimiento = dr("FechaVencimiento").ToString.ToDate - GlobalDTParametros = Par - Else - GlobalDTParametros = Nothing - End If - - End Get - End Property - - Property GlobalDTOIRevision(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTOIRevision"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTOIRevision = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOIRevision = DirectCast(Application("GlobalDTOIRevision"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTOIRevision") = value - End Set - End Property - Property GlobalDTOIAgendaTipo() As DataTable - Get - GlobalDTOIAgendaTipo = DirectCast(Application("GlobalDTOIAgendaTipo"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTOIAgendaTipo") = value - End Set - End Property - Property GlobalDTOIAgenda() As DataTable - Get - GlobalDTOIAgenda = DirectCast(Application("GlobalDTOIAgenda"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTOIAgenda") = value - End Set - End Property - Property GlobalDTVtaCondicionesEntrega(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTVtaCondicionesEntrega"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTVtaCondicionesEntrega = Dv.ToTable - Dv.Dispose() - Else - GlobalDTVtaCondicionesEntrega = DirectCast(Application("GlobalDTVtaCondicionesEntrega"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTVtaCondicionesEntrega") = value - End Set - End Property - Property GlobalDTPaqueteriaGuiaTipos(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(Application("GlobalDTPaqueteriaGuiaTipos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTPaqueteriaGuiaTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTPaqueteriaGuiaTipos = DirectCast(Application("GlobalDTPaqueteriaGuiaTipos"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTPaqueteriaGuiaTipos") = value - End Set - End Property - Property GlobalDTClasificacionPorcentaje(CveEmpresa As Integer, Optional CveClasicacionPorcentaje As Integer = -1, Optional CveClasicacion As Integer = -1, - Optional PorcentajeIVA As Double = -1) As DataTable - - Get - Dim Str As StringBuilder = New StringBuilder() - If CveEmpresa <> -1 Or CveClasicacionPorcentaje <> -1 Or CveClasicacion <> -1 Or PorcentajeIVA <> -1 Then - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveClasicacionPorcentaje <> -1 Then Str.AppendFormat(" {0} CveClasicacionPorcentaje = {1}", If(Str.Length > 0, "AND", ""), CveClasicacionPorcentaje) - If CveClasicacion <> -1 Then Str.AppendFormat(" {0} CveClasicacion = {1}", If(Str.Length > 0, "AND", ""), CveClasicacion) - If PorcentajeIVA <> -1 Then Str.AppendFormat(" {0} PorcentajeIVA = {1}", If(Str.Length > 0, "AND", ""), PorcentajeIVA) - Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionPorcentaje"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTClasificacionPorcentaje = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionPorcentaje = DirectCast(Application("GlobalDTClasificacionPorcentaje"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTClasificacionPorcentaje") = value - End Set - End Property - Property GlobalDTPaqueterias() As DataTable - Get - GlobalDTPaqueterias = DirectCast(Application("GlobalDTPaqueterias"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTPaqueterias") = value - End Set - End Property - Property GlobalDTAcumTiposDefecto() As DataTable - Get - GlobalDTAcumTiposDefecto = DirectCast(Application("GlobalDTAcumTiposDefecto"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAcumTiposDefecto") = value - End Set - End Property - Property GlobalDTAcumTiposUso() As DataTable - Get - GlobalDTAcumTiposUso = DirectCast(Application("GlobalDTAcumTiposUso"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAcumTiposUso") = value - End Set End Property - Property GlobalDTAcumGarantiasMesesTipoUso(CveEmpresa As Integer, CveMarca As Integer) As DataTable + + Property GlobalDTDepartamentos() As DataTable + Get + GlobalDTDepartamentos = DirectCast(Application("GlobalDTDepartamentos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTDepartamentos") = value + End Set + End Property + Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTRHPuestos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTRHPuestos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTRHPuestos = DirectCast(Application("GlobalDTRHPuestos"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTRHPuestos") = value + End Set + End Property + Property GlobalDTEscolaridad() As DataTable + Get + GlobalDTEscolaridad = DirectCast(Application("GlobalDTEscolaridad"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEscolaridad") = value + End Set + End Property + Property GlobalDTEstadoCivil() As DataTable + Get + GlobalDTEstadoCivil = DirectCast(Application("GlobalDTEstadoCivil"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTEstadoCivil") = value + End Set + End Property + Property GlobalDTDocumentos() As DataTable + Get + GlobalDTDocumentos = DirectCast(Application("GlobalDTDocumentos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTDocumentos") = value + End Set + End Property + Property GlobalDTGenero() As DataTable + Get + GlobalDTGenero = DirectCast(Application("GlobalDTGenero"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTGenero") = value + End Set + End Property + Property GlobalDTMotivoBaja() As DataTable + Get + GlobalDTMotivoBaja = DirectCast(Application("GlobalDTMotivoBaja"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMotivoBaja") = value + End Set + End Property + Property GlobalDTTiposContrato() As DataTable + Get + GlobalDTTiposContrato = DirectCast(Application("GlobalDTTiposContrato"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTiposContrato") = value + End Set + End Property + Property GlobalDTRutas() As DataTable + Get + GlobalDTRutas = DirectCast(Application("GlobalDTRutas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTRutas") = value + End Set + End Property + Property GlobalDTTurno() As DataTable + Get + GlobalDTTurno = DirectCast(Application("GlobalDTTurno"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTurno") = value + End Set + End Property + Property GlobalDTJornadas() As DataTable + Get + GlobalDTJornadas = DirectCast(Application("GlobalDTJornadas"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTJornadas") = value + End Set + End Property + Property GlobalDTMotivosHorasExtras() As DataTable + Get + GlobalDTMotivosHorasExtras = DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMotivosHorasExtras") = value + End Set + End Property + Property GlobalDTTipoBuzon() As DataTable + Get + GlobalDTTipoBuzon = DirectCast(Application("GlobalDTTipoBuzon"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTipoBuzon") = value + End Set + End Property +#End Region + +#Region "*********** D T - C O M B U S T I B L E S ***********" + + + + Property GlobalDTCombustibles(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As New StringBuilder + StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTCombustibles"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTCombustibles = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTCombustibles = DirectCast(Application("GlobalDTCombustibles"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTCombustibles") = value + End Set + End Property + + Property GlobalDTCombustiblesTipos(Optional CveCombustibleTipo As Integer = -1) As DataTable + Get + + If CveCombustibleTipo <> -1 Then + + Dim StrSQL As New StringBuilder + If CveCombustibleTipo <> -1 Then StrSQL.AppendFormat("CveCombustibleTipo = {0}", CveCombustibleTipo) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTCombustiblesTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTCombustiblesTipos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTCombustiblesTipos = DirectCast(Application("GlobalDTCombustiblesTipos"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + Application("GlobalDTCombustiblesTipos") = value + End Set + End Property +#End Region + +#Region "*********** D T - M A N T E N I M I E N T O S ***********" + + Property GlobalDTMantenimientosTipos() As DataTable + Get + GlobalDTMantenimientosTipos = DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMantenimientosTipos") = value + End Set + End Property + + Property GlobalDTMantenimientos() As DataTable + Get + GlobalDTMantenimientos = DirectCast(Application("GlobalDTMantenimientos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTMantenimientos") = value + End Set + End Property + + Property GlobalDTMantenimientosTipos(Optional CveMantenimientoTipo As Integer = -1) As DataTable + Get + + If CveMantenimientoTipo <> -1 Then + + Dim StrSQL As New StringBuilder + If CveMantenimientoTipo <> -1 Then StrSQL.AppendFormat("CveMantenimientoTipo = {0}", CveMantenimientoTipo) + + Dim Dv As New DataView(DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTMantenimientosTipos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTMantenimientosTipos = DirectCast(Application("GlobalDTMantenimientosTipos"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + + Application("GlobalDTMantenimientosTipos") = value + End Set + End Property + +#End Region + + +#Region "*********** D T - T A L L E R E S ***********" + + Property GlobalDTTalleresTipos() As DataTable + Get + GlobalDTTalleresTipos = DirectCast(Application("GlobalDTTalleresTipos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTalleresTipos") = value + End Set + End Property + + Property GlobalDTTalleres() As DataTable + Get + GlobalDTTalleres = DirectCast(Application("GlobalDTTalleres"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTTalleres") = value + End Set + End Property + +#End Region + +#Region "*********** D T - D I S T R I B U I D O R E S ***********" + + Property GlobalDTDistribuidoresTipos() As DataTable + Get + GlobalDTDistribuidoresTipos = DirectCast(Application("GlobalDTDistribuidoresTipos"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTDistribuidoresTipos") = value + End Set + End Property + + Property GlobalDTDistribuidores() As DataTable + Get + GlobalDTDistribuidores = DirectCast(Application("GlobalDTDistribuidores"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTDistribuidores") = value + End Set + End Property + +#End Region + + Public Class SisParametro + Public Property CveParametro As Integer + Public Property CveModulo As Integer + Public Property Descripcion As String + Public Property Cadena1 As String + Public Property Cadena2 As String + Public Property Numero1 As Integer + Public Property Numero2 As Integer + Public Property Fecha1 As DateTime + Public Property Fecha2 As DateTime + Public Property FechaVencimiento As DateTime + End Class + + ReadOnly Property GlobalDTParametros(CveParametro As SisParametros) As SisParametro + Get + + Dim dr As DataRow = DirectCast(Application("GlobalDTParametros"), DataTable).FiltroPrimero("CveParametro =" & CveParametro, "") + + If dr IsNot Nothing Then + Dim Par As New SisParametro + Par.CveParametro = dr("CveParametro").ToString.ToEntero + Par.CveModulo = dr("CveModulo").ToString.ToEntero + Par.Descripcion = dr("Descripcion").ToString + Par.Cadena1 = dr("StrValor1").ToString + Par.Cadena2 = dr("StrValor2").ToString + Par.Numero1 = dr("NumValor1").ToString.ToEntero + Par.Numero2 = dr("NumValor2").ToString.ToEntero + Par.Fecha1 = dr("DTValor1").ToString.ToDate + Par.Fecha2 = dr("DTValor2").ToString.ToDate + Par.FechaVencimiento = dr("FechaVencimiento").ToString.ToDate + GlobalDTParametros = Par + Else + GlobalDTParametros = Nothing + End If + + End Get + End Property + + Property GlobalDTOIRevision(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTOIRevision"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTOIRevision = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOIRevision = DirectCast(Application("GlobalDTOIRevision"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTOIRevision") = value + End Set + End Property + Property GlobalDTOIAgendaTipo() As DataTable + Get + GlobalDTOIAgendaTipo = DirectCast(Application("GlobalDTOIAgendaTipo"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTOIAgendaTipo") = value + End Set + End Property + Property GlobalDTOIAgenda() As DataTable + Get + GlobalDTOIAgenda = DirectCast(Application("GlobalDTOIAgenda"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTOIAgenda") = value + End Set + End Property + Property GlobalDTVtaCondicionesEntrega(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTVtaCondicionesEntrega"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTVtaCondicionesEntrega = Dv.ToTable + Dv.Dispose() + Else + GlobalDTVtaCondicionesEntrega = DirectCast(Application("GlobalDTVtaCondicionesEntrega"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTVtaCondicionesEntrega") = value + End Set + End Property + Property GlobalDTPaqueteriaGuiaTipos(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(Application("GlobalDTPaqueteriaGuiaTipos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTPaqueteriaGuiaTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTPaqueteriaGuiaTipos = DirectCast(Application("GlobalDTPaqueteriaGuiaTipos"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTPaqueteriaGuiaTipos") = value + End Set + End Property + Property GlobalDTClasificacionPorcentaje(CveEmpresa As Integer, Optional CveClasicacionPorcentaje As Integer = -1, Optional CveClasicacion As Integer = -1, + Optional PorcentajeIVA As Double = -1) As DataTable + + Get + Dim Str As StringBuilder = New StringBuilder() + If CveEmpresa <> -1 Or CveClasicacionPorcentaje <> -1 Or CveClasicacion <> -1 Or PorcentajeIVA <> -1 Then + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveClasicacionPorcentaje <> -1 Then Str.AppendFormat(" {0} CveClasicacionPorcentaje = {1}", If(Str.Length > 0, "AND", ""), CveClasicacionPorcentaje) + If CveClasicacion <> -1 Then Str.AppendFormat(" {0} CveClasicacion = {1}", If(Str.Length > 0, "AND", ""), CveClasicacion) + If PorcentajeIVA <> -1 Then Str.AppendFormat(" {0} PorcentajeIVA = {1}", If(Str.Length > 0, "AND", ""), PorcentajeIVA) + Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificacionPorcentaje"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTClasificacionPorcentaje = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionPorcentaje = DirectCast(Application("GlobalDTClasificacionPorcentaje"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTClasificacionPorcentaje") = value + End Set + End Property + Property GlobalDTPaqueterias() As DataTable + Get + GlobalDTPaqueterias = DirectCast(Application("GlobalDTPaqueterias"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTPaqueterias") = value + End Set + End Property + Property GlobalDTAcumTiposDefecto() As DataTable + Get + GlobalDTAcumTiposDefecto = DirectCast(Application("GlobalDTAcumTiposDefecto"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAcumTiposDefecto") = value + End Set + End Property + Property GlobalDTAcumTiposUso() As DataTable + Get + GlobalDTAcumTiposUso = DirectCast(Application("GlobalDTAcumTiposUso"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAcumTiposUso") = value + End Set + End Property + + Property GlobalDTAcumGarantiasMesesTipoUso(CveEmpresa As Integer, CveMarca As Integer) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTAcumGarantiasMesesTipoUso{0}", CveEmpresa) If Application(AppNombre) Is Nothing Then @@ -3287,674 +3287,674 @@ Public Class ClsPaginas End If If CveMarca <> -1 Then - Dim Str As StringBuilder = New StringBuilder() + Dim Str As StringBuilder = New StringBuilder() If CveMarca <> -1 Then Str.AppendFormat("CveMarca = {0}", CveMarca) - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTAcumGarantiasMesesTipoUso = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAcumGarantiasMesesTipoUso = DirectCast(Application(AppNombre), DataTable) + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTAcumGarantiasMesesTipoUso = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAcumGarantiasMesesTipoUso = DirectCast(Application(AppNombre), DataTable) End If - End Get + End Get Set(value As DataTable) - Dim AppNombre As String = String.Format("GlobalDTAcumGarantiasMesesTipoUso{0}", CveEmpresa) - Application(AppNombre) = value - End Set + Dim AppNombre As String = String.Format("GlobalDTAcumGarantiasMesesTipoUso{0}", CveEmpresa) + Application(AppNombre) = value + End Set End Property - Property GlobalDTAcumTamaños() As DataTable - Get - GlobalDTAcumTamaños = DirectCast(Application("GlobalDTAcumTamaños"), DataTable) - End Get - Set(value As DataTable) - Application("GlobalDTAcumTamaños") = value - End Set - End Property - -#Region "GDT'S RASTREO" - Property GlobalDTDispositivos(CveCliente As Integer) As DataTable - Get - Dim Str As StringBuilder = New StringBuilder() - - If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) - - - If CveCliente <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTDispositivos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTDispositivos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTDispositivos = DirectCast(Application("GlobalDTDispositivos"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTDispositivos") = value - End Set - End Property - - Public Sub RecargaGlobalDTDispositivos(GPS As ClsGPS) - If GPS.DispositivosGet(-1, -1, -1, -1) Then - GlobalDTDispositivos(-1) = GPS.DtResultados - End If - End Sub - - Property GlobalDTDispositivosUsuarios(CveCliente As Integer, Optional CveUsuario As Integer = -1) As DataTable - Get - If Application("GlobalDTDispositivosUsuarios") Is Nothing Then - Dim ObjGPS As New ClsGPS - If ObjGPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then - Application("GlobalDTDispositivosUsuarios") = ObjGPS.DtResultados - End If - ObjGPS.Dispose() - End If - - Dim Str As StringBuilder = New StringBuilder() - - If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) - If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) - - - If CveUsuario <> -1 OrElse CveCliente <> -1 Then - Dim Dv As New DataView(DirectCast(Application("GlobalDTDispositivosUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTDispositivosUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTDispositivosUsuarios = DirectCast(Application("GlobalDTDispositivosUsuarios"), DataTable) - End If - - End Get - Set(value As DataTable) - Application("GlobalDTDispositivosUsuarios") = value - End Set - End Property - -#End Region -#End Region - - - Public Enum SisParametros As Integer - URL = 1 - DirectorioSitio = 2 - eFacturasCaptcha = 3 - - - - RutaEmpresasJM = 500 - RutaEmpresasRM = 501 - RutaEmpresasPC = 502 - RutaEmpresasP1 = 503 - RutaEmpresasP2 = 504 - RutaEmpresasP3 = 505 - End Enum - Private Function IsCurrentDate(Ticks As Long) As Boolean - Dim FechaRequest As DateTime = New DateTime(Ticks) - Dim FechaServer As DateTime = DateTime.UtcNow - - Return (FechaRequest > (FechaServer).AddMinutes(-5) And FechaRequest < (FechaServer).AddMinutes(5)) - End Function - Private Function URLRequestParams(Cadena As String) As Hashtable - Dim P1() As String = Cadena.Split("&"c) - Dim Tmp As String - Dim P2() As String - - Dim URLParametros As New Hashtable - - For Each Tmp In P1 - P2 = Tmp.Replace("%26%", "&").Split("="c) - URLParametros.Add(P2(0).ToString.ToUpper, P2(1)) - Next - Return URLParametros - End Function - Private Function AuthorizePageWithoutSessions() As List(Of String) - Dim pages = New List(Of String) - pages.Add("/Compras/PopUpVerFactura.aspx") - Return pages - End Function - Dim sw As Diagnostics.Stopwatch + Property GlobalDTAcumTamaños() As DataTable + Get + GlobalDTAcumTamaños = DirectCast(Application("GlobalDTAcumTamaños"), DataTable) + End Get + Set(value As DataTable) + Application("GlobalDTAcumTamaños") = value + End Set + End Property + +#Region "GDT'S RASTREO" + Property GlobalDTDispositivos(CveCliente As Integer) As DataTable + Get + Dim Str As StringBuilder = New StringBuilder() + + If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) + + + If CveCliente <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTDispositivos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTDispositivos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTDispositivos = DirectCast(Application("GlobalDTDispositivos"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTDispositivos") = value + End Set + End Property + + Public Sub RecargaGlobalDTDispositivos(GPS As ClsGPS) + If GPS.DispositivosGet(-1, -1, -1, -1) Then + GlobalDTDispositivos(-1) = GPS.DtResultados + End If + End Sub + + Property GlobalDTDispositivosUsuarios(CveCliente As Integer, Optional CveUsuario As Integer = -1) As DataTable + Get + If Application("GlobalDTDispositivosUsuarios") Is Nothing Then + Dim ObjGPS As New ClsGPS + If ObjGPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then + Application("GlobalDTDispositivosUsuarios") = ObjGPS.DtResultados + End If + ObjGPS.Dispose() + End If + + Dim Str As StringBuilder = New StringBuilder() + + If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) + If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) + + + If CveUsuario <> -1 OrElse CveCliente <> -1 Then + Dim Dv As New DataView(DirectCast(Application("GlobalDTDispositivosUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTDispositivosUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTDispositivosUsuarios = DirectCast(Application("GlobalDTDispositivosUsuarios"), DataTable) + End If + + End Get + Set(value As DataTable) + Application("GlobalDTDispositivosUsuarios") = value + End Set + End Property + +#End Region +#End Region + + + Public Enum SisParametros As Integer + URL = 1 + DirectorioSitio = 2 + eFacturasCaptcha = 3 + + + + RutaEmpresasJM = 500 + RutaEmpresasRM = 501 + RutaEmpresasPC = 502 + RutaEmpresasP1 = 503 + RutaEmpresasP2 = 504 + RutaEmpresasP3 = 505 + End Enum + Private Function IsCurrentDate(Ticks As Long) As Boolean + Dim FechaRequest As DateTime = New DateTime(Ticks) + Dim FechaServer As DateTime = DateTime.UtcNow + + Return (FechaRequest > (FechaServer).AddMinutes(-5) And FechaRequest < (FechaServer).AddMinutes(5)) + End Function + Private Function URLRequestParams(Cadena As String) As Hashtable + Dim P1() As String = Cadena.Split("&"c) + Dim Tmp As String + Dim P2() As String + + Dim URLParametros As New Hashtable + + For Each Tmp In P1 + P2 = Tmp.Replace("%26%", "&").Split("="c) + URLParametros.Add(P2(0).ToString.ToUpper, P2(1)) + Next + Return URLParametros + End Function + Private Function AuthorizePageWithoutSessions() As List(Of String) + Dim pages = New List(Of String) + pages.Add("/Compras/PopUpVerFactura.aspx") + Return pages + End Function + Dim sw As Diagnostics.Stopwatch Protected Overridable Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.PreInit sw = New Diagnostics.Stopwatch - sw.Start() - If Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing Then - Dim AuthorizeRequest As Boolean = False - Dim HuboError = False - Dim statusCode = 200 - - If AuthorizePageWithoutSessions().Contains(Request.ServerVariables("URL")) Then - If Request.Headers("ADSToken") IsNot Nothing AndAlso Request.Headers("Host") IsNot Nothing Then - Try - 'If (Not UrlSitio.Contains(Request.Headers("Host").ToString())) Then - ' AuthorizeRequest = False - ' statusCode = 401 - ' Usuario.CerrarSession() - ' Response.End() - 'End If - - Dim UserParams As Hashtable = URLRequestParams(Decripta((Request.Headers("ADSToken").ToString))) - - Dim CveEmpresaToken As Integer = UserParams("CVEEMPRESA").ToString().ToEntero() - Dim Ticks As Long = UserParams("TICKS").ToString().ToLong() - - AuthorizeRequest = IsCurrentDate(Ticks) AndAlso CveEmpresaToken > 0 - Catch ex As Exception - HuboError = True - AuthorizeRequest = False - OnError("Ocurrió un error al leer el token de autorización", ex) - Finally - - If HuboError Then - statusCode = 500 - End If - If Not AuthorizeRequest Then - statusCode = 401 - End If - - End Try - Else - AuthorizeRequest = False - End If - Else - AuthorizeRequest = False - End If - - Response.StatusCode = statusCode - If Not AuthorizeRequest Then - Usuario.CerrarSession() - Response.End() - End If - - Else - If Not Page.IsPostBack Then - - 'If Not CType(Session("UsuarioSIG"), Usuario).SeleccionoEmpresa AndAlso Request.ServerVariables("URL") <> "/Sistemas/PopUpSeleccionarEmpresa.aspx" Then - ' Response.Redirect("/Sistemas/PopUpSeleccionarEmpresa.aspx") - ' 'Alert(Request.ServerVariables("URL")) - 'End If - - Dim i As Integer = Obt_ClavePagina(Request.ServerVariables("URL")) - Dim FailURL As String = $"{FormsAuthentication.DefaultUrl}?ADCod={Encripta($"CveModulo={i}")}" - - 'si es <0 la página es sin restricciones - If i = -1 Then - CveModulo = -333 - Else - CveModulo = i - If i > 0 Then - - If Not UsuarioActual.TienePermisoPagina(i) Then - Response.Redirect(FailURL) - End If - - Else - Response.Redirect(FailURL) - End If - End If - - 'Else - ' If ViewState("TipoPermiso") IsNot Nothing Then TipoPermiso = ViewState("TipoPermiso").ToString - End If - If UsuarioActual.CveEmpresa = 42 Then - Me.MasterPageFile = "~/Masters/Site42.master" + sw.Start() + If Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing Then + Dim AuthorizeRequest As Boolean = False + Dim HuboError = False + Dim statusCode = 200 + + If AuthorizePageWithoutSessions().Contains(Request.ServerVariables("URL")) Then + If Request.Headers("ADSToken") IsNot Nothing AndAlso Request.Headers("Host") IsNot Nothing Then + Try + 'If (Not UrlSitio.Contains(Request.Headers("Host").ToString())) Then + ' AuthorizeRequest = False + ' statusCode = 401 + ' Usuario.CerrarSession() + ' Response.End() + 'End If + + Dim UserParams As Hashtable = URLRequestParams(Decripta((Request.Headers("ADSToken").ToString))) + + Dim CveEmpresaToken As Integer = UserParams("CVEEMPRESA").ToString().ToEntero() + Dim Ticks As Long = UserParams("TICKS").ToString().ToLong() + + AuthorizeRequest = IsCurrentDate(Ticks) AndAlso CveEmpresaToken > 0 + Catch ex As Exception + HuboError = True + AuthorizeRequest = False + OnError("Ocurrió un error al leer el token de autorización", ex) + Finally + + If HuboError Then + statusCode = 500 + End If + If Not AuthorizeRequest Then + statusCode = 401 + End If + + End Try + Else + AuthorizeRequest = False + End If + Else + AuthorizeRequest = False End If - ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.CambiarModulo, Nothing, -1, "", Request.Url.ToString()) - 'If Me.Request.ServerVariables("http_user_agent").ToLower.Contains("safari") AndAlso Page.ClientTarget <> "uplevel" Then Page.ClientTarget = "uplevel" 'Código agregado para que muestre bién el menu, en chrome - End If - End Sub - - - - Private Function Obt_ClavePagina(Pagina As String) As Integer - Dim Retorno As Integer - - Dim PaginaDict As System.Collections.Hashtable - - If Application("GlobalSIGAppPaginas") Is Nothing Then - PaginaDict = New System.Collections.Hashtable - - PaginaDict.Add("/Inicio.aspx".ToUpper(), -1) - PaginaDict.Add("/reporteador.aspx".ToUpper(), -1) - PaginaDict.Add("/General/CATIEPSxEntidadFed.aspx".ToUpper(), 719) - PaginaDict.Add("/GPS/RepArrastre.aspx".ToUpper(), 718) - PaginaDict.Add("/Ventas/RepConciliacionEmitidosSat.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/RepConciliacionSat.aspx".ToUpper(), 716) - PaginaDict.Add("/Ventas/SolicitudesSAT.aspx".ToUpper(), 717) - - PaginaDict.Add("/Nomina/CatConceptos2.aspx".ToUpper(), -1) - PaginaDict.Add("/Nomina/Aguinaldo.aspx".ToUpper(), -1) - PaginaDict.Add("/Nomina/RepInversiondeNomina.aspx".ToUpper(), 906) - PaginaDict.Add("/Nomina/FiniquitoB.aspx".ToUpper(), -1) - ''CONFIGURACIONES GENERALES - PaginaDict.Add("/Sistemas/SistemaSIG.aspx".ToUpper(), 9999) - - - 'Páginas agregadas recientemente (Implementación Metronic) - PaginaDict.Add("/Default2.aspx".ToUpper(), -1) - PaginaDict.Add("/CargaCuentas.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/Tareas.aspx".ToUpper(), -1) - PaginaDict.Add("/AdSistemasTeam/ProcedimientosAlmacenados.aspx".ToUpper(), -1) - PaginaDict.Add("/OS/CatOrdenesServiciosCaracteristicas.aspx".ToUpper(), -1) - PaginaDict.Add("/OS/CatOSCaracteristicasOpciones.aspx".ToUpper(), -1) - PaginaDict.Add("/OS/CatSubTiposOrdenesServicios.aspx".ToUpper(), -1) - PaginaDict.Add("/Prospectos/CatEncuestas.aspx".ToUpper(), -1) - PaginaDict.Add("/Inventarios/Equivalencia.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/PopUpVerFactura.aspx".ToUpper(), -1) - PaginaDict.Add("/OC/OCPendientes.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/Registro.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/WizardRegistro.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/VentasRene.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/Contrato2.aspx".ToUpper(), -1) - PaginaDict.Add("/Flotillas/CatMantenimientos.aspx".ToUpper(), -1) - PaginaDict.Add("/Inventarios/PaqueteDetalles.aspx".ToUpper(), -1) - - - - - 'Cargo las páginas que NO deben tener restricción - PaginaDict.Add("/Pruebas.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/PopUpSeleccionarEmpresa.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/PopUpPerfil.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/CatContrasenia.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/PopUpBuscarClientes.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/PopUpBuscarProveedor.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/PopUpImprimir.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/PopUpAuxiliar.aspx".ToUpper(), -1) - PaginaDict.Add("/Fiscal/PopUpConfiguracion.aspx".ToUpper(), -1) - PaginaDict.Add("/Planeacion/PopUpEventos.aspx".ToUpper(), -1) - PaginaDict.Add("/RH/PopUpBuscarPersonal.aspx".ToUpper(), -1) - PaginaDict.Add("/UploadFile.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/RepProveedorFacturas.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/Reportes.aspx".ToUpper(), -1) - - PaginaDict.Add("/Prospectos/PopUpBuscarProspectos.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/PopUpCambiaUsuario.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/CatDistribuidores.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/CatPlataformas.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/PopUpAddUsuario.aspx".ToUpper(), -1) - PaginaDict.Add("/General/JAMComparativos.aspx".ToUpper(), 643) - - '-------------------------------------------Q U I T A R---------------------------------- -#Region "Q U I T A R" - - - PaginaDict.Add("/Contratos/Estimaciones.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratos.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosAvances.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosPresupuesto.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/CatContratosTipos.aspx".ToUpper(), -1) - - - PaginaDict.Add("/SCT/RepGISSucesos.aspx".ToUpper(), -1) - PaginaDict.Add("/SCT/RepLicencias.aspx".ToUpper(), -1) - PaginaDict.Add("/SCT/Licencias.aspx".ToUpper(), -1) - PaginaDict.Add("/SCT/LicenciasDetalle.aspx".ToUpper(), -1) - - PaginaDict.Add("/Prospectos/Prospectos.aspx".ToUpper(), -1) - PaginaDict.Add("/XXXEjemplosPaola/Agenda/page_calendar.aspx".ToUpper(), -1) - PaginaDict.Add("/Orlando/Default.aspx".ToUpper(), -1) - PaginaDict.Add("/Orlando/Ventas.aspx".ToUpper(), -1) - - PaginaDict.Add("/Armonizacion/RepPresupuesto.aspx".ToUpper(), -1) - PaginaDict.Add("/Armonizacion/PresupuestoIngreso.aspx".ToUpper(), -1) - PaginaDict.Add("/Armonizacion/PresupuestoEgresos.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/CatProveedoresCuentas.aspx".ToUpper(), -1) - - PaginaDict.Add("/123/DefaultGrid.aspx".ToUpper(), -1) - PaginaDict.Add("/123/Default.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/EnviarCorreosPrueba.aspx".ToUpper(), -1) - - PaginaDict.Add("/Daniel/index.aspx".ToUpper(), -1) - PaginaDict.Add("/Daniel/CatCiudades.aspx".ToUpper(), -1) - PaginaDict.Add("/Daniel/Rodolfo.aspx".ToUpper(), -1) - PaginaDict.Add("/MaquinariaFlotillas/CatEstatusMF.aspx".ToUpper(), -1) - PaginaDict.Add("/TiposGastos/CatGastos.aspx".ToUpper(), -1) - PaginaDict.Add("/Daniel/ProyectoFinal.aspx".ToUpper(), -1) - PaginaDict.Add("/Daniel/ProyectoFinalTAP.aspx".ToUpper(), -1) - PaginaDict.Add("/Daniel/Ejercicio.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/Ventas10.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/CatTipoPolizas.aspx".ToUpper(), 571) - PaginaDict.Add("/Bancos/RepSaldoFianzas.aspx".ToUpper(), -1) - PaginaDict.Add("/Hiram/Ventas.aspx".ToUpper(), -1) - PaginaDict.Add("/RH/RepCursos.aspx".ToUpper(), -1) - PaginaDict.Add("/OS/OrdenesServiciosPrueba.aspx".ToUpper(), -1) - PaginaDict.Add("/OS/CatTiposCuentasEquiposPrueba.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/DIOTChilo.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/SaldarCajaChica.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/IngresosEgresosPorComprobar.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/ClientesAbonar.aspx".ToUpper(), -1) - -#End Region - '-------------------------------------------F I N - Q U I T A R---------------------------------- - - 'AMORTIZACIÓN CONTABLE -#Region "AC" - PaginaDict.Add("/AC/CatFuentesRecaudacion.aspx".ToUpper(), 268) - PaginaDict.Add("/AC/CatRubrosIngreso.aspx".ToUpper(), 265) - PaginaDict.Add("/AC/CatDependencias.aspx".ToUpper(), 266) - PaginaDict.Add("/AC/CatUnidadesAdministrativas.aspx".ToUpper(), 267) - PaginaDict.Add("/AC/CatOGClasificaciones.aspx".ToUpper(), 269) - PaginaDict.Add("/AC/CatClasificacionGeografica.aspx".ToUpper(), 271) - PaginaDict.Add("/AC/CatFinalidad.aspx".ToUpper(), 275) - PaginaDict.Add("/AC/CatFuncion.aspx".ToUpper(), 278) - PaginaDict.Add("/AC/CatSubPrograma.aspx".ToUpper(), 282) - PaginaDict.Add("/AC/CatPrograma.aspx".ToUpper(), 279) - PaginaDict.Add("/AC/CatProgramaCONAC.aspx".ToUpper(), 280) - PaginaDict.Add("/AC/CatClasificacionFuncional.aspx".ToUpper(), 274) - PaginaDict.Add("/AC/CatFuentesFinanciamiento.aspx".ToUpper(), 276) - PaginaDict.Add("/AC/CatCuentas.aspx".ToUpper(), -1) - PaginaDict.Add("/AC/CatFuentesFinanciamientoCONAC.aspx".ToUpper(), 277) - PaginaDict.Add("/AC/ProgramaOperativo.aspx".ToUpper(), 289) - PaginaDict.Add("/AC/RepProgramaOperativo.aspx".ToUpper(), 289) - PaginaDict.Add("/AC/RepPresupuestoEgresos.aspx".ToUpper(), 290) - PaginaDict.Add("/AC/RepPresupuestoEgresosMensual.aspx".ToUpper(), 290) - PaginaDict.Add("/AC/RepPresupuestoEgresosDetalle.aspx".ToUpper(), 290) - PaginaDict.Add("/AC/ProyectoProceso.aspx".ToUpper(), 288) - PaginaDict.Add("/AC/PresupuestoEgresos.aspx".ToUpper(), 291) - PaginaDict.Add("/AC/CatPresupuestoEgresos.aspx".ToUpper(), 291) - PaginaDict.Add("/AC/RegEgresosModificaciones.aspx".ToUpper(), 297) - PaginaDict.Add("/AC/PresupuestoIngresos.aspx".ToUpper(), 299) - PaginaDict.Add("/AC/CatPresupuestoIngresos.aspx".ToUpper(), 299) - PaginaDict.Add("/AC/RegIngresosModificaciones.aspx".ToUpper(), 300) - PaginaDict.Add("/AC/RepMatrizIngresos.aspx".ToUpper(), 301) - PaginaDict.Add("/AC/RepMatrizEgresos.aspx".ToUpper(), 302) - PaginaDict.Add("/AC/RegRecaudado.aspx".ToUpper(), 287) - PaginaDict.Add("/AC/RegDevengadoIngresos.aspx".ToUpper(), 298) - PaginaDict.Add("/AC/RepPresupuestoIngresos.aspx".ToUpper(), 316) - PaginaDict.Add("/AC/RepPresupuestoIngresosMensual.aspx".ToUpper(), 316) - PaginaDict.Add("/AC/RegNomina.aspx".ToUpper(), 317) - PaginaDict.Add("/AC/RepIngresosMensuales.aspx".ToUpper(), 331) - PaginaDict.Add("/AC/RepSituacionFinanciera.aspx".ToUpper(), 332) - PaginaDict.Add("/AC/RepEstadoActividades.aspx".ToUpper(), 334) - PaginaDict.Add("/AC/RepEstadoAnaliticoActivo.aspx".ToUpper(), 335) - PaginaDict.Add("/AC/RepAnaliticoDeudaPublica.aspx".ToUpper(), 121) - PaginaDict.Add("/AC/RepFlujoEfectivo.aspx".ToUpper(), 347) - PaginaDict.Add("/AC/RepCambiosSituacionFinanciera.aspx".ToUpper(), 348) - PaginaDict.Add("/AC/RepVariacionHaciendaPublica.aspx".ToUpper(), 349) - PaginaDict.Add("/AC/RepPresupuestoIngresosDetalle.aspx".ToUpper(), 299) - PaginaDict.Add("/AC/CatClasificacionAdministrativa.aspx.aspx".ToUpper(), -1) 'ELIMINAR ??? -#End Region - ' AC2 -#Region "AC2" - PaginaDict.Add("/AC2/CatPresupuestoEgresos.aspx".ToUpper(), 598) - PaginaDict.Add("/AC2/CatPresupuestoIngresos.aspx".ToUpper(), 599) - PaginaDict.Add("/AC2/RegComprometido.aspx".ToUpper(), 600) - PaginaDict.Add("/AC2/RegComprometido.aspx?Opc=NOM".ToUpper(), 601) - PaginaDict.Add("/AC2/RegNomina.aspx".ToUpper(), 602) - PaginaDict.Add("/AC2/RepPresupuesto.aspx".ToUpper(), 603) - PaginaDict.Add("/AC2/RepPresupuestoEgresos.aspx".ToUpper(), 604) - PaginaDict.Add("/AC2/RepPresupuestoEgresosMensual.aspx".ToUpper(), 605) - PaginaDict.Add("/AC2/RepPresupuestoIngresos.aspx".ToUpper(), 606) - PaginaDict.Add("/AC2/RepPresupuestoIngresosMensual.aspx".ToUpper(), 607) - PaginaDict.Add("/AC2/RepProgramaOperativo.aspx".ToUpper(), 608) - PaginaDict.Add("/AC2/RegEgresosModificaciones.aspx".ToUpper(), 609) - PaginaDict.Add("/AC2/PresupuestoEgresos.aspx".ToUpper(), 610) - PaginaDict.Add("/AC2/PresupuestoIngresos.aspx".ToUpper(), 611) - PaginaDict.Add("/AC2/RepPresupuestoEgresosDetalle.aspx".ToUpper(), 604) - PaginaDict.Add("/AC2/RepPresupuestoIngresosDetalle.aspx".ToUpper(), 613) - PaginaDict.Add("/AC2/ProgramaOperativo.aspx".ToUpper(), 608) -#End Region - 'ACARREOS' -#Region "Acarreos" - PaginaDict.Add("/Acarreos/CatChoferes.aspx".ToUpper(), 467) - PaginaDict.Add("/Acarreos/CatTransportistas.aspx".ToUpper(), 465) - PaginaDict.Add("/Acarreos/CatUnidades.aspx".ToUpper(), 466) - PaginaDict.Add("/Acarreos/Acarreos.aspx".ToUpper(), -1) - PaginaDict.Add("/Acarreos/RepAcarreos.aspx".ToUpper(), 461) - PaginaDict.Add("/Acarreos/RepAcarreosDetalle.aspx".ToUpper(), 461) - PaginaDict.Add("/Acarreos/CatMateriales.aspx".ToUpper(), 468) - PaginaDict.Add("/Acarreos/RegistroAcarreo.aspx".ToUpper(), 462) - PaginaDict.Add("/Acarreos/AcarreosConcluidos.aspx".ToUpper(), 463) - PaginaDict.Add("/Acarreos/RepAcarreosUnidades.aspx".ToUpper(), -1) - PaginaDict.Add("/Acarreos/AcarreosUnidades.aspx".ToUpper(), -1) - PaginaDict.Add("/Acarreos/CatEstatus.aspx".ToUpper(), -1) - PaginaDict.Add("/Acarreos/RegistroContratosAcarreos.aspx".ToUpper(), 481) - PaginaDict.Add("/Acarreos/ContratosAcarreos.aspx".ToUpper(), 481) - PaginaDict.Add("/Acarreos/AcarreosPreEstimacion.aspx".ToUpper(), 480) - PaginaDict.Add("/Acarreos/RepContratosAcarreos.aspx".ToUpper(), 482) - PaginaDict.Add("/Acarreos/RepContratosAcarreosDetalle.aspx".ToUpper(), 482) - PaginaDict.Add("/Acarreos/RepPreEstimacionDetalle.aspx".ToUpper(), 482) -#End Region - 'ACTIVOS FIJOS -#Region "AF" - PaginaDict.Add("/AF/ValesCombustible.aspx".ToUpper(), 384) - PaginaDict.Add("/AF/PopUpBuscarAF.aspx".ToUpper(), 62) - PaginaDict.Add("/AF/CatAF.aspx".ToUpper(), 63) - PaginaDict.Add("/AF/AF.aspx".ToUpper(), 63) - PaginaDict.Add("/AF/RepAF.aspx".ToUpper(), 403) - PaginaDict.Add("/AF/BitacoraAF.aspx".ToUpper(), 2043) - '-------------HIJOS DE 57 - PaginaDict.Add("/AF/CatTipos.aspx".ToUpper(), 138) - PaginaDict.Add("/AF/CatSubTipos.aspx".ToUpper(), 139) - PaginaDict.Add("/AF/CatModelos.aspx".ToUpper(), 140) - PaginaDict.Add("/AF/CatMarcas.aspx".ToUpper(), 141) - PaginaDict.Add("/AF/CatClasificacionesCaracteristicas.aspx".ToUpper(), 252) - PaginaDict.Add("/AF/CatClasificaciones.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/CatCaracteristicas.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/CatOpciones.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/ResguardoAF.aspx".ToUpper(), 574) - PaginaDict.Add("/AF/CatOperadores.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/CatTiposCombustible.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/CatCombustibles.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/CatCargasCombustible.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepFlotillas.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepPlacas.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepIncidentes.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepPolizaSeguro.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepLicencias.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepServicios.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepDepreciacion.aspx".ToUpper(), -1) - PaginaDict.Add("/AF/RepEventosProgramados.aspx".ToUpper(), 656) -#End Region - 'AIMMGM -#Region "AIMMGM" - PaginaDict.Add("/AIMMGM/Registro.aspx".ToUpper(), -1) - PaginaDict.Add("/AIMMGM/PopRegistro.aspx".ToUpper(), -1) - PaginaDict.Add("/AIMMGM/RegistroGIS.aspx".ToUpper(), -1) - PaginaDict.Add("/AIMMGM/RepVentas.aspx".ToUpper(), 236) - PaginaDict.Add("/AIMMGM/Pagos.aspx".ToUpper(), 238) - PaginaDict.Add("/AIMMGM/Saldos.aspx".ToUpper(), 239) - PaginaDict.Add("/AIMMGM/VentasPS.aspx".ToUpper(), 240) -#End Region - - 'BANCOS -#Region "Bancos" - PaginaDict.Add("/Bancos/ProveedoresAbonarH.aspx".ToUpper(), 84) - PaginaDict.Add("/Bancos/RepProveedoresPagosH.aspx".ToUpper(), 84) - PaginaDict.Add("/Bancos/PruebaCFDI.aspx".ToUpper(), 2027) - PaginaDict.Add("/Bancos/CatBancos.aspx".ToUpper(), 150) - PaginaDict.Add("/Bancos/CuentasBancarias.aspx".ToUpper(), 151) - PaginaDict.Add("/Bancos/CatEstatusIE.aspx".ToUpper(), 152) - PaginaDict.Add("/Bancos/CatTiposTransaccion.aspx".ToUpper(), 154) - PaginaDict.Add("/Bancos/CuentasBancariasDetalle.aspx".ToUpper(), 151) - PaginaDict.Add("/Bancos/Transferencias.aspx".ToUpper(), 285) - PaginaDict.Add("/Bancos/OtrosIE.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/IE.aspx?Opcion=EGSSINFACT&Tipo=PRESTAMODEUDOR".ToUpper(), 508) - PaginaDict.Add("/Bancos/IE.aspx?Opcion=EGSSINFACT&Tipo=PAGOACREEDOR".ToUpper(), 509) - PaginaDict.Add("/Bancos/IE.aspx?Opcion=INGPC&Tipo=PAGODEUDOR".ToUpper(), 510) - PaginaDict.Add("/Bancos/IE.aspx?Opcion=INGPC&Tipo=PRESTAMOACREEDOR".ToUpper(), 507) - PaginaDict.Add("/Bancos/PopUpBuscaPersonal.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/PopUpBuscarColectiva.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/PopUpBuscarProveedor.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/PopUpBuscarFolioC.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/PopUpBuscarClientes.aspx".ToUpper(), 281) - 'PaginaDict.Add("/Bancos/CatTiposCuenta.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/RepClientesAnticipo.aspx".ToUpper(), 306) - PaginaDict.Add("/Bancos/CIF.aspx".ToUpper(), 309) - PaginaDict.Add("/Bancos/Creditos.aspx".ToUpper(), 318) - PaginaDict.Add("/Bancos/PagoElectronico.aspx".ToUpper(), 324) - PaginaDict.Add("/Bancos/RepProgramaciones.aspx".ToUpper(), 323) - - PaginaDict.Add("/Bancos/PopIE.aspx".ToUpper(), 153) - PaginaDict.Add("/Bancos/PopIEVentas.aspx".ToUpper(), 153) - PaginaDict.Add("/Bancos/PopIECompras.aspx".ToUpper(), 153) - PaginaDict.Add("/Bancos/RepProveedoresPagos.aspx".ToUpper(), 84) - PaginaDict.Add("/Bancos/ProveedoresAbonar.aspx".ToUpper(), 84) - PaginaDict.Add("/Bancos/RepSaldos.aspx".ToUpper(), 169) - PaginaDict.Add("/Bancos/RepSaldosDetalle.aspx".ToUpper(), 169) - PaginaDict.Add("/Bancos/RepProgramarRecursos.aspx".ToUpper(), 170) - 'PaginaDict.Add("/Bancos/PolizaCheque.aspx".ToUpper(), 171) - PaginaDict.Add("/Bancos/RepEgresosSinComprobante.aspx".ToUpper(), 235) - PaginaDict.Add("/Bancos/RepCxCCliente.aspx".ToUpper(), 321) - PaginaDict.Add("/Bancos/FluctuacionCambiaria.aspx".ToUpper(), 329) - PaginaDict.Add("/Bancos/Reembolsos.aspx".ToUpper(), 333) - PaginaDict.Add("/Bancos/CreditosPagoMultiple.aspx".ToUpper(), 342) - PaginaDict.Add("/Bancos/NotificacionCheques.aspx".ToUpper(), 345) - PaginaDict.Add("/Bancos/ProductosFinancieros.aspx".ToUpper(), 351) - PaginaDict.Add("/Bancos/PopUpBuscarIE.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/RepCobradoPagadoDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Bancos/RepCobradoPagado.aspx".ToUpper(), 368) - PaginaDict.Add("/Bancos/RepIngresosPorComprobar.aspx".ToUpper(), 381) - PaginaDict.Add("/Bancos/Documentos.aspx".ToUpper(), 319) - PaginaDict.Add("/Bancos/RepCreditos.aspx".ToUpper(), 320) - PaginaDict.Add("/Bancos/RepSaldosDAP.aspx".ToUpper(), 385) - PaginaDict.Add("/Bancos/DepositosCaja.aspx".ToUpper(), 560) - PaginaDict.Add("/Bancos/RepCortes.aspx".ToUpper(), 1008) - PaginaDict.Add("/Bancos/RegistroPagoIntermediario.aspx".ToUpper(), 1013) - PaginaDict.Add("/Bancos/RepComplementoPago.aspx".ToUpper(), 512) - PaginaDict.Add("/Bancos/DepositoTerminal.aspx".ToUpper(), 281) - PaginaDict.Add("/Bancos/FlujoDiario.aspx".ToUpper(), 515) - PaginaDict.Add("/Bancos/RepComprobaciones.aspx".ToUpper(), 647) - PaginaDict.Add("/Bancos/RepCobrado.aspx".ToUpper(), 505) - PaginaDict.Add("/Bancos/RepCobradoDetalle.aspx".ToUpper(), 505) - PaginaDict.Add("/Bancos/ConciliacionesBancarias.aspx".ToUpper(), 874) - PaginaDict.Add("/Bancos/CargarConciliacionesBancarias.aspx".ToUpper(), 878) - PaginaDict.Add("/Bancos/PagoAcreedor.aspx".ToUpper(), 507) - PaginaDict.Add("/Bancos/PagoDeudor.aspx".ToUpper(), 508) - PaginaDict.Add("/Bancos/Devoluciones.aspx".ToUpper(), 283) - PaginaDict.Add("/Bancos/RepProveedoresCreditos.aspx".ToUpper(), 528) - PaginaDict.Add("/Bancos/ProveedoresCreditos.aspx".ToUpper(), 528) - PaginaDict.Add("/Bancos/RepSaldosPeriodo.aspx".ToUpper(), 884) - PaginaDict.Add("/Bancos/PrestamoPersonal.aspx".ToUpper(), 890) -#End Region - -#Region "CGame" - PaginaDict.Add("/CGame/OrdenProduccion.aspx".ToUpper(), 815) - PaginaDict.Add("/CGame/PopUpBuscarOrdenProduccion.aspx".ToUpper(), 816) - PaginaDict.Add("/CGame/RepOrdenProduccion.aspx".ToUpper(), 824) - PaginaDict.Add("/CGame/RepAvance.aspx".ToUpper(), 844) - - 'Reportes de Gastos - PaginaDict.Add("/CGame/RepPreEnfriado.aspx".ToUpper(), 855) - PaginaDict.Add("/CGame/RepCorte.aspx".ToUpper(), 857) - PaginaDict.Add("/CGame/RepFletes.aspx".ToUpper(), 858) - PaginaDict.Add("/CGame/RepOtrosGastos.aspx".ToUpper(), 859) - PaginaDict.Add("/CGame/RepMateriales.aspx".ToUpper(), 860) - PaginaDict.Add("/CGame/RepMaquila.aspx".ToUpper(), 862) - - 'Reportes de Ingresos - PaginaDict.Add("/CGame/RepIngresos.aspx".ToUpper(), 861) - - 'Estado de Cuenta - PaginaDict.Add("/CGame/EstadoCuenta.aspx".ToUpper(), 851) - PaginaDict.Add("/CGame/EstadoCuentaDetalle.aspx".ToUpper(), 851) - - 'Liquidacion - PaginaDict.Add("/CGame/Liquidacion.aspx".ToUpper(), 853) - - 'Orden Corte' - PaginaDict.Add("/CGame/EntradaMateriaPrima.aspx".ToUpper(), 820) - PaginaDict.Add("/CGame/RepOrdenCorte.aspx".ToUpper(), 842) - PaginaDict.Add("/CGame/RepOrdenCorteDetalle.aspx".ToUpper(), 842) - PaginaDict.Add("/CGame/GenerarOrdenCorte.aspx".ToUpper(), 845) - PaginaDict.Add("/CGame/CorteGasto.aspx".ToUpper(), 835) - PaginaDict.Add("/CGame/PopUpBuscarCorteGasto.aspx".ToUpper(), 836) - PaginaDict.Add("/CGame/RepCorteGasto.aspx".ToUpper(), 850) - PaginaDict.Add("/CGame/RepOrdenProduccionXHuerta.aspx".ToUpper(), 856) - - 'Empaque' - PaginaDict.Add("/CGame/Empaque.aspx".ToUpper(), 822) - PaginaDict.Add("/CGame/PopUpBuscarEmpaque.aspx".ToUpper(), 823) - PaginaDict.Add("/CGame/RepEmpaque.aspx".ToUpper(), 825) - PaginaDict.Add("/CGame/AsignacionEmpaque.aspx".ToUpper(), 826) - PaginaDict.Add("/CGame/RepEmpaqueDetalle.aspx".ToUpper(), 825) - PaginaDict.Add("/CGame/AsignacionEmpaque2.aspx".ToUpper(), 826) - - 'Fletes' - PaginaDict.Add("/CGame/Fletes.aspx".ToUpper(), 830) - PaginaDict.Add("/CGame/RepFletesPendientes.aspx".ToUpper(), 847) - 'Configuración - PaginaDict.Add("/CGame/CatEstatus.aspx".ToUpper(), 811) - PaginaDict.Add("/CGame/CatTamaños.aspx".ToUpper(), 812) - PaginaDict.Add("/CGame/CatEmpaque.aspx".ToUpper(), 814) - PaginaDict.Add("/CGame/CatCalidad.aspx".ToUpper(), 810) - PaginaDict.Add("/CGame/CatTipoCaja.aspx".ToUpper(), 813) - PaginaDict.Add("/CGame/CatProductos.aspx".ToUpper(), 834) - PaginaDict.Add("/CGame/CatCGameClientes.aspx".ToUpper(), 8301) - PaginaDict.Add("/CGame/CatTipoEmpaque.aspx".ToUpper(), 832) - PaginaDict.Add("/CGame/CatTipoMaduracion.aspx".ToUpper(), 833) - PaginaDict.Add("/CGame/CatTipoProducto.aspx".ToUpper(), 837) - PaginaDict.Add("/CGame/CatHuerta.aspx".ToUpper(), 818) - PaginaDict.Add("/CGame/CatMotivosMerma.aspx".ToUpper(), 819) - PaginaDict.Add("/CGame/CatScat.aspx".ToUpper(), 846) - PaginaDict.Add("/Acarreos/CatTransportistas.aspx?Op=Cor".ToUpper(), 828) - PaginaDict.Add("/Acarreos/CatChoferes.aspx?Op=Cor".ToUpper(), 829) - PaginaDict.Add("/CGame/CatConceptoGastoCorte.aspx".ToUpper(), 848) - PaginaDict.Add("/CGame/CatCargosFijos.aspx".ToUpper(), 852) -#End Region - 'COMPRAS -#Region "Compras" - PaginaDict.Add("/Compras/RepTopCompras.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/CatProveedores.aspx".ToUpper(), 37) - PaginaDict.Add("/Compras/Proveedores.aspx".ToUpper(), 37) - PaginaDict.Add("/Compras/Compras.aspx".ToUpper(), 38) - 'PaginaDict.Add("/Compras/ComprasJaneth.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/PopUpBuscarFolioC.aspx".ToUpper(), 38) - 'PaginaDict.Add("/Compras/RecepcionFacturas.aspx".ToUpper(), 38) - PaginaDict.Add("/Compras/RepCompras.aspx".ToUpper(), 95) - PaginaDict.Add("/Compras/RepComprasPeriodo.aspx".ToUpper(), 96) - PaginaDict.Add("/Compras/RepComprasDetalle.aspx".ToUpper(), 95) - PaginaDict.Add("/Compras/eFacturas.aspx".ToUpper(), 137) - PaginaDict.Add("/Compras/CatEstatusFactura.aspx".ToUpper(), 145) - PaginaDict.Add("/Compras/RepCxP.aspx".ToUpper(), 168) - PaginaDict.Add("/Compras/RepCxPDetalle.aspx".ToUpper(), 168) - PaginaDict.Add("/Compras/CatProveedoresClasificaciones.aspx".ToUpper(), 186) - PaginaDict.Add("/Compras/CatAcreedores.aspx".ToUpper(), 303) - PaginaDict.Add("/Compras/Acreedores.aspx".ToUpper(), 303) - PaginaDict.Add("/Compras/RepComprasG.aspx".ToUpper(), 286) - PaginaDict.Add("/Compras/Compras2.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/Compras3.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/Compras5.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/Importaciones.aspx".ToUpper(), 319) - PaginaDict.Add("/Compras/RepImportaciones.aspx".ToUpper(), 326) - PaginaDict.Add("/Compras/RegGastos.aspx".ToUpper(), 328) - PaginaDict.Add("/Compras/RepBeneficiarios.aspx".ToUpper(), 336) - PaginaDict.Add("/Compras/RepBeneficiariosDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/RepProductosServiciosDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/RepNotasCredito.aspx".ToUpper(), 337) - PaginaDict.Add("/Compras/ReembolsosComprobaciones.aspx".ToUpper(), 350) - PaginaDict.Add("/Compras/RepProductosServicios.aspx".ToUpper(), 97) - PaginaDict.Add("/Compras/RepPerioricidad.aspx".ToUpper(), 126) - PaginaDict.Add("/Compras/PopUpFacturasPendientesAutorizar.aspx".ToUpper(), 559) - PaginaDict.Add("/Compras/RepEvaluacionProveedor.aspx".ToUpper(), 564) - PaginaDict.Add("/Compras/RepRembolsoComprobaciones.aspx".ToUpper(), 591) - PaginaDict.Add("/Compras/ComprasO.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/ComprasH.aspx".ToUpper(), -1) - PaginaDict.Add("/Compras/RembolsosSinAsignar.aspx".ToUpper(), 635) - PaginaDict.Add("/Compras/RepGastos.aspx".ToUpper(), 2051) - PaginaDict.Add("/Compras/RepGastosDetalle.aspx".ToUpper(), 2051) - PaginaDict.Add("/Compras/RepComprasAF.aspx".ToUpper(), 636) - PaginaDict.Add("/Compras/RepComprasAFDetalle.aspx".ToUpper(), 636) - PaginaDict.Add("/Compras/RepComprasPersonal.aspx".ToUpper(), 637) - PaginaDict.Add("/Compras/RepComprasPersonalDetalle.aspx".ToUpper(), 637) - PaginaDict.Add("/Compras/RepComplementoPago.aspx".ToUpper(), 657) - PaginaDict.Add("/Compras/RepPromociones.aspx".ToUpper(), 638) - PaginaDict.Add("/Compras/RepProductosServiciosPeriodo.aspx".ToUpper(), 866) - PaginaDict.Add("/Compras/RepGastosFijos.aspx".ToUpper(), 661) - PaginaDict.Add("/Compras/RepPagado.aspx".ToUpper(), 872) - PaginaDict.Add("/Compras/RepPagadoDetalle.aspx".ToUpper(), 872) - PaginaDict.Add("/Compras/RepPagadoPeriodo.aspx".ToUpper(), 886) - PaginaDict.Add("/Compras/RepCxPPeriodo.aspx".ToUpper(), 888) - PaginaDict.Add("/Compras/RepGastosSemanal.aspx".ToUpper(), 534) - PaginaDict.Add("/Compras/ProveedoresAuxiliar.aspx".ToUpper(), 536) - PaginaDict.Add("/Compras/RepComprasInventarios.aspx".ToUpper(), 537) - PaginaDict.Add("/Compras/RepAnt-NC-EXC.aspx".ToUpper(), 538) + Response.StatusCode = statusCode + If Not AuthorizeRequest Then + Usuario.CerrarSession() + Response.End() + End If + + Else + If Not Page.IsPostBack Then + + 'If Not CType(Session("UsuarioSIG"), Usuario).SeleccionoEmpresa AndAlso Request.ServerVariables("URL") <> "/Sistemas/PopUpSeleccionarEmpresa.aspx" Then + ' Response.Redirect("/Sistemas/PopUpSeleccionarEmpresa.aspx") + ' 'Alert(Request.ServerVariables("URL")) + 'End If + + Dim i As Integer = Obt_ClavePagina(Request.ServerVariables("URL")) + Dim FailURL As String = $"{FormsAuthentication.DefaultUrl}?ADCod={Encripta($"CveModulo={i}")}" + + 'si es <0 la página es sin restricciones + If i = -1 Then + CveModulo = -333 + Else + CveModulo = i + If i > 0 Then + + If Not UsuarioActual.TienePermisoPagina(i) Then + Response.Redirect(FailURL) + End If + + Else + Response.Redirect(FailURL) + End If + End If + + 'Else + ' If ViewState("TipoPermiso") IsNot Nothing Then TipoPermiso = ViewState("TipoPermiso").ToString + End If + If UsuarioActual.CveEmpresa = 42 Then + Me.MasterPageFile = "~/Masters/Site42.master" + End If + + ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.CambiarModulo, Nothing, -1, "", Request.Url.ToString()) + 'If Me.Request.ServerVariables("http_user_agent").ToLower.Contains("safari") AndAlso Page.ClientTarget <> "uplevel" Then Page.ClientTarget = "uplevel" 'Código agregado para que muestre bién el menu, en chrome + End If + End Sub + + + + Private Function Obt_ClavePagina(Pagina As String) As Integer + Dim Retorno As Integer + + Dim PaginaDict As System.Collections.Hashtable + + If Application("GlobalSIGAppPaginas") Is Nothing Then + PaginaDict = New System.Collections.Hashtable + + PaginaDict.Add("/Inicio.aspx".ToUpper(), -1) + PaginaDict.Add("/reporteador.aspx".ToUpper(), -1) + PaginaDict.Add("/General/CATIEPSxEntidadFed.aspx".ToUpper(), 719) + PaginaDict.Add("/GPS/RepArrastre.aspx".ToUpper(), 718) + PaginaDict.Add("/Ventas/RepConciliacionEmitidosSat.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepConciliacionSat.aspx".ToUpper(), 716) + PaginaDict.Add("/Ventas/SolicitudesSAT.aspx".ToUpper(), 717) + + PaginaDict.Add("/Nomina/CatConceptos2.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/Aguinaldo.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/RepInversiondeNomina.aspx".ToUpper(), 906) + PaginaDict.Add("/Nomina/FiniquitoB.aspx".ToUpper(), -1) + ''CONFIGURACIONES GENERALES + PaginaDict.Add("/Sistemas/SistemaSIG.aspx".ToUpper(), 9999) + + + 'Páginas agregadas recientemente (Implementación Metronic) + PaginaDict.Add("/Default2.aspx".ToUpper(), -1) + PaginaDict.Add("/CargaCuentas.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/Tareas.aspx".ToUpper(), -1) + PaginaDict.Add("/AdSistemasTeam/ProcedimientosAlmacenados.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/CatOrdenesServiciosCaracteristicas.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/CatOSCaracteristicasOpciones.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/CatSubTiposOrdenesServicios.aspx".ToUpper(), -1) + PaginaDict.Add("/Prospectos/CatEncuestas.aspx".ToUpper(), -1) + PaginaDict.Add("/Inventarios/Equivalencia.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/PopUpVerFactura.aspx".ToUpper(), -1) + PaginaDict.Add("/OC/OCPendientes.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/Registro.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/WizardRegistro.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/VentasRene.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/Contrato2.aspx".ToUpper(), -1) + PaginaDict.Add("/Flotillas/CatMantenimientos.aspx".ToUpper(), -1) + PaginaDict.Add("/Inventarios/PaqueteDetalles.aspx".ToUpper(), -1) + + + + + 'Cargo las páginas que NO deben tener restricción + PaginaDict.Add("/Pruebas.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/PopUpSeleccionarEmpresa.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/PopUpPerfil.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/CatContrasenia.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/PopUpBuscarClientes.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/PopUpBuscarProveedor.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/PopUpImprimir.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/PopUpAuxiliar.aspx".ToUpper(), -1) + PaginaDict.Add("/Fiscal/PopUpConfiguracion.aspx".ToUpper(), -1) + PaginaDict.Add("/Planeacion/PopUpEventos.aspx".ToUpper(), -1) + PaginaDict.Add("/RH/PopUpBuscarPersonal.aspx".ToUpper(), -1) + PaginaDict.Add("/UploadFile.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/RepProveedorFacturas.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/Reportes.aspx".ToUpper(), -1) + + PaginaDict.Add("/Prospectos/PopUpBuscarProspectos.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/PopUpCambiaUsuario.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/CatDistribuidores.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/CatPlataformas.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/PopUpAddUsuario.aspx".ToUpper(), -1) + PaginaDict.Add("/General/JAMComparativos.aspx".ToUpper(), 643) + + '-------------------------------------------Q U I T A R---------------------------------- +#Region "Q U I T A R" + + + PaginaDict.Add("/Contratos/Estimaciones.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/RepContratos.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/RepContratosDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/RepContratosAvances.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/RepContratosPresupuesto.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/CatContratosTipos.aspx".ToUpper(), -1) + + + PaginaDict.Add("/SCT/RepGISSucesos.aspx".ToUpper(), -1) + PaginaDict.Add("/SCT/RepLicencias.aspx".ToUpper(), -1) + PaginaDict.Add("/SCT/Licencias.aspx".ToUpper(), -1) + PaginaDict.Add("/SCT/LicenciasDetalle.aspx".ToUpper(), -1) + + PaginaDict.Add("/Prospectos/Prospectos.aspx".ToUpper(), -1) + PaginaDict.Add("/XXXEjemplosPaola/Agenda/page_calendar.aspx".ToUpper(), -1) + PaginaDict.Add("/Orlando/Default.aspx".ToUpper(), -1) + PaginaDict.Add("/Orlando/Ventas.aspx".ToUpper(), -1) + + PaginaDict.Add("/Armonizacion/RepPresupuesto.aspx".ToUpper(), -1) + PaginaDict.Add("/Armonizacion/PresupuestoIngreso.aspx".ToUpper(), -1) + PaginaDict.Add("/Armonizacion/PresupuestoEgresos.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/CatProveedoresCuentas.aspx".ToUpper(), -1) + + PaginaDict.Add("/123/DefaultGrid.aspx".ToUpper(), -1) + PaginaDict.Add("/123/Default.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/EnviarCorreosPrueba.aspx".ToUpper(), -1) + + PaginaDict.Add("/Daniel/index.aspx".ToUpper(), -1) + PaginaDict.Add("/Daniel/CatCiudades.aspx".ToUpper(), -1) + PaginaDict.Add("/Daniel/Rodolfo.aspx".ToUpper(), -1) + PaginaDict.Add("/MaquinariaFlotillas/CatEstatusMF.aspx".ToUpper(), -1) + PaginaDict.Add("/TiposGastos/CatGastos.aspx".ToUpper(), -1) + PaginaDict.Add("/Daniel/ProyectoFinal.aspx".ToUpper(), -1) + PaginaDict.Add("/Daniel/ProyectoFinalTAP.aspx".ToUpper(), -1) + PaginaDict.Add("/Daniel/Ejercicio.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/Ventas10.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/CatTipoPolizas.aspx".ToUpper(), 571) + PaginaDict.Add("/Bancos/RepSaldoFianzas.aspx".ToUpper(), -1) + PaginaDict.Add("/Hiram/Ventas.aspx".ToUpper(), -1) + PaginaDict.Add("/RH/RepCursos.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/OrdenesServiciosPrueba.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/CatTiposCuentasEquiposPrueba.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/DIOTChilo.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/SaldarCajaChica.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/IngresosEgresosPorComprobar.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/ClientesAbonar.aspx".ToUpper(), -1) + +#End Region + '-------------------------------------------F I N - Q U I T A R---------------------------------- + + 'AMORTIZACIÓN CONTABLE +#Region "AC" + PaginaDict.Add("/AC/CatFuentesRecaudacion.aspx".ToUpper(), 268) + PaginaDict.Add("/AC/CatRubrosIngreso.aspx".ToUpper(), 265) + PaginaDict.Add("/AC/CatDependencias.aspx".ToUpper(), 266) + PaginaDict.Add("/AC/CatUnidadesAdministrativas.aspx".ToUpper(), 267) + PaginaDict.Add("/AC/CatOGClasificaciones.aspx".ToUpper(), 269) + PaginaDict.Add("/AC/CatClasificacionGeografica.aspx".ToUpper(), 271) + PaginaDict.Add("/AC/CatFinalidad.aspx".ToUpper(), 275) + PaginaDict.Add("/AC/CatFuncion.aspx".ToUpper(), 278) + PaginaDict.Add("/AC/CatSubPrograma.aspx".ToUpper(), 282) + PaginaDict.Add("/AC/CatPrograma.aspx".ToUpper(), 279) + PaginaDict.Add("/AC/CatProgramaCONAC.aspx".ToUpper(), 280) + PaginaDict.Add("/AC/CatClasificacionFuncional.aspx".ToUpper(), 274) + PaginaDict.Add("/AC/CatFuentesFinanciamiento.aspx".ToUpper(), 276) + PaginaDict.Add("/AC/CatCuentas.aspx".ToUpper(), -1) + PaginaDict.Add("/AC/CatFuentesFinanciamientoCONAC.aspx".ToUpper(), 277) + PaginaDict.Add("/AC/ProgramaOperativo.aspx".ToUpper(), 289) + PaginaDict.Add("/AC/RepProgramaOperativo.aspx".ToUpper(), 289) + PaginaDict.Add("/AC/RepPresupuestoEgresos.aspx".ToUpper(), 290) + PaginaDict.Add("/AC/RepPresupuestoEgresosMensual.aspx".ToUpper(), 290) + PaginaDict.Add("/AC/RepPresupuestoEgresosDetalle.aspx".ToUpper(), 290) + PaginaDict.Add("/AC/ProyectoProceso.aspx".ToUpper(), 288) + PaginaDict.Add("/AC/PresupuestoEgresos.aspx".ToUpper(), 291) + PaginaDict.Add("/AC/CatPresupuestoEgresos.aspx".ToUpper(), 291) + PaginaDict.Add("/AC/RegEgresosModificaciones.aspx".ToUpper(), 297) + PaginaDict.Add("/AC/PresupuestoIngresos.aspx".ToUpper(), 299) + PaginaDict.Add("/AC/CatPresupuestoIngresos.aspx".ToUpper(), 299) + PaginaDict.Add("/AC/RegIngresosModificaciones.aspx".ToUpper(), 300) + PaginaDict.Add("/AC/RepMatrizIngresos.aspx".ToUpper(), 301) + PaginaDict.Add("/AC/RepMatrizEgresos.aspx".ToUpper(), 302) + PaginaDict.Add("/AC/RegRecaudado.aspx".ToUpper(), 287) + PaginaDict.Add("/AC/RegDevengadoIngresos.aspx".ToUpper(), 298) + PaginaDict.Add("/AC/RepPresupuestoIngresos.aspx".ToUpper(), 316) + PaginaDict.Add("/AC/RepPresupuestoIngresosMensual.aspx".ToUpper(), 316) + PaginaDict.Add("/AC/RegNomina.aspx".ToUpper(), 317) + PaginaDict.Add("/AC/RepIngresosMensuales.aspx".ToUpper(), 331) + PaginaDict.Add("/AC/RepSituacionFinanciera.aspx".ToUpper(), 332) + PaginaDict.Add("/AC/RepEstadoActividades.aspx".ToUpper(), 334) + PaginaDict.Add("/AC/RepEstadoAnaliticoActivo.aspx".ToUpper(), 335) + PaginaDict.Add("/AC/RepAnaliticoDeudaPublica.aspx".ToUpper(), 121) + PaginaDict.Add("/AC/RepFlujoEfectivo.aspx".ToUpper(), 347) + PaginaDict.Add("/AC/RepCambiosSituacionFinanciera.aspx".ToUpper(), 348) + PaginaDict.Add("/AC/RepVariacionHaciendaPublica.aspx".ToUpper(), 349) + PaginaDict.Add("/AC/RepPresupuestoIngresosDetalle.aspx".ToUpper(), 299) + PaginaDict.Add("/AC/CatClasificacionAdministrativa.aspx.aspx".ToUpper(), -1) 'ELIMINAR ??? +#End Region + ' AC2 +#Region "AC2" + PaginaDict.Add("/AC2/CatPresupuestoEgresos.aspx".ToUpper(), 598) + PaginaDict.Add("/AC2/CatPresupuestoIngresos.aspx".ToUpper(), 599) + PaginaDict.Add("/AC2/RegComprometido.aspx".ToUpper(), 600) + PaginaDict.Add("/AC2/RegComprometido.aspx?Opc=NOM".ToUpper(), 601) + PaginaDict.Add("/AC2/RegNomina.aspx".ToUpper(), 602) + PaginaDict.Add("/AC2/RepPresupuesto.aspx".ToUpper(), 603) + PaginaDict.Add("/AC2/RepPresupuestoEgresos.aspx".ToUpper(), 604) + PaginaDict.Add("/AC2/RepPresupuestoEgresosMensual.aspx".ToUpper(), 605) + PaginaDict.Add("/AC2/RepPresupuestoIngresos.aspx".ToUpper(), 606) + PaginaDict.Add("/AC2/RepPresupuestoIngresosMensual.aspx".ToUpper(), 607) + PaginaDict.Add("/AC2/RepProgramaOperativo.aspx".ToUpper(), 608) + PaginaDict.Add("/AC2/RegEgresosModificaciones.aspx".ToUpper(), 609) + PaginaDict.Add("/AC2/PresupuestoEgresos.aspx".ToUpper(), 610) + PaginaDict.Add("/AC2/PresupuestoIngresos.aspx".ToUpper(), 611) + PaginaDict.Add("/AC2/RepPresupuestoEgresosDetalle.aspx".ToUpper(), 604) + PaginaDict.Add("/AC2/RepPresupuestoIngresosDetalle.aspx".ToUpper(), 613) + PaginaDict.Add("/AC2/ProgramaOperativo.aspx".ToUpper(), 608) +#End Region + 'ACARREOS' +#Region "Acarreos" + PaginaDict.Add("/Acarreos/CatChoferes.aspx".ToUpper(), 467) + PaginaDict.Add("/Acarreos/CatTransportistas.aspx".ToUpper(), 465) + PaginaDict.Add("/Acarreos/CatUnidades.aspx".ToUpper(), 466) + PaginaDict.Add("/Acarreos/Acarreos.aspx".ToUpper(), -1) + PaginaDict.Add("/Acarreos/RepAcarreos.aspx".ToUpper(), 461) + PaginaDict.Add("/Acarreos/RepAcarreosDetalle.aspx".ToUpper(), 461) + PaginaDict.Add("/Acarreos/CatMateriales.aspx".ToUpper(), 468) + PaginaDict.Add("/Acarreos/RegistroAcarreo.aspx".ToUpper(), 462) + PaginaDict.Add("/Acarreos/AcarreosConcluidos.aspx".ToUpper(), 463) + PaginaDict.Add("/Acarreos/RepAcarreosUnidades.aspx".ToUpper(), -1) + PaginaDict.Add("/Acarreos/AcarreosUnidades.aspx".ToUpper(), -1) + PaginaDict.Add("/Acarreos/CatEstatus.aspx".ToUpper(), -1) + PaginaDict.Add("/Acarreos/RegistroContratosAcarreos.aspx".ToUpper(), 481) + PaginaDict.Add("/Acarreos/ContratosAcarreos.aspx".ToUpper(), 481) + PaginaDict.Add("/Acarreos/AcarreosPreEstimacion.aspx".ToUpper(), 480) + PaginaDict.Add("/Acarreos/RepContratosAcarreos.aspx".ToUpper(), 482) + PaginaDict.Add("/Acarreos/RepContratosAcarreosDetalle.aspx".ToUpper(), 482) + PaginaDict.Add("/Acarreos/RepPreEstimacionDetalle.aspx".ToUpper(), 482) +#End Region + 'ACTIVOS FIJOS +#Region "AF" + PaginaDict.Add("/AF/ValesCombustible.aspx".ToUpper(), 384) + PaginaDict.Add("/AF/PopUpBuscarAF.aspx".ToUpper(), 62) + PaginaDict.Add("/AF/CatAF.aspx".ToUpper(), 63) + PaginaDict.Add("/AF/AF.aspx".ToUpper(), 63) + PaginaDict.Add("/AF/RepAF.aspx".ToUpper(), 403) + PaginaDict.Add("/AF/BitacoraAF.aspx".ToUpper(), 2043) + '-------------HIJOS DE 57 + PaginaDict.Add("/AF/CatTipos.aspx".ToUpper(), 138) + PaginaDict.Add("/AF/CatSubTipos.aspx".ToUpper(), 139) + PaginaDict.Add("/AF/CatModelos.aspx".ToUpper(), 140) + PaginaDict.Add("/AF/CatMarcas.aspx".ToUpper(), 141) + PaginaDict.Add("/AF/CatClasificacionesCaracteristicas.aspx".ToUpper(), 252) + PaginaDict.Add("/AF/CatClasificaciones.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/CatCaracteristicas.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/CatOpciones.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/ResguardoAF.aspx".ToUpper(), 574) + PaginaDict.Add("/AF/CatOperadores.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/CatTiposCombustible.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/CatCombustibles.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/CatCargasCombustible.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepFlotillas.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepPlacas.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepIncidentes.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepPolizaSeguro.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepLicencias.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepServicios.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepDepreciacion.aspx".ToUpper(), -1) + PaginaDict.Add("/AF/RepEventosProgramados.aspx".ToUpper(), 656) +#End Region + 'AIMMGM +#Region "AIMMGM" + PaginaDict.Add("/AIMMGM/Registro.aspx".ToUpper(), -1) + PaginaDict.Add("/AIMMGM/PopRegistro.aspx".ToUpper(), -1) + PaginaDict.Add("/AIMMGM/RegistroGIS.aspx".ToUpper(), -1) + PaginaDict.Add("/AIMMGM/RepVentas.aspx".ToUpper(), 236) + PaginaDict.Add("/AIMMGM/Pagos.aspx".ToUpper(), 238) + PaginaDict.Add("/AIMMGM/Saldos.aspx".ToUpper(), 239) + PaginaDict.Add("/AIMMGM/VentasPS.aspx".ToUpper(), 240) +#End Region + + 'BANCOS +#Region "Bancos" + PaginaDict.Add("/Bancos/ProveedoresAbonarH.aspx".ToUpper(), 84) + PaginaDict.Add("/Bancos/RepProveedoresPagosH.aspx".ToUpper(), 84) + PaginaDict.Add("/Bancos/PruebaCFDI.aspx".ToUpper(), 2027) + PaginaDict.Add("/Bancos/CatBancos.aspx".ToUpper(), 150) + PaginaDict.Add("/Bancos/CuentasBancarias.aspx".ToUpper(), 151) + PaginaDict.Add("/Bancos/CatEstatusIE.aspx".ToUpper(), 152) + PaginaDict.Add("/Bancos/CatTiposTransaccion.aspx".ToUpper(), 154) + PaginaDict.Add("/Bancos/CuentasBancariasDetalle.aspx".ToUpper(), 151) + PaginaDict.Add("/Bancos/Transferencias.aspx".ToUpper(), 285) + PaginaDict.Add("/Bancos/OtrosIE.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/IE.aspx?Opcion=EGSSINFACT&Tipo=PRESTAMODEUDOR".ToUpper(), 508) + PaginaDict.Add("/Bancos/IE.aspx?Opcion=EGSSINFACT&Tipo=PAGOACREEDOR".ToUpper(), 509) + PaginaDict.Add("/Bancos/IE.aspx?Opcion=INGPC&Tipo=PAGODEUDOR".ToUpper(), 510) + PaginaDict.Add("/Bancos/IE.aspx?Opcion=INGPC&Tipo=PRESTAMOACREEDOR".ToUpper(), 507) + PaginaDict.Add("/Bancos/PopUpBuscaPersonal.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/PopUpBuscarColectiva.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/PopUpBuscarProveedor.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/PopUpBuscarFolioC.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/PopUpBuscarClientes.aspx".ToUpper(), 281) + 'PaginaDict.Add("/Bancos/CatTiposCuenta.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/RepClientesAnticipo.aspx".ToUpper(), 306) + PaginaDict.Add("/Bancos/CIF.aspx".ToUpper(), 309) + PaginaDict.Add("/Bancos/Creditos.aspx".ToUpper(), 318) + PaginaDict.Add("/Bancos/PagoElectronico.aspx".ToUpper(), 324) + PaginaDict.Add("/Bancos/RepProgramaciones.aspx".ToUpper(), 323) + + PaginaDict.Add("/Bancos/PopIE.aspx".ToUpper(), 153) + PaginaDict.Add("/Bancos/PopIEVentas.aspx".ToUpper(), 153) + PaginaDict.Add("/Bancos/PopIECompras.aspx".ToUpper(), 153) + PaginaDict.Add("/Bancos/RepProveedoresPagos.aspx".ToUpper(), 84) + PaginaDict.Add("/Bancos/ProveedoresAbonar.aspx".ToUpper(), 84) + PaginaDict.Add("/Bancos/RepSaldos.aspx".ToUpper(), 169) + PaginaDict.Add("/Bancos/RepSaldosDetalle.aspx".ToUpper(), 169) + PaginaDict.Add("/Bancos/RepProgramarRecursos.aspx".ToUpper(), 170) + 'PaginaDict.Add("/Bancos/PolizaCheque.aspx".ToUpper(), 171) + PaginaDict.Add("/Bancos/RepEgresosSinComprobante.aspx".ToUpper(), 235) + PaginaDict.Add("/Bancos/RepCxCCliente.aspx".ToUpper(), 321) + PaginaDict.Add("/Bancos/FluctuacionCambiaria.aspx".ToUpper(), 329) + PaginaDict.Add("/Bancos/Reembolsos.aspx".ToUpper(), 333) + PaginaDict.Add("/Bancos/CreditosPagoMultiple.aspx".ToUpper(), 342) + PaginaDict.Add("/Bancos/NotificacionCheques.aspx".ToUpper(), 345) + PaginaDict.Add("/Bancos/ProductosFinancieros.aspx".ToUpper(), 351) + PaginaDict.Add("/Bancos/PopUpBuscarIE.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/RepCobradoPagadoDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Bancos/RepCobradoPagado.aspx".ToUpper(), 368) + PaginaDict.Add("/Bancos/RepIngresosPorComprobar.aspx".ToUpper(), 381) + PaginaDict.Add("/Bancos/Documentos.aspx".ToUpper(), 319) + PaginaDict.Add("/Bancos/RepCreditos.aspx".ToUpper(), 320) + PaginaDict.Add("/Bancos/RepSaldosDAP.aspx".ToUpper(), 385) + PaginaDict.Add("/Bancos/DepositosCaja.aspx".ToUpper(), 560) + PaginaDict.Add("/Bancos/RepCortes.aspx".ToUpper(), 1008) + PaginaDict.Add("/Bancos/RegistroPagoIntermediario.aspx".ToUpper(), 1013) + PaginaDict.Add("/Bancos/RepComplementoPago.aspx".ToUpper(), 512) + PaginaDict.Add("/Bancos/DepositoTerminal.aspx".ToUpper(), 281) + PaginaDict.Add("/Bancos/FlujoDiario.aspx".ToUpper(), 515) + PaginaDict.Add("/Bancos/RepComprobaciones.aspx".ToUpper(), 647) + PaginaDict.Add("/Bancos/RepCobrado.aspx".ToUpper(), 505) + PaginaDict.Add("/Bancos/RepCobradoDetalle.aspx".ToUpper(), 505) + PaginaDict.Add("/Bancos/ConciliacionesBancarias.aspx".ToUpper(), 874) + PaginaDict.Add("/Bancos/CargarConciliacionesBancarias.aspx".ToUpper(), 878) + PaginaDict.Add("/Bancos/PagoAcreedor.aspx".ToUpper(), 507) + PaginaDict.Add("/Bancos/PagoDeudor.aspx".ToUpper(), 508) + PaginaDict.Add("/Bancos/Devoluciones.aspx".ToUpper(), 283) + PaginaDict.Add("/Bancos/RepProveedoresCreditos.aspx".ToUpper(), 528) + PaginaDict.Add("/Bancos/ProveedoresCreditos.aspx".ToUpper(), 528) + PaginaDict.Add("/Bancos/RepSaldosPeriodo.aspx".ToUpper(), 884) + PaginaDict.Add("/Bancos/PrestamoPersonal.aspx".ToUpper(), 890) +#End Region + +#Region "CGame" + PaginaDict.Add("/CGame/OrdenProduccion.aspx".ToUpper(), 815) + PaginaDict.Add("/CGame/PopUpBuscarOrdenProduccion.aspx".ToUpper(), 816) + PaginaDict.Add("/CGame/RepOrdenProduccion.aspx".ToUpper(), 824) + PaginaDict.Add("/CGame/RepAvance.aspx".ToUpper(), 844) + + 'Reportes de Gastos + PaginaDict.Add("/CGame/RepPreEnfriado.aspx".ToUpper(), 855) + PaginaDict.Add("/CGame/RepCorte.aspx".ToUpper(), 857) + PaginaDict.Add("/CGame/RepFletes.aspx".ToUpper(), 858) + PaginaDict.Add("/CGame/RepOtrosGastos.aspx".ToUpper(), 859) + PaginaDict.Add("/CGame/RepMateriales.aspx".ToUpper(), 860) + PaginaDict.Add("/CGame/RepMaquila.aspx".ToUpper(), 862) + + 'Reportes de Ingresos + PaginaDict.Add("/CGame/RepIngresos.aspx".ToUpper(), 861) + + 'Estado de Cuenta + PaginaDict.Add("/CGame/EstadoCuenta.aspx".ToUpper(), 851) + PaginaDict.Add("/CGame/EstadoCuentaDetalle.aspx".ToUpper(), 851) + + 'Liquidacion + PaginaDict.Add("/CGame/Liquidacion.aspx".ToUpper(), 853) + + 'Orden Corte' + PaginaDict.Add("/CGame/EntradaMateriaPrima.aspx".ToUpper(), 820) + PaginaDict.Add("/CGame/RepOrdenCorte.aspx".ToUpper(), 842) + PaginaDict.Add("/CGame/RepOrdenCorteDetalle.aspx".ToUpper(), 842) + PaginaDict.Add("/CGame/GenerarOrdenCorte.aspx".ToUpper(), 845) + PaginaDict.Add("/CGame/CorteGasto.aspx".ToUpper(), 835) + PaginaDict.Add("/CGame/PopUpBuscarCorteGasto.aspx".ToUpper(), 836) + PaginaDict.Add("/CGame/RepCorteGasto.aspx".ToUpper(), 850) + PaginaDict.Add("/CGame/RepOrdenProduccionXHuerta.aspx".ToUpper(), 856) + + 'Empaque' + PaginaDict.Add("/CGame/Empaque.aspx".ToUpper(), 822) + PaginaDict.Add("/CGame/PopUpBuscarEmpaque.aspx".ToUpper(), 823) + PaginaDict.Add("/CGame/RepEmpaque.aspx".ToUpper(), 825) + PaginaDict.Add("/CGame/AsignacionEmpaque.aspx".ToUpper(), 826) + PaginaDict.Add("/CGame/RepEmpaqueDetalle.aspx".ToUpper(), 825) + PaginaDict.Add("/CGame/AsignacionEmpaque2.aspx".ToUpper(), 826) + + 'Fletes' + PaginaDict.Add("/CGame/Fletes.aspx".ToUpper(), 830) + PaginaDict.Add("/CGame/RepFletesPendientes.aspx".ToUpper(), 847) + 'Configuración + PaginaDict.Add("/CGame/CatEstatus.aspx".ToUpper(), 811) + PaginaDict.Add("/CGame/CatTamaños.aspx".ToUpper(), 812) + PaginaDict.Add("/CGame/CatEmpaque.aspx".ToUpper(), 814) + PaginaDict.Add("/CGame/CatCalidad.aspx".ToUpper(), 810) + PaginaDict.Add("/CGame/CatTipoCaja.aspx".ToUpper(), 813) + PaginaDict.Add("/CGame/CatProductos.aspx".ToUpper(), 834) + PaginaDict.Add("/CGame/CatCGameClientes.aspx".ToUpper(), 8301) + PaginaDict.Add("/CGame/CatTipoEmpaque.aspx".ToUpper(), 832) + PaginaDict.Add("/CGame/CatTipoMaduracion.aspx".ToUpper(), 833) + PaginaDict.Add("/CGame/CatTipoProducto.aspx".ToUpper(), 837) + PaginaDict.Add("/CGame/CatHuerta.aspx".ToUpper(), 818) + PaginaDict.Add("/CGame/CatMotivosMerma.aspx".ToUpper(), 819) + PaginaDict.Add("/CGame/CatScat.aspx".ToUpper(), 846) + PaginaDict.Add("/Acarreos/CatTransportistas.aspx?Op=Cor".ToUpper(), 828) + PaginaDict.Add("/Acarreos/CatChoferes.aspx?Op=Cor".ToUpper(), 829) + PaginaDict.Add("/CGame/CatConceptoGastoCorte.aspx".ToUpper(), 848) + PaginaDict.Add("/CGame/CatCargosFijos.aspx".ToUpper(), 852) +#End Region + 'COMPRAS +#Region "Compras" + PaginaDict.Add("/Compras/RepTopCompras.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/CatProveedores.aspx".ToUpper(), 37) + PaginaDict.Add("/Compras/Proveedores.aspx".ToUpper(), 37) + PaginaDict.Add("/Compras/Compras.aspx".ToUpper(), 38) + 'PaginaDict.Add("/Compras/ComprasJaneth.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/PopUpBuscarFolioC.aspx".ToUpper(), 38) + 'PaginaDict.Add("/Compras/RecepcionFacturas.aspx".ToUpper(), 38) + PaginaDict.Add("/Compras/RepCompras.aspx".ToUpper(), 95) + PaginaDict.Add("/Compras/RepComprasPeriodo.aspx".ToUpper(), 96) + PaginaDict.Add("/Compras/RepComprasDetalle.aspx".ToUpper(), 95) + PaginaDict.Add("/Compras/eFacturas.aspx".ToUpper(), 137) + PaginaDict.Add("/Compras/CatEstatusFactura.aspx".ToUpper(), 145) + PaginaDict.Add("/Compras/RepCxP.aspx".ToUpper(), 168) + PaginaDict.Add("/Compras/RepCxPDetalle.aspx".ToUpper(), 168) + PaginaDict.Add("/Compras/CatProveedoresClasificaciones.aspx".ToUpper(), 186) + PaginaDict.Add("/Compras/CatAcreedores.aspx".ToUpper(), 303) + PaginaDict.Add("/Compras/Acreedores.aspx".ToUpper(), 303) + PaginaDict.Add("/Compras/RepComprasG.aspx".ToUpper(), 286) + PaginaDict.Add("/Compras/Compras2.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/Compras3.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/Compras5.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/Importaciones.aspx".ToUpper(), 319) + PaginaDict.Add("/Compras/RepImportaciones.aspx".ToUpper(), 326) + PaginaDict.Add("/Compras/RegGastos.aspx".ToUpper(), 328) + PaginaDict.Add("/Compras/RepBeneficiarios.aspx".ToUpper(), 336) + PaginaDict.Add("/Compras/RepBeneficiariosDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/RepProductosServiciosDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/RepNotasCredito.aspx".ToUpper(), 337) + PaginaDict.Add("/Compras/ReembolsosComprobaciones.aspx".ToUpper(), 350) + PaginaDict.Add("/Compras/RepProductosServicios.aspx".ToUpper(), 97) + PaginaDict.Add("/Compras/RepPerioricidad.aspx".ToUpper(), 126) + PaginaDict.Add("/Compras/PopUpFacturasPendientesAutorizar.aspx".ToUpper(), 559) + PaginaDict.Add("/Compras/RepEvaluacionProveedor.aspx".ToUpper(), 564) + PaginaDict.Add("/Compras/RepRembolsoComprobaciones.aspx".ToUpper(), 591) + PaginaDict.Add("/Compras/ComprasO.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/ComprasH.aspx".ToUpper(), -1) + PaginaDict.Add("/Compras/RembolsosSinAsignar.aspx".ToUpper(), 635) + PaginaDict.Add("/Compras/RepGastos.aspx".ToUpper(), 2051) + PaginaDict.Add("/Compras/RepGastosDetalle.aspx".ToUpper(), 2051) + PaginaDict.Add("/Compras/RepComprasAF.aspx".ToUpper(), 636) + PaginaDict.Add("/Compras/RepComprasAFDetalle.aspx".ToUpper(), 636) + PaginaDict.Add("/Compras/RepComprasPersonal.aspx".ToUpper(), 637) + PaginaDict.Add("/Compras/RepComprasPersonalDetalle.aspx".ToUpper(), 637) + PaginaDict.Add("/Compras/RepComplementoPago.aspx".ToUpper(), 657) + PaginaDict.Add("/Compras/RepPromociones.aspx".ToUpper(), 638) + PaginaDict.Add("/Compras/RepProductosServiciosPeriodo.aspx".ToUpper(), 866) + PaginaDict.Add("/Compras/RepGastosFijos.aspx".ToUpper(), 661) + PaginaDict.Add("/Compras/RepPagado.aspx".ToUpper(), 872) + PaginaDict.Add("/Compras/RepPagadoDetalle.aspx".ToUpper(), 872) + PaginaDict.Add("/Compras/RepPagadoPeriodo.aspx".ToUpper(), 886) + PaginaDict.Add("/Compras/RepCxPPeriodo.aspx".ToUpper(), 888) + PaginaDict.Add("/Compras/RepGastosSemanal.aspx".ToUpper(), 534) + PaginaDict.Add("/Compras/ProveedoresAuxiliar.aspx".ToUpper(), 536) + PaginaDict.Add("/Compras/RepComprasInventarios.aspx".ToUpper(), 537) + PaginaDict.Add("/Compras/RepAnt-NC-EXC.aspx".ToUpper(), 538) PaginaDict.Add("/Compras/RepAnt-NC-EXCDetalle.aspx".ToUpper(), 538) - PaginaDict.Add("/Compras/EvaluacionProveedor.aspx".ToUpper(), 715) 'EvaluacionProveedor.aspx + PaginaDict.Add("/Compras/EvaluacionProveedor.aspx".ToUpper(), 715) 'EvaluacionProveedor.aspx PaginaDict.Add("/Compras/RepPUESinPago.aspx".ToUpper(), 675) PaginaDict.Add("/Compras/RepReqOCCompraInv.aspx".ToUpper(), 689) PaginaDict.Add("/Compras/RepComprasPrecios.aspx".ToUpper(), 690) @@ -3962,706 +3962,706 @@ Public Class ClsPaginas PaginaDict.Add("/Compras/CatPaqueteriasGuiasTipo.aspx".ToUpper(), 753) PaginaDict.Add("/Compras/RepEvaluacionesProveedores.aspx".ToUpper(), 754) -#End Region +#End Region 'CONTABILIDAD -#Region "Contabilidad" +#Region "Contabilidad" 'CONTABILIDAD ELECTRONICA - PaginaDict.Add("/Contabilidad/ContabilidadElectronica.aspx".ToUpper(), 566) - PaginaDict.Add("/Contabilidad/RepGastosCC.aspx".ToUpper(), 535) - PaginaDict.Add("/Contabilidad/ContabilizarPagosCliente.aspx".ToUpper(), 52) - PaginaDict.Add("/Contabilidad/DiarioVentas.aspx".ToUpper(), 53) - PaginaDict.Add("/Contabilidad/ContabilizacionVentas.aspx".ToUpper(), 53) - PaginaDict.Add("/Contabilidad/ContabilizacionCompras.aspx".ToUpper(), 555) - PaginaDict.Add("/Contabilidad/ContabilizacionComprasRefinada.aspx".ToUpper(), 53) - PaginaDict.Add("/Contabilidad/DiarioCompras.aspx".ToUpper(), 130) - PaginaDict.Add("/Contabilidad/DiarioPagos.aspx".ToUpper(), 52) - PaginaDict.Add("/Contabilidad/DiarioAmortizaciones.aspx".ToUpper(), 119) - PaginaDict.Add("/Contabilidad/Poliza.aspx".ToUpper(), 54) - PaginaDict.Add("/Contabilidad/RegPoliza.aspx".ToUpper(), 54) - - PaginaDict.Add("/Contabilidad/TiposPoliza.aspx".ToUpper(), 165) - PaginaDict.Add("/Contabilidad/PlantillasPolizas.aspx".ToUpper(), 304) - PaginaDict.Add("/Contabilidad/PlantillasPolizasDetalle.aspx".ToUpper(), 304) - PaginaDict.Add("/Contabilidad/ConceptosContables.aspx".ToUpper(), 166) - PaginaDict.Add("/Contabilidad/RepAuxiliar.aspx".ToUpper(), 133) - PaginaDict.Add("/Contabilidad/RepPolizasCuadre.aspx".ToUpper(), 386) - - PaginaDict.Add("/Contabilidad/RepBalanceGeneralMensual.aspx".ToUpper(), 123) - PaginaDict.Add("/Contabilidad/RepEstadoResultadosMensual.aspx".ToUpper(), 124) - 'PaginaDict.Add("/Contabilidad/RepBalanceGeneralAnual.aspx".ToUpper(), 126) - PaginaDict.Add("/Contabilidad/RepEstadoResultadosAnual.aspx".ToUpper(), 127) - PaginaDict.Add("/Contabilidad/FiltraPolizas.aspx".ToUpper(), 128) - PaginaDict.Add("/Contabilidad/RepContabilidadDiaria.aspx".ToUpper(), 504) - PaginaDict.Add("/Contabilidad/CatCuentas.aspx".ToUpper(), 178) - PaginaDict.Add("/Contabilidad/RepOrigenAplicacion.aspx".ToUpper(), 354) - PaginaDict.Add("/Contabilidad/RepBalanceGeneralProForma.aspx".ToUpper(), 358) - PaginaDict.Add("/Contabilidad/RepEstadoResultadosProForma.aspx".ToUpper(), 359) - PaginaDict.Add("/Contabilidad/RepBalanceGeneral.aspx".ToUpper(), 362) - PaginaDict.Add("/Contabilidad/RepEstadoResultados.aspx".ToUpper(), 363) - PaginaDict.Add("/Contabilidad/RepIVADiferencias.aspx".ToUpper(), 127) - PaginaDict.Add("/Contabilidad/PolizasImpresion.aspx".ToUpper(), 380) - PaginaDict.Add("/Contabilidad/RegPrePoliza.aspx".ToUpper(), 398) + PaginaDict.Add("/Contabilidad/ContabilidadElectronica.aspx".ToUpper(), 566) + PaginaDict.Add("/Contabilidad/RepGastosCC.aspx".ToUpper(), 535) + PaginaDict.Add("/Contabilidad/ContabilizarPagosCliente.aspx".ToUpper(), 52) + PaginaDict.Add("/Contabilidad/DiarioVentas.aspx".ToUpper(), 53) + PaginaDict.Add("/Contabilidad/ContabilizacionVentas.aspx".ToUpper(), 53) + PaginaDict.Add("/Contabilidad/ContabilizacionCompras.aspx".ToUpper(), 555) + PaginaDict.Add("/Contabilidad/ContabilizacionComprasRefinada.aspx".ToUpper(), 53) + PaginaDict.Add("/Contabilidad/DiarioCompras.aspx".ToUpper(), 130) + PaginaDict.Add("/Contabilidad/DiarioPagos.aspx".ToUpper(), 52) + PaginaDict.Add("/Contabilidad/DiarioAmortizaciones.aspx".ToUpper(), 119) + PaginaDict.Add("/Contabilidad/Poliza.aspx".ToUpper(), 54) + PaginaDict.Add("/Contabilidad/RegPoliza.aspx".ToUpper(), 54) + + PaginaDict.Add("/Contabilidad/TiposPoliza.aspx".ToUpper(), 165) + PaginaDict.Add("/Contabilidad/PlantillasPolizas.aspx".ToUpper(), 304) + PaginaDict.Add("/Contabilidad/PlantillasPolizasDetalle.aspx".ToUpper(), 304) + PaginaDict.Add("/Contabilidad/ConceptosContables.aspx".ToUpper(), 166) + PaginaDict.Add("/Contabilidad/RepAuxiliar.aspx".ToUpper(), 133) + PaginaDict.Add("/Contabilidad/RepPolizasCuadre.aspx".ToUpper(), 386) + + PaginaDict.Add("/Contabilidad/RepBalanceGeneralMensual.aspx".ToUpper(), 123) + PaginaDict.Add("/Contabilidad/RepEstadoResultadosMensual.aspx".ToUpper(), 124) + 'PaginaDict.Add("/Contabilidad/RepBalanceGeneralAnual.aspx".ToUpper(), 126) + PaginaDict.Add("/Contabilidad/RepEstadoResultadosAnual.aspx".ToUpper(), 127) + PaginaDict.Add("/Contabilidad/FiltraPolizas.aspx".ToUpper(), 128) + PaginaDict.Add("/Contabilidad/RepContabilidadDiaria.aspx".ToUpper(), 504) + PaginaDict.Add("/Contabilidad/CatCuentas.aspx".ToUpper(), 178) + PaginaDict.Add("/Contabilidad/RepOrigenAplicacion.aspx".ToUpper(), 354) + PaginaDict.Add("/Contabilidad/RepBalanceGeneralProForma.aspx".ToUpper(), 358) + PaginaDict.Add("/Contabilidad/RepEstadoResultadosProForma.aspx".ToUpper(), 359) + PaginaDict.Add("/Contabilidad/RepBalanceGeneral.aspx".ToUpper(), 362) + PaginaDict.Add("/Contabilidad/RepEstadoResultados.aspx".ToUpper(), 363) + PaginaDict.Add("/Contabilidad/RepIVADiferencias.aspx".ToUpper(), 127) + PaginaDict.Add("/Contabilidad/PolizasImpresion.aspx".ToUpper(), 380) + PaginaDict.Add("/Contabilidad/RegPrePoliza.aspx".ToUpper(), 398) PaginaDict.Add("/Contabilidad/RegPrePoliza1.aspx".ToUpper(), 398) - PaginaDict.Add("/Contabilidad/RegPrePolizaS.aspx".ToUpper(), 398) - PaginaDict.Add("/Contabilidad/DescargaRespaldos.aspx".ToUpper(), 400) - PaginaDict.Add("/Contabilidad/RepBalanceGeneral2.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/CatEjercicios.aspx".ToUpper(), 570) - PaginaDict.Add("/Contabilidad/AnalisisVertical.aspx".ToUpper(), 416) - PaginaDict.Add("/Contabilidad/FisImpuestos.aspx".ToUpper(), 431) - PaginaDict.Add("/Contabilidad/RepFisImpuestos.aspx".ToUpper(), 432) - PaginaDict.Add("/Contabilidad/LibroDiario.aspx".ToUpper(), 620) - PaginaDict.Add("/Contabilidad/LibroMayor.aspx".ToUpper(), 619) - PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmon.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmonDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/ComparacionesContabilidad.aspx".ToUpper(), 330) - PaginaDict.Add("/Contabilidad/RepEdoResultados2.aspx".ToUpper(), 89) - PaginaDict.Add("/Contabilidad/RepEdoResultados2Detalle.aspx".ToUpper(), 89) - PaginaDict.Add("/Contabilidad/RepIVA.aspx".ToUpper(), 658) - PaginaDict.Add("/Contabilidad/AuxiliarPrePolizas.aspx".ToUpper(), 871) - PaginaDict.Add("/Contabilidad/RepEstadoResultadosPorSegmento.aspx".ToUpper(), 1317) - - PaginaDict.Add("/Contabilidad/RepAnexoCatalogoMes.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/RepAnexoCatalogoSegmento.aspx".ToUpper(), -1) - PaginaDict.Add("/Contabilidad/RepAnexoCatalogo.aspx".ToUpper(), 341) - PaginaDict.Add("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), 340) - PaginaDict.Add("/Contabilidad/RepBalanzaComprobacion.aspx".ToUpper(), 344) - PaginaDict.Add("/Contabilidad/CatCuentasSIG.aspx".ToUpper(), 405) - PaginaDict.Add("/Contabilidad/RepIEPS.aspx".ToUpper(), 714) + PaginaDict.Add("/Contabilidad/RegPrePolizaS.aspx".ToUpper(), 398) + PaginaDict.Add("/Contabilidad/DescargaRespaldos.aspx".ToUpper(), 400) + PaginaDict.Add("/Contabilidad/RepBalanceGeneral2.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/CatEjercicios.aspx".ToUpper(), 570) + PaginaDict.Add("/Contabilidad/AnalisisVertical.aspx".ToUpper(), 416) + PaginaDict.Add("/Contabilidad/FisImpuestos.aspx".ToUpper(), 431) + PaginaDict.Add("/Contabilidad/RepFisImpuestos.aspx".ToUpper(), 432) + PaginaDict.Add("/Contabilidad/LibroDiario.aspx".ToUpper(), 620) + PaginaDict.Add("/Contabilidad/LibroMayor.aspx".ToUpper(), 619) + PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmon.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmonDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/ComparacionesContabilidad.aspx".ToUpper(), 330) + PaginaDict.Add("/Contabilidad/RepEdoResultados2.aspx".ToUpper(), 89) + PaginaDict.Add("/Contabilidad/RepEdoResultados2Detalle.aspx".ToUpper(), 89) + PaginaDict.Add("/Contabilidad/RepIVA.aspx".ToUpper(), 658) + PaginaDict.Add("/Contabilidad/AuxiliarPrePolizas.aspx".ToUpper(), 871) + PaginaDict.Add("/Contabilidad/RepEstadoResultadosPorSegmento.aspx".ToUpper(), 1317) + + PaginaDict.Add("/Contabilidad/RepAnexoCatalogoMes.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/RepAnexoCatalogoSegmento.aspx".ToUpper(), -1) + PaginaDict.Add("/Contabilidad/RepAnexoCatalogo.aspx".ToUpper(), 341) + PaginaDict.Add("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), 340) + PaginaDict.Add("/Contabilidad/RepBalanzaComprobacion.aspx".ToUpper(), 344) + PaginaDict.Add("/Contabilidad/CatCuentasSIG.aspx".ToUpper(), 405) + PaginaDict.Add("/Contabilidad/RepIEPS.aspx".ToUpper(), 714) PaginaDict.Add("/Contabilidad/CatPeriodosBloqueo.aspx".ToUpper(), 677) PaginaDict.Add("/Contabilidad/CatClasificacionPorcentaje.aspx".ToUpper(), 752) -#End Region +#End Region 'CONTABILIDAD2 -#Region "Contabilidad2" - PaginaDict.Add("/Contabilidad2/RepAnexoCatalogo.aspx".ToUpper(), 580) - PaginaDict.Add("/Contabilidad2/RepBalanzaComprobacion.aspx".ToUpper(), 582) - PaginaDict.Add("/Contabilidad2/RepEstadoActividades.aspx".ToUpper(), 583) - PaginaDict.Add("/Contabilidad2/RepFlujoEfectivo.aspx".ToUpper(), 584) - PaginaDict.Add("/Contabilidad2/RepCambiosSituacionFinanciera.aspx".ToUpper(), 585) - PaginaDict.Add("/Contabilidad2/RepSituacionFinanciera.aspx".ToUpper(), 586) - PaginaDict.Add("/Contabilidad2/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), 587) - PaginaDict.Add("/Contabilidad2/RegPoliza.aspx".ToUpper(), 588) - PaginaDict.Add("/Contabilidad2/PymeRegPoliza.aspx".ToUpper(), 588) - PaginaDict.Add("/Contabilidad2/RepAlmacenConta.aspx".ToUpper(), 539) - - PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoMensual.aspx".ToUpper(), 589) - PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoAnual.aspx".ToUpper(), 593) - PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoCC.aspx".ToUpper(), 594) - PaginaDict.Add("/Contabilidad2/RepVariacionHaciendaPublica.aspx".ToUpper(), 595) - PaginaDict.Add("/Contabilidad2/CatCuentas.aspx".ToUpper(), 596) - - PaginaDict.Add("/Contabilidad2/RepSituacionFinancieraSAT.aspx".ToUpper(), 615) - PaginaDict.Add("/Contabilidad2/RepEstadoActividadesSAT.aspx".ToUpper(), 616) - PaginaDict.Add("/Contabilidad2/RepBalanzaComprobacionSAT.aspx".ToUpper(), 617) - PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoSAT.aspx".ToUpper(), 618) - PaginaDict.Add("/Contabilidad2/MovimientosConProveedores.aspx".ToUpper(), 619) - PaginaDict.Add("/Contabilidad2/RepBalanceGeneral.aspx".ToUpper(), 530) -#End Region - 'CONTRATOS -#Region "Contratos" - - '------------------------------ C O N T R A T O S - P R E S U P U E S T O S --------------------- - PaginaDict.Add("/Contratos/Presupuestos.aspx".ToUpper(), 901) - PaginaDict.Add("/Contratos/ModificarPresupuesto.aspx".ToUpper(), 902) - PaginaDict.Add("/Contratos/CatPresupuestos.aspx".ToUpper(), 903) - PaginaDict.Add("/Contratos/RepPresupuestos.aspx".ToUpper(), 905) - PaginaDict.Add("/Contratos/RepPresupuestosDetalle.aspx".ToUpper(), 905) - PaginaDict.Add("/Contratos/RepPresupuestosDetalleCompras.aspx".ToUpper(), 905) - PaginaDict.Add("/Contratos/FacturacionMasiva.aspx".ToUpper(), 454) - PaginaDict.Add("/Contratos/CatContratosPlantillas.aspx".ToUpper(), 455) - - - PaginaDict.Add("/Contratos/CatSecciones.aspx".ToUpper(), -1) '152 - PaginaDict.Add("/Contratos/ContratosSecciones.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/Contratos.aspx".ToUpper(), -1) '154 - PaginaDict.Add("/Contratos/ContratosDetalle.aspx".ToUpper(), -1) '154 - PaginaDict.Add("/Contratos/CatEstimaciones.aspx".ToUpper(), 155) - PaginaDict.Add("/Contratos/Contrato.aspx".ToUpper(), 313) - PaginaDict.Add("/Contratos/PopUpBuscarContrato.aspx".ToUpper(), 315) - PaginaDict.Add("/Contratos/ContratoAvance.aspx".ToUpper(), 377) - PaginaDict.Add("/Contratos/RepContratosAvancesCP.aspx".ToUpper(), 410) - PaginaDict.Add("/Contratos/CatPeriodosFacturacion.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/CatTarifas.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosSuministros.aspx".ToUpper(), 496) - PaginaDict.Add("/Contratos/RepContratosCostos.aspx".ToUpper(), 670) - 'PaginaDict.Add("/Contratos/CatReferendos.aspx".ToUpper(), 644) - PaginaDict.Add("/Contratos/CatRefrendos.aspx".ToUpper(), 644) - PaginaDict.Add("/Contratos/RepContratosFianzas.aspx".ToUpper(), 646) - PaginaDict.Add("/Contratos/RepPedidosDevolucionesXContrato.aspx".ToUpper(), 705) -#End Region - 'CONTABILIDAD2 - Finanzas -#Region "CrM" - 'CRM - PaginaDict.Add("/CRM/CatTipoProceso.aspx".ToUpper(), 1301) - PaginaDict.Add("/CRM/CatMediosCaptacion.aspx".ToUpper(), 1302) - PaginaDict.Add("/CRM/CatRechazoMotivo.aspx".ToUpper(), 1303) - PaginaDict.Add("/CRM/CatEtapasProceso.aspx".ToUpper(), 1304) - PaginaDict.Add("/CRM/CatEmpresasCRM.aspx".ToUpper(), 1305) - PaginaDict.Add("/CRM/EmpresaCRM.aspx".ToUpper(), 1305) - PaginaDict.Add("/CRM/CatProbabilidadAcercamiento.aspx".ToUpper(), 1306) - 'PaginaDict.Add("/CRM/Acercamiento.aspx".ToUpper(), 1308) - PaginaDict.Add("/CRM/Acercamiento.aspx".ToUpper(), 1305) - PaginaDict.Add("/CRM/RepAcercamientosEtapas.aspx".ToUpper(), 1310) - PaginaDict.Add("/CRM/RepAcercamientos.aspx".ToUpper(), 1311) - PaginaDict.Add("/CRM/PopUpBuscarAcercamiento.aspx".ToUpper(), 1312) - PaginaDict.Add("/CRM/RepAcercamientosProcesos.aspx".ToUpper(), -1) - PaginaDict.Add("/CRM/RepAcercamientosRechazos.aspx".ToUpper(), -1) - PaginaDict.Add("/CRM/RepAcercamientosProcesosDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/CRM/CatMetas.aspx".ToUpper(), 684) -#End Region -#Region "CxC" - - 'CxC - PaginaDict.Add("/CxC/RepCxC.aspx".ToUpper(), 8) - PaginaDict.Add("/CxC/RepCxCDetalle.aspx".ToUpper(), 565) - PaginaDict.Add("/CxC/RepCxCSemanal.aspx".ToUpper(), 31) - PaginaDict.Add("/CxC/GestionCobranza.aspx".ToUpper(), 490) - PaginaDict.Add("/CxC/RepCxCPeriodo.aspx".ToUpper(), 887) -#End Region -#Region "Finanzas" - 'Finanzas - PaginaDict.Add("/Finanzas/RepRazonesFinancieras.aspx".ToUpper(), 592) - PaginaDict.Add("/Finanzas/FinanMetas.aspx".ToUpper(), 361) - PaginaDict.Add("/Finanzas/FinanVentasProyecciones.aspx".ToUpper(), 360) - PaginaDict.Add("/Finanzas/AnalisisCreditoCliente.aspx".ToUpper(), 879) - PaginaDict.Add("/Finanzas/AnalisisCreditoProveedor.aspx".ToUpper(), 880) - PaginaDict.Add("/Finanzas/RepBalanceGeneral.aspx".ToUpper(), 578) - PaginaDict.Add("/Finanzas/RepBalanceGeneralVertical.aspx".ToUpper(), 418) - PaginaDict.Add("/Finanzas/RepBalanceGeneralHorizontal.aspx".ToUpper(), 419) - PaginaDict.Add("/Finanzas/RepEstadoResultados.aspx".ToUpper(), 579) - PaginaDict.Add("/Finanzas/RepEstadoResultadosHorizontal.aspx".ToUpper(), 420) - PaginaDict.Add("/Finanzas/RepEstadoResultadosVertical.aspx".ToUpper(), 424) - PaginaDict.Add("/Finanzas/RepOrigenAplicacion.aspx".ToUpper(), 581) - PaginaDict.Add("/Finanzas/RazonesFinancierasCuentas.aspx".ToUpper(), -1) - PaginaDict.Add("/Finanzas/RepRotacionCartera.aspx".ToUpper(), 649) - PaginaDict.Add("/Finanzas/RepRotacionCarteraDetalle.aspx".ToUpper(), 649) -#End Region -#Region "Flotillas" - - 'FLOTILLAS - PaginaDict.Add("/Flotillas/CatCombustibles.aspx".ToUpper(), 284) - PaginaDict.Add("/Flotillas/RepIncidentes.aspx".ToUpper(), 497) - PaginaDict.Add("/Flotillas/RepLicencias.aspx".ToUpper(), 498) - PaginaDict.Add("/Flotillas/RepPlacas.aspx".ToUpper(), 499) - PaginaDict.Add("/Flotillas/RepPolizaSeguro.aspx".ToUpper(), 500) - PaginaDict.Add("/Flotillas/RepServicios.aspx".ToUpper(), 501) -#End Region - 'GENERAL -#Region "General" - PaginaDict.Add("/General/CatClasificaciones.aspx".ToUpper(), 425) - PaginaDict.Add("/General/CatPSCaracteristicas.aspx".ToUpper(), 101) - PaginaDict.Add("/General/CatCategorias.aspx".ToUpper(), 233) - PaginaDict.Add("/General/SaldosIniciales.aspx".ToUpper(), 526) - PaginaDict.Add("/General/Colectivas.aspx".ToUpper(), 307) - PaginaDict.Add("/General/ColectivasDetalle.aspx".ToUpper(), 307) - PaginaDict.Add("/Planeacion/CatFolios.aspx".ToUpper(), 15) - PaginaDict.Add("/General/CatMarcas.aspx".ToUpper(), 402) - PaginaDict.Add("/General/CatCompuestos.aspx".ToUpper(), 470) - PaginaDict.Add("/Encuestas/Encuestas.aspx".ToUpper(), 1021) - PaginaDict.Add("/General/CatDiasInhabiles.aspx".ToUpper(), 429) - PaginaDict.Add("/General/CatTipoCambio.aspx".ToUpper(), 642) - PaginaDict.Add("/General/PopUpPaqueteriasGuias.aspx".ToUpper(), 659) - PaginaDict.Add("/General/CatPaqueterias.aspx".ToUpper(), 665) - PaginaDict.Add("/General/CatDocumentacionTipo.aspx".ToUpper(), -1) - PaginaDict.Add("/General/CatModelos.aspx".ToUpper(), 710) - PaginaDict.Add("/General/CatRinTamanios.aspx".ToUpper(), 711) - PaginaDict.Add("/General/CatMedidas.aspx".ToUpper(), 712) +#Region "Contabilidad2" + PaginaDict.Add("/Contabilidad2/RepAnexoCatalogo.aspx".ToUpper(), 580) + PaginaDict.Add("/Contabilidad2/RepBalanzaComprobacion.aspx".ToUpper(), 582) + PaginaDict.Add("/Contabilidad2/RepEstadoActividades.aspx".ToUpper(), 583) + PaginaDict.Add("/Contabilidad2/RepFlujoEfectivo.aspx".ToUpper(), 584) + PaginaDict.Add("/Contabilidad2/RepCambiosSituacionFinanciera.aspx".ToUpper(), 585) + PaginaDict.Add("/Contabilidad2/RepSituacionFinanciera.aspx".ToUpper(), 586) + PaginaDict.Add("/Contabilidad2/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), 587) + PaginaDict.Add("/Contabilidad2/RegPoliza.aspx".ToUpper(), 588) + PaginaDict.Add("/Contabilidad2/PymeRegPoliza.aspx".ToUpper(), 588) + PaginaDict.Add("/Contabilidad2/RepAlmacenConta.aspx".ToUpper(), 539) + + PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoMensual.aspx".ToUpper(), 589) + PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoAnual.aspx".ToUpper(), 593) + PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoCC.aspx".ToUpper(), 594) + PaginaDict.Add("/Contabilidad2/RepVariacionHaciendaPublica.aspx".ToUpper(), 595) + PaginaDict.Add("/Contabilidad2/CatCuentas.aspx".ToUpper(), 596) + + PaginaDict.Add("/Contabilidad2/RepSituacionFinancieraSAT.aspx".ToUpper(), 615) + PaginaDict.Add("/Contabilidad2/RepEstadoActividadesSAT.aspx".ToUpper(), 616) + PaginaDict.Add("/Contabilidad2/RepBalanzaComprobacionSAT.aspx".ToUpper(), 617) + PaginaDict.Add("/Contabilidad2/RepAnexoCatalogoSAT.aspx".ToUpper(), 618) + PaginaDict.Add("/Contabilidad2/MovimientosConProveedores.aspx".ToUpper(), 619) + PaginaDict.Add("/Contabilidad2/RepBalanceGeneral.aspx".ToUpper(), 530) +#End Region + 'CONTRATOS +#Region "Contratos" + + '------------------------------ C O N T R A T O S - P R E S U P U E S T O S --------------------- + PaginaDict.Add("/Contratos/Presupuestos.aspx".ToUpper(), 901) + PaginaDict.Add("/Contratos/ModificarPresupuesto.aspx".ToUpper(), 902) + PaginaDict.Add("/Contratos/CatPresupuestos.aspx".ToUpper(), 903) + PaginaDict.Add("/Contratos/RepPresupuestos.aspx".ToUpper(), 905) + PaginaDict.Add("/Contratos/RepPresupuestosDetalle.aspx".ToUpper(), 905) + PaginaDict.Add("/Contratos/RepPresupuestosDetalleCompras.aspx".ToUpper(), 905) + PaginaDict.Add("/Contratos/FacturacionMasiva.aspx".ToUpper(), 454) + PaginaDict.Add("/Contratos/CatContratosPlantillas.aspx".ToUpper(), 455) + + + PaginaDict.Add("/Contratos/CatSecciones.aspx".ToUpper(), -1) '152 + PaginaDict.Add("/Contratos/ContratosSecciones.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/Contratos.aspx".ToUpper(), -1) '154 + PaginaDict.Add("/Contratos/ContratosDetalle.aspx".ToUpper(), -1) '154 + PaginaDict.Add("/Contratos/CatEstimaciones.aspx".ToUpper(), 155) + PaginaDict.Add("/Contratos/Contrato.aspx".ToUpper(), 313) + PaginaDict.Add("/Contratos/PopUpBuscarContrato.aspx".ToUpper(), 315) + PaginaDict.Add("/Contratos/ContratoAvance.aspx".ToUpper(), 377) + PaginaDict.Add("/Contratos/RepContratosAvancesCP.aspx".ToUpper(), 410) + PaginaDict.Add("/Contratos/CatPeriodosFacturacion.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/CatTarifas.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/RepContratosSuministros.aspx".ToUpper(), 496) + PaginaDict.Add("/Contratos/RepContratosCostos.aspx".ToUpper(), 670) + 'PaginaDict.Add("/Contratos/CatReferendos.aspx".ToUpper(), 644) + PaginaDict.Add("/Contratos/CatRefrendos.aspx".ToUpper(), 644) + PaginaDict.Add("/Contratos/RepContratosFianzas.aspx".ToUpper(), 646) + PaginaDict.Add("/Contratos/RepPedidosDevolucionesXContrato.aspx".ToUpper(), 705) +#End Region + 'CONTABILIDAD2 - Finanzas +#Region "CrM" + 'CRM + PaginaDict.Add("/CRM/CatTipoProceso.aspx".ToUpper(), 1301) + PaginaDict.Add("/CRM/CatMediosCaptacion.aspx".ToUpper(), 1302) + PaginaDict.Add("/CRM/CatRechazoMotivo.aspx".ToUpper(), 1303) + PaginaDict.Add("/CRM/CatEtapasProceso.aspx".ToUpper(), 1304) + PaginaDict.Add("/CRM/CatEmpresasCRM.aspx".ToUpper(), 1305) + PaginaDict.Add("/CRM/EmpresaCRM.aspx".ToUpper(), 1305) + PaginaDict.Add("/CRM/CatProbabilidadAcercamiento.aspx".ToUpper(), 1306) + 'PaginaDict.Add("/CRM/Acercamiento.aspx".ToUpper(), 1308) + PaginaDict.Add("/CRM/Acercamiento.aspx".ToUpper(), 1305) + PaginaDict.Add("/CRM/RepAcercamientosEtapas.aspx".ToUpper(), 1310) + PaginaDict.Add("/CRM/RepAcercamientos.aspx".ToUpper(), 1311) + PaginaDict.Add("/CRM/PopUpBuscarAcercamiento.aspx".ToUpper(), 1312) + PaginaDict.Add("/CRM/RepAcercamientosProcesos.aspx".ToUpper(), -1) + PaginaDict.Add("/CRM/RepAcercamientosRechazos.aspx".ToUpper(), -1) + PaginaDict.Add("/CRM/RepAcercamientosProcesosDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/CRM/CatMetas.aspx".ToUpper(), 684) +#End Region +#Region "CxC" + + 'CxC + PaginaDict.Add("/CxC/RepCxC.aspx".ToUpper(), 8) + PaginaDict.Add("/CxC/RepCxCDetalle.aspx".ToUpper(), 565) + PaginaDict.Add("/CxC/RepCxCSemanal.aspx".ToUpper(), 31) + PaginaDict.Add("/CxC/GestionCobranza.aspx".ToUpper(), 490) + PaginaDict.Add("/CxC/RepCxCPeriodo.aspx".ToUpper(), 887) +#End Region +#Region "Finanzas" + 'Finanzas + PaginaDict.Add("/Finanzas/RepRazonesFinancieras.aspx".ToUpper(), 592) + PaginaDict.Add("/Finanzas/FinanMetas.aspx".ToUpper(), 361) + PaginaDict.Add("/Finanzas/FinanVentasProyecciones.aspx".ToUpper(), 360) + PaginaDict.Add("/Finanzas/AnalisisCreditoCliente.aspx".ToUpper(), 879) + PaginaDict.Add("/Finanzas/AnalisisCreditoProveedor.aspx".ToUpper(), 880) + PaginaDict.Add("/Finanzas/RepBalanceGeneral.aspx".ToUpper(), 578) + PaginaDict.Add("/Finanzas/RepBalanceGeneralVertical.aspx".ToUpper(), 418) + PaginaDict.Add("/Finanzas/RepBalanceGeneralHorizontal.aspx".ToUpper(), 419) + PaginaDict.Add("/Finanzas/RepEstadoResultados.aspx".ToUpper(), 579) + PaginaDict.Add("/Finanzas/RepEstadoResultadosHorizontal.aspx".ToUpper(), 420) + PaginaDict.Add("/Finanzas/RepEstadoResultadosVertical.aspx".ToUpper(), 424) + PaginaDict.Add("/Finanzas/RepOrigenAplicacion.aspx".ToUpper(), 581) + PaginaDict.Add("/Finanzas/RazonesFinancierasCuentas.aspx".ToUpper(), -1) + PaginaDict.Add("/Finanzas/RepRotacionCartera.aspx".ToUpper(), 649) + PaginaDict.Add("/Finanzas/RepRotacionCarteraDetalle.aspx".ToUpper(), 649) +#End Region +#Region "Flotillas" + + 'FLOTILLAS + PaginaDict.Add("/Flotillas/CatCombustibles.aspx".ToUpper(), 284) + PaginaDict.Add("/Flotillas/RepIncidentes.aspx".ToUpper(), 497) + PaginaDict.Add("/Flotillas/RepLicencias.aspx".ToUpper(), 498) + PaginaDict.Add("/Flotillas/RepPlacas.aspx".ToUpper(), 499) + PaginaDict.Add("/Flotillas/RepPolizaSeguro.aspx".ToUpper(), 500) + PaginaDict.Add("/Flotillas/RepServicios.aspx".ToUpper(), 501) +#End Region + 'GENERAL +#Region "General" + PaginaDict.Add("/General/CatClasificaciones.aspx".ToUpper(), 425) + PaginaDict.Add("/General/CatPSCaracteristicas.aspx".ToUpper(), 101) + PaginaDict.Add("/General/CatCategorias.aspx".ToUpper(), 233) + PaginaDict.Add("/General/SaldosIniciales.aspx".ToUpper(), 526) + PaginaDict.Add("/General/Colectivas.aspx".ToUpper(), 307) + PaginaDict.Add("/General/ColectivasDetalle.aspx".ToUpper(), 307) + PaginaDict.Add("/Planeacion/CatFolios.aspx".ToUpper(), 15) + PaginaDict.Add("/General/CatMarcas.aspx".ToUpper(), 402) + PaginaDict.Add("/General/CatCompuestos.aspx".ToUpper(), 470) + PaginaDict.Add("/Encuestas/Encuestas.aspx".ToUpper(), 1021) + PaginaDict.Add("/General/CatDiasInhabiles.aspx".ToUpper(), 429) + PaginaDict.Add("/General/CatTipoCambio.aspx".ToUpper(), 642) + PaginaDict.Add("/General/PopUpPaqueteriasGuias.aspx".ToUpper(), 659) + PaginaDict.Add("/General/CatPaqueterias.aspx".ToUpper(), 665) + PaginaDict.Add("/General/CatDocumentacionTipo.aspx".ToUpper(), -1) + PaginaDict.Add("/General/CatModelos.aspx".ToUpper(), 710) + PaginaDict.Add("/General/CatRinTamanios.aspx".ToUpper(), 711) + PaginaDict.Add("/General/CatMedidas.aspx".ToUpper(), 712) PaginaDict.Add("/General/CatSatListado69B.aspx".ToUpper, 1038) -#End Region -#Region "GPS" - PaginaDict.Add("/GPS/RepTemperatura.aspx".ToUpper(), 681) - PaginaDict.Add("/GPS/FacturasSims.aspx".ToUpper(), 8401) - PaginaDict.Add("/GPS/VehiculoTrama.aspx".ToUpper(), 682) - PaginaDict.Add("/GPS/DashboardGPS.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/WizardModelo.aspx".ToUpper(), 458) - PaginaDict.Add("/GPS/CatConductores.aspx".ToUpper(), 448) - PaginaDict.Add("/GPS/Conductores.aspx".ToUpper(), 502) - PaginaDict.Add("/GPS/CatVehiculos.aspx".ToUpper(), 449) - PaginaDict.Add("/GPS/CatProveedoresComunicacionCuentas.aspx".ToUpper(), 442) - PaginaDict.Add("/GPS/CatPlanesDatos.aspx".ToUpper(), 443) - PaginaDict.Add("/GPS/WizardDispositivos.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/CatDispositivos.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/CatModelos.aspx".ToUpper(), 434) - PaginaDict.Add("/GPS/CatEventosTipos.aspx".ToUpper(), 435) - PaginaDict.Add("/GPS/CatEventos.aspx".ToUpper(), 436) - PaginaDict.Add("/GPS/CatTipoComunicacion.aspx".ToUpper(), 438) - PaginaDict.Add("/GPS/CatProveedorComunicacion.aspx".ToUpper(), 439) - PaginaDict.Add("/GPS/CatDistribuidoresMaster.aspx".ToUpper(), 441) - PaginaDict.Add("/GPS/Rastreo.aspx".ToUpper(), 444) - PaginaDict.Add("/GPS/GeoReferencias.aspx".ToUpper(), 471) - PaginaDict.Add("/GPS/RepGeoReferencias.aspx".ToUpper(), 472) - PaginaDict.Add("/GPS/PuntosDeInteres.aspx".ToUpper(), 487) - PaginaDict.Add("/GPS/RepPuntosDeInteres.aspx".ToUpper(), 488) - PaginaDict.Add("/GPS/CatControlesGraficos.aspx".ToUpper(), 451) - PaginaDict.Add("/GPS/Dashboard.aspx".ToUpper(), -1) - PaginaDict.Add("/PortalGPS/InicioGPS.aspx".ToUpper(), 447) - PaginaDict.Add("/GPS/Soporte.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/Vehiculos.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/DispositivosControles.aspx".ToUpper(), 495) - PaginaDict.Add("/GPS/CatUMControles.aspx".ToUpper(), 503) - PaginaDict.Add("/GPS/Busqueda.aspx".ToUpper(), 459) - PaginaDict.Add("/GPS/ConfiguradorVehiculos.aspx".ToUpper(), 485) - PaginaDict.Add("/GPS/CatReportesProgramados.aspx".ToUpper(), 479) - PaginaDict.Add("/GPS/EntradasSalidasGR.aspx".ToUpper(), 483) - PaginaDict.Add("/GPS/ConfiguracionUsuarios.aspx".ToUpper(), 489) - PaginaDict.Add("/GPS/CatUsuarios.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/CatRemisionesVehiculos.aspx".ToUpper(), 484) - PaginaDict.Add("/GPS/ConfiguracionEventos.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/UsuariosRastreo.aspx".ToUpper(), 492) - PaginaDict.Add("/GPS/ReporteAccesos.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/RepCombustible.aspx".ToUpper(), 513) - PaginaDict.Add("/GPS/RepTemperaturas.aspx".ToUpper(), 516) - PaginaDict.Add("/GPS/RepPasajeros.aspx".ToUpper(), 517) - PaginaDict.Add("/GPS/RepParadas.aspx".ToUpper(), 518) - PaginaDict.Add("/GPS/RepPasajero.aspx".ToUpper(), 520) - PaginaDict.Add("/GPS/RepEventos.aspx".ToUpper(), 521) - PaginaDict.Add("/GPS/RepIgnicion.aspx".ToUpper(), 522) - PaginaDict.Add("/GPS/Trayectos.aspx".ToUpper(), 523) - PaginaDict.Add("/GPS/TrayectoDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/GPS/CatEstatusTrayectos.aspx".ToUpper(), 527) - PaginaDict.Add("/GPS/CatRutas.aspx".ToUpper(), 640) - PaginaDict.Add("/GPS/CatGrupos.aspx".ToUpper(), 641) - PaginaDict.Add("/GPS/Notificaciones.aspx".ToUpper(), -1) +#End Region +#Region "GPS" + PaginaDict.Add("/GPS/RepTemperatura.aspx".ToUpper(), 681) + PaginaDict.Add("/GPS/FacturasSims.aspx".ToUpper(), 8401) + PaginaDict.Add("/GPS/VehiculoTrama.aspx".ToUpper(), 682) + PaginaDict.Add("/GPS/DashboardGPS.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/WizardModelo.aspx".ToUpper(), 458) + PaginaDict.Add("/GPS/CatConductores.aspx".ToUpper(), 448) + PaginaDict.Add("/GPS/Conductores.aspx".ToUpper(), 502) + PaginaDict.Add("/GPS/CatVehiculos.aspx".ToUpper(), 449) + PaginaDict.Add("/GPS/CatProveedoresComunicacionCuentas.aspx".ToUpper(), 442) + PaginaDict.Add("/GPS/CatPlanesDatos.aspx".ToUpper(), 443) + PaginaDict.Add("/GPS/WizardDispositivos.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/CatDispositivos.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/CatModelos.aspx".ToUpper(), 434) + PaginaDict.Add("/GPS/CatEventosTipos.aspx".ToUpper(), 435) + PaginaDict.Add("/GPS/CatEventos.aspx".ToUpper(), 436) + PaginaDict.Add("/GPS/CatTipoComunicacion.aspx".ToUpper(), 438) + PaginaDict.Add("/GPS/CatProveedorComunicacion.aspx".ToUpper(), 439) + PaginaDict.Add("/GPS/CatDistribuidoresMaster.aspx".ToUpper(), 441) + PaginaDict.Add("/GPS/Rastreo.aspx".ToUpper(), 444) + PaginaDict.Add("/GPS/GeoReferencias.aspx".ToUpper(), 471) + PaginaDict.Add("/GPS/RepGeoReferencias.aspx".ToUpper(), 472) + PaginaDict.Add("/GPS/PuntosDeInteres.aspx".ToUpper(), 487) + PaginaDict.Add("/GPS/RepPuntosDeInteres.aspx".ToUpper(), 488) + PaginaDict.Add("/GPS/CatControlesGraficos.aspx".ToUpper(), 451) + PaginaDict.Add("/GPS/Dashboard.aspx".ToUpper(), -1) + PaginaDict.Add("/PortalGPS/InicioGPS.aspx".ToUpper(), 447) + PaginaDict.Add("/GPS/Soporte.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/Vehiculos.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/DispositivosControles.aspx".ToUpper(), 495) + PaginaDict.Add("/GPS/CatUMControles.aspx".ToUpper(), 503) + PaginaDict.Add("/GPS/Busqueda.aspx".ToUpper(), 459) + PaginaDict.Add("/GPS/ConfiguradorVehiculos.aspx".ToUpper(), 485) + PaginaDict.Add("/GPS/CatReportesProgramados.aspx".ToUpper(), 479) + PaginaDict.Add("/GPS/EntradasSalidasGR.aspx".ToUpper(), 483) + PaginaDict.Add("/GPS/ConfiguracionUsuarios.aspx".ToUpper(), 489) + PaginaDict.Add("/GPS/CatUsuarios.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/CatRemisionesVehiculos.aspx".ToUpper(), 484) + PaginaDict.Add("/GPS/ConfiguracionEventos.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/UsuariosRastreo.aspx".ToUpper(), 492) + PaginaDict.Add("/GPS/ReporteAccesos.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/RepCombustible.aspx".ToUpper(), 513) + PaginaDict.Add("/GPS/RepTemperaturas.aspx".ToUpper(), 516) + PaginaDict.Add("/GPS/RepPasajeros.aspx".ToUpper(), 517) + PaginaDict.Add("/GPS/RepParadas.aspx".ToUpper(), 518) + PaginaDict.Add("/GPS/RepPasajero.aspx".ToUpper(), 520) + PaginaDict.Add("/GPS/RepEventos.aspx".ToUpper(), 521) + PaginaDict.Add("/GPS/RepIgnicion.aspx".ToUpper(), 522) + PaginaDict.Add("/GPS/Trayectos.aspx".ToUpper(), 523) + PaginaDict.Add("/GPS/TrayectoDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/CatEstatusTrayectos.aspx".ToUpper(), 527) + PaginaDict.Add("/GPS/CatRutas.aspx".ToUpper(), 640) + PaginaDict.Add("/GPS/CatGrupos.aspx".ToUpper(), 641) + PaginaDict.Add("/GPS/Notificaciones.aspx".ToUpper(), -1) PaginaDict.Add("/GPS/Shipments.aspx".ToUpper(), 673) PaginaDict.Add("/GPS/RepGastos.aspx".ToUpper(), 685) -#End Region +#End Region 'INVENTARIOS -#Region "Inventarios" - PaginaDict.Add("/Inventarios/Fletes.aspx".ToUpper(), 550) - PaginaDict.Add("/Inventarios/RepFletes.aspx".ToUpper(), 551) - PaginaDict.Add("/Inventarios/CatTiposAlmacenes.aspx".ToUpper(), 222) - PaginaDict.Add("/Inventarios/CatSeccionesAlmacenes.aspx".ToUpper(), 221) - PaginaDict.Add("/Inventarios/CatAlmacenes.aspx".ToUpper(), 220) - PaginaDict.Add("/Inventarios/EntradasSalidas.aspx".ToUpper(), 219) - PaginaDict.Add("/Inventarios/Kardex.aspx".ToUpper(), 224) - PaginaDict.Add("/Inventarios/Equivalencias.aspx".ToUpper(), 225) - PaginaDict.Add("/Inventarios/RepEntradasSalidas.aspx".ToUpper(), 227) - PaginaDict.Add("/Inventarios/RepExistenciasCostos.aspx".ToUpper(), 228) - PaginaDict.Add("/Inventarios/PopUpExistenciasAlmacen.aspx".ToUpper(), 228) - PaginaDict.Add("/Inventarios/InventarioFisico.aspx".ToUpper(), 229) - PaginaDict.Add("/Inventarios/InventarioFisicoDetalle.aspx".ToUpper(), 229) - PaginaDict.Add("/Inventarios/RepAnomalias.aspx".ToUpper(), 230) - PaginaDict.Add("/Inventarios/PaquetesArmadoDesarmado.aspx".ToUpper(), 226) - PaginaDict.Add("/Inventarios/ConsignacionesMaterial.aspx".ToUpper(), 227) - PaginaDict.Add("/Inventarios/RecepcionAlmacen.aspx".ToUpper(), 241) - PaginaDict.Add("/Inventarios/TraspasoAlmacen.aspx".ToUpper(), 343) - PaginaDict.Add("/Inventarios/Consignaciones.aspx".ToUpper(), 356) - PaginaDict.Add("/Inventarios/RepConsignaciones.aspx".ToUpper(), 364) - PaginaDict.Add("/Inventarios/RepAlmacenCompras.aspx".ToUpper(), 375) - PaginaDict.Add("/Inventarios/RepAlmacen.aspx".ToUpper(), 376) - PaginaDict.Add("/Inventarios/RecepcionEntrega.aspx".ToUpper(), 387) - PaginaDict.Add("/Inventarios/RepUMEquivalencia.aspx".ToUpper(), 399) - PaginaDict.Add("/Inventarios/ResguardoMaterial.aspx".ToUpper(), 562) - PaginaDict.Add("/Inventarios/RepMaximoMinimo.aspx".ToUpper(), 389) - PaginaDict.Add("/Inventarios/RepMovimientos.aspx".ToUpper(), 1009) - PaginaDict.Add("/Inventarios/RepNotasSinAlmacen.aspx".ToUpper(), 1010) - PaginaDict.Add("/Inventarios/RepOcInv.aspx".ToUpper(), 1011) - PaginaDict.Add("/Inventarios/RepOcInvMoto.aspx".ToUpper(), 1012) - 'PaginaDict.Add("/Inventarios/RepEntregasForaneas.aspx".ToUpper(), 450) - PaginaDict.Add("/General/RepPaqueteriasGuias.aspx".ToUpper(), 450) - PaginaDict.Add("/Inventarios/Apartados.aspx".ToUpper(), 622) - PaginaDict.Add("/Inventarios/RepApartados.aspx".ToUpper(), 623) - PaginaDict.Add("/Inventarios/RepApartados2.aspx".ToUpper(), 671) - PaginaDict.Add("/Inventarios/RepVentasXSurtir.aspx".ToUpper(), 624) - PaginaDict.Add("/Inventarios/PopUpExistenciasAlmacenDT.aspx".ToUpper(), -1) - PaginaDict.Add("/Inventarios/PopUpBuscarMovto.aspx".ToUpper(), 219) - PaginaDict.Add("/Inventarios/RepMaterialResguardo.aspx".ToUpper(), 493) - PaginaDict.Add("/Inventarios/TrasladoSolicitud.aspx".ToUpper(), 524) - PaginaDict.Add("/Inventarios/RepTrasladoSolicitud.aspx".ToUpper(), 514) - PaginaDict.Add("/Inventarios/CatGrupoPS.aspx".ToUpper(), 849) - PaginaDict.Add("/Inventarios/KardexAlmacen.aspx".ToUpper(), 639) - PaginaDict.Add("/Inventarios/KardexAlmacenHorizontal.aspx".ToUpper(), 645) - PaginaDict.Add("/Inventarios/RepConsumoInterno.aspx".ToUpper(), 660) - PaginaDict.Add("/Inventarios/RepMovimientosProveedor.aspx".ToUpper(), 867) - PaginaDict.Add("/Inventarios/RepReciclaje.aspx".ToUpper(), 873) - PaginaDict.Add("/Inventarios/Remanufactura.aspx".ToUpper(), 873) - PaginaDict.Add("/Inventarios/RepEntradasSalidasXContrato.aspx".ToUpper(), 876) - PaginaDict.Add("/Inventarios/RepAlmacenPeriodo.aspx".ToUpper(), 883) - PaginaDict.Add("/Inventarios/PrestamosdeProveedor.aspx".ToUpper(), 668) - PaginaDict.Add("/Inventarios/RepMovimientosSalida.aspx".ToUpper(), 541) - 'PaginaDict.Add("/Inventarios/RecepcionAlmacen.aspx".ToUpper(), 2022) - 'PaginaDict.Add("/Inventarios/RecepcionEntrega.aspx".ToUpper(), 2023) - 'PaginaDict.Add("/Inventarios/CatAlmacenes.aspx".ToUpper(), 2024) - 'PaginaDict.Add("/Inventarios/EntradasSalidas.aspx".ToUpper(), 2025) - 'PaginaDict.Add("/Inventarios/TraspasoAlmacen.aspx".ToUpper(), 2026) - PaginaDict.Add("/Inventarios/EntradasSalidas.aspx?CI=1".ToUpper(), 2027) - 'PaginaDict.Add("/Inventarios/RepMovimientos.aspx".ToUpper(), 2028) - 'PaginaDict.Add("/Inventarios/RepAlmacen.aspx".ToUpper(), 2029) - 'PaginaDict.Add("/Inventarios/RepEntradasSalidas.aspx".ToUpper(), 2030) - 'PaginaDict.Add("/Inventarios/Kardex.aspx".ToUpper(), 2031) - PaginaDict.Add("/Inventarios/RepEntradasSalidas2.aspx".ToUpper(), -1) - ' PaginaDict.Add("/Inventarios/RecepcionUsados.aspx".ToUpper(), 1202) - PaginaDict.Add("/Inventarios/RepTraspasoEmitido.aspx".ToUpper(), 891) - PaginaDict.Add("/Inventarios/KardexSeccionAlmacen.aspx".ToUpper(), 892) +#Region "Inventarios" + PaginaDict.Add("/Inventarios/Fletes.aspx".ToUpper(), 550) + PaginaDict.Add("/Inventarios/RepFletes.aspx".ToUpper(), 551) + PaginaDict.Add("/Inventarios/CatTiposAlmacenes.aspx".ToUpper(), 222) + PaginaDict.Add("/Inventarios/CatSeccionesAlmacenes.aspx".ToUpper(), 221) + PaginaDict.Add("/Inventarios/CatAlmacenes.aspx".ToUpper(), 220) + PaginaDict.Add("/Inventarios/EntradasSalidas.aspx".ToUpper(), 219) + PaginaDict.Add("/Inventarios/Kardex.aspx".ToUpper(), 224) + PaginaDict.Add("/Inventarios/Equivalencias.aspx".ToUpper(), 225) + PaginaDict.Add("/Inventarios/RepEntradasSalidas.aspx".ToUpper(), 227) + PaginaDict.Add("/Inventarios/RepExistenciasCostos.aspx".ToUpper(), 228) + PaginaDict.Add("/Inventarios/PopUpExistenciasAlmacen.aspx".ToUpper(), 228) + PaginaDict.Add("/Inventarios/InventarioFisico.aspx".ToUpper(), 229) + PaginaDict.Add("/Inventarios/InventarioFisicoDetalle.aspx".ToUpper(), 229) + PaginaDict.Add("/Inventarios/RepAnomalias.aspx".ToUpper(), 230) + PaginaDict.Add("/Inventarios/PaquetesArmadoDesarmado.aspx".ToUpper(), 226) + PaginaDict.Add("/Inventarios/ConsignacionesMaterial.aspx".ToUpper(), 227) + PaginaDict.Add("/Inventarios/RecepcionAlmacen.aspx".ToUpper(), 241) + PaginaDict.Add("/Inventarios/TraspasoAlmacen.aspx".ToUpper(), 343) + PaginaDict.Add("/Inventarios/Consignaciones.aspx".ToUpper(), 356) + PaginaDict.Add("/Inventarios/RepConsignaciones.aspx".ToUpper(), 364) + PaginaDict.Add("/Inventarios/RepAlmacenCompras.aspx".ToUpper(), 375) + PaginaDict.Add("/Inventarios/RepAlmacen.aspx".ToUpper(), 376) + PaginaDict.Add("/Inventarios/RecepcionEntrega.aspx".ToUpper(), 387) + PaginaDict.Add("/Inventarios/RepUMEquivalencia.aspx".ToUpper(), 399) + PaginaDict.Add("/Inventarios/ResguardoMaterial.aspx".ToUpper(), 562) + PaginaDict.Add("/Inventarios/RepMaximoMinimo.aspx".ToUpper(), 389) + PaginaDict.Add("/Inventarios/RepMovimientos.aspx".ToUpper(), 1009) + PaginaDict.Add("/Inventarios/RepNotasSinAlmacen.aspx".ToUpper(), 1010) + PaginaDict.Add("/Inventarios/RepOcInv.aspx".ToUpper(), 1011) + PaginaDict.Add("/Inventarios/RepOcInvMoto.aspx".ToUpper(), 1012) + 'PaginaDict.Add("/Inventarios/RepEntregasForaneas.aspx".ToUpper(), 450) + PaginaDict.Add("/General/RepPaqueteriasGuias.aspx".ToUpper(), 450) + PaginaDict.Add("/Inventarios/Apartados.aspx".ToUpper(), 622) + PaginaDict.Add("/Inventarios/RepApartados.aspx".ToUpper(), 623) + PaginaDict.Add("/Inventarios/RepApartados2.aspx".ToUpper(), 671) + PaginaDict.Add("/Inventarios/RepVentasXSurtir.aspx".ToUpper(), 624) + PaginaDict.Add("/Inventarios/PopUpExistenciasAlmacenDT.aspx".ToUpper(), -1) + PaginaDict.Add("/Inventarios/PopUpBuscarMovto.aspx".ToUpper(), 219) + PaginaDict.Add("/Inventarios/RepMaterialResguardo.aspx".ToUpper(), 493) + PaginaDict.Add("/Inventarios/TrasladoSolicitud.aspx".ToUpper(), 524) + PaginaDict.Add("/Inventarios/RepTrasladoSolicitud.aspx".ToUpper(), 514) + PaginaDict.Add("/Inventarios/CatGrupoPS.aspx".ToUpper(), 849) + PaginaDict.Add("/Inventarios/KardexAlmacen.aspx".ToUpper(), 639) + PaginaDict.Add("/Inventarios/KardexAlmacenHorizontal.aspx".ToUpper(), 645) + PaginaDict.Add("/Inventarios/RepConsumoInterno.aspx".ToUpper(), 660) + PaginaDict.Add("/Inventarios/RepMovimientosProveedor.aspx".ToUpper(), 867) + PaginaDict.Add("/Inventarios/RepReciclaje.aspx".ToUpper(), 873) + PaginaDict.Add("/Inventarios/Remanufactura.aspx".ToUpper(), 873) + PaginaDict.Add("/Inventarios/RepEntradasSalidasXContrato.aspx".ToUpper(), 876) + PaginaDict.Add("/Inventarios/RepAlmacenPeriodo.aspx".ToUpper(), 883) + PaginaDict.Add("/Inventarios/PrestamosdeProveedor.aspx".ToUpper(), 668) + PaginaDict.Add("/Inventarios/RepMovimientosSalida.aspx".ToUpper(), 541) + 'PaginaDict.Add("/Inventarios/RecepcionAlmacen.aspx".ToUpper(), 2022) + 'PaginaDict.Add("/Inventarios/RecepcionEntrega.aspx".ToUpper(), 2023) + 'PaginaDict.Add("/Inventarios/CatAlmacenes.aspx".ToUpper(), 2024) + 'PaginaDict.Add("/Inventarios/EntradasSalidas.aspx".ToUpper(), 2025) + 'PaginaDict.Add("/Inventarios/TraspasoAlmacen.aspx".ToUpper(), 2026) + PaginaDict.Add("/Inventarios/EntradasSalidas.aspx?CI=1".ToUpper(), 2027) + 'PaginaDict.Add("/Inventarios/RepMovimientos.aspx".ToUpper(), 2028) + 'PaginaDict.Add("/Inventarios/RepAlmacen.aspx".ToUpper(), 2029) + 'PaginaDict.Add("/Inventarios/RepEntradasSalidas.aspx".ToUpper(), 2030) + 'PaginaDict.Add("/Inventarios/Kardex.aspx".ToUpper(), 2031) + PaginaDict.Add("/Inventarios/RepEntradasSalidas2.aspx".ToUpper(), -1) + ' PaginaDict.Add("/Inventarios/RecepcionUsados.aspx".ToUpper(), 1202) + PaginaDict.Add("/Inventarios/RepTraspasoEmitido.aspx".ToUpper(), 891) + PaginaDict.Add("/Inventarios/KardexSeccionAlmacen.aspx".ToUpper(), 892) PaginaDict.Add("/Inventarios/RepTraspasoAlmacen.aspx".ToUpper(), 688) -#End Region -#Region "MF" - PaginaDict.Add("/MF/BitacoraDiaria.aspx".ToUpper(), 801) - PaginaDict.Add("/MF/CatActividades.aspx".ToUpper(), 803) - PaginaDict.Add("/MF/CatOperadores.aspx".ToUpper(), 804) - PaginaDict.Add("/MF/CatEstatus.aspx".ToUpper(), 805) - PaginaDict.Add("/MF/CargaLayout.aspx".ToUpper(), 863) - PaginaDict.Add("/MF/RepConsumoCombustible.aspx".ToUpper(), 864) -#End Region -#Region "Nomina" - - 'NÓMINA - PaginaDict.Add("/Nomina/Calculo.aspx".ToUpper(), -1) - PaginaDict.Add("/Nomina/SobreRecibo.aspx".ToUpper(), -1) - PaginaDict.Add("/Nomina/SobreReciboCharlie.aspx".ToUpper(), -1) - PaginaDict.Add("/Nomina/CatTiposPeriodos.aspx".ToUpper(), 60) - PaginaDict.Add("/Nomina/PreNomina.aspx".ToUpper(), 74) - PaginaDict.Add("/Nomina/PreNominaHistorial.aspx".ToUpper(), 148) - PaginaDict.Add("/Nomina/RepPreNomina.aspx".ToUpper(), 74) - PaginaDict.Add("/Nomina/Nomina.aspx".ToUpper(), 75) - PaginaDict.Add("/Nomina/NominaB.aspx".ToUpper(), 75) - PaginaDict.Add("/Nomina/Nomina2.aspx".ToUpper(), 75) - PaginaDict.Add("/Nomina/ListaAsistencias.aspx".ToUpper(), 91) - PaginaDict.Add("/Nomina/ConceptosEspeciales.aspx".ToUpper(), 136) - PaginaDict.Add("/Nomina/CatConceptos.aspx".ToUpper(), 172) - PaginaDict.Add("/Nomina/ConceptoNomina.aspx".ToUpper(), 172) - PaginaDict.Add("/Nomina/RegistroNomina.aspx".ToUpper(), 173) - PaginaDict.Add("/Nomina/RepConceptosAcumulados.aspx".ToUpper(), 174) - PaginaDict.Add("/Nomina/RepPersonalAcumulados.aspx".ToUpper(), 393) - PaginaDict.Add("/Nomina/CatPeriodos.aspx".ToUpper(), 177) - PaginaDict.Add("/Nomina/Finiquito.aspx".ToUpper(), 197) - PaginaDict.Add("/Nomina/CatSatBancos.aspx".ToUpper(), 255) - PaginaDict.Add("/Nomina/CatSatConceptos.aspx".ToUpper(), 256) - PaginaDict.Add("/Nomina/CatSatRegimenContratacion.aspx".ToUpper(), 257) - PaginaDict.Add("/Nomina/CatSatTipoIncapacidad.aspx".ToUpper(), 258) - PaginaDict.Add("/Nomina/CatSatRiesgoPuesto.aspx".ToUpper(), 259) - PaginaDict.Add("/Nomina/ReportePTU.aspx".ToUpper(), 870) -#End Region - 'Ordenes de Servicios -#Region "OS" - PaginaDict.Add("/OS/PopUpBuscarOS.aspx".ToUpper(), 80) - PaginaDict.Add("/OS/CatEstatusOrdenServicio.aspx".ToUpper(), 99) - PaginaDict.Add("/OS/PopUpBuscarCuentasEquipos.aspx".ToUpper(), 100) - PaginaDict.Add("/OS/PopUpCuentasEquipos.aspx".ToUpper(), -1) - 'PaginaDict.Add("/OS/CatSubTiposOrdenesServicios.aspx".ToUpper(), 101) - - 'PaginaDict.Add("/OS/CatCaracteristicasOrdenServicio.aspx".ToUpper(), 131) - 'PaginaDict.Add("/OS/CatOSCaracteristicasOpciones.aspx".ToUpper(), 132) - PaginaDict.Add("/OS/RepOrdenesServicios.aspx".ToUpper(), 134) - PaginaDict.Add("/OS/OrdenesServicios.aspx".ToUpper(), 135) - PaginaDict.Add("/OS/CatTipoCuentasEquipos.aspx".ToUpper(), 159) - PaginaDict.Add("/OS/CatTiposOrdenesServicios.aspx".ToUpper(), 167) - PaginaDict.Add("/OS/PopUpOS_PS_Especificaciones.aspx".ToUpper(), 135) - PaginaDict.Add("/OS/PopUpMateriales.aspx".ToUpper(), 135) - PaginaDict.Add("/OS/Asignaciones.aspx".ToUpper(), 125) -#End Region - 'OC -#Region "OC" - PaginaDict.Add("/OC/OC.aspx".ToUpper(), 155) - PaginaDict.Add("/OC/OC2.aspx".ToUpper(), -1) - - PaginaDict.Add("/OC/OCCompras.aspx".ToUpper(), 158) - 'PaginaDict.Add("/OC/CatEstatusOrdenCompra.aspx".ToUpper(), 156) - 'PaginaDict.Add("/OC/CatEstatusUsuarios.aspx".ToUpper(), 156) - PaginaDict.Add("/OC/RepOC.aspx".ToUpper(), 157) - PaginaDict.Add("/OC/CatEstatus.aspx".ToUpper(), 162) - PaginaDict.Add("/OC/RepRequisiciones.aspx".ToUpper(), 249) - 'PaginaDict.Add("/OC/PopOCCotizaciones.aspx".ToUpper(), 155) - PaginaDict.Add("/OC/PopUpBuscarReq.aspx".ToUpper(), 305) - PaginaDict.Add("/OC/RepCotizaciones.aspx".ToUpper(), 158) - PaginaDict.Add("/OC/RepCotizacionesDetalle.aspx".ToUpper(), 158) - PaginaDict.Add("/OC/PopUpBuscarCot.aspx".ToUpper(), 160) - PaginaDict.Add("/OC/Cotizaciones.aspx".ToUpper(), 132) - PaginaDict.Add("/OC/CotizacionEnLinea.aspx".ToUpper(), -1) - PaginaDict.Add("/OC/CotizacionEnvio.aspx".ToUpper(), -1) - PaginaDict.Add("/OC/OC.aspx?Tipo= REQ", 250) - PaginaDict.Add("/OC/RepOCSinFactura.aspx".ToUpper(), 388) - PaginaDict.Add("/OC/RepOCxSurtir.aspx".ToUpper(), 469) - PaginaDict.Add("/OC/RepReqXOC.aspx".ToUpper(), 634) - PaginaDict.Add("/OC/RepOCGuias.aspx".ToUpper(), 494) - PaginaDict.Add("/OC/ListaRequisicion.aspx".ToUpper(), 667) - PaginaDict.Add("/OC/RepOCAnticiposPtes.aspx".ToUpper(), 506) - PaginaDict.Add("/OC/RepSolicitudesAnticipo.aspx".ToUpper(), 529) -#End Region - 'OI -#Region "OI" - PaginaDict.Add("/OI/EventoDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/Normatividad.aspx".ToUpper(), 669) - PaginaDict.Add("/OI/RepNormatividad.aspx".ToUpper(), 669) - PaginaDict.Add("/OI/Minutas.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/RepDocumentos.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/EventoComentario.aspx".ToUpper(), -1) - - PaginaDict.Add("/OI/RepEventos.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/RepTareas.aspx".ToUpper(), 293) - PaginaDict.Add("/OI/RepMinutas.aspx".ToUpper(), 338) - PaginaDict.Add("/OI/PopUpAgenda.aspx".ToUpper(), -1) - PaginaDict.Add("/OI/RepSoporteADS.aspx".ToUpper(), 456) - PaginaDict.Add("/OI/SoporteADS.aspx".ToUpper(), 457) - PaginaDict.Add("/OI/Desarrollo.aspx".ToUpper(), 473) - PaginaDict.Add("/OI/RepDesarrollo.aspx".ToUpper(), 475) - PaginaDict.Add("/OI/DesarrolloWizard.aspx".ToUpper(), 474) - PaginaDict.Add("/OI/SubidasADS.aspx".ToUpper(), 476) -#End Region -#Region "Planeacion" - 'PLANEACIÓN - PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 17) - PaginaDict.Add("/Planeacion/Sucursal.aspx".ToUpper(), 17) - PaginaDict.Add("/Planeacion/CatProyectos.aspx".ToUpper(), 34) - PaginaDict.Add("/Planeacion/CatSubProyectos.aspx".ToUpper(), 35) - PaginaDict.Add("/Planeacion/CatTiposEventos.aspx".ToUpper(), 66) - PaginaDict.Add("/Planeacion/Notificaciones.aspx".ToUpper(), -1) - 'PRUEBA CON Metronic - PaginaDict.Add("/Planeacion/CatProyectos2.aspx".ToUpper(), -1) - 'PaginaDict.Add("/123/TablaBD.aspx".ToUpper(), 5) - 'PaginaDict.Add("/123/CatClientes.aspx".ToUpper(), 5) -#End Region - 'PRESUPUESTOS -#Region "Presupuestos" - PaginaDict.Add("/Presupuestos/GenerarPresupuestos.aspx".ToUpper(), 242) - PaginaDict.Add("/Presupuestos/GenerarPresupuestos2.aspx".ToUpper(), 247) - PaginaDict.Add("/Presupuestos/RepPresupuestos.aspx".ToUpper(), 118) - PaginaDict.Add("/Presupuestos/Presupuesto.aspx".ToUpper(), 369) -#End Region - 'Prospeccion -#Region "Prospeccion" - PaginaDict.Add("/Prospeccion/Prospectos.aspx".ToUpper(), 392) - PaginaDict.Add("/Prospeccion/PopUpBuscarProspectos.aspx".ToUpper(), 392) - PaginaDict.Add("/Prospeccion/RepProspeccion.aspx".ToUpper(), 395) - PaginaDict.Add("/Prospeccion/RepProspeccionDetalle.aspx".ToUpper(), 395) - PaginaDict.Add("/Prospeccion/RepProspectosGIS.aspx".ToUpper(), 390) - -#End Region -#Region "Prospectos" - 'PROSPECTOS - PaginaDict.Add("/Prospectos/CatClasificacionesCaracteristicas.aspx".ToUpper(), 180) - PaginaDict.Add("/Prospectos/ProspectoExpediente.aspx".ToUpper(), 181) - PaginaDict.Add("/Prospectos/CatProspectos.aspx".ToUpper(), 182) - PaginaDict.Add("/Prospectos/CatProspectosRedes.aspx".ToUpper(), 183) - PaginaDict.Add("/Prospectos/CatCoordinadores.aspx".ToUpper(), 184) - PaginaDict.Add("/Prospectos/CatSupervisores.aspx".ToUpper(), 185) - PaginaDict.Add("/Prospectos/ProspectosG15.aspx".ToUpper(), 187) - PaginaDict.Add("/Prospectos/CatProspectosG15.aspx".ToUpper(), 188) - PaginaDict.Add("/Prospectos/CatEventos.aspx".ToUpper(), 189) - PaginaDict.Add("/Prospectos/CatResponsables.aspx".ToUpper(), 190) - PaginaDict.Add("/Prospectos/CatPromotores.aspx".ToUpper(), 191) - PaginaDict.Add("/Prospectos/CatAnfitriones.aspx".ToUpper(), 192) - PaginaDict.Add("/Prospectos/CatProspectosApoyos.aspx".ToUpper(), 193) - PaginaDict.Add("/Prospectos/CatProspectosClasificaciones.aspx".ToUpper(), 194) - PaginaDict.Add("/Prospectos/CatProspectosSeguimiento.aspx".ToUpper(), 195) - PaginaDict.Add("/Prospectos/Solicitudes/CatSolicitudesG15.aspx".ToUpper(), 246) - PaginaDict.Add("/Prospectos/Solicitudes/CatProspectosSolicitudesEstatus.aspx".ToUpper(), 198) - PaginaDict.Add("/Prospectos/Solicitudes/CatProspectosSolicitudesTipos.aspx".ToUpper(), 199) - PaginaDict.Add("/Prospectos/RedesIndicadores.aspx".ToUpper(), 202) - PaginaDict.Add("/Prospectos/RepRedesEstructuras.aspx".ToUpper(), 202) - PaginaDict.Add("/Prospectos/RedesArbol.aspx".ToUpper(), 203) - PaginaDict.Add("/Prospectos/CatProspectosRedesMetas.aspx".ToUpper(), 204) - PaginaDict.Add("/Prospectos/RepProspectosRedes.aspx".ToUpper(), 205) - PaginaDict.Add("/Prospectos/ProspectosRedes.aspx".ToUpper(), 206) - PaginaDict.Add("/Prospectos/ProspectosSIP.aspx".ToUpper(), 207) - PaginaDict.Add("/Prospectos/RedesCallCenter.aspx".ToUpper(), 209) - PaginaDict.Add("/Prospectos/BuscadorBD.aspx".ToUpper(), 210) - PaginaDict.Add("/Prospectos/ProspectosEstructuras.aspx".ToUpper(), 211) - PaginaDict.Add("/Prospectos/CatEventosEstructuras.aspx".ToUpper(), 212) - PaginaDict.Add("/Prospectos/RepPadron.aspx".ToUpper(), 213) - PaginaDict.Add("/Prospectos/RepPadronDetalle.aspx".ToUpper(), 213) - PaginaDict.Add("/Prospectos/RepEventos.aspx".ToUpper(), 213) - PaginaDict.Add("/Prospectos/RepEventosDetalle.aspx".ToUpper(), 213) - PaginaDict.Add("/Prospectos/RedesEncuestas.aspx".ToUpper(), 214) - PaginaDict.Add("/Prospectos/RepEncuestas.aspx".ToUpper(), 217) - PaginaDict.Add("/Prospectos/RepEncuestasDetalle.aspx".ToUpper(), 217) - PaginaDict.Add("/Prospectos/RepEncuestasDetalleTabla.aspx".ToUpper(), 217) - PaginaDict.Add("/Prospectos/CatProspectosDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Prospectos/CatProspectosEstatus.aspx".ToUpper(), 200) - PaginaDict.Add("/Prospectos/CatProspectosTipos.aspx".ToUpper(), 215) - PaginaDict.Add("/Prospectos/Encuestas/CatEncuestas.aspx".ToUpper(), 218) - PaginaDict.Add("/Prospectos/RepEncuestasAvances.aspx".ToUpper(), 231) - PaginaDict.Add("/Prospectos/ProspectosValidar.aspx".ToUpper(), 232) - PaginaDict.Add("/Prospectos/RepAgendasBitacoras.aspx".ToUpper(), 234) - PaginaDict.Add("/Prospectos/RepSolicitudes.aspx".ToUpper(), 243) - PaginaDict.Add("/Prospectos/CatProspectosApoyosTipos.aspx".ToUpper(), 216) - PaginaDict.Add("/Prospectos/CatEventosTipos.aspx".ToUpper(), 245) - PaginaDict.Add("/Prospectos/RepProspectos.aspx".ToUpper(), 208) -#End Region - 'RECURSOS HUMANOS -#Region "RH" - PaginaDict.Add("/RH/CatDepartamentos.aspx".ToUpper(), 40) - PaginaDict.Add("/RH/CatEscolaridad.aspx".ToUpper(), 41) - PaginaDict.Add("/RH/CatEstadoCivil.aspx".ToUpper(), 42) - PaginaDict.Add("/RH/CatEstatusPersonal.aspx".ToUpper(), 43) - PaginaDict.Add("/RH/CatGenero.aspx".ToUpper(), 44) - PaginaDict.Add("/RH/CatMotivoBaja.aspx".ToUpper(), 45) - PaginaDict.Add("/RH/Personal.aspx".ToUpper(), 46) - PaginaDict.Add("/RH/CatPersonal.aspx".ToUpper(), 46) - PaginaDict.Add("/RH/CatPuesto.aspx".ToUpper(), 47) - PaginaDict.Add("/RH/CatRuta.aspx".ToUpper(), 48) - PaginaDict.Add("/RH/CatTiposContratos.aspx".ToUpper(), 49) - PaginaDict.Add("/RH/CatTurno.aspx".ToUpper(), 50) - PaginaDict.Add("/RH/Asistencias.aspx".ToUpper(), 67) - PaginaDict.Add("/RH/BuzonCalidad.aspx".ToUpper(), 67) - PaginaDict.Add("/RH/CatAsistenciasInasistencias.aspx".ToUpper(), 71) - PaginaDict.Add("/RH/CatMotivosHorasExtras.aspx".ToUpper(), 72) - PaginaDict.Add("/RH/CatTipoBuzon.aspx".ToUpper(), 86) - PaginaDict.Add("/RH/ActualizacionMasiva.aspx".ToUpper(), 92) - PaginaDict.Add("/RH/RepBuzonCalidad.aspx".ToUpper(), 102) - PaginaDict.Add("/RH/CatDocumentos.aspx".ToUpper(), 253) - PaginaDict.Add("/RH/CatJornadas.aspx".ToUpper(), 254) - PaginaDict.Add("/RH/AsistenciaDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/RH/ComparativoNomina.aspx".ToUpper(), 311) - PaginaDict.Add("/RH/RepPersonalInconsistencias.aspx".ToUpper(), 314) - PaginaDict.Add("/RH/CatPuestosSueldos.aspx".ToUpper(), 370) - PaginaDict.Add("/RH/CatPersonalRequerido.aspx".ToUpper(), 401) - PaginaDict.Add("/RH/RepPersonalNecesidades.aspx".ToUpper(), 556) - PaginaDict.Add("/RH/RepIndiceRotacionPersonal.aspx".ToUpper(), 557) - PaginaDict.Add("/RH/RepAusentismoLaboral.aspx".ToUpper(), 558) - PaginaDict.Add("/RH/Organigrama.aspx".ToUpper(), 407) - PaginaDict.Add("/RH/CatCaracteristicas.aspx".ToUpper(), 411) - PaginaDict.Add("/RH/CatCursosTemas.aspx".ToUpper(), 1015) - PaginaDict.Add("/RH/CatCursosCapacitadores.aspx".ToUpper(), 1016) - PaginaDict.Add("/RH/CatCursos.aspx".ToUpper(), 1017) - PaginaDict.Add("/RH/Reclutamiento.aspx".ToUpper(), 1022) - PaginaDict.Add("/RH/RepDocumentacionVencida.aspx".ToUpper(), 412) - PaginaDict.Add("/RH/CatSubProyectosZonas.aspx".ToUpper(), 421) - PaginaDict.Add("/RH/RepVacaciones.aspx".ToUpper(), 422) - PaginaDict.Add("/RH/CatChecadorTipo.aspx".ToUpper(), 427) - PaginaDict.Add("/RH/CatChecadorHorarios.aspx".ToUpper(), 428) - PaginaDict.Add("/RH/CatChecadorEstaciones.aspx".ToUpper(), 627) - PaginaDict.Add("/RH/RepChecadorPreAsistencia.aspx".ToUpper(), 628) - PaginaDict.Add("/RH/CatCaptaciones.aspx".ToUpper(), 629) - PaginaDict.Add("/RH/RepUniformes.aspx".ToUpper(), 630) - PaginaDict.Add("/RH/RepUniformesResguardo.aspx".ToUpper(), 666) - - PaginaDict.Add("/RH/ListaAsistenciaRH.aspx".ToUpper(), 631) - PaginaDict.Add("/RH/CatUniformes.aspx".ToUpper(), 632) - PaginaDict.Add("/RH/CatUniformesDetalle.aspx".ToUpper(), 633) - PaginaDict.Add("/RH/CatConceptosViaticos.aspx".ToUpper(), 662) - PaginaDict.Add("/RH/SolicitudViaticos.aspx".ToUpper(), 663) - PaginaDict.Add("/RH/ReporteViaticos.aspx".ToUpper(), 664) - PaginaDict.Add("/RH/MiPerfil.aspx".ToUpper(), -1) ' se dejará libre el módulo para que cualquier que tenga cvepersonal, pueda acceder -#End Region -#Region "Sistema" - 'Cargo las páginas que deben tener restricción - PaginaDict.Add("/Sistemas/CatEmpresas.aspx".ToUpper(), 2) - PaginaDict.Add("/Sistemas/Empresa.aspx".ToUpper(), 2) - PaginaDict.Add("/Sistemas/CatUsuarios.aspx".ToUpper(), 20) - PaginaDict.Add("/Sistemas/Usuarios.aspx".ToUpper(), 20) - PaginaDict.Add("/Sistemas/UsuarioDetalle.aspx".ToUpper(), 20) - PaginaDict.Add("/Sistemas/CatRoles.aspx".ToUpper(), 21) - PaginaDict.Add("/Sistemas/RolesDetalle.aspx".ToUpper(), 21) - PaginaDict.Add("/Sistemas/CatModulos.aspx".ToUpper(), 22) - PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 69) - PaginaDict.Add("/Sistemas/CatParametros.aspx".ToUpper(), 143) - PaginaDict.Add("/Sistemas/PopUpCargaCertificados.aspx".ToUpper(), 144) - PaginaDict.Add("/Sistemas/CatNotificaciones.aspx".ToUpper(), 146) - PaginaDict.Add("/Sistemas/EmpresasModulos.aspx".ToUpper(), 346) - PaginaDict.Add("/Sistemas/CatSesiones.aspx".ToUpper(), 374) - PaginaDict.Add("/Sistemas/CatFuncionalidades.aspx".ToUpper(), 568) - PaginaDict.Add("/Sistemas/CatIndicadores.aspx".ToUpper(), 573) - PaginaDict.Add("/Sistemas/CatIndicadoresUsuarios.aspx".ToUpper(), 572) - PaginaDict.Add("/Sistemas/CatPAC.aspx".ToUpper(), 409) - PaginaDict.Add("/Sistemas/PermisosPorUsuario.aspx".ToUpper(), 700) - PaginaDict.Add("/Sistemas/Cierre.aspx".ToUpper(), 713) - PaginaDict.Add("/Sistemas/CatTareasProgramadas.aspx".ToUpper(), -1) - PaginaDict.Add("/Sistemas/ConfiguracionEmpresa.aspx".ToUpper(), 683) -#End Region -#Region "Ventas" - 'VENTAS - PaginaDict.Add("/Ventas/RepIngresosDetalle.aspx".ToUpper(), 540) - PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 5) - PaginaDict.Add("/Ventas/CatClientes.aspx".ToUpper(), 5) - PaginaDict.Add("/Ventas/CatClientesClasificaciones.aspx".ToUpper(), 408) +#End Region +#Region "MF" + PaginaDict.Add("/MF/BitacoraDiaria.aspx".ToUpper(), 801) + PaginaDict.Add("/MF/CatActividades.aspx".ToUpper(), 803) + PaginaDict.Add("/MF/CatOperadores.aspx".ToUpper(), 804) + PaginaDict.Add("/MF/CatEstatus.aspx".ToUpper(), 805) + PaginaDict.Add("/MF/CargaLayout.aspx".ToUpper(), 863) + PaginaDict.Add("/MF/RepConsumoCombustible.aspx".ToUpper(), 864) +#End Region +#Region "Nomina" + + 'NÓMINA + PaginaDict.Add("/Nomina/Calculo.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/SobreRecibo.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/SobreReciboCharlie.aspx".ToUpper(), -1) + PaginaDict.Add("/Nomina/CatTiposPeriodos.aspx".ToUpper(), 60) + PaginaDict.Add("/Nomina/PreNomina.aspx".ToUpper(), 74) + PaginaDict.Add("/Nomina/PreNominaHistorial.aspx".ToUpper(), 148) + PaginaDict.Add("/Nomina/RepPreNomina.aspx".ToUpper(), 74) + PaginaDict.Add("/Nomina/Nomina.aspx".ToUpper(), 75) + PaginaDict.Add("/Nomina/NominaB.aspx".ToUpper(), 75) + PaginaDict.Add("/Nomina/Nomina2.aspx".ToUpper(), 75) + PaginaDict.Add("/Nomina/ListaAsistencias.aspx".ToUpper(), 91) + PaginaDict.Add("/Nomina/ConceptosEspeciales.aspx".ToUpper(), 136) + PaginaDict.Add("/Nomina/CatConceptos.aspx".ToUpper(), 172) + PaginaDict.Add("/Nomina/ConceptoNomina.aspx".ToUpper(), 172) + PaginaDict.Add("/Nomina/RegistroNomina.aspx".ToUpper(), 173) + PaginaDict.Add("/Nomina/RepConceptosAcumulados.aspx".ToUpper(), 174) + PaginaDict.Add("/Nomina/RepPersonalAcumulados.aspx".ToUpper(), 393) + PaginaDict.Add("/Nomina/CatPeriodos.aspx".ToUpper(), 177) + PaginaDict.Add("/Nomina/Finiquito.aspx".ToUpper(), 197) + PaginaDict.Add("/Nomina/CatSatBancos.aspx".ToUpper(), 255) + PaginaDict.Add("/Nomina/CatSatConceptos.aspx".ToUpper(), 256) + PaginaDict.Add("/Nomina/CatSatRegimenContratacion.aspx".ToUpper(), 257) + PaginaDict.Add("/Nomina/CatSatTipoIncapacidad.aspx".ToUpper(), 258) + PaginaDict.Add("/Nomina/CatSatRiesgoPuesto.aspx".ToUpper(), 259) + PaginaDict.Add("/Nomina/ReportePTU.aspx".ToUpper(), 870) +#End Region + 'Ordenes de Servicios +#Region "OS" + PaginaDict.Add("/OS/PopUpBuscarOS.aspx".ToUpper(), 80) + PaginaDict.Add("/OS/CatEstatusOrdenServicio.aspx".ToUpper(), 99) + PaginaDict.Add("/OS/PopUpBuscarCuentasEquipos.aspx".ToUpper(), 100) + PaginaDict.Add("/OS/PopUpCuentasEquipos.aspx".ToUpper(), -1) + 'PaginaDict.Add("/OS/CatSubTiposOrdenesServicios.aspx".ToUpper(), 101) + + 'PaginaDict.Add("/OS/CatCaracteristicasOrdenServicio.aspx".ToUpper(), 131) + 'PaginaDict.Add("/OS/CatOSCaracteristicasOpciones.aspx".ToUpper(), 132) + PaginaDict.Add("/OS/RepOrdenesServicios.aspx".ToUpper(), 134) + PaginaDict.Add("/OS/OrdenesServicios.aspx".ToUpper(), 135) + PaginaDict.Add("/OS/CatTipoCuentasEquipos.aspx".ToUpper(), 159) + PaginaDict.Add("/OS/CatTiposOrdenesServicios.aspx".ToUpper(), 167) + PaginaDict.Add("/OS/PopUpOS_PS_Especificaciones.aspx".ToUpper(), 135) + PaginaDict.Add("/OS/PopUpMateriales.aspx".ToUpper(), 135) + PaginaDict.Add("/OS/Asignaciones.aspx".ToUpper(), 125) +#End Region + 'OC +#Region "OC" + PaginaDict.Add("/OC/OC.aspx".ToUpper(), 155) + PaginaDict.Add("/OC/OC2.aspx".ToUpper(), -1) + + PaginaDict.Add("/OC/OCCompras.aspx".ToUpper(), 158) + 'PaginaDict.Add("/OC/CatEstatusOrdenCompra.aspx".ToUpper(), 156) + 'PaginaDict.Add("/OC/CatEstatusUsuarios.aspx".ToUpper(), 156) + PaginaDict.Add("/OC/RepOC.aspx".ToUpper(), 157) + PaginaDict.Add("/OC/CatEstatus.aspx".ToUpper(), 162) + PaginaDict.Add("/OC/RepRequisiciones.aspx".ToUpper(), 249) + 'PaginaDict.Add("/OC/PopOCCotizaciones.aspx".ToUpper(), 155) + PaginaDict.Add("/OC/PopUpBuscarReq.aspx".ToUpper(), 305) + PaginaDict.Add("/OC/RepCotizaciones.aspx".ToUpper(), 158) + PaginaDict.Add("/OC/RepCotizacionesDetalle.aspx".ToUpper(), 158) + PaginaDict.Add("/OC/PopUpBuscarCot.aspx".ToUpper(), 160) + PaginaDict.Add("/OC/Cotizaciones.aspx".ToUpper(), 132) + PaginaDict.Add("/OC/CotizacionEnLinea.aspx".ToUpper(), -1) + PaginaDict.Add("/OC/CotizacionEnvio.aspx".ToUpper(), -1) + PaginaDict.Add("/OC/OC.aspx?Tipo= REQ", 250) + PaginaDict.Add("/OC/RepOCSinFactura.aspx".ToUpper(), 388) + PaginaDict.Add("/OC/RepOCxSurtir.aspx".ToUpper(), 469) + PaginaDict.Add("/OC/RepReqXOC.aspx".ToUpper(), 634) + PaginaDict.Add("/OC/RepOCGuias.aspx".ToUpper(), 494) + PaginaDict.Add("/OC/ListaRequisicion.aspx".ToUpper(), 667) + PaginaDict.Add("/OC/RepOCAnticiposPtes.aspx".ToUpper(), 506) + PaginaDict.Add("/OC/RepSolicitudesAnticipo.aspx".ToUpper(), 529) +#End Region + 'OI +#Region "OI" + PaginaDict.Add("/OI/EventoDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/Normatividad.aspx".ToUpper(), 669) + PaginaDict.Add("/OI/RepNormatividad.aspx".ToUpper(), 669) + PaginaDict.Add("/OI/Minutas.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/RepDocumentos.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/EventoComentario.aspx".ToUpper(), -1) + + PaginaDict.Add("/OI/RepEventos.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/RepTareas.aspx".ToUpper(), 293) + PaginaDict.Add("/OI/RepMinutas.aspx".ToUpper(), 338) + PaginaDict.Add("/OI/PopUpAgenda.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/RepSoporteADS.aspx".ToUpper(), 456) + PaginaDict.Add("/OI/SoporteADS.aspx".ToUpper(), 457) + PaginaDict.Add("/OI/Desarrollo.aspx".ToUpper(), 473) + PaginaDict.Add("/OI/RepDesarrollo.aspx".ToUpper(), 475) + PaginaDict.Add("/OI/DesarrolloWizard.aspx".ToUpper(), 474) + PaginaDict.Add("/OI/SubidasADS.aspx".ToUpper(), 476) +#End Region +#Region "Planeacion" + 'PLANEACIÓN + PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 17) + PaginaDict.Add("/Planeacion/Sucursal.aspx".ToUpper(), 17) + PaginaDict.Add("/Planeacion/CatProyectos.aspx".ToUpper(), 34) + PaginaDict.Add("/Planeacion/CatSubProyectos.aspx".ToUpper(), 35) + PaginaDict.Add("/Planeacion/CatTiposEventos.aspx".ToUpper(), 66) + PaginaDict.Add("/Planeacion/Notificaciones.aspx".ToUpper(), -1) + 'PRUEBA CON Metronic + PaginaDict.Add("/Planeacion/CatProyectos2.aspx".ToUpper(), -1) + 'PaginaDict.Add("/123/TablaBD.aspx".ToUpper(), 5) + 'PaginaDict.Add("/123/CatClientes.aspx".ToUpper(), 5) +#End Region + 'PRESUPUESTOS +#Region "Presupuestos" + PaginaDict.Add("/Presupuestos/GenerarPresupuestos.aspx".ToUpper(), 242) + PaginaDict.Add("/Presupuestos/GenerarPresupuestos2.aspx".ToUpper(), 247) + PaginaDict.Add("/Presupuestos/RepPresupuestos.aspx".ToUpper(), 118) + PaginaDict.Add("/Presupuestos/Presupuesto.aspx".ToUpper(), 369) +#End Region + 'Prospeccion +#Region "Prospeccion" + PaginaDict.Add("/Prospeccion/Prospectos.aspx".ToUpper(), 392) + PaginaDict.Add("/Prospeccion/PopUpBuscarProspectos.aspx".ToUpper(), 392) + PaginaDict.Add("/Prospeccion/RepProspeccion.aspx".ToUpper(), 395) + PaginaDict.Add("/Prospeccion/RepProspeccionDetalle.aspx".ToUpper(), 395) + PaginaDict.Add("/Prospeccion/RepProspectosGIS.aspx".ToUpper(), 390) + +#End Region +#Region "Prospectos" + 'PROSPECTOS + PaginaDict.Add("/Prospectos/CatClasificacionesCaracteristicas.aspx".ToUpper(), 180) + PaginaDict.Add("/Prospectos/ProspectoExpediente.aspx".ToUpper(), 181) + PaginaDict.Add("/Prospectos/CatProspectos.aspx".ToUpper(), 182) + PaginaDict.Add("/Prospectos/CatProspectosRedes.aspx".ToUpper(), 183) + PaginaDict.Add("/Prospectos/CatCoordinadores.aspx".ToUpper(), 184) + PaginaDict.Add("/Prospectos/CatSupervisores.aspx".ToUpper(), 185) + PaginaDict.Add("/Prospectos/ProspectosG15.aspx".ToUpper(), 187) + PaginaDict.Add("/Prospectos/CatProspectosG15.aspx".ToUpper(), 188) + PaginaDict.Add("/Prospectos/CatEventos.aspx".ToUpper(), 189) + PaginaDict.Add("/Prospectos/CatResponsables.aspx".ToUpper(), 190) + PaginaDict.Add("/Prospectos/CatPromotores.aspx".ToUpper(), 191) + PaginaDict.Add("/Prospectos/CatAnfitriones.aspx".ToUpper(), 192) + PaginaDict.Add("/Prospectos/CatProspectosApoyos.aspx".ToUpper(), 193) + PaginaDict.Add("/Prospectos/CatProspectosClasificaciones.aspx".ToUpper(), 194) + PaginaDict.Add("/Prospectos/CatProspectosSeguimiento.aspx".ToUpper(), 195) + PaginaDict.Add("/Prospectos/Solicitudes/CatSolicitudesG15.aspx".ToUpper(), 246) + PaginaDict.Add("/Prospectos/Solicitudes/CatProspectosSolicitudesEstatus.aspx".ToUpper(), 198) + PaginaDict.Add("/Prospectos/Solicitudes/CatProspectosSolicitudesTipos.aspx".ToUpper(), 199) + PaginaDict.Add("/Prospectos/RedesIndicadores.aspx".ToUpper(), 202) + PaginaDict.Add("/Prospectos/RepRedesEstructuras.aspx".ToUpper(), 202) + PaginaDict.Add("/Prospectos/RedesArbol.aspx".ToUpper(), 203) + PaginaDict.Add("/Prospectos/CatProspectosRedesMetas.aspx".ToUpper(), 204) + PaginaDict.Add("/Prospectos/RepProspectosRedes.aspx".ToUpper(), 205) + PaginaDict.Add("/Prospectos/ProspectosRedes.aspx".ToUpper(), 206) + PaginaDict.Add("/Prospectos/ProspectosSIP.aspx".ToUpper(), 207) + PaginaDict.Add("/Prospectos/RedesCallCenter.aspx".ToUpper(), 209) + PaginaDict.Add("/Prospectos/BuscadorBD.aspx".ToUpper(), 210) + PaginaDict.Add("/Prospectos/ProspectosEstructuras.aspx".ToUpper(), 211) + PaginaDict.Add("/Prospectos/CatEventosEstructuras.aspx".ToUpper(), 212) + PaginaDict.Add("/Prospectos/RepPadron.aspx".ToUpper(), 213) + PaginaDict.Add("/Prospectos/RepPadronDetalle.aspx".ToUpper(), 213) + PaginaDict.Add("/Prospectos/RepEventos.aspx".ToUpper(), 213) + PaginaDict.Add("/Prospectos/RepEventosDetalle.aspx".ToUpper(), 213) + PaginaDict.Add("/Prospectos/RedesEncuestas.aspx".ToUpper(), 214) + PaginaDict.Add("/Prospectos/RepEncuestas.aspx".ToUpper(), 217) + PaginaDict.Add("/Prospectos/RepEncuestasDetalle.aspx".ToUpper(), 217) + PaginaDict.Add("/Prospectos/RepEncuestasDetalleTabla.aspx".ToUpper(), 217) + PaginaDict.Add("/Prospectos/CatProspectosDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/Prospectos/CatProspectosEstatus.aspx".ToUpper(), 200) + PaginaDict.Add("/Prospectos/CatProspectosTipos.aspx".ToUpper(), 215) + PaginaDict.Add("/Prospectos/Encuestas/CatEncuestas.aspx".ToUpper(), 218) + PaginaDict.Add("/Prospectos/RepEncuestasAvances.aspx".ToUpper(), 231) + PaginaDict.Add("/Prospectos/ProspectosValidar.aspx".ToUpper(), 232) + PaginaDict.Add("/Prospectos/RepAgendasBitacoras.aspx".ToUpper(), 234) + PaginaDict.Add("/Prospectos/RepSolicitudes.aspx".ToUpper(), 243) + PaginaDict.Add("/Prospectos/CatProspectosApoyosTipos.aspx".ToUpper(), 216) + PaginaDict.Add("/Prospectos/CatEventosTipos.aspx".ToUpper(), 245) + PaginaDict.Add("/Prospectos/RepProspectos.aspx".ToUpper(), 208) +#End Region + 'RECURSOS HUMANOS +#Region "RH" + PaginaDict.Add("/RH/CatDepartamentos.aspx".ToUpper(), 40) + PaginaDict.Add("/RH/CatEscolaridad.aspx".ToUpper(), 41) + PaginaDict.Add("/RH/CatEstadoCivil.aspx".ToUpper(), 42) + PaginaDict.Add("/RH/CatEstatusPersonal.aspx".ToUpper(), 43) + PaginaDict.Add("/RH/CatGenero.aspx".ToUpper(), 44) + PaginaDict.Add("/RH/CatMotivoBaja.aspx".ToUpper(), 45) + PaginaDict.Add("/RH/Personal.aspx".ToUpper(), 46) + PaginaDict.Add("/RH/CatPersonal.aspx".ToUpper(), 46) + PaginaDict.Add("/RH/CatPuesto.aspx".ToUpper(), 47) + PaginaDict.Add("/RH/CatRuta.aspx".ToUpper(), 48) + PaginaDict.Add("/RH/CatTiposContratos.aspx".ToUpper(), 49) + PaginaDict.Add("/RH/CatTurno.aspx".ToUpper(), 50) + PaginaDict.Add("/RH/Asistencias.aspx".ToUpper(), 67) + PaginaDict.Add("/RH/BuzonCalidad.aspx".ToUpper(), 67) + PaginaDict.Add("/RH/CatAsistenciasInasistencias.aspx".ToUpper(), 71) + PaginaDict.Add("/RH/CatMotivosHorasExtras.aspx".ToUpper(), 72) + PaginaDict.Add("/RH/CatTipoBuzon.aspx".ToUpper(), 86) + PaginaDict.Add("/RH/ActualizacionMasiva.aspx".ToUpper(), 92) + PaginaDict.Add("/RH/RepBuzonCalidad.aspx".ToUpper(), 102) + PaginaDict.Add("/RH/CatDocumentos.aspx".ToUpper(), 253) + PaginaDict.Add("/RH/CatJornadas.aspx".ToUpper(), 254) + PaginaDict.Add("/RH/AsistenciaDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/RH/ComparativoNomina.aspx".ToUpper(), 311) + PaginaDict.Add("/RH/RepPersonalInconsistencias.aspx".ToUpper(), 314) + PaginaDict.Add("/RH/CatPuestosSueldos.aspx".ToUpper(), 370) + PaginaDict.Add("/RH/CatPersonalRequerido.aspx".ToUpper(), 401) + PaginaDict.Add("/RH/RepPersonalNecesidades.aspx".ToUpper(), 556) + PaginaDict.Add("/RH/RepIndiceRotacionPersonal.aspx".ToUpper(), 557) + PaginaDict.Add("/RH/RepAusentismoLaboral.aspx".ToUpper(), 558) + PaginaDict.Add("/RH/Organigrama.aspx".ToUpper(), 407) + PaginaDict.Add("/RH/CatCaracteristicas.aspx".ToUpper(), 411) + PaginaDict.Add("/RH/CatCursosTemas.aspx".ToUpper(), 1015) + PaginaDict.Add("/RH/CatCursosCapacitadores.aspx".ToUpper(), 1016) + PaginaDict.Add("/RH/CatCursos.aspx".ToUpper(), 1017) + PaginaDict.Add("/RH/Reclutamiento.aspx".ToUpper(), 1022) + PaginaDict.Add("/RH/RepDocumentacionVencida.aspx".ToUpper(), 412) + PaginaDict.Add("/RH/CatSubProyectosZonas.aspx".ToUpper(), 421) + PaginaDict.Add("/RH/RepVacaciones.aspx".ToUpper(), 422) + PaginaDict.Add("/RH/CatChecadorTipo.aspx".ToUpper(), 427) + PaginaDict.Add("/RH/CatChecadorHorarios.aspx".ToUpper(), 428) + PaginaDict.Add("/RH/CatChecadorEstaciones.aspx".ToUpper(), 627) + PaginaDict.Add("/RH/RepChecadorPreAsistencia.aspx".ToUpper(), 628) + PaginaDict.Add("/RH/CatCaptaciones.aspx".ToUpper(), 629) + PaginaDict.Add("/RH/RepUniformes.aspx".ToUpper(), 630) + PaginaDict.Add("/RH/RepUniformesResguardo.aspx".ToUpper(), 666) + + PaginaDict.Add("/RH/ListaAsistenciaRH.aspx".ToUpper(), 631) + PaginaDict.Add("/RH/CatUniformes.aspx".ToUpper(), 632) + PaginaDict.Add("/RH/CatUniformesDetalle.aspx".ToUpper(), 633) + PaginaDict.Add("/RH/CatConceptosViaticos.aspx".ToUpper(), 662) + PaginaDict.Add("/RH/SolicitudViaticos.aspx".ToUpper(), 663) + PaginaDict.Add("/RH/ReporteViaticos.aspx".ToUpper(), 664) + PaginaDict.Add("/RH/MiPerfil.aspx".ToUpper(), -1) ' se dejará libre el módulo para que cualquier que tenga cvepersonal, pueda acceder +#End Region +#Region "Sistema" + 'Cargo las páginas que deben tener restricción + PaginaDict.Add("/Sistemas/CatEmpresas.aspx".ToUpper(), 2) + PaginaDict.Add("/Sistemas/Empresa.aspx".ToUpper(), 2) + PaginaDict.Add("/Sistemas/CatUsuarios.aspx".ToUpper(), 20) + PaginaDict.Add("/Sistemas/Usuarios.aspx".ToUpper(), 20) + PaginaDict.Add("/Sistemas/UsuarioDetalle.aspx".ToUpper(), 20) + PaginaDict.Add("/Sistemas/CatRoles.aspx".ToUpper(), 21) + PaginaDict.Add("/Sistemas/RolesDetalle.aspx".ToUpper(), 21) + PaginaDict.Add("/Sistemas/CatModulos.aspx".ToUpper(), 22) + PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 69) + PaginaDict.Add("/Sistemas/CatParametros.aspx".ToUpper(), 143) + PaginaDict.Add("/Sistemas/PopUpCargaCertificados.aspx".ToUpper(), 144) + PaginaDict.Add("/Sistemas/CatNotificaciones.aspx".ToUpper(), 146) + PaginaDict.Add("/Sistemas/EmpresasModulos.aspx".ToUpper(), 346) + PaginaDict.Add("/Sistemas/CatSesiones.aspx".ToUpper(), 374) + PaginaDict.Add("/Sistemas/CatFuncionalidades.aspx".ToUpper(), 568) + PaginaDict.Add("/Sistemas/CatIndicadores.aspx".ToUpper(), 573) + PaginaDict.Add("/Sistemas/CatIndicadoresUsuarios.aspx".ToUpper(), 572) + PaginaDict.Add("/Sistemas/CatPAC.aspx".ToUpper(), 409) + PaginaDict.Add("/Sistemas/PermisosPorUsuario.aspx".ToUpper(), 700) + PaginaDict.Add("/Sistemas/Cierre.aspx".ToUpper(), 713) + PaginaDict.Add("/Sistemas/CatTareasProgramadas.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/ConfiguracionEmpresa.aspx".ToUpper(), 683) +#End Region +#Region "Ventas" + 'VENTAS + PaginaDict.Add("/Ventas/RepIngresosDetalle.aspx".ToUpper(), 540) + PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 5) + PaginaDict.Add("/Ventas/CatClientes.aspx".ToUpper(), 5) + PaginaDict.Add("/Ventas/CatClientesClasificaciones.aspx".ToUpper(), 408) PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 6) - PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 366) + PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 366) PaginaDict.Add("/Ventas/RepVentas.aspx".ToUpper(), 9) - PaginaDict.Add("/Ventas/RepVentas.aspx?Op=Cot".ToUpper(), 367) - PaginaDict.Add("/Ventas/RepRemisiones.aspx".ToUpper(), 430) - PaginaDict.Add("/Ventas/RepRemisionesDetalle.aspx".ToUpper(), 430) - PaginaDict.Add("/Ventas/RepCotizaciones.aspx".ToUpper(), 430) - PaginaDict.Add("/Ventas/RepCotizacionesDetalle.aspx".ToUpper(), 430) - PaginaDict.Add("/Ventas/RepVentasPV.aspx".ToUpper(), 9) - PaginaDict.Add("/Ventas/RepVentaDetalle.aspx".ToUpper(), 9) - PaginaDict.Add("/Ventas/CatClasificaciones.aspx".ToUpper(), 12) - PaginaDict.Add("/Ventas/CatClasificaciones2.aspx".ToUpper(), 396) - PaginaDict.Add("/Ventas/CatClasificacionesDetalle.aspx".ToUpper(), 12) - PaginaDict.Add("/Ventas/ProductosServicios.aspx".ToUpper(), 13) - PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 13) - PaginaDict.Add("/Ventas/CatEstatusFactura.aspx".ToUpper(), 14) - PaginaDict.Add("/Ventas/CatLeyendasFiscales.aspx".ToUpper(), 16) - PaginaDict.Add("/Ventas/CatUnidadesMedida.aspx".ToUpper(), 18) - PaginaDict.Add("/Ventas/RepVentasPeriodo.aspx".ToUpper(), 27) - PaginaDict.Add("/Ventas/PopUpBuscarFolio.aspx".ToUpper(), 28) - PaginaDict.Add("/Ventas/RepProductos.aspx".ToUpper(), 32) - PaginaDict.Add("/Ventas/CatVendedores.aspx".ToUpper(), 142) - PaginaDict.Add("/Ventas/PuntoVenta.aspx".ToUpper(), 163) - PaginaDict.Add("/Ventas/CatMesas.aspx".ToUpper(), 244) - PaginaDict.Add("/Ventas/CatPreciosLista.aspx".ToUpper(), 378) - PaginaDict.Add("/Ventas/RepProductosServicios.aspx".ToUpper(), 352) - PaginaDict.Add("/Ventas/RepProductosServiciosDetalle.aspx".ToUpper(), 352) - PaginaDict.Add("/Ventas/RepPS.aspx".ToUpper(), 701) - PaginaDict.Add("/Ventas/RepABT.aspx".ToUpper(), 353) - PaginaDict.Add("/Ventas/CatPromociones.aspx".ToUpper(), 123) - PaginaDict.Add("/Ventas/Promociones.aspx".ToUpper(), 124) - PaginaDict.Add("/Ventas/CatFamiliaSubFamilia.aspx".ToUpper(), 372) - PaginaDict.Add("/Ventas/RepComisiones.aspx".ToUpper(), 382) - PaginaDict.Add("/Ventas/RepComisionesDetalle.aspx".ToUpper(), 382) - PaginaDict.Add("/Ventas/RepComisionesDetallePS.aspx".ToUpper(), 382) - PaginaDict.Add("/Ventas/CatEsquemaComisiones.aspx".ToUpper(), 379) - PaginaDict.Add("/Ventas/CatImpuestosLocales.aspx".ToUpper(), 394) - PaginaDict.Add("/Ventas/ActualizarPrecios.aspx".ToUpper(), 397) - PaginaDict.Add("/Ventas/ClientesAbonar.aspx".ToUpper(), 321) - PaginaDict.Add("/Ventas/Reportes.aspx".ToUpper(), 567) - PaginaDict.Add("/Ventas/DiseñadorReportes.aspx".ToUpper(), 569) - PaginaDict.Add("/Ventas/ReporteDetalle.aspx".ToUpper(), 576) - PaginaDict.Add("/Ventas/PopUpBuscarPs.aspx".ToUpper(), 13) - PaginaDict.Add("/Ventas/RepVentasUtilidadPadre.aspx".ToUpper(), 590) - PaginaDict.Add("/Ventas/RepVentasUtilidad.aspx".ToUpper(), 590) - PaginaDict.Add("/Ventas/RepVentasUtilidadDetalle.aspx".ToUpper(), 590) - PaginaDict.Add("/Ventas/eFacturas.aspx".ToUpper(), 413) - PaginaDict.Add("/Ventas/PV.aspx".ToUpper(), 163) - PaginaDict.Add("/Ventas/PVRene.aspx".ToUpper(), 163) - PaginaDict.Add("/Ventas/Corporativo.aspx".ToUpper(), 807) - PaginaDict.Add("/Ventas/RepRecuperacion.aspx".ToUpper(), 88) - PaginaDict.Add("/Ventas/RepRecuperacionDetalle.aspx".ToUpper(), 88) - PaginaDict.Add("/Ventas/RepComisionesJAM.aspx".ToUpper(), 650) - PaginaDict.Add("/Ventas/RepNCxAplicar.aspx".ToUpper(), 648) - PaginaDict.Add("/Ventas/CatDocumentosClientes.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/RepDocumentacionVencidaClientes.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/RepProductosServiciosPeriodo.aspx".ToUpper(), 865) - PaginaDict.Add("/Ventas/ClasificacionesDetalle.aspx".ToUpper(), 875) - PaginaDict.Add("/Ventas/RepPedidos2.aspx".ToUpper(), 881) - PaginaDict.Add("/Ventas/RepPedidos2Detalle.aspx".ToUpper(), 881) - PaginaDict.Add("/Ventas/RepRecuperacionPeriodo.aspx".ToUpper(), 885) - PaginaDict.Add("/Ventas/RepVentasAutorizaciones.aspx".ToUpper(), 531) - PaginaDict.Add("/Ventas/RepComisionesJAM2.aspx".ToUpper(), 889) - PaginaDict.Add("/Ventas/RepComisionesJAM2Detalle.aspx".ToUpper(), 889) - PaginaDict.Add("/Ventas/AuxiliarCliente.aspx".ToUpper(), 1316) - PaginaDict.Add("/Ventas/AuxiliarClienteVentas.aspx".ToUpper(), 542) - PaginaDict.Add("/Ventas/RepCostoPromedioVenta.aspx".ToUpper(), 532) - PaginaDict.Add("/Ventas/RepVentasNetasResumen.aspx".ToUpper(), 533) - PaginaDict.Add("/Ventas/RepTopVentas.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/RepSolicitudesCancelacion.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/RepCanceladasPendientes.aspx".ToUpper(), -1) - - PaginaDict.Add("/Ventas/RepCancelacionesPorAtender.aspx".ToUpper(), 750) - PaginaDict.Add("/Ventas/RepCancelacionesPorRespuesta.aspx".ToUpper(), 751) - PaginaDict.Add("/Ventas/RepIngresos.aspx".ToUpper(), 540) - 'Reportes de Anticipos-NC-IXC' - PaginaDict.Add("/Ventas/RepAnticipo-NC-IXC.aspx".ToUpper(), 869) - PaginaDict.Add("/Ventas/RepAnticipo-NC-IXCDetalle.aspx".ToUpper(), 869) - 'PaginaDict.Add("/Ventas/Efacturas.aspx".ToUpper(), 2015) - 'PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 2016) - 'PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 2017) - PaginaDict.Add("/Ventas/Ventas.aspx?Op=Rem".ToUpper(), 2018) - 'PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 2019) - PaginaDict.Add("/Ventas/VentasH.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/ClientesAbonarH.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/PVRaul.aspx".ToUpper(), -1) - PaginaDict.Add("/Ventas/CatAutorizacionDescuentos.aspx".ToUpper(), 1037) - PaginaDict.Add("/Ventas/RepPUESinPago.aspx".ToUpper(), 672) - PaginaDict.Add("/Ventas/RepVentasResumen.aspx".ToUpper(), 674) - PaginaDict.Add("/Ventas/RepAnticiposEspeciales.aspx".ToUpper(), 678) - PaginaDict.Add("/Ventas/RepArqueos.aspx".ToUpper(), 679) - PaginaDict.Add("/Ventas/RepArqueosDetalle.aspx".ToUpper(), 680) - PaginaDict.Add("/Ventas/RepCotizacionesxFacturar.aspx".ToUpper(), 686) + PaginaDict.Add("/Ventas/RepVentas.aspx?Op=Cot".ToUpper(), 367) + PaginaDict.Add("/Ventas/RepRemisiones.aspx".ToUpper(), 430) + PaginaDict.Add("/Ventas/RepRemisionesDetalle.aspx".ToUpper(), 430) + PaginaDict.Add("/Ventas/RepCotizaciones.aspx".ToUpper(), 430) + PaginaDict.Add("/Ventas/RepCotizacionesDetalle.aspx".ToUpper(), 430) + PaginaDict.Add("/Ventas/RepVentasPV.aspx".ToUpper(), 9) + PaginaDict.Add("/Ventas/RepVentaDetalle.aspx".ToUpper(), 9) + PaginaDict.Add("/Ventas/CatClasificaciones.aspx".ToUpper(), 12) + PaginaDict.Add("/Ventas/CatClasificaciones2.aspx".ToUpper(), 396) + PaginaDict.Add("/Ventas/CatClasificacionesDetalle.aspx".ToUpper(), 12) + PaginaDict.Add("/Ventas/ProductosServicios.aspx".ToUpper(), 13) + PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 13) + PaginaDict.Add("/Ventas/CatEstatusFactura.aspx".ToUpper(), 14) + PaginaDict.Add("/Ventas/CatLeyendasFiscales.aspx".ToUpper(), 16) + PaginaDict.Add("/Ventas/CatUnidadesMedida.aspx".ToUpper(), 18) + PaginaDict.Add("/Ventas/RepVentasPeriodo.aspx".ToUpper(), 27) + PaginaDict.Add("/Ventas/PopUpBuscarFolio.aspx".ToUpper(), 28) + PaginaDict.Add("/Ventas/RepProductos.aspx".ToUpper(), 32) + PaginaDict.Add("/Ventas/CatVendedores.aspx".ToUpper(), 142) + PaginaDict.Add("/Ventas/PuntoVenta.aspx".ToUpper(), 163) + PaginaDict.Add("/Ventas/CatMesas.aspx".ToUpper(), 244) + PaginaDict.Add("/Ventas/CatPreciosLista.aspx".ToUpper(), 378) + PaginaDict.Add("/Ventas/RepProductosServicios.aspx".ToUpper(), 352) + PaginaDict.Add("/Ventas/RepProductosServiciosDetalle.aspx".ToUpper(), 352) + PaginaDict.Add("/Ventas/RepPS.aspx".ToUpper(), 701) + PaginaDict.Add("/Ventas/RepABT.aspx".ToUpper(), 353) + PaginaDict.Add("/Ventas/CatPromociones.aspx".ToUpper(), 123) + PaginaDict.Add("/Ventas/Promociones.aspx".ToUpper(), 124) + PaginaDict.Add("/Ventas/CatFamiliaSubFamilia.aspx".ToUpper(), 372) + PaginaDict.Add("/Ventas/RepComisiones.aspx".ToUpper(), 382) + PaginaDict.Add("/Ventas/RepComisionesDetalle.aspx".ToUpper(), 382) + PaginaDict.Add("/Ventas/RepComisionesDetallePS.aspx".ToUpper(), 382) + PaginaDict.Add("/Ventas/CatEsquemaComisiones.aspx".ToUpper(), 379) + PaginaDict.Add("/Ventas/CatImpuestosLocales.aspx".ToUpper(), 394) + PaginaDict.Add("/Ventas/ActualizarPrecios.aspx".ToUpper(), 397) + PaginaDict.Add("/Ventas/ClientesAbonar.aspx".ToUpper(), 321) + PaginaDict.Add("/Ventas/Reportes.aspx".ToUpper(), 567) + PaginaDict.Add("/Ventas/DiseñadorReportes.aspx".ToUpper(), 569) + PaginaDict.Add("/Ventas/ReporteDetalle.aspx".ToUpper(), 576) + PaginaDict.Add("/Ventas/PopUpBuscarPs.aspx".ToUpper(), 13) + PaginaDict.Add("/Ventas/RepVentasUtilidadPadre.aspx".ToUpper(), 590) + PaginaDict.Add("/Ventas/RepVentasUtilidad.aspx".ToUpper(), 590) + PaginaDict.Add("/Ventas/RepVentasUtilidadDetalle.aspx".ToUpper(), 590) + PaginaDict.Add("/Ventas/eFacturas.aspx".ToUpper(), 413) + PaginaDict.Add("/Ventas/PV.aspx".ToUpper(), 163) + PaginaDict.Add("/Ventas/PVRene.aspx".ToUpper(), 163) + PaginaDict.Add("/Ventas/Corporativo.aspx".ToUpper(), 807) + PaginaDict.Add("/Ventas/RepRecuperacion.aspx".ToUpper(), 88) + PaginaDict.Add("/Ventas/RepRecuperacionDetalle.aspx".ToUpper(), 88) + PaginaDict.Add("/Ventas/RepComisionesJAM.aspx".ToUpper(), 650) + PaginaDict.Add("/Ventas/RepNCxAplicar.aspx".ToUpper(), 648) + PaginaDict.Add("/Ventas/CatDocumentosClientes.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepDocumentacionVencidaClientes.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepProductosServiciosPeriodo.aspx".ToUpper(), 865) + PaginaDict.Add("/Ventas/ClasificacionesDetalle.aspx".ToUpper(), 875) + PaginaDict.Add("/Ventas/RepPedidos2.aspx".ToUpper(), 881) + PaginaDict.Add("/Ventas/RepPedidos2Detalle.aspx".ToUpper(), 881) + PaginaDict.Add("/Ventas/RepRecuperacionPeriodo.aspx".ToUpper(), 885) + PaginaDict.Add("/Ventas/RepVentasAutorizaciones.aspx".ToUpper(), 531) + PaginaDict.Add("/Ventas/RepComisionesJAM2.aspx".ToUpper(), 889) + PaginaDict.Add("/Ventas/RepComisionesJAM2Detalle.aspx".ToUpper(), 889) + PaginaDict.Add("/Ventas/AuxiliarCliente.aspx".ToUpper(), 1316) + PaginaDict.Add("/Ventas/AuxiliarClienteVentas.aspx".ToUpper(), 542) + PaginaDict.Add("/Ventas/RepCostoPromedioVenta.aspx".ToUpper(), 532) + PaginaDict.Add("/Ventas/RepVentasNetasResumen.aspx".ToUpper(), 533) + PaginaDict.Add("/Ventas/RepTopVentas.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepSolicitudesCancelacion.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepCanceladasPendientes.aspx".ToUpper(), -1) + + PaginaDict.Add("/Ventas/RepCancelacionesPorAtender.aspx".ToUpper(), 750) + PaginaDict.Add("/Ventas/RepCancelacionesPorRespuesta.aspx".ToUpper(), 751) + PaginaDict.Add("/Ventas/RepIngresos.aspx".ToUpper(), 540) + 'Reportes de Anticipos-NC-IXC' + PaginaDict.Add("/Ventas/RepAnticipo-NC-IXC.aspx".ToUpper(), 869) + PaginaDict.Add("/Ventas/RepAnticipo-NC-IXCDetalle.aspx".ToUpper(), 869) + 'PaginaDict.Add("/Ventas/Efacturas.aspx".ToUpper(), 2015) + 'PaginaDict.Add("/Ventas/Ventas.aspx".ToUpper(), 2016) + 'PaginaDict.Add("/Ventas/Clientes.aspx".ToUpper(), 2017) + PaginaDict.Add("/Ventas/Ventas.aspx?Op=Rem".ToUpper(), 2018) + 'PaginaDict.Add("/Ventas/Ventas.aspx?Op=Cot".ToUpper(), 2019) + PaginaDict.Add("/Ventas/VentasH.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/ClientesAbonarH.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/PVRaul.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/CatAutorizacionDescuentos.aspx".ToUpper(), 1037) + PaginaDict.Add("/Ventas/RepPUESinPago.aspx".ToUpper(), 672) + PaginaDict.Add("/Ventas/RepVentasResumen.aspx".ToUpper(), 674) + PaginaDict.Add("/Ventas/RepAnticiposEspeciales.aspx".ToUpper(), 678) + PaginaDict.Add("/Ventas/RepArqueos.aspx".ToUpper(), 679) + PaginaDict.Add("/Ventas/RepArqueosDetalle.aspx".ToUpper(), 680) + PaginaDict.Add("/Ventas/RepCotizacionesxFacturar.aspx".ToUpper(), 686) PaginaDict.Add("/Ventas/RepRemisionesNC.aspx".ToUpper(), 687) PaginaDict.Add("/Ventas/CatCobranzaEstatus.aspx".ToUpper(), 7003) PaginaDict.Add("/Ventas/CatCobranzaEstatusTurno.aspx".ToUpper(), 7004) @@ -4669,12 +4669,12 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/RepVentasMensualesDetalle.aspx".ToUpper(), 721) PaginaDict.Add("/Ventas/MetasVendedores.aspx".ToUpper(), 722) PaginaDict.Add("/Ventas/CatMetasVendedores.aspx".ToUpper(), 723) -#End Region +#End Region 'Portal Cliente/Proveedor - PaginaDict.Add("/PortalCliente/PortalCliente.aspx".ToUpper(), 1101) + PaginaDict.Add("/PortalCliente/PortalCliente.aspx".ToUpper(), 1101) PaginaDict.Add("/PortalProveedor/PortalProveedor.aspx".ToUpper(), 1201) PaginaDict.Add("/Edoc/CatDocumentos.aspx".ToUpper(), 1205) @@ -4683,79 +4683,79 @@ Public Class ClsPaginas PaginaDict.Add("/Edoc/Contratos.aspx".ToUpper(), 1209) 'Portal - PaginaDict.Add("/AIMMGM/ConsultaCliente.aspx".ToUpper(), -1) - PaginaDict.Add("/Portal/ConsultaCliente.aspx".ToUpper(), -1) - PaginaDict.Add("/Proveedores/PortalProveedor.aspx".ToUpper(), -1) - PaginaDict.Add("/Proveedores/LogInProveedores.aspx".ToUpper(), -1) - - 'Punto de Venta - PaginaDict.Add("/PV/PVRepVentas.aspx".ToUpper(), 270) - PaginaDict.Add("/PV/PVRepCompras.aspx".ToUpper(), 272) - PaginaDict.Add("/PV/PVRepVentasCompras.aspx".ToUpper(), 273) - - PaginaDict.Add("/Bancos/PagoElectronicoGrupos.aspx".ToUpper(), -1) - - - - - - - - 'Orden Produccion' - - 'RMA - PaginaDict.Add("/RMA/Garantias.aspx".ToUpper(), 175) - - - - - - - 'IMPUESTOS - PaginaDict.Add("/Impuestos/RepIVAACreditable.aspx".ToUpper(), 563) - - - - - - 'Votos - 'PaginaDict.Add("/Temporal/RegBoletas.aspx".ToUpper(), 1026) - 'PaginaDict.Add("/Temporal/RepVotos.aspx".ToUpper(), 1027) - - - 'DG2016 - PaginaDict.Add("/ZDG/RepGeneral.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/RepMunicipios.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/RepMunicipiosCoordinadores.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/RepMunicipiosLideres.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/RepMunicipiosMovilizadores.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/RepMunicipiosMilitantes.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/PopUpBuscarMilitante.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/ActualizaPadron.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/CapturaManual.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/MensajeManual.aspx".ToUpper(), -1) - PaginaDict.Add("/ZDG/MensajeAutomatico.aspx".ToUpper(), -1) - - 'PymeCharlie - PaginaDict.Add("/PyME/Contabilidad/CatCuentas.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/TiposPoliza.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/PlantillasPolizas.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/PlantillasPolizasDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RegPoliza.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RegPrePoliza.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/ContabilizacionVentas.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/ContabilizacionCompras.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/ContabilidadElectronica.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/CierreEjercicio.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RepBalanceGeneral.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RepAnexoCatalogo.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RepBalanzaComprobacion.aspx".ToUpper(), -1) - PaginaDict.Add("/PyME/Contabilidad/RepEstadoResultados.aspx".ToUpper(), -1) - PaginaDict.Add("/Planeacion/Presupuestos.aspx".ToUpper(), -1) - - 'Pyme 2017 - PaginaDict.Add("/PyME/Sistemas/RegistroEmpresa.aspx".ToUpper(), -1) + PaginaDict.Add("/AIMMGM/ConsultaCliente.aspx".ToUpper(), -1) + PaginaDict.Add("/Portal/ConsultaCliente.aspx".ToUpper(), -1) + PaginaDict.Add("/Proveedores/PortalProveedor.aspx".ToUpper(), -1) + PaginaDict.Add("/Proveedores/LogInProveedores.aspx".ToUpper(), -1) + + 'Punto de Venta + PaginaDict.Add("/PV/PVRepVentas.aspx".ToUpper(), 270) + PaginaDict.Add("/PV/PVRepCompras.aspx".ToUpper(), 272) + PaginaDict.Add("/PV/PVRepVentasCompras.aspx".ToUpper(), 273) + + PaginaDict.Add("/Bancos/PagoElectronicoGrupos.aspx".ToUpper(), -1) + + + + + + + + 'Orden Produccion' + + 'RMA + PaginaDict.Add("/RMA/Garantias.aspx".ToUpper(), 175) + + + + + + + 'IMPUESTOS + PaginaDict.Add("/Impuestos/RepIVAACreditable.aspx".ToUpper(), 563) + + + + + + 'Votos + 'PaginaDict.Add("/Temporal/RegBoletas.aspx".ToUpper(), 1026) + 'PaginaDict.Add("/Temporal/RepVotos.aspx".ToUpper(), 1027) + + + 'DG2016 + PaginaDict.Add("/ZDG/RepGeneral.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/RepMunicipios.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/RepMunicipiosCoordinadores.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/RepMunicipiosLideres.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/RepMunicipiosMovilizadores.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/RepMunicipiosMilitantes.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/PopUpBuscarMilitante.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/ActualizaPadron.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/CapturaManual.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/MensajeManual.aspx".ToUpper(), -1) + PaginaDict.Add("/ZDG/MensajeAutomatico.aspx".ToUpper(), -1) + + 'PymeCharlie + PaginaDict.Add("/PyME/Contabilidad/CatCuentas.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/TiposPoliza.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/PlantillasPolizas.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/PlantillasPolizasDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RegPoliza.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RegPrePoliza.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/ContabilizacionVentas.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/ContabilizacionCompras.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/ContabilidadElectronica.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/CierreEjercicio.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RepBalanceGeneral.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RepAnexoCatalogo.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RepBalanzaComprobacion.aspx".ToUpper(), -1) + PaginaDict.Add("/PyME/Contabilidad/RepEstadoResultados.aspx".ToUpper(), -1) + PaginaDict.Add("/Planeacion/Presupuestos.aspx".ToUpper(), -1) + + 'Pyme 2017 + PaginaDict.Add("/PyME/Sistemas/RegistroEmpresa.aspx".ToUpper(), -1) PaginaDict.Add("/PyME/Sistemas/WizardRegistro.aspx".ToUpper(), -1) @@ -4788,2956 +4788,2956 @@ Public Class ClsPaginas - PaginaDict.Add("/Compras/RepCxPCaudillo.aspx".ToUpper(), -1) - - - 'ECOMMERCE - PaginaDict.Add("/Ecommerce/Insignias.aspx".ToUpper(), 7002) - - PaginaDict.Add("/Acumuladores/Tamaños.aspx".ToUpper(), 1031) - PaginaDict.Add("/Acumuladores/RepUsados.aspx".ToUpper(), 1032) - PaginaDict.Add("/Acumuladores/CatTiposDefecto.aspx".ToUpper(), 1033) - PaginaDict.Add("/Acumuladores/CatTiposUso.aspx".ToUpper(), 1034) - PaginaDict.Add("/Acumuladores/CatFoliosGarantia.aspx".ToUpper(), 1035) + PaginaDict.Add("/Compras/RepCxPCaudillo.aspx".ToUpper(), -1) + + + 'ECOMMERCE + PaginaDict.Add("/Ecommerce/Insignias.aspx".ToUpper(), 7002) + + PaginaDict.Add("/Acumuladores/Tamaños.aspx".ToUpper(), 1031) + PaginaDict.Add("/Acumuladores/RepUsados.aspx".ToUpper(), 1032) + PaginaDict.Add("/Acumuladores/CatTiposDefecto.aspx".ToUpper(), 1033) + PaginaDict.Add("/Acumuladores/CatTiposUso.aspx".ToUpper(), 1034) + PaginaDict.Add("/Acumuladores/CatFoliosGarantia.aspx".ToUpper(), 1035) PaginaDict.Add("/Acumuladores/CatGarantiasMeses.aspx".ToUpper(), 1036) PaginaDict.Add("/Acumuladores/RepIndicadorDiario.aspx".ToUpper(), 2055) - PaginaDict.Add("/Acumuladores/RepEntradasUsadosClientes.aspx".ToUpper(), 543) - PaginaDict.Add("/Acumuladores/EntradasUsadosResumenRep.aspx".ToUpper(), 1032) - - - 'Antes de aquí. - Application("GlobalSIGAppPaginas") = PaginaDict - - Else - PaginaDict = DirectCast(Application("GlobalSIGAppPaginas"), Hashtable) - End If - - Retorno = Convert.ToInt32(PaginaDict.Item(Pagina.ToUpper())) - - ' If Retorno = 0 Then 'No lo encontró en la lista General de Página y busca en los que son temporales - 'Dim PaginaDictTemp As New HybridDictionary - ' - If Pagina.ToUpper() = ("/Bancos/IE.aspx").ToUpper() Then - Select Case Request("Opcion") - Case "EGSSINFACT" : Retorno = 176 - Case "DEV" : Retorno = 283 - Case "ANTC" : Retorno = 266 - Case "INGPC" : Retorno = 156 - Case Else : Retorno = 153 - End Select - End If - - If Pagina.ToUpper() = ("/Bancos/IE2.aspx").ToUpper() Then - Select Case Request("Opcion") - Case "EGSSINFACT" : Retorno = 176 - Case "DEV" : Retorno = 283 - Case "ANTC" : Retorno = 266 - Case Else : Retorno = 153 - End Select - End If - - If Pagina.ToUpper() = ("/Bancos/RepIE.aspx").ToUpper() Then - Select Case Request("Tipo") - Case "Conciliaciones" : Retorno = 83 - Case Else : Retorno = 82 - End Select - End If - - - If Pagina.ToUpper() = ("/Bancos/PolizaCheque.aspx").ToUpper() Then - Select Case Request("Tipo") - Case "Ing" : Retorno = 161 - Case Else : Retorno = 171 - End Select - End If - ' - If Pagina.ToUpper() = "/AC/RegComprometido.aspx".ToUpper() Then - Select Case Request("Opc") - Case "NOM" : Retorno = 295 - Case Else : Retorno = 296 - End Select - End If - - If Pagina.ToUpper() = ("/Temporal/RegBoletas.aspx").ToUpper() Then - Select Case Request("Tipo") - Case "E" : Retorno = 1026 - Case "N" : Retorno = 1028 - End Select - End If - - If Pagina.ToUpper() = ("/Temporal/RepVotos.aspx").ToUpper() Then - Select Case Request("Tipo") - Case "E" : Retorno = 1027 - Case "N" : Retorno = 1029 - End Select - End If - - If Pagina.ToUpper() = ("/Inventarios/EntradasSalidas.aspx").ToUpper() Then - Select Case Request("CI") - Case "1" : Retorno = 452 - Case Else : Retorno = 219 - End Select - End If - - If Pagina.ToUpper() = ("/Inventarios/RecepcionUsados.aspx").ToUpper() Then - Select Case Request("Opc") - Case "S" : Retorno = 1203 - Case Else : Retorno = 1202 - End Select + PaginaDict.Add("/Acumuladores/RepEntradasUsadosClientes.aspx".ToUpper(), 543) + PaginaDict.Add("/Acumuladores/EntradasUsadosResumenRep.aspx".ToUpper(), 1032) + + + 'Antes de aquí. + Application("GlobalSIGAppPaginas") = PaginaDict + + Else + PaginaDict = DirectCast(Application("GlobalSIGAppPaginas"), Hashtable) End If - If Pagina.ToUpper() = ("/Ventas/Ventas.aspx").ToUpper() Then - Select Case Request("Op") + Retorno = Convert.ToInt32(PaginaDict.Item(Pagina.ToUpper())) + + ' If Retorno = 0 Then 'No lo encontró en la lista General de Página y busca en los que son temporales + 'Dim PaginaDictTemp As New HybridDictionary + ' + If Pagina.ToUpper() = ("/Bancos/IE.aspx").ToUpper() Then + Select Case Request("Opcion") + Case "EGSSINFACT" : Retorno = 176 + Case "DEV" : Retorno = 283 + Case "ANTC" : Retorno = 266 + Case "INGPC" : Retorno = 156 + Case Else : Retorno = 153 + End Select + End If + + If Pagina.ToUpper() = ("/Bancos/IE2.aspx").ToUpper() Then + Select Case Request("Opcion") + Case "EGSSINFACT" : Retorno = 176 + Case "DEV" : Retorno = 283 + Case "ANTC" : Retorno = 266 + Case Else : Retorno = 153 + End Select + End If + + If Pagina.ToUpper() = ("/Bancos/RepIE.aspx").ToUpper() Then + Select Case Request("Tipo") + Case "Conciliaciones" : Retorno = 83 + Case Else : Retorno = 82 + End Select + End If + + + If Pagina.ToUpper() = ("/Bancos/PolizaCheque.aspx").ToUpper() Then + Select Case Request("Tipo") + Case "Ing" : Retorno = 161 + Case Else : Retorno = 171 + End Select + End If + ' + If Pagina.ToUpper() = "/AC/RegComprometido.aspx".ToUpper() Then + Select Case Request("Opc") + Case "NOM" : Retorno = 295 + Case Else : Retorno = 296 + End Select + End If + + If Pagina.ToUpper() = ("/Temporal/RegBoletas.aspx").ToUpper() Then + Select Case Request("Tipo") + Case "E" : Retorno = 1026 + Case "N" : Retorno = 1028 + End Select + End If + + If Pagina.ToUpper() = ("/Temporal/RepVotos.aspx").ToUpper() Then + Select Case Request("Tipo") + Case "E" : Retorno = 1027 + Case "N" : Retorno = 1029 + End Select + End If + + If Pagina.ToUpper() = ("/Inventarios/EntradasSalidas.aspx").ToUpper() Then + Select Case Request("CI") + Case "1" : Retorno = 452 + Case Else : Retorno = 219 + End Select + End If + + If Pagina.ToUpper() = ("/Inventarios/RecepcionUsados.aspx").ToUpper() Then + Select Case Request("Opc") + Case "S" : Retorno = 1203 + Case Else : Retorno = 1202 + End Select + End If + + If Pagina.ToUpper() = ("/Ventas/Ventas.aspx").ToUpper() Then + Select Case Request("Op") Case "Cot" : Retorno = 366 - Case "Rem" : Retorno = 2018 - Case Else : Retorno = 6 - End Select + Case "Rem" : Retorno = 2018 + Case Else : Retorno = 6 + End Select End If - If Pagina.ToUpper() = ("/Ventas/RepVentas.aspx").ToUpper() Then - Select Case Request("Op") - Case "Cot" : Retorno = 367 - Case Else : Retorno = 9 - End Select - End If - - Return Retorno - - End Function - Public Sub CerrarSession() - - Usuario.CerrarSession() - End Sub - Public Sub Alert(Mensaje As String, Optional pOpcion As TipoMensaje = TipoMensaje.MsgInformacion, Optional JSBtnAceptar As String = "", Optional timeout As Integer = 5) - If DirectCast(pOpcion, Integer) >= 5 Then - Mensaje = Mensaje.Replace("'"c, "\'").Replace(vbCrLf, "").Replace("""", "\'").Replace(vbLf, " ") - JSBtnAceptar = JSBtnAceptar.Replace("'"c, "\'") - Dim toastscript As String = String.Format("alertatoast({3},'{0}',function(){{{1}}},{2});", Mensaje, JSBtnAceptar, timeout, DirectCast(pOpcion, Integer)) - ViewState("strToastMsglargonoreplace") = String.Format("{0}{1}", If(Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString().Length > 0, ViewState("strToastMsglargonoreplace").ToString(), ""), toastscript) - Else - Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout) - End If - End Sub + If Pagina.ToUpper() = ("/Ventas/RepVentas.aspx").ToUpper() Then + Select Case Request("Op") + Case "Cot" : Retorno = 367 + Case Else : Retorno = 9 + End Select + End If + + Return Retorno + + End Function + Public Sub CerrarSession() + + Usuario.CerrarSession() + End Sub + Public Sub Alert(Mensaje As String, Optional pOpcion As TipoMensaje = TipoMensaje.MsgInformacion, Optional JSBtnAceptar As String = "", Optional timeout As Integer = 5) + If DirectCast(pOpcion, Integer) >= 5 Then + Mensaje = Mensaje.Replace("'"c, "\'").Replace(vbCrLf, "").Replace("""", "\'").Replace(vbLf, " ") + JSBtnAceptar = JSBtnAceptar.Replace("'"c, "\'") + Dim toastscript As String = String.Format("alertatoast({3},'{0}',function(){{{1}}},{2});", Mensaje, JSBtnAceptar, timeout, DirectCast(pOpcion, Integer)) + ViewState("strToastMsglargonoreplace") = String.Format("{0}{1}", If(Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString().Length > 0, ViewState("strToastMsglargonoreplace").ToString(), ""), toastscript) + Else + Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout) + End If + End Sub Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender If sw IsNot Nothing AndAlso Not (Not User.Identity.IsAuthenticated OrElse UsuarioActual Is Nothing) Then sw.Stop() Using ObjUsuario As New ClsSisUsuarios - ObjUsuario.AddBitacora(CveModulo, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Request.Url.ToString(), sw.ElapsedMilliseconds) + ObjUsuario.AddBitacora(CveModulo, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Request.Url.PathAndQuery.ToString(), sw.ElapsedMilliseconds) End Using End If - If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then - RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro") - ViewState("strToastMsglargonoreplace") = Nothing - End If - - End Sub - Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object) - 'If Request.Form("__VIEWSTATE_KEY") IsNot Nothing Then Cache.Remove(Request.Form("__VIEWSTATE_KEY")) 'elimino la cachado anteriormente - Dim VSKey As String = String.Format("VIEWSTATE_{0}_{1}_{2}", Session.SessionID, Request.Path, Date.Now.Ticks) - 'Cache.Add(VSKey, pviewState, Nothing, Date.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, Nothing) 'Store the ViewState on Cache - Session.Add(VSKey, pviewState) 'Store the ViewState on Cache - ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", VSKey) - - End Sub - Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object - - Dim VSKey As String = Request.Form("__VIEWSTATE_KEY") - If Not VSKey.StartsWith("VIEWSTATE_") Then 'Request the Key from the page and validade it. - Throw New Exception(String.Format("Invalid VIEWSTATE Key: {0}", VSKey)) - End If - If Session(VSKey) Is Nothing Then 'si por algún motivo, el caché expiró, le dice a la página que se recargue y obtenga los datos de nuevo, y así evitar errores al obtener el viewstate vacío - Response.Redirect(Request.RawUrl) - Return Nothing - Else - Return Session(VSKey) - End If - - End Function - Public Shared Sub CargaParametros(Parametros As String) - Dim P1() As String = Parametros.Split("&"c) - Dim Tmp As String - Dim P2() As String - - UrlParametros = New Hashtable - - For Each Tmp In P1 - P2 = Tmp.Split("="c) - UrlParametros.Add(P2(0).ToString.ToUpper(), P2(1)) - Next - - End Sub - Shared Sub RegeneraImagen(ByVal Ruta As String) - - Dim BM As New Drawing.Bitmap(Ruta) - Dim Width As Integer = BM.Width - Dim Height As Integer = BM.Height - Dim Thumb As New Drawing.Bitmap(Width, Height) - Dim G As Drawing.Graphics = Drawing.Graphics.FromImage(Thumb) - - - G.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic - G.DrawImage(BM, New Drawing.Rectangle(0, 0, Width, Height), New Drawing.Rectangle(0, 0, BM.Width, BM.Height), Drawing.GraphicsUnit.Pixel) - - BM.Dispose() - G.Dispose() - - 'image path. - Thumb.Save(Ruta, Drawing.Imaging.ImageFormat.Jpeg) 'can use any image format - Thumb.Dispose() - End Sub - Public Sub RegistraScript(Script As String, Optional valuetick As String = "") - Dim Rdm As Random = New Random() - ScriptManager.RegisterStartupScript(Page, Me.GetType(), String.Format("{0}{1}{2}", (DateTime.Now.Ticks + 1), Rdm.Next(), valuetick), String.Format("", Script), False) - End Sub - Public Sub TabEnabled(Tab As System.Web.UI.HtmlControls.HtmlAnchor, Valor As Boolean) - If Valor Then - 'RegistraScript(String.Format("$( ""#{0}"" ).removeClass( ""linkdesactive"" );", tab.ClientID)) - Try - Tab.Attributes("class") = Tab.Attributes("class").Replace("linkdesactive", "") - Catch ex As Exception - Tab.Attributes("class") = "" - End Try - Else - Tab.Attributes.Add("class", "linkdesactive") - End If - End Sub - Public Sub TabActive(Tab As System.Web.UI.HtmlControls.HtmlAnchor) - RegistraScript(String.Format("$( ""#{0}"" ).Click( );", Tab.ClientID)) - End Sub - ''' - ''' - ''' - Public Sub Alerta(Mensaje As String, Tipo As String, Funcion As String) - RegistraScript(String.Format("bootbox.alert('{0}', function() {{{2}}} );", Mensaje, Tipo, Funcion)) - End Sub - Public Sub NotificacionesPendientes(Nota As String) - 'incremento el contador de alertas - Dim Type = Master.GetType - Dim Prop = Type.GetProperty("countNotificaciones") - Prop.SetValue(Master, 1 + CInt(Prop.GetValue(Master))) - 'end incremento contador de alertas - - Dim ltl = DirectCast(Master.FindControl("LtlMNotificaciones"), Literal) - - ltl.Text = String.Format(" {0} {1}", ltl.Text, Nota) - End Sub - Public Sub Confirmacion(Mensaje As String, Tipo As String, FuncionOK As String, FuncionCancel As String) - RegistraScript(String.Format("bootbox.confirm('{0}', function(result) {{if (result){{ {2} }}else{{ {3} }} }}); ", Mensaje, Tipo, FuncionOK, FuncionCancel)) - End Sub - Public Function AddBitacoraUsuario(CveModulo As Integer, Accion As String, Resultado As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - Dim ObjUsuario As New ClsSisUsuarios - Retorno = ObjUsuario.AddBitacora(CveModulo, Accion, Resultado, CveUsuario, CveEmpresa) - ObjUsuario.Dispose() - Return Retorno - End Function - -#Region " IMPRIMIR PDF " - ''' - ''' Genera documento PDF o Excel - ''' - ''' Directorio donde se ubica el archivo - ''' Datatable - ''' Listado de parametros para el reporte - ''' Opcional Nombre del archivo que se descarga - ''' Optional, Formato de Generacion PDF o Excel - ''' - Public Sub ImprimirPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = RDSName - rds.Value = DtDatos - lrds.Add(rds) - ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) - End Sub - Public Sub ImprimirPDFMultiDS(RutaReporte As String, lrds As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) - ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) - End Sub - - ''' - ''' Genera documento PDF o Excel - ''' - ''' Directorio donde se ubica el archivo - ''' Contenedor de Datatables - ''' Listado de parametros para el reporte - ''' Opcional Nombre del archivo que se descarga - ''' Optional, Formato de Generacion PDF o Excel - ''' - Public Sub ImprimirPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) - 'limpio ReportViwer - ImprimirbytesPDF(StreamPDF(RutaReporte, DataSource, Parametros, NombreArchivo, Formato, MR), NombreArchivo, Formato) - End Sub - Public Function StreamPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) As Byte() - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = RDSName - rds.Value = DtDatos - lrds.Add(rds) - Return StreamPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) - End Function - Public Function StreamPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) As Byte() - 'limpio ReportViwer - Dim sw As New System.Diagnostics.Stopwatch() - sw.Start() - - If IsNothing(MR) Then MR = New ReportViewer - Dim Bytes As Byte() = Nothing - Try - ' MasterReporteador.LocalReport.DataSources.Clear() - For Each RDS As ReportDataSource In DataSource - MR.LocalReport.DataSources.Add(RDS) - Next - - MR.LocalReport.ReportPath = RutaReporte - MR.ProcessingMode = ProcessingMode.Local - MR.LocalReport.EnableExternalImages = True - MR.LocalReport.SetParameters(Parametros) - MR.LocalReport.Refresh() - Dim Warnings As Warning() = Nothing - Dim StreamIds As String() = Nothing - Dim MimeType As String = Nothing - Dim Encoding As String = Nothing - Dim Extension As String = Nothing - Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings) - Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - End Try - - sw.Stop() - If sw.Elapsed.TotalSeconds > 10 Then - GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") - End If - - Return Bytes - End Function - Public Function ImprimirPDFCrystal(RutaReporte As String, DataSource As DataTable, Parametros As List(Of CrystalParametro), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportDocument = Nothing) As Byte() - 'limpio ReportViwer - Dim sw As New System.Diagnostics.Stopwatch() - sw.Start() - If IsNothing(MR) Then MR = New ReportDocument() - Dim Bytes As Byte() = Nothing - Dim formatType As ExportFormatType = ExportFormatType.NoFormat - Try - MR.Load(RutaReporte) - MR.SetDataSource(DataSource) - - For Each item As CrystalParametro In Parametros - MR.SetParameterValue(item.Nombre, item.Valor) - Next - - Select Case Formato - Case "PDF" - formatType = ExportFormatType.PortableDocFormat - 'Format = "Application/pdf" - Case "EXCEL" - formatType = ExportFormatType.Excel - 'Format = "application/ms-excel" - End Select - Dim Stream As IO.Stream = MR.ExportToStream(formatType) - Dim BD As New BinaryReader(MR.ExportToStream(formatType)) - Bytes = BD.ReadBytes(CInt(MR.ExportToStream(formatType).Length)) - BD.Dispose() - Stream.Dispose() - 'Dim Buffer(CInt(Stream.Length)) As Byte - 'Bytes = Buffer - 'MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo) - Catch ex As CrystalReportsException - GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, - $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, - ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, - $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, - ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) - - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - End Try - sw.Stop() - If sw.Elapsed.TotalSeconds > 10 Then - GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") - End If - If MR IsNot Nothing Then MR.Dispose() - Return Bytes - End Function - - Public Function ImprimirSubRepPDFCrystal(RutaReporte As String, DataSource As DataTable, Parametros As List(Of CrystalParametro), DataSource1 As DataTable, DataSource2 As DataTable, SubRep1 As String, SubRep2 As String, Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportDocument = Nothing) As Byte() - 'limpio ReportViwer - Dim sw As New System.Diagnostics.Stopwatch() - - sw.Start() - If IsNothing(MR) Then MR = New ReportDocument() - - Dim SR1 As New ReportDocument - Dim SR2 As New ReportDocument - - Dim Bytes As Byte() = Nothing - Dim formatType As ExportFormatType = ExportFormatType.NoFormat - Try - - MR.Load(RutaReporte) - - SR1 = MR.OpenSubreport(SubRep1) - SR2 = MR.OpenSubreport(SubRep2) - - MR.SetDataSource(DataSource) - - SR1.SetDataSource(DataSource1) - SR2.SetDataSource(DataSource2) - - For Each item As CrystalParametro In Parametros - MR.SetParameterValue(item.Nombre, item.Valor) - Next - - Select Case Formato - Case "PDF" - formatType = ExportFormatType.PortableDocFormat - 'Format = "Application/pdf" - Case "EXCEL" - formatType = ExportFormatType.Excel - 'Format = "application/ms-excel" - End Select - Dim Stream As IO.Stream = MR.ExportToStream(formatType) - Dim BD As New BinaryReader(MR.ExportToStream(formatType)) - Bytes = BD.ReadBytes(CInt(MR.ExportToStream(formatType).Length)) - BD.Dispose() - Stream.Dispose() - 'Dim Buffer(CInt(Stream.Length)) As Byte - 'Bytes = Buffer - 'MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo) - Catch ex As CrystalReportsException - GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, - $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, - ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, - $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, - ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) - - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - End Try - sw.Stop() - If sw.Elapsed.TotalSeconds > 10 Then - GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") - End If - If MR IsNot Nothing Then MR.Dispose() - Return Bytes - End Function - - Public Function ImprimirPDFPyME(RutaReporte As String, DataSource As DataSet, Parametros As List(Of CrystalParametro), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As StiReport = Nothing) As Byte() - - If IsNothing(MR) Then MR = New StiReport() - Dim Bytes As Byte() = Nothing - Try - MR.Load(RutaReporte) - MR.Dictionary.DataSources.Clear() - MR.RegData(DataSource) - Dim Lista = MR.Dictionary.Variables.ToList() - For Each item As CrystalParametro In Parametros - If Lista.Exists(Function(a) a.Name = item.Nombre) Then - MR.Dictionary.Variables(item.Nombre).Value = item.Valor.ToString - End If - Next - - MR.Dictionary.Synchronize() - MR.IsRendered = False - MR.Render(False) - Dim pdfSettings As New StiPdfExportSettings() - Dim MemoryStream As New MemoryStream - Select Case Formato - Case "PDF" - MR.ExportDocument(StiExportFormat.Pdf, MemoryStream, pdfSettings) - Case "EXCEL" - MR.ExportDocument(StiExportFormat.Excel2007, MemoryStream, pdfSettings) - End Select - Bytes = MemoryStream.ToArray - Catch ex As Exception - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - End Try - Return Bytes - End Function - - Public Function StreamPDFTest(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) As Byte() - 'limpio ReportViwer - - Dim sw As New System.Diagnostics.Stopwatch() - sw.Start() - - If IsNothing(MR) Then MR = New ReportViewer - Dim Bytes As Byte() = Nothing - Try - - ' MR.LocalReport.ReportPath = RutaReporte - MR.ProcessingMode = ProcessingMode.Local - - Using rdlcR As New StreamReader(RutaReporte) - MR.LocalReport.LoadReportDefinition(rdlcR) - MR.LocalReport.EnableExternalImages = True - MR.LocalReport.SetParameters(Parametros) - MR.LocalReport.Refresh() - End Using - - For Each RDS As ReportDataSource In DataSource - MR.LocalReport.DataSources.Add(RDS) - Next - - Dim Warnings As Warning() = Nothing - Dim StreamIds As String() = Nothing - Dim MimeType As String = Nothing - Dim Encoding As String = Nothing - Dim Extension As String = Nothing - - Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings) - Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - End Try - - sw.Stop() - If sw.Elapsed.TotalSeconds > 10 Then - GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") - 'GuardaLog($"Tiempo Renderizado Milisegundos {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") - End If - - Return Bytes - End Function - - - ''' - ''' Genera documento PDF o Excel - ''' - ''' - ''' - ''' - ''' - Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False) - 'limpio ReportViwer - Dim mimeType As String = Nothing - Dim extension As String = Nothing - - 'If Descarga Then - ' Try - ' bytes = bytes - ' File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img) - ' Catch ex As Exception - ' If UsuarioActual.CveRol = 1 Then - ' Alert(ex.Message, TipoMensaje.MsgAdvertencia) - ' Else - ' Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia) - ' End If - ' End Try - 'End If - - Try - bytes = bytes - Response.Buffer = True - Response.Clear() - Response.ContentType = mimeType - Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.{1}", NombreArchivo, If(Formato = "PDF", "pdf", "xls"))) - Response.BinaryWrite(bytes) ' create the file - Response.Flush() ' send it to the client to download - HttpContext.Current.Response.SuppressContent = True - HttpContext.Current.ApplicationInstance.CompleteRequest() - HttpContext.Current.Response.End() - - Catch ex As Exception - - If UsuarioActual.CveRol = 1 Then - Alert($"Error: {ex.Message} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))}", TipoMensaje.MsgAdvertencia) - Else - Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod:'IMPDFclspag'", TipoMensaje.MsgAdvertencia) - End If - End Try - End Sub - Public Sub ImprimirPDFview(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = RDSName - rds.Value = DtDatos - lrds.Add(rds) - ImprimirPDFview(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) - End Sub - Public Sub ImprimirPDFview(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) - 'limpio ReportViwer - If IsNothing(MR) Then - MR = New ReportViewer - End If - ' MasterReporteador.LocalReport.DataSources.Clear() - For Each rds As ReportDataSource In DataSource - MR.LocalReport.DataSources.Add(rds) - Next - MR.LocalReport.ReportPath = RutaReporte - MR.ProcessingMode = ProcessingMode.Local - MR.LocalReport.EnableExternalImages = True - MR.LocalReport.SetParameters(Parametros) - MR.LocalReport.Refresh() - - End Sub -#End Region - -#Region "IMPRIMIR FACTURA" - Public Sub PdfFacturaPyME(ByRef Vta As Modelos.Factura, DT As DataTable) - Dim retorno As Byte() = Nothing - - 'DATOS GENERALES - Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" - Dim PathXML As String = $"{Ruta}XML\{Vta.TipoDocto}\{Vta.SerieFolio}.xml" - Dim NombreArchivo As String = "" - Dim NombreArchivoDescarga As String = "" - Dim TipoDocumento As String = "" - Dim TipoDocumentoRef As String = "" - Dim AplicaPagare As String = "1" - - Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) - Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) - - Dim ImagenPath = String.Format("{0}Formatos\Suc{1}\logo.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - Dim Logo As New System.IO.FileInfo(ImagenPath) - Dim ImgLogo = New Uri(String.Format("{0}Empresas/{1}/Formatos/Suc{2}.png", UrlSitio, UsuarioActual.CveEmpresa, Vta.CveSucursal)).AbsoluteUri - - Dim SBDomicilioSucursal As New StringBuilder() - Dim CiudadSucursal As String = String.Format("{0},{1}", Vta.SubProyecto.Municipio, Vta.SubProyecto.Estado) - Dim DomicilioSucursal As String = "" - - SBDomicilioSucursal.AppendFormat("{0}", Vta.SubProyecto.Calle) - If Vta.SubProyecto.NoExt.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", Vta.SubProyecto.NoExt) - If Vta.SubProyecto.NoInt.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", Vta.SubProyecto.NoInt) - If Vta.SubProyecto.Colonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", Vta.SubProyecto.Colonia) - If Vta.SubProyecto.CP.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", Vta.SubProyecto.CP) - If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) - If Vta.SubProyecto.Pais.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", Vta.SubProyecto.Pais) - - DomicilioSucursal = SBDomicilioSucursal.ToString - - Dim Fecha As String = Vta.Fecha.ToShortDateString - - Dim SBDireccion As New StringBuilder() - Dim SBLugar As New StringBuilder() - Dim ClienteDireccion As String - Dim ClienteLugar As String - - 'SI ESTA TIMBRADA - CON XML - If File.Exists(PathXML) AndAlso Vta.Serie <> "VistaPrevia" Then 'Cuando es vista previe y coincide la serie y folio se ponen los datos fiscales - Dim XmlDoc As New System.Xml.XmlDocument - XmlDoc.Load(PathXML) - - Dim TC As Decimal = 1 - Try - TC = XmlDoc.DocumentElement.Attributes("TipoCambio").InnerText.ToDecimal - Catch ex As Exception - TC = 1 - End Try - - Vta.FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate - Vta.NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText - - Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") - - If Not IsNothing(validaElemento) Then - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText - Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate - Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText - Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText - - End If - Next - Else - Vta.FolioFiscal = "Sin Timbrar" - Vta.NoSerieCertificado = "Sin Timbrar" - Vta.SelloCFDi = "Sin Timbrar" - Vta.SelloSAT = "Sin Timbrar" - End If - - 'SIN TIMBRAR - SIN XML - Else - Vta.FolioFiscal = "Sin Timbrar" - Vta.NoSerieCertificado = "Sin Timbrar" - Vta.SelloCFDi = "Sin Timbrar" - Vta.SelloSAT = "Sin Timbrar" - End If - - 'DIRECCION CLIENTE - If Vta.CveClienteSucursal.ToEntero > 0 Then - 'Si cliente tiene Noint, NoExt, CP - SBDireccion.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) - If Vta.ClienteSucursal.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) - If Vta.ClienteSucursal.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) - If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.ClienteSucursal.Colonia) - - If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then - If Vta.ClienteSucursal.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.ClienteSucursal.CP.Trim) - End If - - 'Si cliente tiene Local, CD, Edo, Pais - If Vta.ClienteSucursal.Localidad IsNot Nothing AndAlso Vta.ClienteSucursal.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.ClienteSucursal.Localidad) - If Vta.ClienteSucursal.Municipio IsNot Nothing AndAlso Vta.ClienteSucursal.Municipio.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.ClienteSucursal.Municipio) - If Vta.ClienteSucursal.Estado IsNot Nothing AndAlso Vta.ClienteSucursal.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.ClienteSucursal.Estado) - If Vta.ClienteSucursal.Pais IsNot Nothing AndAlso Vta.ClienteSucursal.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.ClienteSucursal.Pais) - Else - SBDireccion.AppendFormat("{0}", Vta.Cliente.Direccion) - If Vta.Cliente.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) - If Vta.Cliente.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) - If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.Cliente.Colonia) - - If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then - If Vta.Cliente.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.Cliente.CP.Trim) - End If - - 'Si cliente tiene Local, CD, Edo, Pais - If Vta.Cliente.Localidad IsNot Nothing AndAlso Vta.Cliente.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.Cliente.Localidad) - If Vta.Cliente.Ciudad IsNot Nothing AndAlso Vta.Cliente.Ciudad.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.Cliente.Ciudad) - If Vta.Cliente.Estado IsNot Nothing AndAlso Vta.Cliente.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.Cliente.Estado) - If Vta.Cliente.Pais IsNot Nothing AndAlso Vta.Cliente.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.Cliente.Pais) - - End If - - ClienteDireccion = SBDireccion.ToString - ClienteLugar = SBLugar.ToString - SBDireccion.Clear() - SBLugar.Clear() - - 'LOGO - Dim LogoRuta As String = "" - 'POR SUCURSAL - LogoRuta = String.Format("{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - If File.Exists(LogoRuta) Then - LogoRuta = String.Format("file://{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - 'POR EMPRESA - Else - LogoRuta = String.Format("{0}Formatos\Logo.png", UsuarioActual.Empresa.Ruta) - If File.Exists(LogoRuta) Then - LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - End If - End If - LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - 'Si no tiene CBB, SE GENERA - If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) - End If - ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) - - Dim CadenaOriginals As String = "||1.0|" + Vta.FolioFiscal + "|" + Vta.FechaCertificacion.ToString("yyyy-MM-dd") + "T" + Vta.FechaCertificacion.ToString("HH:mm:ss") + "|" + Vta.SelloCFDi + "|" + Vta.NoSerieCertificado + "||" - If Not ImagenCBB.Exists Then ImgCBB = "" - Dim RutaFormato As String = "" - - - 'AQUI EMPIEZA LOS PARAMETROS - Try - Dim params = New List(Of CrystalParametro) - - 'CLIENTE - params.Add(New CrystalParametro("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) - params.Add(New CrystalParametro("ClienteDireccion", ClienteDireccion)) - params.Add(New CrystalParametro("ClienteLugar", ClienteLugar)) - - - 'TOTALES - params.Add(New CrystalParametro("SubTotal", Vta.SubTotal.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("Descuento", Vta.Descuento.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("Amortizacion", Vta.Amortizacion.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("SubTotal2", (Vta.SubTotal - Vta.Descuento - Vta.Amortizacion).ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("IVA", Vta.IVA.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("RetIVA", Vta.RetIVA.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("RetISR", Vta.RetISR.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("Total", Vta.Total.ToString.FormatoNumero(2))) - params.Add(New CrystalParametro("ImporteLetra", Vta.Total.ToString.ToDouble.Texto2Letras(Vta.CveMoneda))) - - 'DATOS GENERALES - params.Add(New CrystalParametro("Observaciones", Vta.Observaciones)) - params.Add(New CrystalParametro("CveVendedor", Vta.CveVendedor.ToString)) - 'params.Add(New CrystalParametro("Status", Vta.EstatusFactura)) - params.Add(New CrystalParametro("FechaSolicitud", Vta.Fecha.ToString("dd/MMMM/yyyy"))) ' se puede omitir - params.Add(New CrystalParametro("Serie", Vta.Serie)) - params.Add(New CrystalParametro("Folio", Vta.Folio.ToString)) - params.Add(New CrystalParametro("DomicilioSucursal", DomicilioSucursal)) - params.Add(New CrystalParametro("Vencimiento", Vta.FechaVencimiento.ToString("dd/MM/yyyy"))) - params.Add(New CrystalParametro("FolioFiscal", Vta.FolioFiscal)) - params.Add(New CrystalParametro("FechaCertificacion", String.Format("{0}T{1}", Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss")))) - params.Add(New CrystalParametro("SelloCFDI", Vta.SelloCFDi)) - params.Add(New CrystalParametro("CadenaSAT", CadenaOriginals)) - params.Add(New CrystalParametro("SelloSAT", Vta.SelloSAT)) - - params.Add(New CrystalParametro("QR", ImgCBB)) - params.Add(New CrystalParametro("ClienteRFC", Vta.Cliente.RFC)) - params.Add(New CrystalParametro("FormaPago", Vta.FormaPagoText)) - params.Add(New CrystalParametro("Moneda", Vta.Moneda)) - params.Add(New CrystalParametro("TipoCambio", Vta.TipoCambio.ToString)) - params.Add(New CrystalParametro("CondicionPago", Vta.CondicionesPagoText)) - params.Add(New CrystalParametro("CadenaOriginal", CadenaOriginals)) - params.Add(New CrystalParametro("SerieCertificadoSAT", Vta.NoSerieCertificado)) - params.Add(New CrystalParametro("CertificadoContribuyente", Vta.NoSerieCertificadoContribuyente)) - params.Add(New CrystalParametro("NumCta", Vta.NumeroCuenta)) - params.Add(New CrystalParametro("LogoPath", LogoRuta)) - - 'VENDEDOR - Dim RowVendedor As DataRow = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveVendedor = {0}", Vta.CveVendedor.ToString)) - If Not IsNothing(RowVendedor) Then - params.Add(New CrystalParametro("VendedorNombre", RowVendedor("Vendedor").ToString)) - params.Add(New CrystalParametro("VendedorMail", RowVendedor("Correo").ToString)) - params.Add(New CrystalParametro("VendedorTelefono", RowVendedor("Telefono").ToString)) - params.Add(New CrystalParametro("VendedorCelular", RowVendedor("Celular").ToString)) - - End If - - params.Add(New CrystalParametro("CiudadSucursal", CiudadSucursal)) - params.Add(New CrystalParametro("OC", Vta.Det_OrdenCompra.ToString)) - - If UsuarioActual.Empresa.Funcionalidad(508) = "1" Then - params.Add(New CrystalParametro("IEPS", Vta.IEPS.ToString.FormatoNumero(2))) - End If - - If Vta.CveClienteSucursal > 0 Then - params.Add(New CrystalParametro("ClienteContactoMail", Vta.ClienteSucursal.CorreoSucursal)) - params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) - Else - params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion)) - params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) - End If - - If UsuarioActual.CveEmpresa.Contiene(17) Then - params.Add(New CrystalParametro("MetodoPago", Vta.ClaveMetodoPagoSAT.ToString)) - Else - params.Add(New CrystalParametro("MetodoPago", Vta.MetodoPago.ToString)) - End If - - - Select Case Vta.TipoDocto - Case "Ing" - NombreArchivo = "Factura" - NombreArchivoDescarga = "Factura" - TipoDocumento = "INGRESO" - - 'GENERAL - params.Add(New CrystalParametro("TipoDocumento", NombreArchivoDescarga)) - params.Add(New CrystalParametro("Tipo", TipoDocumento)) - params.Add(New CrystalParametro("Ref", TipoDocumentoRef)) - params.Add(New CrystalParametro("AplicaPagare", AplicaPagare)) - - 'VSH - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122, 145) Then - 'DATOS CLIENTES - Dim ClienteRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Vta.CveCliente.ToString)) - Dim DatosCliente = "" - If ClienteRow IsNot Nothing Then - DatosCliente = String.Format("{0} | {1} | {2}", Vta.SubProyecto.Municipio, ClienteRow("CuentaContable"), ClienteRow("Codigo")) - End If - params.Add(New CrystalParametro("DatosClientes", DatosCliente)) - params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) - End If - - 'COMPU, DN DIFUSA - If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then - params.Add(New CrystalParametro("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) - params.Add(New CrystalParametro("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) - params.Add(New CrystalParametro("PedidoContrato", Vta.PedidoContrato)) - params.Add(New CrystalParametro("DescripcionContrato", Vta.NumeroDescripcionContrato)) - - params.Add(New CrystalParametro("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) - params.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New CrystalParametro("FechaImpresion", Now.ToDateTime.ToString)) - params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) - - 'INE COMPLEMENTOS - If UsuarioActual.CveEmpresa.Contiene(72) Then - Dim INETipoProceso As String = "" - Dim INETipoComite As String = "" - Dim INEIdContabilidad As Integer = 0 - If Vta.ComplementoINE IsNot Nothing Then - INETipoProceso = Vta.ComplementoINE.INETipoProceso - INETipoComite = Vta.ComplementoINE.INETipoComite - INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad - End If - params.Add(New CrystalParametro("INETipoProceso", INETipoProceso)) - params.Add(New CrystalParametro("INETipoComite", INETipoComite)) - params.Add(New CrystalParametro("INEIdContabilidad", INEIdContabilidad)) - params.Add(New CrystalParametro("Referencia", Vta.Cliente.ReferenciaFiscal)) - params.Add(New CrystalParametro("ClienteContacto", Vta.AtnA)) - End If - - 'DIRECCION ENVIO - If Vta.EnviarA.CveDireccionEnvio > 0 Then - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", Vta.EnviarA.EnvioDireccion) - If Vta.EnviarA.EnvioNoExt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.EnviarA.EnvioNoExt) - If Vta.EnviarA.EnvioNoInt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.EnviarA.EnvioNoInt) - - params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New CrystalParametro("EnvioNoExt", Vta.EnviarA.EnvioNoExt)) - params.Add(New CrystalParametro("EnvioNoInt", Vta.EnviarA.EnvioNoInt)) - params.Add(New CrystalParametro("EnvioColonia", Vta.EnviarA.EnvioColonia)) - params.Add(New CrystalParametro("EnvioCiudad", Vta.EnviarA.EnvioCiudad)) - params.Add(New CrystalParametro("EnvioEstado", Vta.EnviarA.EnvioEstado)) - params.Add(New CrystalParametro("EnvioContacto", Vta.EnviarA.EnvioContacto)) - params.Add(New CrystalParametro("EnvioDepartamento", Vta.EnviarA.EnvioDepartamento)) - params.Add(New CrystalParametro("EnvioCP", Vta.EnviarA.EnvioCP)) - Else - If Vta.CveClienteSucursal.ToEntero > 0 Then - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) - If Vta.ClienteSucursal.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) - If Vta.ClienteSucursal.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) - params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New CrystalParametro("EnvioColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) - params.Add(New CrystalParametro("EnvioCiudad", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) - params.Add(New CrystalParametro("EnvioEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) - params.Add(New CrystalParametro("EnvioCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) - Else - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, "")) - If Vta.Cliente.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) - If Vta.Cliente.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) - params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New CrystalParametro("EnvioColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) - params.Add(New CrystalParametro("EnvioCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) - params.Add(New CrystalParametro("EnvioEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) - params.Add(New CrystalParametro("EnvioCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) - End If - - End If - - 'CLIENTE SUCURSAL - If Vta.CveClienteSucursal.ToEntero > 0 Then - params.Add(New CrystalParametro("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) - params.Add(New CrystalParametro("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) - params.Add(New CrystalParametro("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) - params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) - params.Add(New CrystalParametro("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) - params.Add(New CrystalParametro("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) - params.Add(New CrystalParametro("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) - params.Add(New CrystalParametro("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) - params.Add(New CrystalParametro("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) - Else - params.Add(New CrystalParametro("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) - params.Add(New CrystalParametro("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) - params.Add(New CrystalParametro("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) - params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) - params.Add(New CrystalParametro("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) - params.Add(New CrystalParametro("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) - params.Add(New CrystalParametro("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) - params.Add(New CrystalParametro("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) - params.Add(New CrystalParametro("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) - End If - End If - - RutaFormato = String.Format("{0}Formatos\{1}.mrt", UsuarioActual.Empresa.Ruta, NombreArchivo) - - Case "Egs" - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - NombreArchivo = "NotaCredito" - Else - NombreArchivo = "Factura" - End If - NombreArchivoDescarga = "Nota de Crédito" - TipoDocumento = "EGRESO" - TipoDocumentoRef = String.Format(": Ref.:{0}", Vta.RefDocto) - AplicaPagare = "0" - - 'GENERAL - params.Add(New CrystalParametro("TipoDocumento", NombreArchivoDescarga)) - params.Add(New CrystalParametro("Tipo", TipoDocumento)) - params.Add(New CrystalParametro("Ref", TipoDocumentoRef)) - params.Add(New CrystalParametro("AplicaPagare", AplicaPagare)) - params.Add(New CrystalParametro("Fecha", String.Format("{0}T{1}", Vta.Fecha.ToString("yyyy-MM-dd"), Vta.Fecha.ToString("HH:mm:ss")))) - - 'ALAN YEPIZ - If UsuarioActual.CveEmpresa.Contiene(123) Then - params.Add(New CrystalParametro("DiaExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Day))) - params.Add(New CrystalParametro("MesExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Month))) - params.Add(New CrystalParametro("AñoExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Year))) - End If - - 'COMPU, DN DIFUSA - If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then - params.Add(New CrystalParametro("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) - params.Add(New CrystalParametro("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) - params.Add(New CrystalParametro("PedidoContrato", Vta.PedidoContrato)) - - params.Add(New CrystalParametro("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) - params.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New CrystalParametro("FechaImpresion", Now.ToDateTime.ToString)) - params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) - - 'CLIENTE SUCURSAL - If Vta.CveClienteSucursal.ToEntero > 0 Then - params.Add(New CrystalParametro("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) - params.Add(New CrystalParametro("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) - params.Add(New CrystalParametro("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) - params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) - params.Add(New CrystalParametro("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) - params.Add(New CrystalParametro("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) - params.Add(New CrystalParametro("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) - params.Add(New CrystalParametro("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) - params.Add(New CrystalParametro("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) - Else - params.Add(New CrystalParametro("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) - params.Add(New CrystalParametro("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) - params.Add(New CrystalParametro("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) - params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) - params.Add(New CrystalParametro("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) - params.Add(New CrystalParametro("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) - params.Add(New CrystalParametro("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) - params.Add(New CrystalParametro("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) - params.Add(New CrystalParametro("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) - End If - End If - - - RutaFormato = String.Format("{0}Formatos\{1}.mrt", UsuarioActual.Empresa.Ruta, "Factura") - Case Else - NombreArchivo = "" - TipoDocumento = "" - End Select - If NombreArchivo = "" Then - GuardaLog("No se especifico el tipo de Impresion de venta (Venta, Remision, Cotización, Nota de Crédito).") - Exit Sub - End If - 'TERMINA REGION PARAMETROS - - Dim lrds As New List(Of ReportDataSource) - 'Si es ECLIPSE CREAR COLUMAS PARA FIRMAS EN DtDetalle. - If UsuarioActual.CveEmpresa.Contiene(1, 15, 17, 71, 76, 125) Then - Dim DtDetalleFirmas As New DataTable - DtDetalleFirmas.TableName = "DetalleFirma" - DtDetalleFirmas = Vta.DtDetalle.Copy() - - 'SI NO TIENE LAS COLUMNAS DE FIRMAS LAS CREA. - If Not DtDetalleFirmas.Columns.Contains("Titulo") Then - DtDetalleFirmas.Columns.Add("Titulo", GetType(String)) - DtDetalleFirmas.Columns.Add("Nombre", GetType(String)) - DtDetalleFirmas.Columns.Add("Puesto", GetType(String)) - DtDetalleFirmas.Columns.Add("Lado", GetType(Integer)) - End If - - 'Se llenan los Rows de las columnas con los datos del DtFirmas - For i As Integer = 0 To Vta.DtFirmas.Rows.Count - 1 - 'Si DtDetalle es menor al DtFirmas, crea un nuevo Row en DtDetalle y le asigna valor, Si no solo asigna valor - If DtDetalleFirmas.Rows.Count < i + 1 Then - Dim Dr = DtDetalleFirmas.NewRow - Dr("Titulo") = Vta.DtFirmas(i)("Titulo").ToString - Dr("Nombre") = Vta.DtFirmas(i)("Nombre").ToString - Dr("Puesto") = Vta.DtFirmas(i)("Puesto").ToString - Dr("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero - DtDetalleFirmas.Rows.Add(Dr) - Else - DtDetalleFirmas(i)("Titulo") = Vta.DtFirmas(i)("Titulo").ToString - DtDetalleFirmas(i)("Nombre") = Vta.DtFirmas(i)("Nombre").ToString - DtDetalleFirmas(i)("Puesto") = Vta.DtFirmas(i)("Puesto").ToString - DtDetalleFirmas(i)("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero - End If - Next i - - Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = DtDetalleFirmas} - lrds.Add(rds) - Else - Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = Vta.DtDetalle} - lrds.Add(rds) - End If - - Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(Vta.DtDeduccion IsNot Nothing, Vta.DtDeduccion, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds1) - - 'DETALLE FIRMAS - - Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(Vta.DtFirmas IsNot Nothing, Vta.DtFirmas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds2) - - Dim Archivo As New System.IO.FileInfo(RutaFormato) - - Dim DataSet As New DataSet - Vta.DtDetalle.TableName = "Datos" - Vta.DtDeduccion.TableName = "Deduccion" - DataSet.Tables.Add(Vta.DtDetalle.Copy) - DataSet.Tables.Add(Vta.DtDeduccion.Copy) - - If Archivo.Exists Then - - - ImprimirbytesPDF(ImprimirPDFPyME(RutaFormato, DataSet, params, NombreArchivo, "PDF", MR:=Nothing), "Factura") - Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) - If Not ArchivoPDF.Exists Then - Try - DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) - DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - Else - Try - ArchivoPDF.Delete() - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - End If - Else - params.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) - params.Add(New CrystalParametro("RFC", UsuarioActual.Empresa.RFC)) - ImprimirbytesPDF(ImprimirPDFPyME(RutaFormato, DataSet, params, NombreArchivo, "PDF", MR:=Nothing), "Factura") - End If - - - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) - End Try - End Sub - Protected Function PdfFactura(ByRef Vta As Modelos.Factura, Optional AplicaPagare As String = "0", Optional Guardar As Boolean = True) As Byte() - Dim retorno As Byte() = Nothing - - ' Dim ObjVentas As New ClsVentas - - 'DATOS GENERALES - Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" - Dim PathXML As String = $"{Ruta}XML\{Vta.TipoDocto}\{Vta.SerieFolio}.xml" - Dim NombreArchivo As String = "" - Dim NombreArchivoDescarga As String = "" - Dim TipoDocumento As String = "" - Dim TipoDocumentoRef As String = "" - - - Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) - Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) - - Dim ImagenPath = String.Format("{0}Formatos\Suc{1}\logo.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - Dim Logo As New System.IO.FileInfo(ImagenPath) - Dim ImgLogo = New Uri(String.Format("{0}Empresas/{1}/Formatos/Suc{2}.png", UrlSitio, UsuarioActual.CveEmpresa, Vta.CveSucursal)).AbsoluteUri - - Dim SBDomicilioSucursal As New StringBuilder() - Dim CiudadSucursal As String = String.Format("{0},{1}", Vta.SubProyecto.Municipio, Vta.SubProyecto.Estado) - Dim DomicilioSucursal As String = "" - - SBDomicilioSucursal.AppendFormat("{0}", Vta.SubProyecto.Calle) - If Vta.SubProyecto.NoExt.Length > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", Vta.SubProyecto.NoExt) - If Vta.SubProyecto.NoInt.Length > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", Vta.SubProyecto.NoInt) - If Vta.SubProyecto.Colonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", Vta.SubProyecto.Colonia) - If Vta.SubProyecto.CP.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", Vta.SubProyecto.CP) - If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) + If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then + RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro") + ViewState("strToastMsglargonoreplace") = Nothing + End If + + End Sub + Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object) + 'If Request.Form("__VIEWSTATE_KEY") IsNot Nothing Then Cache.Remove(Request.Form("__VIEWSTATE_KEY")) 'elimino la cachado anteriormente + Dim VSKey As String = String.Format("VIEWSTATE_{0}_{1}_{2}", Session.SessionID, Request.Path, Date.Now.Ticks) + 'Cache.Add(VSKey, pviewState, Nothing, Date.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, Nothing) 'Store the ViewState on Cache + Session.Add(VSKey, pviewState) 'Store the ViewState on Cache + ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", VSKey) + + End Sub + Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object + + Dim VSKey As String = Request.Form("__VIEWSTATE_KEY") + If Not VSKey.StartsWith("VIEWSTATE_") Then 'Request the Key from the page and validade it. + Throw New Exception(String.Format("Invalid VIEWSTATE Key: {0}", VSKey)) + End If + If Session(VSKey) Is Nothing Then 'si por algún motivo, el caché expiró, le dice a la página que se recargue y obtenga los datos de nuevo, y así evitar errores al obtener el viewstate vacío + Response.Redirect(Request.RawUrl) + Return Nothing + Else + Return Session(VSKey) + End If + + End Function + Public Shared Sub CargaParametros(Parametros As String) + Dim P1() As String = Parametros.Split("&"c) + Dim Tmp As String + Dim P2() As String + + UrlParametros = New Hashtable + + For Each Tmp In P1 + P2 = Tmp.Split("="c) + UrlParametros.Add(P2(0).ToString.ToUpper(), P2(1)) + Next + + End Sub + Shared Sub RegeneraImagen(ByVal Ruta As String) + + Dim BM As New Drawing.Bitmap(Ruta) + Dim Width As Integer = BM.Width + Dim Height As Integer = BM.Height + Dim Thumb As New Drawing.Bitmap(Width, Height) + Dim G As Drawing.Graphics = Drawing.Graphics.FromImage(Thumb) + + + G.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic + G.DrawImage(BM, New Drawing.Rectangle(0, 0, Width, Height), New Drawing.Rectangle(0, 0, BM.Width, BM.Height), Drawing.GraphicsUnit.Pixel) + + BM.Dispose() + G.Dispose() + + 'image path. + Thumb.Save(Ruta, Drawing.Imaging.ImageFormat.Jpeg) 'can use any image format + Thumb.Dispose() + End Sub + Public Sub RegistraScript(Script As String, Optional valuetick As String = "") + Dim Rdm As Random = New Random() + ScriptManager.RegisterStartupScript(Page, Me.GetType(), String.Format("{0}{1}{2}", (DateTime.Now.Ticks + 1), Rdm.Next(), valuetick), String.Format("", Script), False) + End Sub + Public Sub TabEnabled(Tab As System.Web.UI.HtmlControls.HtmlAnchor, Valor As Boolean) + If Valor Then + 'RegistraScript(String.Format("$( ""#{0}"" ).removeClass( ""linkdesactive"" );", tab.ClientID)) + Try + Tab.Attributes("class") = Tab.Attributes("class").Replace("linkdesactive", "") + Catch ex As Exception + Tab.Attributes("class") = "" + End Try + Else + Tab.Attributes.Add("class", "linkdesactive") + End If + End Sub + Public Sub TabActive(Tab As System.Web.UI.HtmlControls.HtmlAnchor) + RegistraScript(String.Format("$( ""#{0}"" ).Click( );", Tab.ClientID)) + End Sub + ''' + ''' + ''' + Public Sub Alerta(Mensaje As String, Tipo As String, Funcion As String) + RegistraScript(String.Format("bootbox.alert('{0}', function() {{{2}}} );", Mensaje, Tipo, Funcion)) + End Sub + Public Sub NotificacionesPendientes(Nota As String) + 'incremento el contador de alertas + Dim Type = Master.GetType + Dim Prop = Type.GetProperty("countNotificaciones") + Prop.SetValue(Master, 1 + CInt(Prop.GetValue(Master))) + 'end incremento contador de alertas + + Dim ltl = DirectCast(Master.FindControl("LtlMNotificaciones"), Literal) + + ltl.Text = String.Format(" {0} {1}", ltl.Text, Nota) + End Sub + Public Sub Confirmacion(Mensaje As String, Tipo As String, FuncionOK As String, FuncionCancel As String) + RegistraScript(String.Format("bootbox.confirm('{0}', function(result) {{if (result){{ {2} }}else{{ {3} }} }}); ", Mensaje, Tipo, FuncionOK, FuncionCancel)) + End Sub + Public Function AddBitacoraUsuario(CveModulo As Integer, Accion As String, Resultado As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + Dim ObjUsuario As New ClsSisUsuarios + Retorno = ObjUsuario.AddBitacora(CveModulo, Accion, Resultado, CveUsuario, CveEmpresa) + ObjUsuario.Dispose() + Return Retorno + End Function + +#Region " IMPRIMIR PDF " + ''' + ''' Genera documento PDF o Excel + ''' + ''' Directorio donde se ubica el archivo + ''' Datatable + ''' Listado de parametros para el reporte + ''' Opcional Nombre del archivo que se descarga + ''' Optional, Formato de Generacion PDF o Excel + ''' + Public Sub ImprimirPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource + rds.Name = RDSName + rds.Value = DtDatos + lrds.Add(rds) + ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) + End Sub + Public Sub ImprimirPDFMultiDS(RutaReporte As String, lrds As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) + ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) + End Sub + + ''' + ''' Genera documento PDF o Excel + ''' + ''' Directorio donde se ubica el archivo + ''' Contenedor de Datatables + ''' Listado de parametros para el reporte + ''' Opcional Nombre del archivo que se descarga + ''' Optional, Formato de Generacion PDF o Excel + ''' + Public Sub ImprimirPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) + 'limpio ReportViwer + ImprimirbytesPDF(StreamPDF(RutaReporte, DataSource, Parametros, NombreArchivo, Formato, MR), NombreArchivo, Formato) + End Sub + Public Function StreamPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) As Byte() + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource + rds.Name = RDSName + rds.Value = DtDatos + lrds.Add(rds) + Return StreamPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) + End Function + Public Function StreamPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) As Byte() + 'limpio ReportViwer + Dim sw As New System.Diagnostics.Stopwatch() + sw.Start() + + If IsNothing(MR) Then MR = New ReportViewer + Dim Bytes As Byte() = Nothing + Try + ' MasterReporteador.LocalReport.DataSources.Clear() + For Each RDS As ReportDataSource In DataSource + MR.LocalReport.DataSources.Add(RDS) + Next + + MR.LocalReport.ReportPath = RutaReporte + MR.ProcessingMode = ProcessingMode.Local + MR.LocalReport.EnableExternalImages = True + MR.LocalReport.SetParameters(Parametros) + MR.LocalReport.Refresh() + Dim Warnings As Warning() = Nothing + Dim StreamIds As String() = Nothing + Dim MimeType As String = Nothing + Dim Encoding As String = Nothing + Dim Extension As String = Nothing + Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings) + Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException + GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + Catch ex As Exception + GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + End Try + + sw.Stop() + If sw.Elapsed.TotalSeconds > 10 Then + GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") + End If + + Return Bytes + End Function + Public Function ImprimirPDFCrystal(RutaReporte As String, DataSource As DataTable, Parametros As List(Of CrystalParametro), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportDocument = Nothing) As Byte() + 'limpio ReportViwer + Dim sw As New System.Diagnostics.Stopwatch() + sw.Start() + If IsNothing(MR) Then MR = New ReportDocument() + Dim Bytes As Byte() = Nothing + Dim formatType As ExportFormatType = ExportFormatType.NoFormat + Try + MR.Load(RutaReporte) + MR.SetDataSource(DataSource) + + For Each item As CrystalParametro In Parametros + MR.SetParameterValue(item.Nombre, item.Valor) + Next + + Select Case Formato + Case "PDF" + formatType = ExportFormatType.PortableDocFormat + 'Format = "Application/pdf" + Case "EXCEL" + formatType = ExportFormatType.Excel + 'Format = "application/ms-excel" + End Select + Dim Stream As IO.Stream = MR.ExportToStream(formatType) + Dim BD As New BinaryReader(MR.ExportToStream(formatType)) + Bytes = BD.ReadBytes(CInt(MR.ExportToStream(formatType).Length)) + BD.Dispose() + Stream.Dispose() + 'Dim Buffer(CInt(Stream.Length)) As Byte + 'Bytes = Buffer + 'MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo) + Catch ex As CrystalReportsException + GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, + $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, + ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + Catch ex As Exception + GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, + $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, + ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) + + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + End Try + sw.Stop() + If sw.Elapsed.TotalSeconds > 10 Then + GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") + End If + If MR IsNot Nothing Then MR.Dispose() + Return Bytes + End Function + + Public Function ImprimirSubRepPDFCrystal(RutaReporte As String, DataSource As DataTable, Parametros As List(Of CrystalParametro), DataSource1 As DataTable, DataSource2 As DataTable, SubRep1 As String, SubRep2 As String, Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportDocument = Nothing) As Byte() + 'limpio ReportViwer + Dim sw As New System.Diagnostics.Stopwatch() + + sw.Start() + If IsNothing(MR) Then MR = New ReportDocument() + + Dim SR1 As New ReportDocument + Dim SR2 As New ReportDocument + + Dim Bytes As Byte() = Nothing + Dim formatType As ExportFormatType = ExportFormatType.NoFormat + Try + + MR.Load(RutaReporte) + + SR1 = MR.OpenSubreport(SubRep1) + SR2 = MR.OpenSubreport(SubRep2) + + MR.SetDataSource(DataSource) + + SR1.SetDataSource(DataSource1) + SR2.SetDataSource(DataSource2) + + For Each item As CrystalParametro In Parametros + MR.SetParameterValue(item.Nombre, item.Valor) + Next + + Select Case Formato + Case "PDF" + formatType = ExportFormatType.PortableDocFormat + 'Format = "Application/pdf" + Case "EXCEL" + formatType = ExportFormatType.Excel + 'Format = "application/ms-excel" + End Select + Dim Stream As IO.Stream = MR.ExportToStream(formatType) + Dim BD As New BinaryReader(MR.ExportToStream(formatType)) + Bytes = BD.ReadBytes(CInt(MR.ExportToStream(formatType).Length)) + BD.Dispose() + Stream.Dispose() + 'Dim Buffer(CInt(Stream.Length)) As Byte + 'Bytes = Buffer + 'MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo) + Catch ex As CrystalReportsException + GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, + $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, + ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + Catch ex As Exception + GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing, + $"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, + ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}")) + + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + End Try + sw.Stop() + If sw.Elapsed.TotalSeconds > 10 Then + GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") + End If + If MR IsNot Nothing Then MR.Dispose() + Return Bytes + End Function + + Public Function ImprimirPDFPyME(RutaReporte As String, DataSource As DataSet, Parametros As List(Of CrystalParametro), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As StiReport = Nothing) As Byte() + + If IsNothing(MR) Then MR = New StiReport() + Dim Bytes As Byte() = Nothing + Try + MR.Load(RutaReporte) + MR.Dictionary.DataSources.Clear() + MR.RegData(DataSource) + Dim Lista = MR.Dictionary.Variables.ToList() + For Each item As CrystalParametro In Parametros + If Lista.Exists(Function(a) a.Name = item.Nombre) Then + MR.Dictionary.Variables(item.Nombre).Value = item.Valor.ToString + End If + Next + + MR.Dictionary.Synchronize() + MR.IsRendered = False + MR.Render(False) + Dim pdfSettings As New StiPdfExportSettings() + Dim MemoryStream As New MemoryStream + Select Case Formato + Case "PDF" + MR.ExportDocument(StiExportFormat.Pdf, MemoryStream, pdfSettings) + Case "EXCEL" + MR.ExportDocument(StiExportFormat.Excel2007, MemoryStream, pdfSettings) + End Select + Bytes = MemoryStream.ToArray + Catch ex As Exception + GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + End Try + Return Bytes + End Function + + Public Function StreamPDFTest(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) As Byte() + 'limpio ReportViwer + + Dim sw As New System.Diagnostics.Stopwatch() + sw.Start() + + If IsNothing(MR) Then MR = New ReportViewer + Dim Bytes As Byte() = Nothing + Try + + ' MR.LocalReport.ReportPath = RutaReporte + MR.ProcessingMode = ProcessingMode.Local + + Using rdlcR As New StreamReader(RutaReporte) + MR.LocalReport.LoadReportDefinition(rdlcR) + MR.LocalReport.EnableExternalImages = True + MR.LocalReport.SetParameters(Parametros) + MR.LocalReport.Refresh() + End Using + + For Each RDS As ReportDataSource In DataSource + MR.LocalReport.DataSources.Add(RDS) + Next + + Dim Warnings As Warning() = Nothing + Dim StreamIds As String() = Nothing + Dim MimeType As String = Nothing + Dim Encoding As String = Nothing + Dim Extension As String = Nothing + + Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings) + Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException + GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + Catch ex As Exception + GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + End Try + + sw.Stop() + If sw.Elapsed.TotalSeconds > 10 Then + GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") + 'GuardaLog($"Tiempo Renderizado Milisegundos {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") + End If + + Return Bytes + End Function + + + ''' + ''' Genera documento PDF o Excel + ''' + ''' + ''' + ''' + ''' + Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False) + 'limpio ReportViwer + Dim mimeType As String = Nothing + Dim extension As String = Nothing + + 'If Descarga Then + ' Try + ' bytes = bytes + ' File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img) + ' Catch ex As Exception + ' If UsuarioActual.CveRol = 1 Then + ' Alert(ex.Message, TipoMensaje.MsgAdvertencia) + ' Else + ' Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia) + ' End If + ' End Try + 'End If + + Try + bytes = bytes + Response.Buffer = True + Response.Clear() + Response.ContentType = mimeType + Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.{1}", NombreArchivo, If(Formato = "PDF", "pdf", "xls"))) + Response.BinaryWrite(bytes) ' create the file + Response.Flush() ' send it to the client to download + HttpContext.Current.Response.SuppressContent = True + HttpContext.Current.ApplicationInstance.CompleteRequest() + HttpContext.Current.Response.End() + + Catch ex As Exception + + If UsuarioActual.CveRol = 1 Then + Alert($"Error: {ex.Message} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))}", TipoMensaje.MsgAdvertencia) + Else + Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod:'IMPDFclspag'", TipoMensaje.MsgAdvertencia) + End If + End Try + End Sub + Public Sub ImprimirPDFview(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource + rds.Name = RDSName + rds.Value = DtDatos + lrds.Add(rds) + ImprimirPDFview(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) + End Sub + Public Sub ImprimirPDFview(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) + 'limpio ReportViwer + If IsNothing(MR) Then + MR = New ReportViewer + End If + ' MasterReporteador.LocalReport.DataSources.Clear() + For Each rds As ReportDataSource In DataSource + MR.LocalReport.DataSources.Add(rds) + Next + MR.LocalReport.ReportPath = RutaReporte + MR.ProcessingMode = ProcessingMode.Local + MR.LocalReport.EnableExternalImages = True + MR.LocalReport.SetParameters(Parametros) + MR.LocalReport.Refresh() + + End Sub +#End Region + +#Region "IMPRIMIR FACTURA" + Public Sub PdfFacturaPyME(ByRef Vta As Modelos.Factura, DT As DataTable) + Dim retorno As Byte() = Nothing + + 'DATOS GENERALES + Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" + Dim PathXML As String = $"{Ruta}XML\{Vta.TipoDocto}\{Vta.SerieFolio}.xml" + Dim NombreArchivo As String = "" + Dim NombreArchivoDescarga As String = "" + Dim TipoDocumento As String = "" + Dim TipoDocumentoRef As String = "" + Dim AplicaPagare As String = "1" + + Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) + Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) + Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) + + Dim ImagenPath = String.Format("{0}Formatos\Suc{1}\logo.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + Dim Logo As New System.IO.FileInfo(ImagenPath) + Dim ImgLogo = New Uri(String.Format("{0}Empresas/{1}/Formatos/Suc{2}.png", UrlSitio, UsuarioActual.CveEmpresa, Vta.CveSucursal)).AbsoluteUri + + Dim SBDomicilioSucursal As New StringBuilder() + Dim CiudadSucursal As String = String.Format("{0},{1}", Vta.SubProyecto.Municipio, Vta.SubProyecto.Estado) + Dim DomicilioSucursal As String = "" + + SBDomicilioSucursal.AppendFormat("{0}", Vta.SubProyecto.Calle) + If Vta.SubProyecto.NoExt.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", Vta.SubProyecto.NoExt) + If Vta.SubProyecto.NoInt.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", Vta.SubProyecto.NoInt) + If Vta.SubProyecto.Colonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", Vta.SubProyecto.Colonia) + If Vta.SubProyecto.CP.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", Vta.SubProyecto.CP) + If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) If Vta.SubProyecto.Pais.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", Vta.SubProyecto.Pais) - If Not String.IsNullOrEmpty(Vta.SubProyecto.Telefono) AndAlso UsuarioActual.CveEmpresa = 141 Then SBDomicilioSucursal.AppendFormat(", Tel: {0}", Vta.SubProyecto.Telefono) - - DomicilioSucursal = SBDomicilioSucursal.ToString - - Dim Fecha As String = Vta.Fecha.ToShortDateString - - Dim SBDireccion As New StringBuilder() - Dim SBLugar As New StringBuilder() - Dim ClienteDireccion As String - Dim ClienteLugar As String - Vta.FolioFiscal = "Sin Timbrar" - Vta.NoSerieCertificado = "Sin Timbrar" - Vta.SelloCFDi = "Sin Timbrar" - Vta.SelloSAT = "Sin Timbrar" - - 'SI ESTA TIMBRADA - CON XML - If File.Exists(PathXML) AndAlso Vta.Serie <> "VistaPrevia" Then 'Cuando es vista previe y coincide la serie y folio se ponen los datos fiscales - Dim XmlDoc As New System.Xml.XmlDocument - - Dim EsXMLValido = False - Try - XmlDoc.Load(PathXML) - EsXMLValido = True - Catch ex As Exception - GuardaLog(" --- *** Impresion ventas - ClsPaginas LN#5016 (Aprox) - EXISTE EL XML PERO NO SE PUEDE LEER. *** --- ") - End Try - - If EsXMLValido Then - Dim TC As Decimal = 1 - Try - TC = XmlDoc.DocumentElement.Attributes("TipoCambio").InnerText.ToDecimal - Catch ex As Exception - TC = 1 - End Try - If ValorNodoXML(XmlDoc.DocumentElement, "version") = "3.3" Then - Vta.FechaEmision = ValorNodoXML(XmlDoc.DocumentElement, "fecha").ToDate - Vta.NoSerieCertificadoContribuyente = ValorNodoXML(XmlDoc.DocumentElement, "NoCertificado") - - Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") - - If Not IsNothing(validaElemento) Then - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText - Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate - Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText - Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText - End If - Next - - End If - Else - Vta.FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate - Vta.NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText - - Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") - - If Not IsNothing(validaElemento) Then - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText - Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate - Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText - Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText - - End If - Next - End If - - End If - End If - - - End If - - 'DIRECCION CLIENTE - If Vta.CveClienteSucursal.ToEntero > 0 Then - 'Si cliente tiene Noint, NoExt, CP - SBDireccion.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) - If Vta.ClienteSucursal.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) - If Vta.ClienteSucursal.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) - If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.ClienteSucursal.Colonia) - - If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then - If Vta.ClienteSucursal.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.ClienteSucursal.CP.Trim) - End If - - 'Si cliente tiene Local, CD, Edo, Pais - If Vta.ClienteSucursal.Localidad IsNot Nothing AndAlso Vta.ClienteSucursal.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.ClienteSucursal.Localidad) - If Vta.ClienteSucursal.Municipio IsNot Nothing AndAlso Vta.ClienteSucursal.Municipio.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.ClienteSucursal.Municipio) - If Vta.ClienteSucursal.Estado IsNot Nothing AndAlso Vta.ClienteSucursal.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.ClienteSucursal.Estado) - If Vta.ClienteSucursal.Pais IsNot Nothing AndAlso Vta.ClienteSucursal.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.ClienteSucursal.Pais) - ElseIf Vta.CveCliente.ToEntero > 0 Then - SBDireccion.AppendFormat("{0}", Vta.Cliente.Direccion) - If Vta.Cliente.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) - If Vta.Cliente.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) - If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.Cliente.Colonia) - - If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then - If Vta.Cliente.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.Cliente.CP.Trim) - End If - - 'Si cliente tiene Local, CD, Edo, Pais - If Vta.Cliente.Localidad IsNot Nothing AndAlso Vta.Cliente.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.Cliente.Localidad) - If Vta.Cliente.Ciudad IsNot Nothing AndAlso Vta.Cliente.Ciudad.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.Cliente.Ciudad) - If Vta.Cliente.Estado IsNot Nothing AndAlso Vta.Cliente.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.Cliente.Estado) - If Vta.Cliente.Pais IsNot Nothing AndAlso Vta.Cliente.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.Cliente.Pais) - - End If - - ClienteDireccion = SBDireccion.ToString - ClienteLugar = SBLugar.ToString - SBDireccion.Clear() - SBLugar.Clear() - - 'LOGO - Dim LogoRuta As String = "" - 'POR SUCURSAL - LogoRuta = String.Format("{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - If File.Exists(LogoRuta) Then - LogoRuta = String.Format("file://{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) - 'POR EMPRESA - Else - LogoRuta = String.Format("{0}Formatos\Logo.png", UsuarioActual.Empresa.Ruta) - If File.Exists(LogoRuta) Then - LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - End If - End If - - 'Si no tiene CBB, SE GENERA - If Not ImagenCBB.Exists AndAlso Vta.CveCliente.ToEntero > 0 Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) - End If - ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) - - 'Dim CadenaOriginals As String = "||1.0|" + Vta.FolioFiscal + "|" + Vta.FechaCertificacion.ToString("yyyy-MM-dd") + "T" + Vta.FechaCertificacion.ToString("HH:mm:ss") + "|" + Vta.SelloCFDi + "|" + Vta.NoSerieCertificado + "||" - Dim CadenaOriginals As String = String.Format("||{0}|{1}|{2}T{3}|{4}|{5}||", If(Vta.Version = "3.3", "1.1", "1.0"), Vta.FolioFiscal, Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss"), Vta.SelloCFDi, Vta.NoSerieCertificado) - If Not ImagenCBB.Exists Then ImgCBB = "" - Dim RutaFormato As String = "" - Dim RutaFormatoDefault As String = "" - - 'AQUI EMPIEZA LOS PARAMETROS - Try - Dim params As New List(Of ReportParameter) - - - 'CLIENTE - If Vta.CveCliente.ToEntero > 0 Then - params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) - params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) - params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) - End If - - 'TOTALES - params.Add(New ReportParameter("SubTotal", Vta.SubTotal.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("Descuento", Vta.Descuento.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("Amortizacion", Vta.Amortizacion.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("SubTotal2", (Vta.SubTotal - Vta.Descuento - Vta.Amortizacion).ToString.FormatoNumero(2))) - params.Add(New ReportParameter("IVA", Vta.IVA.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("RetIVA", Vta.RetIVA.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("RetISR", Vta.RetISR.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("Total", Vta.Total.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("ImporteLetra", Vta.Total.ToString.ToDouble.Texto2Letras(Vta.CveMoneda))) - - 'DATOS GENERALES - - - - 'params.Add(New ReportParameter("CP", UsuarioActual.Empresa.CP.ToString)) - params.Add(New ReportParameter("Observaciones", Vta.Observaciones)) - params.Add(New ReportParameter("CveVendedor", Vta.CveVendedor.ToString)) - params.Add(New ReportParameter("Status", Vta.EstatusFactura)) - params.Add(New ReportParameter("FechaSolicitud", Vta.Fecha.ToString("dd/MMMM/yyyy"))) ' se puede omitir - params.Add(New ReportParameter("Serie", Vta.Serie)) - params.Add(New ReportParameter("Folio", Vta.Folio.ToString)) - params.Add(New ReportParameter("DomicilioSucursal", DomicilioSucursal)) - params.Add(New ReportParameter("Vencimiento", Vta.FechaVencimiento.ToString("dd/MM/yyyy"))) - params.Add(New ReportParameter("FolioFiscal", Vta.FolioFiscal)) - params.Add(New ReportParameter("FechaCertificacion", String.Format("{0}T{1}", Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss")))) - params.Add(New ReportParameter("SelloCFDI", Vta.SelloCFDi)) - params.Add(New ReportParameter("CadenaSAT", CadenaOriginals)) - params.Add(New ReportParameter("SelloSAT", Vta.SelloSAT)) - - params.Add(New ReportParameter("QR", ImgCBB)) - params.Add(New ReportParameter("Moneda", Vta.Moneda)) - params.Add(New ReportParameter("TipoCambio", Vta.TipoCambio.ToString)) - params.Add(New ReportParameter("CondicionPago", Vta.CondicionesPagoText)) - params.Add(New ReportParameter("CadenaOriginal", CadenaOriginals)) - params.Add(New ReportParameter("SerieCertificadoSAT", Vta.NoSerieCertificado)) - params.Add(New ReportParameter("CertificadoContribuyente", Vta.NoSerieCertificadoContribuyente)) - params.Add(New ReportParameter("NumCta", Vta.NumeroCuenta)) - params.Add(New ReportParameter("LogoPath", LogoRuta)) - params.Add(New ReportParameter("CiudadSucursal", CiudadSucursal)) - params.Add(New ReportParameter("OC", Vta.Det_OrdenCompra.ToString)) - params.Add(New ReportParameter("ClienteDiasCredito", "0")) - params.Add(New ReportParameter("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) - params.Add(New ReportParameter("Sucursal", Vta.SubProyecto.SubProyecto)) - params.Add(New ReportParameter("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) - params.Add(New ReportParameter("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) - params.Add(New ReportParameter("PedidoContrato", Vta.PedidoContrato)) - params.Add(New ReportParameter("OrdenCompra", Vta.OrdenCompra)) - params.Add(New ReportParameter("DescripcionContrato", Vta.NumeroDescripcionContrato)) - params.Add(New ReportParameter("Contrato", Vta.NumeroContrato)) - params.Add(New ReportParameter("Fecha", String.Format("{0}T{1}", Vta.Fecha.ToString("yyyy-MM-dd"), Vta.Fecha.ToString("HH:mm:ss")))) - - 'VENDEDOR - Dim VendedorNombre As String = "" - Dim VendedorMail As String = "" - Dim VendedorTelefono As String = "" - Dim VendedorCelular As String = "" - Dim RowVendedor As DataRow = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveVendedor = {0}", Vta.CveVendedor.ToString)) - If Not IsNothing(RowVendedor) Then - VendedorNombre = RowVendedor("Vendedor").ToString - VendedorMail = RowVendedor("Correo").ToString - VendedorTelefono = RowVendedor("Telefono").ToString - VendedorCelular = RowVendedor("Celular").ToString - End If - params.Add(New ReportParameter("VendedorNombre", VendedorNombre)) - params.Add(New ReportParameter("VendedorMail", VendedorMail)) - params.Add(New ReportParameter("VendedorTelefono", VendedorTelefono)) - params.Add(New ReportParameter("VendedorCelular", VendedorCelular)) - - If UsuarioActual.Empresa.Funcionalidad(508) = "1" Then - params.Add(New ReportParameter("IEPS", Vta.IEPS.ToString.FormatoNumero(2))) - End If - - If Vta.CveClienteSucursal > 0 Then - params.Add(New ReportParameter("ClienteContactoMail", Vta.ClienteSucursal.CorreoSucursal)) - params.Add(New ReportParameter("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) - ElseIf Vta.CveCliente.ToEntero > 0 Then - params.Add(New ReportParameter("ClienteContactoMail", Vta.Cliente.MailCotizacion)) - params.Add(New ReportParameter("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) - End If - - If UsuarioActual.CveEmpresa.Contiene(17) Then - params.Add(New ReportParameter("MetodoPago", Vta.ClaveMetodoPagoSAT.ToString)) - End If - - If Vta.Version = "3.3" Then - params.Add(New ReportParameter("FormaPago", Vta.FormaPago33.ToString)) - params.Add(New ReportParameter("MetodoPago", Vta.MetodoPago33.ToString)) - params.Add(New ReportParameter("UsoCFDI", Vta.UsoCFDI)) - If Vta.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then - params.Add(New ReportParameter("TipoRelacionTexto", If(Vta.Timbre.CFDIRelacionados.TipoRelacionTexto Is Nothing, "", Vta.Timbre.CFDIRelacionados.TipoRelacionTexto))) - params.Add(New ReportParameter("FolioFiscalRelacionado", If(Vta.Timbre.CFDIRelacionados.UUID.Count = 0, "", Vta.Timbre.CFDIRelacionados.UUID.Item(0)))) - End If - Else - params.Add(New ReportParameter("FormaPago", Vta.FormaPagoText)) - params.Add(New ReportParameter("MetodoPago", Vta.MetodoPago.ToString)) - End If - - 'DIRECCION ENVIO - If Vta.EnviarA IsNot Nothing AndAlso Vta.EnviarA.CveDireccionEnvio > 0 Then - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", Vta.EnviarA.EnvioDireccion) - If Vta.EnviarA.EnvioNoExt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.EnviarA.EnvioNoExt) - If Vta.EnviarA.EnvioNoInt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.EnviarA.EnvioNoInt) - - params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New ReportParameter("EnvioNoExt", Vta.EnviarA.EnvioNoExt)) - params.Add(New ReportParameter("EnvioNoInt", Vta.EnviarA.EnvioNoInt)) - params.Add(New ReportParameter("EnvioColonia", Vta.EnviarA.EnvioColonia)) - params.Add(New ReportParameter("EnvioCiudad", Vta.EnviarA.EnvioCiudad)) - params.Add(New ReportParameter("EnvioEstado", Vta.EnviarA.EnvioEstado)) - params.Add(New ReportParameter("EnvioContacto", Vta.EnviarA.EnvioContacto)) - params.Add(New ReportParameter("EnvioDepartamento", Vta.EnviarA.EnvioDepartamento)) - params.Add(New ReportParameter("EnvioCP", Vta.EnviarA.EnvioCP)) - If Vta.CveEmpresa = 72 Then - params.Add(New ReportParameter("EnvioTel", Vta.EnviarA.EnvioTel)) - End If - ElseIf Vta.CveCliente.ToEntero > 0 Then - If Vta.CveClienteSucursal.ToEntero > 0 Then - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) - If Vta.ClienteSucursal.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) - If Vta.ClienteSucursal.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) - params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New ReportParameter("EnvioNoExt", Vta.ClienteSucursal.NoExt)) - params.Add(New ReportParameter("EnvioNoInt", Vta.ClienteSucursal.NoInt)) - params.Add(New ReportParameter("EnvioColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) - params.Add(New ReportParameter("EnvioCiudad", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) - params.Add(New ReportParameter("EnvioEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) - params.Add(New ReportParameter("EnvioCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) - Else - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, "")) - If Vta.Cliente.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) - If Vta.Cliente.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) - params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New ReportParameter("EnvioNoExt", Vta.Cliente.NoExt)) - params.Add(New ReportParameter("EnvioNoInt", Vta.Cliente.NoInt)) - params.Add(New ReportParameter("EnvioColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) - params.Add(New ReportParameter("EnvioCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) - params.Add(New ReportParameter("EnvioEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) - params.Add(New ReportParameter("EnvioCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) - End If - params.Add(New ReportParameter("EnvioContacto", "")) - params.Add(New ReportParameter("EnvioDepartamento", "")) - End If - - 'CLIENTE SUCURSAL - If Vta.CveClienteSucursal.ToEntero > 0 Then - params.Add(New ReportParameter("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) - params.Add(New ReportParameter("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) - params.Add(New ReportParameter("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) - params.Add(New ReportParameter("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) - params.Add(New ReportParameter("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) - params.Add(New ReportParameter("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) - params.Add(New ReportParameter("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) - params.Add(New ReportParameter("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) - params.Add(New ReportParameter("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) - params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) - ElseIf Vta.CveCliente.ToEntero > 0 Then - params.Add(New ReportParameter("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) - params.Add(New ReportParameter("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) - params.Add(New ReportParameter("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) - params.Add(New ReportParameter("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) - params.Add(New ReportParameter("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) - params.Add(New ReportParameter("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) - params.Add(New ReportParameter("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) - params.Add(New ReportParameter("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) - params.Add(New ReportParameter("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) - params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) - End If - - 'PARAMETROS SEGUN TIPO DOCUMENTO - Select Case Vta.TipoDocto - Case "Ing" - NombreArchivo = "Factura" - NombreArchivoDescarga = "Factura" - TipoDocumento = "INGRESO" - - If UsuarioActual.CveEmpresa.Contiene(137) Then - params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) - End If - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - 'VSH - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122, 145) Then - 'DATOS CLIENTES - Dim ClienteRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Vta.CveCliente.ToString)) - Dim DatosCliente = "" - If ClienteRow IsNot Nothing Then - DatosCliente = String.Format("{0} | {1} | {2}", Vta.SubProyecto.Municipio, ClienteRow("CuentaContable"), ClienteRow("Codigo")) - End If - params.Add(New ReportParameter("ClienteDatoExtra1", DatosCliente)) - End If - - 'INE COMPLEMENTOS - If UsuarioActual.CveEmpresa.Contiene(72, 1) Then - Dim INETipoProceso As String = "" - Dim INETipoComite As String = "" - Dim INEIdContabilidad As Integer = 0 - If Vta.ComplementoINE IsNot Nothing Then - INETipoProceso = Vta.ComplementoINE.INETipoProceso - INETipoComite = Vta.ComplementoINE.INETipoComite - INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad - End If - params.Add(New ReportParameter("INETipoProceso", INETipoProceso)) - params.Add(New ReportParameter("INETipoComite", INETipoComite)) - params.Add(New ReportParameter("INEIdContabilidad", INEIdContabilidad.ToString)) - params.Add(New ReportParameter("Referencia", Vta.Cliente.ReferenciaFiscal)) - - End If - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Rem" - NombreArchivo = "Remision" - NombreArchivoDescarga = "Remisión" - TipoDocumento = "REMISION" - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - 'ALAN YEPIZ - If UsuarioActual.CveEmpresa.Contiene(123) Then - params.Add(New ReportParameter("DiaExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Day))) - params.Add(New ReportParameter("MesExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Month))) - params.Add(New ReportParameter("AñoExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Year))) - End If - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Cot" - NombreArchivo = "Cotizacion" - NombreArchivoDescarga = "Cotización" - TipoDocumento = "COTIZACIÓN" - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - params.Add(New ReportParameter("ClienteContacto", Vta.AtencionA)) - - If UsuarioActual.CveEmpresa.Contiene(137, 132, 144) Then - params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) - End If - - 'COMPU DN DIFUSA - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 137, 132, 144) Then - - Dim FirmaVendedor As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveVendedor)) - - params.Add(New ReportParameter("FirmaVendedor", If(FirmaVendedor.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", UsuarioActual.CveEmpresa, Vta.CveVendedor))).AbsoluteUri, ""))) - params.Add(New ReportParameter("Entrega", Vta.Entrega)) - params.Add(New ReportParameter("Vigencia", Vta.Vigencia.ToString("dd/MMMM/yyyy"))) - params.Add(New ReportParameter("Sucursal", Vta.SubProyecto.SubProyecto)) - params.Add(New ReportParameter("SucursalCliente", If(Vta.ClienteSucursal.Sucursal.ToString Is Nothing, "", Vta.ClienteSucursal.Sucursal.ToString))) - params.Add(New ReportParameter("CveMoneda", Vta.CveMoneda.ToString)) - params.Add(New ReportParameter("FormaEntrega", Vta.CondicionEntrega)) - - If Not IsNothing(RowVendedor) Then - params.Add(New ReportParameter("TituloVendedor", RowVendedor("TituloDocumentos").ToString)) - Else - params.Add(New ReportParameter("TituloVendedor", "")) - End If - - End If - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Egs" - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - NombreArchivo = "NotaCredito" - Else - NombreArchivo = "Factura" - End If - NombreArchivoDescarga = "Nota de Crédito" - TipoDocumento = "EGRESO" - TipoDocumentoRef = String.Format(": Ref.:{0}", Vta.RefDocto) - AplicaPagare = "0" - - If UsuarioActual.CveEmpresa.Contiene(137) Then - params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) - End If - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Ant" - NombreArchivo = "Factura" - NombreArchivoDescarga = "Anticipo" - TipoDocumento = "INGRESO" - - If UsuarioActual.CveEmpresa.Contiene(137) Then - params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) - End If - - 'GENERAL - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - 'INE COMPLEMENTOS - If UsuarioActual.CveEmpresa.Contiene(72) Then - Dim INETipoProceso As String = "" - Dim INETipoComite As String = "" - Dim INEIdContabilidad As Integer = 0 - If Vta.ComplementoINE IsNot Nothing Then - INETipoProceso = Vta.ComplementoINE.INETipoProceso - INETipoComite = Vta.ComplementoINE.INETipoComite - INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad - End If - params.Add(New ReportParameter("INETipoProceso", INETipoProceso)) - params.Add(New ReportParameter("INETipoComite", INETipoComite)) - params.Add(New ReportParameter("INEIdContabilidad", INEIdContabilidad.ToString)) - params.Add(New ReportParameter("Referencia", Vta.Cliente.ReferenciaFiscal)) - params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) - End If - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Ped" - NombreArchivo = "Pedido" - NombreArchivoDescarga = "Pedido" - TipoDocumento = "INGRESO" - - 'GENERAL - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - params.Add(New ReportParameter("CveAlmacenTraspasoOrigen", Vta.CveAlmacenTraspasoOrigen.ToString)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Pd2" - NombreArchivo = "Pedido2" - NombreArchivoDescarga = "Pedido2" - TipoDocumento = "INGRESO" - - 'GENERAL - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Dev" - NombreArchivo = "NotaDevolucion" - NombreArchivoDescarga = "NotaDevolucion" - TipoDocumento = "DEVOLUCION" - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "DPe" - NombreArchivo = "DevolucionPedido" - NombreArchivoDescarga = "DevolucionPedido" - TipoDocumento = "INGRESO" - - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "PeC" - NombreArchivo = "PedidoConsignacion" - NombreArchivoDescarga = "Pedido Consignación" - TipoDocumento = "INGRESO" - - 'GENERAL - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case "Tra" - NombreArchivo = "Traspaso" - NombreArchivoDescarga = "Traspaso" - TipoDocumento = "Traspaso" - - Dim ObjInv As New ClsInventarios - Dim AlmOrigen As String = "" - Dim AlmDestino As String = "" - - Dim SBDireccionO As New StringBuilder() - Dim SBDireccionD As New StringBuilder() - - If ObjInv.GetMovimientos(Vta.Inv_CveMovimiento.ToEntero, -1, -1, UsuarioActual.CveEmpresa) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - Dim Dr As DataRow = ObjInv.DtResultados.Rows(0) - If Dr IsNot Nothing Then - AlmOrigen = Dr("AlmacenOrigen").ToString - AlmDestino = Dr("AlmacenDestino").ToString - - If Dr("CalleOrigen").ToString.Length > 0 Then - SBDireccionO.AppendFormat("{0}", Dr("CalleOrigen").ToString) - If Dr("NoExtOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", No.Ext: {0}", Dr("NoExtOrigen").ToString) - If Dr("ColoniaOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Col: {0}", Dr("ColoniaOrigen").ToString) - If Dr("CPOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", CP: {0}", Dr("CPOrigen").ToString) - If Dr("LocalidadOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Loc: {0}", Dr("LocalidadOrigen").ToString) - If Dr("MunicipioOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Cd: {0}", Dr("MunicipioOrigen").ToString) - If Dr("EstadoOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Edo: {0}", Dr("EstadoOrigen").ToString) - If Dr("PaisOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", País: {0}", Dr("PaisOrigen").ToString) - End If - If Dr("CalleDestino").ToString.Length > 0 Then - SBDireccionD.AppendFormat("{0}", Dr("CalleDestino").ToString) - If Dr("NoExtDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", No.Ext: {0}", Dr("NoExtDestino").ToString) - If Dr("ColoniaDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Col: {0}", Dr("ColoniaDestino").ToString) - If Dr("CPDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", CP: {0}", Dr("CPDestino").ToString) - If Dr("LocalidadDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Loc: {0}", Dr("LocalidadDestino").ToString) - If Dr("MunicipioDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Cd: {0}", Dr("MunicipioDestino").ToString) - If Dr("EstadoDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Edo: {0}", Dr("EstadoDestino").ToString) - If Dr("PaisDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", País: {0}", Dr("PaisDestino").ToString) - End If - End If - End If - End If - - 'GENERAL - params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) - params.Add(New ReportParameter("Tipo", TipoDocumento)) - params.Add(New ReportParameter("Ref", TipoDocumentoRef)) - params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) - params.Add(New ReportParameter("AlmOrigen", AlmOrigen)) - params.Add(New ReportParameter("AlmDestino", AlmDestino)) - params.Add(New ReportParameter("DireccionOrigen", SBDireccionO.ToString)) - params.Add(New ReportParameter("DireccionDestino", SBDireccionD.ToString)) - - RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) - RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) - Case Else - NombreArchivo = "" - TipoDocumento = "" - End Select - - If NombreArchivo = "" Then - GuardaLog("No se especifico el tipo de Impresion de venta (Venta, Remision, Cotización, Nota de Crédito).") - Return Nothing - End If - 'TERMINA REGION PARAMETROS - - Dim lrds As New List(Of ReportDataSource) - 'Si es ECLIPSE CREAR COLUMAS PARA FIRMAS EN DtDetalle. - If UsuarioActual.CveEmpresa.Contiene(1, 15, 17, 71, 76, 126) AndAlso Vta.DtFirmas IsNot Nothing Then - Dim DtDetalleFirmas As New DataTable - DtDetalleFirmas.TableName = "DetalleFirma" - DtDetalleFirmas = Vta.DtDetalle.Copy() - - 'SI NO TIENE LAS COLUMNAS DE FIRMAS LAS CREA. - If Not DtDetalleFirmas.Columns.Contains("Titulo") Then - DtDetalleFirmas.Columns.Add("Titulo", GetType(String)) - DtDetalleFirmas.Columns.Add("Nombre", GetType(String)) - DtDetalleFirmas.Columns.Add("Puesto", GetType(String)) - DtDetalleFirmas.Columns.Add("Lado", GetType(Integer)) - End If - - 'Se llenan los Rows de las columnas con los datos del DtFirmas - For i As Integer = 0 To Vta.DtFirmas.Rows.Count - 1 - 'Si DtDetalle es menor al DtFirmas, crea un nuevo Row en DtDetalle y le asigna valor, Si no solo asigna valor - If DtDetalleFirmas.Rows.Count < i + 1 Then - Dim Dr = DtDetalleFirmas.NewRow - Dr("Titulo") = Vta.DtFirmas(i)("Titulo").ToString - Dr("Nombre") = Vta.DtFirmas(i)("Nombre").ToString - Dr("Puesto") = Vta.DtFirmas(i)("Puesto").ToString - Dr("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero - DtDetalleFirmas.Rows.Add(Dr) - Else - DtDetalleFirmas(i)("Titulo") = Vta.DtFirmas(i)("Titulo").ToString - DtDetalleFirmas(i)("Nombre") = Vta.DtFirmas(i)("Nombre").ToString - DtDetalleFirmas(i)("Puesto") = Vta.DtFirmas(i)("Puesto").ToString - DtDetalleFirmas(i)("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero - End If - Next i - - Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = DtDetalleFirmas} - lrds.Add(rds) - Else - Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = Vta.DtDetalle} - lrds.Add(rds) - End If - - Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(Vta.DtDeduccion IsNot Nothing, Vta.DtDeduccion, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds1) - - 'DETALLE FIRMAS - Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(Vta.DtFirmas IsNot Nothing, Vta.DtFirmas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds2) - - Dim rds3 As New ReportDataSource With {.Name = "DataSet3", .Value = If(Vta.DtDesgloseImpuestos IsNot Nothing, Vta.DtDesgloseImpuestos, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds3) - - Dim rds4 As New ReportDataSource With {.Name = "DataSet4", .Value = If(Vta.DtDocumentosRelacionados IsNot Nothing, Vta.DtDocumentosRelacionados, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds4) - - Dim rds5 As New ReportDataSource With {.Name = "DataSet5", .Value = If(Vta.DtNCVinculadas IsNot Nothing, Vta.DtNCVinculadas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte - lrds.Add(rds5) - + + DomicilioSucursal = SBDomicilioSucursal.ToString + + Dim Fecha As String = Vta.Fecha.ToShortDateString + + Dim SBDireccion As New StringBuilder() + Dim SBLugar As New StringBuilder() + Dim ClienteDireccion As String + Dim ClienteLugar As String + + 'SI ESTA TIMBRADA - CON XML + If File.Exists(PathXML) AndAlso Vta.Serie <> "VistaPrevia" Then 'Cuando es vista previe y coincide la serie y folio se ponen los datos fiscales + Dim XmlDoc As New System.Xml.XmlDocument + XmlDoc.Load(PathXML) + + Dim TC As Decimal = 1 + Try + TC = XmlDoc.DocumentElement.Attributes("TipoCambio").InnerText.ToDecimal + Catch ex As Exception + TC = 1 + End Try + + Vta.FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate + Vta.NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText + + Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") + + If Not IsNothing(validaElemento) Then + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then + Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText + Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate + Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText + Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText + + End If + Next + Else + Vta.FolioFiscal = "Sin Timbrar" + Vta.NoSerieCertificado = "Sin Timbrar" + Vta.SelloCFDi = "Sin Timbrar" + Vta.SelloSAT = "Sin Timbrar" + End If + + 'SIN TIMBRAR - SIN XML + Else + Vta.FolioFiscal = "Sin Timbrar" + Vta.NoSerieCertificado = "Sin Timbrar" + Vta.SelloCFDi = "Sin Timbrar" + Vta.SelloSAT = "Sin Timbrar" + End If + + 'DIRECCION CLIENTE + If Vta.CveClienteSucursal.ToEntero > 0 Then + 'Si cliente tiene Noint, NoExt, CP + SBDireccion.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) + If Vta.ClienteSucursal.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) + If Vta.ClienteSucursal.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) + If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.ClienteSucursal.Colonia) + + If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then + If Vta.ClienteSucursal.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.ClienteSucursal.CP.Trim) + End If + + 'Si cliente tiene Local, CD, Edo, Pais + If Vta.ClienteSucursal.Localidad IsNot Nothing AndAlso Vta.ClienteSucursal.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.ClienteSucursal.Localidad) + If Vta.ClienteSucursal.Municipio IsNot Nothing AndAlso Vta.ClienteSucursal.Municipio.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.ClienteSucursal.Municipio) + If Vta.ClienteSucursal.Estado IsNot Nothing AndAlso Vta.ClienteSucursal.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.ClienteSucursal.Estado) + If Vta.ClienteSucursal.Pais IsNot Nothing AndAlso Vta.ClienteSucursal.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.ClienteSucursal.Pais) + Else + SBDireccion.AppendFormat("{0}", Vta.Cliente.Direccion) + If Vta.Cliente.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) + If Vta.Cliente.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) + If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.Cliente.Colonia) + + If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then + If Vta.Cliente.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.Cliente.CP.Trim) + End If + + 'Si cliente tiene Local, CD, Edo, Pais + If Vta.Cliente.Localidad IsNot Nothing AndAlso Vta.Cliente.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.Cliente.Localidad) + If Vta.Cliente.Ciudad IsNot Nothing AndAlso Vta.Cliente.Ciudad.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.Cliente.Ciudad) + If Vta.Cliente.Estado IsNot Nothing AndAlso Vta.Cliente.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.Cliente.Estado) + If Vta.Cliente.Pais IsNot Nothing AndAlso Vta.Cliente.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.Cliente.Pais) + + End If + + ClienteDireccion = SBDireccion.ToString + ClienteLugar = SBLugar.ToString + SBDireccion.Clear() + SBLugar.Clear() + + 'LOGO + Dim LogoRuta As String = "" + 'POR SUCURSAL + LogoRuta = String.Format("{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + If File.Exists(LogoRuta) Then + LogoRuta = String.Format("file://{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + 'POR EMPRESA + Else + LogoRuta = String.Format("{0}Formatos\Logo.png", UsuarioActual.Empresa.Ruta) + If File.Exists(LogoRuta) Then + LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + End If + End If + LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + 'Si no tiene CBB, SE GENERA + If Not ImagenCBB.Exists Then + Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + End If + ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) + + Dim CadenaOriginals As String = "||1.0|" + Vta.FolioFiscal + "|" + Vta.FechaCertificacion.ToString("yyyy-MM-dd") + "T" + Vta.FechaCertificacion.ToString("HH:mm:ss") + "|" + Vta.SelloCFDi + "|" + Vta.NoSerieCertificado + "||" + If Not ImagenCBB.Exists Then ImgCBB = "" + Dim RutaFormato As String = "" + + + 'AQUI EMPIEZA LOS PARAMETROS + Try + Dim params = New List(Of CrystalParametro) + + 'CLIENTE + params.Add(New CrystalParametro("ClienteCodigo", Vta.Cliente.Codigo)) + params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New CrystalParametro("ClienteDireccion", ClienteDireccion)) + params.Add(New CrystalParametro("ClienteLugar", ClienteLugar)) + + + 'TOTALES + params.Add(New CrystalParametro("SubTotal", Vta.SubTotal.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("Descuento", Vta.Descuento.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("Amortizacion", Vta.Amortizacion.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("SubTotal2", (Vta.SubTotal - Vta.Descuento - Vta.Amortizacion).ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("IVA", Vta.IVA.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("RetIVA", Vta.RetIVA.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("RetISR", Vta.RetISR.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("Total", Vta.Total.ToString.FormatoNumero(2))) + params.Add(New CrystalParametro("ImporteLetra", Vta.Total.ToString.ToDouble.Texto2Letras(Vta.CveMoneda))) + + 'DATOS GENERALES + params.Add(New CrystalParametro("Observaciones", Vta.Observaciones)) + params.Add(New CrystalParametro("CveVendedor", Vta.CveVendedor.ToString)) + 'params.Add(New CrystalParametro("Status", Vta.EstatusFactura)) + params.Add(New CrystalParametro("FechaSolicitud", Vta.Fecha.ToString("dd/MMMM/yyyy"))) ' se puede omitir + params.Add(New CrystalParametro("Serie", Vta.Serie)) + params.Add(New CrystalParametro("Folio", Vta.Folio.ToString)) + params.Add(New CrystalParametro("DomicilioSucursal", DomicilioSucursal)) + params.Add(New CrystalParametro("Vencimiento", Vta.FechaVencimiento.ToString("dd/MM/yyyy"))) + params.Add(New CrystalParametro("FolioFiscal", Vta.FolioFiscal)) + params.Add(New CrystalParametro("FechaCertificacion", String.Format("{0}T{1}", Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss")))) + params.Add(New CrystalParametro("SelloCFDI", Vta.SelloCFDi)) + params.Add(New CrystalParametro("CadenaSAT", CadenaOriginals)) + params.Add(New CrystalParametro("SelloSAT", Vta.SelloSAT)) + + params.Add(New CrystalParametro("QR", ImgCBB)) + params.Add(New CrystalParametro("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New CrystalParametro("FormaPago", Vta.FormaPagoText)) + params.Add(New CrystalParametro("Moneda", Vta.Moneda)) + params.Add(New CrystalParametro("TipoCambio", Vta.TipoCambio.ToString)) + params.Add(New CrystalParametro("CondicionPago", Vta.CondicionesPagoText)) + params.Add(New CrystalParametro("CadenaOriginal", CadenaOriginals)) + params.Add(New CrystalParametro("SerieCertificadoSAT", Vta.NoSerieCertificado)) + params.Add(New CrystalParametro("CertificadoContribuyente", Vta.NoSerieCertificadoContribuyente)) + params.Add(New CrystalParametro("NumCta", Vta.NumeroCuenta)) + params.Add(New CrystalParametro("LogoPath", LogoRuta)) + + 'VENDEDOR + Dim RowVendedor As DataRow = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveVendedor = {0}", Vta.CveVendedor.ToString)) + If Not IsNothing(RowVendedor) Then + params.Add(New CrystalParametro("VendedorNombre", RowVendedor("Vendedor").ToString)) + params.Add(New CrystalParametro("VendedorMail", RowVendedor("Correo").ToString)) + params.Add(New CrystalParametro("VendedorTelefono", RowVendedor("Telefono").ToString)) + params.Add(New CrystalParametro("VendedorCelular", RowVendedor("Celular").ToString)) + + End If + + params.Add(New CrystalParametro("CiudadSucursal", CiudadSucursal)) + params.Add(New CrystalParametro("OC", Vta.Det_OrdenCompra.ToString)) + + If UsuarioActual.Empresa.Funcionalidad(508) = "1" Then + params.Add(New CrystalParametro("IEPS", Vta.IEPS.ToString.FormatoNumero(2))) + End If + + If Vta.CveClienteSucursal > 0 Then + params.Add(New CrystalParametro("ClienteContactoMail", Vta.ClienteSucursal.CorreoSucursal)) + params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) + Else + params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion)) + params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + End If + + If UsuarioActual.CveEmpresa.Contiene(17) Then + params.Add(New CrystalParametro("MetodoPago", Vta.ClaveMetodoPagoSAT.ToString)) + Else + params.Add(New CrystalParametro("MetodoPago", Vta.MetodoPago.ToString)) + End If + + + Select Case Vta.TipoDocto + Case "Ing" + NombreArchivo = "Factura" + NombreArchivoDescarga = "Factura" + TipoDocumento = "INGRESO" + + 'GENERAL + params.Add(New CrystalParametro("TipoDocumento", NombreArchivoDescarga)) + params.Add(New CrystalParametro("Tipo", TipoDocumento)) + params.Add(New CrystalParametro("Ref", TipoDocumentoRef)) + params.Add(New CrystalParametro("AplicaPagare", AplicaPagare)) + + 'VSH + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122, 145) Then + 'DATOS CLIENTES + Dim ClienteRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Vta.CveCliente.ToString)) + Dim DatosCliente = "" + If ClienteRow IsNot Nothing Then + DatosCliente = String.Format("{0} | {1} | {2}", Vta.SubProyecto.Municipio, ClienteRow("CuentaContable"), ClienteRow("Codigo")) + End If + params.Add(New CrystalParametro("DatosClientes", DatosCliente)) + params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) + End If + + 'COMPU, DN DIFUSA + If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then + params.Add(New CrystalParametro("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) + params.Add(New CrystalParametro("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) + params.Add(New CrystalParametro("PedidoContrato", Vta.PedidoContrato)) + params.Add(New CrystalParametro("DescripcionContrato", Vta.NumeroDescripcionContrato)) + + params.Add(New CrystalParametro("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) + params.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New CrystalParametro("FechaImpresion", Now.ToDateTime.ToString)) + params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) + + 'INE COMPLEMENTOS + If UsuarioActual.CveEmpresa.Contiene(72) Then + Dim INETipoProceso As String = "" + Dim INETipoComite As String = "" + Dim INEIdContabilidad As Integer = 0 + If Vta.ComplementoINE IsNot Nothing Then + INETipoProceso = Vta.ComplementoINE.INETipoProceso + INETipoComite = Vta.ComplementoINE.INETipoComite + INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad + End If + params.Add(New CrystalParametro("INETipoProceso", INETipoProceso)) + params.Add(New CrystalParametro("INETipoComite", INETipoComite)) + params.Add(New CrystalParametro("INEIdContabilidad", INEIdContabilidad)) + params.Add(New CrystalParametro("Referencia", Vta.Cliente.ReferenciaFiscal)) + params.Add(New CrystalParametro("ClienteContacto", Vta.AtnA)) + End If + + 'DIRECCION ENVIO + If Vta.EnviarA.CveDireccionEnvio > 0 Then + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", Vta.EnviarA.EnvioDireccion) + If Vta.EnviarA.EnvioNoExt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.EnviarA.EnvioNoExt) + If Vta.EnviarA.EnvioNoInt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.EnviarA.EnvioNoInt) + + params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New CrystalParametro("EnvioNoExt", Vta.EnviarA.EnvioNoExt)) + params.Add(New CrystalParametro("EnvioNoInt", Vta.EnviarA.EnvioNoInt)) + params.Add(New CrystalParametro("EnvioColonia", Vta.EnviarA.EnvioColonia)) + params.Add(New CrystalParametro("EnvioCiudad", Vta.EnviarA.EnvioCiudad)) + params.Add(New CrystalParametro("EnvioEstado", Vta.EnviarA.EnvioEstado)) + params.Add(New CrystalParametro("EnvioContacto", Vta.EnviarA.EnvioContacto)) + params.Add(New CrystalParametro("EnvioDepartamento", Vta.EnviarA.EnvioDepartamento)) + params.Add(New CrystalParametro("EnvioCP", Vta.EnviarA.EnvioCP)) + Else + If Vta.CveClienteSucursal.ToEntero > 0 Then + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) + If Vta.ClienteSucursal.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) + If Vta.ClienteSucursal.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) + params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New CrystalParametro("EnvioColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) + params.Add(New CrystalParametro("EnvioCiudad", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) + params.Add(New CrystalParametro("EnvioEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) + params.Add(New CrystalParametro("EnvioCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) + Else + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, "")) + If Vta.Cliente.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) + If Vta.Cliente.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) + params.Add(New CrystalParametro("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New CrystalParametro("EnvioColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) + params.Add(New CrystalParametro("EnvioCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) + params.Add(New CrystalParametro("EnvioEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) + params.Add(New CrystalParametro("EnvioCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) + End If + + End If + + 'CLIENTE SUCURSAL + If Vta.CveClienteSucursal.ToEntero > 0 Then + params.Add(New CrystalParametro("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) + params.Add(New CrystalParametro("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) + params.Add(New CrystalParametro("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) + params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) + params.Add(New CrystalParametro("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) + params.Add(New CrystalParametro("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) + params.Add(New CrystalParametro("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) + params.Add(New CrystalParametro("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) + params.Add(New CrystalParametro("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) + Else + params.Add(New CrystalParametro("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) + params.Add(New CrystalParametro("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) + params.Add(New CrystalParametro("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) + params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) + params.Add(New CrystalParametro("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) + params.Add(New CrystalParametro("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) + params.Add(New CrystalParametro("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) + params.Add(New CrystalParametro("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) + params.Add(New CrystalParametro("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) + End If + End If + + RutaFormato = String.Format("{0}Formatos\{1}.mrt", UsuarioActual.Empresa.Ruta, NombreArchivo) + + Case "Egs" + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + NombreArchivo = "NotaCredito" + Else + NombreArchivo = "Factura" + End If + NombreArchivoDescarga = "Nota de Crédito" + TipoDocumento = "EGRESO" + TipoDocumentoRef = String.Format(": Ref.:{0}", Vta.RefDocto) + AplicaPagare = "0" + + 'GENERAL + params.Add(New CrystalParametro("TipoDocumento", NombreArchivoDescarga)) + params.Add(New CrystalParametro("Tipo", TipoDocumento)) + params.Add(New CrystalParametro("Ref", TipoDocumentoRef)) + params.Add(New CrystalParametro("AplicaPagare", AplicaPagare)) + params.Add(New CrystalParametro("Fecha", String.Format("{0}T{1}", Vta.Fecha.ToString("yyyy-MM-dd"), Vta.Fecha.ToString("HH:mm:ss")))) + + 'ALAN YEPIZ + If UsuarioActual.CveEmpresa.Contiene(123) Then + params.Add(New CrystalParametro("DiaExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Day))) + params.Add(New CrystalParametro("MesExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Month))) + params.Add(New CrystalParametro("AñoExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Year))) + End If + + 'COMPU, DN DIFUSA + If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then + params.Add(New CrystalParametro("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) + params.Add(New CrystalParametro("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) + params.Add(New CrystalParametro("PedidoContrato", Vta.PedidoContrato)) + + params.Add(New CrystalParametro("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) + params.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New CrystalParametro("FechaImpresion", Now.ToDateTime.ToString)) + params.Add(New CrystalParametro("Sucursal", Vta.SubProyecto.SubProyecto)) + + 'CLIENTE SUCURSAL + If Vta.CveClienteSucursal.ToEntero > 0 Then + params.Add(New CrystalParametro("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) + params.Add(New CrystalParametro("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) + params.Add(New CrystalParametro("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) + params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) + params.Add(New CrystalParametro("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) + params.Add(New CrystalParametro("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) + params.Add(New CrystalParametro("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) + params.Add(New CrystalParametro("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) + params.Add(New CrystalParametro("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) + Else + params.Add(New CrystalParametro("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) + params.Add(New CrystalParametro("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) + params.Add(New CrystalParametro("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) + params.Add(New CrystalParametro("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) + params.Add(New CrystalParametro("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) + params.Add(New CrystalParametro("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) + params.Add(New CrystalParametro("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) + params.Add(New CrystalParametro("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) + params.Add(New CrystalParametro("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) + End If + End If + + + RutaFormato = String.Format("{0}Formatos\{1}.mrt", UsuarioActual.Empresa.Ruta, "Factura") + Case Else + NombreArchivo = "" + TipoDocumento = "" + End Select + If NombreArchivo = "" Then + GuardaLog("No se especifico el tipo de Impresion de venta (Venta, Remision, Cotización, Nota de Crédito).") + Exit Sub + End If + 'TERMINA REGION PARAMETROS + + Dim lrds As New List(Of ReportDataSource) + 'Si es ECLIPSE CREAR COLUMAS PARA FIRMAS EN DtDetalle. + If UsuarioActual.CveEmpresa.Contiene(1, 15, 17, 71, 76, 125) Then + Dim DtDetalleFirmas As New DataTable + DtDetalleFirmas.TableName = "DetalleFirma" + DtDetalleFirmas = Vta.DtDetalle.Copy() + + 'SI NO TIENE LAS COLUMNAS DE FIRMAS LAS CREA. + If Not DtDetalleFirmas.Columns.Contains("Titulo") Then + DtDetalleFirmas.Columns.Add("Titulo", GetType(String)) + DtDetalleFirmas.Columns.Add("Nombre", GetType(String)) + DtDetalleFirmas.Columns.Add("Puesto", GetType(String)) + DtDetalleFirmas.Columns.Add("Lado", GetType(Integer)) + End If + + 'Se llenan los Rows de las columnas con los datos del DtFirmas + For i As Integer = 0 To Vta.DtFirmas.Rows.Count - 1 + 'Si DtDetalle es menor al DtFirmas, crea un nuevo Row en DtDetalle y le asigna valor, Si no solo asigna valor + If DtDetalleFirmas.Rows.Count < i + 1 Then + Dim Dr = DtDetalleFirmas.NewRow + Dr("Titulo") = Vta.DtFirmas(i)("Titulo").ToString + Dr("Nombre") = Vta.DtFirmas(i)("Nombre").ToString + Dr("Puesto") = Vta.DtFirmas(i)("Puesto").ToString + Dr("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero + DtDetalleFirmas.Rows.Add(Dr) + Else + DtDetalleFirmas(i)("Titulo") = Vta.DtFirmas(i)("Titulo").ToString + DtDetalleFirmas(i)("Nombre") = Vta.DtFirmas(i)("Nombre").ToString + DtDetalleFirmas(i)("Puesto") = Vta.DtFirmas(i)("Puesto").ToString + DtDetalleFirmas(i)("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero + End If + Next i + + Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = DtDetalleFirmas} + lrds.Add(rds) + Else + Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = Vta.DtDetalle} + lrds.Add(rds) + End If + + Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(Vta.DtDeduccion IsNot Nothing, Vta.DtDeduccion, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds1) + + 'DETALLE FIRMAS + + Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(Vta.DtFirmas IsNot Nothing, Vta.DtFirmas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds2) + + Dim Archivo As New System.IO.FileInfo(RutaFormato) + + Dim DataSet As New DataSet + Vta.DtDetalle.TableName = "Datos" + Vta.DtDeduccion.TableName = "Deduccion" + DataSet.Tables.Add(Vta.DtDetalle.Copy) + DataSet.Tables.Add(Vta.DtDeduccion.Copy) + + If Archivo.Exists Then + + + ImprimirbytesPDF(ImprimirPDFPyME(RutaFormato, DataSet, params, NombreArchivo, "PDF", MR:=Nothing), "Factura") + Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) + If Not ArchivoPDF.Exists Then + Try + DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) + DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + Else + Try + ArchivoPDF.Delete() + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + End If + Else + params.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) + params.Add(New CrystalParametro("RFC", UsuarioActual.Empresa.RFC)) + ImprimirbytesPDF(ImprimirPDFPyME(RutaFormato, DataSet, params, NombreArchivo, "PDF", MR:=Nothing), "Factura") + End If + + + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) + End Try + End Sub + Protected Function PdfFactura(ByRef Vta As Modelos.Factura, Optional AplicaPagare As String = "0", Optional Guardar As Boolean = True) As Byte() + Dim retorno As Byte() = Nothing + + ' Dim ObjVentas As New ClsVentas + + 'DATOS GENERALES + Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" + Dim PathXML As String = $"{Ruta}XML\{Vta.TipoDocto}\{Vta.SerieFolio}.xml" + Dim NombreArchivo As String = "" + Dim NombreArchivoDescarga As String = "" + Dim TipoDocumento As String = "" + Dim TipoDocumentoRef As String = "" + + + Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) + Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) + Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) + + Dim ImagenPath = String.Format("{0}Formatos\Suc{1}\logo.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + Dim Logo As New System.IO.FileInfo(ImagenPath) + Dim ImgLogo = New Uri(String.Format("{0}Empresas/{1}/Formatos/Suc{2}.png", UrlSitio, UsuarioActual.CveEmpresa, Vta.CveSucursal)).AbsoluteUri + + Dim SBDomicilioSucursal As New StringBuilder() + Dim CiudadSucursal As String = String.Format("{0},{1}", Vta.SubProyecto.Municipio, Vta.SubProyecto.Estado) + Dim DomicilioSucursal As String = "" + + SBDomicilioSucursal.AppendFormat("{0}", Vta.SubProyecto.Calle) + If Vta.SubProyecto.NoExt.Length > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", Vta.SubProyecto.NoExt) + If Vta.SubProyecto.NoInt.Length > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", Vta.SubProyecto.NoInt) + If Vta.SubProyecto.Colonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", Vta.SubProyecto.Colonia) + If Vta.SubProyecto.CP.ToEntero > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", Vta.SubProyecto.CP) + If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) + If Vta.SubProyecto.Pais.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", Vta.SubProyecto.Pais) + If Not String.IsNullOrEmpty(Vta.SubProyecto.Telefono) AndAlso UsuarioActual.CveEmpresa = 141 Then SBDomicilioSucursal.AppendFormat(", Tel: {0}", Vta.SubProyecto.Telefono) + + DomicilioSucursal = SBDomicilioSucursal.ToString + + Dim Fecha As String = Vta.Fecha.ToShortDateString + + Dim SBDireccion As New StringBuilder() + Dim SBLugar As New StringBuilder() + Dim ClienteDireccion As String + Dim ClienteLugar As String + Vta.FolioFiscal = "Sin Timbrar" + Vta.NoSerieCertificado = "Sin Timbrar" + Vta.SelloCFDi = "Sin Timbrar" + Vta.SelloSAT = "Sin Timbrar" + + 'SI ESTA TIMBRADA - CON XML + If File.Exists(PathXML) AndAlso Vta.Serie <> "VistaPrevia" Then 'Cuando es vista previe y coincide la serie y folio se ponen los datos fiscales + Dim XmlDoc As New System.Xml.XmlDocument + + Dim EsXMLValido = False + Try + XmlDoc.Load(PathXML) + EsXMLValido = True + Catch ex As Exception + GuardaLog(" --- *** Impresion ventas - ClsPaginas LN#5016 (Aprox) - EXISTE EL XML PERO NO SE PUEDE LEER. *** --- ") + End Try + + If EsXMLValido Then + Dim TC As Decimal = 1 + Try + TC = XmlDoc.DocumentElement.Attributes("TipoCambio").InnerText.ToDecimal + Catch ex As Exception + TC = 1 + End Try + If ValorNodoXML(XmlDoc.DocumentElement, "version") = "3.3" Then + Vta.FechaEmision = ValorNodoXML(XmlDoc.DocumentElement, "fecha").ToDate + Vta.NoSerieCertificadoContribuyente = ValorNodoXML(XmlDoc.DocumentElement, "NoCertificado") + + Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") + + If Not IsNothing(validaElemento) Then + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then + Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText + Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate + Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText + Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText + End If + Next + + End If + Else + Vta.FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate + Vta.NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText + + Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") + + If Not IsNothing(validaElemento) Then + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then + Vta.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + Vta.NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText + Vta.FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate + Vta.SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText + Vta.SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText + + End If + Next + End If + + End If + End If + + + End If + + 'DIRECCION CLIENTE + If Vta.CveClienteSucursal.ToEntero > 0 Then + 'Si cliente tiene Noint, NoExt, CP + SBDireccion.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) + If Vta.ClienteSucursal.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) + If Vta.ClienteSucursal.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) + If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.ClienteSucursal.Colonia) + + If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then + If Vta.ClienteSucursal.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.ClienteSucursal.CP.Trim) + End If + + 'Si cliente tiene Local, CD, Edo, Pais + If Vta.ClienteSucursal.Localidad IsNot Nothing AndAlso Vta.ClienteSucursal.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.ClienteSucursal.Localidad) + If Vta.ClienteSucursal.Municipio IsNot Nothing AndAlso Vta.ClienteSucursal.Municipio.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.ClienteSucursal.Municipio) + If Vta.ClienteSucursal.Estado IsNot Nothing AndAlso Vta.ClienteSucursal.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.ClienteSucursal.Estado) + If Vta.ClienteSucursal.Pais IsNot Nothing AndAlso Vta.ClienteSucursal.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.ClienteSucursal.Pais) + ElseIf Vta.CveCliente.ToEntero > 0 Then + SBDireccion.AppendFormat("{0}", Vta.Cliente.Direccion) + If Vta.Cliente.NoExt.Length > 0 Then SBDireccion.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) + If Vta.Cliente.NoInt.Length > 0 Then SBDireccion.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) + If UsuarioActual.CveEmpresa <> 66 Then SBDireccion.AppendFormat(", Col: {0}", Vta.Cliente.Colonia) + + If Not (UsuarioActual.CveEmpresa.Contiene(66, 81, 109) AndAlso Vta.TipoDocto = "Cot") Then + If Vta.Cliente.CP.Length > 0 Then SBDireccion.AppendFormat(", CP: {0} ", Vta.Cliente.CP.Trim) + End If + + 'Si cliente tiene Local, CD, Edo, Pais + If Vta.Cliente.Localidad IsNot Nothing AndAlso Vta.Cliente.Localidad.Length > 0 Then SBLugar.AppendFormat("Loc: {0}, ", Vta.Cliente.Localidad) + If Vta.Cliente.Ciudad IsNot Nothing AndAlso Vta.Cliente.Ciudad.Length > 0 Then SBLugar.AppendFormat("Cd: {0}, ", Vta.Cliente.Ciudad) + If Vta.Cliente.Estado IsNot Nothing AndAlso Vta.Cliente.Estado.Length > 0 Then SBLugar.AppendFormat(" Edo: {0}, ", Vta.Cliente.Estado) + If Vta.Cliente.Pais IsNot Nothing AndAlso Vta.Cliente.Pais.Length > 0 Then SBLugar.AppendFormat(" País: {0} ", Vta.Cliente.Pais) + + End If + + ClienteDireccion = SBDireccion.ToString + ClienteLugar = SBLugar.ToString + SBDireccion.Clear() + SBLugar.Clear() + + 'LOGO + Dim LogoRuta As String = "" + 'POR SUCURSAL + LogoRuta = String.Format("{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + If File.Exists(LogoRuta) Then + LogoRuta = String.Format("file://{0}Formatos\Suc{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveSucursal) + 'POR EMPRESA + Else + LogoRuta = String.Format("{0}Formatos\Logo.png", UsuarioActual.Empresa.Ruta) + If File.Exists(LogoRuta) Then + LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + End If + End If + + 'Si no tiene CBB, SE GENERA + If Not ImagenCBB.Exists AndAlso Vta.CveCliente.ToEntero > 0 Then + Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + End If + ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) + + 'Dim CadenaOriginals As String = "||1.0|" + Vta.FolioFiscal + "|" + Vta.FechaCertificacion.ToString("yyyy-MM-dd") + "T" + Vta.FechaCertificacion.ToString("HH:mm:ss") + "|" + Vta.SelloCFDi + "|" + Vta.NoSerieCertificado + "||" + Dim CadenaOriginals As String = String.Format("||{0}|{1}|{2}T{3}|{4}|{5}||", If(Vta.Version = "3.3", "1.1", "1.0"), Vta.FolioFiscal, Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss"), Vta.SelloCFDi, Vta.NoSerieCertificado) + If Not ImagenCBB.Exists Then ImgCBB = "" + Dim RutaFormato As String = "" + Dim RutaFormatoDefault As String = "" + + 'AQUI EMPIEZA LOS PARAMETROS + Try + Dim params As New List(Of ReportParameter) + + + 'CLIENTE + If Vta.CveCliente.ToEntero > 0 Then + params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) + params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) + params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) + params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + End If + + 'TOTALES + params.Add(New ReportParameter("SubTotal", Vta.SubTotal.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("Descuento", Vta.Descuento.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("Amortizacion", Vta.Amortizacion.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("SubTotal2", (Vta.SubTotal - Vta.Descuento - Vta.Amortizacion).ToString.FormatoNumero(2))) + params.Add(New ReportParameter("IVA", Vta.IVA.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("RetIVA", Vta.RetIVA.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("RetISR", Vta.RetISR.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("Total", Vta.Total.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("ImporteLetra", Vta.Total.ToString.ToDouble.Texto2Letras(Vta.CveMoneda))) + + 'DATOS GENERALES + + + + 'params.Add(New ReportParameter("CP", UsuarioActual.Empresa.CP.ToString)) + params.Add(New ReportParameter("Observaciones", Vta.Observaciones)) + params.Add(New ReportParameter("CveVendedor", Vta.CveVendedor.ToString)) + params.Add(New ReportParameter("Status", Vta.EstatusFactura)) + params.Add(New ReportParameter("FechaSolicitud", Vta.Fecha.ToString("dd/MMMM/yyyy"))) ' se puede omitir + params.Add(New ReportParameter("Serie", Vta.Serie)) + params.Add(New ReportParameter("Folio", Vta.Folio.ToString)) + params.Add(New ReportParameter("DomicilioSucursal", DomicilioSucursal)) + params.Add(New ReportParameter("Vencimiento", Vta.FechaVencimiento.ToString("dd/MM/yyyy"))) + params.Add(New ReportParameter("FolioFiscal", Vta.FolioFiscal)) + params.Add(New ReportParameter("FechaCertificacion", String.Format("{0}T{1}", Vta.FechaCertificacion.ToString("yyyy-MM-dd"), Vta.FechaCertificacion.ToString("HH:mm:ss")))) + params.Add(New ReportParameter("SelloCFDI", Vta.SelloCFDi)) + params.Add(New ReportParameter("CadenaSAT", CadenaOriginals)) + params.Add(New ReportParameter("SelloSAT", Vta.SelloSAT)) + + params.Add(New ReportParameter("QR", ImgCBB)) + params.Add(New ReportParameter("Moneda", Vta.Moneda)) + params.Add(New ReportParameter("TipoCambio", Vta.TipoCambio.ToString)) + params.Add(New ReportParameter("CondicionPago", Vta.CondicionesPagoText)) + params.Add(New ReportParameter("CadenaOriginal", CadenaOriginals)) + params.Add(New ReportParameter("SerieCertificadoSAT", Vta.NoSerieCertificado)) + params.Add(New ReportParameter("CertificadoContribuyente", Vta.NoSerieCertificadoContribuyente)) + params.Add(New ReportParameter("NumCta", Vta.NumeroCuenta)) + params.Add(New ReportParameter("LogoPath", LogoRuta)) + params.Add(New ReportParameter("CiudadSucursal", CiudadSucursal)) + params.Add(New ReportParameter("OC", Vta.Det_OrdenCompra.ToString)) + params.Add(New ReportParameter("ClienteDiasCredito", "0")) + params.Add(New ReportParameter("MonedaAbreviatura", If(Vta.MonedaAbreviatura.ToString IsNot Nothing, Vta.MonedaAbreviatura.ToString, ""))) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) + params.Add(New ReportParameter("Sucursal", Vta.SubProyecto.SubProyecto)) + params.Add(New ReportParameter("EstatusFactura", If(Vta.TipoEstatus = 5, Vta.EstatusFactura, ""))) + params.Add(New ReportParameter("EstatusEntrega", If(Vta.Inv_CveEstatusEntrega = 1, Vta.Inv_EstatusEntrega, ""))) + params.Add(New ReportParameter("PedidoContrato", Vta.PedidoContrato)) + params.Add(New ReportParameter("OrdenCompra", Vta.OrdenCompra)) + params.Add(New ReportParameter("DescripcionContrato", Vta.NumeroDescripcionContrato)) + params.Add(New ReportParameter("Contrato", Vta.NumeroContrato)) + params.Add(New ReportParameter("Fecha", String.Format("{0}T{1}", Vta.Fecha.ToString("yyyy-MM-dd"), Vta.Fecha.ToString("HH:mm:ss")))) + + 'VENDEDOR + Dim VendedorNombre As String = "" + Dim VendedorMail As String = "" + Dim VendedorTelefono As String = "" + Dim VendedorCelular As String = "" + Dim RowVendedor As DataRow = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveVendedor = {0}", Vta.CveVendedor.ToString)) + If Not IsNothing(RowVendedor) Then + VendedorNombre = RowVendedor("Vendedor").ToString + VendedorMail = RowVendedor("Correo").ToString + VendedorTelefono = RowVendedor("Telefono").ToString + VendedorCelular = RowVendedor("Celular").ToString + End If + params.Add(New ReportParameter("VendedorNombre", VendedorNombre)) + params.Add(New ReportParameter("VendedorMail", VendedorMail)) + params.Add(New ReportParameter("VendedorTelefono", VendedorTelefono)) + params.Add(New ReportParameter("VendedorCelular", VendedorCelular)) + + If UsuarioActual.Empresa.Funcionalidad(508) = "1" Then + params.Add(New ReportParameter("IEPS", Vta.IEPS.ToString.FormatoNumero(2))) + End If + + If Vta.CveClienteSucursal > 0 Then + params.Add(New ReportParameter("ClienteContactoMail", Vta.ClienteSucursal.CorreoSucursal)) + params.Add(New ReportParameter("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) + ElseIf Vta.CveCliente.ToEntero > 0 Then + params.Add(New ReportParameter("ClienteContactoMail", Vta.Cliente.MailCotizacion)) + params.Add(New ReportParameter("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + End If + + If UsuarioActual.CveEmpresa.Contiene(17) Then + params.Add(New ReportParameter("MetodoPago", Vta.ClaveMetodoPagoSAT.ToString)) + End If + + If Vta.Version = "3.3" Then + params.Add(New ReportParameter("FormaPago", Vta.FormaPago33.ToString)) + params.Add(New ReportParameter("MetodoPago", Vta.MetodoPago33.ToString)) + params.Add(New ReportParameter("UsoCFDI", Vta.UsoCFDI)) + If Vta.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then + params.Add(New ReportParameter("TipoRelacionTexto", If(Vta.Timbre.CFDIRelacionados.TipoRelacionTexto Is Nothing, "", Vta.Timbre.CFDIRelacionados.TipoRelacionTexto))) + params.Add(New ReportParameter("FolioFiscalRelacionado", If(Vta.Timbre.CFDIRelacionados.UUID.Count = 0, "", Vta.Timbre.CFDIRelacionados.UUID.Item(0)))) + End If + Else + params.Add(New ReportParameter("FormaPago", Vta.FormaPagoText)) + params.Add(New ReportParameter("MetodoPago", Vta.MetodoPago.ToString)) + End If + + 'DIRECCION ENVIO + If Vta.EnviarA IsNot Nothing AndAlso Vta.EnviarA.CveDireccionEnvio > 0 Then + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", Vta.EnviarA.EnvioDireccion) + If Vta.EnviarA.EnvioNoExt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.EnviarA.EnvioNoExt) + If Vta.EnviarA.EnvioNoInt IsNot Nothing AndAlso Vta.EnviarA.EnvioNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.EnviarA.EnvioNoInt) + + params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New ReportParameter("EnvioNoExt", Vta.EnviarA.EnvioNoExt)) + params.Add(New ReportParameter("EnvioNoInt", Vta.EnviarA.EnvioNoInt)) + params.Add(New ReportParameter("EnvioColonia", Vta.EnviarA.EnvioColonia)) + params.Add(New ReportParameter("EnvioCiudad", Vta.EnviarA.EnvioCiudad)) + params.Add(New ReportParameter("EnvioEstado", Vta.EnviarA.EnvioEstado)) + params.Add(New ReportParameter("EnvioContacto", Vta.EnviarA.EnvioContacto)) + params.Add(New ReportParameter("EnvioDepartamento", Vta.EnviarA.EnvioDepartamento)) + params.Add(New ReportParameter("EnvioCP", Vta.EnviarA.EnvioCP)) + If Vta.CveEmpresa = 72 Then + params.Add(New ReportParameter("EnvioTel", Vta.EnviarA.EnvioTel)) + End If + ElseIf Vta.CveCliente.ToEntero > 0 Then + If Vta.CveClienteSucursal.ToEntero > 0 Then + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", Vta.ClienteSucursal.Direccion) + If Vta.ClienteSucursal.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.ClienteSucursal.NoExt) + If Vta.ClienteSucursal.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.ClienteSucursal.NoInt) + params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New ReportParameter("EnvioNoExt", Vta.ClienteSucursal.NoExt)) + params.Add(New ReportParameter("EnvioNoInt", Vta.ClienteSucursal.NoInt)) + params.Add(New ReportParameter("EnvioColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) + params.Add(New ReportParameter("EnvioCiudad", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) + params.Add(New ReportParameter("EnvioEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) + params.Add(New ReportParameter("EnvioCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) + Else + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, "")) + If Vta.Cliente.NoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", Vta.Cliente.NoExt) + If Vta.Cliente.NoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", Vta.Cliente.NoInt) + params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New ReportParameter("EnvioNoExt", Vta.Cliente.NoExt)) + params.Add(New ReportParameter("EnvioNoInt", Vta.Cliente.NoInt)) + params.Add(New ReportParameter("EnvioColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) + params.Add(New ReportParameter("EnvioCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) + params.Add(New ReportParameter("EnvioEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) + params.Add(New ReportParameter("EnvioCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) + End If + params.Add(New ReportParameter("EnvioContacto", "")) + params.Add(New ReportParameter("EnvioDepartamento", "")) + End If + + 'CLIENTE SUCURSAL + If Vta.CveClienteSucursal.ToEntero > 0 Then + params.Add(New ReportParameter("ClienteCalle", If(Vta.ClienteSucursal.Direccion.Length > 0, Vta.ClienteSucursal.Direccion, ""))) + params.Add(New ReportParameter("ClienteColonia", If(Vta.ClienteSucursal.Colonia.Length > 0, Vta.ClienteSucursal.Colonia, ""))) + params.Add(New ReportParameter("ClienteCiudad", If(Vta.ClienteSucursal.Localidad IsNot Nothing And Vta.ClienteSucursal.Localidad.Length > 0, Vta.ClienteSucursal.Localidad, ""))) + params.Add(New ReportParameter("ClienteMunicipio", If(Vta.ClienteSucursal.Municipio.Length > 0, Vta.ClienteSucursal.Municipio, ""))) + params.Add(New ReportParameter("ClienteEstado", If(Vta.ClienteSucursal.Estado.Length > 0, Vta.ClienteSucursal.Estado, ""))) + params.Add(New ReportParameter("ClienteCP", If(Vta.ClienteSucursal.CP.Length > 0, Vta.ClienteSucursal.CP, ""))) + params.Add(New ReportParameter("ClienteNoInt", If(Vta.ClienteSucursal.NoInt.Length > 0, Vta.ClienteSucursal.NoInt, ""))) + params.Add(New ReportParameter("ClienteNoExt", If(Vta.ClienteSucursal.NoExt.Length > 0, Vta.ClienteSucursal.NoExt, ""))) + params.Add(New ReportParameter("ClientePais", If(Vta.ClienteSucursal.Pais.Length > 0, Vta.ClienteSucursal.Pais, ""))) + params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) + ElseIf Vta.CveCliente.ToEntero > 0 Then + params.Add(New ReportParameter("ClienteCalle", If(Vta.Cliente.Direccion.Length > 0, Vta.Cliente.Direccion, ""))) + params.Add(New ReportParameter("ClienteColonia", If(Vta.Cliente.Colonia.Length > 0, Vta.Cliente.Colonia, ""))) + params.Add(New ReportParameter("ClienteCiudad", If(Vta.Cliente.Localidad IsNot Nothing And Vta.Cliente.Localidad.Length > 0, Vta.Cliente.Localidad, ""))) + params.Add(New ReportParameter("ClienteMunicipio", If(Vta.Cliente.Ciudad.Length > 0, Vta.Cliente.Ciudad, ""))) + params.Add(New ReportParameter("ClienteEstado", If(Vta.Cliente.Estado.Length > 0, Vta.Cliente.Estado, ""))) + params.Add(New ReportParameter("ClienteCP", If(Vta.Cliente.CP.Length > 0, Vta.Cliente.CP, ""))) + params.Add(New ReportParameter("ClienteNoInt", If(Vta.Cliente.NoInt.Length > 0, Vta.Cliente.NoInt, ""))) + params.Add(New ReportParameter("ClienteNoExt", If(Vta.Cliente.NoExt.Length > 0, Vta.Cliente.NoExt, ""))) + params.Add(New ReportParameter("ClientePais", If(Vta.Cliente.Pais.Length > 0, Vta.Cliente.Pais, ""))) + params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) + End If + + 'PARAMETROS SEGUN TIPO DOCUMENTO + Select Case Vta.TipoDocto + Case "Ing" + NombreArchivo = "Factura" + NombreArchivoDescarga = "Factura" + TipoDocumento = "INGRESO" + + If UsuarioActual.CveEmpresa.Contiene(137) Then + params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) + End If + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + 'VSH + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122, 145) Then + 'DATOS CLIENTES + Dim ClienteRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Vta.CveCliente.ToString)) + Dim DatosCliente = "" + If ClienteRow IsNot Nothing Then + DatosCliente = String.Format("{0} | {1} | {2}", Vta.SubProyecto.Municipio, ClienteRow("CuentaContable"), ClienteRow("Codigo")) + End If + params.Add(New ReportParameter("ClienteDatoExtra1", DatosCliente)) + End If + + 'INE COMPLEMENTOS + If UsuarioActual.CveEmpresa.Contiene(72, 1) Then + Dim INETipoProceso As String = "" + Dim INETipoComite As String = "" + Dim INEIdContabilidad As Integer = 0 + If Vta.ComplementoINE IsNot Nothing Then + INETipoProceso = Vta.ComplementoINE.INETipoProceso + INETipoComite = Vta.ComplementoINE.INETipoComite + INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad + End If + params.Add(New ReportParameter("INETipoProceso", INETipoProceso)) + params.Add(New ReportParameter("INETipoComite", INETipoComite)) + params.Add(New ReportParameter("INEIdContabilidad", INEIdContabilidad.ToString)) + params.Add(New ReportParameter("Referencia", Vta.Cliente.ReferenciaFiscal)) + + End If + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Rem" + NombreArchivo = "Remision" + NombreArchivoDescarga = "Remisión" + TipoDocumento = "REMISION" + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + 'ALAN YEPIZ + If UsuarioActual.CveEmpresa.Contiene(123) Then + params.Add(New ReportParameter("DiaExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Day))) + params.Add(New ReportParameter("MesExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Month))) + params.Add(New ReportParameter("AñoExpedicion", String.Format("{0}", Vta.Fecha.ToDate.Year))) + End If + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Cot" + NombreArchivo = "Cotizacion" + NombreArchivoDescarga = "Cotización" + TipoDocumento = "COTIZACIÓN" + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + params.Add(New ReportParameter("ClienteContacto", Vta.AtencionA)) + + If UsuarioActual.CveEmpresa.Contiene(137, 132, 144) Then + params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) + End If + + 'COMPU DN DIFUSA + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 137, 132, 144) Then + + Dim FirmaVendedor As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveVendedor)) + + params.Add(New ReportParameter("FirmaVendedor", If(FirmaVendedor.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", UsuarioActual.CveEmpresa, Vta.CveVendedor))).AbsoluteUri, ""))) + params.Add(New ReportParameter("Entrega", Vta.Entrega)) + params.Add(New ReportParameter("Vigencia", Vta.Vigencia.ToString("dd/MMMM/yyyy"))) + params.Add(New ReportParameter("Sucursal", Vta.SubProyecto.SubProyecto)) + params.Add(New ReportParameter("SucursalCliente", If(Vta.ClienteSucursal.Sucursal.ToString Is Nothing, "", Vta.ClienteSucursal.Sucursal.ToString))) + params.Add(New ReportParameter("CveMoneda", Vta.CveMoneda.ToString)) + params.Add(New ReportParameter("FormaEntrega", Vta.CondicionEntrega)) + + If Not IsNothing(RowVendedor) Then + params.Add(New ReportParameter("TituloVendedor", RowVendedor("TituloDocumentos").ToString)) + Else + params.Add(New ReportParameter("TituloVendedor", "")) + End If + + End If + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Egs" + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + NombreArchivo = "NotaCredito" + Else + NombreArchivo = "Factura" + End If + NombreArchivoDescarga = "Nota de Crédito" + TipoDocumento = "EGRESO" + TipoDocumentoRef = String.Format(": Ref.:{0}", Vta.RefDocto) + AplicaPagare = "0" + + If UsuarioActual.CveEmpresa.Contiene(137) Then + params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) + End If + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Ant" + NombreArchivo = "Factura" + NombreArchivoDescarga = "Anticipo" + TipoDocumento = "INGRESO" + + If UsuarioActual.CveEmpresa.Contiene(137) Then + params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) + End If + + 'GENERAL + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + 'INE COMPLEMENTOS + If UsuarioActual.CveEmpresa.Contiene(72) Then + Dim INETipoProceso As String = "" + Dim INETipoComite As String = "" + Dim INEIdContabilidad As Integer = 0 + If Vta.ComplementoINE IsNot Nothing Then + INETipoProceso = Vta.ComplementoINE.INETipoProceso + INETipoComite = Vta.ComplementoINE.INETipoComite + INEIdContabilidad = Vta.ComplementoINE.INEIdContabilidad + End If + params.Add(New ReportParameter("INETipoProceso", INETipoProceso)) + params.Add(New ReportParameter("INETipoComite", INETipoComite)) + params.Add(New ReportParameter("INEIdContabilidad", INEIdContabilidad.ToString)) + params.Add(New ReportParameter("Referencia", Vta.Cliente.ReferenciaFiscal)) + params.Add(New ReportParameter("ClienteContacto", Vta.AtnA)) + End If + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Ped" + NombreArchivo = "Pedido" + NombreArchivoDescarga = "Pedido" + TipoDocumento = "INGRESO" + + 'GENERAL + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + params.Add(New ReportParameter("CveAlmacenTraspasoOrigen", Vta.CveAlmacenTraspasoOrigen.ToString)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Pd2" + NombreArchivo = "Pedido2" + NombreArchivoDescarga = "Pedido2" + TipoDocumento = "INGRESO" + + 'GENERAL + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Dev" + NombreArchivo = "NotaDevolucion" + NombreArchivoDescarga = "NotaDevolucion" + TipoDocumento = "DEVOLUCION" + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "DPe" + NombreArchivo = "DevolucionPedido" + NombreArchivoDescarga = "DevolucionPedido" + TipoDocumento = "INGRESO" + + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "PeC" + NombreArchivo = "PedidoConsignacion" + NombreArchivoDescarga = "Pedido Consignación" + TipoDocumento = "INGRESO" + + 'GENERAL + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case "Tra" + NombreArchivo = "Traspaso" + NombreArchivoDescarga = "Traspaso" + TipoDocumento = "Traspaso" + + Dim ObjInv As New ClsInventarios + Dim AlmOrigen As String = "" + Dim AlmDestino As String = "" + + Dim SBDireccionO As New StringBuilder() + Dim SBDireccionD As New StringBuilder() + + If ObjInv.GetMovimientos(Vta.Inv_CveMovimiento.ToEntero, -1, -1, UsuarioActual.CveEmpresa) Then + If ObjInv.DtResultados.Rows.Count > 0 Then + Dim Dr As DataRow = ObjInv.DtResultados.Rows(0) + If Dr IsNot Nothing Then + AlmOrigen = Dr("AlmacenOrigen").ToString + AlmDestino = Dr("AlmacenDestino").ToString + + If Dr("CalleOrigen").ToString.Length > 0 Then + SBDireccionO.AppendFormat("{0}", Dr("CalleOrigen").ToString) + If Dr("NoExtOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", No.Ext: {0}", Dr("NoExtOrigen").ToString) + If Dr("ColoniaOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Col: {0}", Dr("ColoniaOrigen").ToString) + If Dr("CPOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", CP: {0}", Dr("CPOrigen").ToString) + If Dr("LocalidadOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Loc: {0}", Dr("LocalidadOrigen").ToString) + If Dr("MunicipioOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Cd: {0}", Dr("MunicipioOrigen").ToString) + If Dr("EstadoOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Edo: {0}", Dr("EstadoOrigen").ToString) + If Dr("PaisOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", País: {0}", Dr("PaisOrigen").ToString) + End If + If Dr("CalleDestino").ToString.Length > 0 Then + SBDireccionD.AppendFormat("{0}", Dr("CalleDestino").ToString) + If Dr("NoExtDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", No.Ext: {0}", Dr("NoExtDestino").ToString) + If Dr("ColoniaDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Col: {0}", Dr("ColoniaDestino").ToString) + If Dr("CPDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", CP: {0}", Dr("CPDestino").ToString) + If Dr("LocalidadDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Loc: {0}", Dr("LocalidadDestino").ToString) + If Dr("MunicipioDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Cd: {0}", Dr("MunicipioDestino").ToString) + If Dr("EstadoDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Edo: {0}", Dr("EstadoDestino").ToString) + If Dr("PaisDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", País: {0}", Dr("PaisDestino").ToString) + End If + End If + End If + End If + + 'GENERAL + params.Add(New ReportParameter("TipoDocumento", NombreArchivoDescarga)) + params.Add(New ReportParameter("Tipo", TipoDocumento)) + params.Add(New ReportParameter("Ref", TipoDocumentoRef)) + params.Add(New ReportParameter("AplicaPagare", AplicaPagare)) + params.Add(New ReportParameter("AlmOrigen", AlmOrigen)) + params.Add(New ReportParameter("AlmDestino", AlmDestino)) + params.Add(New ReportParameter("DireccionOrigen", SBDireccionO.ToString)) + params.Add(New ReportParameter("DireccionDestino", SBDireccionD.ToString)) + + RutaFormato = String.Format("{0}Formatos\{1}.rdlc", UsuarioActual.Empresa.Ruta, NombreArchivo) + RutaFormatoDefault = String.Format("Empresas\Grales\Formatos\{0}.rdlc", NombreArchivo) + Case Else + NombreArchivo = "" + TipoDocumento = "" + End Select + + If NombreArchivo = "" Then + GuardaLog("No se especifico el tipo de Impresion de venta (Venta, Remision, Cotización, Nota de Crédito).") + Return Nothing + End If + 'TERMINA REGION PARAMETROS + + Dim lrds As New List(Of ReportDataSource) + 'Si es ECLIPSE CREAR COLUMAS PARA FIRMAS EN DtDetalle. + If UsuarioActual.CveEmpresa.Contiene(1, 15, 17, 71, 76, 126) AndAlso Vta.DtFirmas IsNot Nothing Then + Dim DtDetalleFirmas As New DataTable + DtDetalleFirmas.TableName = "DetalleFirma" + DtDetalleFirmas = Vta.DtDetalle.Copy() + + 'SI NO TIENE LAS COLUMNAS DE FIRMAS LAS CREA. + If Not DtDetalleFirmas.Columns.Contains("Titulo") Then + DtDetalleFirmas.Columns.Add("Titulo", GetType(String)) + DtDetalleFirmas.Columns.Add("Nombre", GetType(String)) + DtDetalleFirmas.Columns.Add("Puesto", GetType(String)) + DtDetalleFirmas.Columns.Add("Lado", GetType(Integer)) + End If + + 'Se llenan los Rows de las columnas con los datos del DtFirmas + For i As Integer = 0 To Vta.DtFirmas.Rows.Count - 1 + 'Si DtDetalle es menor al DtFirmas, crea un nuevo Row en DtDetalle y le asigna valor, Si no solo asigna valor + If DtDetalleFirmas.Rows.Count < i + 1 Then + Dim Dr = DtDetalleFirmas.NewRow + Dr("Titulo") = Vta.DtFirmas(i)("Titulo").ToString + Dr("Nombre") = Vta.DtFirmas(i)("Nombre").ToString + Dr("Puesto") = Vta.DtFirmas(i)("Puesto").ToString + Dr("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero + DtDetalleFirmas.Rows.Add(Dr) + Else + DtDetalleFirmas(i)("Titulo") = Vta.DtFirmas(i)("Titulo").ToString + DtDetalleFirmas(i)("Nombre") = Vta.DtFirmas(i)("Nombre").ToString + DtDetalleFirmas(i)("Puesto") = Vta.DtFirmas(i)("Puesto").ToString + DtDetalleFirmas(i)("Lado") = Vta.DtFirmas(i)("Lado").ToString.ToEntero + End If + Next i + + Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = DtDetalleFirmas} + lrds.Add(rds) + Else + Dim rds As New ReportDataSource With {.Name = "DsOC", .Value = Vta.DtDetalle} + lrds.Add(rds) + End If + + Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(Vta.DtDeduccion IsNot Nothing, Vta.DtDeduccion, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds1) + + 'DETALLE FIRMAS + Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(Vta.DtFirmas IsNot Nothing, Vta.DtFirmas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds2) + + Dim rds3 As New ReportDataSource With {.Name = "DataSet3", .Value = If(Vta.DtDesgloseImpuestos IsNot Nothing, Vta.DtDesgloseImpuestos, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds3) + + Dim rds4 As New ReportDataSource With {.Name = "DataSet4", .Value = If(Vta.DtDocumentosRelacionados IsNot Nothing, Vta.DtDocumentosRelacionados, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds4) + + Dim rds5 As New ReportDataSource With {.Name = "DataSet5", .Value = If(Vta.DtNCVinculadas IsNot Nothing, Vta.DtNCVinculadas, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte + lrds.Add(rds5) + If UsuarioActual.CveEmpresa = 141 AndAlso RutaFormato.Contains("Factura") Then params.Add(New ReportParameter("Kilometraje", Vta.Kilometraje.ToString)) - End If - 'Imprime los parametros - 'Dim ast As New StringBuilder - 'For Each par As ReportParameter In params - ' ast.AppendFormat("{0}{1}", par.Name, vbCrLf) - 'Next - 'ast.ToString.GuardaLog() - - Dim Archivo As New System.IO.FileInfo(RutaFormato) - If Archivo.Exists Then - - retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing) - Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) - If Guardar Then - If Not ArchivoPDF.Exists Then - Try - DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) - DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - Else - Try - ArchivoPDF.Delete() - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - End If - End If - Else - params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) - retorno = StreamPDF(RutaFormatoDefault, lrds, params, NombreArchivo, "PDF", MR:=Nothing) - End If - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) - End Try - - Return retorno - End Function - Private Function ValorNodoXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String - Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) - If o Is Nothing Then - Return Retorno - Else - Return o.Value - End If - End Function - Public Sub GenerarFacturaVenta(CveVenta As Integer) - Dim ObjVentas As New ClsVentas - Dim Vta As Modelos.Factura = Nothing - - Dim TmpDTImpuestos = New DataTable - TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) - TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) - TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - Dim dtVentas As DataTable = ObjVentas.DtResultados - - ' se rellenan los campos de la factura - Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) - - Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString - 'se rellena la sucursal - Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) - Vta.Cliente = New Modelos.ClienteModel - Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString - Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString - Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString - Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString - Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString - Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString - Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString - Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString - Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString - Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString - Vta.AtencionA = dtVentas(0)("AtencionA").ToString - Vta.TelefonoGenerico = dtVentas(0)("TelefonoGenerico").ToString - Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString - Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString - Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString - Vta.Cliente.Mail = dtVentas(0)("Mail").ToString - Vta.RefDocto = dtVentas(0)("Ref").ToString - Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero - Vta.Version = dtVentas(0)("Version").ToString - - Vta.ClienteSucursal = New Modelos.SucursalModel - Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString - Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString - Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString - Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString - Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString - Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString - Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString - Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString - Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString - Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString - Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString - Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString - - Vta.EnviarA = New Modelos.EnviarAModel - Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero - Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString - Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString - Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString - Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString - Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString - - Dim DR As DataRow = TmpDTImpuestos.NewRow() - If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then - If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("IVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) - - 'solo para eclipse, que muesre un subtotal debajo de IVA - If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 1000 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - End If - - If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra - Vta.DtDetalle = ObjVentas.DtResultados - End If - - If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then - If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then - Dim dtImpuesto As DataTable = ObjVentas.DtResultados - If dtImpuesto.Rows.Count > 0 Then - For Each Row As DataRow In dtImpuesto.Rows - Dim Orden = 80 - If Row("Importe").ToString.ToDouble <> 0 Then - DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString - DR("Importe") = Row("Importe").ToString.ToDouble - DR("Orden") = Orden - TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - Orden = Orden + 1 - End If - Next - End If - Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") - Else - Vta.DtDeduccion = ObjVentas.DtResultados - End If - End If - - If ObjVentas.GetVentasFirmas(CveVenta) Then - Vta.DtFirmas = ObjVentas.DtResultados - End If - End If - ObjVentas.Dispose() - - If Not IsNothing(Vta) Then - PdfFactura(Vta) - Vta = Nothing - End If - - End Sub -#End Region - -#Region " PDF OC NEW 2.0" - Public Function NewGeneraBytesOC(tCveOrdenCompra As Integer, Optional MR As ReportViewer = Nothing, Optional ConBitacora As Boolean = False) As Byte() - Dim bytes As Byte() = Nothing - Dim CveEmpresaActual As Integer - Dim TmpDTEnvioDireccion As DataTable - Dim params As New List(Of ReportParameter) - - Try - - Dim DtDetalle As DataTable = Nothing - Dim ObjOC As New ClsOC - - If ObjOC.GetOC(tCveOrdenCompra, UsuarioActual.CveEmpresa, CveUsuario:=UsuarioActual.CveUsuario) Then - CveEmpresaActual = ObjOC.CveEmpresa - - Dim ObjEmpresa As New ClsSisEmpresas() - Dim EmpresaActual As New Empresa - If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then - 'Session("Empresa") = ObjEmpresa - If ObjEmpresa.GetEmpresasFuncionalidades(CveEmpresaActual) Then - Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados - - Dim EmpresasFuncionalidades As New HybridDictionary - For Each Row As Data.DataRow In dttmp.Rows - EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) - Next - ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) - End If - - EmpresaActual = ObjEmpresa.Empresa - End If - ObjEmpresa.Dispose() - - Dim dtOC As DataTable = ObjOC.DtResultados - If ObjOC.GetOrdenesDetalle(ObjOC.CveOrdenCompra) Then 'Obtenemos el Detalle de la Oorden de Compra - DtDetalle = ObjOC.DtResultados - End If - - - 'Obtenemos la sucursal de la OC PARA COMPU PROVEEDORES - Dim DomicilioSucursal As String = "" - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - Dim SBDomicilioSucursal As New StringBuilder() - Dim CiudadSucursal As String = "" - Dim ObjClientes As New ClsClientes - - If ObjOC.GetSucursalOC(ObjOC.CveOrdenCompra) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then - - CiudadSucursal = String.Format("{0},{1}", ObjOC.SucMunicipio, ObjOC.SucEstado) - - SBDomicilioSucursal.AppendFormat("{0}", ObjOC.SucCalle) - If ObjOC.SucNoExt.Length > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", ObjOC.SucNoExt) - If ObjOC.SucNoInt.Length > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", ObjOC.SucNoInt) - If ObjOC.SucColonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", ObjOC.SucColonia) - If ObjOC.SucCP.Length > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", ObjOC.SucCP) - If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) - If ObjOC.SucPais.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", ObjOC.SucPais) - - DomicilioSucursal = SBDomicilioSucursal.ToString - params.Add(New ReportParameter("Proyecto", ObjOC.SucSubProyecto.ToString)) - params.Add(New ReportParameter("Telefono", ObjOC.SucTelefono.ToString)) - - 'Obtenemos la direccion envio PARA COMPU PROVEEDORES - If ObjOC.CveDireccionEnvio > 0 Then - Dim StrEnvioDi As New StringBuilder - - If ObjClientes.DireccionEnvioGet(ObjOC.CveDireccionEnvio, ObjOC.CveCliente, -1) Then - TmpDTEnvioDireccion = ObjClientes.DtResultados - Else - TmpDTEnvioDireccion = Nothing - End If - ObjClientes.Dispose() - - - If TmpDTEnvioDireccion IsNot Nothing AndAlso TmpDTEnvioDireccion.FiltraParametros(String.Format("CveDireccionEnvio = {0}", ObjOC.CveDireccionEnvio)).Rows.Count > 0 Then - StrEnvioDi.AppendFormat("{0}", TmpDTEnvioDireccion(0)("EnvioDireccion")) - If TmpDTEnvioDireccion(0)("EnvioNoExt") IsNot Nothing AndAlso TmpDTEnvioDireccion(0)("EnvioNoExt").ToString.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", TmpDTEnvioDireccion(0)("EnvioNoExt")) - If TmpDTEnvioDireccion(0)("EnvioNoInt") IsNot Nothing AndAlso TmpDTEnvioDireccion(0)("EnvioNoInt").ToString.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", TmpDTEnvioDireccion(0)("EnvioNoInt")) - - params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New ReportParameter("EnvioNoExt", TmpDTEnvioDireccion(0)("EnvioNoExt").ToString)) - params.Add(New ReportParameter("EnvioNoInt", TmpDTEnvioDireccion(0)("EnvioNoInt").ToString)) - params.Add(New ReportParameter("EnvioColonia", TmpDTEnvioDireccion(0)("EnvioColonia").ToString)) - params.Add(New ReportParameter("EnvioCiudad", TmpDTEnvioDireccion(0)("EnvioCiudad").ToString)) - params.Add(New ReportParameter("EnvioEstado", TmpDTEnvioDireccion(0)("EnvioEstado").ToString)) - params.Add(New ReportParameter("EnvioContacto", TmpDTEnvioDireccion(0)("EnvioContacto").ToString)) - params.Add(New ReportParameter("EnvioDepartamento", TmpDTEnvioDireccion(0)("EnvioDepartamento").ToString)) - params.Add(New ReportParameter("EnvioCP", TmpDTEnvioDireccion(0)("EnvioCP").ToString)) - params.Add(New ReportParameter("EnvioTel", TmpDTEnvioDireccion(0)("EnvioTel").ToString)) - End If - - Else - - If ObjOC.LugarEntrega.ToString IsNot Nothing AndAlso ObjOC.LugarEntrega.ToString = "" Then - Dim StrEnvioDi As New StringBuilder - StrEnvioDi.AppendFormat("{0}", ObjOC.SucCalle) - If ObjOC.SucNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", ObjOC.SucNoExt) - If ObjOC.SucNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", ObjOC.SucNoInt) - params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) - params.Add(New ReportParameter("EnvioColonia", If(ObjOC.SucColonia.Length > 0, ObjOC.SucColonia, ""))) - params.Add(New ReportParameter("EnvioCiudad", If(ObjOC.SucMunicipio.Length > 0, ObjOC.SucMunicipio, ""))) - params.Add(New ReportParameter("EnvioEstado", If(ObjOC.SucEstado.Length > 0, ObjOC.SucEstado, ""))) - params.Add(New ReportParameter("EnvioCP", If(ObjOC.SucCP.Length > 0, ObjOC.SucCP, ""))) - Else - params.Add(New ReportParameter("EnvioDireccion", ObjOC.LugarEntrega)) - params.Add(New ReportParameter("LugarEntrega", ObjOC.LugarEntrega)) - End If - params.Add(New ReportParameter("EnvioTel", ObjOC.SucTelefono.ToString)) - - - End If - - End If - End If - - - Dim CveUsuarioSol As Integer = dtOC(0)("CveUsuarioSolicito").ToString.ToEntero - Dim CveUsuarioAut As Integer = dtOC(0)("CveUsuarioAutorizo").ToString.ToEntero - Dim drSol As DataRow = GlobalDTUsuarios(CveUsuarioSol, EmpresaActual.CveEmpresa).FiltroPrimero("") 'DataRow (incluye el NOMBRE de quien SOLICITÓ la OC) - Dim drAut As DataRow = GlobalDTUsuarios(CveUsuarioAut, EmpresaActual.CveEmpresa).FiltroPrimero("") 'DataRow (incluye el NOMBRE de quien AUTORIZÓ la OC) - - Dim CvePersonalSol, CvePersonalAut As Integer - - Dim PuestoSol As String = "" - Dim PuestoAut As String = "" - - If drSol IsNot Nothing AndAlso drSol("CvePersonal").ToString.ToEntero > 0 Then CvePersonalSol = drSol("CvePersonal").ToString.ToEntero - If drAut IsNot Nothing AndAlso drAut("CvePersonal").ToString.ToEntero > 0 Then CvePersonalAut = drAut("CvePersonal").ToString.ToEntero - - Dim ObjRH As New ClsRH() - If ObjRH.GetPersonal(CvePersonalSol, EmpresaActual.CveEmpresa) AndAlso ObjRH.DtResultados.Rows.Count > 0 Then - PuestoSol = ObjRH.DtResultados(0)("Puesto").ToString - End If - If ObjRH.GetPersonal(CvePersonalAut, EmpresaActual.CveEmpresa) AndAlso ObjRH.DtResultados.Rows.Count > 0 Then - PuestoAut = ObjRH.DtResultados(0)("Puesto").ToString - End If - ObjRH.Dispose() - - Dim TipoCambio As String - If ObjOC.CveMoneda = 1 Then - TipoCambio = "1.00" - Else - TipoCambio = GlobalTipoCambio.ToString() - End If - - - - Dim nombreautorizo As String = dtOC(0)("UsuarioAutorizo").ToString - - 'If EmpresaActual = 48 Then - ' nombreautorizo = "Lic. LUIS JORGE CONTRERAS LANDGRAVE" - 'End If - Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\OC.rdlc", EmpresaActual.Ruta)) + End If + 'Imprime los parametros + 'Dim ast As New StringBuilder + 'For Each par As ReportParameter In params + ' ast.AppendFormat("{0}{1}", par.Name, vbCrLf) + 'Next + 'ast.ToString.GuardaLog() + + Dim Archivo As New System.IO.FileInfo(RutaFormato) + If Archivo.Exists Then + + retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing) + Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio)) + If Guardar Then + If Not ArchivoPDF.Exists Then + Try + DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) + DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + Else + Try + ArchivoPDF.Delete() + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + End If + End If + Else + params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) + retorno = StreamPDF(RutaFormatoDefault, lrds, params, NombreArchivo, "PDF", MR:=Nothing) + End If + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) + End Try + + Return retorno + End Function + Private Function ValorNodoXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String + Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) + If o Is Nothing Then + Return Retorno + Else + Return o.Value + End If + End Function + Public Sub GenerarFacturaVenta(CveVenta As Integer) + Dim ObjVentas As New ClsVentas + Dim Vta As Modelos.Factura = Nothing + + Dim TmpDTImpuestos = New DataTable + TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) + TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) + TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + Dim dtVentas As DataTable = ObjVentas.DtResultados + + ' se rellenan los campos de la factura + Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) + + Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString + 'se rellena la sucursal + Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) + Vta.Cliente = New Modelos.ClienteModel + Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString + Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString + Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString + Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString + Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString + Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString + Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString + Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString + Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString + Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString + Vta.AtencionA = dtVentas(0)("AtencionA").ToString + Vta.TelefonoGenerico = dtVentas(0)("TelefonoGenerico").ToString + Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString + Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString + Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString + Vta.Cliente.Mail = dtVentas(0)("Mail").ToString + Vta.RefDocto = dtVentas(0)("Ref").ToString + Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero + Vta.Version = dtVentas(0)("Version").ToString + + Vta.ClienteSucursal = New Modelos.SucursalModel + Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString + Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString + Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString + Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString + Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString + Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString + Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString + Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString + Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString + Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString + Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString + Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString + + Vta.EnviarA = New Modelos.EnviarAModel + Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero + Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString + Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString + Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString + Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString + Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString + + Dim DR As DataRow = TmpDTImpuestos.NewRow() + If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then + If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("IVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) + + 'solo para eclipse, que muesre un subtotal debajo de IVA + If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 1000 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + End If + + If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra + Vta.DtDetalle = ObjVentas.DtResultados + End If + + If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then + If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then + Dim dtImpuesto As DataTable = ObjVentas.DtResultados + If dtImpuesto.Rows.Count > 0 Then + For Each Row As DataRow In dtImpuesto.Rows + Dim Orden = 80 + If Row("Importe").ToString.ToDouble <> 0 Then + DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString + DR("Importe") = Row("Importe").ToString.ToDouble + DR("Orden") = Orden + TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + Orden = Orden + 1 + End If + Next + End If + Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") + Else + Vta.DtDeduccion = ObjVentas.DtResultados + End If + End If + + If ObjVentas.GetVentasFirmas(CveVenta) Then + Vta.DtFirmas = ObjVentas.DtResultados + End If + End If + ObjVentas.Dispose() + + If Not IsNothing(Vta) Then + PdfFactura(Vta) + Vta = Nothing + End If + + End Sub +#End Region + +#Region " PDF OC NEW 2.0" + Public Function NewGeneraBytesOC(tCveOrdenCompra As Integer, Optional MR As ReportViewer = Nothing, Optional ConBitacora As Boolean = False) As Byte() + Dim bytes As Byte() = Nothing + Dim CveEmpresaActual As Integer + Dim TmpDTEnvioDireccion As DataTable + Dim params As New List(Of ReportParameter) + + Try + + Dim DtDetalle As DataTable = Nothing + Dim ObjOC As New ClsOC + + If ObjOC.GetOC(tCveOrdenCompra, UsuarioActual.CveEmpresa, CveUsuario:=UsuarioActual.CveUsuario) Then + CveEmpresaActual = ObjOC.CveEmpresa + + Dim ObjEmpresa As New ClsSisEmpresas() + Dim EmpresaActual As New Empresa + If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then + 'Session("Empresa") = ObjEmpresa + If ObjEmpresa.GetEmpresasFuncionalidades(CveEmpresaActual) Then + Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados + + Dim EmpresasFuncionalidades As New HybridDictionary + For Each Row As Data.DataRow In dttmp.Rows + EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) + Next + ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) + End If + + EmpresaActual = ObjEmpresa.Empresa + End If + ObjEmpresa.Dispose() + + Dim dtOC As DataTable = ObjOC.DtResultados + If ObjOC.GetOrdenesDetalle(ObjOC.CveOrdenCompra) Then 'Obtenemos el Detalle de la Oorden de Compra + DtDetalle = ObjOC.DtResultados + End If + + + 'Obtenemos la sucursal de la OC PARA COMPU PROVEEDORES + Dim DomicilioSucursal As String = "" + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + Dim SBDomicilioSucursal As New StringBuilder() + Dim CiudadSucursal As String = "" + Dim ObjClientes As New ClsClientes + + If ObjOC.GetSucursalOC(ObjOC.CveOrdenCompra) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then + + CiudadSucursal = String.Format("{0},{1}", ObjOC.SucMunicipio, ObjOC.SucEstado) + + SBDomicilioSucursal.AppendFormat("{0}", ObjOC.SucCalle) + If ObjOC.SucNoExt.Length > 0 Then SBDomicilioSucursal.AppendFormat(" No.Ext: {0}", ObjOC.SucNoExt) + If ObjOC.SucNoInt.Length > 0 Then SBDomicilioSucursal.AppendFormat(", No.Int: {0}", ObjOC.SucNoInt) + If ObjOC.SucColonia.Length > 0 Then SBDomicilioSucursal.AppendFormat(", Col: {0}", ObjOC.SucColonia) + If ObjOC.SucCP.Length > 0 Then SBDomicilioSucursal.AppendFormat(", CP: {0}", ObjOC.SucCP) + If CiudadSucursal.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", CiudadSucursal) + If ObjOC.SucPais.Length > 0 Then SBDomicilioSucursal.AppendFormat(", {0}", ObjOC.SucPais) + + DomicilioSucursal = SBDomicilioSucursal.ToString + params.Add(New ReportParameter("Proyecto", ObjOC.SucSubProyecto.ToString)) + params.Add(New ReportParameter("Telefono", ObjOC.SucTelefono.ToString)) + + 'Obtenemos la direccion envio PARA COMPU PROVEEDORES + If ObjOC.CveDireccionEnvio > 0 Then + Dim StrEnvioDi As New StringBuilder + + If ObjClientes.DireccionEnvioGet(ObjOC.CveDireccionEnvio, ObjOC.CveCliente, -1) Then + TmpDTEnvioDireccion = ObjClientes.DtResultados + Else + TmpDTEnvioDireccion = Nothing + End If + ObjClientes.Dispose() + + + If TmpDTEnvioDireccion IsNot Nothing AndAlso TmpDTEnvioDireccion.FiltraParametros(String.Format("CveDireccionEnvio = {0}", ObjOC.CveDireccionEnvio)).Rows.Count > 0 Then + StrEnvioDi.AppendFormat("{0}", TmpDTEnvioDireccion(0)("EnvioDireccion")) + If TmpDTEnvioDireccion(0)("EnvioNoExt") IsNot Nothing AndAlso TmpDTEnvioDireccion(0)("EnvioNoExt").ToString.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", TmpDTEnvioDireccion(0)("EnvioNoExt")) + If TmpDTEnvioDireccion(0)("EnvioNoInt") IsNot Nothing AndAlso TmpDTEnvioDireccion(0)("EnvioNoInt").ToString.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", TmpDTEnvioDireccion(0)("EnvioNoInt")) + + params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New ReportParameter("EnvioNoExt", TmpDTEnvioDireccion(0)("EnvioNoExt").ToString)) + params.Add(New ReportParameter("EnvioNoInt", TmpDTEnvioDireccion(0)("EnvioNoInt").ToString)) + params.Add(New ReportParameter("EnvioColonia", TmpDTEnvioDireccion(0)("EnvioColonia").ToString)) + params.Add(New ReportParameter("EnvioCiudad", TmpDTEnvioDireccion(0)("EnvioCiudad").ToString)) + params.Add(New ReportParameter("EnvioEstado", TmpDTEnvioDireccion(0)("EnvioEstado").ToString)) + params.Add(New ReportParameter("EnvioContacto", TmpDTEnvioDireccion(0)("EnvioContacto").ToString)) + params.Add(New ReportParameter("EnvioDepartamento", TmpDTEnvioDireccion(0)("EnvioDepartamento").ToString)) + params.Add(New ReportParameter("EnvioCP", TmpDTEnvioDireccion(0)("EnvioCP").ToString)) + params.Add(New ReportParameter("EnvioTel", TmpDTEnvioDireccion(0)("EnvioTel").ToString)) + End If + + Else + + If ObjOC.LugarEntrega.ToString IsNot Nothing AndAlso ObjOC.LugarEntrega.ToString = "" Then + Dim StrEnvioDi As New StringBuilder + StrEnvioDi.AppendFormat("{0}", ObjOC.SucCalle) + If ObjOC.SucNoExt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Ext: {0}", ObjOC.SucNoExt) + If ObjOC.SucNoInt.Length > 0 Then StrEnvioDi.AppendFormat(", No.Int: {0}", ObjOC.SucNoInt) + params.Add(New ReportParameter("EnvioDireccion", StrEnvioDi.ToString)) + params.Add(New ReportParameter("EnvioColonia", If(ObjOC.SucColonia.Length > 0, ObjOC.SucColonia, ""))) + params.Add(New ReportParameter("EnvioCiudad", If(ObjOC.SucMunicipio.Length > 0, ObjOC.SucMunicipio, ""))) + params.Add(New ReportParameter("EnvioEstado", If(ObjOC.SucEstado.Length > 0, ObjOC.SucEstado, ""))) + params.Add(New ReportParameter("EnvioCP", If(ObjOC.SucCP.Length > 0, ObjOC.SucCP, ""))) + Else + params.Add(New ReportParameter("EnvioDireccion", ObjOC.LugarEntrega)) + params.Add(New ReportParameter("LugarEntrega", ObjOC.LugarEntrega)) + End If + params.Add(New ReportParameter("EnvioTel", ObjOC.SucTelefono.ToString)) + + + End If + + End If + End If + + + Dim CveUsuarioSol As Integer = dtOC(0)("CveUsuarioSolicito").ToString.ToEntero + Dim CveUsuarioAut As Integer = dtOC(0)("CveUsuarioAutorizo").ToString.ToEntero + Dim drSol As DataRow = GlobalDTUsuarios(CveUsuarioSol, EmpresaActual.CveEmpresa).FiltroPrimero("") 'DataRow (incluye el NOMBRE de quien SOLICITÓ la OC) + Dim drAut As DataRow = GlobalDTUsuarios(CveUsuarioAut, EmpresaActual.CveEmpresa).FiltroPrimero("") 'DataRow (incluye el NOMBRE de quien AUTORIZÓ la OC) + + Dim CvePersonalSol, CvePersonalAut As Integer + + Dim PuestoSol As String = "" + Dim PuestoAut As String = "" + + If drSol IsNot Nothing AndAlso drSol("CvePersonal").ToString.ToEntero > 0 Then CvePersonalSol = drSol("CvePersonal").ToString.ToEntero + If drAut IsNot Nothing AndAlso drAut("CvePersonal").ToString.ToEntero > 0 Then CvePersonalAut = drAut("CvePersonal").ToString.ToEntero + + Dim ObjRH As New ClsRH() + If ObjRH.GetPersonal(CvePersonalSol, EmpresaActual.CveEmpresa) AndAlso ObjRH.DtResultados.Rows.Count > 0 Then + PuestoSol = ObjRH.DtResultados(0)("Puesto").ToString + End If + If ObjRH.GetPersonal(CvePersonalAut, EmpresaActual.CveEmpresa) AndAlso ObjRH.DtResultados.Rows.Count > 0 Then + PuestoAut = ObjRH.DtResultados(0)("Puesto").ToString + End If + ObjRH.Dispose() + + Dim TipoCambio As String + If ObjOC.CveMoneda = 1 Then + TipoCambio = "1.00" + Else + TipoCambio = GlobalTipoCambio.ToString() + End If + + + + Dim nombreautorizo As String = dtOC(0)("UsuarioAutorizo").ToString + + 'If EmpresaActual = 48 Then + ' nombreautorizo = "Lic. LUIS JORGE CONTRERAS LANDGRAVE" + 'End If + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\OC.rdlc", EmpresaActual.Ruta)) If Not Archivo.Exists OrElse EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 122, 126) Then params.Add(New ReportParameter("Descuento", DtDetalle.SUM("Descuento").ToString.FormatoNumero(2))) - End If - 'DATOS PARA DESCUENTO - If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 122, 126) Then 'EMPRESAS QUE YA TIENEN EL AJUSTE EN EL FORMATO - params.Add(New ReportParameter("SubTotal", ObjOC.SubTotal.ToString)) - params.Add(New ReportParameter("SubTotal2", DtDetalle.SUM("Total").ToString)) - Else - params.Add(New ReportParameter("SubTotal", DtDetalle.SUM("Total").ToString)) - End If - - If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 122) Then - - params.Add(New ReportParameter("ReferenciaBancaria", dtOC(0)("BancoCuenta").ToString)) - params.Add(New ReportParameter("ReferenciaBanco", dtOC(0)("BancoNombre").ToString)) - params.Add(New ReportParameter("Justificacion", dtOC(0)("Justificacion").ToString)) - params.Add(New ReportParameter("TipoTermino", ObjOC.TipoTermino.ToString)) - params.Add(New ReportParameter("Proyecto", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("SubProyecto").ToString, ""))) - Else - params.Add(New ReportParameter("Proyecto", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) - End If - params.Add(New ReportParameter("CentroCostos", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) - - params.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) - params.Add(New ReportParameter("ProveedorNombre", ObjOC.RazonSocial)) - params.Add(New ReportParameter("ProveedorLugar", ObjOC.LugarEntrega)) - params.Add(New ReportParameter("Estatus", ObjOC.Estatus)) - params.Add(New ReportParameter("Descripcion", ObjOC.Descripcion)) - params.Add(New ReportParameter("Asunto", ObjOC.Justificacion)) - params.Add(New ReportParameter("FechaEntrega", ObjOC.FechaEstimadaEntrega.ToString("dd/MM/yyyy"))) - params.Add(New ReportParameter("FechaSolicitud", String.Format("{0}T{1}", ObjOC.Fecha.ToString("dd/MM/yyyy"), ObjOC.HoraElaboracion.ToString))) - - params.Add(New ReportParameter("ProveedorDireccion", If(ObjOC.CveProveedorSucursal > 0, ObjOC.SucursalDireccion, ObjOC.Direccion))) - params.Add(New ReportParameter("ProveedorTel", If(ObjOC.CveProveedorSucursal > 0, ObjOC.SucursalTelefono, ObjOC.Telefono))) - params.Add(New ReportParameter("ProveedorRFC", ObjOC.RFC)) - params.Add(New ReportParameter("IVA", ObjOC.IVA.ToString)) - params.Add(New ReportParameter("RetIVA", ObjOC.RetIVA.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("RetISR", ObjOC.RetISR.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("IEPS", ObjOC.IEPS.ToString.FormatoNumero(2))) - params.Add(New ReportParameter("Total", ObjOC.Total.ToString)) - params.Add(New ReportParameter("ImporteLetra", (ObjOC.Total).ToString.ToDouble.Texto2Letras(ObjOC.CveMoneda))) - params.Add(New ReportParameter("CorreoControl", If(drAut IsNot Nothing, drAut("Correo").ToString, ""))) - params.Add(New ReportParameter("Moneda", ObjOC.Moneda)) - params.Add(New ReportParameter("TipoCambio", TipoCambio)) - params.Add(New ReportParameter("NombreSolicito", dtOC(0)("UsuarioSolicito").ToString)) 'drSol("Nombre").ToString)) - params.Add(New ReportParameter("PuestoSolicito", PuestoSol)) 'drPuestoSol("Puesto").ToString - params.Add(New ReportParameter("NombreAutorizo", nombreautorizo)) - params.Add(New ReportParameter("PuestoAutorizo", PuestoAut)) 'drPuestoAut("Puesto").ToString - params.Add(New ReportParameter("TipoOC", If(ObjOC.Tipo = "OC", "Orden de Compra", "Requisición"))) - params.Add(New ReportParameter("UsoCFDI", ObjOC.UsoCFDI)) - - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - - params.Add(New ReportParameter("FolioAdicional", dtOC(0)("FolioAdicional").ToString)) - params.Add(New ReportParameter("Vendedor", dtOC(0)("Vendedor").ToString)) - params.Add(New ReportParameter("Observacion", dtOC(0)("PrioridadObservacion").ToString)) - params.Add(New ReportParameter("EntregarA", ObjOC.LugarEntrega)) - params.Add(New ReportParameter("EntregaDirecta", ObjOC.EntregaDirecta.ToString)) - params.Add(New ReportParameter("NombreCliente", ObjOC.NombreCliente.ToString)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) - params.Add(New ReportParameter("DomicilioSucursal", DomicilioSucursal)) - params.Add(New ReportParameter("ProveedorContacto", ObjOC.ProveedorContacto)) - params.Add(New ReportParameter("Comprador", ObjOC.UsuarioAsignado)) - End If - - 'params.Add(New ReportParameter("FechaOC", ObjOC.Fecha.ToShortDateString)) - Dim FirmaSol As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", EmpresaActual.Ruta, CveUsuarioSol)) - params.Add(New ReportParameter("FirmaSolicito", If(FirmaSol.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", EmpresaActual.CveEmpresa, CveUsuarioSol))).AbsoluteUri, ""))) - Dim FirmaAut As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", EmpresaActual.Ruta, CveUsuarioAut)) + End If + 'DATOS PARA DESCUENTO + If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 122, 126) Then 'EMPRESAS QUE YA TIENEN EL AJUSTE EN EL FORMATO + params.Add(New ReportParameter("SubTotal", ObjOC.SubTotal.ToString)) + params.Add(New ReportParameter("SubTotal2", DtDetalle.SUM("Total").ToString)) + Else + params.Add(New ReportParameter("SubTotal", DtDetalle.SUM("Total").ToString)) + End If + + If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 122) Then + + params.Add(New ReportParameter("ReferenciaBancaria", dtOC(0)("BancoCuenta").ToString)) + params.Add(New ReportParameter("ReferenciaBanco", dtOC(0)("BancoNombre").ToString)) + params.Add(New ReportParameter("Justificacion", dtOC(0)("Justificacion").ToString)) + params.Add(New ReportParameter("TipoTermino", ObjOC.TipoTermino.ToString)) + params.Add(New ReportParameter("Proyecto", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("SubProyecto").ToString, ""))) + Else + params.Add(New ReportParameter("Proyecto", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) + End If + params.Add(New ReportParameter("CentroCostos", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) + + params.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) + params.Add(New ReportParameter("ProveedorNombre", ObjOC.RazonSocial)) + params.Add(New ReportParameter("ProveedorLugar", ObjOC.LugarEntrega)) + params.Add(New ReportParameter("Estatus", ObjOC.Estatus)) + params.Add(New ReportParameter("Descripcion", ObjOC.Descripcion)) + params.Add(New ReportParameter("Asunto", ObjOC.Justificacion)) + params.Add(New ReportParameter("FechaEntrega", ObjOC.FechaEstimadaEntrega.ToString("dd/MM/yyyy"))) + params.Add(New ReportParameter("FechaSolicitud", String.Format("{0}T{1}", ObjOC.Fecha.ToString("dd/MM/yyyy"), ObjOC.HoraElaboracion.ToString))) + + params.Add(New ReportParameter("ProveedorDireccion", If(ObjOC.CveProveedorSucursal > 0, ObjOC.SucursalDireccion, ObjOC.Direccion))) + params.Add(New ReportParameter("ProveedorTel", If(ObjOC.CveProveedorSucursal > 0, ObjOC.SucursalTelefono, ObjOC.Telefono))) + params.Add(New ReportParameter("ProveedorRFC", ObjOC.RFC)) + params.Add(New ReportParameter("IVA", ObjOC.IVA.ToString)) + params.Add(New ReportParameter("RetIVA", ObjOC.RetIVA.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("RetISR", ObjOC.RetISR.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("IEPS", ObjOC.IEPS.ToString.FormatoNumero(2))) + params.Add(New ReportParameter("Total", ObjOC.Total.ToString)) + params.Add(New ReportParameter("ImporteLetra", (ObjOC.Total).ToString.ToDouble.Texto2Letras(ObjOC.CveMoneda))) + params.Add(New ReportParameter("CorreoControl", If(drAut IsNot Nothing, drAut("Correo").ToString, ""))) + params.Add(New ReportParameter("Moneda", ObjOC.Moneda)) + params.Add(New ReportParameter("TipoCambio", TipoCambio)) + params.Add(New ReportParameter("NombreSolicito", dtOC(0)("UsuarioSolicito").ToString)) 'drSol("Nombre").ToString)) + params.Add(New ReportParameter("PuestoSolicito", PuestoSol)) 'drPuestoSol("Puesto").ToString + params.Add(New ReportParameter("NombreAutorizo", nombreautorizo)) + params.Add(New ReportParameter("PuestoAutorizo", PuestoAut)) 'drPuestoAut("Puesto").ToString + params.Add(New ReportParameter("TipoOC", If(ObjOC.Tipo = "OC", "Orden de Compra", "Requisición"))) + params.Add(New ReportParameter("UsoCFDI", ObjOC.UsoCFDI)) + + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + + params.Add(New ReportParameter("FolioAdicional", dtOC(0)("FolioAdicional").ToString)) + params.Add(New ReportParameter("Vendedor", dtOC(0)("Vendedor").ToString)) + params.Add(New ReportParameter("Observacion", dtOC(0)("PrioridadObservacion").ToString)) + params.Add(New ReportParameter("EntregarA", ObjOC.LugarEntrega)) + params.Add(New ReportParameter("EntregaDirecta", ObjOC.EntregaDirecta.ToString)) + params.Add(New ReportParameter("NombreCliente", ObjOC.NombreCliente.ToString)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) + params.Add(New ReportParameter("DomicilioSucursal", DomicilioSucursal)) + params.Add(New ReportParameter("ProveedorContacto", ObjOC.ProveedorContacto)) + params.Add(New ReportParameter("Comprador", ObjOC.UsuarioAsignado)) + End If + + 'params.Add(New ReportParameter("FechaOC", ObjOC.Fecha.ToShortDateString)) + Dim FirmaSol As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", EmpresaActual.Ruta, CveUsuarioSol)) + params.Add(New ReportParameter("FirmaSolicito", If(FirmaSol.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", EmpresaActual.CveEmpresa, CveUsuarioSol))).AbsoluteUri, ""))) + Dim FirmaAut As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", EmpresaActual.Ruta, CveUsuarioAut)) params.Add(New ReportParameter("FirmaAutorizo", If(FirmaAut.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", EmpresaActual.CveEmpresa, CveUsuarioAut))).AbsoluteUri, ""))) - If Archivo.Exists Then - bytes = StreamPDF(String.Format("{0}Formatos\OC.rdlc", EmpresaActual.Ruta), DtDetalle, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) - Else - params.Add(New ReportParameter("Empresa", EmpresaActual.Empresa)) - bytes = StreamPDF("Empresas\Grales\Formatos\OC.rdlc", DtDetalle, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) - End If - - If ConBitacora Then - Dim dttemp As New DataTable - Dim ObjEventoBitacora As New ClsOIEventos() - If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, EmpresaActual.CveEmpresa, CveOC:=tCveOrdenCompra) Then - dttemp = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") - End If - ObjEventoBitacora.Dispose() - If Not IsNothing(dttemp) AndAlso dttemp.Rows.Count > 0 Then - - Dim paramsest As New List(Of ReportParameter) - paramsest.Add(New ReportParameter("Empresa", EmpresaActual.Empresa)) - paramsest.Add(New ReportParameter("Titulo", "Bitácora de órdenes de compra")) - paramsest.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) - paramsest.Add(New ReportParameter("TipoOC", If(ObjOC.Tipo = "OC", "Orden de Compra", "Requisición"))) - Dim bytes2 As Byte() - bytes2 = StreamPDF("Empresas\Grales\Formatos\Bitacora.rdlc", dttemp, paramsest, $"OC_{ObjOC.Folio.ToString}", MR:=MR) - Using ms As New MemoryStream() - Using document As New iTextSharp.text.Document() - Using copy As New PdfCopy(document, ms) - document.Open() - - Dim reader As New PdfReader(bytes) - ' loop over the pages in that document - Dim n As Integer = reader.NumberOfPages - Dim page As Integer = 0 - While page < n - page = page + 1 - copy.AddPage(copy.GetImportedPage(reader, page)) - End While - - - reader = New PdfReader(bytes2) - ' loop over the pages in that document - n = reader.NumberOfPages - page = 0 - While page < n - page = page + 1 - copy.AddPage(copy.GetImportedPage(reader, page)) - End While - - End Using - End Using - bytes = ms.ToArray() - End Using - End If - dttemp.Dispose() - End If - - End If - ObjOC.Dispose() - - DtDetalle.Dispose() - - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", tCveOrdenCompra, ex.Message)) - End Try - - Return bytes - End Function - - Public Function NewGeneraOCCotizacion(tCveOrdenCompra As Integer, Optional MR As ReportViewer = Nothing, Optional ConBitacora As Boolean = False) As Byte() - Dim bytes As Byte() = Nothing - Dim CveEmpresaActual As Integer - - Try - Dim DtDetalle As DataTable = Nothing - Dim ObjOC As New ClsOC - - If ObjOC.GetOC(tCveOrdenCompra, UsuarioActual.CveEmpresa, CveUsuario:=UsuarioActual.CveUsuario) Then - CveEmpresaActual = ObjOC.CveEmpresa - - Dim ObjEmpresa As New ClsSisEmpresas() - Dim EmpresaActual As New Empresa - If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then - EmpresaActual = ObjEmpresa.Empresa - End If - ObjEmpresa.Dispose() - - '-----------------------COTIZACIONES-------------------------- - Dim params As New List(Of ReportParameter) - Dim NumCotizaciones = 0 - Dim DtCotizaciones As New DataTable - Dim ProveedoresCotizacion = New ArrayList - Dim Ds As DataSet = ObjOC.GetCotizacionesTabla(tCveOrdenCompra) - If Ds IsNot Nothing AndAlso Ds.Tables.Count = 2 Then - For Each Dr2 As DataRow In Ds.Tables(1).Rows - ProveedoresCotizacion.Add(Dr2("RazonSocial")) - Next - NumCotizaciones = Ds.Tables(1).Rows.Count - DtCotizaciones = Ds.Tables(0) - - If Not DtCotizaciones.Columns.Contains("PU1") Then DtCotizaciones.Columns.Add("PU1", GetType(String)) - If Not DtCotizaciones.Columns.Contains("PU2") Then DtCotizaciones.Columns.Add("PU2", GetType(String)) - If Not DtCotizaciones.Columns.Contains("PU3") Then DtCotizaciones.Columns.Add("PU3", GetType(String)) - If Not DtCotizaciones.Columns.Contains("PU4") Then DtCotizaciones.Columns.Add("PU4", GetType(String)) - If Not DtCotizaciones.Columns.Contains("PU5") Then DtCotizaciones.Columns.Add("PU5", GetType(String)) - - End If - - 'COTIZACION - For Index = 1 To 5 - Try - params.Add(New ReportParameter($"Cotizacion{Index.ToString}", ProveedoresCotizacion(Index - 1).ToString)) - Catch ex As Exception - params.Add(New ReportParameter($"Cotizacion{Index.ToString}", "")) - End Try - Next - - params.Add(New ReportParameter("CentroCostos", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) - params.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) - params.Add(New ReportParameter("ProveedorNombre", ObjOC.RazonSocial)) - params.Add(New ReportParameter("ProveedorLugar", ObjOC.LugarEntrega)) - params.Add(New ReportParameter("Estatus", ObjOC.Estatus)) - params.Add(New ReportParameter("Descripcion", ObjOC.Descripcion)) - params.Add(New ReportParameter("Asunto", ObjOC.Justificacion)) - params.Add(New ReportParameter("FechaEntrega", ObjOC.FechaEstimadaEntrega.ToShortDateString)) - params.Add(New ReportParameter("FechaSolicitud", ObjOC.Fecha.ToShortDateString)) - - Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\CotizacionOC.rdlc", EmpresaActual.Ruta)) - If Archivo.Exists Then - bytes = StreamPDF(String.Format("{0}Formatos\CotizacionOC.rdlc", EmpresaActual.Ruta), DtCotizaciones, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) - End If - End If - ObjOC.Dispose() - DtDetalle.Dispose() - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", tCveOrdenCompra, ex.Message)) - End Try - Return bytes - End Function -#End Region - -#Region "NEW RepProveedorCxP.rpt" - Public Function NewGeneraBytesCxP(CveProveedor As Integer, UsuarioActual As String, Optional MR As ReportViewer = Nothing) As Byte() - Dim bytes As Byte() = Nothing - Dim CveEmpresaActual As Integer - 'Dim TmpDTEnvioDireccion As DataTable - Dim params As New List(Of ReportParameter) - - Try - Dim DTCxPTempral As DataTable = Nothing - - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, "-1", "-1") Then - DTCxPTempral = ObjMovtos.DtResultados - End If - - If DTCxPTempral IsNot Nothing AndAlso DTCxPTempral.Rows.Count > 0 Then - Dim dr As DataRow = DTCxPTempral.Rows(0) - Dim NombreProv = "" - Dim Direccion = "" - Dim RFC = "" - Dim Tel = "" - Dim DiasCredito = "" - Dim LimCredito As Double - - CveEmpresaActual = dr("CveEmpresa").ToString.ToEntero - Dim ObjEmpresa As New ClsSisEmpresas() - Dim EmpresaActual As New Empresa - If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then - EmpresaActual = ObjEmpresa.Empresa - End If - ObjEmpresa.Dispose() - - Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepProveedorCxP.rpt", EmpresaActual.Ruta)) - Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", EmpresaActual.Ruta)) - Dim logouri = String.Format("{0}Logo.png", EmpresaActual.Ruta) 'String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, CveEmpresaActual) - - Dim ObjProveedor As New ClsCompProveedores() - If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, EmpresaActual.CveEmpresa) Then - If ObjProveedor.DtResultados.Rows.Count > 0 Then - NombreProv = ObjProveedor.RazonSocial - Direccion = ObjProveedor.Direccion - RFC = ObjProveedor.RFC - Tel = ObjProveedor.Telefono - DiasCredito = ObjProveedor.PlazoPago.ToString - LimCredito = ObjProveedor.LimiteCredito.ToEntero - End If - End If - ObjProveedor.Dispose() - - Dim lista = New List(Of CrystalParametro) - lista.Add(New CrystalParametro("Empresa", EmpresaActual.Empresa)) - lista.Add(New CrystalParametro("TipoCuentas", "Todas")) - lista.Add(New CrystalParametro("FechaInicio", "-")) - lista.Add(New CrystalParametro("FechaFin", DateTime.Now.ToShortDateString)) - lista.Add(New CrystalParametro("NombreProveedor", NombreProv)) - lista.Add(New CrystalParametro("DireccionProveedor", Direccion)) - lista.Add(New CrystalParametro("ProveedorRFC", RFC)) - lista.Add(New CrystalParametro("ProveedorTelefono", Tel)) - lista.Add(New CrystalParametro("DiasCredito", DiasCredito)) - lista.Add(New CrystalParametro("LimiteCredito", LimCredito)) - lista.Add(New CrystalParametro("SaldoDisponible", (LimCredito - dr("Saldo").ToString.ToDouble).ToString.FormatoNumero)) - lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual)) - - If Imagen.Exists Then - lista.Add(New CrystalParametro("LogoPath", logouri)) - Else - lista.Add(New CrystalParametro("LogoPath", "")) - End If - - If Archivo.Exists Then - bytes = ImprimirPDFCrystal(String.Format("{0}Formatos/RepProveedorCxP.rpt", EmpresaActual.Ruta), DTCxPTempral, lista, "EstadoCuentaCxP") - Else - bytes = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepProveedorCxP.rpt"), DTCxPTempral, lista, "EstadoCuentaCxP") - End If - - End If - - ObjMovtos.Dispose() - - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", CveProveedor, ex.Message)) - End Try - - Return bytes - End Function -#End Region - -#Region "PDF NOMINA" - Public Function GeneraPDFNomina(CvePersonal As Integer, CvePeriodo As Integer, CveEmpresa As Integer, RutaEmpresa As String) As Byte() - - Dim ObjNomina As New ClsNominas - Dim ObjPersonal As New ClsRH - Dim TieneError = False - Dim Retorno As Byte() = Nothing - - If Not ObjNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodo, -1, CveEmpresa) Then - Alert("Ocurrio un erro al obtener datos de la nomina", TipoMensaje.MsgError) - ObjPersonal.Dispose() - ObjNomina.Dispose() - Return Nothing - End If - - Dim CveNomina = ObjNomina.CveNomina - Dim DTPercepciones As Data.DataTable - Dim DTDeducciones As Data.DataTable - - Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{CveEmpresa}\" - Dim PathXML As String = $"{Ruta}XML\Nomina\{ObjNomina.SerieFolio}.xml" - Dim FechaEmision, FechaCertificacion As DateTime - Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String - FolioFiscal = "" - NoSerieCertificado = "" - SelloCFDi = "" - SelloSAT = "" - NoSerieCertificadoContribuyente = "" - - - Dim RutaCBB As String = String.Format("{0}CBB\Nomina\{1}.jpg", RutaEmpresa, ObjNomina.SerieFolio) - Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - Dim ImgCBB As String - - Dim RutaFormato As String = String.Format("{0}Formatos\Nomina.rdlc", RutaEmpresa) - Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\Nomina.rdlc") - - 'SI ESTA TIMBRADA - CON XML - - If System.IO.File.Exists(PathXML) Then - - Dim XmlDoc As New System.Xml.XmlDocument - 'XmlDoc.Load(Ruta & "XML\\Nomina\NOM A-3845.xml") - XmlDoc.Load(PathXML) - - If ValorNodoXML(XmlDoc.DocumentElement, "version") = "3.3" Then - FechaEmision = XmlDoc.DocumentElement.Attributes("Fecha").InnerText.ToDate - NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("NoCertificado").InnerText - - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText - FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate - SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText - SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText - End If - Next - Else - FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate - NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText - - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:timbreFiscalDigital" Then - FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText - FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("fechaTimbrado").InnerText.ToDate - SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText - SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText - End If - Next - End If - - - 'SIN TIMBRAR - SIN XML - Else - FolioFiscal = "Sin Timbrar" - NoSerieCertificado = "Sin Timbrar" - SelloCFDi = "Sin Timbrar" - SelloSAT = "Sin Timbrar" - End If - - 'Si no tiene CBB, SE GENERA - If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString.ToDecimal, FolioFiscal, RutaCBB) - End If - End If - - ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/Nomina/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, ObjNomina.SerieFolio) - - Try - Dim CadenaOriginalCFD As String = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" - - Dim RptParametro As New List(Of ReportParameter) - - - 'Datos Empresa - RptParametro.Add(New ReportParameter("RegistroPatronal", ObjNomina.RegistroPatronal)) - - 'DATOS DEL EMPLEADO - If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then - - RptParametro.Add(New ReportParameter("NoEmpleado", ObjPersonal.Codigo)) - RptParametro.Add(New ReportParameter("RFC", ObjPersonal.RFC)) - RptParametro.Add(New ReportParameter("CURP", ObjPersonal.CURP)) - - RptParametro.Add(New ReportParameter("NombreCompleto", ObjPersonal.NombreCompleto)) - RptParametro.Add(New ReportParameter("Regimen", ObjPersonal.RegimenContratacion)) - RptParametro.Add(New ReportParameter("RiesgoPuesto", ObjPersonal.RiesgoPuesto)) - - RptParametro.Add(New ReportParameter("NSS", ObjPersonal.NumeroSS)) - RptParametro.Add(New ReportParameter("Departamento", ObjPersonal.Departamento)) - RptParametro.Add(New ReportParameter("Puesto", ObjPersonal.Puesto.ToString)) - - RptParametro.Add(New ReportParameter("Contrato", ObjPersonal.TipoContrato.ToString)) - - RptParametro.Add(New ReportParameter("Jornada", ObjPersonal.Jornada)) - RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) - RptParametro.Add(New ReportParameter("SalarioBase", ObjPersonal.SalarioDiario.ToString)) - RptParametro.Add(New ReportParameter("SalarioDiarioInt", ObjPersonal.SDI.ToString)) - - RptParametro.Add(New ReportParameter("Banco", ObjPersonal.Banco)) - RptParametro.Add(New ReportParameter("CLABE", ObjPersonal.CLABE)) - - - 'DATOS NOMINA - If ObjNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, 1, CveEmpresa) Then - RptParametro.Add(New ReportParameter("ReciboNomina", ObjNomina.Folio.ToString)) - RptParametro.Add(New ReportParameter("Serie", ObjNomina.Serie)) - RptParametro.Add(New ReportParameter("Fecha", ObjNomina.Fecha.ToString)) - RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) - - RptParametro.Add(New ReportParameter("DiasPagados", ObjNomina.DiasPagados.ToString)) - RptParametro.Add(New ReportParameter("MetodoPago", ObjNomina.MetodoPago)) - RptParametro.Add(New ReportParameter("FormaPago", ObjNomina.FormaPago)) - - RptParametro.Add(New ReportParameter("Cantidad", "1")) - RptParametro.Add(New ReportParameter("Unidad", "SERVICIO")) - RptParametro.Add(New ReportParameter("Descripcion", "PAGO DE NÓMINA")) - RptParametro.Add(New ReportParameter("PU", ObjNomina.SubTotal.ToString)) - RptParametro.Add(New ReportParameter("Importe", ObjNomina.SubTotal.ToString)) - - RptParametro.Add(New ReportParameter("SubTotal", ObjNomina.SubTotal.ToString)) - RptParametro.Add(New ReportParameter("Descuentos", ObjNomina.Descuento.ToString)) - RptParametro.Add(New ReportParameter("ISR", ObjNomina.RetISR.ToString)) - RptParametro.Add(New ReportParameter("Total", ObjNomina.Total.ToString)) - - - RptParametro.Add(New ReportParameter("ImporteLetra", ObjNomina.Total.ToString.ToDouble.Texto2Letras)) - RptParametro.Add(New ReportParameter("Clave", "")) - Else - TieneError = True - End If - Else - TieneError = True - End If - - If Not TieneError Then - If ObjNomina.GetPeriodos(-1, CveEmpresa, -1, -1, CvePeriodo) Then - RptParametro.Add(New ReportParameter("FechaInicio", ObjNomina.FechaInicio.ToString("dd/MM/yyyy"))) - RptParametro.Add(New ReportParameter("FechaFin", ObjNomina.FechaFin.ToString("dd/MM/yyyy"))) - Else - TieneError = True - End If - End If - - - 'Timbrado - RptParametro.Add(New ReportParameter("FolioFiscal", FolioFiscal)) - RptParametro.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado)) - RptParametro.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString)) - RptParametro.Add(New ReportParameter("SelloDigitalEmisor", SelloCFDi)) - RptParametro.Add(New ReportParameter("SelloDigitalSAT", SelloSAT)) - RptParametro.Add(New ReportParameter("CadenaOriginal", CadenaOriginalCFD)) - RptParametro.Add(New ReportParameter("QR", ImgCBB.ToString)) - - 'PERCECIONES - DEDUCCIONES - If ObjNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - DTPercepciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1") - DTDeducciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1") - Else - DTPercepciones = Nothing - DTDeducciones = Nothing - End If - - Dim LSRds As New List(Of ReportDataSource) - Dim RptDS As New ReportDataSource - RptDS.Name = "DsOC" - RptDS.Value = DTPercepciones - LSRds.Add(RptDS) - - Dim RDS As New ReportDataSource - RDS.Name = "DataSet1" - RDS.Value = DTDeducciones - LSRds.Add(RDS) - Dim Archivo As New System.IO.FileInfo(RutaFormato) - - If Not TieneError Then - If Archivo.Exists Then - Retorno = StreamPDF(RutaFormato, LSRds, RptParametro, ObjNomina.SerieFolio, "PDF", MR:=Nothing) - Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio)) - If Not ArchivoPDF.Exists Then - Try - DirectoryExistsCreate(String.Format("{0}PDF", RutaEmpresa)) - DirectoryExistsCreate(String.Format("{0}PDF\{1}", RutaEmpresa, "Nomina")) - File.WriteAllBytes(String.Format("{0}PDF\Nomina\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio), Retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - End If - Else - ImprimirPDF(String.Format("{0}\Formatos\Nomina.rdlc", RutaEmpresa), LSRds, RptParametro, ObjNomina.SerieFolio) - End If - Else - Alert("Ocurrio un error al obtener los datos de la Nomina") - End If - Catch ex As Exception - - GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) - End Try - - - ObjNomina.Dispose() - ObjPersonal.Dispose() - - Return Retorno - End Function -#End Region - -#Region "PDF PAGOS" - Public Sub PDFReciboDePagos(CveVenta As Integer, CveIE As Integer, CveComplementoPago As Integer, Optional imprimir As Boolean = True) - - - Dim ObjBancos As New ClsBancos - Dim ObjClientes As New ClsClientes - Dim params As New List(Of ReportParameter) - Dim SerieFolio As String - - Dim Serie = "" - Dim Folio = "" - Dim CveCliente = -1 - Dim RFCOrdenante = "" - Dim CveMoneda As Integer = 1 - - Dim FolioFiscal = "" - Dim NoSerieCertificado = "" - Dim FechaCertificacion = "" - Dim SelloCFDi = "" - Dim SelloSAT = "" - Dim CertificadoSAT = "" - Dim FechaComprobante As Date - - Dim CveUnidad = "" - Dim Descripcion = "" - Dim Cantidad = "" - Dim CvePS = "" - Dim PU = "" - Dim Importe = "" - Dim TotalLetra = "" - - Dim FechaRecibo = "" - - 'DT PAGO - Dim DTConceptosPago As New DataTable - DTConceptosPago.Columns.Add("CtaOrdenante", GetType(String)) - DTConceptosPago.Columns.Add("Monto", GetType(Decimal)) - DTConceptosPago.Columns.Add("MonedaP", GetType(String)) - DTConceptosPago.Columns.Add("FormaDePagoP", GetType(String)) - DTConceptosPago.Columns.Add("FechaPago", GetType(String)) - DTConceptosPago.Columns.Add("TipoCambioP", GetType(String)) - DTConceptosPago.Columns.Add("RfcEmisorCtaOrd", GetType(String)) - - 'DT DOCUMENTOS RELACIONADOS - Dim DTConceptosPagoRelacionado As New DataTable - DTConceptosPagoRelacionado.Columns.Add("IdDocumento", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("Folio", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("Serie", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("ImpPagado", GetType(Decimal)) - DTConceptosPagoRelacionado.Columns.Add("ImpSaldoAnt", GetType(Decimal)) - DTConceptosPagoRelacionado.Columns.Add("NumParcialidad", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("MetodoDePagoDR", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("MonedaDR", GetType(String)) - DTConceptosPagoRelacionado.Columns.Add("TipoCambioDR", GetType(String)) - - - If ObjBancos.GetComplementoPagos(CveComplementoPago, CveIE, CveVenta, UsuarioActual.CveEmpresa) Then - Serie = ObjBancos.DtResultados.FiltroPrimeroValor("Serie") - Folio = ObjBancos.DtResultados.FiltroPrimeroValor("Folio") - CveCliente = ObjBancos.DtResultados.FiltroPrimeroValor("CveCliente").ToEntero - CveMoneda = ObjBancos.DtResultados.FiltroPrimeroValor("CveMoneda").ToEntero - FechaComprobante = ObjBancos.DtResultados.FiltroPrimeroValor("Fecha").ToDate - End If - - 'CLIENTE - If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus:=-1) Then - RFCOrdenante = ObjClientes.RFC - - params.Add(New ReportParameter("Cliente", ObjClientes.Nombre)) - params.Add(New ReportParameter("ClienteDireccion", ObjClientes.Direccion)) - params.Add(New ReportParameter("ClienteColonia", ObjClientes.Colonia)) - params.Add(New ReportParameter("ClienteCiudad", ObjClientes.Ciudad)) - params.Add(New ReportParameter("ClienteEstado", ObjClientes.Estado)) - params.Add(New ReportParameter("ClienteCP", ObjClientes.CP)) - params.Add(New ReportParameter("ClienteRFC", ObjClientes.RFC)) - End If - - 'DATOS DE EMPRESA - params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("EmpresaDireccion", UsuarioActual.Empresa.Direccion)) - params.Add(New ReportParameter("EmpresaColonia", UsuarioActual.Empresa.Colonia)) - params.Add(New ReportParameter("EmpresaCiudad", UsuarioActual.Empresa.Ciudad)) - params.Add(New ReportParameter("EmpresaEstado", UsuarioActual.Empresa.Estado)) - params.Add(New ReportParameter("EmpresaCP", UsuarioActual.Empresa.CP.ToString())) - params.Add(New ReportParameter("EmpresaRFC", UsuarioActual.Empresa.RFC)) - params.Add(New ReportParameter("EmpresaNoExt", UsuarioActual.Empresa.NoExt)) - params.Add(New ReportParameter("EmpresaNoInt", UsuarioActual.Empresa.NoInt)) - - 'DATOS IMPRESION - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) - - 'DATOS GENERALES - Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" - Dim PathXML As String = $"{Ruta}XML\Pag\{Serie}-{Folio}.xml" - Dim PathPDF As String = $"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf" - SerieFolio = $"{Serie}-{Folio}" - Dim ImagenCBB As String = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, $"{Serie}-{Folio}.jpg") - - If File.Exists(PathXML) Then - Dim XmlDoc As New System.Xml.XmlDocument - XmlDoc.Load(PathXML) - - Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") - Dim validaElementoPago = XmlDoc.DocumentElement("cfdi:Conceptos") - - 'Datos Fiscales - If Not IsNothing(validaElemento) Then - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText - FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText - SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText - SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText - End If - Next - End If - - 'Pago - If Not IsNothing(validaElemento) Then - Dim PagosChild = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Pagos", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() - - For Each Pagos As XmlNode In PagosChild.ChildNodes - Dim Dr As DataRow = DTConceptosPago.NewRow - - If Not Pagos.Attributes("CtaOrdenante") Is Nothing Then Dr("CtaOrdenante") = Pagos.Attributes("CtaOrdenante").Value Else Dr("CtaOrdenante") = "" - If Not Pagos.Attributes("TipoCambioP") Is Nothing Then Dr("TipoCambioP") = Pagos.Attributes("TipoCambioP").Value Else Dr("TipoCambioP") = "" - - If Not Pagos.Attributes("RfcEmisorCtaOrd") Is Nothing Then - Dr("RfcEmisorCtaOrd") = Pagos.Attributes("RfcEmisorCtaOrd").Value - RFCOrdenante = Pagos.Attributes("RfcEmisorCtaOrd").Value - Else - Dr("RfcEmisorCtaOrd") = "" - End If - - Dr("Monto") = Pagos.Attributes("Monto").Value - Dr("MonedaP") = Pagos.Attributes("MonedaP").Value - Dr("FormaDePagoP") = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPagoSAT", $"ClaveFormaPagoSAT= '{Pagos.Attributes("FormaDePagoP").Value}'") - Dr("FechaPago") = Pagos.Attributes("FechaPago").Value - - FechaRecibo = Pagos.Attributes("FechaPago").Value - TotalLetra = Pagos.Attributes("Monto").Value.ToString.ToDouble.Texto2Letras(CveMoneda) - - DTConceptosPago.Rows.Add(Dr) - - For Each Relacionado As XmlNode In Pagos.ChildNodes - Dim DrRelacionado As DataRow = DTConceptosPagoRelacionado.NewRow - - If Not Relacionado.Attributes("Folio") Is Nothing Then DrRelacionado("Folio") = Relacionado.Attributes("Folio").Value Else DrRelacionado("Folio") = "" - If Not Relacionado.Attributes("Serie") Is Nothing Then DrRelacionado("Serie") = Relacionado.Attributes("Serie").Value Else DrRelacionado("Serie") = "" - If Not Relacionado.Attributes("TipoCambioDR") Is Nothing Then DrRelacionado("TipoCambioDR") = Relacionado.Attributes("TipoCambioDR").Value Else DrRelacionado("TipoCambioDR") = "" - - DrRelacionado("IdDocumento") = Relacionado.Attributes("IdDocumento").Value - DrRelacionado("ImpPagado") = Relacionado.Attributes("ImpPagado").Value - DrRelacionado("ImpSaldoAnt") = Relacionado.Attributes("ImpSaldoAnt").Value - DrRelacionado("NumParcialidad") = Relacionado.Attributes("NumParcialidad").Value - DrRelacionado("MetodoDePagoDR") = Relacionado.Attributes("MetodoDePagoDR").Value - DrRelacionado("MonedaDR") = Relacionado.Attributes("MonedaDR").Value - - DTConceptosPagoRelacionado.Rows.Add(DrRelacionado) - Next - Next - - End If - - If Not IsNothing(validaElementoPago) Then - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Name = "cfdi:Concepto" Then - Importe = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Importe").InnerText - PU = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ValorUnitario").InnerText - Descripcion = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Descripcion").InnerText - CveUnidad = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ClaveUnidad").InnerText - Cantidad = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Cantidad").InnerText - CvePS = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ClaveProdServ").InnerText - End If - Next - End If - - Dim CadenaOriginal As String = $"||1.0| {FolioFiscal} | {FechaCertificacion.ToDate.ToShortDateString} T {FechaCertificacion.ToDateTime.ToShortTimeString} | {SelloCFDi} | {NoSerieCertificado} ||" - - ' PARAMETROS DEL REPORTE - - params.Add(New ReportParameter("SerieFolio", SerieFolio)) - params.Add(New ReportParameter("RFCOrdenante", RFCOrdenante)) - params.Add(New ReportParameter("FechaRecibo", FechaRecibo)) - - params.Add(New ReportParameter("Cantidad", Cantidad)) - params.Add(New ReportParameter("Descripcion", Descripcion)) - params.Add(New ReportParameter("UnidadMedida", CveUnidad)) - params.Add(New ReportParameter("PU", PU)) - params.Add(New ReportParameter("Importe", Importe)) - - params.Add(New ReportParameter("CantidadLetra", TotalLetra.ToUpper())) - - params.Add(New ReportParameter("UUIDPago", FolioFiscal)) - params.Add(New ReportParameter("NoCertificado", NoSerieCertificado)) - params.Add(New ReportParameter("FechaTimbre", FechaComprobante.ToShortDateString)) - params.Add(New ReportParameter("Sello", SelloCFDi)) - params.Add(New ReportParameter("SelloSAT", SelloSAT)) - params.Add(New ReportParameter("CadenaOriginal", CadenaOriginal)) - params.Add(New ReportParameter("CertificadoSAT", CertificadoSAT)) - params.Add(New ReportParameter("QR", ImagenCBB)) - - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = If(DTConceptosPago IsNot Nothing, DTConceptosPago, New DataTable)} - Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(DTConceptosPagoRelacionado IsNot Nothing, DTConceptosPagoRelacionado, New DataTable)} - lrds.Add(rds) - lrds.Add(rds2) - - Dim rutaArchivo As String = "" - - 'LOGO - Dim LogoRuta As String = "" - - LogoRuta = String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta) - If File.Exists(LogoRuta) Then - - If File.Exists(LogoRuta) Then - LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - End If - 'POR EMPRESA - params.Add(New ReportParameter("LogoPath", LogoRuta)) - Else - params.Add(New ReportParameter("LogoPath", "")) - End If - - - If File.Exists($"{UsuarioActual.Empresa.Ruta}\Formatos\ReciboDePago.rdlc") Then - rutaArchivo = $"Empresas\{UsuarioActual.CveEmpresa}\Formatos\ReciboDePago.rdlc" - Else - rutaArchivo = " \Empresas\Grales\Formatos\ReciboDePago.rdlc" - End If - - If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Then - Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") - End If - - - Dim ArchivoPDF As New System.IO.FileInfo($"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf") - If ArchivoPDF.Exists Then - Try - ArchivoPDF.Delete() - File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - Else - File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) - End If - - If imprimir Then - ImprimirPDF(rutaArchivo, lrds, params, SerieFolio, "PDF") - End If - - End If - - ObjBancos.Dispose() - ObjClientes.Dispose() - - End Sub -#End Region - -End Class - + If Archivo.Exists Then + bytes = StreamPDF(String.Format("{0}Formatos\OC.rdlc", EmpresaActual.Ruta), DtDetalle, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) + Else + params.Add(New ReportParameter("Empresa", EmpresaActual.Empresa)) + bytes = StreamPDF("Empresas\Grales\Formatos\OC.rdlc", DtDetalle, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) + End If + + If ConBitacora Then + Dim dttemp As New DataTable + Dim ObjEventoBitacora As New ClsOIEventos() + If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, EmpresaActual.CveEmpresa, CveOC:=tCveOrdenCompra) Then + dttemp = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") + End If + ObjEventoBitacora.Dispose() + If Not IsNothing(dttemp) AndAlso dttemp.Rows.Count > 0 Then + + Dim paramsest As New List(Of ReportParameter) + paramsest.Add(New ReportParameter("Empresa", EmpresaActual.Empresa)) + paramsest.Add(New ReportParameter("Titulo", "Bitácora de órdenes de compra")) + paramsest.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) + paramsest.Add(New ReportParameter("TipoOC", If(ObjOC.Tipo = "OC", "Orden de Compra", "Requisición"))) + Dim bytes2 As Byte() + bytes2 = StreamPDF("Empresas\Grales\Formatos\Bitacora.rdlc", dttemp, paramsest, $"OC_{ObjOC.Folio.ToString}", MR:=MR) + Using ms As New MemoryStream() + Using document As New iTextSharp.text.Document() + Using copy As New PdfCopy(document, ms) + document.Open() + + Dim reader As New PdfReader(bytes) + ' loop over the pages in that document + Dim n As Integer = reader.NumberOfPages + Dim page As Integer = 0 + While page < n + page = page + 1 + copy.AddPage(copy.GetImportedPage(reader, page)) + End While + + + reader = New PdfReader(bytes2) + ' loop over the pages in that document + n = reader.NumberOfPages + page = 0 + While page < n + page = page + 1 + copy.AddPage(copy.GetImportedPage(reader, page)) + End While + + End Using + End Using + bytes = ms.ToArray() + End Using + End If + dttemp.Dispose() + End If + + End If + ObjOC.Dispose() + + DtDetalle.Dispose() + + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", tCveOrdenCompra, ex.Message)) + End Try + + Return bytes + End Function + + Public Function NewGeneraOCCotizacion(tCveOrdenCompra As Integer, Optional MR As ReportViewer = Nothing, Optional ConBitacora As Boolean = False) As Byte() + Dim bytes As Byte() = Nothing + Dim CveEmpresaActual As Integer + + Try + Dim DtDetalle As DataTable = Nothing + Dim ObjOC As New ClsOC + + If ObjOC.GetOC(tCveOrdenCompra, UsuarioActual.CveEmpresa, CveUsuario:=UsuarioActual.CveUsuario) Then + CveEmpresaActual = ObjOC.CveEmpresa + + Dim ObjEmpresa As New ClsSisEmpresas() + Dim EmpresaActual As New Empresa + If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then + EmpresaActual = ObjEmpresa.Empresa + End If + ObjEmpresa.Dispose() + + '-----------------------COTIZACIONES-------------------------- + Dim params As New List(Of ReportParameter) + Dim NumCotizaciones = 0 + Dim DtCotizaciones As New DataTable + Dim ProveedoresCotizacion = New ArrayList + Dim Ds As DataSet = ObjOC.GetCotizacionesTabla(tCveOrdenCompra) + If Ds IsNot Nothing AndAlso Ds.Tables.Count = 2 Then + For Each Dr2 As DataRow In Ds.Tables(1).Rows + ProveedoresCotizacion.Add(Dr2("RazonSocial")) + Next + NumCotizaciones = Ds.Tables(1).Rows.Count + DtCotizaciones = Ds.Tables(0) + + If Not DtCotizaciones.Columns.Contains("PU1") Then DtCotizaciones.Columns.Add("PU1", GetType(String)) + If Not DtCotizaciones.Columns.Contains("PU2") Then DtCotizaciones.Columns.Add("PU2", GetType(String)) + If Not DtCotizaciones.Columns.Contains("PU3") Then DtCotizaciones.Columns.Add("PU3", GetType(String)) + If Not DtCotizaciones.Columns.Contains("PU4") Then DtCotizaciones.Columns.Add("PU4", GetType(String)) + If Not DtCotizaciones.Columns.Contains("PU5") Then DtCotizaciones.Columns.Add("PU5", GetType(String)) + + End If + + 'COTIZACION + For Index = 1 To 5 + Try + params.Add(New ReportParameter($"Cotizacion{Index.ToString}", ProveedoresCotizacion(Index - 1).ToString)) + Catch ex As Exception + params.Add(New ReportParameter($"Cotizacion{Index.ToString}", "")) + End Try + Next + + params.Add(New ReportParameter("CentroCostos", If(DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0, DtDetalle.MAX("Proyecto").ToString, ""))) + params.Add(New ReportParameter("Folio", ObjOC.Folio.ToString)) + params.Add(New ReportParameter("ProveedorNombre", ObjOC.RazonSocial)) + params.Add(New ReportParameter("ProveedorLugar", ObjOC.LugarEntrega)) + params.Add(New ReportParameter("Estatus", ObjOC.Estatus)) + params.Add(New ReportParameter("Descripcion", ObjOC.Descripcion)) + params.Add(New ReportParameter("Asunto", ObjOC.Justificacion)) + params.Add(New ReportParameter("FechaEntrega", ObjOC.FechaEstimadaEntrega.ToShortDateString)) + params.Add(New ReportParameter("FechaSolicitud", ObjOC.Fecha.ToShortDateString)) + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\CotizacionOC.rdlc", EmpresaActual.Ruta)) + If Archivo.Exists Then + bytes = StreamPDF(String.Format("{0}Formatos\CotizacionOC.rdlc", EmpresaActual.Ruta), DtCotizaciones, params, $"OC_{ObjOC.Folio.ToString}", RDSName:="DsOC", MR:=MR) + End If + End If + ObjOC.Dispose() + DtDetalle.Dispose() + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", tCveOrdenCompra, ex.Message)) + End Try + Return bytes + End Function +#End Region + +#Region "NEW RepProveedorCxP.rpt" + Public Function NewGeneraBytesCxP(CveProveedor As Integer, UsuarioActual As String, Optional MR As ReportViewer = Nothing) As Byte() + Dim bytes As Byte() = Nothing + Dim CveEmpresaActual As Integer + 'Dim TmpDTEnvioDireccion As DataTable + Dim params As New List(Of ReportParameter) + + Try + Dim DTCxPTempral As DataTable = Nothing + + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, "-1", "-1") Then + DTCxPTempral = ObjMovtos.DtResultados + End If + + If DTCxPTempral IsNot Nothing AndAlso DTCxPTempral.Rows.Count > 0 Then + Dim dr As DataRow = DTCxPTempral.Rows(0) + Dim NombreProv = "" + Dim Direccion = "" + Dim RFC = "" + Dim Tel = "" + Dim DiasCredito = "" + Dim LimCredito As Double + + CveEmpresaActual = dr("CveEmpresa").ToString.ToEntero + Dim ObjEmpresa As New ClsSisEmpresas() + Dim EmpresaActual As New Empresa + If ObjEmpresa.GetEmpresas(CveEmpresaActual, "-1", "-1", "-1", "-1") Then + EmpresaActual = ObjEmpresa.Empresa + End If + ObjEmpresa.Dispose() + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepProveedorCxP.rpt", EmpresaActual.Ruta)) + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", EmpresaActual.Ruta)) + Dim logouri = String.Format("{0}Logo.png", EmpresaActual.Ruta) 'String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, CveEmpresaActual) + + Dim ObjProveedor As New ClsCompProveedores() + If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, EmpresaActual.CveEmpresa) Then + If ObjProveedor.DtResultados.Rows.Count > 0 Then + NombreProv = ObjProveedor.RazonSocial + Direccion = ObjProveedor.Direccion + RFC = ObjProveedor.RFC + Tel = ObjProveedor.Telefono + DiasCredito = ObjProveedor.PlazoPago.ToString + LimCredito = ObjProveedor.LimiteCredito.ToEntero + End If + End If + ObjProveedor.Dispose() + + Dim lista = New List(Of CrystalParametro) + lista.Add(New CrystalParametro("Empresa", EmpresaActual.Empresa)) + lista.Add(New CrystalParametro("TipoCuentas", "Todas")) + lista.Add(New CrystalParametro("FechaInicio", "-")) + lista.Add(New CrystalParametro("FechaFin", DateTime.Now.ToShortDateString)) + lista.Add(New CrystalParametro("NombreProveedor", NombreProv)) + lista.Add(New CrystalParametro("DireccionProveedor", Direccion)) + lista.Add(New CrystalParametro("ProveedorRFC", RFC)) + lista.Add(New CrystalParametro("ProveedorTelefono", Tel)) + lista.Add(New CrystalParametro("DiasCredito", DiasCredito)) + lista.Add(New CrystalParametro("LimiteCredito", LimCredito)) + lista.Add(New CrystalParametro("SaldoDisponible", (LimCredito - dr("Saldo").ToString.ToDouble).ToString.FormatoNumero)) + lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual)) + + If Imagen.Exists Then + lista.Add(New CrystalParametro("LogoPath", logouri)) + Else + lista.Add(New CrystalParametro("LogoPath", "")) + End If + + If Archivo.Exists Then + bytes = ImprimirPDFCrystal(String.Format("{0}Formatos/RepProveedorCxP.rpt", EmpresaActual.Ruta), DTCxPTempral, lista, "EstadoCuentaCxP") + Else + bytes = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepProveedorCxP.rpt"), DTCxPTempral, lista, "EstadoCuentaCxP") + End If + + End If + + ObjMovtos.Dispose() + + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el strem de la oc={0}. {1}", CveProveedor, ex.Message)) + End Try + + Return bytes + End Function +#End Region + +#Region "PDF NOMINA" + Public Function GeneraPDFNomina(CvePersonal As Integer, CvePeriodo As Integer, CveEmpresa As Integer, RutaEmpresa As String) As Byte() + + Dim ObjNomina As New ClsNominas + Dim ObjPersonal As New ClsRH + Dim TieneError = False + Dim Retorno As Byte() = Nothing + + If Not ObjNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodo, -1, CveEmpresa) Then + Alert("Ocurrio un erro al obtener datos de la nomina", TipoMensaje.MsgError) + ObjPersonal.Dispose() + ObjNomina.Dispose() + Return Nothing + End If + + Dim CveNomina = ObjNomina.CveNomina + Dim DTPercepciones As Data.DataTable + Dim DTDeducciones As Data.DataTable + + Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{CveEmpresa}\" + Dim PathXML As String = $"{Ruta}XML\Nomina\{ObjNomina.SerieFolio}.xml" + Dim FechaEmision, FechaCertificacion As DateTime + Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String + FolioFiscal = "" + NoSerieCertificado = "" + SelloCFDi = "" + SelloSAT = "" + NoSerieCertificadoContribuyente = "" + + + Dim RutaCBB As String = String.Format("{0}CBB\Nomina\{1}.jpg", RutaEmpresa, ObjNomina.SerieFolio) + Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) + Dim ImgCBB As String + + Dim RutaFormato As String = String.Format("{0}Formatos\Nomina.rdlc", RutaEmpresa) + Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\Nomina.rdlc") + + 'SI ESTA TIMBRADA - CON XML + + If System.IO.File.Exists(PathXML) Then + + Dim XmlDoc As New System.Xml.XmlDocument + 'XmlDoc.Load(Ruta & "XML\\Nomina\NOM A-3845.xml") + XmlDoc.Load(PathXML) + + If ValorNodoXML(XmlDoc.DocumentElement, "version") = "3.3" Then + FechaEmision = XmlDoc.DocumentElement.Attributes("Fecha").InnerText.ToDate + NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("NoCertificado").InnerText + + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then + FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText + FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate + SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText + SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText + End If + Next + Else + FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate + NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText + + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:timbreFiscalDigital" Then + FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText + FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("fechaTimbrado").InnerText.ToDate + SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText + SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText + End If + Next + End If + + + 'SIN TIMBRAR - SIN XML + Else + FolioFiscal = "Sin Timbrar" + NoSerieCertificado = "Sin Timbrar" + SelloCFDi = "Sin Timbrar" + SelloSAT = "Sin Timbrar" + End If + + 'Si no tiene CBB, SE GENERA + If Not ImagenCBB.Exists Then + Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() + If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ObjPersonal.RFC, ObjNomina.Total.ToString.ToDecimal, FolioFiscal, RutaCBB) + End If + End If + + ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/Nomina/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, ObjNomina.SerieFolio) + + Try + Dim CadenaOriginalCFD As String = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" + + Dim RptParametro As New List(Of ReportParameter) + + + 'Datos Empresa + RptParametro.Add(New ReportParameter("RegistroPatronal", ObjNomina.RegistroPatronal)) + + 'DATOS DEL EMPLEADO + If ObjPersonal.GetPersonal(CvePersonal, CveEmpresa) Then + + RptParametro.Add(New ReportParameter("NoEmpleado", ObjPersonal.Codigo)) + RptParametro.Add(New ReportParameter("RFC", ObjPersonal.RFC)) + RptParametro.Add(New ReportParameter("CURP", ObjPersonal.CURP)) + + RptParametro.Add(New ReportParameter("NombreCompleto", ObjPersonal.NombreCompleto)) + RptParametro.Add(New ReportParameter("Regimen", ObjPersonal.RegimenContratacion)) + RptParametro.Add(New ReportParameter("RiesgoPuesto", ObjPersonal.RiesgoPuesto)) + + RptParametro.Add(New ReportParameter("NSS", ObjPersonal.NumeroSS)) + RptParametro.Add(New ReportParameter("Departamento", ObjPersonal.Departamento)) + RptParametro.Add(New ReportParameter("Puesto", ObjPersonal.Puesto.ToString)) + + RptParametro.Add(New ReportParameter("Contrato", ObjPersonal.TipoContrato.ToString)) + + RptParametro.Add(New ReportParameter("Jornada", ObjPersonal.Jornada)) + RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) + RptParametro.Add(New ReportParameter("SalarioBase", ObjPersonal.SalarioDiario.ToString)) + RptParametro.Add(New ReportParameter("SalarioDiarioInt", ObjPersonal.SDI.ToString)) + + RptParametro.Add(New ReportParameter("Banco", ObjPersonal.Banco)) + RptParametro.Add(New ReportParameter("CLABE", ObjPersonal.CLABE)) + + + 'DATOS NOMINA + If ObjNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, 1, CveEmpresa) Then + RptParametro.Add(New ReportParameter("ReciboNomina", ObjNomina.Folio.ToString)) + RptParametro.Add(New ReportParameter("Serie", ObjNomina.Serie)) + RptParametro.Add(New ReportParameter("Fecha", ObjNomina.Fecha.ToString)) + RptParametro.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) + + RptParametro.Add(New ReportParameter("DiasPagados", ObjNomina.DiasPagados.ToString)) + RptParametro.Add(New ReportParameter("MetodoPago", ObjNomina.MetodoPago)) + RptParametro.Add(New ReportParameter("FormaPago", ObjNomina.FormaPago)) + + RptParametro.Add(New ReportParameter("Cantidad", "1")) + RptParametro.Add(New ReportParameter("Unidad", "SERVICIO")) + RptParametro.Add(New ReportParameter("Descripcion", "PAGO DE NÓMINA")) + RptParametro.Add(New ReportParameter("PU", ObjNomina.SubTotal.ToString)) + RptParametro.Add(New ReportParameter("Importe", ObjNomina.SubTotal.ToString)) + + RptParametro.Add(New ReportParameter("SubTotal", ObjNomina.SubTotal.ToString)) + RptParametro.Add(New ReportParameter("Descuentos", ObjNomina.Descuento.ToString)) + RptParametro.Add(New ReportParameter("ISR", ObjNomina.RetISR.ToString)) + RptParametro.Add(New ReportParameter("Total", ObjNomina.Total.ToString)) + + + RptParametro.Add(New ReportParameter("ImporteLetra", ObjNomina.Total.ToString.ToDouble.Texto2Letras)) + RptParametro.Add(New ReportParameter("Clave", "")) + Else + TieneError = True + End If + Else + TieneError = True + End If + + If Not TieneError Then + If ObjNomina.GetPeriodos(-1, CveEmpresa, -1, -1, CvePeriodo) Then + RptParametro.Add(New ReportParameter("FechaInicio", ObjNomina.FechaInicio.ToString("dd/MM/yyyy"))) + RptParametro.Add(New ReportParameter("FechaFin", ObjNomina.FechaFin.ToString("dd/MM/yyyy"))) + Else + TieneError = True + End If + End If + + + 'Timbrado + RptParametro.Add(New ReportParameter("FolioFiscal", FolioFiscal)) + RptParametro.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado)) + RptParametro.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString)) + RptParametro.Add(New ReportParameter("SelloDigitalEmisor", SelloCFDi)) + RptParametro.Add(New ReportParameter("SelloDigitalSAT", SelloSAT)) + RptParametro.Add(New ReportParameter("CadenaOriginal", CadenaOriginalCFD)) + RptParametro.Add(New ReportParameter("QR", ImgCBB.ToString)) + + 'PERCECIONES - DEDUCCIONES + If ObjNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then + DTPercepciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1") + DTDeducciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1") + Else + DTPercepciones = Nothing + DTDeducciones = Nothing + End If + + Dim LSRds As New List(Of ReportDataSource) + Dim RptDS As New ReportDataSource + RptDS.Name = "DsOC" + RptDS.Value = DTPercepciones + LSRds.Add(RptDS) + + Dim RDS As New ReportDataSource + RDS.Name = "DataSet1" + RDS.Value = DTDeducciones + LSRds.Add(RDS) + Dim Archivo As New System.IO.FileInfo(RutaFormato) + + If Not TieneError Then + If Archivo.Exists Then + Retorno = StreamPDF(RutaFormato, LSRds, RptParametro, ObjNomina.SerieFolio, "PDF", MR:=Nothing) + Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio)) + If Not ArchivoPDF.Exists Then + Try + DirectoryExistsCreate(String.Format("{0}PDF", RutaEmpresa)) + DirectoryExistsCreate(String.Format("{0}PDF\{1}", RutaEmpresa, "Nomina")) + File.WriteAllBytes(String.Format("{0}PDF\Nomina\{1}.pdf", RutaEmpresa, ObjNomina.SerieFolio), Retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + End If + Else + ImprimirPDF(String.Format("{0}\Formatos\Nomina.rdlc", RutaEmpresa), LSRds, RptParametro, ObjNomina.SerieFolio) + End If + Else + Alert("Ocurrio un error al obtener los datos de la Nomina") + End If + Catch ex As Exception + + GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) + End Try + + + ObjNomina.Dispose() + ObjPersonal.Dispose() + + Return Retorno + End Function +#End Region + +#Region "PDF PAGOS" + Public Sub PDFReciboDePagos(CveVenta As Integer, CveIE As Integer, CveComplementoPago As Integer, Optional imprimir As Boolean = True) + + + Dim ObjBancos As New ClsBancos + Dim ObjClientes As New ClsClientes + Dim params As New List(Of ReportParameter) + Dim SerieFolio As String + + Dim Serie = "" + Dim Folio = "" + Dim CveCliente = -1 + Dim RFCOrdenante = "" + Dim CveMoneda As Integer = 1 + + Dim FolioFiscal = "" + Dim NoSerieCertificado = "" + Dim FechaCertificacion = "" + Dim SelloCFDi = "" + Dim SelloSAT = "" + Dim CertificadoSAT = "" + Dim FechaComprobante As Date + + Dim CveUnidad = "" + Dim Descripcion = "" + Dim Cantidad = "" + Dim CvePS = "" + Dim PU = "" + Dim Importe = "" + Dim TotalLetra = "" + + Dim FechaRecibo = "" + + 'DT PAGO + Dim DTConceptosPago As New DataTable + DTConceptosPago.Columns.Add("CtaOrdenante", GetType(String)) + DTConceptosPago.Columns.Add("Monto", GetType(Decimal)) + DTConceptosPago.Columns.Add("MonedaP", GetType(String)) + DTConceptosPago.Columns.Add("FormaDePagoP", GetType(String)) + DTConceptosPago.Columns.Add("FechaPago", GetType(String)) + DTConceptosPago.Columns.Add("TipoCambioP", GetType(String)) + DTConceptosPago.Columns.Add("RfcEmisorCtaOrd", GetType(String)) + + 'DT DOCUMENTOS RELACIONADOS + Dim DTConceptosPagoRelacionado As New DataTable + DTConceptosPagoRelacionado.Columns.Add("IdDocumento", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("Folio", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("Serie", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("ImpPagado", GetType(Decimal)) + DTConceptosPagoRelacionado.Columns.Add("ImpSaldoAnt", GetType(Decimal)) + DTConceptosPagoRelacionado.Columns.Add("NumParcialidad", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("MetodoDePagoDR", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("MonedaDR", GetType(String)) + DTConceptosPagoRelacionado.Columns.Add("TipoCambioDR", GetType(String)) + + + If ObjBancos.GetComplementoPagos(CveComplementoPago, CveIE, CveVenta, UsuarioActual.CveEmpresa) Then + Serie = ObjBancos.DtResultados.FiltroPrimeroValor("Serie") + Folio = ObjBancos.DtResultados.FiltroPrimeroValor("Folio") + CveCliente = ObjBancos.DtResultados.FiltroPrimeroValor("CveCliente").ToEntero + CveMoneda = ObjBancos.DtResultados.FiltroPrimeroValor("CveMoneda").ToEntero + FechaComprobante = ObjBancos.DtResultados.FiltroPrimeroValor("Fecha").ToDate + End If + + 'CLIENTE + If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus:=-1) Then + RFCOrdenante = ObjClientes.RFC + + params.Add(New ReportParameter("Cliente", ObjClientes.Nombre)) + params.Add(New ReportParameter("ClienteDireccion", ObjClientes.Direccion)) + params.Add(New ReportParameter("ClienteColonia", ObjClientes.Colonia)) + params.Add(New ReportParameter("ClienteCiudad", ObjClientes.Ciudad)) + params.Add(New ReportParameter("ClienteEstado", ObjClientes.Estado)) + params.Add(New ReportParameter("ClienteCP", ObjClientes.CP)) + params.Add(New ReportParameter("ClienteRFC", ObjClientes.RFC)) + End If + + 'DATOS DE EMPRESA + params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("EmpresaDireccion", UsuarioActual.Empresa.Direccion)) + params.Add(New ReportParameter("EmpresaColonia", UsuarioActual.Empresa.Colonia)) + params.Add(New ReportParameter("EmpresaCiudad", UsuarioActual.Empresa.Ciudad)) + params.Add(New ReportParameter("EmpresaEstado", UsuarioActual.Empresa.Estado)) + params.Add(New ReportParameter("EmpresaCP", UsuarioActual.Empresa.CP.ToString())) + params.Add(New ReportParameter("EmpresaRFC", UsuarioActual.Empresa.RFC)) + params.Add(New ReportParameter("EmpresaNoExt", UsuarioActual.Empresa.NoExt)) + params.Add(New ReportParameter("EmpresaNoInt", UsuarioActual.Empresa.NoInt)) + + 'DATOS IMPRESION + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) + + 'DATOS GENERALES + Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" + Dim PathXML As String = $"{Ruta}XML\Pag\{Serie}-{Folio}.xml" + Dim PathPDF As String = $"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf" + SerieFolio = $"{Serie}-{Folio}" + Dim ImagenCBB As String = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, $"{Serie}-{Folio}.jpg") + + If File.Exists(PathXML) Then + Dim XmlDoc As New System.Xml.XmlDocument + XmlDoc.Load(PathXML) + + Dim validaElemento = XmlDoc.DocumentElement("cfdi:Complemento") + Dim validaElementoPago = XmlDoc.DocumentElement("cfdi:Conceptos") + + 'Datos Fiscales + If Not IsNothing(validaElemento) Then + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then + FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText + NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText + FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText + SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText + SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText + End If + Next + End If + + 'Pago + If Not IsNothing(validaElemento) Then + Dim PagosChild = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Cast(Of XmlNode).Where(Function(a) a.LocalName.Equals("Pagos", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault() + + For Each Pagos As XmlNode In PagosChild.ChildNodes + Dim Dr As DataRow = DTConceptosPago.NewRow + + If Not Pagos.Attributes("CtaOrdenante") Is Nothing Then Dr("CtaOrdenante") = Pagos.Attributes("CtaOrdenante").Value Else Dr("CtaOrdenante") = "" + If Not Pagos.Attributes("TipoCambioP") Is Nothing Then Dr("TipoCambioP") = Pagos.Attributes("TipoCambioP").Value Else Dr("TipoCambioP") = "" + + If Not Pagos.Attributes("RfcEmisorCtaOrd") Is Nothing Then + Dr("RfcEmisorCtaOrd") = Pagos.Attributes("RfcEmisorCtaOrd").Value + RFCOrdenante = Pagos.Attributes("RfcEmisorCtaOrd").Value + Else + Dr("RfcEmisorCtaOrd") = "" + End If + + Dr("Monto") = Pagos.Attributes("Monto").Value + Dr("MonedaP") = Pagos.Attributes("MonedaP").Value + Dr("FormaDePagoP") = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPagoSAT", $"ClaveFormaPagoSAT= '{Pagos.Attributes("FormaDePagoP").Value}'") + Dr("FechaPago") = Pagos.Attributes("FechaPago").Value + + FechaRecibo = Pagos.Attributes("FechaPago").Value + TotalLetra = Pagos.Attributes("Monto").Value.ToString.ToDouble.Texto2Letras(CveMoneda) + + DTConceptosPago.Rows.Add(Dr) + + For Each Relacionado As XmlNode In Pagos.ChildNodes + Dim DrRelacionado As DataRow = DTConceptosPagoRelacionado.NewRow + + If Not Relacionado.Attributes("Folio") Is Nothing Then DrRelacionado("Folio") = Relacionado.Attributes("Folio").Value Else DrRelacionado("Folio") = "" + If Not Relacionado.Attributes("Serie") Is Nothing Then DrRelacionado("Serie") = Relacionado.Attributes("Serie").Value Else DrRelacionado("Serie") = "" + If Not Relacionado.Attributes("TipoCambioDR") Is Nothing Then DrRelacionado("TipoCambioDR") = Relacionado.Attributes("TipoCambioDR").Value Else DrRelacionado("TipoCambioDR") = "" + + DrRelacionado("IdDocumento") = Relacionado.Attributes("IdDocumento").Value + DrRelacionado("ImpPagado") = Relacionado.Attributes("ImpPagado").Value + DrRelacionado("ImpSaldoAnt") = Relacionado.Attributes("ImpSaldoAnt").Value + DrRelacionado("NumParcialidad") = Relacionado.Attributes("NumParcialidad").Value + DrRelacionado("MetodoDePagoDR") = Relacionado.Attributes("MetodoDePagoDR").Value + DrRelacionado("MonedaDR") = Relacionado.Attributes("MonedaDR").Value + + DTConceptosPagoRelacionado.Rows.Add(DrRelacionado) + Next + Next + + End If + + If Not IsNothing(validaElementoPago) Then + For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes.Count - 1 + If XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Name = "cfdi:Concepto" Then + Importe = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Importe").InnerText + PU = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ValorUnitario").InnerText + Descripcion = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Descripcion").InnerText + CveUnidad = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ClaveUnidad").InnerText + Cantidad = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("Cantidad").InnerText + CvePS = XmlDoc.DocumentElement("cfdi:Conceptos").ChildNodes(i).Attributes("ClaveProdServ").InnerText + End If + Next + End If + + Dim CadenaOriginal As String = $"||1.0| {FolioFiscal} | {FechaCertificacion.ToDate.ToShortDateString} T {FechaCertificacion.ToDateTime.ToShortTimeString} | {SelloCFDi} | {NoSerieCertificado} ||" + + ' PARAMETROS DEL REPORTE + + params.Add(New ReportParameter("SerieFolio", SerieFolio)) + params.Add(New ReportParameter("RFCOrdenante", RFCOrdenante)) + params.Add(New ReportParameter("FechaRecibo", FechaRecibo)) + + params.Add(New ReportParameter("Cantidad", Cantidad)) + params.Add(New ReportParameter("Descripcion", Descripcion)) + params.Add(New ReportParameter("UnidadMedida", CveUnidad)) + params.Add(New ReportParameter("PU", PU)) + params.Add(New ReportParameter("Importe", Importe)) + + params.Add(New ReportParameter("CantidadLetra", TotalLetra.ToUpper())) + + params.Add(New ReportParameter("UUIDPago", FolioFiscal)) + params.Add(New ReportParameter("NoCertificado", NoSerieCertificado)) + params.Add(New ReportParameter("FechaTimbre", FechaComprobante.ToShortDateString)) + params.Add(New ReportParameter("Sello", SelloCFDi)) + params.Add(New ReportParameter("SelloSAT", SelloSAT)) + params.Add(New ReportParameter("CadenaOriginal", CadenaOriginal)) + params.Add(New ReportParameter("CertificadoSAT", CertificadoSAT)) + params.Add(New ReportParameter("QR", ImagenCBB)) + + Dim lrds As New List(Of ReportDataSource) + Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = If(DTConceptosPago IsNot Nothing, DTConceptosPago, New DataTable)} + Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(DTConceptosPagoRelacionado IsNot Nothing, DTConceptosPagoRelacionado, New DataTable)} + lrds.Add(rds) + lrds.Add(rds2) + + Dim rutaArchivo As String = "" + + 'LOGO + Dim LogoRuta As String = "" + + LogoRuta = String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta) + If File.Exists(LogoRuta) Then + + If File.Exists(LogoRuta) Then + LogoRuta = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + End If + 'POR EMPRESA + params.Add(New ReportParameter("LogoPath", LogoRuta)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + + + If File.Exists($"{UsuarioActual.Empresa.Ruta}\Formatos\ReciboDePago.rdlc") Then + rutaArchivo = $"Empresas\{UsuarioActual.CveEmpresa}\Formatos\ReciboDePago.rdlc" + Else + rutaArchivo = " \Empresas\Grales\Formatos\ReciboDePago.rdlc" + End If + + If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Then + Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") + End If + + + Dim ArchivoPDF As New System.IO.FileInfo($"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf") + If ArchivoPDF.Exists Then + Try + ArchivoPDF.Delete() + File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + Else + File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) + End If + + If imprimir Then + ImprimirPDF(rutaArchivo, lrds, params, SerieFolio, "PDF") + End If + + End If + + ObjBancos.Dispose() + ObjClientes.Dispose() + + End Sub +#End Region + +End Class + From 3ef09adf508214b60156b33b3d44ee4c060ef24d Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Wed, 18 Mar 2020 13:49:41 -0700 Subject: [PATCH 10/24] --- Contabilidad2/CatCuentas.aspx.vb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Contabilidad2/CatCuentas.aspx.vb b/Contabilidad2/CatCuentas.aspx.vb index f96e41d01..7bbd87a3c 100644 --- a/Contabilidad2/CatCuentas.aspx.vb +++ b/Contabilidad2/CatCuentas.aspx.vb @@ -234,7 +234,7 @@ Partial Class Contabilidad2_CatCuentas DdlClientesWS.SelectedText = rowcc("Cliente").ToString().ToEntero() DdlClientesWS.SelectedValue = CveCliente Dim PorcentajeImpuesto As Decimal = rowcc("PorcentajeImpuesto").ToString().ToDecimal() * 100 - DdlClasificacion.SelectedValueExist(PorcentajeImpuesto) + TxtPorcentaje.Text = (PorcentajeImpuesto) CveClasificacion = rowcc("CveClasificacion").ToString().ToEntero() DdlClasificacion.SelectedValueExist(CveClasificacion) CveBancoCuenta = rowcc("CveBancoCuenta").ToString().ToEntero() @@ -292,21 +292,24 @@ Partial Class Contabilidad2_CatCuentas CveConceptoAdmin:=CveConceptoAdmin, CveProveedor:=CveProveedor, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeImpuesto, CveBancoCuenta:=CveBancoCuenta, CveAlmacen:=CveAlmacen) Then Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}") - Using ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa) + If UsuarioActual.Empresa.TipoContabilizacion <> 1 Then - If ObjConta2.GetCuentas(-1, "-1", -1) Then - Dim Id As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigo}'").ToEntero - Dim IdAgrupador As Integer + Using ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa) - If ObjConta2.GetAgrupadoresSAT() Then - IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero - End If - If Id > 0 Then - If ObjConta2.UpdateCuenta(Id, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero, IdAgrupador, SubCuentaDe:=Tsubcuenta.Text.Trim) > 0 Then + If ObjConta2.GetCuentas(-1, "-1", -1) Then + Dim Id As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigo}'").ToEntero + Dim IdAgrupador As Integer + + If ObjConta2.GetAgrupadoresSAT() Then + IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero + End If + If Id > 0 Then + If ObjConta2.UpdateCuenta(Id, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero, IdAgrupador, SubCuentaDe:=Tsubcuenta.Text.Trim) > 0 Then + End If End If End If - End If - End Using + End Using + End If Dim customerRow As Data.DataRow customerRow = DtDatos.Select(String.Format("CveCuenta = {0}", IDSelected))(0) From cf1d13d8a03ba5eb4d7272285191eb965cd8496d Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Mar 2020 16:34:03 -0700 Subject: [PATCH 11/24] - filtrado por area --- Acumuladores/CatFoliosGarantia.aspx | 8 ++++++++ Acumuladores/CatFoliosGarantia.aspx.vb | 4 ++-- Inventarios/RecepcionUsados.aspx.vb | 2 +- Ventas/PV.aspx.vb | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Acumuladores/CatFoliosGarantia.aspx b/Acumuladores/CatFoliosGarantia.aspx index 4dd384796..d5595991a 100644 --- a/Acumuladores/CatFoliosGarantia.aspx +++ b/Acumuladores/CatFoliosGarantia.aspx @@ -281,6 +281,14 @@ + +
+   + + Piso + Almacen + +
<%--
diff --git a/Acumuladores/CatFoliosGarantia.aspx.vb b/Acumuladores/CatFoliosGarantia.aspx.vb index 1d4de3735..778a6275d 100644 --- a/Acumuladores/CatFoliosGarantia.aspx.vb +++ b/Acumuladores/CatFoliosGarantia.aspx.vb @@ -38,7 +38,7 @@ Partial Class Acumuladores_CatFoliosGarantia If Not Page.IsPostBack Then CargaSubProyectos() - CargadatosGvFolioGarantia(-1, "-1") + CargadatosGvFolioGarantia(DdlEstatus.SelectedValue.ToEntero, DdlTipoFolio.SelectedValue) End If End Sub @@ -116,7 +116,7 @@ Partial Class Acumuladores_CatFoliosGarantia If Not Actualizar Then - If ObjAcum.FoliosGarantiaAdd(TxtFolioGarantia.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlSubProyectos.SelectedValue.ToEntero, DdlTipoFolioModal.SelectedValue, TxtLimite.Text.ToEntero, 2) Then + If ObjAcum.FoliosGarantiaAdd(TxtFolioGarantia.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlSubProyectos.SelectedValue.ToEntero, DdlTipoFolioModal.SelectedValue, TxtLimite.Text.ToEntero, DdlArea.SelectedValue.ToEntero) Then TxtFolioGarantia.Text = "" ChkEstatus.Checked = True diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 9ac0d338f..b5a526673 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2621,7 +2621,7 @@ Partial Class Inventarios_RecepcionUsados Private Sub CargaFolioAjuste() DdlFolioGarantia.Items.Clear() Dim ObjAcum As New ClsAcumuladores - If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, Area:=2) Then + If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, Estatus:=1, Area:=2) Then DdlFolioGarantia.DataSource = ObjAcum.DtResultados DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1")) End If diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 0c1cf7a08..a19c6152c 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -5772,7 +5772,7 @@ Partial Class PV Private Sub CargaAjuste() Dim ObjAcum As New ClsAcumuladores - If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, 1) Then + If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, Estatus:=1, Area:=1) Then DdlFolioGarantia.DataSource = ObjAcum.DtResultados DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1")) End If From 833637aaa3ee06fd310ef84be21006582a1d4646 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 18 Mar 2020 19:19:18 -0700 Subject: [PATCH 12/24] Retencion de servicios desde crear a partir de --- Ventas/Ventas.aspx | 2 +- Ventas/Ventas.aspx.vb | 106 ++++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index d05f330be..c691aaab8 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3355,7 +3355,7 @@ - + <%----%> diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 531622ce0..0fae9f162 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5335,65 +5335,65 @@ Partial Class Ventas UPPCreditoDisponible.Update() ElseIf UsuarioActual.CveEmpresa.Contiene(119, 1) AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso CveVenta > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Pd2", "Cot") Or (DdlTipoComprobante.SelectedValue = "Rem" And ModalidadEdicion And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000")) Then Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) - If CreditoDispo > 0 Then - Dim Vta As New ClsVentas - Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) - Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) - Vta.Dispose() - If Opcion > 0 Then - If ModalidadEdicion AndAlso ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero And DdlTipoComprobante.SelectedValue = "Rem" And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000" Then - ViewState("CveCliente") = ViewState("CveClienteAnterior").ToString.ToEntero + If CreditoDispo > 0 Then + Dim Vta As New ClsVentas + Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) + Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

{0}", Vta.SerieVenta) + Vta.Dispose() + If Opcion > 0 Then + If ModalidadEdicion AndAlso ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero And DdlTipoComprobante.SelectedValue = "Rem" And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000" Then + ViewState("CveCliente") = ViewState("CveClienteAnterior").ToString.ToEntero CargaCliente(ViewState("CveCliente").ToString.ToEntero) - If Opcion > 0 Then - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - Else - If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) - End If - BtnEmitirImprimir.Visible = False - BtnVistaPrevia.Visible = False - UpFacturar.Update() - Exit Sub - ElseIf DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso EsCreaApartirDe Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) - BtnGenerarRemision.Visible = False - BtnGenerarOS.Visible = False - BtnEmitirImprimir.Visible = True - BtnsFacturar.Visible = False - Else - - If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then - BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) - End If - BtnGenerarRemision.Visible = False - BtnGenerarOS.Visible = False - BtnEmitirImprimir.Visible = False - BtnsFacturar.Visible = False - If ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero Then - If Opcion > 0 Then - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - Else - If Alertas Then Alert("El cliente tiene límite de crédito agotado.", TipoMensaje.MsgAdvertencia) - End If - End If - End If + If Opcion > 0 Then + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) Else - BtnGeneraAutorizacion.Visible = False - If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then - BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) - End If + If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) End If - Else + BtnEmitirImprimir.Visible = False + BtnVistaPrevia.Visible = False + UpFacturar.Update() + Exit Sub + ElseIf DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso EsCreaApartirDe Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) BtnGenerarRemision.Visible = False + BtnGenerarOS.Visible = False + BtnEmitirImprimir.Visible = True + BtnsFacturar.Visible = False + Else + If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) End If + BtnGenerarRemision.Visible = False + BtnGenerarOS.Visible = False + BtnEmitirImprimir.Visible = False + BtnsFacturar.Visible = False + If ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero Then + If Opcion > 0 Then + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + Else + If Alertas Then Alert("El cliente tiene límite de crédito agotado.", TipoMensaje.MsgAdvertencia) + End If + End If + End If + Else + BtnGeneraAutorizacion.Visible = False + If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then + BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) End If End If + Else + BtnGenerarRemision.Visible = False + If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then + BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) + End If + End If + End If End Sub @@ -13755,7 +13755,9 @@ Partial Class Ventas End Sub Protected Sub DdlSucursalCliente_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSucursalCliente.SelectedIndexChanged CargaClienteSucursal(DdlSucursalCliente.SelectedValue.ToEntero) - CargaRestriccionesCreditoCliente(Alertas:=True) + 'If Me.CveVenta > 0 Then + ' CargaRestriccionesCreditoCliente(Alertas:=True) + 'End If End Sub Protected Sub DdlCCEdit_SelectedIndexChanged(sender As Object, e As System.EventArgs) Dim gvr As GridViewRow = DirectCast(DirectCast(sender, DropDownList).BindingContainer, GridViewRow) @@ -24167,9 +24169,11 @@ Partial Class Ventas PlazoCobranzaRemision = ObjCliente.PlazoCobranzaRemision 'TxtNumCtaPago.Text = ObjCliente.NumCtaPago TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString + DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString) End If End If ObjCliente.Dispose() + DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) TrVistaPrevia.Visible = True TxtFechaVencimientoCotizacion.Text = Now.ToShortDateString @@ -24930,7 +24934,7 @@ Partial Class Ventas Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then For Each RowServicio As DataRow In TmpDT.Rows From a3c38cc1219c8c0a2b897ea9d5b7f2b2af4e405e Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 19 Mar 2020 10:09:30 -0700 Subject: [PATCH 13/24] - --- Contabilidad/ContabilizacionVentas.aspx | 2 +- Inventarios/RecepcionUsados.aspx.vb | 11 +- Ventas/ClientesAbonar.aspx.vb | 2868 +++++++++++------------ 3 files changed, 1442 insertions(+), 1439 deletions(-) diff --git a/Contabilidad/ContabilizacionVentas.aspx b/Contabilidad/ContabilizacionVentas.aspx index 3cb3117cb..8eb4fa9aa 100644 --- a/Contabilidad/ContabilizacionVentas.aspx +++ b/Contabilidad/ContabilizacionVentas.aspx @@ -217,7 +217,7 @@ - + diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index b5a526673..46e950f43 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -1730,11 +1730,12 @@ Partial Class Inventarios_RecepcionUsados DivClienteSucursal.Visible = False DdlClientesSucursales.Items.Clear() - Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("EsDistribuidor", $"CveCliente = {DdlClientes.SelectedValue.ToEntero()}")) - - CargaSucursalesCliente() - CargaFacturasCliente() + If DdlClientes.SelectedValue.ToEntero > 0 Then + Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("EsDistribuidor", "")) + CargaSucursalesCliente() + CargaFacturasCliente() + End If UpGenerales.Update() End Sub Private Sub CargaFacturasCliente() @@ -2767,6 +2768,8 @@ Partial Class Inventarios_RecepcionUsados "", "-1", "-1", "-1", "", "", "", -1, "", "", CveTamaño) End If + Else + Alert("No se pudo cargar el producto", TipoMensaje.MsgError) End If ObjPS.Dispose() End Sub diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 99fa14ae2..3ad207baf 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -1,658 +1,658 @@ Imports Extensiones Imports System.Data -Imports System.Linq - -Partial Class Ventas_ClientesAbonar +Imports System.Linq + +Partial Class Ventas_ClientesAbonar Inherits ClsPaginas -#Region "Propiedades" - Private ReadOnly Property CveCliente As Integer - Get - Return ViewState("CveCliente").ToString.ToEntero - End Get - End Property - Private Property CveMoneda As Integer - Get - Return ViewState("CveMoneda").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMoneda") = value - End Set - End Property - - Private Property CveMonedaPago As Integer - Get - Return ViewState("CveMonedaPago").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMonedaPago") = value - End Set - End Property - Private Property CveMonedaFiltro As Integer - Get - Return ViewState("CveMonedaFiltro").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMonedaFiltro") = value - End Set - End Property - Private Property CveSubProyecto As Integer - Get - Return ViewState("CveSubProyecto").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveSubProyecto") = value - End Set - End Property - Private Property CveClienteSucursal As Integer - Get - Return If(IsNothing(ViewState("CveClienteSucursal")), -1, ViewState("CveClienteSucursal").ToString.ToEntero) - End Get - Set(value As Integer) - ViewState("CveClienteSucursal") = value - End Set - End Property - Private Property DTFuenteRecaudacion As DataTable - Get - Return CType(ViewState("DTFuenteRecaudacion"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTFuenteRecaudacion") = value - End Set - End Property - - Private Property IdCuentaBancaria As Integer - Get - Return ViewState("IdCuentaBancaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCuentaBancaria") = value - End Set - End Property - Private Property IdCuentaBancariaComplementaria As Integer - Get - Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCuentaBancariaComplementaria") = value - End Set - End Property - Private Property CveCuentaBancaria As Integer - Get - Return ViewState("CveCuentaBancaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBancaria") = value - End Set - End Property - Private Property CveCuentaBancariaComplementaria As Integer - Get - Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBancariaComplementaria") = value - End Set - End Property - Private Property NombreComercial As String - Get - Return ViewState("NombreComercial").ToString - End Get - Set(value As String) - ViewState("NombreComercial") = value - End Set - End Property - - Private Property IdCuentaCliente As Integer - Get - Return ViewState("IdCuentaCliente").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCuentaCliente") = value - End Set - End Property - Private ReadOnly Property IdCtaContMonedaExtranjera As Integer - Get - Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property IdCtaContComplementaria As Integer - Get - Return ViewState("IdCtaContComplementaria").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property IdCtaContRetIVA As Integer - Get - Return ViewState("IdCtaContRetIVA").ToString.ToEntero - End Get - End Property - Private ReadOnly Property IdCtaContRetISR As Integer - Get - Return ViewState("IdCtaContRetISR").ToString.ToEntero - End Get - End Property - Private Property IdCtaAnticipo As Integer - Get - Return ViewState("IdCtaAnticipo").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCtaAnticipo") = value - End Set - End Property - Private Property IdCtaContMonedaExtranjeraAnticipo As Integer - Get - Return ViewState("IdCtaContMonedaExtranjeraAnticipo").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCtaContMonedaExtranjeraAnticipo") = value - End Set - End Property - Private Property IdCtaContMonedaComplementariaAnticipo As Integer - Get - Return ViewState("IdCtaContMonedaComplementariaAnticipo").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IdCtaContMonedaComplementariaAnticipo") = value - End Set - End Property - - Private Property CveCuentaCliente As Integer - Get - Return ViewState("CveCuentaCliente").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaCliente") = value - End Set - End Property - Private ReadOnly Property CveCuentaMonedaExtranjera As Integer - Get - Return ViewState("CveCuentaMonedaExtranjera").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property CveCuentaComplementaria As Integer - Get - Return ViewState("CveCuentaComplementaria").ToString.ToEntero - End Get - End Property - - Private ReadOnly Property CveCuentaRetIVA As Integer - Get - Return ViewState("CveCuentaRetIVA").ToString.ToEntero - End Get - End Property - Private ReadOnly Property CveCuentaRetISR As Integer - Get - Return ViewState("CveCuentaRetISR").ToString.ToEntero - End Get - End Property - - Private Property EmpresaPrueba As Boolean - Get - Return CBool(ViewState("EmpresaPrueba")) - End Get - Set(value As Boolean) - ViewState("EmpresaPrueba") = value - End Set - End Property - - Private Property Mail As String - Get - If ViewState("Mail") Is Nothing Then - Return "" - Else - Return ViewState("Mail").ToString - End If - End Get - Set(value As String) - ViewState("Mail") = value - End Set - End Property - Private Property CveIESustitucion As Integer - Get - Return ViewState("CveIESustitucion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveIESustitucion") = value - End Set - End Property - Private Property CFDIRelacionadoSustitucion As String - Get - If ViewState("CFDIRelacionadoSustitucion") Is Nothing Then - Return "-1" - Else - Return ViewState("CFDIRelacionadoSustitucion").ToString - End If - End Get - Set(value As String) - ViewState("CFDIRelacionadoSustitucion") = value - End Set - End Property - Private Property FechaCorteIE As DateTime - Get - Return ViewState("FechaCorteIE").ToString.ToDateTime - End Get - Set(value As DateTime) - ViewState("FechaCorteIE") = value - End Set - End Property - Private Property IDPoliza As Integer - Get - Return ViewState("IDPoliza").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("IDPoliza") = value - End Set - End Property - Private Property FolioIECancelado As String - Get - If ViewState("FolioIECancelado") Is Nothing Then - Return "-1" - Else - Return ViewState("FolioIECancelado").ToString - End If - End Get - Set(value As String) - ViewState("FolioIECancelado") = value - End Set - End Property - Private Property ComplementoSustitucionGenerado As Boolean - Get - Return CBool(ViewState("ComplementoSustitucionGenerado")) - End Get - Set(value As Boolean) - ViewState("ComplementoSustitucionGenerado") = value - End Set - End Property - Private Property Fecha As Date - Get - Return ViewState("Fecha").ToString.ToDate - End Get - Set(value As Date) - ViewState("Fecha") = value - End Set +#Region "Propiedades" + Private ReadOnly Property CveCliente As Integer + Get + Return ViewState("CveCliente").ToString.ToEntero + End Get + End Property + Private Property CveMoneda As Integer + Get + Return ViewState("CveMoneda").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMoneda") = 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 - CveMonedaPago = -1 - If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToString.ToEntero > 0 Then - ViewState("CveCliente") = Request("CveCliente").ToString.ToEntero - 'ViewState("CveUsuario") = IfNultl(Request("CveUsuario"), "-1").ToStrirowComisionesng.ToEntero - ViewState("CveMonedaFiltro") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero - ViewState("CveMoneda") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero - ViewState("FechaI") = IfNull(Request("FechaI"), "-1").ToString.ToEntero - ViewState("FechaE") = IfNull(Request("FechaE"), "-1").ToString.ToEntero - ViewState("CveSubProyecto") = IfNull(Request("CveSubProyecto"), "-1").ToString.ToEntero - ViewState("CveClienteSucursal") = IfNull(Request("CveClienteSucursal"), "-1").ToString.ToEntero - - ViewState("IdCtaAnticipo") = 0 - ViewState("IdCtaContMonedaExtranjeraAnticipo") = 0 - ViewState("IdCtaContMonedaComplementariaAnticipo") = 0 - - ViewState("CveIESustitucion") = IfNull(Request("CveIESustitucion"), "-1").ToString.ToEntero - DdlProveedorIntermediario.setEsWebService(True) - DdlProveedorIntermediario.Attributes.Add("data-metodo", "getproveedores") - - FechaCorteIE = DateTime.Now - - If CveIESustitucion > 0 Then - CargaIESustituir() - End If - - Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, Now.Day - 1, Now.Day) - Fecha = (dia.ToString + "/" + Now.Month.ToString + "/" + Now.Year.ToString).ToDate - - If CargaCliente(CveCliente, CveMonedaFiltro) Then - - IdCuentaBancaria = 0 - CveCuentaBancaria = 0 - - TxtOtrosImportes.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1});", "TxtTotal", 0)) - - - If Not UsuarioActual.Empresa.UsaAC Then - EmpresaPrueba = True - End If - - If CveMoneda > 0 Then LbTipoMoneda.Text = String.Format("Pago en {0}", GlobalDTMonedas.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)).Rows(0)("Moneda")) - - - If CveMoneda = 2 Then - ChkPagarPesos.Visible = True - TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - DivTCDolaresDolares.Visible = True - TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") - ElseIf CveMoneda = 1 Then - ChkPagarDolares.Visible = True - TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - ElseIf CveMoneda = -1 Then - TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") - TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + Private Property CveMonedaPago As Integer + Get + Return ViewState("CveMonedaPago").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMonedaPago") = value + End Set + End Property + Private Property CveMonedaFiltro As Integer + Get + Return ViewState("CveMonedaFiltro").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMonedaFiltro") = value + End Set + End Property + Private Property CveSubProyecto As Integer + Get + Return ViewState("CveSubProyecto").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveSubProyecto") = value + End Set + End Property + Private Property CveClienteSucursal As Integer + Get + Return If(IsNothing(ViewState("CveClienteSucursal")), -1, ViewState("CveClienteSucursal").ToString.ToEntero) + End Get + Set(value As Integer) + ViewState("CveClienteSucursal") = value + End Set + End Property + Private Property DTFuenteRecaudacion As DataTable + Get + Return CType(ViewState("DTFuenteRecaudacion"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTFuenteRecaudacion") = value + End Set + End Property + + Private Property IdCuentaBancaria As Integer + Get + Return ViewState("IdCuentaBancaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaBancaria") = value + End Set + End Property + Private Property IdCuentaBancariaComplementaria As Integer + Get + Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaBancariaComplementaria") = value + End Set + End Property + Private Property CveCuentaBancaria As Integer + Get + Return ViewState("CveCuentaBancaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBancaria") = value + End Set + End Property + Private Property CveCuentaBancariaComplementaria As Integer + Get + Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBancariaComplementaria") = value + End Set + End Property + Private Property NombreComercial As String + Get + Return ViewState("NombreComercial").ToString + End Get + Set(value As String) + ViewState("NombreComercial") = value + End Set + End Property + + Private Property IdCuentaCliente As Integer + Get + Return ViewState("IdCuentaCliente").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaCliente") = value + End Set + End Property + Private ReadOnly Property IdCtaContMonedaExtranjera As Integer + Get + Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property IdCtaContComplementaria As Integer + Get + Return ViewState("IdCtaContComplementaria").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property IdCtaContRetIVA As Integer + Get + Return ViewState("IdCtaContRetIVA").ToString.ToEntero + End Get + End Property + Private ReadOnly Property IdCtaContRetISR As Integer + Get + Return ViewState("IdCtaContRetISR").ToString.ToEntero + End Get + End Property + Private Property IdCtaAnticipo As Integer + Get + Return ViewState("IdCtaAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCtaAnticipo") = value + End Set + End Property + Private Property IdCtaContMonedaExtranjeraAnticipo As Integer + Get + Return ViewState("IdCtaContMonedaExtranjeraAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCtaContMonedaExtranjeraAnticipo") = value + End Set + End Property + Private Property IdCtaContMonedaComplementariaAnticipo As Integer + Get + Return ViewState("IdCtaContMonedaComplementariaAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCtaContMonedaComplementariaAnticipo") = value + End Set + End Property + + Private Property CveCuentaCliente As Integer + Get + Return ViewState("CveCuentaCliente").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaCliente") = value + End Set + End Property + Private ReadOnly Property CveCuentaMonedaExtranjera As Integer + Get + Return ViewState("CveCuentaMonedaExtranjera").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property CveCuentaComplementaria As Integer + Get + Return ViewState("CveCuentaComplementaria").ToString.ToEntero + End Get + End Property + + Private ReadOnly Property CveCuentaRetIVA As Integer + Get + Return ViewState("CveCuentaRetIVA").ToString.ToEntero + End Get + End Property + Private ReadOnly Property CveCuentaRetISR As Integer + Get + Return ViewState("CveCuentaRetISR").ToString.ToEntero + End Get + End Property + + Private Property EmpresaPrueba As Boolean + Get + Return CBool(ViewState("EmpresaPrueba")) + End Get + Set(value As Boolean) + ViewState("EmpresaPrueba") = value + End Set + End Property + + Private Property Mail As String + Get + If ViewState("Mail") Is Nothing Then + Return "" + Else + Return ViewState("Mail").ToString + End If + End Get + Set(value As String) + ViewState("Mail") = value + End Set + End Property + Private Property CveIESustitucion As Integer + Get + Return ViewState("CveIESustitucion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveIESustitucion") = value + End Set + End Property + Private Property CFDIRelacionadoSustitucion As String + Get + If ViewState("CFDIRelacionadoSustitucion") Is Nothing Then + Return "-1" + Else + Return ViewState("CFDIRelacionadoSustitucion").ToString + End If + End Get + Set(value As String) + ViewState("CFDIRelacionadoSustitucion") = value + End Set + End Property + Private Property FechaCorteIE As DateTime + Get + Return ViewState("FechaCorteIE").ToString.ToDateTime + End Get + Set(value As DateTime) + ViewState("FechaCorteIE") = value + End Set + End Property + Private Property IDPoliza As Integer + Get + Return ViewState("IDPoliza").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IDPoliza") = value + End Set + End Property + Private Property FolioIECancelado As String + Get + If ViewState("FolioIECancelado") Is Nothing Then + Return "-1" + Else + Return ViewState("FolioIECancelado").ToString + End If + End Get + Set(value As String) + ViewState("FolioIECancelado") = value + End Set + End Property + Private Property ComplementoSustitucionGenerado As Boolean + Get + Return CBool(ViewState("ComplementoSustitucionGenerado")) + End Get + Set(value As Boolean) + ViewState("ComplementoSustitucionGenerado") = value + End Set + End Property + Private Property Fecha As Date + Get + Return ViewState("Fecha").ToString.ToDate + End Get + Set(value As Date) + ViewState("Fecha") = 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 + CveMonedaPago = -1 + If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToString.ToEntero > 0 Then + ViewState("CveCliente") = Request("CveCliente").ToString.ToEntero + 'ViewState("CveUsuario") = IfNultl(Request("CveUsuario"), "-1").ToStrirowComisionesng.ToEntero + ViewState("CveMonedaFiltro") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero + ViewState("CveMoneda") = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero + ViewState("FechaI") = IfNull(Request("FechaI"), "-1").ToString.ToEntero + ViewState("FechaE") = IfNull(Request("FechaE"), "-1").ToString.ToEntero + ViewState("CveSubProyecto") = IfNull(Request("CveSubProyecto"), "-1").ToString.ToEntero + ViewState("CveClienteSucursal") = IfNull(Request("CveClienteSucursal"), "-1").ToString.ToEntero + + ViewState("IdCtaAnticipo") = 0 + ViewState("IdCtaContMonedaExtranjeraAnticipo") = 0 + ViewState("IdCtaContMonedaComplementariaAnticipo") = 0 + + ViewState("CveIESustitucion") = IfNull(Request("CveIESustitucion"), "-1").ToString.ToEntero + DdlProveedorIntermediario.setEsWebService(True) + DdlProveedorIntermediario.Attributes.Add("data-metodo", "getproveedores") + + FechaCorteIE = DateTime.Now + + If CveIESustitucion > 0 Then + CargaIESustituir() + End If + + Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, Now.Day - 1, Now.Day) + Fecha = (dia.ToString + "/" + Now.Month.ToString + "/" + Now.Year.ToString).ToDate + + If CargaCliente(CveCliente, CveMonedaFiltro) Then + + IdCuentaBancaria = 0 + CveCuentaBancaria = 0 + + TxtOtrosImportes.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1});", "TxtTotal", 0)) + + + If Not UsuarioActual.Empresa.UsaAC Then + EmpresaPrueba = True + End If + + If CveMoneda > 0 Then LbTipoMoneda.Text = String.Format("Pago en {0}", GlobalDTMonedas.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)).Rows(0)("Moneda")) + + + If CveMoneda = 2 Then + ChkPagarPesos.Visible = True TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - End If - - If UsuarioActual.TienePermisoProceso(209) Or UsuarioActual.TienePermisoProceso(204) Then - HlSaldarCuentasIncobrables.Visible = True - End If - - End If - - If CveMonedaFiltro = -1 Then - ChkPagarPesos.Visible = False - ChkPagarDolares.Visible = False - End If - - RegistraScript($"TipoCambioActual = {GlobalTipoCambio(Fecha).FormatoNumero(4)}") - End If - - RVTxtFechaDocumento.MaximumValue = Now.ToString("dd/MM/yyyy") - - End If - - If (CveMonedaFiltro = 2 And ChkPagarPesos.Checked) Then - RegistraScript("document.getElementById('DivTC').style.display = 'block';") - End If - - End Sub - - Private Sub CargaTipoTransaccion() - DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Ing' AND Estatus = 1 ") - DdlTipoTransaccion.DataBind() - DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) - RecargaCuentasDepositos() - End Sub - - Private Sub CargaCuentas() - DdlCuenta.Items.Clear() - Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) - - If ChkPagarPesos.Checked Then - dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1)) - RegistraScript("CambiaPesosDolares();") - ElseIf ChkPagarDolares.Checked Then - dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2)) - RegistraScript("CambiaDolaresPesos();") - Else - If CveMonedaFiltro > 0 Then - dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMonedaFiltro)) - End If - End If - - DdlCuenta.DataSource = dt - DdlCuenta.DataBind() - DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) - End Sub - - Private Function CargaCliente(tCveCliente As Integer, tCveMoneda As Integer) As Boolean - Dim Retorno As Boolean = False - Dim ObjCliente As New ClsClientes() - If ObjCliente.GetClientes(tCveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then - If ObjCliente.DtResultados.Rows.Count > 0 Then - Retorno = True - CargaCuentas() - CargaTipoTransaccion() - TxtFechaDocumento.Text = IIf(CveIESustitucion > 0, FechaCorteIE.ToShortDateString, Now.ToShortDateString).ToString - - TxtAboneA.Enabled = False - LbEncabezado.Text = String.Format("{1}", CveCliente, ObjCliente.NombreComercial) - TxtAboneA.Text = ObjCliente.NombreComercial - NombreComercial = ObjCliente.NombreComercial - TxtImporte.Attributes.Add("disabled", "disabled") - If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False - ViewState("CtaCliente") = ObjCliente.IdCtaContClientes - ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes - ViewState("IdCtaContMonedaExtranjera") = ObjCliente.IdCtaContMonedaExtranjera - ViewState("IdCtaContComplementaria") = ObjCliente.IdCtaContComplementaria - ViewState("IdCtaContRetIVA") = ObjCliente.IdCtaContRetIVA - ViewState("IdCtaContRetISR") = ObjCliente.IdCtaContRetISR - - ViewState("CveCuentaCliente") = ObjCliente.CveCuentaClientes - ViewState("CveCuentaMonedaExtranjera") = ObjCliente.CveCuentaMonedaExtranjera - ViewState("CveCuentaComplementaria") = ObjCliente.CveCuentaComplementaria - ViewState("CveCuentaRetIVA") = ObjCliente.CveCuentaRetIVA - ViewState("CveCuentaRetISR") = ObjCliente.CveCuentaRetISR - - ViewState("IdCtaAnticipo") = ObjCliente.IdCtaContAnticipos - ViewState("IdCtaContMonedaExtranjeraAnticipo") = ObjCliente.IdCtaMonedaExtranjeraAnticipos - ViewState("IdCtaContMonedaComplementariaAnticipo") = ObjCliente.IdCtaContCompAnticipos - - Mail = String.Format("{0};{1}", ObjCliente.CobranzaCorreo, ObjCliente.NotificarA) - - If Request("FechaI") IsNot Nothing Then ViewState("FechaI") = Request("FechaI") Else ViewState("FechaI") = "-1" - If Request("FechaF") IsNot Nothing Then ViewState("FechaF") = Request("FechaF") Else ViewState("FechaF") = "-1" - - CargaDatos(tCveMoneda) - Else - Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) - End If - End If - ObjCliente.Dispose() - Return Retorno - End Function - - Private Sub CargaDatos(pCveMoneda As Integer) - Dim Mov As New ClsMovimientos - Dim FechaI As String = IfNull(Request("FechaI"), "-1") - Dim FechaF As String = IfNull(Request("FechaF"), "-1") - - Dim FechaCorte As Date = IIf(CveIESustitucion > 0, (FechaCorteIE.ToDate).ToShortDateString, DateTime.Now.AddYears(1).ToShortDateString).ToString.ToDate - - Dim SumDescuentoProntoPago As Double = 0.0 - If Mov.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, FechaI, FechaF, pCveMoneda, CveSubProyecto, UsuarioActual.CveEmpresa, CveClienteSucursal, FechaCorte:=FechaCorte, CveIESustitucion:=CveIESustitucion) Then - Dim TmpCxCAux As DataTable - TmpCxCAux = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio") - SumDescuentoProntoPago = TmpCxCAux.SUM("DescuentoProntoPago") - - GvCxC.DataSource = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio") - GvCxC.DataBind() - CveMoneda = pCveMoneda - - End If - TxtImporte.Text = "" - TxtObservaciones.Text = "" - If SumDescuentoProntoPago > 0.0 Then - GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO + TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + DivTCDolaresDolares.Visible = True + TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") + ElseIf CveMoneda = 1 Then + ChkPagarDolares.Visible = True + TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + ElseIf CveMoneda = -1 Then + TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") + TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + End If + + If UsuarioActual.TienePermisoProceso(209) Or UsuarioActual.TienePermisoProceso(204) Then + HlSaldarCuentasIncobrables.Visible = True + End If + + End If + + If CveMonedaFiltro = -1 Then + ChkPagarPesos.Visible = False + ChkPagarDolares.Visible = False + End If + + RegistraScript($"TipoCambioActual = {GlobalTipoCambio(Fecha).FormatoNumero(4)}") + End If + + RVTxtFechaDocumento.MaximumValue = Now.ToString("dd/MM/yyyy") + + End If + + If (CveMonedaFiltro = 2 And ChkPagarPesos.Checked) Then + RegistraScript("document.getElementById('DivTC').style.display = 'block';") + End If + + End Sub + + Private Sub CargaTipoTransaccion() + DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Ing' AND Estatus = 1 ") + DdlTipoTransaccion.DataBind() + DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + RecargaCuentasDepositos() + End Sub + + Private Sub CargaCuentas() + DdlCuenta.Items.Clear() + Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) + + If ChkPagarPesos.Checked Then + dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1)) + RegistraScript("CambiaPesosDolares();") + ElseIf ChkPagarDolares.Checked Then + dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2)) + RegistraScript("CambiaDolaresPesos();") + Else + If CveMonedaFiltro > 0 Then + dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMonedaFiltro)) + End If + End If + + DdlCuenta.DataSource = dt + DdlCuenta.DataBind() + DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) + End Sub + + Private Function CargaCliente(tCveCliente As Integer, tCveMoneda As Integer) As Boolean + Dim Retorno As Boolean = False + Dim ObjCliente As New ClsClientes() + If ObjCliente.GetClientes(tCveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + Retorno = True + CargaCuentas() + CargaTipoTransaccion() + TxtFechaDocumento.Text = IIf(CveIESustitucion > 0, FechaCorteIE.ToShortDateString, Now.ToShortDateString).ToString + + TxtAboneA.Enabled = False + LbEncabezado.Text = String.Format("{1}", CveCliente, ObjCliente.NombreComercial) + TxtAboneA.Text = ObjCliente.NombreComercial + NombreComercial = ObjCliente.NombreComercial + TxtImporte.Attributes.Add("disabled", "disabled") + If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False + ViewState("CtaCliente") = ObjCliente.IdCtaContClientes + ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes + ViewState("IdCtaContMonedaExtranjera") = ObjCliente.IdCtaContMonedaExtranjera + ViewState("IdCtaContComplementaria") = ObjCliente.IdCtaContComplementaria + ViewState("IdCtaContRetIVA") = ObjCliente.IdCtaContRetIVA + ViewState("IdCtaContRetISR") = ObjCliente.IdCtaContRetISR + + ViewState("CveCuentaCliente") = ObjCliente.CveCuentaClientes + ViewState("CveCuentaMonedaExtranjera") = ObjCliente.CveCuentaMonedaExtranjera + ViewState("CveCuentaComplementaria") = ObjCliente.CveCuentaComplementaria + ViewState("CveCuentaRetIVA") = ObjCliente.CveCuentaRetIVA + ViewState("CveCuentaRetISR") = ObjCliente.CveCuentaRetISR + + ViewState("IdCtaAnticipo") = ObjCliente.IdCtaContAnticipos + ViewState("IdCtaContMonedaExtranjeraAnticipo") = ObjCliente.IdCtaMonedaExtranjeraAnticipos + ViewState("IdCtaContMonedaComplementariaAnticipo") = ObjCliente.IdCtaContCompAnticipos + + Mail = String.Format("{0};{1}", ObjCliente.CobranzaCorreo, ObjCliente.NotificarA) + + If Request("FechaI") IsNot Nothing Then ViewState("FechaI") = Request("FechaI") Else ViewState("FechaI") = "-1" + If Request("FechaF") IsNot Nothing Then ViewState("FechaF") = Request("FechaF") Else ViewState("FechaF") = "-1" + + CargaDatos(tCveMoneda) + Else + Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) + End If + End If + ObjCliente.Dispose() + Return Retorno + End Function + + Private Sub CargaDatos(pCveMoneda As Integer) + Dim Mov As New ClsMovimientos + Dim FechaI As String = IfNull(Request("FechaI"), "-1") + Dim FechaF As String = IfNull(Request("FechaF"), "-1") + + Dim FechaCorte As Date = IIf(CveIESustitucion > 0, (FechaCorteIE.ToDate).ToShortDateString, DateTime.Now.AddYears(1).ToShortDateString).ToString.ToDate + + Dim SumDescuentoProntoPago As Double = 0.0 + If Mov.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, FechaI, FechaF, pCveMoneda, CveSubProyecto, UsuarioActual.CveEmpresa, CveClienteSucursal, FechaCorte:=FechaCorte, CveIESustitucion:=CveIESustitucion) Then + Dim TmpCxCAux As DataTable + TmpCxCAux = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio") + SumDescuentoProntoPago = TmpCxCAux.SUM("DescuentoProntoPago") + + GvCxC.DataSource = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio") + GvCxC.DataBind() + CveMoneda = pCveMoneda + + End If + TxtImporte.Text = "" + TxtObservaciones.Text = "" + If SumDescuentoProntoPago > 0.0 Then + GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then GvCxC.Columns(15).Visible = True 'HABILITAR NC - End If - End If - - Mov.Dispose() - UPVentas.Update() - End Sub - - Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged - 'recargo la moneda con la que se va a pagar - Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) - Dim moneda As Integer = 0 - If DdlCuenta.SelectedValue > 0 Then - moneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero - End If - - CveMonedaPago = moneda - - If dr IsNot Nothing Then - If ChkPagarPesos.Checked Then - CveMoneda = 2 - RegistraScript("document.getElementById('DivTC').style.display = 'block';") - RegistraScript("CambiaPesosDolares();") - TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) - ElseIf ChkPagarPesos.Checked = False Then - CveMoneda = dr("CveMoneda").ToString.ToEntero - RegistraScript("document.getElementById('DivTC').style.display = 'none';") - RegistraScript("CambiaDolaresPesos();") - TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) - End If - - If ChkPagarDolares.Checked Then - CveMoneda = 1 - TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) - End If - - IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero - IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero - - CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero - CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero - ValidaCuentaDePagoFormaDePago() - End If - - CargaDatos(CveMoneda) - - - ' si no tiene CveMoneda, o es -1, cuando cambia de cuenta filtra las facturas - If IfNull(Request("CveMoneda"), "-1").ToString.ToEntero = -1 Then - CargaDatos(-1) - - moneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero - If moneda = 1 Then - 'DivTC.Visible = True - DivTCDolares.Visible = False - TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) - ElseIf moneda = 2 Then - 'DivTC.Visible = False - RegistraScript("document.getElementById('DivTC').style.display = 'none';") - DivTCDolares.Visible = True - TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) - End If - End If - - If HdnTipoTransaccion.Value = "Ing" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then - If UsuarioActual.CveEmpresa = 119 Then - Dim ObjFolios As New ClsGralFolios - If ObjFolios.GetFolios("RMF", UsuarioActual.CveEmpresa) Then - Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo'")) - If DT.Rows.Count > 0 Then - TxtFolio.Text = DT.Rows(0)("FActual").ToString.ToEntero - End If - ObjFolios.Dispose() - End If - Else - Dim Folio As Long - Dim Banco As New ClsBancos - Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) - Banco.Dispose() - TxtFolio.Text = Folio.ToString - - End If - - Else - TxtFolio.Text = "" - - End If - - - End Sub - - Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged - Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing - If dr IsNot Nothing Then - HdnTipoTransaccion.Value = dr("Tipo").ToString - End If - RecargaCuentasDepositos() - 'CargaCuentas() - ValidaCuentaDePagoFormaDePago() - End Sub - - Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim moneda As Integer = 0 - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).ColumnSpan = 5 - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(1).Visible = False - e.Row.Cells(2).Visible = False - e.Row.Cells(3).Visible = False - e.Row.Cells(4).Visible = False - e.Row.BackColor = Drawing.Color.LightGray - End If - If e.Row.RowIndex = 1 Then - e.Row.Cells(0).Width = Unit.Pixel(25) - e.Row.Cells(1).Width = Unit.Pixel(90) - e.Row.Cells(2).Width = Unit.Pixel(70) - e.Row.Cells(3).Width = Unit.Pixel(70) - e.Row.Cells(6).Width = Unit.Pixel(50) - e.Row.Cells(7).Width = Unit.Pixel(70) - e.Row.Cells(8).Width = Unit.Pixel(50) - e.Row.Cells(9).Width = Unit.Pixel(90) - e.Row.Cells(10).Width = Unit.Pixel(80) - e.Row.Cells(11).Width = Unit.Pixel(60) - End If - - ' e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right - ' e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right - ' e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right - - If e.Row.DBCampo("Saldo").ToDecimal < 0 Then e.Row.Cells(11).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("DiasVencidos").ToDecimal > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(5).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("Original").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" - If e.Row.DBCampo("Abonado").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" - If e.Row.DBCampo("Saldo").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" - - Select Case RblTipoPago.SelectedValue - Case "1" - If DdlCuenta.SelectedValue > 0 Then - moneda = CveMonedaPago - ElseIf RblTipoPago.SelectedValue = "1" Then - e.Row.FCCheckBox("Chk").Enabled = False - e.Row.FCTextBox("TxtAbonar").Enabled = False - End If - Case "3" - moneda = CveMonedaPago - - End Select - + End If + End If + + Mov.Dispose() + UPVentas.Update() + End Sub + + Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged + 'recargo la moneda con la que se va a pagar + Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) + Dim moneda As Integer = 0 + If DdlCuenta.SelectedValue > 0 Then + moneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero + End If + + CveMonedaPago = moneda + + If dr IsNot Nothing Then + If ChkPagarPesos.Checked Then + CveMoneda = 2 + RegistraScript("document.getElementById('DivTC').style.display = 'block';") + RegistraScript("CambiaPesosDolares();") + TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) + ElseIf ChkPagarPesos.Checked = False Then + CveMoneda = dr("CveMoneda").ToString.ToEntero + RegistraScript("document.getElementById('DivTC').style.display = 'none';") + RegistraScript("CambiaDolaresPesos();") + TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) + End If + + If ChkPagarDolares.Checked Then + CveMoneda = 1 + TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) + End If + + IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero + IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero + + CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero + ValidaCuentaDePagoFormaDePago() + End If + + CargaDatos(CveMoneda) + + + ' si no tiene CveMoneda, o es -1, cuando cambia de cuenta filtra las facturas + If IfNull(Request("CveMoneda"), "-1").ToString.ToEntero = -1 Then + CargaDatos(-1) + + moneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero + If moneda = 1 Then + 'DivTC.Visible = True + DivTCDolares.Visible = False + TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) + ElseIf moneda = 2 Then + 'DivTC.Visible = False + RegistraScript("document.getElementById('DivTC').style.display = 'none';") + DivTCDolares.Visible = True + TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) + End If + End If + + If HdnTipoTransaccion.Value = "Ing" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then + If UsuarioActual.CveEmpresa = 119 Then + Dim ObjFolios As New ClsGralFolios + If ObjFolios.GetFolios("RMF", UsuarioActual.CveEmpresa) Then + Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo'")) + If DT.Rows.Count > 0 Then + TxtFolio.Text = DT.Rows(0)("FActual").ToString.ToEntero + End If + ObjFolios.Dispose() + End If + Else + Dim Folio As Long + Dim Banco As New ClsBancos + Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) + Banco.Dispose() + TxtFolio.Text = Folio.ToString + + End If + + Else + TxtFolio.Text = "" + + End If + + + End Sub + + Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged + Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing + If dr IsNot Nothing Then + HdnTipoTransaccion.Value = dr("Tipo").ToString + End If + RecargaCuentasDepositos() + 'CargaCuentas() + ValidaCuentaDePagoFormaDePago() + End Sub + + Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim moneda As Integer = 0 + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).ColumnSpan = 5 + e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(1).Visible = False + e.Row.Cells(2).Visible = False + e.Row.Cells(3).Visible = False + e.Row.Cells(4).Visible = False + e.Row.BackColor = Drawing.Color.LightGray + End If + If e.Row.RowIndex = 1 Then + e.Row.Cells(0).Width = Unit.Pixel(25) + e.Row.Cells(1).Width = Unit.Pixel(90) + e.Row.Cells(2).Width = Unit.Pixel(70) + e.Row.Cells(3).Width = Unit.Pixel(70) + e.Row.Cells(6).Width = Unit.Pixel(50) + e.Row.Cells(7).Width = Unit.Pixel(70) + e.Row.Cells(8).Width = Unit.Pixel(50) + e.Row.Cells(9).Width = Unit.Pixel(90) + e.Row.Cells(10).Width = Unit.Pixel(80) + e.Row.Cells(11).Width = Unit.Pixel(60) + End If + + ' e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right + ' e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right + ' e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right + + If e.Row.DBCampo("Saldo").ToDecimal < 0 Then e.Row.Cells(11).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("DiasVencidos").ToDecimal > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(5).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("Original").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" + If e.Row.DBCampo("Abonado").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" + If e.Row.DBCampo("Saldo").ToDecimal = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" + + Select Case RblTipoPago.SelectedValue + Case "1" + If DdlCuenta.SelectedValue > 0 Then + moneda = CveMonedaPago + ElseIf RblTipoPago.SelectedValue = "1" Then + e.Row.FCCheckBox("Chk").Enabled = False + e.Row.FCTextBox("TxtAbonar").Enabled = False + End If + Case "3" + moneda = CveMonedaPago + + End Select + If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 Then e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnSeleccionaNC({5},{6},{0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.FCCheckBox("Chk").ClientID, e.Row.FCCheckBox("ChkGenerarNC").ClientID)) Else e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda)) End If - If Not UsuarioActual.Empresa.Funcionalidad(536) = "1" Then - If e.Row.DBCampo("TipoDocto") = "Rem" Then - e.Row.FCCheckBox("Chk").Visible = False ' que no se pueda pagar si es remisión - e.Row.Cells(0).ToolTip = "El documento es remisión y no se puede realizar el pago" - End If - End If - - - If e.Row.DBCampo("CveVenta").ToEntero > 0 Then - e.Row.FCLiteral("LtlAux").Text = String.Format("Ir", e.Row.DBCampo("CveCliente").ToEntero, e.Row.DBCampo("CveVenta").ToEntero) - e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda)) - - If UsuarioActual.Empresa.Funcionalidad(157).ToDecimal <> 0 Then - e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnLimites({0},this,{1},{2},2);", e.Row.FCCheckBox("Chk").ClientID, -UsuarioActual.Empresa.Funcionalidad(157), UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal)) - e.Row.FCRangeValidator("RVComision").MinimumValue = -UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal - e.Row.FCRangeValidator("RVComision").MaximumValue = UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal - e.Row.FCRangeValidator("RVComision").Enabled = True - Else - e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda)) - e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00 - e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo") - End If - + If Not UsuarioActual.Empresa.Funcionalidad(536) = "1" Then + If e.Row.DBCampo("TipoDocto") = "Rem" Then + e.Row.FCCheckBox("Chk").Visible = False ' que no se pueda pagar si es remisión + e.Row.Cells(0).ToolTip = "El documento es remisión y no se puede realizar el pago" + End If + End If + + + If e.Row.DBCampo("CveVenta").ToEntero > 0 Then + e.Row.FCLiteral("LtlAux").Text = String.Format("Ir", e.Row.DBCampo("CveCliente").ToEntero, e.Row.DBCampo("CveVenta").ToEntero) + e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda)) + + If UsuarioActual.Empresa.Funcionalidad(157).ToDecimal <> 0 Then + e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnLimites({0},this,{1},{2},2);", e.Row.FCCheckBox("Chk").ClientID, -UsuarioActual.Empresa.Funcionalidad(157), UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal)) + e.Row.FCRangeValidator("RVComision").MinimumValue = -UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal + e.Row.FCRangeValidator("RVComision").MaximumValue = UsuarioActual.Empresa.Funcionalidad(157).ToString.ToDecimal + e.Row.FCRangeValidator("RVComision").Enabled = True + Else + e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,{2},{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), CveMonedaFiltro, moneda)) + e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00 + e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo") + End If + If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 AndAlso e.Row.DBCampo("DiasVencidos").ToEntero() <= 0 Then e.Row.FCCheckBox("ChkGenerarNC").Visible = True e.Row.FCCheckBox("ChkGenerarNC").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnEditarImporte({2}, {0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo").ToDecimal - e.Row.DBCampo("DescuentoProntoPago").ToDecimal, e.Row.FCCheckBox("ChkGenerarNC").ClientID, CveMonedaFiltro, moneda)) - End If - - Else - e.Row.FCTextBox("TxtAbonar").Visible = False - e.Row.FCTextBox("TxtComision").Visible = False - e.Row.FCCheckBox("Chk").Visible = False - End If - - End If - End Sub - + End If + + Else + e.Row.FCTextBox("TxtAbonar").Visible = False + e.Row.FCTextBox("TxtComision").Visible = False + e.Row.FCCheckBox("Chk").Visible = False + End If + + End If + End Sub + Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click If Not TxtImporte.Text.ToDecimal > 0 Then @@ -663,34 +663,34 @@ Partial Class Ventas_ClientesAbonar If Not (TxtFolio.Text.Trim <> "" Or RblTipoPago.SelectedValue = "2" Or RblTipoPago.SelectedValue = "3") Then Alert("Debe de llevar un Folio", TipoMensaje.MsgAdvertencia) Exit Sub - End If - - Dim Cuenta As String = "" - Dim CuentaDeposito As String = "" - - Dim seleccion As Integer = 0 - For Each gvr As GridViewRow In GvCxC.Rows - If gvr.FCCheckBox("Chk").Checked Then - seleccion += 1 - End If - Next - - If seleccion = 0 Then - Alert("No ha seleccionado ninguna factura para abonar.", TipoMensaje.MsgAdvertencia) - Exit Sub End If - - Dim CvePrePoliza As Integer = 0 - Dim IDPoliza As Integer = 0 - Dim FolioPoliza As String = "" - Dim CveIE As Integer = -1 - Dim CveVentasPago As New List(Of Integer) - Dim SeriesPago As New List(Of String) - - Dim MsgError As String = "" - Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura) - Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura) - + + Dim Cuenta As String = "" + Dim CuentaDeposito As String = "" + + Dim seleccion As Integer = 0 + For Each gvr As GridViewRow In GvCxC.Rows + If gvr.FCCheckBox("Chk").Checked Then + seleccion += 1 + End If + Next + + If seleccion = 0 Then + Alert("No ha seleccionado ninguna factura para abonar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim CvePrePoliza As Integer = 0 + Dim IDPoliza As Integer = 0 + Dim FolioPoliza As String = "" + Dim CveIE As Integer = -1 + Dim CveVentasPago As New List(Of Integer) + Dim SeriesPago As New List(Of String) + + Dim MsgError As String = "" + Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura) + Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura) + Dim ImporteSeleccionado As Decimal = 0 '02-05-2018 MANDAMOS CANCELAR EL COMPLEMENTO A SUSTITUIR @@ -701,14 +701,14 @@ Partial Class Ventas_ClientesAbonar If ErrorCancelarIE Then Exit Sub End If - End If - - Dim ObjIE As New ClsBancos() - Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) + End If + + Dim ObjIE As New ClsBancos() + Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) Dim ObjVentasSaldos As New ClsVentas(ObjIE.IniciaTransacSQL) - Dim ObjEvento As New ClsOIEventos(ObjIE.IniciaTransacSQL) - Dim ObjConta As ClsContPAQi = Nothing - + Dim ObjEvento As New ClsOIEventos(ObjIE.IniciaTransacSQL) + Dim ObjConta As ClsContPAQi = Nothing + Try Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos Dim filemove As String = "" @@ -1752,16 +1752,16 @@ Partial Class Ventas_ClientesAbonar Alert(MsgError, TipoMensaje.MsgAdvertencia) End If - ObjIE.Dispose() - ObjVentasSaldos.Dispose() - ObjMov.Dispose() - If ObjConta IsNot Nothing Then ObjConta.Dispose() - ObjEvento.Dispose() - + ObjIE.Dispose() + ObjVentasSaldos.Dispose() + ObjMov.Dispose() + If ObjConta IsNot Nothing Then ObjConta.Dispose() + ObjEvento.Dispose() + LimpiaCampos() - UPVentas.Update() - + UPVentas.Update() + End Sub #Region " N O T A - D E - C R E D I T O" @@ -2136,89 +2136,89 @@ Partial Class Ventas_ClientesAbonar Return query.QueryToDataTable(False) End Function - Protected Function CreaDTDetalleNC() As DataTable - Dim TmpDT = New DataTable - TmpDT.Columns.Add("CveVenta", GetType(Integer)) - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("SATClaveUM", GetType(String)) - TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDT.Columns.Add("Clasificacion", GetType(String)) - TmpDT.Columns.Add("CvePS", GetType(Integer)) - TmpDT.Columns.Add("PS", GetType(String)) - TmpDT.Columns.Add("CodigoPS", GetType(String)) - TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) - TmpDT.Columns.Add("NoIdentificacion", GetType(String)) - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) - TmpDT.Columns.Add("SerieLote", GetType(String)) - TmpDT.Columns.Add("CuentaPredial", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("TiempoEntrega", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) - TmpDT.Columns.Add("IEPS", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) - TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - 'Para uso del módulo contable - TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) - TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) - TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) - 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto - TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) - 'Contratos - TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) - 'Remisiones a Facturas - TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) - 'Pedido2 a Facturas - TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) - TmpDT.Columns.Add("Origen", GetType(Integer)) - 'Ordenes Servicio - TmpDT.Columns.Add("CveOS", GetType(Integer)) - TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) - TmpDT.Columns.Add("SeFacturara", GetType(Integer)) - TmpDT.Columns.Add("Folio", GetType(Integer)) - TmpDT.Columns.Add("Estatus", GetType(String)) - 'Ordenamiento - TmpDT.Columns.Add("Orden", GetType(Integer)) - TmpDT.Columns.Add("TipoDocto", GetType(String)) - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) - TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) - TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) - TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - TmpDT.Columns.Add("CveTamaño", GetType(Integer)) - TmpDT.Columns.Add("EsCargo", GetType(Boolean)) - - Return TmpDT + Protected Function CreaDTDetalleNC() As DataTable + Dim TmpDT = New DataTable + TmpDT.Columns.Add("CveVenta", GetType(Integer)) + TmpDT.Columns.Add("Consec", GetType(Integer)) + TmpDT.Columns.Add("Cantidad", GetType(Decimal)) + TmpDT.Columns.Add("Codigo", GetType(String)) + TmpDT.Columns.Add("CveUM", GetType(Integer)) + TmpDT.Columns.Add("UM", GetType(String)) + TmpDT.Columns.Add("SATClaveUM", GetType(String)) + TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) + TmpDT.Columns.Add("Clasificacion", GetType(String)) + TmpDT.Columns.Add("CvePS", GetType(Integer)) + TmpDT.Columns.Add("PS", GetType(String)) + TmpDT.Columns.Add("CodigoPS", GetType(String)) + TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) + TmpDT.Columns.Add("NoIdentificacion", GetType(String)) + TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) + TmpDT.Columns.Add("SerieLote", GetType(String)) + TmpDT.Columns.Add("CuentaPredial", GetType(String)) + TmpDT.Columns.Add("Obs", GetType(String)) + TmpDT.Columns.Add("TiempoEntrega", GetType(String)) + TmpDT.Columns.Add("PU", GetType(Decimal)) + TmpDT.Columns.Add("IVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) + TmpDT.Columns.Add("IEPS", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) + TmpDT.Columns.Add("Descuento", GetType(Decimal)) + TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) + TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) + TmpDT.Columns.Add("Total", GetType(Decimal)) + 'Para uso del módulo contable + TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) + TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) + TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) + TmpDT.Columns.Add("CveProyecto", GetType(Integer)) + TmpDT.Columns.Add("Proyecto", GetType(String)) + TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDT.Columns.Add("SubProyecto", GetType(String)) + TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) + 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto + TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) + TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) + 'Contratos + TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) + 'Remisiones a Facturas + TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) + 'Pedido2 a Facturas + TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) + TmpDT.Columns.Add("Origen", GetType(Integer)) + 'Ordenes Servicio + TmpDT.Columns.Add("CveOS", GetType(Integer)) + TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) + TmpDT.Columns.Add("SeFacturara", GetType(Integer)) + TmpDT.Columns.Add("Folio", GetType(Integer)) + TmpDT.Columns.Add("Estatus", GetType(String)) + 'Ordenamiento + TmpDT.Columns.Add("Orden", GetType(Integer)) + TmpDT.Columns.Add("TipoDocto", GetType(String)) + 'OC + TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) + TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) + TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) + TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) + TmpDT.Columns.Add("CveTamaño", GetType(Integer)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + + Return TmpDT End Function Private Function InicializaDTVentasNC() As DataTable Dim DtVentasNC = New DataTable @@ -2234,621 +2234,621 @@ Partial Class Ventas_ClientesAbonar #End Region - Private Sub LimpiaCampos() - TxtFolio.Text = "" - TxtObservaciones.Text = "" - TxtImporte.Text = "" - TxtTotal.Text = "" - TxtFechaDocumento.Text = Now.ToShortDateString - DdlCuenta.SelectedValue = "-1" - DdlTipoTransaccion.SelectedValue = "-1" - - CveIESustitucion = "-1" - CFDIRelacionadoSustitucion = "-1" - FechaCorteIE = DateTime.Now.ToDate - IDPoliza = -1 - FolioIECancelado = "" - - If UsuarioActual.Empresa.UsaAC Then - TxtOtrosImportes.Text = "" - UpDatos.Update() - CargaDatos(-1) - Else - UpDatos.Update() - CargaDatos(If(Request("CveMoneda") IsNot Nothing AndAlso Request("CveMoneda").ToString.ToEntero > 0, Request("CveMoneda").ToString.ToEntero, -1)) - End If - - End Sub - - Private Sub RblTipoPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoPago.SelectedIndexChanged - Select Case RblTipoPago.SelectedValue - Case "1" - DdlProveedorPagoInt.Items.Clear() - DivDatosBancarios.Visible = True - TxtFolio.Enabled = True - divAbonese.Visible = True - divIntermediario.Visible = False - PanelIngresos.Visible = False - Case "3" - ' Ingresos por comprobar - DdlProveedorPagoInt.Items.Clear() - DivDatosBancarios.Visible = False - PanelIngresos.Visible = True - TxtFolio.Enabled = True - divAbonese.Visible = True - divIntermediario.Visible = False - 'filtro primero por los de la moneda - CargaIngresos(CveMonedaFiltro) - - If ChkPagarDolares.Checked Then - CveMonedaPago = 2 - CveMoneda = 1 - TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", 2)) - Else - CveMonedaPago = 1 - End If - CargaDatos(CveMoneda) - Case Else - - divAbonese.Visible = False - Dim ObjProveedores As New ClsCompProveedores - ObjProveedores.GetProveedorProsepago(UsuarioActual.CveEmpresa) - - divIntermediario.Visible = True - DdlProveedorPagoInt.DataSource = ObjProveedores.DtResultados - ObjProveedores.Dispose() - DdlProveedorPagoInt.DataBind() - - DivDatosBancarios.Visible = False - TxtFolio.Enabled = False - PanelIngresos.Visible = False - - End Select - - CargaDatos(CveMoneda) - UpDatos.Update() - End Sub - - Private Sub CargaIngresos(tCveMoneda As Integer) - - Dim Deudores As New ClsMovimientos - If Deudores.GetIngresosSaldosDetalle(CveCliente, tCveMoneda, UsuarioActual.CveEmpresa) Then - DdlIngreso.DataSource = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0 AND CveIE > 0") - End If - Deudores.Dispose() - - DdlIngreso.DataBind() - DdlIngreso.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - - Protected Sub ChkAjusteOI_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ChkAjusteOI.CheckedChanged - - If ChkAjusteOI.Checked Then - TxtOtrosImportes.Visible = True - TxtTotal.Visible = True - GvCxC.Columns(13).Visible = True - Else - TxtOtrosImportes.Visible = False - TxtTotal.Visible = False - GvCxC.Columns(13).Visible = False - TxtOtrosImportes.Text = "" - TxtTotal.Text = "" - RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);") - End If - - UpDatos.Update() - UPVentas.Update() + Private Sub LimpiaCampos() + TxtFolio.Text = "" + TxtObservaciones.Text = "" + TxtImporte.Text = "" + TxtTotal.Text = "" + TxtFechaDocumento.Text = Now.ToShortDateString + DdlCuenta.SelectedValue = "-1" + DdlTipoTransaccion.SelectedValue = "-1" + + CveIESustitucion = "-1" + CFDIRelacionadoSustitucion = "-1" + FechaCorteIE = DateTime.Now.ToDate + IDPoliza = -1 + FolioIECancelado = "" + + If UsuarioActual.Empresa.UsaAC Then + TxtOtrosImportes.Text = "" + UpDatos.Update() + CargaDatos(-1) + Else + UpDatos.Update() + CargaDatos(If(Request("CveMoneda") IsNot Nothing AndAlso Request("CveMoneda").ToString.ToEntero > 0, Request("CveMoneda").ToString.ToEntero, -1)) + End If + End Sub -#Region " PAGAR CON PESOS " - Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs) - If ChkPagarPesos.Checked Then - DivTCDolaresDolares.Visible = False - RegistraScript("$get('DivTC').style.display = 'block';") - CargaCuentas() - If RblTipoPago.SelectedValue = "3" Then - CargaIngresos(1) - End If - TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - Else - DivTCDolaresDolares.Visible = True - 'RegistraScript("document.getElementById('DivTC').style.display = 'none';") - CargaCuentas() - TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - End If - UpDatos.Update() - - CargaDatos(2) - RegistraScript("CambiaPesosDolares();") - End Sub -#End Region + Private Sub RblTipoPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoPago.SelectedIndexChanged + Select Case RblTipoPago.SelectedValue + Case "1" + DdlProveedorPagoInt.Items.Clear() + DivDatosBancarios.Visible = True + TxtFolio.Enabled = True + divAbonese.Visible = True + divIntermediario.Visible = False + PanelIngresos.Visible = False + Case "3" + ' Ingresos por comprobar + DdlProveedorPagoInt.Items.Clear() + DivDatosBancarios.Visible = False + PanelIngresos.Visible = True + TxtFolio.Enabled = True + divAbonese.Visible = True + divIntermediario.Visible = False + 'filtro primero por los de la moneda + CargaIngresos(CveMonedaFiltro) -#Region "PAGAR CON DOLARES" - Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs) - If ChkPagarDolares.Checked Then - DivTCDolares.Visible = True - CargaCuentas() - If RblTipoPago.SelectedValue = "3" Then - CargaIngresos(2) - RegistraScript("CambiaDolaresPesos();") - End If - TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") - TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - Else - DivTCDolares.Visible = False - CargaCuentas() - TxtFechaDocumento.Attributes.Remove("onchange") - End If - UpDatos.Update() - - CargaDatos(1) - RegistraScript("CambiaDolaresPesos();") - End Sub -#End Region + If ChkPagarDolares.Checked Then + CveMonedaPago = 2 + CveMoneda = 1 + TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,1,{0});", 2)) + Else + CveMonedaPago = 1 + End If + CargaDatos(CveMoneda) + Case Else -#Region " CUENTAS DEPOSITOS" - Private Sub CargaCuentasDepositos() - DdlCuentaDeposito.Items.Clear() - If DdlTipoTransaccion.SelectedValue > 0 Then ' transferencias y layout - trCuentaDeposito.Visible = False - - Dim Dep As New ClsGenerales - If Dep.GetCuentasDepositos(CveCliente:=CveCliente) Then - If DdlTipoTransaccion.SelectedValue = "9" Then - - DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") - - If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - Else - BtnIEGuardar.Enabled = False - Alert("El Cliente no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) - End If - - Else - DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'") - If Dep.DtResultados.Rows.Count >= 1 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - End If - End If - - - End If - Dep.Dispose() - - - DdlCuentaDeposito.DataBind() - - Else - trCuentaDeposito.Visible = False - DdlCuentaDeposito.Items.Clear() - End If - - UpCuentaDeposito.Update() - UpDatos.Update() - - End Sub - - Private Sub RecargaCuentasDepositos() - - Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing - If dr IsNot Nothing Then - HdnTipoTransaccion.Value = dr("Tipo").ToString - HdnTipoTransaccionAbreviatura.Value = dr("Abreviatura").ToString - End If - CargaCuentasDepositos() - End Sub - Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim Dep As New ClsGenerales - If Dep.GetCuentasDepositos(CveCliente:=CveCliente, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then - If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then - TrReferenciaCIE.Visible = True - TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString - Else - TrReferenciaCIE.Visible = False - End If - End If - Dep.Dispose() - UpCuentaDeposito.Update() - End Sub -#End Region + divAbonese.Visible = False + Dim ObjProveedores As New ClsCompProveedores + ObjProveedores.GetProveedorProsepago(UsuarioActual.CveEmpresa) -#Region " COMPLEMENTOS PAGO " + divIntermediario.Visible = True + DdlProveedorPagoInt.DataSource = ObjProveedores.DtResultados + ObjProveedores.Dispose() + DdlProveedorPagoInt.DataBind() + + DivDatosBancarios.Visible = False + TxtFolio.Enabled = False + PanelIngresos.Visible = False + + End Select + + CargaDatos(CveMoneda) + UpDatos.Update() + End Sub + + Private Sub CargaIngresos(tCveMoneda As Integer) + + Dim Deudores As New ClsMovimientos + If Deudores.GetIngresosSaldosDetalle(CveCliente, tCveMoneda, UsuarioActual.CveEmpresa) Then + DdlIngreso.DataSource = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0 AND CveIE > 0") + End If + Deudores.Dispose() + + DdlIngreso.DataBind() + DdlIngreso.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + Protected Sub ChkAjusteOI_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ChkAjusteOI.CheckedChanged + + If ChkAjusteOI.Checked Then + TxtOtrosImportes.Visible = True + TxtTotal.Visible = True + GvCxC.Columns(13).Visible = True + Else + TxtOtrosImportes.Visible = False + TxtTotal.Visible = False + GvCxC.Columns(13).Visible = False + TxtOtrosImportes.Text = "" + TxtTotal.Text = "" + RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);") + End If + + UpDatos.Update() + UPVentas.Update() + End Sub + +#Region " PAGAR CON PESOS " + Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs) + If ChkPagarPesos.Checked Then + DivTCDolaresDolares.Visible = False + RegistraScript("$get('DivTC').style.display = 'block';") + CargaCuentas() + If RblTipoPago.SelectedValue = "3" Then + CargaIngresos(1) + End If + TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + Else + DivTCDolaresDolares.Visible = True + 'RegistraScript("document.getElementById('DivTC').style.display = 'none';") + CargaCuentas() + TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + End If + UpDatos.Update() + + CargaDatos(2) + RegistraScript("CambiaPesosDolares();") + End Sub +#End Region + +#Region "PAGAR CON DOLARES" + Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs) + If ChkPagarDolares.Checked Then + DivTCDolares.Visible = True + CargaCuentas() + If RblTipoPago.SelectedValue = "3" Then + CargaIngresos(2) + RegistraScript("CambiaDolaresPesos();") + End If + TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") + TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + Else + DivTCDolares.Visible = False + CargaCuentas() + TxtFechaDocumento.Attributes.Remove("onchange") + End If + UpDatos.Update() + + CargaDatos(1) + RegistraScript("CambiaDolaresPesos();") + End Sub +#End Region + +#Region " CUENTAS DEPOSITOS" + Private Sub CargaCuentasDepositos() + DdlCuentaDeposito.Items.Clear() + If DdlTipoTransaccion.SelectedValue > 0 Then ' transferencias y layout + trCuentaDeposito.Visible = False + + Dim Dep As New ClsGenerales + If Dep.GetCuentasDepositos(CveCliente:=CveCliente) Then + If DdlTipoTransaccion.SelectedValue = "9" Then + + DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + + If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnIEGuardar.Enabled = False + Alert("El Cliente no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) + End If + + Else + DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'") + If Dep.DtResultados.Rows.Count >= 1 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + End If + + + End If + Dep.Dispose() + + + DdlCuentaDeposito.DataBind() + + Else + trCuentaDeposito.Visible = False + DdlCuentaDeposito.Items.Clear() + End If + + UpCuentaDeposito.Update() + UpDatos.Update() + + End Sub + + Private Sub RecargaCuentasDepositos() + + Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing + If dr IsNot Nothing Then + HdnTipoTransaccion.Value = dr("Tipo").ToString + HdnTipoTransaccionAbreviatura.Value = dr("Abreviatura").ToString + End If + CargaCuentasDepositos() + End Sub + Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim Dep As New ClsGenerales + If Dep.GetCuentasDepositos(CveCliente:=CveCliente, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then + If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then + TrReferenciaCIE.Visible = True + TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString + Else + TrReferenciaCIE.Visible = False + End If + End If + Dep.Dispose() + UpCuentaDeposito.Update() + End Sub +#End Region + +#Region " COMPLEMENTOS PAGO " Private Function EmitirComplementoPago(CveIE As Integer, CveVentas As List(Of Integer), Series As List(Of String)) As String If Not UsuarioActual.Empresa.FacturaProduccion Then Return "" End If - If Not ChkComplementoPago.Checked Then - Return "" - End If - - Dim Retorno As New StringBuilder - - 'For i = 0 To CveVentas.Count - 1 - Dim ObjBancos As New ClsBancos - ObjBancos.IniciaTransacSQL() - - If ObjBancos.GeneraTimbrePago(CveIE, -1, UsuarioActual, CveCliente, CFDIRelacionado:=CFDIRelacionadoSustitucion, EsRegeneracion:=If(CveIESustitucion > 0, True, False)) Then - ObjBancos.Commit() - ComplementoSustitucionGenerado = True - - PDFReciboDePagos(-1, -1, ObjBancos.CveComplementoPago, False) - - Dim LigaDescargaXML = $"../Empresas/{UsuarioActual.CveEmpresa}/XML/Pag/{ObjBancos.ComplementoSerieFolio}.xml" - Dim LigaDescargaPDF = $"../Empresas/{UsuarioActual.CveEmpresa}/PDF/Pag/{ObjBancos.ComplementoSerieFolio}.pdf" - Retorno.AppendFormat(" Complemento de pago {0}
", ObjBancos.ComplementoSerieFolio) - Retorno.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE))) - Retorno.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE))) - - Dim ResultadoMail As Integer - Dim ObjMail As New ClsSisMail() - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\XML\Pag\{ObjBancos.ComplementoSerieFolio}.xml"}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{ObjBancos.ComplementoSerieFolio}.pdf"}) - - 'Dim Mail As String = "demo@adsistemas.mx" - Dim Asunto As String = "Envío de complemento de pago" - Dim Cuerpo As String = "Complemento de Pago" - - If ObjMail.SendMail(UsuarioActual.Empresa, Mail, Asunto, Cuerpo, "", LSRutasMail) Then - ResultadoMail = 1 - Else - ResultadoMail = 3 - Alert("No se pudo enviar el correo", TipoMensaje.MsgAdvertencia) - End If - Else - ComplementoSustitucionGenerado = False - Retorno.AppendFormat($" Complemento de pago NO generado . {ObjBancos.Mensaje}") - ObjBancos.RollBack() - End If - - ObjBancos.Dispose() - - ' Next - - Return Retorno.ToString + If Not ChkComplementoPago.Checked Then + Return "" + End If + + Dim Retorno As New StringBuilder + + 'For i = 0 To CveVentas.Count - 1 + Dim ObjBancos As New ClsBancos + ObjBancos.IniciaTransacSQL() + + If ObjBancos.GeneraTimbrePago(CveIE, -1, UsuarioActual, CveCliente, CFDIRelacionado:=CFDIRelacionadoSustitucion, EsRegeneracion:=If(CveIESustitucion > 0, True, False)) Then + ObjBancos.Commit() + ComplementoSustitucionGenerado = True + + PDFReciboDePagos(-1, -1, ObjBancos.CveComplementoPago, False) + + Dim LigaDescargaXML = $"../Empresas/{UsuarioActual.CveEmpresa}/XML/Pag/{ObjBancos.ComplementoSerieFolio}.xml" + Dim LigaDescargaPDF = $"../Empresas/{UsuarioActual.CveEmpresa}/PDF/Pag/{ObjBancos.ComplementoSerieFolio}.pdf" + Retorno.AppendFormat(" Complemento de pago {0}
", ObjBancos.ComplementoSerieFolio) + Retorno.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE))) + Retorno.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", ObjBancos.ComplementoSerieFolio, ObjBancos.CveComplementoPago, CveIE))) + + Dim ResultadoMail As Integer + Dim ObjMail As New ClsSisMail() + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\XML\Pag\{ObjBancos.ComplementoSerieFolio}.xml"}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = $"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{ObjBancos.ComplementoSerieFolio}.pdf"}) + + 'Dim Mail As String = "demo@adsistemas.mx" + Dim Asunto As String = "Envío de complemento de pago" + Dim Cuerpo As String = "Complemento de Pago" + + If ObjMail.SendMail(UsuarioActual.Empresa, Mail, Asunto, Cuerpo, "", LSRutasMail) Then + ResultadoMail = 1 + Else + ResultadoMail = 3 + Alert("No se pudo enviar el correo", TipoMensaje.MsgAdvertencia) + End If + Else + ComplementoSustitucionGenerado = False + Retorno.AppendFormat($" Complemento de pago NO generado . {ObjBancos.Mensaje}") + ObjBancos.RollBack() + End If + + ObjBancos.Dispose() + + ' Next + + Return Retorno.ToString End Function -#End Region +#End Region -#Region "SALDAR CUENTAS" +#Region "SALDAR CUENTAS" - Private Sub BtnSaldarCuentasIncobrables_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasIncobrables.Click - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = 0 - Dim MsgError As String = "" - - Dim ObjIE As New ClsBancos - Dim FechaUltimaFluctuacion As Date = MinFecha - Dim TipoCambioFluctuacion As Decimal = 1 - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") - - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If - - End If - End If - + Private Sub BtnSaldarCuentasIncobrables_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasIncobrables.Click + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + Dim CvePrePoliza As Integer = 0 + Dim MsgError As String = "" + + Dim ObjIE As New ClsBancos + Dim FechaUltimaFluctuacion As Date = MinFecha + Dim TipoCambioFluctuacion As Decimal = 1 + If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + If ObjIE.DtResultados.Rows.Count > 0 Then + Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate + Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") + + If drr IsNot Nothing Then + FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + End If + + End If + End If + ObjIE.Dispose() - CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - - For Each gr As GridViewRow In GvCxC.Rows - If gr.FCCheckBox("Chk").Checked Then - Dim IdCtaContable As Integer = IdCuentaCliente - Dim CveCuenta As Integer = 0 - Dim PorcentajePago As Decimal = gr.DataKey("Saldo").ToDecimal / gr.DataKey("Original").ToDecimal - Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal - Dim SubTotal As Decimal = PorcentajePago * gr.DataKey("SubTotal").ToDecimal - Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal - Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal - Dim TCVenta As Decimal = gr.DataKey("TipoCambio").ToDecimal - Dim FechaVenta As Date = gr.DataKey("Fecha").ToDate - Dim tCveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero - Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaIncobrable.Text.ToDate).FormatoNumero(4) - Dim CveConceptoDeduccion As Integer = DdlTipoDeduccion.SelectedValue.ToEntero - - - 'si la fecha del documento es anterior a su ultima fluctuación. toma el Tc de la fluctuacion - If tCveMoneda = 2 Then - If FechaVenta < FechaUltimaFluctuacion Then - TCVenta = TipoCambioFluctuacion - End If - End If - - - 'condicionante - Dim ClienteMovto As Boolean = True - Dim SubtotalMovto As Boolean = False - Dim CveConceptoCliente As Integer = 2 - Dim ImpuestosMovto As Boolean = False - Dim IdCuentaContableNoDeducible As Integer = 0 - Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero - Dim ConceptoPartida As String = TxtObsSaldarIncobrable.Text.Trim & " " & gr.DataKey("SerieFolio").ToString - - If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero - If CveConceptoDeduccion = 211 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero - If CveConceptoDeduccion = 263 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(537).ToEntero - If CveConceptoDeduccion = 252 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(581).ToEntero - If CveConceptoDeduccion = 78 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.IdCuentaOtrosIngresos - - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) Then - ClienteMovto = False : Saldo = Saldo * -1 - ImpuestosMovto = True : IVA = IVA * -1 - CveConceptoCliente = 1 - 'falta cuenta incobrable - IdCuentaContableNoDeducible = 3114 - End If - - Dim UsaComplementaria As Boolean = False - - If UsuarioActual.CveEmpresa = 119 Then - UsaComplementaria = True - End If - + CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + + For Each gr As GridViewRow In GvCxC.Rows + If gr.FCCheckBox("Chk").Checked Then + Dim IdCtaContable As Integer = IdCuentaCliente + Dim CveCuenta As Integer = 0 + Dim PorcentajePago As Decimal = gr.DataKey("Saldo").ToDecimal / gr.DataKey("Original").ToDecimal + Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal + Dim SubTotal As Decimal = PorcentajePago * gr.DataKey("SubTotal").ToDecimal + Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal + Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal + Dim TCVenta As Decimal = gr.DataKey("TipoCambio").ToDecimal + Dim FechaVenta As Date = gr.DataKey("Fecha").ToDate + Dim tCveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero + Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaIncobrable.Text.ToDate).FormatoNumero(4) + Dim CveConceptoDeduccion As Integer = DdlTipoDeduccion.SelectedValue.ToEntero + + + 'si la fecha del documento es anterior a su ultima fluctuación. toma el Tc de la fluctuacion + If tCveMoneda = 2 Then + If FechaVenta < FechaUltimaFluctuacion Then + TCVenta = TipoCambioFluctuacion + End If + End If + + + 'condicionante + Dim ClienteMovto As Boolean = True + Dim SubtotalMovto As Boolean = False + Dim CveConceptoCliente As Integer = 2 + Dim ImpuestosMovto As Boolean = False + Dim IdCuentaContableNoDeducible As Integer = 0 + Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero + Dim ConceptoPartida As String = TxtObsSaldarIncobrable.Text.Trim & " " & gr.DataKey("SerieFolio").ToString + + If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero + If CveConceptoDeduccion = 211 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero + If CveConceptoDeduccion = 263 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(537).ToEntero + If CveConceptoDeduccion = 252 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(581).ToEntero + If CveConceptoDeduccion = 78 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.IdCuentaOtrosIngresos + + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) Then + ClienteMovto = False : Saldo = Saldo * -1 + ImpuestosMovto = True : IVA = IVA * -1 + CveConceptoCliente = 1 + 'falta cuenta incobrable + IdCuentaContableNoDeducible = 3114 + End If + + Dim UsaComplementaria As Boolean = False + + If UsuarioActual.CveEmpresa = 119 Then + UsaComplementaria = True + End If + If MsgError = "" Then - If tCveMoneda = 2 Then - IdCtaContable = IdCtaContMonedaExtranjera - Else - IdCtaContable = IdCuentaCliente - End If - - If UsaComplementaria AndAlso tCveMoneda = 2 Then - 'normal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - 'complementaria - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, gr.DataKey("SerieFolio").ToString, 207, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContComplementaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, (Saldo * TCVenta) - Saldo), ImporteME:=Saldo, CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - - Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo * TCVenta), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - - End If - - 'fluctuación. - If tCveMoneda = 2 Then - Dim ImporteFluctuacion As Decimal = 0 - ImporteFluctuacion = Saldo * (TCPago - TCVenta) - If TCPago > TCVenta Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - End If - - 'cuando hay pago en dólares, se ajusta el concepto de subtotal, - SubTotal = (Saldo * TCVenta) + ImporteFluctuacion - (IVA * TCVenta) - (IEPS * TCVenta) - - End If - - - ' iva - Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal - - Dim IdCtaIVAXTrasladar As Integer = 0 - Dim CveCuentaIVAxTrasladar As Integer = 0 - - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then - IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero - CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVAxTrasladar").ToString.ToEntero - End If - - IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) - CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar) - If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - - IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar - CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar - If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - - 'al gasto,Subtotal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then - MsgError = "Ocurrio un error al saldar el movimiento" - End If - - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia - GuardaLogAD($"Ventas/ClientesAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - Exit For - End If - End If - End If - End If - Next - - If MsgError = "" Then - 'ObjConta.RollBack() - ObjConta.Commit() - CargaDatos(CveMonedaFiltro) - RegistraScript("$('#ModalSaldarCuentaIncobrable').modal('hide')") - Alert(String.Format("Los movimientos se saldaron correctamente.
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) - - Else - ObjConta.RollBack() - Alert(MsgError, TipoMensaje.MsgError) - End If - - BtnSaldarCuentasIncobrables.Visible = False - ObjConta.Dispose() - End Sub - - - Private Sub ValidaCuentaDePagoFormaDePago() - - If Not (DdlTipoTransaccion.SelectedValue.ToEntero > 0 And DdlCuenta.SelectedValue.ToEntero > 0) Then - Exit Sub - End If - - Dim DTTipoTransacciones As DataTable = GlobalDTTipoTransacciones.FiltraParametros($"CveTipoTransaccion={DdlTipoTransaccion.SelectedValue}") - Dim DTCuentas As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta={DdlCuenta.SelectedValue}") - - Dim ClaveFormaPagoSAT As String = "" - Dim Cuentapago As String = "" - Dim CuentaBeneficiario As String = "" - - - If DTTipoTransacciones.Rows.Count > 0 Then - ClaveFormaPagoSAT = DTTipoTransacciones.Rows(0)("ClaveFormaPagoSAT").ToString - Else - Alert("La forma de pago no tiene una forma de pago SAT", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If DTCuentas.Rows.Count > 0 Then - CuentaBeneficiario = DTCuentas.Rows(0)("NumCuenta").ToString - Else - Alert("No se pudo encontrar la cuenta", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - - Dim Mensaje As String = "" - Cuentapago = "" - - - Select Case ClaveFormaPagoSAT.ToString - Case "01" - ' no tiene restricciones - Case "02" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(11, 18) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - Case "03" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 16, 18) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 18)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - Case "04" - - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - - Case "05" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 11, 15, 16, 18, 50) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - Case "06" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - CuentaBeneficiario = "" - Case "28" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - Case "29" - If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(15, 16) Then - Mensaje = "La cuenta ordenante no cumple con el formato esperado." - End If - - If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then - Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." - End If - - Case Else - - - - End Select - - LblValidaCeuntaTipoTransaccion.Text = Mensaje - - If Not Mensaje.Length = 0 Then - 'Alert(Mensaje, TipoMensaje.MsgAdvertencia) - LblValidaCeuntaTipoTransaccion.Visible = True - Else - LblValidaCeuntaTipoTransaccion.Visible = False - End If - - UpGuardar.Update() - + If tCveMoneda = 2 Then + IdCtaContable = IdCtaContMonedaExtranjera + Else + IdCtaContable = IdCuentaCliente + End If + + If UsaComplementaria AndAlso tCveMoneda = 2 Then + 'normal + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + 'complementaria + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, gr.DataKey("SerieFolio").ToString, 207, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContComplementaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, (Saldo * TCVenta) - Saldo), ImporteME:=Saldo, CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + + Else + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, gr.DataKey("SerieFolio").ToString, CveConceptoCliente, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, Saldo, Saldo * TCVenta), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + + End If + + 'fluctuación. + If tCveMoneda = 2 Then + Dim ImporteFluctuacion As Decimal = 0 + ImporteFluctuacion = Saldo * (TCPago - TCVenta) + If TCPago > TCVenta Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + Else + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + End If + + 'cuando hay pago en dólares, se ajusta el concepto de subtotal, + SubTotal = (Saldo * TCVenta) + ImporteFluctuacion - (IVA * TCVenta) - (IEPS * TCVenta) + + End If + + + ' iva + Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal + + Dim IdCtaIVAXTrasladar As Integer = 0 + Dim CveCuentaIVAxTrasladar As Integer = 0 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then + IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero + CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("CveCuentaIVAxTrasladar").ToString.ToEntero + End If + + IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) + CveCuenta = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar) + If IVA > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, gr.DataKey("SerieFolio").ToString, 13, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IVA, IVA * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + + IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar + CveCuenta = UsuarioActual.Empresa.CveCuentaIEPSxTrasladar + If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, gr.DataKey("SerieFolio").ToString, 38, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=If(CveMonedaFiltro = 1, IEPS, IEPS * TCVenta), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + + 'al gasto,Subtotal + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + MsgError = "Ocurrio un error al saldar el movimiento" + End If + + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia + GuardaLogAD($"Ventas/ClientesAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + Exit For + End If + End If + End If + End If + Next + + If MsgError = "" Then + 'ObjConta.RollBack() + ObjConta.Commit() + CargaDatos(CveMonedaFiltro) + RegistraScript("$('#ModalSaldarCuentaIncobrable').modal('hide')") + Alert(String.Format("Los movimientos se saldaron correctamente.
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) + + Else + ObjConta.RollBack() + Alert(MsgError, TipoMensaje.MsgError) + End If + + BtnSaldarCuentasIncobrables.Visible = False + ObjConta.Dispose() End Sub -#End Region -#Region "COMPLEMENTO DE PAGO - ELIMINAR POR SUSTITUCION" - Protected Sub CargaIESustituir() - Dim ObjIE As New ClsBancos() - If ObjIE.GetBancosIE(CveIESustitucion, UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - FechaCorteIE = ObjIE.FechaDocumento - CveMoneda = ObjIE.CveMoneda - CveMonedaFiltro = CveMoneda - IDPoliza = ObjIE.IDPoliza - FolioIECancelado = ObjIE.Folio - End If - End If - ObjIE.Dispose() - UpDatos.Update() - End Sub - Function CancelarIE() As Boolean - Dim ErrorCancelar = False - - If Not IsDate(TxtFechaDocumento.Text.ToDate) Then - Alert("El campo fecha cancelación es incorrecto. Por favor verifique y vuelva a intentar") - Return True - End If - - Dim Banc As New ClsBancos - Banc.IniciaTransacSQL() - - Dim ObjAC As ClsContPAQi = Nothing - If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then - ObjAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - End If - - Dim IdPolizaNueva = -1 - Dim FolioPolizaNueva = -1 - + Private Sub ValidaCuentaDePagoFormaDePago() + + If Not (DdlTipoTransaccion.SelectedValue.ToEntero > 0 And DdlCuenta.SelectedValue.ToEntero > 0) Then + Exit Sub + End If + + Dim DTTipoTransacciones As DataTable = GlobalDTTipoTransacciones.FiltraParametros($"CveTipoTransaccion={DdlTipoTransaccion.SelectedValue}") + Dim DTCuentas As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta={DdlCuenta.SelectedValue}") + + Dim ClaveFormaPagoSAT As String = "" + Dim Cuentapago As String = "" + Dim CuentaBeneficiario As String = "" + + + If DTTipoTransacciones.Rows.Count > 0 Then + ClaveFormaPagoSAT = DTTipoTransacciones.Rows(0)("ClaveFormaPagoSAT").ToString + Else + Alert("La forma de pago no tiene una forma de pago SAT", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DTCuentas.Rows.Count > 0 Then + CuentaBeneficiario = DTCuentas.Rows(0)("NumCuenta").ToString + Else + Alert("No se pudo encontrar la cuenta", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + + Dim Mensaje As String = "" + Cuentapago = "" + + + Select Case ClaveFormaPagoSAT.ToString + Case "01" + ' no tiene restricciones + Case "02" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(11, 18) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + Case "03" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 16, 18) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 18)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + Case "04" + + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + + Case "05" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10, 11, 15, 16, 18, 50) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + Case "06" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(10) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + CuentaBeneficiario = "" + Case "28" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(16) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + Case "29" + If Cuentapago <> "" AndAlso Not Cuentapago.Length.Contiene(15, 16) Then + Mensaje = "La cuenta ordenante no cumple con el formato esperado." + End If + + If CuentaBeneficiario <> "" AndAlso Not (CuentaBeneficiario.Length.Contiene(10, 11, 15, 16, 18, 50)) Then + Mensaje = $"{Mensaje} La Cuenta Beneficiario no cumple con el formato esperado." + End If + + Case Else + + + + End Select + + LblValidaCeuntaTipoTransaccion.Text = Mensaje + + If Not Mensaje.Length = 0 Then + 'Alert(Mensaje, TipoMensaje.MsgAdvertencia) + LblValidaCeuntaTipoTransaccion.Visible = True + Else + LblValidaCeuntaTipoTransaccion.Visible = False + End If + + UpGuardar.Update() + + End Sub + +#End Region + +#Region "COMPLEMENTO DE PAGO - ELIMINAR POR SUSTITUCION" + Protected Sub CargaIESustituir() + Dim ObjIE As New ClsBancos() + If ObjIE.GetBancosIE(CveIESustitucion, UsuarioActual.CveEmpresa) Then + If ObjIE.DtResultados.Rows.Count > 0 Then + FechaCorteIE = ObjIE.FechaDocumento + CveMoneda = ObjIE.CveMoneda + CveMonedaFiltro = CveMoneda + IDPoliza = ObjIE.IDPoliza + FolioIECancelado = ObjIE.Folio + End If + End If + ObjIE.Dispose() + UpDatos.Update() + End Sub + Function CancelarIE() As Boolean + Dim ErrorCancelar = False + + If Not IsDate(TxtFechaDocumento.Text.ToDate) Then + Alert("El campo fecha cancelación es incorrecto. Por favor verifique y vuelva a intentar") + Return True + End If + + Dim Banc As New ClsBancos + Banc.IniciaTransacSQL() + + Dim ObjAC As ClsContPAQi = Nothing + If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then + ObjAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + End If + + Dim IdPolizaNueva = -1 + Dim FolioPolizaNueva = -1 + Try 'CANCELA IE CONTABILIZADO If IDPoliza > 0 Then @@ -2974,89 +2974,89 @@ Partial Class Ventas_ClientesAbonar End Try If Not ErrorCancelar Then - Banc.Commit() - If ObjAC IsNot Nothing Then ObjAC.Commit() - - Dim Msg As New StringBuilder - Msg.Append("El movimiento bancario quedó cancelado exitosamente.") - - If IdPolizaNueva > 0 Then Msg.AppendFormat("

Ver Póliza de cancelación", IdPolizaNueva) - Alert(Msg.ToString, TipoMensaje.MsgInformacion) + Banc.Commit() + If ObjAC IsNot Nothing Then ObjAC.Commit() + + Dim Msg As New StringBuilder + Msg.Append("El movimiento bancario quedó cancelado exitosamente.") + + If IdPolizaNueva > 0 Then Msg.AppendFormat("

Ver Póliza de cancelación", IdPolizaNueva) + Alert(Msg.ToString, TipoMensaje.MsgInformacion) Else - Banc.RollBack() - If ObjAC IsNot Nothing Then ObjAC.RollBack() - Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - If ObjAC IsNot Nothing Then ObjAC.Dispose() - Banc.Dispose() - Return ErrorCancelar - End Function - - Private Sub BtnVincularIntermediario_Click(sender As Object, e As EventArgs) Handles BtnVincularIntermediario.Click - RegistraScript("$('#ModalVincularIntermediario').modal('hide')", "hidemodal") + Banc.RollBack() + If ObjAC IsNot Nothing Then ObjAC.RollBack() + Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + If ObjAC IsNot Nothing Then ObjAC.Dispose() + Banc.Dispose() + Return ErrorCancelar + End Function + + Private Sub BtnVincularIntermediario_Click(sender As Object, e As EventArgs) Handles BtnVincularIntermediario.Click + RegistraScript("$('#ModalVincularIntermediario').modal('hide')", "hidemodal") End Sub -#End Region +#End Region - Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) - CambiaTipoMoneda() - End Sub - Private Sub CambiaTipoMoneda() - Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, TxtFechaDocumento.Text.ToDate.Day - 1, TxtFechaDocumento.Text.ToDate.Day) - Fecha = (dia.ToString + "/" + TxtFechaDocumento.Text.ToDate.Month.ToString + "/" + TxtFechaDocumento.Text.ToDate.Year.ToString).ToDate - - If TxtTC.Visible Then - TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - End If - - If DivTCDolares.Visible Then - TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - End If - - If DivTCDolaresDolares.Visible Then - TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) - End If - - Dim moneda As Integer = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero - If CveMonedaFiltro = -1 Then - RegistraScript(String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) - Else - RegistraScript(String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) - End If - - UpDatos.Update() - End Sub - - Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged - 'saco la moneda de la selección - - If DdlIngreso.SelectedValue.ToEntero > 0 Then - Dim Banco As New ClsBancos - - If Banco.GetBancosIE(DdlIngreso.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - CveMonedaPago = Banco.CveMoneda - End If - IdCuentaBancariaComplementaria = 0 - CveCuentaBancariaComplementaria = 0 - Banco.Dispose() - Else - CveMonedaPago = -1 - End If - - - If CveMonedaPago = 1 Then - 'DivTC.Visible = True - DivTCDolares.Visible = False - TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago)) - ElseIf CveMonedaPago = 2 Then - 'DivTC.Visible = False - RegistraScript("document.getElementById('DivTC').style.display = 'none';") - DivTCDolares.Visible = True - TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago)) - End If - - CargaDatos(CveMoneda) - - End Sub -End Class + Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) + CambiaTipoMoneda() + End Sub + Private Sub CambiaTipoMoneda() + Dim dia As Integer = If(UsuarioActual.CveEmpresa = 13, TxtFechaDocumento.Text.ToDate.Day - 1, TxtFechaDocumento.Text.ToDate.Day) + Fecha = (dia.ToString + "/" + TxtFechaDocumento.Text.ToDate.Month.ToString + "/" + TxtFechaDocumento.Text.ToDate.Year.ToString).ToDate + + If TxtTC.Visible Then + TxtTC.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + End If + + If DivTCDolares.Visible Then + TxtTCDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + End If + + If DivTCDolaresDolares.Visible Then + TxtTCDolaresDolares.Text = GlobalTipoCambio(Fecha).FormatoNumero(4) + End If + + Dim moneda As Integer = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero + If CveMonedaFiltro = -1 Then + RegistraScript(String.Format("FnCambia(0,0,0,0,-1,{0});", moneda)) + Else + RegistraScript(String.Format("FnCambia(0,0,0,0,1,{0});", moneda)) + End If + + UpDatos.Update() + End Sub + + Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged + 'saco la moneda de la selección + + If DdlIngreso.SelectedValue.ToEntero > 0 Then + Dim Banco As New ClsBancos + + If Banco.GetBancosIE(DdlIngreso.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + CveMonedaPago = Banco.CveMoneda + End If + IdCuentaBancariaComplementaria = 0 + CveCuentaBancariaComplementaria = 0 + Banco.Dispose() + Else + CveMonedaPago = -1 + End If + + + If CveMonedaPago = 1 Then + 'DivTC.Visible = True + DivTCDolares.Visible = False + TxtTC.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago)) + ElseIf CveMonedaPago = 2 Then + 'DivTC.Visible = False + RegistraScript("document.getElementById('DivTC').style.display = 'none';") + DivTCDolares.Visible = True + TxtTCDolares.Attributes.Add("onkeyup", String.Format("FnCambia(0,0,0,0,-1,{0});", CveMonedaPago)) + End If + + CargaDatos(CveMoneda) + + End Sub +End Class From 4a037cbb5564c88fd16f20d4028351d5b2fddffc Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 19 Mar 2020 11:56:35 -0700 Subject: [PATCH 14/24] -cambios de contabilidad --- App_Code/ClsSisEmpresas.vb | 3 +- App_Code/Empresa.vb | 1 + Contabilidad/ContabilizacionVentas.aspx | 22 ++++----- Contabilidad/ContabilizacionVentas.aspx.cs | 56 ++++++++++++++-------- Contabilidad/RegPrePoliza.aspx.vb | 2 +- Contabilidad/RegPrePolizaS.aspx | 2 +- 6 files changed, 53 insertions(+), 33 deletions(-) diff --git a/App_Code/ClsSisEmpresas.vb b/App_Code/ClsSisEmpresas.vb index 12fb16ca2..19ac5cf29 100644 --- a/App_Code/ClsSisEmpresas.vb +++ b/App_Code/ClsSisEmpresas.vb @@ -463,7 +463,8 @@ Public Class ClsSisEmpresas _Empresa.CveDistribuidor = Data.Rows(0)("CveDistribuidor").ToString.ToEntero _Empresa.DiasPermitidos = Data.Rows(0)("DiasPermitidos").ToString.ToEntero _Empresa.AsientoContableComprasContado = If(Data.Rows(0)("Conta_AsientoContableComprasContado").ToString = "", False, CBool(Data.Rows(0)("Conta_AsientoContableComprasContado").ToString)) - _Empresa.TipoContabilizacion = Data.Rows(0)("Conta_TipoContabilizacion").ToString.ToEntero '0 - Sin Conta, 1- Contabilidad SIG, 2- Contabilidad Contpaq + _Empresa.TipoContabilizacion = Data.Rows(0)("Conta_TipoContabilizacion").ToString.ToEntero + _Empresa.TipoContabilidad = Data.Rows(0)("Conta_TipoContabilidad").ToString.ToEntero '0 - Sin Conta, 1- Contabilidad SIG, 2- Contabilidad Contpaq _Empresa.DefaultAsistencias = If(Data.Rows(0)("RH_DefaultAsistencias").ToString = "", False, CBool(Data.Rows(0)("RH_DefaultAsistencias").ToString)) _Empresa.CIEC = Data.Rows(0)("CIEC").ToString _Empresa.Localidad = Data.Rows(0)("Localidad").ToString diff --git a/App_Code/Empresa.vb b/App_Code/Empresa.vb index 2efb97358..c16fa4e9b 100644 --- a/App_Code/Empresa.vb +++ b/App_Code/Empresa.vb @@ -153,6 +153,7 @@ Public Class Empresa Public Property DiasPermitidos As Integer Public Property AsientoContableComprasContado As Boolean Public Property TipoContabilizacion As Integer + Public Property TipoContabilidad As Integer Public Property DefaultAsistencias As Boolean Public Property FormatoImpresion As Integer Public Property EsPersonaFisica As Integer diff --git a/Contabilidad/ContabilizacionVentas.aspx b/Contabilidad/ContabilizacionVentas.aspx index 8eb4fa9aa..3bd4788a6 100644 --- a/Contabilidad/ContabilizacionVentas.aspx +++ b/Contabilidad/ContabilizacionVentas.aspx @@ -111,12 +111,12 @@
- + - + @@ -125,7 +125,7 @@ - + @@ -203,12 +203,12 @@ - + - + @@ -217,7 +217,7 @@ - + @@ -292,12 +292,12 @@ - + - + @@ -306,7 +306,7 @@ - + @@ -386,7 +386,7 @@ - + @@ -395,7 +395,7 @@ - + diff --git a/Contabilidad/ContabilizacionVentas.aspx.cs b/Contabilidad/ContabilizacionVentas.aspx.cs index 450020920..a1f1b73db 100644 --- a/Contabilidad/ContabilizacionVentas.aspx.cs +++ b/Contabilidad/ContabilizacionVentas.aspx.cs @@ -35,7 +35,7 @@ public partial class Contabilidad_ContabilizacionVentas : ClsPaginas { TienePermisoVerPoliza = false; TienePermisoEditar = false; - if (UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.TipoContabilidad == 2 && UsuarioActual.Empresa.UsaContabilidad) { TienePermisoEditar = UsuarioActual.TienePermisoProceso(221); @@ -51,16 +51,16 @@ public partial class Contabilidad_ContabilizacionVentas : ClsPaginas TienePermisoVerPoliza = true; } } - else - { - Alert("Este módulo requiere el uso de Contabilidad.", ModExtensiones.TipoMensaje.MsgAdvertencia); - //BtnConsultar.Enabled = false; - BtnContabilizarVentas.Enabled = false; - BtnContabilizarPagos.Enabled = false; - BtnContabilizarAnticipos.Enabled = false; - BtnContabilizarAmortizaciones.Enabled = false; - ImgExcel2.Visible = false; - } + //else + //{ + // Alert("Este módulo requiere el uso de Contabilidad.", ModExtensiones.TipoMensaje.MsgAdvertencia); + // //BtnConsultar.Enabled = false; + // BtnContabilizarVentas.Enabled = false; + // BtnContabilizarPagos.Enabled = false; + // BtnContabilizarAnticipos.Enabled = false; + // BtnContabilizarAmortizaciones.Enabled = false; + // ImgExcel2.Visible = false; + //} DdlClientes.setEsWebService(true); DdlClientes.Attributes.Add("data-metodo", "getcliente"); @@ -330,7 +330,8 @@ public partial class Contabilidad_ContabilizacionVentas : ClsPaginas { if (e.Row.RowType == DataControlRowType.DataRow) { - int cuenta = e.Row.DataKey("IdCtaContable").ToString().ToEntero(); + int cuenta = e.Row.DataKey("IdCtaContable").ToString().ToEntero(); + int cvecuenta = e.Row.DataKey("CveCuenta").ToString().ToEntero(); int CveConcepto = e.Row.DBCampo("CveConceptoContable").ToEntero(); if (CveConcepto.Contiene(5, 6, 14, 19, 17, 206, 25, 26)) @@ -354,19 +355,36 @@ public partial class Contabilidad_ContabilizacionVentas : ClsPaginas e.Row.FCHyperLink("HplC").NavigateUrl = string.Format("/RH/Personal.aspx?CvePersonal={0}", e.Row.DBCampo("CvePersonal")); } - if (cuenta > 0) - { - DataRow dr = DTmpC.FiltroPrimero(String.Format("Id = {0}", cuenta)); - if (dr != null) e.Row.Cells[3].Text = string.Format("{0}
{1}", dr["CuentaFormato"], dr["Nombre"]); + if (UsuarioActual.Empresa.TipoContabilidad == 1) // conta SIG + { + if (cvecuenta == 0) + { + e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Visible = false; + } + } else { - e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + if (UsuarioActual.Empresa.TipoContabilidad == 2) // conta Contpaq + { + if (cuenta > 0) + { + DataRow dr = DTmpC.FiltroPrimero(String.Format("Id = {0}", cuenta)); - ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Visible = false; + if (dr != null) e.Row.Cells[3].Text = string.Format("{0}
{1}", dr["CuentaFormato"], dr["Nombre"]); + } + else + { + e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + + ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Visible = false; + } + + } } - + if (Convert.ToDecimal(e.Row.DataKey("Cargo").ToString()) == 0) e.Row.Cells[4].Text = ""; if (Convert.ToDecimal(e.Row.DataKey("Abono").ToString()) == 0) e.Row.Cells[5].Text = ""; diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb index 206ab0252..5b8d34dd4 100644 --- a/Contabilidad/RegPrePoliza.aspx.vb +++ b/Contabilidad/RegPrePoliza.aspx.vb @@ -171,7 +171,7 @@ Partial Class ContabilidadC_RegPrePoliza Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then - If UsuarioActual.Empresa.TipoContabilizacion = 1 Then + If UsuarioActual.Empresa.TipoContabilidad = 1 Then Response.Redirect(Request.Url.PathAndQuery.Replace("RegPrePoliza", "RegPrePolizaS")) End If diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 42dc3d8b6..56ac1ea7e 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -456,7 +456,7 @@ Cuenta -
+
<%----%> <%--
--%>
From b564fe72b12188cc140c50ccc95353f523a19059 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 19 Mar 2020 11:57:05 -0700 Subject: [PATCH 15/24] --- Contabilidad2/CatCuentas.aspx | 5 +++-- Contabilidad2/CatCuentas.aspx.vb | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Contabilidad2/CatCuentas.aspx b/Contabilidad2/CatCuentas.aspx index 0bbfc328f..ca1f269ad 100644 --- a/Contabilidad2/CatCuentas.aspx +++ b/Contabilidad2/CatCuentas.aspx @@ -191,7 +191,7 @@
- + (0% - 100% )
@@ -205,8 +205,9 @@
-
+
+
diff --git a/Contabilidad2/CatCuentas.aspx.vb b/Contabilidad2/CatCuentas.aspx.vb index 7bbd87a3c..64e94e54c 100644 --- a/Contabilidad2/CatCuentas.aspx.vb +++ b/Contabilidad2/CatCuentas.aspx.vb @@ -83,6 +83,7 @@ Partial Class Contabilidad2_CatCuentas ' If UsuarioActual.Empresa.UsaContabilidad Then DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) CargaMonedas() CargaAgrupadorSAT() CargaDatos() @@ -90,6 +91,15 @@ Partial Class Contabilidad2_CatCuentas objconta.GetConta_ConceptosContables(1) DtConceptosconta = objconta.DtResultados End Using + Using ObjBancos As New ClsBancos + If ObjBancos.GetBancosCuentas(-1) Then + ddlBancos.DataSource = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + ddlBancos.DataBind() + ddlBancos.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + End Using + + DdlConcepto.DataSource = DtConceptosconta DdlConcepto.DataBind() DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) @@ -224,7 +234,7 @@ Partial Class Contabilidad2_CatCuentas objconta.GetConta_CuentasDataContabilidad(IDSelected, UsuarioActual.CveEmpresa) If objconta.DtResultados.Rows.Count > 0 Then Dim rowcc As DataRow = objconta.DtResultados.Rows(0) - + DdlConcepto.SelectedValue = -1 DdlConcepto.SelectedValueExist(rowcc("CveConceptoAdmin").ToString().ToEntero()) onconceptochange() CveProveedor = rowcc("CveProveedor").ToString().ToEntero() @@ -238,7 +248,10 @@ Partial Class Contabilidad2_CatCuentas CveClasificacion = rowcc("CveClasificacion").ToString().ToEntero() DdlClasificacion.SelectedValueExist(CveClasificacion) CveBancoCuenta = rowcc("CveBancoCuenta").ToString().ToEntero() + ddlBancos.SelectedValue = -1 + ddlBancos.SelectedValueExist(CveBancoCuenta) CveAlmacen = rowcc("CveAlmacen").ToString().ToEntero() + DdlAlmacen.SelectedValue = -1 DdlAlmacen.SelectedValueExist(CveAlmacen) End If @@ -286,7 +299,7 @@ Partial Class Contabilidad2_CatCuentas Dim CveCliente As Integer = DdlClientesWS.SelectedValue.ToEntero() Dim CveClasificacion As Integer = DdlClasificacion.SelectedValue.ToEntero() Dim PorcentajeImpuesto As Decimal = TxtPorcentaje.Text.ToDecimal() / 100 - Dim CveBancoCuenta As Integer = -1 + Dim CveBancoCuenta As Integer = ddlBancos.SelectedValue.ToEntero Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero() If ObjConta.UpdateCuenta(IDSelected.ToEntero, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToString.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, TxtNomIngles.Text.ToString, CveConceptoAdmin:=CveConceptoAdmin, CveProveedor:=CveProveedor, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeImpuesto, CveBancoCuenta:=CveBancoCuenta, CveAlmacen:=CveAlmacen) Then From f01c46f54b2971bc56c8d230b889dade4f8ee24d Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 19 Mar 2020 13:13:54 -0700 Subject: [PATCH 16/24] -condiion de seguridad --- Inventarios/RecepcionEntrega.aspx.vb | 241 ++++++++++++++------------- 1 file changed, 126 insertions(+), 115 deletions(-) diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb index d6f6cf9ab..c611b6e05 100644 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ b/Inventarios/RecepcionEntrega.aspx.vb @@ -1877,110 +1877,121 @@ Partial Class Inventarios_RecepcionEntrega Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero + If TipoDocto = "Rem" AndAlso CveAlmacenTraspasoDestino = 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error. no se tiene definido el almacen destino" + End If + 'DEVOLUCION REMISION If TipoMovimiento = 2 And TipoDocto = "Rem" Then - ConceptoMovimiento = 8 - Almacen1 = CveAlmacenTraspasoDestino - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If + ConceptoMovimiento = 8 + Almacen1 = CveAlmacenTraspasoDestino + CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero + End If - 'CANCELACION DE DEVOLUCION - If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then - ConceptoMovimiento = 3 - Almacen1 = DdlAlmacen.SelectedValue.ToEntero - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If + 'CANCELACION DE DEVOLUCION + If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then + ConceptoMovimiento = 3 + Almacen1 = DdlAlmacen.SelectedValue.ToEntero + CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero + End If - CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, + CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Modulo:="RE/G7") - Folio = ObjInventario.Folio + Folio = ObjInventario.Folio - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) - 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then - If CveMovimiento > 0 Then + 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) + 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then + If CveMovimiento > 0 Then - 'SACA LO DE TRASPASOS - APARTADO - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + 'SACA LO DE TRASPASOS - APARTADO + For Each Dr1 As DataRow In DtTraspasos.Rows + CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + If ObjInventario.DtResultados.Rows.Count = 0 Then ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - If ErrorMovInv Then Exit For - Next - - 'ES EL MOVIMIENTO PRINCIPAL - CantidadPendiente = 0 - Dim Cont As Integer = 0 - For Each Dr As DataRow In DtDatos.Rows - CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal - If CantidadPendiente > 0 Then - Dim PU As Decimal = 0 - - 'SI FUE POR SERIELOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - If DtDetalle.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalle.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - ElseIf DtDetalleLote.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalleLote.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - Else - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal + TextoError = "Ocurrió un error, no se tienen registros que ingresar" + Exit Sub End If - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For - End If - End If - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorMovInv = True - TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For End If Next End If - Cont += 1 - End If - Next - Else - ErrorMovInv = True + If ErrorMovInv Then Exit For + Next + + 'ES EL MOVIMIENTO PRINCIPAL + CantidadPendiente = 0 + Dim Cont As Integer = 0 + For Each Dr As DataRow In DtDatos.Rows + CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal + If CantidadPendiente > 0 Then + Dim PU As Decimal = 0 + + 'SI FUE POR SERIELOTE + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) + DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) + If DtDetalle.Rows.Count > 0 Then + For Each Dr1 As DataRow In DtDetalle.Rows + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." + Exit For + End If + Next + ElseIf DtDetalleLote.Rows.Count > 0 Then + For Each Dr1 As DataRow In DtDetalleLote.Rows + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." + Exit For + End If + Next + Else + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." + Exit For + End If + End If + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + Cont += 1 + End If + Next + Else + ErrorMovInv = True + End If End If - End If - 'End If + 'End If - 'ENTRADA POR TRASPASO CUANDO ES REMISION - If Not ErrorMovInv Then + 'ENTRADA POR TRASPASO CUANDO ES REMISION + If Not ErrorMovInv Then If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G8") @@ -2212,7 +2223,7 @@ Partial Class Inventarios_RecepcionEntrega End If ' COMIENZA: VIRTUAL - If TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then + If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then Dim DtPSVirtual As New DataTable("DtTamanios") If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then @@ -2246,46 +2257,46 @@ Partial Class Inventarios_RecepcionEntrega End If If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then - CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6") - FolioVirtual = ObjInventario.Folio + FolioVirtual = ObjInventario.Folio - If CveMovimientoVirtual > 0 Then - For Each RowUsado As DataRow In DtPSVirtual.Rows - Dim CvePS = RowUsado("CvePS").ToString().ToEntero() - Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Double = RowUsado("PU").ToString().ToDouble() - Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - Else - ErrorMovInv = True - End If + If CveMovimientoVirtual > 0 Then + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() + Dim PU As Double = RowUsado("PU").ToString().ToDouble() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + Next Else - If ValidaVirtual Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar." - - End If + ErrorMovInv = True End If - If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then + Else + If ValidaVirtual Then ErrorMovInv = True - TextoError = "No se tienen productos para el almacen virtual." + TextoError = "Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar." + End If End If - ' TERMINA: VIRTUAL + If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then + ErrorMovInv = True + TextoError = "No se tienen productos para el almacen virtual." + End If + End If + + ' TERMINA: VIRTUAL - 'AGREGA BITACORA A VENTA - If Not ErrorMovInv Then + 'AGREGA BITACORA A VENTA + If Not ErrorMovInv Then Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta") If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then ErrorMovInv = True From cbaa17f1087d774be59e83e40cbfc754e4ca79aa Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 19 Mar 2020 13:17:20 -0700 Subject: [PATCH 17/24] --- Contabilidad2/CatCuentas.aspx.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Contabilidad2/CatCuentas.aspx.vb b/Contabilidad2/CatCuentas.aspx.vb index 64e94e54c..7dbef8341 100644 --- a/Contabilidad2/CatCuentas.aspx.vb +++ b/Contabilidad2/CatCuentas.aspx.vb @@ -305,7 +305,8 @@ Partial Class Contabilidad2_CatCuentas CveConceptoAdmin:=CveConceptoAdmin, CveProveedor:=CveProveedor, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeImpuesto, CveBancoCuenta:=CveBancoCuenta, CveAlmacen:=CveAlmacen) Then Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}") - If UsuarioActual.Empresa.TipoContabilizacion <> 1 Then + + If UsuarioActual.Empresa.TipoContabilidad <> 1 Then Using ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa) From f40282f6494c89632bdafef903ab143e255b030e Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 19 Mar 2020 14:19:15 -0700 Subject: [PATCH 18/24] estatus-1 --- Inventarios/RepAlmacen.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventarios/RepAlmacen.aspx.vb b/Inventarios/RepAlmacen.aspx.vb index 57284f8ca..e5c1795b3 100644 --- a/Inventarios/RepAlmacen.aspx.vb +++ b/Inventarios/RepAlmacen.aspx.vb @@ -40,7 +40,7 @@ Partial Class Inventarios_RepAlmacen DdlTipoAlmacen.DataBind() DdlTipoAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1) + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1, CveEstatus:=-1) DdlAlmacen.DataBind() DdlAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) From c708f20fb8e7ed83a809f24b612be0b86cced480 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 19 Mar 2020 17:37:41 -0700 Subject: [PATCH 19/24] --- .gitignore | 2 ++ App_Code/ClsContabilidad.vb | 18 ++++++++++++ App_Code/ClsInventarios.vb | 6 ++-- App_Code/MyHub.vb | 3 +- App_Code/Notificaciones.vb | 4 +++ Inventarios/CatAlmacenes.aspx | 31 ++++++++++++-------- Inventarios/CatAlmacenes.aspx.vb | 49 +++++++++++++++++++++++--------- vwd.webinfo | 2 ++ 8 files changed, 87 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 9b5134ac3..ea1f6b673 100644 --- a/.gitignore +++ b/.gitignore @@ -269,3 +269,5 @@ paket-files/ __pycache__/ *.pyc /Utilerias +/Default.aspx +/Default.aspx.cs diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index f5e63f696..39578f6b3 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -149,6 +149,24 @@ Public Class ClsContabilidad #End Region + + Public Function CuentasContablesSigGet(cveEmpresa As Int32) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Conta_CuentasContablesSigGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener las Cuentas Contables", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener las Cuentas Contables", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + #Region " C O N T A B I L I D A D - P R E P O L I Z A" Public Function ObtenerTipoPoliza(Valor1 As String, Valor2 As String, CveEmpresa As Integer) As Integer Dim Retorno As Integer = -1 diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index dcb5e33bb..0d59da612 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -355,7 +355,7 @@ Public Class ClsInventarios End Function - Public Function AddAlmacen(Almacen As String, CveTipoAlmacen As Integer, IdCtaContable As Integer, Modalidad As Integer, CveUsuario As Integer, CveEmpresa As Integer, Inventariable As Byte, CveSubProyecto As Integer, Optional Orden As Integer = -1) As Boolean + Public Function AddAlmacen(Almacen As String, CveTipoAlmacen As Integer, IdCtaContable As Integer, Modalidad As Integer, CveUsuario As Integer, CveEmpresa As Integer, Inventariable As Byte, CveSubProyecto As Integer, Optional Orden As Integer = -1, Optional CveCuenta As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_AlmacenesAdd") @@ -370,6 +370,7 @@ Public Class ClsInventarios .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@Orden", SqlDbType.SmallInt).Value = Orden + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta End With Try @@ -388,7 +389,7 @@ Public Class ClsInventarios Return Retorno End Function - Public Function UpdateAlmacen(Almacen As String, CveTipoAlmacen As Integer, IdCtaContable As Integer, Modalidad As Integer, Estatus As Boolean, CveAlmacen As Integer, Inventariable As Byte, CveSubProyecto As Integer, Optional Orden As Integer = -1) As Boolean + Public Function UpdateAlmacen(Almacen As String, CveTipoAlmacen As Integer, IdCtaContable As Integer, Modalidad As Integer, Estatus As Boolean, CveAlmacen As Integer, Inventariable As Byte, CveSubProyecto As Integer, Optional Orden As Integer = -1, Optional CveCuenta As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_AlmacenesUpdate") @@ -403,6 +404,7 @@ Public Class ClsInventarios .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@Orden", SqlDbType.SmallInt).Value = Orden + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta End With Try diff --git a/App_Code/MyHub.vb b/App_Code/MyHub.vb index 188cdf257..192de4c25 100644 --- a/App_Code/MyHub.vb +++ b/App_Code/MyHub.vb @@ -15,7 +15,7 @@ Public Class MyHub Private Sub RemoveUsuarios() End Sub - Public Shared Sub RemoveConexiones(CveUsuario As Integer) + Public Shared Sub RemoveConexiones(CveUsuario As Integer) End Sub Public Sub ShowUsersOnLine() @@ -76,6 +76,7 @@ Public Class MyhubUserIdProvider Private Function IUserIdProvider_GetUserId(request As IRequest) As String Implements IUserIdProvider.GetUserId Dim userId = Decripta(request.User.Identity.Name) 'MyCustomUserClass.FindUserId(request.User.Identity.Name) + GuardaLog(String.Format("userId:{0}", userId)) Return userId.ToString() End Function End Class \ No newline at end of file diff --git a/App_Code/Notificaciones.vb b/App_Code/Notificaciones.vb index fa9af0d8c..998dc6149 100644 --- a/App_Code/Notificaciones.vb +++ b/App_Code/Notificaciones.vb @@ -31,4 +31,8 @@ Public Class Notificaciones Clients.Users(Para).AlertaVentana(Titulo, Message, DirectCast(Tipo, Integer), timeoutseconds) End Sub + 'Public Shared Sub AlertaVentana(Message As String, Para As List(Of String), Optional Titulo As String = "", Optional timeoutseconds As Integer = 5, Optional Tipo As TipoNotificacion = TipoNotificacion.AlertaVentanaNoOcultar) + ' Dim Clients As Hubs.IHubConnectionContext(Of Object) = GlobalHost.ConnectionManager.GetHubContext(Of Notificaciones)().Clients + ' Clients.Users(Para).AlertaVentana(Titulo, Message, DirectCast(Tipo, Integer), timeoutseconds) + 'End Sub End Class diff --git a/Inventarios/CatAlmacenes.aspx b/Inventarios/CatAlmacenes.aspx index 7f05df293..76ccaeb2b 100644 --- a/Inventarios/CatAlmacenes.aspx +++ b/Inventarios/CatAlmacenes.aspx @@ -151,7 +151,7 @@ - + @@ -233,7 +233,7 @@
- +
@@ -244,13 +244,13 @@
--%>
- +
- +
@@ -261,14 +261,21 @@ - +
-
- - -
+ + + + + + + + + + +
@@ -278,14 +285,14 @@ - +
- +
@@ -293,7 +300,7 @@
- +
diff --git a/Inventarios/CatAlmacenes.aspx.vb b/Inventarios/CatAlmacenes.aspx.vb index d28cd35dd..c600d6351 100644 --- a/Inventarios/CatAlmacenes.aspx.vb +++ b/Inventarios/CatAlmacenes.aspx.vb @@ -84,17 +84,33 @@ Partial Class Inventarios_CatAlmacenes End Sub Private Sub CargaCuentasContables() - Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) - 'UsuarioActual.Empresa.Funcionalidad(208).ToEntero - If ObjContabilidad.GetCuentasRecursiva(UsuarioActual.Empresa.Funcionalidad(208).ToEntero, 1) Then - DtCuentasContables = ObjContabilidad.DtResultados + If UsuarioActual.Empresa.TipoContabilidad = 1 Then + divCuentasCompac.Visible = False + pnlCuentassig.Visible = True + Using ObjContabilidad As New ClsContabilidad + 'UsuarioActual.Empresa.Funcionalidad(208).ToEntero + If ObjContabilidad.CuentasContablesSigGet(UsuarioActual.CveEmpresa) Then + DdlCuentasSig.DataSource = ObjContabilidad.DtResultados + DdlCuentasSig.DataBind() + DdlCuentasSig.Items.Insert(0, New ListItem("Selecione", "-1")) + End If + End Using Else - DtCuentasContables = Nothing + divCuentasCompac.Visible = True + pnlCuentassig.Visible = False + Using ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) + 'UsuarioActual.Empresa.Funcionalidad(208).ToEntero + If ObjContabilidad.GetCuentasRecursiva(UsuarioActual.Empresa.Funcionalidad(208).ToEntero, 1) Then + DtCuentasContables = ObjContabilidad.DtResultados + Else + DtCuentasContables = Nothing + End If + End Using + + DdlCuentasContables.DataSource = DtCuentasContables + DdlCuentasContables.DataBind() End If - ObjContabilidad.Dispose() - DdlCuentasContables.DataSource = DtCuentasContables - DdlCuentasContables.DataBind() UpAddAlmacen.Update() End Sub @@ -207,12 +223,17 @@ Partial Class Inventarios_CatAlmacenes Dim TieneError = False Dim Estatus = 0 If ChkEstatus.Checked Then Estatus = 1 - Dim CuentaContable = DdlCuentasContables.SelectedValue.ToEntero - If divddlcc.Visible = False Then - CuentaContable = 0 + Dim CuentaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + If divddlcc.Visible Then + If pnlCuentassig.Visible Then + CveCuenta = DdlCuentasSig.SelectedValue.ToEntero() + Else + CuentaContable = DdlCuentasContables.SelectedValue.ToEntero() + End If End If If HdnModalidad.Value = "A" Then - If ObjAlmacen.AddAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero) Then + If ObjAlmacen.AddAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero, CveCuenta) Then Alert("El nuevo Almacen se guardó correctamente.", TipoMensaje.MsgInformacion) UpDatos.Update() ViewState("DTAlmacenes") = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) @@ -222,7 +243,7 @@ Partial Class Inventarios_CatAlmacenes Else TieneError = True End If - ElseIf ObjAlmacen.UpdateAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, (CByte(Estatus)), HdnID.Value.ToEntero, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero) Then + ElseIf ObjAlmacen.UpdateAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, (CByte(Estatus)), HdnID.Value.ToEntero, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero, CveCuenta) Then Alert("El Almacen se actualizo correctamente.", TipoMensaje.MsgInformacion) UpDatos.Update() ViewState("DTAlmacenes") = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) @@ -280,6 +301,8 @@ Partial Class Inventarios_CatAlmacenes DdlModalidad.SelectedValue = If((GvRow.DataKey("Modalidad")) = "Solo Existencia", 0, 1) divddlcc.Visible = If((DdlModalidad.SelectedValue) = 1, True, False) DdlCuentasContables.SelectedValueExist(GvRow.DataKey("IdCtaContable")) + DdlCuentasSig.SelectedValueExist(-1) + DdlCuentasSig.SelectedValueExist(GvRow.DataKey("CveCuenta")) DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto")) DdlTipoAlmacen.SelectedValueExist(GvRow.DataKey("CveTipoAlmacen")) TxtAlmacen.Text = GvRow.DataKey("Almacen") diff --git a/vwd.webinfo b/vwd.webinfo index 3f67b239f..8bbca547d 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -28,6 +28,8 @@ + + From 6d8a7c1e953e79d76e7eaef5a50ba91e6b283928 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 19 Mar 2020 18:55:29 -0700 Subject: [PATCH 20/24] - cambios signalr --- Contabilidad/ContabilizacionCompras.aspx | 14 ++--- Contabilidad/ContabilizacionCompras.aspx.cs | 63 ++++++++++++++------- LogIn.aspx | 1 + Scripts/Notificaciones.js | 34 +++++------ Site.master | 2 +- 5 files changed, 68 insertions(+), 46 deletions(-) diff --git a/Contabilidad/ContabilizacionCompras.aspx b/Contabilidad/ContabilizacionCompras.aspx index 0d1df40eb..cf38a955a 100644 --- a/Contabilidad/ContabilizacionCompras.aspx +++ b/Contabilidad/ContabilizacionCompras.aspx @@ -129,7 +129,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -249,7 +249,7 @@ - + @@ -345,7 +345,7 @@ - + @@ -354,7 +354,7 @@ - + @@ -435,7 +435,7 @@ - + @@ -444,7 +444,7 @@ - + diff --git a/Contabilidad/ContabilizacionCompras.aspx.cs b/Contabilidad/ContabilizacionCompras.aspx.cs index 77c08b249..ec8ae0aba 100644 --- a/Contabilidad/ContabilizacionCompras.aspx.cs +++ b/Contabilidad/ContabilizacionCompras.aspx.cs @@ -42,7 +42,7 @@ public partial class Contabilidad_ContabilizacionCompras : ClsPaginas TienePermisoEditar = false; DdlProveedores.setEsWebService(true); DdlProveedores.Attributes.Add("data-metodo", "getproveedores"); - if (UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.TipoContabilidad == 2 && UsuarioActual.Empresa.UsaContabilidad) { TienePermisoEditar = false; ClsContPAQi ObjCont = new ClsContPAQi(UsuarioActual.Empresa); @@ -65,23 +65,27 @@ public partial class Contabilidad_ContabilizacionCompras : ClsPaginas txtFechaF.Text = DateTime.Now.ToShortDateString(); //CargaDatos(); + + } - if (UsuarioActual.CveRol == 1 || UsuarioActual.CveUsuario == 17 || UsuarioActual.CveUsuario == 171 || UsuarioActual.TienePermisoProceso(221)) - { - TienePermisoEditar = true; - TienePermisoVerPoliza = true; - } - } - else + if (UsuarioActual.CveRol == 1 || UsuarioActual.CveUsuario == 17 || UsuarioActual.CveUsuario == 171 || UsuarioActual.TienePermisoProceso(221)) { - Alert("Este módulo requiere el uso de Contabilidad.", ModExtensiones.TipoMensaje.MsgAdvertencia); - // BtnConsultar.Enabled = false; - BtnContabilizarCompras.Enabled = false; - BtnContabilizarPagos.Enabled = false; - BtnContabilizarAnticipos.Enabled = false; - BtnContabilizarAmortizaciones.Enabled = false; + TienePermisoEditar = true; + TienePermisoVerPoliza = true; } + txtFechaI.Text = DateTime.Now.ToShortDateString(); + txtFechaF.Text = DateTime.Now.ToShortDateString(); + //else + //{ + // Alert("Este módulo requiere el uso de Contabilidad.", ModExtensiones.TipoMensaje.MsgAdvertencia); + // // BtnConsultar.Enabled = false; + // BtnContabilizarCompras.Enabled = false; + // BtnContabilizarPagos.Enabled = false; + // BtnContabilizarAnticipos.Enabled = false; + // BtnContabilizarAmortizaciones.Enabled = false; + //} + } BtnConsultar.Click += new EventHandler(this.BtnConsultar_Click); @@ -310,6 +314,7 @@ public partial class Contabilidad_ContabilizacionCompras : ClsPaginas if (e.Row.RowType == DataControlRowType.DataRow) { int cuenta = e.Row.DataKey("IdCtaContable").ToString().ToEntero(); + int cvecuenta = e.Row.DataKey("CveCuenta").ToString().ToEntero(); int CveConcepto = e.Row.DBCampo("CveConceptoContable").ToEntero(); if (CveConcepto.Contiene(5, 6, 14, 16, 17, 19, 206, 22, 23, 25, 26, 18, 60, 183, 184, 185, 186 ,205, 240, 243, 244, 248, 249,15,22,248,249,237)) @@ -337,21 +342,37 @@ public partial class Contabilidad_ContabilizacionCompras : ClsPaginas e.Row.FCHyperLink("HplC").NavigateUrl = string.Format("/OC/OC.aspx?OC={0}", e.Row.DBCampo("CveOC")); } - - if (cuenta > 0) + if (UsuarioActual.Empresa.TipoContabilidad == 1) // conta SIG { - DataRow dr = DTmpC.FiltroPrimero(String.Format("Id = {0}", cuenta)); + if (cvecuenta == 0) + { + e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Visible = false; + } - if (dr != null) e.Row.Cells[3].Text = string.Format("{0}
{1}", dr["CuentaFormato"], dr["Nombre"]); } else { - e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + if (UsuarioActual.Empresa.TipoContabilidad == 2) // conta Contpaq + { - ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Enabled = false; - ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").ToolTip = "Hay conceptos sin cuenta asignada"; + if (cuenta > 0) + { + DataRow dr = DTmpC.FiltroPrimero(String.Format("Id = {0}", cuenta)); + + if (dr != null) e.Row.Cells[3].Text = string.Format("{0}
{1}", dr["CuentaFormato"], dr["Nombre"]); + } + else + { + e.Row.Cells[0].ForeColor = System.Drawing.Color.Red; + + ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").Enabled = false; + ((GridViewRow)((GridView)e.Row.NamingContainer).BindingContainer).FCCheckBox("Chk").ToolTip = "Hay conceptos sin cuenta asignada"; + } + } } + if (Convert.ToDecimal(e.Row.DataKey("Cargo").ToString()) == 0) e.Row.Cells[4].Text = ""; if (Convert.ToDecimal(e.Row.DataKey("Abono").ToString()) == 0) e.Row.Cells[5].Text = ""; diff --git a/LogIn.aspx b/LogIn.aspx index 48b8f0570..72432698d 100644 --- a/LogIn.aspx +++ b/LogIn.aspx @@ -129,6 +129,7 @@ <%: Scripts.Render("~/Metronic/assets/global/scripts/JS") %> - +