From 93fed87fb852d9387963e1cc6d11a6596f3e62a2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 8 Dec 2021 15:17:33 -0700 Subject: [PATCH 1/6] Quitar carga de variable CveDevolucion al cargar documento tipo devolucion --- Ventas/Ventas.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 5e8d6547b..6e4e7d7d9 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -4388,7 +4388,7 @@ Partial Class Ventas DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() + 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() Trsaldo.Visible = True HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) From eb8de2783725dbc2e7d240a8be5b988fde67d4cd Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 8 Dec 2021 16:12:40 -0700 Subject: [PATCH 2/6] Presupuesto Excel --- Contratos/Contrato.aspx | 5 ++++- Contratos/Contrato.aspx.vb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Contratos/Contrato.aspx b/Contratos/Contrato.aspx index 7fb92b014..52992ef0a 100644 --- a/Contratos/Contrato.aspx +++ b/Contratos/Contrato.aspx @@ -130,7 +130,9 @@
  • Presupuesto PDF
  • - +
  • + Presupuesto Excel +
  • Activos Fijos PDF
  • @@ -170,6 +172,7 @@ + diff --git a/Contratos/Contrato.aspx.vb b/Contratos/Contrato.aspx.vb index 02127071e..50bb6f76a 100644 --- a/Contratos/Contrato.aspx.vb +++ b/Contratos/Contrato.aspx.vb @@ -2754,7 +2754,7 @@ Partial Class Contratos_Default Private Sub CargaGVGastos() Dim objContrato As New ClsContratos - If objContrato.GetContratoGastos(CveContrato) Then + If objContrato.GetContratoGastos(CveContrato, UsuarioActual.CveEmpresa) Then DtGastos = objContrato.DtResultados GvContratosGastos.DataSource = DtGastos SumaGasto = objContrato.DtResultados.SUM("Importe", "CveContratoGasto IS NULL") @@ -3835,6 +3835,9 @@ Partial Class Contratos_Default #Region "I M P R E S I O N D E P R E S U P U E S T O " Private Sub lLbImprimirPresupuesto_Click(sender As Object, e As EventArgs) Handles LbImprimirPresupuesto.Click GenerarPDFPPresupuesto() + End Sub + Private Sub lLbImprimirPresupuestoEXCEL_Click(sender As Object, e As EventArgs) Handles LbImprimirPresupuestoExcel.Click + GenerarPDFPPresupuesto(Formato:="EXCEL") End Sub Private Sub GenerarPDFPPresupuesto(Optional Formato As String = "PDF") Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) From 9e8aebc774ebde3bf02dde523a3c99945d8bc406 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 9 Dec 2021 15:46:47 -0700 Subject: [PATCH 3/6] Correcion de asignacion de permisos --- Sistemas/UsuarioDetalle.aspx.vb | 1521 +++++++++++++++---------------- 1 file changed, 760 insertions(+), 761 deletions(-) diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index b17cec2e5..a70806496 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -6,8 +6,8 @@ Imports System.Data Imports System.Threading Partial Class Sistemas_UsuarioDetalle - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "P R O P I E D A D E S" Private Property DTEstatusSubProyectos As DataTable Get @@ -84,7 +84,7 @@ Partial Class Sistemas_UsuarioDetalle Get Return ViewState("Password").ToString End Get - End Property + End Property Private ReadOnly Property CodigoAcceso As String Get Return ViewState("CodigoAcceso").ToString @@ -395,10 +395,10 @@ Partial Class Sistemas_UsuarioDetalle Set(value As Integer) ViewState("CveEmpresaAnterior") = value End Set - End Property + End Property #End Region - - + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then @@ -450,30 +450,30 @@ Partial Class Sistemas_UsuarioDetalle TrLimiteAutorizacion.Visible = True End If - If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then - TrCodigoAcceso.Visible = True + If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then + TrCodigoAcceso.Visible = True End If - CargaDatos() - InicializaClonarUsuario() - InicializaRestricciones() - CargaGvBitacora() - CargaEmpresasAsignaciones() - CreaDtAsignacionesMultiEmpresa() - CveEmpresaAnterior = DdlEmpresaAsignaciones.SelectedValue.ToEntero - + CargaDatos() + InicializaClonarUsuario() + InicializaRestricciones() + CargaGvBitacora() + CargaEmpresasAsignaciones() + CreaDtAsignacionesMultiEmpresa() + CveEmpresaAnterior = DdlEmpresaAsignaciones.SelectedValue.ToEntero + End If - End Sub - - 'DOCUMENTACION - 'LOS CAMPOS DE DATATABLE "ACCION" SE REFIERE AL ESTATUS DE LOS CAMBIOS QUE OCURRIERON ANTES DE DARLE GUARDAR - ' 0/NULL/VACIO = ORIGINAL (SIN CAMBIO) - ' 1 = AGREGADO - ' 2 = ELIMINADO - ' 3 = NADA (AGREGADO Y ELIMINADO): CUANDO AGREGA UN REGISTRO Y LO ELIMINA, ES DECIR, NO SE GUARDA NADA - ' 4 = UPDATE - - + End Sub + + 'DOCUMENTACION + 'LOS CAMPOS DE DATATABLE "ACCION" SE REFIERE AL ESTATUS DE LOS CAMBIOS QUE OCURRIERON ANTES DE DARLE GUARDAR + ' 0/NULL/VACIO = ORIGINAL (SIN CAMBIO) + ' 1 = AGREGADO + ' 2 = ELIMINADO + ' 3 = NADA (AGREGADO Y ELIMINADO): CUANDO AGREGA UN REGISTRO Y LO ELIMINA, ES DECIR, NO SE GUARDA NADA + ' 4 = UPDATE + + #Region " C A R G A R - D A T O S " Private Sub CargaDatos() @@ -527,10 +527,10 @@ Partial Class Sistemas_UsuarioDetalle CargarRol() CargaAsignaciones() - CargaUsuarioResponsable() - - ' ValidaAccesoEstatusOC() - + CargaUsuarioResponsable() + + ' ValidaAccesoEstatusOC() + End Sub Public Sub CargaUsuarioResponsable() @@ -587,7 +587,7 @@ Partial Class Sistemas_UsuarioDetalle LblFechaCaptura.Text = ObjUsuario.Fecha.ToShortDateString LblUsuarioCapturo.Text = ObjUsuario.UsuarioCreo - TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero + TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero TxtLimiteAutorizado.Text = ObjUsuario.DtResultados.Rows(0)("LimiteCreditoAutorizado").ToString() Else Alert("El Usuario Solicitado no existe, Revise su búsqueda.", TipoMensaje.MsgAdvertencia) @@ -759,23 +759,23 @@ Partial Class Sistemas_UsuarioDetalle If CveTipoDocumentoAsignado <> "-1" Then DdlTipoDocumento.SelectedValueExist(CveTipoDocumentoAsignado) UpFiltrosAsignarPermiso.Update() - End Sub + End Sub #End Region - - 'Private Sub CargaSucursal() - ' DtSubProyectos2 = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveSubProyecto =" & DdlSubProyectos.SelectedValue.ToEntero) - ' If DtSubProyectos2.Rows.Count > 0 Then - ' Dim dr As DataRow - ' dr = DtSubProyectos2(0) - ' CveSucursal = dr("CveSucursal").ToString.ToEntero - ' Else - ' CveSucursal = -1 - ' End If - - 'End Sub - + + 'Private Sub CargaSucursal() + ' DtSubProyectos2 = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveSubProyecto =" & DdlSubProyectos.SelectedValue.ToEntero) + ' If DtSubProyectos2.Rows.Count > 0 Then + ' Dim dr As DataRow + ' dr = DtSubProyectos2(0) + ' CveSucursal = dr("CveSucursal").ToString.ToEntero + ' Else + ' CveSucursal = -1 + ' End If + + 'End Sub + #Region " G U A R D A R - U P D A T E " - + Private Function ValidaUsername(Username As String, Correo As String) As Boolean Dim Retorno As Boolean = True 'If CveUsuario = -1 Then @@ -804,491 +804,490 @@ Partial Class Sistemas_UsuarioDetalle Dim TieneError = False Dim EsNuevoUsuario As Boolean = False - Try - 'Cargo la ultima empresa consultada en asignaciones - Dim DtValida = DtAsignacionesMultiEmpresa.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) - If DtValida.Rows.Count > 0 Then - Dim dr = DtAsignacionesMultiEmpresa.Select(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) - dr(0)("CveEmpresa") = CveEmpresaAnterior - dr(0)("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - dr(0)("CveVendedor") = DdlVendedor.SelectedValue.ToEntero - dr(0)("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero - dr(0)("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero - dr(0)("CveTipoDocumento") = DdlTipoDocumento.SelectedValue - dr(0).AcceptChanges() - Else - Dim Row As DataRow = Nothing - Row = DtAsignacionesMultiEmpresa.NewRow() - Row("CveEmpresa") = CveEmpresaAnterior - Row("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - Row("CveVendedor") = DdlVendedor.SelectedValue.ToEntero - Row("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero - Row("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero - Row("CveTipoDocumento") = DdlTipoDocumento.SelectedValue - DtAsignacionesMultiEmpresa.Rows.Add(Row) - End If - - Dim CodigoAcceso As String = If(String.IsNullOrEmpty(TxtCodigoAcceso.Text.Trim), "-1", TxtCodigoAcceso.Text.Trim) - - 'REGISTRA O ACTUALIZA LOS DATOS GENERALES DEL USUARIO - If CveUsuario = -1 Then - CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) - EsNuevoUsuario = True - If CveUsuario = -1 Then - TieneError = True - End If - - For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows - If Not ObjUsuarios.AddUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveTipoDocumento").ToString, Row("CveEmpresa").ToString.ToEntero, CveUsuario) Then - TieneError = True - End If - Next - Else - If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) Then - TieneError = True - End If - - For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows - If Not ObjUsuarios.UpdateUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveEmpresa").ToString.ToEntero, Row("CveTipoDocumento").ToString, CveUsuario, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - TieneError = True - End If - Next - End If - - 'GUARDA ACCESO MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosAcceso.Rows - 'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol - If Row.DataKey("CveModuloAcceso") <> "" Then - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Else - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - - Next - End If - - 'GUARDA PERMISO MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosPermiso.Rows - - If Row.DataKey("CveProcesoAcceso") <> "" Then - 'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Else - 'permisos que el rol, no le está otorgando, y serán únicos para el usuario - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - - ''checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados - 'If Row.DataKey("CveProcesoAcceso") <> "" Then - ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked) Then - ' TieneError = True - ' Exit For - ' End If - 'Else - ' 'permisos que el rol, no le está otorgando, y serán únicos para el usuario - ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked) Then - ' TieneError = True - ' Exit For - ' End If - 'End If - - Next - End If - - - 'Agregar Indicadores - If Not TieneError Then - For Each Row As GridViewRow In GvIndicadores.Rows - - If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then - If Not Indicador.RemoveIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - - If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") = "" Then - If Row.FCCheckBox("chkIndicador").Checked Then - If Not Indicador.AddIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - - - 'GUARDA ACCESO EMPRESAS - If Not TieneError Then - For Each dr As DataRow In DtEmpresasUsuario.FiltraParametros("Accion IN (1,2)").Rows - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddUsuariosEmpresas(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveEmpresasAcceso(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA SUBPROYECTOS - If Not TieneError Then - For Each dr As DataRow In DtSubProyectos.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, dr("ViejoCveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA ESTATUS DE OC - If Not TieneError Then - If DTEstatusOC IsNot Nothing AndAlso DTEstatusOC.Rows.Count > 0 Then - For Each dr As DataRow In DTEstatusOC.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero, dr("ViejoCveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - End If - 'GUARDA CLASIFICACIONES - If Not TieneError Then - If DtClasificaciones IsNot Nothing AndAlso DtClasificaciones.Rows.Count > 0 Then - For Each dr As DataRow In DtClasificaciones.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - End If - - - - - 'GUARDA ALMACENES - If Not TieneError Then - For Each dr As DataRow In DtAlmacenes.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, dr("ViejoCveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - - End If - - - 'Guarda Estatus de Ordenes de Compra - If Not TieneError Then - GuardaEstatusProyectosREQ(ObjOC, TieneError) - GuardaEstatusProyectoOC(ObjOC, TieneError) - End If - - ''Guarda Estatus de Ordenes de Servicio - 'If Not TieneError Then - ' GuardaEstatusOS(ObjOS, TieneError) - 'End If - - - 'GUARDA CUENTAS BANCARIAS - If Not TieneError Then - For Each dr As DataRow In DtCuentasBancarias.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjBancos.AddBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjBancos.RemoveBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - - End If - - - 'GUARDAMOS RESTRICCIONES DE ACCESO - If Not TieneError Then - For Each dr As DataRow In DtRestricciones.FiltraParametros("Accion IN (1,2,4)").Rows - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoAdd(CveUsuario, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoRemove(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoUpdate(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Next - End If - ObjUsuarios.UsuariosRestriccioneXMacUpdate(CveUsuario) - 'CLONAR USUARIO - If Not TieneError Then - If EsNuevoUsuario Then - If Not ClonarUsuario(DdlUsuarioClonar.SelectedValue.ToEntero, ObjUsuarios) Then - TieneError = True - End If - End If - End If - - - - ''''''''''''''''''''''''GUARDA ASIGNAR'''''''''''''''''''''''' - - 'GUARDA ROLES - If Not TieneError Then - For Each dr As DataRow In DTRolesAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA ALMACENES - If Not TieneError Then - For Each dr As DataRow In DtAlmacenesAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA SUBPROYECTOS - If Not TieneError Then - For Each dr As DataRow In DtSubProyectosAsignar.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA CUENTAS BANCARIAS - If Not TieneError Then - For Each dr As DataRow In DtCuentasBancariasAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA PERMISOS - If Not TieneError Then - For Each Row As GridViewRow In GvPermisosAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemovePermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddPermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA INDICADORES - If Not TieneError Then - For Each Row As GridViewRow In GvIndicadoresAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA EMPRESAS - If Not TieneError Then - For Each Row As GridViewRow In GvEmpresasAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'ELIMINA YA AGREGADOS EMPRESAS - If Not TieneError Then - For Each dr As DataRow In DTEmpresasAsignar.FiltraParametros("TienePermiso IN (-2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, dr("CveEmpresa").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - Catch ex As Exception - TieneError = True - OnError("Ocurrió un error al guardar el usuario", ex) - End Try - - + Try + 'Cargo la ultima empresa consultada en asignaciones + Dim DtValida = DtAsignacionesMultiEmpresa.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) + If DtValida.Rows.Count > 0 Then + Dim dr = DtAsignacionesMultiEmpresa.Select(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) + dr(0)("CveEmpresa") = CveEmpresaAnterior + dr(0)("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + dr(0)("CveVendedor") = DdlVendedor.SelectedValue.ToEntero + dr(0)("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero + dr(0)("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero + dr(0)("CveTipoDocumento") = DdlTipoDocumento.SelectedValue + dr(0).AcceptChanges() + Else + Dim Row As DataRow = Nothing + Row = DtAsignacionesMultiEmpresa.NewRow() + Row("CveEmpresa") = CveEmpresaAnterior + Row("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + Row("CveVendedor") = DdlVendedor.SelectedValue.ToEntero + Row("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero + Row("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero + Row("CveTipoDocumento") = DdlTipoDocumento.SelectedValue + DtAsignacionesMultiEmpresa.Rows.Add(Row) + End If + + Dim CodigoAcceso As String = If(String.IsNullOrEmpty(TxtCodigoAcceso.Text.Trim), "-1", TxtCodigoAcceso.Text.Trim) + + 'REGISTRA O ACTUALIZA LOS DATOS GENERALES DEL USUARIO + If CveUsuario = -1 Then + CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) + EsNuevoUsuario = True + If CveUsuario = -1 Then + TieneError = True + End If + + For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows + If Not ObjUsuarios.AddUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveTipoDocumento").ToString, Row("CveEmpresa").ToString.ToEntero, CveUsuario) Then + TieneError = True + End If + Next + Else + If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) Then + TieneError = True + End If + + For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows + If Not ObjUsuarios.UpdateUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveEmpresa").ToString.ToEntero, Row("CveTipoDocumento").ToString, CveUsuario, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + TieneError = True + End If + Next + End If + + 'GUARDA ACCESO MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosAcceso.Rows + 'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol + If Row.DataKey("CveModuloAcceso") <> "" Then + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Else + If Row.DataKey("Permitir").Contiene("", "0") AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA PERMISO MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosPermiso.Rows + + If Row.DataKey("CveProcesoAcceso") <> "" Then + 'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Else + 'permisos que el rol, no le está otorgando, y serán únicos para el usuario + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + + ''checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados + 'If Row.DataKey("CveProcesoAcceso") <> "" Then + ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked) Then + ' TieneError = True + ' Exit For + ' End If + 'Else + ' 'permisos que el rol, no le está otorgando, y serán únicos para el usuario + ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked) Then + ' TieneError = True + ' Exit For + ' End If + 'End If + + Next + End If + + + 'Agregar Indicadores + If Not TieneError Then + For Each Row As GridViewRow In GvIndicadores.Rows + + If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then + If Not Indicador.RemoveIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + + If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") = "" Then + If Row.FCCheckBox("chkIndicador").Checked Then + If Not Indicador.AddIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + + + 'GUARDA ACCESO EMPRESAS + If Not TieneError Then + For Each dr As DataRow In DtEmpresasUsuario.FiltraParametros("Accion IN (1,2)").Rows + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddUsuariosEmpresas(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveEmpresasAcceso(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA SUBPROYECTOS + If Not TieneError Then + For Each dr As DataRow In DtSubProyectos.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, dr("ViejoCveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA ESTATUS DE OC + If Not TieneError Then + If DTEstatusOC IsNot Nothing AndAlso DTEstatusOC.Rows.Count > 0 Then + For Each dr As DataRow In DTEstatusOC.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero, dr("ViejoCveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + End If + 'GUARDA CLASIFICACIONES + If Not TieneError Then + If DtClasificaciones IsNot Nothing AndAlso DtClasificaciones.Rows.Count > 0 Then + For Each dr As DataRow In DtClasificaciones.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + End If + + + + + 'GUARDA ALMACENES + If Not TieneError Then + For Each dr As DataRow In DtAlmacenes.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, dr("ViejoCveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + + End If + + + 'Guarda Estatus de Ordenes de Compra + If Not TieneError Then + GuardaEstatusProyectosREQ(ObjOC, TieneError) + GuardaEstatusProyectoOC(ObjOC, TieneError) + End If + + ''Guarda Estatus de Ordenes de Servicio + 'If Not TieneError Then + ' GuardaEstatusOS(ObjOS, TieneError) + 'End If + + + 'GUARDA CUENTAS BANCARIAS + If Not TieneError Then + For Each dr As DataRow In DtCuentasBancarias.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjBancos.AddBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjBancos.RemoveBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + + End If + + + 'GUARDAMOS RESTRICCIONES DE ACCESO + If Not TieneError Then + For Each dr As DataRow In DtRestricciones.FiltraParametros("Accion IN (1,2,4)").Rows + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoAdd(CveUsuario, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoRemove(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoUpdate(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Next + End If + ObjUsuarios.UsuariosRestriccioneXMacUpdate(CveUsuario) + 'CLONAR USUARIO + If Not TieneError Then + If EsNuevoUsuario Then + If Not ClonarUsuario(DdlUsuarioClonar.SelectedValue.ToEntero, ObjUsuarios) Then + TieneError = True + End If + End If + End If + + + + ''''''''''''''''''''''''GUARDA ASIGNAR'''''''''''''''''''''''' + + 'GUARDA ROLES + If Not TieneError Then + For Each dr As DataRow In DTRolesAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA ALMACENES + If Not TieneError Then + For Each dr As DataRow In DtAlmacenesAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA SUBPROYECTOS + If Not TieneError Then + For Each dr As DataRow In DtSubProyectosAsignar.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA CUENTAS BANCARIAS + If Not TieneError Then + For Each dr As DataRow In DtCuentasBancariasAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA PERMISOS + If Not TieneError Then + For Each Row As GridViewRow In GvPermisosAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemovePermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddPermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA INDICADORES + If Not TieneError Then + For Each Row As GridViewRow In GvIndicadoresAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA EMPRESAS + If Not TieneError Then + For Each Row As GridViewRow In GvEmpresasAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'ELIMINA YA AGREGADOS EMPRESAS + If Not TieneError Then + For Each dr As DataRow In DTEmpresasAsignar.FiltraParametros("TienePermiso IN (-2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, dr("CveEmpresa").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + Catch ex As Exception + TieneError = True + OnError("Ocurrió un error al guardar el usuario", ex) + End Try + + If Not TieneError Then If EsNuevoUsuario Then EnviaCorreo() @@ -1302,11 +1301,11 @@ Partial Class Sistemas_UsuarioDetalle End If - ObjUsuarios.Dispose() - ObjSubProyectos.Dispose() - ObjOC.Dispose() - ObjOS.Dispose() - Indicador.Dispose() + ObjUsuarios.Dispose() + ObjSubProyectos.Dispose() + ObjOC.Dispose() + ObjOS.Dispose() + Indicador.Dispose() ObjBancos.Dispose() End Sub @@ -1331,26 +1330,26 @@ Partial Class Sistemas_UsuarioDetalle ' Application("GlobalDTProyectosUsuarios") = Nothing ' TieneError = True 'End If - End If - - 'RECARGA GLOBAL BANCOS - 'If ObjBancos.GetBancosCuentasUsuarios(-1) Then - GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing 'ObjBancos.DtResultados - ' End If - - 'RECARGA GLOBAL ESTATUS + End If + + 'RECARGA GLOBAL BANCOS + 'If ObjBancos.GetBancosCuentasUsuarios(-1) Then + GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing 'ObjBancos.DtResultados + ' End If + + 'RECARGA GLOBAL ESTATUS If ObjOC.GetEstatus() Then Application("GlobalDTOCEstatus") = ObjOC.DtResultados Else Application("GlobalDTOCEstatus") = Nothing - GlobalDTOCEstatusUsuarios(UsuarioActual.CveEmpresa) = Nothing - - 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing - - - 'RECARGA GLOBAL ALMACEN - 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing - GlobalDTAlmacenUsuarios(-1, UsuarioActual.CveEmpresa) = Nothing - - 'RECARGA GLOBAL EMPRESAS USUARIOS + GlobalDTOCEstatusUsuarios(UsuarioActual.CveEmpresa) = Nothing + + 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing + + + 'RECARGA GLOBAL ALMACEN + 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing + GlobalDTAlmacenUsuarios(-1, UsuarioActual.CveEmpresa) = Nothing + + 'RECARGA GLOBAL EMPRESAS USUARIOS If ObjUsuarios.GetUsuariosEmpresas(-1) Then Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados Application("GlobalDTUsuarioResponsable") = ObjUsuarios.DtResultados.FiltraParametros("ProveedoresResponsables > 0") @@ -1409,10 +1408,10 @@ Partial Class Sistemas_UsuarioDetalle Catch ex As Exception OnError("Ocurrió error al mandar MAIL", ex) End Try - End Sub + End Sub #End Region - - + + #Region " E L I M I N A R - U S U A R I O " Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click ''DENTRO DEL PROCEDIMIENTO ELIMINA TODO LO RELACIONADO CON EL USUARIO (ALMACENES, SUBPROYECTOS, ACCESO A EMPRESAS...) @@ -1424,10 +1423,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Ocurrió un error al eliminar el usuario. Por favor vuelva a intentar", TipoMensaje.MsgError) End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region " CONTRASEÑA " Protected Sub LnkRestablecer_Click(sender As Object, e As EventArgs) Handles LnkRestablecer.Click Dim Usuario As New ClsSisUsuarios @@ -1441,15 +1440,15 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub LnkVerPass_Click(sender As Object, e As EventArgs) Handles LnkVerPass.Click Alert(Extensiones.Decripta(Password)) - End Sub + End Sub Protected Sub LnkVerCodigoAcceso_Click(sender As Object, e As EventArgs) Handles LnkVerCodigoAcceso.Click Alert(CodigoAcceso) - End Sub - - + End Sub + + #End Region - - + + #Region "TAB - ASIGNACIONES" Protected Sub DdlEmpresaAsignaciones_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaAsignaciones.SelectedIndexChanged @@ -1511,8 +1510,8 @@ Partial Class Sistemas_UsuarioDetalle DtAsignacionesMultiEmpresa.Columns.Add("CveSucursal", GetType(Integer)) DtAsignacionesMultiEmpresa.Columns.Add("CveAlmacen", GetType(Integer)) DtAsignacionesMultiEmpresa.Columns.Add("CveTipoDocumento", GetType(String)) - End Sub - + End Sub + #Region " PROYECTOS-SUBPROYECTOS " Private Sub CargaProyectos() DdlProyecto.Items.Clear() @@ -1585,11 +1584,11 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub CboProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged CargaSubProyectos(DdlProyecto.SelectedValue.ToEntero, DdlEmpresaAsignaciones.SelectedValue.ToEntero()) End Sub - Private Sub CargaSubProyectos(Optional CveProyectoFiltrado As Integer = -1, Optional CveEmpresaFiltro As Integer = -1) - + Private Sub CargaSubProyectos(Optional CveProyectoFiltrado As Integer = -1, Optional CveEmpresaFiltro As Integer = -1) + Dim CveEmpresaRef As Integer = UsuarioActual.CveEmpresa - If CveEmpresaFiltro > 0 Then - CveEmpresaRef = CveEmpresaFiltro + If CveEmpresaFiltro > 0 Then + CveEmpresaRef = CveEmpresaFiltro End If DdlSubProyecto.Items.Clear() @@ -1900,8 +1899,8 @@ Partial Class Sistemas_UsuarioDetalle End If End If ChkAsignarAllProyectos.Checked = False - End Sub - + End Sub + #Region "GV SUBPROYECTOS" Protected Sub GvSubProyectos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvSubProyectos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -2003,14 +2002,14 @@ Partial Class Sistemas_UsuarioDetalle GvSubProyectos.EditIndex = -1 CargaGvSubProyectos() - End Sub - + End Sub + #End Region - + #End Region - + #Region " ALMACENES " - + Private Function GetAlmacenesSinGV() As String Dim SB As New StringBuilder Dim prefix As String = "" @@ -2119,8 +2118,8 @@ Partial Class Sistemas_UsuarioDetalle Private Sub CargaGVAlmacen() GvAlmacenes.DataSource = DtAlmacenes.FiltraParametros(String.Format("CveEmpresa = {0} And (isnull(Accion,0) < 2 Or Accion = 4)", DdlEmpresaAsignaciones.SelectedValue.ToEntero)) GvAlmacenes.DataBind() - End Sub - + End Sub + #Region "GV ALMACENES" Protected Sub GvAlmacenes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAlmacenes.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -2207,11 +2206,11 @@ Partial Class Sistemas_UsuarioDetalle GvAlmacenes.EditIndex = -1 CargaGVAlmacen() - End Sub + End Sub #End Region - + #End Region - + #Region " CUENTAS BANCARIAS " Private Sub CargaCuentasBancarias() DdlCuentasBancarias.Items.Clear() @@ -2274,9 +2273,9 @@ Partial Class Sistemas_UsuarioDetalle DtCuentasBancarias.AcceptChanges() CargaGvCuentasBancarias() - End Sub + End Sub #End Region - + #Region " ESTATUS DE ÓRDENES DE COMPRA" Private Sub CargaEstatusOrdenesCompra() ' Exit Sub @@ -2470,20 +2469,20 @@ Partial Class Sistemas_UsuarioDetalle Else CargaGridEstatusUsuarioOC("OC") End If - End Sub + End Sub #Region "GRIDVIEW" - - Protected Sub GvEstatusUsuariosREQ_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosREQ.RowDataBound - If e.Row.RowType = DataControlRowType.Header Then - For i As Integer = 2 To GvEstatusUsuariosREQ.Columns.Count - 1 + + Protected Sub GvEstatusUsuariosREQ_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosREQ.RowDataBound + If e.Row.RowType = DataControlRowType.Header Then + For i As Integer = 2 To GvEstatusUsuariosREQ.Columns.Count - 1 Dim CveEstatus As Integer = GvEstatusUsuariosREQ.Columns(i).FooterText.ToEntero Dim idIndex As Integer = i - 1 - If CveEstatus > -1 Then - e.Row.FCLabel($"LblTituloEstatusREQ{idIndex}").Text = GvEstatusUsuariosREQ.Columns(i).HeaderText - End If - Next - End If - + If CveEstatus > -1 Then + e.Row.FCLabel($"LblTituloEstatusREQ{idIndex}").Text = GvEstatusUsuariosREQ.Columns(i).HeaderText + End If + Next + End If + If e.Row.RowType = DataControlRowType.DataRow Then Dim tmpT As DataTable = DTEstatusSubProyectos.FiltraParametros(String.Format("CveSubProyecto = {0}", e.Row.DBCampo("CveSubProyecto").ToString)) @@ -2610,18 +2609,18 @@ Partial Class Sistemas_UsuarioDetalle Next End If End Sub - Protected Sub GvEstatusUsuariosOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosOC.RowDataBound - - If e.Row.RowType = DataControlRowType.Header Then - For i As Integer = 2 To GvEstatusUsuariosOC.Columns.Count - 1 + Protected Sub GvEstatusUsuariosOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosOC.RowDataBound + + If e.Row.RowType = DataControlRowType.Header Then + For i As Integer = 2 To GvEstatusUsuariosOC.Columns.Count - 1 Dim CveEstatus As Integer = GvEstatusUsuariosOC.Columns(i).FooterText.ToEntero Dim idIndex As Integer = i - 1 - If CveEstatus > -1 Then - e.Row.FCLabel($"LblTituloEstatus{idIndex}").Text = GvEstatusUsuariosOC.Columns(i).HeaderText - End If - Next - End If - + If CveEstatus > -1 Then + e.Row.FCLabel($"LblTituloEstatus{idIndex}").Text = GvEstatusUsuariosOC.Columns(i).HeaderText + End If + Next + End If + If e.Row.RowType = DataControlRowType.DataRow Then Dim tmpT As DataTable = DTEstatusSubProyectos.FiltraParametros(String.Format("CveSubProyecto = {0}", e.Row.DBCampo("CveSubProyecto").ToString)) @@ -2634,7 +2633,7 @@ Partial Class Sistemas_UsuarioDetalle Dim ImgClasificaciones As LinkButton = e.Row.FCLinkButton($"ImgClasificaciones{idIndex}") Dim hdnCveEstatusUsuarios As HiddenField = e.Row.FCHiddenField($"hdnCveEstatusUsuarios{idIndex}") Dim lblSuperior As Label = e.Row.FCLabel($"lblSuperior{idIndex}") - Dim lblLimites As Label = e.Row.FCLabel($"lblLimites{idIndex}") + Dim lblLimites As Label = e.Row.FCLabel($"lblLimites{idIndex}") chkEstatus.CssClass = $"chkEstatus{idIndex}" Dim dtTemp As New DataTable @@ -2749,13 +2748,13 @@ Partial Class Sistemas_UsuarioDetalle End If Next End If - End Sub - - + End Sub + + #End Region - + #End Region - + #Region "ESTATUS DE ORDENES DE SERVICIO" Private Sub CargaEstatusOS() CreaGridEstatusOS() @@ -2908,9 +2907,9 @@ Partial Class Sistemas_UsuarioDetalle End If Next Next - End Sub + End Sub #End Region - + #Region " ESTATUS ORDENES DE COMPRA - CLASIFICACIONES USUARIO OC " Private Sub InicializaEstasClasificacionesOC() @@ -2972,15 +2971,15 @@ Partial Class Sistemas_UsuarioDetalle ObjOC.Dispose() CargaGVOCClasificaciones() - End Sub - - - + End Sub + + + #End Region - + #End Region - - + + #Region "TAB - ACCESO MODULOS" Public Sub CargaModulosAcceso() Dim ObjPermisos As New ClsSisUsuarios @@ -3066,10 +3065,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Los Permisos se eliminaron correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/Sistemas/Usuarios.aspx""") End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region "TAB - PERMISO MODULOS" Public Sub CargaModulosPermisos() Dim ObjProcesos As New ClsSisUsuarios @@ -3169,10 +3168,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Los Procesos se eliminaron correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/Sistemas/Usuarios.aspx""") End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region "TAB - ACCESO EMPRESAS" Private Sub CargaEmpresas() Dim ClsUsuarios As New ClsSisUsuarios @@ -3362,10 +3361,10 @@ Partial Class Sistemas_UsuarioDetalle Private Sub LnkRenviaCorreo_Click(sender As Object, e As EventArgs) Handles LnkRenviaCorreo.Click EnviaCorreo() Alert("Correo enviado con exito.", TipoMensaje.MsgInformacion) - End Sub + End Sub #End Region - - + + #Region "TAB - RESTRICCIONES ACCESO " Private Sub InicializaRestricciones() CargaDtRestricciones() @@ -3578,8 +3577,8 @@ Partial Class Sistemas_UsuarioDetalle CargaGvRestricciones() RegistraScript("$('#DivAgregarRestricción').modal('hide')") - End Sub - + End Sub + #Region " GV " Private Sub GvRestricciones_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvRestricciones.RowCommand @@ -3669,13 +3668,13 @@ Partial Class Sistemas_UsuarioDetalle End If CargaGvRestricciones() - End Sub + End Sub #End Region - - + + #End Region - - + + #Region "TAB - INDICADORES" Public Sub CargaGridIndicadores() Dim Objeto As New ClsIndicadores @@ -3692,11 +3691,11 @@ Partial Class Sistemas_UsuarioDetalle e.Row.FCCheckBox("chkIndicador").Checked = True End If End If - End Sub - + End Sub + #End Region - - + + #Region " CLONAR USUARIO " Private Sub InicializaClonarUsuario() DdlUsuarioClonar.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) @@ -3744,16 +3743,16 @@ Partial Class Sistemas_UsuarioDetalle End If - ObjUsuarios.Dispose() - - LblClonarMensaje.Text = $"En el usuario {TxtUsuario.Text} se reemplazará la información del usuario {DdlUsuarioClonar.SelectedItem.Text} con las siguientes secciones que seleccione." + ObjUsuarios.Dispose() + + LblClonarMensaje.Text = $"En el usuario {TxtUsuario.Text} se reemplazará la información del usuario {DdlUsuarioClonar.SelectedItem.Text} con las siguientes secciones que seleccione." Else LblClonarMensaje.Text = "" - End If - - - - + End If + + + + UpClonarUsuario.Update() End Sub Protected Sub BtnClonar_Click(sender As Object, e As EventArgs) @@ -3782,12 +3781,12 @@ Partial Class Sistemas_UsuarioDetalle 'CargaDatos() Return Retorno - End Function - - + End Function + + #End Region - - + + #Region " MANDA CORREO " Private Sub MandaCorreo(Asunto As String, Para As String, Body As String) Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) @@ -3795,13 +3794,13 @@ Partial Class Sistemas_UsuarioDetalle Dim Mail As New ClsSisMail() 'Mail.MandaCorreo(ClsPaginas.EmpresaNotificaciones, Para, Asunto, "", "", Nothing, Body) Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - End Sub - - - + End Sub + + + #End Region - - + + #Region " ASIGNACIONES DE PERMISOS " Protected Sub DdlEmpresaAsignarPermiso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaAsignarPermiso.SelectedIndexChanged CargaAsignaciones() @@ -3825,8 +3824,8 @@ Partial Class Sistemas_UsuarioDetalle CargaDtEstatusOC() CargaGvEstatusOC() - End Sub - + End Sub + #Region " EMPRESAS " Public Sub CargaDTEmpresasAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -3885,10 +3884,10 @@ Partial Class Sistemas_UsuarioDetalle CargaAsignaciones() - End Sub - + End Sub + #End Region - + #Region " ROLES " Private Sub CargaDtRolesAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -3977,9 +3976,9 @@ Partial Class Sistemas_UsuarioDetalle DTRolesAsignar.AcceptChanges() CargaGVRolesAsignar() - End Sub + End Sub #End Region - + #Region " ALMACENES " Private Sub CargaDtAlmacenAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -4070,11 +4069,11 @@ Partial Class Sistemas_UsuarioDetalle DtAlmacenesAsignar.AcceptChanges() CargaGVAlmacenAsignar() - End Sub - - + End Sub + + #End Region - + #Region " PROYECTOS-SUBPROYECTOS " Private Sub CargaDtSubProyectosAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -4185,10 +4184,10 @@ Partial Class Sistemas_UsuarioDetalle DtSubProyectosAsignar.AcceptChanges() CargarGvSubProyectosAsignar() - End Sub - + End Sub + #End Region - + #Region " CUENTAS BANCARIAS " Private Sub CargaCuentasBancariasAsignar() DdlCuentasBancariasAsignar.Items.Clear() @@ -4273,9 +4272,9 @@ Partial Class Sistemas_UsuarioDetalle DtCuentasBancariasAsignar.AcceptChanges() CargaGvCuentasBancariasAsignar() - End Sub + End Sub #End Region - + #Region " MODULOS " Public Sub CargaDTModulosAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -4310,10 +4309,10 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub - + End Sub + #End Region - + #Region " PERMISOS " Public Sub CargaDTPermisosAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -4348,9 +4347,9 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub + End Sub #End Region - + #Region " INDICADORES " Public Sub CargaDTIndicadoresAsignar() Dim ObjIndicadores As New ClsSisUsuarios @@ -4378,13 +4377,13 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub + End Sub #End Region - - + + #End Region - - + + #Region " USUARIO CONTROLADO " Private Sub InicializaUsuarioControlado() Dim ClsUsuarios As New ClsSisUsuarios @@ -4434,12 +4433,12 @@ Partial Class Sistemas_UsuarioDetalle End If ClsUsuarios.Dispose() - End Sub + End Sub #End Region - - + + #Region "C O N T O L E S DE U S U A R I O S" - + #Region "ESTATUS DE ÓRDENES DE COMPRA" Private Sub CargaDtEstatusOCPermisos() Dim ClsUsuarios As New ClsSisUsuarios @@ -4560,10 +4559,10 @@ Partial Class Sistemas_UsuarioDetalle DTEstatusOC = dt DTEstatusOCAsignar = dt - End Sub + End Sub #End Region - - + + #Region "GV ESTATUS DE OC" Protected Sub GvEstatusOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusOC.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -4674,11 +4673,11 @@ Partial Class Sistemas_UsuarioDetalle GvEstatusUsuariosOC.Columns(i).Visible = (dtValida IsNot Nothing AndAlso dtValida.Rows.Count = 1) End If Next - End Sub - + End Sub + #End Region #End Region - + Protected Sub LnkAgregarClasificacion_Click(sender As Object, e As EventArgs) If DtClasificaciones IsNot Nothing Then Dim CveClasificacion As Integer = DdlClasificacion.SelectedValue.ToEntero @@ -4805,10 +4804,10 @@ Partial Class Sistemas_UsuarioDetalle - End Sub - + End Sub + #Region "USUARIO RESPONSABLE" - + Protected Sub BtnUpdateUsuarioResponsable_Click(sender As Object, e As EventArgs) Dim ObjUsuarios As New ClsSisUsuarios If ObjUsuarios.UpdateUsuarioResponsableMasivo(CveUsuario, DdlUsuarioResponsable.SelectedValue.ToEntero) Then @@ -4816,10 +4815,10 @@ Partial Class Sistemas_UsuarioDetalle RegistraScript("$('#DivUpdateUsuarioResponsable').modal('hide')") End If ObjUsuarios.Dispose() - End Sub - + End Sub + #End Region - + Protected Sub LnkAutorizarEquipo_Click(sender As Object, e As EventArgs) 'CveUsuario Dim AdsCodex As String = Encripta(String.Format("{0}_{1}_{2}", CveUsuario, DateTime.Now.Ticks, UsuarioActual.CveUsuario)) @@ -4833,63 +4832,63 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub BtnCerrarSession_Click(sender As Object, e As EventArgs) 'ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.CerrarSession, CveUsuario:=CveUsuario) - Dim objlist As List(Of ADSSession.ADSSessionObj) = DirectCast(ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.getListasession, CveUsuario:=CveUsuario), List(Of ADSSession.ADSSessionObj)) - - For Each user As ADSSession.ADSSessionObj In objlist - If CveUsuario = user.CveUsuario Then 'AndAlso (CveEmpresa = -1 OrElse CveEmpresa = user.CveEmpresa) Then - Dim taspsig As String = user.ASPSIG '"94C6AC57E8599390A4B7B8AB41FEABEF466D9B31120BE06D78110E66265F1ACC5616297BF3B88EDCEE71EBCFE35484308F62C8017EAC29FB3F0FB45CEC09E8F03DFBB4A4DD890D45755B7A30185C6D01F20AEFA74BE3A25FD12D536B20DCB8D9940A3D95" - Dim tsessionID As String = user.SessionID - Dim url = System.Configuration.ConfigurationManager.AppSettings("urlcerrarSession").ToString() - Dim cookie As String = String.Format("ASP.NET_SessionId={0};.ASPXSIG={1}", tsessionID, taspsig) - sendURL(url, cookie) - End If + Dim objlist As List(Of ADSSession.ADSSessionObj) = DirectCast(ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.getListasession, CveUsuario:=CveUsuario), List(Of ADSSession.ADSSessionObj)) + + For Each user As ADSSession.ADSSessionObj In objlist + If CveUsuario = user.CveUsuario Then 'AndAlso (CveEmpresa = -1 OrElse CveEmpresa = user.CveEmpresa) Then + Dim taspsig As String = user.ASPSIG '"94C6AC57E8599390A4B7B8AB41FEABEF466D9B31120BE06D78110E66265F1ACC5616297BF3B88EDCEE71EBCFE35484308F62C8017EAC29FB3F0FB45CEC09E8F03DFBB4A4DD890D45755B7A30185C6D01F20AEFA74BE3A25FD12D536B20DCB8D9940A3D95" + Dim tsessionID As String = user.SessionID + Dim url = System.Configuration.ConfigurationManager.AppSettings("urlcerrarSession").ToString() + Dim cookie As String = String.Format("ASP.NET_SessionId={0};.ASPXSIG={1}", tsessionID, taspsig) + sendURL(url, cookie) + End If Next Alert("Sessión Cerrada") - End Sub - - Private Shared Function sendURL(ByVal URL As String, ByVal Optional Cookie As String = "", ByVal Optional maxTimeMilliseconds As Integer = 120000) As String - Dim resultado As String = "" - - Try - - Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest) - request.Timeout = maxTimeMilliseconds - request.Method = "POST" - request.ContentType = "text/xml; charset=utf-8" - - If Not String.IsNullOrEmpty(Cookie) Then - request.Headers.Add("Cookie", Cookie) - End If - - Using stream As IO.Stream = request.GetRequestStream() - - Using stmw As IO.StreamWriter = New IO.StreamWriter(stream) - stmw.Write("") - End Using - End Using - - Using response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse) - Using sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream()) - - resultado = sr.ReadToEnd() - sr.Close() - End Using - - End Using - request = Nothing - Catch ex As Exception - 'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}") - End Try - - Return resultado - End Function - - Protected Sub LnkClonarUsuario_Click(sender As Object, e As EventArgs) - - RegistraScript("$('#DivClonar').modal('show');") - LblClonarMensaje.Text = "" - UpClonarUsuario.Update() - - End Sub - + End Sub + + Private Shared Function sendURL(ByVal URL As String, ByVal Optional Cookie As String = "", ByVal Optional maxTimeMilliseconds As Integer = 120000) As String + Dim resultado As String = "" + + Try + + Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest) + request.Timeout = maxTimeMilliseconds + request.Method = "POST" + request.ContentType = "text/xml; charset=utf-8" + + If Not String.IsNullOrEmpty(Cookie) Then + request.Headers.Add("Cookie", Cookie) + End If + + Using stream As IO.Stream = request.GetRequestStream() + + Using stmw As IO.StreamWriter = New IO.StreamWriter(stream) + stmw.Write("") + End Using + End Using + + Using response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse) + Using sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream()) + + resultado = sr.ReadToEnd() + sr.Close() + End Using + + End Using + request = Nothing + Catch ex As Exception + 'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}") + End Try + + Return resultado + End Function + + Protected Sub LnkClonarUsuario_Click(sender As Object, e As EventArgs) + + RegistraScript("$('#DivClonar').modal('show');") + LblClonarMensaje.Text = "" + UpClonarUsuario.Update() + + End Sub + End Class From 4f9eca412c900a1d1ec9396c94604168a81d3936 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 20 Dec 2021 11:39:55 -0700 Subject: [PATCH 4/6] =?UTF-8?q?mejora=20en=20validaci=C3=B3n=20de=20datos?= =?UTF-8?q?=20de=20traslados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inventarios/TraspasoAlmacen.aspx.vb | 44 +++++++++++++---------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 3f7215698..c4fab3d5a 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -204,29 +204,25 @@ Partial Class Inventarios_TraspasoAlmacen divEmitir.Visible = False End If - If UsuarioActual.CveEmpresa.Contiene(1, 119, 140, 2) Then - - If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then - ChkEmitirTimbrado.Checked = True - End If + If UsuarioActual.CveEmpresa.Contiene(1, 2, 119, 140) Then ChkEmitirCartaPorte.Visible = True End If CantidadTotal = 0 - CvePS = 0 - TipoSeccionAlmacen = 0 + CvePS = 0 + TipoSeccionAlmacen = 0 - If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then + If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then - TxtFecha.Enabled = False - ImgFecha.Visible = False + TxtFecha.Enabled = False + ImgFecha.Visible = False - TxtFechaRecepcion.Enabled = False - ImgFechaRecepcion.Visible = False + TxtFechaRecepcion.Enabled = False + ImgFechaRecepcion.Visible = False - End If + End If Else If ChkTransitorio.Checked Then @@ -731,19 +727,19 @@ Partial Class Inventarios_TraspasoAlmacen #Region " GUARDAR " Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - If ChkEmitirTimbrado.Checked Then + 'If ChkEmitirTimbrado.Checked Then - If DdlChofer.SelectedValue.ToEntero <= 0 Then - Alert("Debe de seleccionar un chofer") - Exit Sub - End If - If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then - Alert("Debe de seleccionar una unidad") - Exit Sub - End If + ' If DdlChofer.SelectedValue.ToEntero <= 0 Then + ' Alert("Debe de seleccionar un chofer") + ' Exit Sub + ' End If + ' If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then + ' Alert("Debe de seleccionar una unidad") + ' Exit Sub + ' End If - End If + 'End If 'VALIDA ALMACEN ORIGEN Y DESTINO If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then @@ -1156,7 +1152,7 @@ Partial Class Inventarios_TraspasoAlmacen Dim CveSubProyectoTimbre As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero Dim Fechallegada As DateTime = (TxtFechaLlegada.Text & " 23:59:59").ToDateTime - Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, Fechallegada, "T", 1, 1, 1) + Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, Fechallegada, "T", "", "", MinFecha, 1, 1, 1) If CveEntregaAlmacen > 0 Then CveTimbre = ObjGral.AddGralTimbre("Tra", CveSubProyectoTimbre, TxtFechaEntrega.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked) From 345dedb7822f93c27450d5781931466b2c3b685c Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 21 Dec 2021 19:14:16 -0700 Subject: [PATCH 5/6] =?UTF-8?q?BDH,=20Liga=20para=20cancelacion=20de=20rem?= =?UTF-8?q?isi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/Modelos.vb | 385 ++++++++++++++++++++++++-------------------- Ashx/SIGWeb.ashx | 48 +++++- 2 files changed, 257 insertions(+), 176 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index a23c7af68..436328d6c 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5080,202 +5080,203 @@ Namespace Modelos If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen Then 'REALIZA DEVOLUCION A LAS SALIDAS PENDIENTES - For Each RowMovimiento As DataRow In DtSalidas.Rows - Dim CveConceptoMovimiento As Integer = -1 - Dim CveAlmacenMovimiento As Integer = -1 + If ObjFactura.TipoDocto <> "Rem" Then + For Each RowMovimiento As DataRow In DtSalidas.Rows + Dim CveConceptoMovimiento As Integer = -1 + Dim CveAlmacenMovimiento As Integer = -1 - Dim CveMovimientoDevolucion As Integer = 0 - Dim Folio As Integer = 0 + Dim CveMovimientoDevolucion As Integer = 0 + Dim Folio As Integer = 0 - Select Case RowMovimiento("CveConcepto").ToString().ToEntero() - Case 3 - CveConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - Case 40 - CveConceptoMovimiento = 41 'DEVOLUCIÓN DEL CLIENTE DIRECTA - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - Case 18 - CveConceptoMovimiento = 3 'DEVOLUCIÓN DEL CLIENTE DIRECTA - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - ''SI TIENE REMISIONES RELACIONADAS - 'If DtRemisionesFacturadas.Rows.Count > 0 Then - ' Dim RowRemision As DataRow = DtExistencias.FiltroPrimero($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}") + Select Case RowMovimiento("CveConcepto").ToString().ToEntero() + Case 3 + CveConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + Case 40 + CveConceptoMovimiento = 41 'DEVOLUCIÓN DEL CLIENTE DIRECTA + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + Case 18 + CveConceptoMovimiento = 3 'DEVOLUCIÓN DEL CLIENTE DIRECTA + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + ''SI TIENE REMISIONES RELACIONADAS + 'If DtRemisionesFacturadas.Rows.Count > 0 Then + ' Dim RowRemision As DataRow = DtExistencias.FiltroPrimero($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}") - ' Dim CveRemision As Integer = RowRemision("CveRemision").ToString().ToEntero() + ' Dim CveRemision As Integer = RowRemision("CveRemision").ToString().ToEntero() - ' Dim CancelarRemision As Boolean = (ListaRemisionesCancelar IsNot Nothing) AndAlso (ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = CveRemision)) + ' Dim CancelarRemision As Boolean = (ListaRemisionesCancelar IsNot Nothing) AndAlso (ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = CveRemision)) - ' 'SI LA REMISION SE VA A CANCELAR DEBE REGRESAR AL ALMACEN GENERAL - ' If CancelarRemision Then - ' CveAlmacenDevolucion = RowRemision("CveAlmacenDevolucion").ToString().ToEntero() - ' Else - ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() - ' End If + ' 'SI LA REMISION SE VA A CANCELAR DEBE REGRESAR AL ALMACEN GENERAL + ' If CancelarRemision Then + ' CveAlmacenDevolucion = RowRemision("CveAlmacenDevolucion").ToString().ToEntero() + ' Else + ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() + ' End If - 'Else - ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() - 'End If - End Select + 'Else + ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() + 'End If + End Select - 'SI TIENE SALDO PENDIENTE POR DEVOLVER GENERA UN MOVIMIENTO DE DEVOLUCION - If ObjFactura.SaldoAlmacen <> 0 Then - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) - CveMovimientoDevolucion = ObjInventario.AddMovimiento(CveAlmacenMovimiento, CveConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1, Modulo:="Mod/CV1") - Folio = ObjInventario.Folio + 'SI TIENE SALDO PENDIENTE POR DEVOLVER GENERA UN MOVIMIENTO DE DEVOLUCION + If ObjFactura.SaldoAlmacen <> 0 Then + 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) + CveMovimientoDevolucion = ObjInventario.AddMovimiento(CveAlmacenMovimiento, CveConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1, Modulo:="Mod/CV1") + Folio = ObjInventario.Folio - If CveMovimientoDevolucion > 0 Then - For Each Dr As DataRow In DtExistencias.FiltraParametros($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}").Rows + If CveMovimientoDevolucion > 0 Then + For Each Dr As DataRow In DtExistencias.FiltraParametros($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}").Rows - Dim FechaCaducidad As Date = MinFecha - If Not String.IsNullOrEmpty(Dr("FechaCaducidad").ToString()) Then - If IsDate(Dr("FechaCaducidad")) Then - FechaCaducidad = Dr("FechaCaducidad").ToString().ToDate() + Dim FechaCaducidad As Date = MinFecha + If Not String.IsNullOrEmpty(Dr("FechaCaducidad").ToString()) Then + If IsDate(Dr("FechaCaducidad")) Then + FechaCaducidad = Dr("FechaCaducidad").ToString().ToDate() + End If + End If + + Dim CveVentaDetalleRemision As Integer = -1 + If CveConceptoMovimiento = 41 Then + CveVentaDetalleRemision = Dr("CveVentaDetalleRemision").ToString.ToEntero() + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoDevolucion, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, FechaCaducidad:=FechaCaducidad, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." + Exit For + End If + Next + Else + MensajeError = "Ocurrió un error al agregar el movimiento" + ErrorCancelar = True + End If + + 'GENERA PREPOLIZA DEL MOVIMIENTO DE DEVOLUCION + If Not ErrorCancelar Then + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + If ObjInventario.GetMovimientosDetalle(CveMovimientoDevolucion, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenMovimiento}").ToEntero + Dim IdCtaContable As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + + Dim Multiplicador As Decimal = -1D + If ObjFactura.TipoDocto = "Dev" Then + Multiplicador = 1D + End If + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then + Dim Fecha As Date = Now + Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero + Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString + Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + + Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Modelos/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + 'SE AGREGA MOVIMIENTO SEPARADO POR LA CUENTA DE VENTAS (ER) + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() + TotalCostoAcumulado += ValorInventario + + 'CUANDO ES EL ÚLTIMO MOVIMIENTO Y HAY DIFERENCIAS EN LOS IMPORTES + If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + + If Not ErrorCancelar Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, Multiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then + ErrorCancelar = True + End If + End If + + cont += 1 + Next + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, Multiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * TotalCosto) Then + ErrorCancelar = True + End If + + 'AUTOCONTA - EL MOVIMIENTO 1 ES EL DE VENTA + + Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" + + If UsuarioActual.CveEmpresa = 119 AndAlso ObjFactura.TipoDocto.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then + AutoConta = False + End If + + If AutoConta And Not ErrorCancelar Then + + If IdCtaContable > 0 Then + If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al contabilizar la prepoliza." + End If + Else + Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) + End If + + End If + + Else + ErrorCancelar = True + MensajeError = "Ocurrió un Error al ingresar las prepolizas" + End If End If End If + End If - Dim CveVentaDetalleRemision As Integer = -1 - If CveConceptoMovimiento = 41 Then - CveVentaDetalleRemision = Dr("CveVentaDetalleRemision").ToString.ToEntero() - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoDevolucion, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, FechaCaducidad:=FechaCaducidad, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then + 'AGREGA BITACORA A VENTA + If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen AndAlso CveMovimientoDevolucion > 0 Then + Dim MensajeBitacora = "Devuelta" + If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimientoDevolucion, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then + MensajeError = "Ocurrió un error al agregar la bitacora." ErrorCancelar = True - MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For + End If + End If + + Else + 'SI EXISTE UNA DEVOLUCION PREVIAMENTE HECHA UTILIZAR COMO REFERENCIA + If DtDevPrevias IsNot Nothing AndAlso DtDevPrevias.Rows.Count > 0 Then + CveMovimientoDevolucion = DtDevPrevias.FiltroPrimeroValor("CveMovimiento", $"CveConcepto = {CveConceptoMovimiento}").ToEntero() + End If + + End If + + + 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION + 'SI ES DEVOLUCION DEL CLIENTE DEBE REGRESAR A ENTREGA POR ADELANTADO + If Not ErrorCancelar AndAlso CveConceptoMovimiento = 18 AndAlso RevivirRemisiones Then + If Not GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimientoDevolucion, ObjVentas, ObjInventario, DtDevRem, ListaRemisionesCancelar) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión" + End If + End If + + If DtVirtuales IsNot Nothing Then + For Each RowVirtual As DataRow In DtVirtuales.Rows + 'REALIZA LA DEVOLUCION AL ALMACEN VIRTUAL + If Not ErrorCancelar AndAlso Not GeneraMovimientosVirtuales(CveVenta, CveMovimientoDevolucion, RowVirtual("CveMovimiento").ToString().ToEntero(), ObjInventario) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." End If Next - Else - MensajeError = "Ocurrió un error al agregar el movimiento" - ErrorCancelar = True End If - 'GENERA PREPOLIZA DEL MOVIMIENTO DE DEVOLUCION - If Not ErrorCancelar Then - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimientoDevolucion, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenMovimiento}").ToEntero - Dim IdCtaContable As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - - Dim Multiplicador As Decimal = -1D - If ObjFactura.TipoDocto = "Dev" Then - Multiplicador = 1D - End If - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then - Dim Fecha As Date = Now - Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero - Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString - Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString - Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - - Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Modelos/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - 'SE AGREGA MOVIMIENTO SEPARADO POR LA CUENTA DE VENTAS (ER) - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() - TotalCostoAcumulado += ValorInventario - - 'CUANDO ES EL ÚLTIMO MOVIMIENTO Y HAY DIFERENCIAS EN LOS IMPORTES - If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then - ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) - End If - - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - - If Not ErrorCancelar Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, Multiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then - ErrorCancelar = True - End If - End If - - cont += 1 - Next - - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, Multiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * TotalCosto) Then - ErrorCancelar = True - End If - - 'AUTOCONTA - EL MOVIMIENTO 1 ES EL DE VENTA - - Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - - If UsuarioActual.CveEmpresa = 119 AndAlso ObjFactura.TipoDocto.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then - AutoConta = False - End If - - If AutoConta And Not ErrorCancelar Then - - If IdCtaContable > 0 Then - If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al contabilizar la prepoliza." - End If - Else - Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) - End If - - End If - - Else - ErrorCancelar = True - MensajeError = "Ocurrió un Error al ingresar las prepolizas" - End If - End If - End If + If ErrorCancelar Then + Exit For End If - 'AGREGA BITACORA A VENTA - If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen AndAlso CveMovimientoDevolucion > 0 Then - Dim MensajeBitacora = "Devuelta" - If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimientoDevolucion, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then - MensajeError = "Ocurrió un error al agregar la bitacora." - ErrorCancelar = True - End If - End If - - Else - 'SI EXISTE UNA DEVOLUCION PREVIAMENTE HECHA UTILIZAR COMO REFERENCIA - If DtDevPrevias IsNot Nothing AndAlso DtDevPrevias.Rows.Count > 0 Then - CveMovimientoDevolucion = DtDevPrevias.FiltroPrimeroValor("CveMovimiento", $"CveConcepto = {CveConceptoMovimiento}").ToEntero() - End If - - End If - - - 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION - 'SI ES DEVOLUCION DEL CLIENTE DEBE REGRESAR A ENTREGA POR ADELANTADO - If Not ErrorCancelar AndAlso CveConceptoMovimiento = 18 AndAlso RevivirRemisiones Then - If Not GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimientoDevolucion, ObjVentas, ObjInventario, DtDevRem, ListaRemisionesCancelar) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión" - End If - End If - - If DtVirtuales IsNot Nothing Then - For Each RowVirtual As DataRow In DtVirtuales.Rows - 'REALIZA LA DEVOLUCION AL ALMACEN VIRTUAL - If Not ErrorCancelar AndAlso Not GeneraMovimientosVirtuales(CveVenta, CveMovimientoDevolucion, RowVirtual("CveMovimiento").ToString().ToEntero(), ObjInventario) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." - End If - Next - End If - - If ErrorCancelar Then - Exit For - End If - - Next - + Next + End If 'SI EXISTEN HAY EXISTENCIA EN (ENTREGA POR ADELANTADO) SE TIENE QUE REGRESAR AL ALMACEN ORGINAL (GENERAL,SIN COSTO) - If Not ErrorCancelar AndAlso ListaRemisionesCancelar IsNot Nothing AndAlso ListaRemisionesCancelar.Count > 0 Then + If Not ErrorCancelar AndAlso ObjFactura.TipoDocto <> "Rem" AndAlso ListaRemisionesCancelar IsNot Nothing AndAlso ListaRemisionesCancelar.Count > 0 Then 'VERIFICA LOS MOVIMIENTOS DE DEVOLUCION YA GENERADOS QUE TENGAN EXISTENCIA EN (ENTREGA POR ADELANTADO) If Not ErrorCancelar Then @@ -5314,6 +5315,40 @@ Namespace Modelos End If + 'CANCELACION DE MOVIMIENTOS DE REMISION + If Not ErrorCancelar AndAlso ObjFactura.TipoDocto = "Rem" AndAlso RealizarDevolucionAlmacen Then + Dim CveAlmacenGeneral As Integer = 0 + Dim DtMovRemision As DataTable = Nothing + 'VERIFICA LOS MOVIMIENTOS DE DEVOLUCION YA GENERADOS QUE TENGAN EXISTENCIA EN (ENTREGA POR ADELANTADO) + If Not ErrorCancelar Then + If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + DtMovRemision = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 10") + CveAlmacenGeneral = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen", "CveTipoAlmacen = 1").ToString().ToEntero() + Else + ErrorCancelar = True + MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." + End If + End If + + 'DEBE REGRESAR LA EXISTENCIA DE (ENTREGA POR ADELANTADO) AL ALMACEN ORGINAL (GENERAL,SIN COSTO) + If Not ErrorCancelar AndAlso DtMovRemision IsNot Nothing AndAlso DtMovRemision.Rows.Count > 0 Then + + Dim DtDevMovs = DtMovRemision.FiltraParametros("", DistinctColumns:={"CveMovimiento", "CveAlmacen"}) + + For Each RowDevolucion As DataRow In DtDevMovs.Rows + CveAlmacen = RowDevolucion("CveAlmacen").ToString().ToEntero() + + If Not CancelarMovimientosRemision(CveVenta, CveAlmacen, CveAlmacenGeneral, DtMovRemision.FiltraParametros($"CveMovimiento={RowDevolucion("CveMovimiento")} AND CvePS > 0"), ObjVentas, ObjInventario) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al cancelar los movimientos de la remisión." + Exit For + End If + Next + + End If + + End If + 'VERIFICAR MOVIMIENTOS DE APARTADOS If Not ErrorCancelar Then If Not GeneraMovimientosApartados(ObjInventario) Then diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 4c8ad31ac..abe9f9840 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -116,7 +116,10 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Case "sendMailLPM" context.Response.Write(sendMailLPM(context)) Case "getSATColomias" - getSatColonias(context) + getSATColonias(context) + + Case "cancelarRemision" + cancelarRemision(context) End Select Catch ex As Exception ex.GuardaLog(ex.Message) @@ -1422,4 +1425,47 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Return retorno End Function #End Region + +#Region "Get SAT Colonmias" + Private Function cancelarRemision(ByVal context As HttpContext) As String + Dim retorno As String = "" + + Dim CveVenta As Integer = IfNull(context.Request("CveVenta"), "-1").ToString().ToEntero() + + If CveVenta > 0 Then + Dim usuario As Usuario = UsuarioActual(context) + If usuario IsNot Nothing AndAlso usuario.CveEmpresa > 0 Then + Dim CveAlmacenDevolucion As Integer = 0 + + Using ObjInv As New ClsInventarios + If ObjInv.GetInv_Mov(CveVenta, usuario.CveEmpresa) Then + If ObjInv.DtResultados.Rows.Count > 0 Then + CveAlmacenDevolucion = ObjInv.DtResultados.FiltroPrimeroValor("CveAlmacen", "CveConcepto IN (3,40)").ToEntero() + End If + End If + End Using + + Dim ObjFacturaCancelacion As New Modelos.Factura(usuario, CveVenta, usuario.CveEmpresa, EsCancelacion:=True) + ObjFacturaCancelacion.CveAlmacenDevolucion = CveAlmacenDevolucion + + If ObjFacturaCancelacion.TipoDocto = "Rem" Then + Dim respuesta = ObjFacturaCancelacion.CancelarFactura(True, New List(Of Integer)) + If respuesta IsNot Nothing Then + retorno = JsonConvert.SerializeObject(respuesta) + End If + End If + + End If + + End If + + If Not String.IsNullOrEmpty(retorno) Then + context.Response.Write(retorno) + Else + context.Response.Write("[]") + End If + + Return retorno + End Function +#End Region End Class \ No newline at end of file From 26752b51e37b5ed8bc69c97e71e16a132ec7fe38 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 21 Dec 2021 19:16:12 -0700 Subject: [PATCH 6/6] E119. Fluctuacion cambiaria mensual --- App_Code/ClsContabilidad.vb | 41 + App_Code/ClsGenerales.vb | 22 +- App_Code/ClsMovimientos.vb | 5 +- App_Code/ClsPaginas.vb | 41 + Bancos/FluctuacionCambiaria.aspx | 1137 ++++++++++++++------------- Bancos/FluctuacionCambiaria.aspx.vb | 154 ++-- Bancos/PopIECompras.aspx.vb | 63 +- Bancos/PopIEVentas.aspx.vb | 30 +- Bancos/ProveedoresAbonar.aspx.vb | 29 +- Compras/RepCxP.aspx | 12 +- Compras/RepCxP.aspx.vb | 2 +- CxC/RepCxC.aspx | 13 +- CxC/RepCxC.aspx.vb | 2 +- Ventas/ClientesAbonar.aspx.vb | 62 +- Ventas/Ventas.aspx.vb | 96 ++- 15 files changed, 996 insertions(+), 713 deletions(-) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index ab161ebc8..9f6902b8d 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -6543,6 +6543,47 @@ Public Class ClsContabilidad Return Retorno End Function +#Region "F L U C T U A C I O N - C A M B I A R I A" + Public Function UpdateVentaTCValuacion(CveVenta As Integer, TCValuacion As Decimal) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_VentasTCValuacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar el tipo de cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateCompraTCValuacion(CveCompra As Integer, TCValuacion As Decimal) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ComprasTCValuacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar el tipo de cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region #Region "IDisposable Support" ' IDisposable diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index fea44cef7..005780993 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -1734,7 +1734,7 @@ Public Class ClsGenerales Return Retorno - End Function + End Function Public Function GetTipoCambio(CveTipoCambio As Integer, Fecha As Date) As Boolean Dim Retorno = False @@ -1754,6 +1754,26 @@ Public Class ClsGenerales Return Retorno End Function + Public Function GetTipoCambioUltimaFluctuacion(CveTipoCambio As Integer, Fecha As Date, Optional Top As Integer = 1000) As Boolean + Dim Retorno = False + + DataAdapter("PA_Gral_TipoCambioUltimaFluctuacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoCambio", SqlDbType.Int).Value = CveTipoCambio + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Top", SqlDbType.Int).Value = Top + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Tipo de Cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function Public Function GetTiposCambio(FechaInicio As Date, FechaFin As Date) As Boolean Dim Retorno = False diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index c0ab586d4..50259e4c7 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -241,7 +241,7 @@ Public Class ClsMovimientos Gpo As Integer, CveResponsable As Integer, TipoCambio As Integer, Optional TCEspecifico As Double = -1, Optional TipoDocto As String = "-1", Optional FechaVI As String = "-1", Optional FechaVF As String = "-1", Optional FechaCorte As Date = Nothing, Optional EstatusCliente As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveCobranzaEstatus As Integer = -1, Optional CveClienteClasificacion As Integer = -1, Optional TipoCliente As Integer = -1, Optional AplicaAnticiposPagados As Integer = 1) As Boolean + Optional CveCobranzaEstatus As Integer = -1, Optional CveClienteClasificacion As Integer = -1, Optional TipoCliente As Integer = -1, Optional AplicaAnticiposPagados As Integer = 1, Optional CveMoneda As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -274,7 +274,8 @@ Public Class ClsMovimientos .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion .Add("@TipoCliente", SqlDbType.Int).Value = TipoCliente - .Add("@AplicaAnticiposPagados", SqlDbType.Int).Value = AplicaAnticiposPagados + .Add("@AplicaAnticiposPagados", SqlDbType.Int).Value = AplicaAnticiposPagados + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda End With Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 7ff070146..48f1a2e9f 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -127,6 +127,47 @@ Public Class ClsPaginas End Set End Property + Public ReadOnly Property GlobalTipoCambioUltimaFluctuacion(Optional Fecha As Date = MinFecha) As MTipoCambioFluctuacion + Get + + If Application("GlobalTipoCambioUltimaFluctuacion") Is Nothing Then + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambioUltimaFluctuacion(-1, Now) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + Application("GlobalTipoCambioUltimaFluctuacion") = ObjGral.DtResultados.Copy() + Else + Application("GlobalTipoCambioUltimaFluctuacion") = Nothing + End If + ObjGral.Dispose() + End If + + Dim fluctuacion = New MTipoCambioFluctuacion() With { + .TCFluctuacion = 0, + .FechaFluctuacion = MinFecha + } + + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + If Application("GlobalTipoCambioUltimaFluctuacion") IsNot Nothing Then + + Dim dr = DirectCast(Application("GlobalTipoCambioUltimaFluctuacion"), DataTable).FiltroPrimero(String.Format("Fecha = '{0}'", Fecha)) + If dr IsNot Nothing Then + fluctuacion.TCFluctuacion = dr("TCFluctuacion").ToString().ToDecimal() + fluctuacion.FechaFluctuacion = dr("FechaFluctuacion").ToString().ToDateTime() + End If + + Return fluctuacion + Else + Return fluctuacion + End If + + End Get + End Property + + Public Class MTipoCambioFluctuacion + Public Property TCFluctuacion As Decimal + Public Property FechaFluctuacion As DateTime + End Class Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double Get If GlobalTipoCambioEuro <= 0 Then diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index 93673c3d1..19dc04717 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -1,593 +1,600 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FluctuacionCambiaria.aspx.vb" Inherits="Bancos_FluctuacionCambiaria" %> - - - - - - - - - - Fluctuación Cambiaria - - - - - - -
    -
    -
    - - -
    -
    - -
    -
    - - - - -
    - - - - - - -
    -
    -
    TC:
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - - - - - - - -
    -
    -
    -

    PÉRDIDA

    -
    - -
    - MXN - - - -
    -
    -
    -
    -
    -
    -

    GANANCIA

    -
    - -
    -
    -
    - MXN - - - -
    -
    -
    -
    -
    -
    -
    -
    -

    -
    - -
    -
    -
    - MXN - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FluctuacionCambiaria.aspx.vb" Inherits="Bancos_FluctuacionCambiaria" %> + + + + + + + + + + Fluctuación Cambiaria + + + + + + +
    +
    +
    + + +
    +
    + +
    + + +
    + +
    + + +
    +
    +
    TC:
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + +
    +
    +
    +

    PÉRDIDA

    +
    + +
    + MXN + + + +
    +
    +
    +
    +
    +
    +

    GANANCIA

    +
    + +
    +
    +
    + MXN + + + +
    +
    +
    +
    +
    +
    +
    +
    +

    +

    +
    + +
    +
    +
    + MXN + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    - +
    - - - - -
    - -
    - - - - - -
    - -
    - + + + +
    -
    - - - - -
    - - - - - - - - - - - <%----%> -
    -
    - - - - -
    -
    -
    -

    PÉRDIDA

    -
    - -
    - MXN - - - -
    -
    -
    -
    -
    -
    -

    GANANCIA

    -
    - -
    -
    -
    - MXN - - - -
    -
    -
    -
    -
    -
    -
    -
    -

    -
    - -
    -
    -
    - MXN - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -
    +
    + + + + + +
    + +
    + +
    + + + + + + +
    + + + + + + + + + + + <%----%> +
    +
    + + + + +
    +
    +
    +

    PÉRDIDA

    +
    + +
    + MXN + + + +
    +
    +
    +
    +
    +
    +

    GANANCIA

    +
    + +
    +
    +
    + MXN + + + +
    +
    +
    +
    +
    +
    +
    +
    +

    +

    +
    + +
    +
    +
    + MXN + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    -
    - - - - -
    - -
    - - - - - -
    - - - -
    - +
    + + + +
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    +
    + + + + + +
    + + + +
    + +
    + +
    + +
    + + + + + + + + + + + + + + + + +
    +
    + + + +
    -
    - - - - -
    - -
    - - - - - -
    - - - -
    - +
    + + + +
    -
    - - - -
    - + + + + + +
    + + + +
    + +
    + + + + + +
    + - - - - - - - - - - - - - - -
    -
    - - - - - - - -
    + Banco,NumCuenta,CveCuentaComplementaria,Saldo" + EmptyDataText="No se Encontraron Cuentas Bancarias." ToolTip="Listado de Cuentas Bancarias" + CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None"> + + + + + + + + + + + + + + +
    +
    + + + + + + + +
    -
    - - - - -
    +
    + + + + +
    -
    - +
    + - - - -
    + + + +
    -
    - +
    +
    - -
    - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - -
    +
    -
    - + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + + + + +
    + +
    + - - - -
    - - - -
    - -
    -
    -
    - - - - - - - - - - - - - -
    -
    - - - -
    -
    - -
    - - - - -
    - -
    - - - - - -
    + + + +
    -
    - -
    -
    - -
    - - -
    - -
    - - - - - - - - - - - - - - - - - - - - - + +
    + +
    +
    +
    + + + + + + + + + + + + + +
    +
    + + + +
    +
    + +
    + + + + +
    + +
    + + + + + +
    + + +
    + +
    +
    + +
    + + +
    +
    + + + + + + + + + + + + + +
    +
    + + + + + + diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index bbc74193e..720450601 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -2,10 +2,18 @@ Option Strict On Imports System.Data +Imports System.Globalization Imports Extensiones Partial Class Bancos_FluctuacionCambiaria Inherits ClsPaginas + + Public ReadOnly Property FechaUltimoDiaMes() As DateTime + Get + Return New DateTime(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero(), 1).AddMonths(1).AddDays(-1) + End Get + End Property + #Region "PROPIEDADES" Private Property LblTotal() As String Get @@ -19,7 +27,7 @@ Partial Class Bancos_FluctuacionCambiaria Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then - + CargaFechas() CargarCentrosDeCosto(Nothing, DdlSubproyectoBancos, Nothing, LblSubProyectoBancos, "") CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "") CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "") @@ -32,6 +40,27 @@ Partial Class Bancos_FluctuacionCambiaria End Sub #Region "CARGAS" + Private Sub CargaFechas() + 'Año actual + DdlAnio.Items.Add(New ListItem(Now.Year.ToString(), Now.Year.ToString())) + 'Año Anterior + DdlAnio.Items.Add(New ListItem(Now.AddYears(-1).Year.ToString(), Now.AddYears(1).Year.ToString())) + + For i = 1 To 12 + Dim fecha = New DateTime(DdlAnio.SelectedValue.ToEntero(), i, 1) + Dim mes = fecha.ToString("MMMM", CultureInfo.GetCultureInfo("es-MX")) + Dim mesStr = Char.ToUpper(mes(0)) + mes.Substring(1) + + DdlMes.Items.Add(New ListItem(mesStr, i.ToString())) + Next + + Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now) + If UltimaFluctuacion IsNot Nothing Then + DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Month) + DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Year) + End If + + End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click CargaTipoCambio() @@ -47,36 +76,52 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaTipoCambio() Dim ObjGenerales As New ClsGenerales - ObjGenerales.GetTipoCambio(-1, TxtFecha.Text.ToDate) + ObjGenerales.GetTipoCambio(-1, FechaUltimoDiaMes) If ObjGenerales.DtResultados.Rows.Count > 0 Then LtTipoCambioActual.Text = ObjGenerales.DtResultados.Rows(0)("TipoCambio").ToString - TxtConceptoFluctuacion.Text = "Fluctuación a " & TxtFecha.Text + TxtConceptoFluctuacion.Text = "Fluctuación a " & FechaUltimoDiaMes.ToShortDateString() End If ObjGenerales.Dispose() End Sub Private Sub CargaUltimaFluctuacion() - Dim Obj As New ClsBancos - If Obj.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - Dim dt As DataTable = Obj.DtResultados.FiltraParametros("TipoFluctuacion = 1", "Fecha DESC") - If dt.Rows.Count > 0 Then - LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", dt.Rows(0)("Fecha").ToString.ToDate.ToShortDateString) - 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual - If dt.Rows(0)("Fecha").ToString.ToDate >= Now.AddMonths(-1).LastDayOfMonth Then - TxtFecha.Text = Now.ToShortDateString - Else - TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() - End If - End If + 'Dim Obj As New ClsBancos + 'If Obj.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' Dim dt As DataTable = Obj.DtResultados.FiltraParametros("TipoFluctuacion = 1", "Fecha DESC") + ' If dt.Rows.Count > 0 Then + ' LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", dt.Rows(0)("Fecha").ToString.ToDate.ToShortDateString) + ' 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual + ' If dt.Rows(0)("Fecha").ToString.ToDate >= Now.AddMonths(-1).LastDayOfMonth Then + ' TxtFecha.Text = Now.ToShortDateString + ' Else + ' TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() + ' End If + ' End If + 'End If + 'Obj.Dispose() + + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now) + + If UltimaFluctuacion IsNot Nothing Then + LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", UltimaFluctuacion.FechaFluctuacion.ToShortDateString) + 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual + If UltimaFluctuacion.FechaFluctuacion >= Now.AddMonths(-1).LastDayOfMonth Then + DdlMes.SelectedValueExist(Now.Month) + DdlAnio.SelectedValueExist(Now.Year) + Else + DdlMes.SelectedValueExist(Now.AddMonths(-1).Month) + DdlAnio.SelectedValueExist(Now.AddMonths(-1).Year) + 'TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() + End If End If - Obj.Dispose() + CargaTipoCambio() End Sub Private Sub CargaDatosCompra() Dim ObjBancos As New ClsBancos 'LblTotalCompras.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 1, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 1, UsuarioActual.CveEmpresa) Then GvCompras.DataSource = ObjBancos.DtResultados 'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ") @@ -110,7 +155,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosVentas() Dim ObjBancos As New ClsBancos LblTotalVentas.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 2, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 2, UsuarioActual.CveEmpresa) Then GvVentas.DataSource = ObjBancos.DtResultados Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0") @@ -142,7 +187,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosCuentas() Dim ObjBancos As New ClsBancos LblTotalBancos.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 4, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 4, UsuarioActual.CveEmpresa) Then Dim DtTemp As DataTable = ObjBancos.DtResultados.Copy Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Dim TotAcumulado As Decimal = 0 @@ -151,7 +196,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim CveCuentaExtranjera As Integer = Dr("CveCuentaExtranjera").ToString.ToEntero If CveCuentaExtranjera > 0 Then - If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaExtranjera, MinFecha, TxtFecha.Text.ToDate, 2, "-1", UsuarioActual.CveEmpresa, "1") Then + If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaExtranjera, MinFecha, FechaUltimoDiaMes, 2, "-1", UsuarioActual.CveEmpresa, "1") Then If Conta.DtResultados.Rows.Count > 1 Then Total = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal End If @@ -162,7 +207,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim SaldoActualContabilidad As Decimal = 0 Dim CveCuentaComplementaria As Integer = Dr("CveCuentaComplementaria").ToString.ToEntero If CveCuentaComplementaria > 0 Then - If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, MinFecha, TxtFecha.Text.ToDate, 2, "-1", UsuarioActual.CveEmpresa, "1") Then + If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, MinFecha, FechaUltimoDiaMes, 2, "-1", UsuarioActual.CveEmpresa, "1") Then If Conta.DtResultados.Rows.Count > 1 Then SaldoActualContabilidad = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal End If @@ -189,7 +234,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosDeudores() Dim ObjBancos As New ClsBancos LblTotalDeudores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 5, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 5, UsuarioActual.CveEmpresa) Then GvDeudores.DataSource = ObjBancos.DtResultados LblTotalDeudores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -203,7 +248,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosAcreedores() Dim ObjBancos As New ClsBancos LblTotalAcreedores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 6, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then GvAcreedores.DataSource = ObjBancos.DtResultados LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -217,7 +262,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosFiliales() Dim ObjBancos As New ClsBancos LblTotalAcreedores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 7, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 7, UsuarioActual.CveEmpresa) Then GvFiliales.DataSource = ObjBancos.DtResultados.FiltraParametros("Saldo > 0") LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -237,15 +282,17 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim idCta As Integer = 0 - Dim CveCuenta As Integer = 0 + Dim CveCuentaPerdida, CveCuentaGanancia As Integer Dim idCtaPerdida, IdCtaGanancia As Integer + Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 - Dim CveCuentaComplementaria As Integer = 55175 - Dim IdCtaComplementaria As Integer = 1248 + Dim IdCtaComplementaria As Integer = 0 + Dim ErrorRegistrar As Boolean = False CveCuentaPerdida = 0 '55379 @@ -257,19 +304,17 @@ Partial Class Bancos_FluctuacionCambiaria Total = LblTotal.ToDecimal If Total > 0 Then CveConceptoContable = 64 - CveCuenta = CveCuentaGanancia idCta = IdCtaGanancia TipoMovto = True Else CveConceptoContable = 65 - CveCuenta = CveCuentaPerdida idCta = idCtaPerdida TipoMovto = False End If + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() - - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -279,12 +324,18 @@ Partial Class Bancos_FluctuacionCambiaria Total = gvr.DataKey("Fluctuacion").ToDecimal 'si es pérdida o ganancia - + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 201, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 201, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total) Then ErrorRegistrar = True Exit For + End If + + If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then + ErrorRegistrar = True + Exit For End If + Next If Not ErrorRegistrar Then @@ -311,16 +362,18 @@ Partial Class Bancos_FluctuacionCambiaria Dim idCtaPerdida, IdCtaGanancia As Integer Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 - Dim CveCuentaComplementaria As Integer = 54141 - Dim IdCtaComplementaria As Integer = 70 + Dim IdCtaComplementaria As Integer = 0 Dim ErrorRegistrar As Boolean = False CveCuentaPerdida = 0 '55379 CveCuentaGanancia = 0 ' 55382 idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 - Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias - + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + '' + Total = LblTotalVentas.Text.ToDecimal If Total > 0 Then CveConceptoContable = 64 @@ -341,7 +394,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoVentas.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoVentas.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then ErrorRegistrar = True @@ -353,14 +406,21 @@ Partial Class Bancos_FluctuacionCambiaria For Each gvr As GridViewRow In GvVentas.Rows Total = -gvr.DataKey("Fluctuacion").ToDecimal + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() + If gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0 Then CveConconceptoCliente = 226 Else CveConconceptoCliente = 203 End If + If Not Conta.UpdateVentaTCValuacion(gvr.DataKey("CveVenta").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then + ErrorRegistrar = True + Exit For + End If + 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If @@ -395,9 +455,9 @@ Partial Class Bancos_FluctuacionCambiaria Dim CveConceptoContable As Integer = 0 Dim ErrorRegistrar As Boolean = False Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal - Dim MesTCtexto As String = String.Format("{0} TC:{1}", TxtFecha.Text.ToDate.ToString("MMMM-yyyy"), TCCierreFluctuacion) + Dim MesTCtexto As String = String.Format("{0} TC:{1}", FechaUltimoDiaMes.ToString("MMMM-yyyy"), TCCierreFluctuacion) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveCuentaPerdida = 0 ' 55379 @@ -477,7 +537,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaDD", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoDeudores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaDD", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoDeudores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -494,7 +554,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Total = LblTotalAcreedores.Text.ToDecimal - Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", TxtFecha.Text) + Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes) Dim CveConconceptoDeudores As Integer = 256 @@ -553,7 +613,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa) ObjContPaq.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -572,7 +632,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Total = LblTotalAcreedores.Text.ToDecimal - Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", TxtFecha.Text) + Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes) 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvFiliales.Rows @@ -646,7 +706,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 719648f77..2babcb0ea 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -637,7 +637,7 @@ Partial Class Bancos_PopIECompras CveMonedaCompra = dr("CveMoneda").ToString.ToEntero CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero SerieFolio = dr("SerieFolio").ToString - TipoCambioOriginal = dr("TipoCambio").ToString.ToDecimal + TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDecimal NombreProveedor = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor)) CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero @@ -1474,6 +1474,14 @@ Partial Class Bancos_PopIECompras Dim CveCuentaContabilizacion As Long = 1 Dim CuentasContablesInvalidasSIG As New StringBuilder + Dim FechaPago As Date = TxtFechaDocumento.Text.ToDate() + 'VERIFICA SI SE ESTA PAGANDO EN EL MISMO MES DE LA FACTURA + Dim PagoMismoMes As Boolean = True + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso (FechaDocumento < FechaPago) AndAlso ((FechaDocumento.Month < FechaPago.Month AndAlso FechaDocumento.Year = FechaPago.Year) OrElse (FechaDocumento.Year < FechaPago.Year)) Then + PagoMismoMes = False + End If + Dim TCUltimaFluctuacion As Decimal = 1 + 'Tipos de cambio segun metodo de pago If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos tipoCambioPago = 1 @@ -1491,6 +1499,13 @@ Partial Class Bancos_PopIECompras tipoCambioPago = TxtTipoCambio.Text.ToDecimal tipoCambioCompra = 1 PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total + End If + + Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(TxtFechaDocumento.Text.ToDate) + If UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < TxtFechaDocumento.Text.ToDate Then + TCUltimaFluctuacion = UltimaFluctuacion.TCFluctuacion + End If End If Select Case RBLContado.SelectedValue @@ -1569,17 +1584,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then @@ -1617,17 +1632,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then @@ -1640,14 +1655,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1664,13 +1679,13 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL @@ -1686,14 +1701,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1710,13 +1725,13 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL @@ -1731,14 +1746,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra = 2 Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1755,17 +1770,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If If CveMonedaCompra = 1 Then @@ -1773,7 +1788,7 @@ Partial Class Bancos_PopIECompras Else IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If ImporteMX = ImporteMovimiento @@ -2557,9 +2572,10 @@ Partial Class Bancos_PopIECompras IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) TimpocambioGeneral = TCImpuestos + Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago < tipoCambioCompra AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta + ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) 'Añadimos la diferencia de ganancia en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR @@ -2581,9 +2597,10 @@ Partial Class Bancos_PopIECompras If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago > tipoCambioCompra AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta + ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 87c387537..d3cd9ce9f 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -1496,20 +1496,30 @@ Partial Class Bancos_PopIEVentas Dim CuentasContablesInvalidasSIG As New StringBuilder Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.Text.ToDate - Dim strFecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & strFecha & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If - End If + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion + End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + + ' Dim strFecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & strFecha & "#", "Fecha DESC") + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + ' End If + 'End If If CveMoneda = 1 AndAlso CveMonedaVenta = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos tipoCambioPago = 1 diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 468b3e084..3f30f6b29 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -924,20 +924,31 @@ Partial Class Bancos_ProveedoresAbonar Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.Text.ToDate - Dim FechaC As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & FechaC & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + ' Dim FechaC As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & FechaC & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + + ' End If + 'End If + Dim DttPlantilla As DataTable = Nothing If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then diff --git a/Compras/RepCxP.aspx b/Compras/RepCxP.aspx index 07bd70a8c..666f8cd15 100644 --- a/Compras/RepCxP.aspx +++ b/Compras/RepCxP.aspx @@ -269,7 +269,17 @@
    - +
    + Moneda: +
    + +
    + + + + + +
    diff --git a/Compras/RepCxP.aspx.vb b/Compras/RepCxP.aspx.vb index f22fe1d7f..8ebbfe1d9 100644 --- a/Compras/RepCxP.aspx.vb +++ b/Compras/RepCxP.aspx.vb @@ -180,7 +180,7 @@ Partial Class Compras_RepCxP If txtFechaVF.Text = "" Then FechaVF = "-1" Dim TipoAgrupacion As Integer = IIf(chkAgruparMes.Checked, 1, -1) Dim TipoDocto As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM) - If Mov.GetCxP(FechaI, FechaF, DdlProveedor.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlProveedoresClasificaciones.SelectedValue.ToEntero, -1, DdlUsuarioResponsable.SelectedValue.ToEntero, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlEstatusCompra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, + If Mov.GetCxP(FechaI, FechaF, DdlProveedor.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlProveedoresClasificaciones.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero(), DdlUsuarioResponsable.SelectedValue.ToEntero, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlEstatusCompra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, FechaVI, FechaVF, FechaCorte:=txtCorteA.Text.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveTipoProveedor:=IIf(DdlTipoProveedor.SelectedValue.ToEntero = 3, -1, DdlTipoProveedor.SelectedValue.ToEntero), Comprobaciones:=DdlComprobacion.SelectedValue.ToEntero, TipoDocto:=TipoDocto, TipoAgrupacion:=TipoAgrupacion) Then GvCxP.DataSource = Mov.DtResultados diff --git a/CxC/RepCxC.aspx b/CxC/RepCxC.aspx index 374b50382..5baadfd42 100644 --- a/CxC/RepCxC.aspx +++ b/CxC/RepCxC.aspx @@ -335,9 +335,20 @@ +
    + Moneda: +
    + +
    + + + + + +
    -
    + diff --git a/CxC/RepCxC.aspx.vb b/CxC/RepCxC.aspx.vb index e625f98bc..d7bda4f73 100644 --- a/CxC/RepCxC.aspx.vb +++ b/CxC/RepCxC.aspx.vb @@ -203,7 +203,7 @@ Partial Class RepCxC "-1", UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM), FechaVI, FechaVF, FechaCorte:=txtCorteA.Text.ToDate, EstatusCliente:=DdlEstatusCliente.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveCobranzaEstatus:=CveCobranzaEstatus, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, - TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, AplicaAnticiposPagados:=AplicaAnticipos) Then + TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, AplicaAnticiposPagados:=AplicaAnticipos, CveMoneda:=DdlMoneda.SelectedValue.ToEntero()) Then GvDatos.DataSource = ObjMovtos.DtResultados DtDatos = ObjMovtos.DtResultados diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 95fe80359..6c53d676e 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -800,20 +800,31 @@ Partial Class Ventas_ClientesAbonar Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.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 + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaDocumento.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 + If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then dtConceptos = ObjMov.DtResultados End If @@ -2554,24 +2565,35 @@ Partial Class Ventas_ClientesAbonar Dim CvePrePoliza As Integer = 0 Dim MsgError As String = "" - Dim ObjIE As New ClsBancos + '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 + Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If - ObjIE.Dispose() + '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) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6e4e7d7d9..1600c6e4d 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6285,7 +6285,7 @@ Partial Class Ventas Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595) 'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO - If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then + If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then RBLPago.SelectedValue = "2" RBLPago.Items(0).Enabled = False RBLPago_SelectedIndexChanged(Nothing, Nothing) @@ -14611,20 +14611,31 @@ Partial Class Ventas 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 = Now 'gvr.DataKey("Fecha").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") + Dim tFecha As Date = Now - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal - End If + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = Now 'gvr.DataKey("Fecha").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 + If DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 1 Then 'SI LA VENTA VIENE EN PESOS Y SE VA A PAGAR EN PESOS tipoCambioPago = 1 tipoCambioVenta = 1 @@ -23935,6 +23946,7 @@ Partial Class Ventas For Each Dr2 As DataRow In DtContratosSerieDetalle.FiltraParametros($"ConsecId = {Dr("CveContratoDetalle")}").Rows Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, factura.CveEmpresa, CveAlmacenExistenciasContrato, Serie:=Dr2("Serie").ToString(), FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < 1 Then + GuardaLogAD($"El producto no tiene existencia: CvePS:{CveProducto},CveUnidad:{CveUnidad},Cantidad: {Cantidad},Existencia: {Existencia},CveAlmacen:{CveAlmacenExistenciasContrato},Serie:{Dr2("Serie").ToString()}") Return False End If @@ -23947,6 +23959,7 @@ Partial Class Ventas Else Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, factura.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < Cantidad Then + GuardaLogAD($"El producto no tiene existencia: CvePS:{CveProducto},CveUnidad:{CveUnidad},Cantidad: {Cantidad},Existencia: {Existencia},CveAlmacen:{CveAlmacenExistenciasContrato}") Return False End If @@ -24719,24 +24732,34 @@ Partial Class Ventas Dim CvePrePoliza As Integer = 0 Dim MsgError As String = "" - Dim ObjIE As New ClsBancos + '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 = TxtFechaSaldarVenta.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 + Dim tFecha As Date = TxtFechaSaldarVenta.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaSaldarVenta.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") - ObjIE.Dispose() + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal + ' End If + + ' End If + 'End If + + ' ObjIE.Dispose() Dim IdCtaContable As Integer = IdCtaContClientes @@ -27719,20 +27742,29 @@ Partial Class Ventas TipoCambioFactura = TxtTipoCambio.Text.ToDecimal If DdlMoneda.SelectedValue.ToEntero() > 1 Then - Dim ObjIE As New ClsBancos - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFecha.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 - TipoCambioFactura = drr("TipoCambio").ToString().ToDecimal - End If + Dim tFecha As Date = TxtFecha.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion > tFecha Then + TipoCambioFactura = UltimaFluctuacion.TCFluctuacion End If End If - ObjIE.Dispose() + + 'Dim ObjIE As New ClsBancos + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFecha.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 + ' TipoCambioFactura = drr("TipoCambio").ToString().ToDecimal + ' End If + + ' End If + 'End If + 'ObjIE.Dispose() Else TipoCambioFactura = 1 End If