diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index 30857a704..88cfc8e83 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -34,11 +34,17 @@ Public Class ClsContratos End Property Public Property NotificarAvanceAlcanzado As Boolean - Public Property CveContratoGasto As Integer - - + Public Property CveContratoGasto As Integer + + Public Property NumeroEstimacionNueva As Integer + Public Property CveEstimacionNueva As Integer + + + + + #End Region - + #Region "T R A N S A C C I O N E S" Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() @@ -1102,6 +1108,61 @@ Public Class ClsContratos Return Retorno End Function + + Public Function AddContratosAvanceEstimacion(CveContrato As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + NumeroEstimacionNueva = -1 + CveEstimacionNueva = -1 + + DataAdapter("PA_Con_ContratosEstimacionAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@NumeroEstimacion", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@CveEstimacion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + + SqlAdapter.Fill(Data) + NumeroEstimacionNueva = SqlAdapter.SelectCommand.Parameters("@NumeroEstimacion").Value.ToString.ToEntero + CveEstimacionNueva = SqlAdapter.SelectCommand.Parameters("@CveEstimacion").Value.ToString.ToEntero + + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al agregar la estimación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function UpdateContratosAvanceEstimacion(CveContratoAvance As Integer, CveEstimacion As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno = False + + DataAdapter("PA_Con_ContratosAvanceEstimacionUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveContratoAvance", SqlDbType.Int).Value = CveContratoAvance + .Add("@CveEstimacion", SqlDbType.Int).Value = CveEstimacion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el avance.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + #End Region #Region " S E C C I O N E S " diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index 78af613be..fe7fee68d 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -745,7 +745,7 @@ Public Class ClsOIEventos OnError("Ocurrió un error al actualizar la relación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return retorno - End Function + End Function Public Function UPEventosVinculo(CveEvento As Integer, CveTipoRelacion As Integer, CveRelacion As Integer, CveEmpresa As Integer, CveUsuarioIng As Integer) As Boolean Dim retorno As Boolean = False DataAdapter("PA_OI_EventosVinculoUP", CommandType.StoredProcedure) diff --git a/Bin/ClosedXML.dll b/Bin/ClosedXML.dll index e945f5d26..4065a321f 100644 Binary files a/Bin/ClosedXML.dll and b/Bin/ClosedXML.dll differ diff --git a/Bin/DocumentFormat.OpenXml.dll b/Bin/DocumentFormat.OpenXml.dll index 53241bd1c..1698758e5 100644 Binary files a/Bin/DocumentFormat.OpenXml.dll and b/Bin/DocumentFormat.OpenXml.dll differ diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx index 7f41f1fa3..8d9162b84 100644 --- a/Compras/eFacturas.aspx +++ b/Compras/eFacturas.aspx @@ -570,6 +570,13 @@ + + + + + + + diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 319d8a3b0..899965cde 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -2926,6 +2926,9 @@ Partial Class Compras_eFacturas End If Next + + + If MSGComplemento.Trim.Length > 0 Then ' BtnVincularPago.Visible = False ViculacionConPUE = True @@ -2974,11 +2977,30 @@ Partial Class Compras_eFacturas GvVincularPago.DataBind() - UpVincularPago.Update() + ListaComprasPUE = ListaComprasPUEInterna + + If DivVincularPagoManualmente.Visible Then + + For Each GvRowValidaCompra As GridViewRow In GVPDocumentosRelacionadosPagos.Rows + If GvRowValidaCompra.DataKey("CveCompra").ToEntero > 0 Then + DivVincularPagoManualmente.Visible = True + Exit For + Else + DivVincularPagoManualmente.Visible = False + End If + Next + + End If + + + + UpVincularPago.Update() + + RegistraScript("$('#ModalVincularPago').modal('show')", "VincularPagoModalShow") End Sub @@ -3004,11 +3026,25 @@ Partial Class Compras_eFacturas For Each Gv As GridViewRow In GVPDocumentosRelacionadosPagos.Rows - If Not ObjCompra.AddComplementoPago(Gv.DataKey("CveIE").ToEntero, Gv.DataKey("CveCompra").ToEntero, Gv.DataKey("ImpPagado").ToDecimal, Gv.DataKey("CvePrePolizaDetalle").ToEntero, CveFacturaPago) > 0 Then - TieneError = True + If HdnCveIE.Value.ToEntero > 0 Then + If Gv.DataKey("CveCompra").ToEntero > 0 And Gv.FCLabel("LblCveIE").Text.ToEntero > 0 Then + + If Not ObjCompra.AddComplementoPago(Gv.FCLabel("LblCveIE").Text.ToEntero, Gv.DataKey("CveCompra").ToEntero, Gv.DataKey("ImpPagado").ToDecimal, Gv.FCLabel("LblCvePrePolizaDetalle").Text.ToEntero, CveFacturaPago) > 0 Then + TieneError = True + Exit For + End If + + End If + Else + If Gv.DataKey("CveCompra").ToEntero > 0 Then + + If Not ObjCompra.AddComplementoPago(Gv.DataKey("CveIE").ToEntero, Gv.DataKey("CveCompra").ToEntero, Gv.DataKey("ImpPagado").ToDecimal, Gv.DataKey("CvePrePolizaDetalle").ToEntero, CveFacturaPago) > 0 Then + TieneError = True + Exit For + End If + + End If End If - - Next If Not TieneError AndAlso Not ObjCompra.AddVincularPago(CveFacturaPago) Then @@ -3021,6 +3057,7 @@ Partial Class Compras_eFacturas If ViculacionConPUE Then + For Each CveCompraVinculada In ListaComprasPUE objEventos.AddEventoBitacora($"Complemento { ComplementoConPUE } vinculado manualmente (Compra PUE) ", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompraVinculada) Next @@ -3040,6 +3077,8 @@ Partial Class Compras_eFacturas ObjCompra.Commit() + HdnCveIE.Value = "" + Alert("El pago fue vinculado correctamente", TipoMensaje.MsgInformacion) RegistraScript("$('#ModalVincularPago').modal('hide')", "VincularPagoModalHide") CargaDatos() @@ -3062,33 +3101,83 @@ Partial Class Compras_eFacturas End Sub Protected Sub BtnVincularManualmente_Click(sender As Object, e As EventArgs) + + If HdnCveIE.Value <> "-1" AndAlso IsNumeric(HdnCveIE.Value) AndAlso HdnCveIE.Value.ToEntero > 0 Then + Dim ImportePago As Double = 0 Dim ImporteIES As Double = 0 Dim SerieFolioIE As String = "" Dim ObjCompras As New ClsCompras + Dim ErrorVinculacion = True + If ObjCompras.GetCompararComplementoPago(CveProveedor, -1, "", UsuarioActual.CveEmpresa, HdnCveIE.Value.ToEntero) Then - GvVincularPago.DataSource = ObjCompras.DtResultados - If ObjCompras.DtResultados.Rows.Count > 0 Then - SerieFolioIE = ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString - End If - ImportePago = ObjCompras.DtResultados.SUMD("Monto") + + 'GvVincularPago.DataSource = ObjCompras.DtResultados + + 'If ObjCompras.DtResultados.Rows.Count > 0 Then + ' SerieFolioIE = ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString + 'End If + + + 'ImportePago = ObjCompras.DtResultados.SUMD("Monto") + + For Each Drow As DataRow In ObjCompras.DtResultados.Rows + For Each GvRow As GridViewRow In GVPDocumentosRelacionadosPagos.Rows + + If GvRow.RowType = DataControlRowType.DataRow Then + + If Drow("CveCompra").ToString.ToEntero = GvRow.DataKey("CveCompra").ToEntero Then + + GvRow.FCLabel("LblCveIE").Text = Drow("CveIE").ToString.ToEntero.ToString + GvRow.FCLabel("LblCvePrePolizaDetalle").Text = Drow("CvePrePolizaDetalle").ToString.ToEntero.ToString + + End If + + End If + + Next + Next + + + For Each GvRow As GridViewRow In GVPDocumentosRelacionadosPagos.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCLabel("LblCveIE").Text.ToEntero > 0 And GvRow.FCLabel("LblCvePrePolizaDetalle").Text.ToEntero > 0 Then + ErrorVinculacion = False + Exit For + Else + ErrorVinculacion = True + + End If + End If + Next + + Else + ErrorVinculacion = True End If - ImporteIES = ObjCompras.DtResultados.FiltraParametros("CveIE > 0").SUM("Importe") - ObjCompras.Dispose() + If Not ErrorVinculacion Then + ImporteIES = ObjCompras.DtResultados.FiltraParametros("CveIE > 0").SUM("Importe") + ObjCompras.Dispose() - BtnVincularPago.Visible = True + BtnVincularPago.Visible = True + + LblSerieFolioPago.Text = $"{SeriePago}-{FolioPago}" + LblImportePago.Text = ImportePago.FormatoNumero + 'LblSerieFolioIE.Text = SerieFolioIE + LblImporteIE.Text = ImporteIES.FormatoNumero + + GvVincularPago.DataBind() + UpVincularPago.Update() + ObjCompras.Dispose() + + Else + Alert("No se pudo realizar la vinculacion manual", TipoMensaje.MsgAdvertencia) + End If - LblSerieFolioPago.Text = $"{SeriePago}-{FolioPago}" - LblImportePago.Text = ImportePago.FormatoNumero - 'LblSerieFolioIE.Text = SerieFolioIE - LblImporteIE.Text = ImporteIES.FormatoNumero - GvVincularPago.DataBind() - UpVincularPago.Update() - ObjCompras.Dispose() End If + End Sub Private Sub GVPDocumentosRelacionadosPagos_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GVPDocumentosRelacionadosPagos.RowCreated diff --git a/Contratos/ContratoAvance.aspx b/Contratos/ContratoAvance.aspx index 6b702897e..2cb599e87 100644 --- a/Contratos/ContratoAvance.aspx +++ b/Contratos/ContratoAvance.aspx @@ -273,7 +273,7 @@
diff --git a/Contratos/ContratoAvance.aspx.vb b/Contratos/ContratoAvance.aspx.vb index db1c3340b..9635f7334 100644 --- a/Contratos/ContratoAvance.aspx.vb +++ b/Contratos/ContratoAvance.aspx.vb @@ -33,7 +33,22 @@ Partial Class Contratos_ContratoAvance Set(value As Integer) ViewState("CveContrato") = value End Set + End Property + + + Private Property CveContratoEstimacion As Integer + Get + If ViewState("CveContratoEstimacion") Is Nothing Then + Return Nothing + Else + Return ViewState("CveContratoEstimacion").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveContratoEstimacion") = value + End Set End Property + 'fecha seleccionada del historico de avances Private Property fecha As String Get @@ -306,7 +321,7 @@ Partial Class Contratos_ContratoAvance Private Sub CargaAvancesParaEstimar() - + CveContratoEstimacion = -1 Dim ObjContratos As New ClsContratos() Dim DTEstimaciones As New DataTable @@ -314,9 +329,10 @@ Partial Class Contratos_ContratoAvance If ObjContratos.GetContratosAvanceEstimacion(DDlContratosEstimaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then DTEstimaciones = ObjContratos.DtResultados - BtnGuardarEstimacion.Visible = True - Else - BtnGuardarEstimacion.Visible = False + + CveContratoEstimacion = DDlContratosEstimaciones.SelectedValue.ToEntero + + End If @@ -325,8 +341,10 @@ Partial Class Contratos_ContratoAvance If DTEstimaciones.Rows.Count > 0 Then GvEstimaciones.DataSource = DTEstimaciones + BtnGuardarEstimacion.Visible = True Else GvEstimaciones.DataSource = Nothing + BtnGuardarEstimacion.Visible = False End If GvEstimaciones.DataBind() @@ -358,16 +376,46 @@ Partial Class Contratos_ContratoAvance End If End If - - - End Sub Private Sub BtnGuardarEstimacion_Click(sender As Object, e As EventArgs) Handles BtnGuardarEstimacion.Click Dim ObjContratos As New ClsContratos() + Dim ErrorProceso As Boolean = False + Dim NuemeroEstimacion As Integer = -1 + ObjContratos.IniciaTransacSQL() + If ObjContratos.AddContratosAvanceEstimacion(CveContratoEstimacion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + + NuemeroEstimacion = ObjContratos.NumeroEstimacionNueva + + For Each GvRow As GridViewRow In GvEstimaciones.Rows + + If GvRow.DataKey("CveContratoAvance").ToEntero > 0 Then + If Not ObjContratos.UpdateContratosAvanceEstimacion(GvRow.DataKey("CveContratoAvance").ToEntero, ObjContratos.CveEstimacionNueva, UsuarioActual.CveEmpresa) Then + ErrorProceso = True + Exit For + End If + End If + Next + + Else + ErrorProceso = True + End If + + 'AddContratosAvanceEstimacion + 'UpdateContratosAvanceEstimacion + + + + If Not ErrorProceso Then + ObjContratos.Commit() + Alert($"Estimación {NuemeroEstimacion} agregada correctamente.") + Else + ObjContratos.RollBack() + End If ObjContratos.Dispose() diff --git a/vwd.webinfo b/vwd.webinfo index 622d89f70..e36646dd2 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -124,6 +124,8 @@ + +