Files
SIG/Contratos/RepContratosObraAvancesPartida.aspx.vb
2020-11-05 20:03:08 -07:00

151 lines
4.7 KiB
VB.net

Imports Extensiones
Imports System.Data
Partial Class RepContratosObraAvancesPartida
Inherits ClsPaginas
Property CveEstimacion As Integer
Get
If ViewState("CveEstimacion") Is Nothing Then
Return -1
Else
Return ViewState("CveEstimacion").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveEstimacion") = value
End Set
End Property
Property CveContrato As Integer
Get
If ViewState("CveContrato") Is Nothing Then
Return -1
Else
Return ViewState("CveContrato").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveContrato") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CveEstimacion = If(Request("CveEstimacion") IsNot Nothing AndAlso Request("CveEstimacion").ToString.ToEntero > 0, Request("CveEstimacion").ToString.ToEntero, -1)
CveContrato = If(Request("CveContrato") IsNot Nothing AndAlso Request("CveContrato").ToString.ToEntero > 0, Request("CveContrato").ToString.ToEntero, -1)
LblEstimacion.Text = If(Request("NumeroEstimacion") IsNot Nothing AndAlso Request("NumeroEstimacion").ToString.Length > 0, $"Numero Estimacion: {Request("NumeroEstimacion").ToString}", "")
If CveEstimacion > 0 Then
CargaDatos()
End If
End If
End Sub
Private Sub CargaDatos()
Dim Con As New ClsContratos
If Con.GetContratosObraRepAvancesPartida(CveEstimacion, UsuarioActual.CveEmpresa) Then
GVDatos.DataSource = Con.DtResultados
If Con.DtResultados.Rows.Count = 0 Then
Alert("No se encontraron partidas.", TipoMensaje.MsgAdvertencia)
End If
Else
GVDatos.DataSource = Nothing
End If
Con.Dispose()
GVDatos.DataBind()
UpDatos.Update()
End Sub
Protected Sub GV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
End If
End Sub
Protected Sub GetAnexos(sender As Object, e As System.EventArgs)
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
LblTituloModalAnexo.Text = "Anexo " & GvRow.DataKey("PS")
'Get the button that raised the event
'Dim CveContratoDetalle As Integer = gvr.DataKey("CveContratoDetalle").ToString.ToEntero
Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate
Dim CveEstimacion As Integer = GvRow.DataKey("CveEstimacion").ToEntero
Dim CveContratoDetalle As Integer = GvRow.DataKey("CveContratoDetalle").ToEntero
Dim objContrato As New ClsContratos
If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, Fecha, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then
GvAnexos.DataSource = objContrato.DtResultados
GvAnexos.DataBind()
GvAnexos.Visible = True
Else
GvAnexos.Visible = False
End If
objContrato.Dispose()
UpModalAnexos.Update()
RegistraScript("$('#ModalAnexos').modal('show');")
End Sub
Protected Sub GvAnexos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvAnexos.RowDataBound
If e.Row.RowIndex > -1 Then
Dim Archivo As String = e.Row.DBCampo("Archivo").ToString
Dim start As Integer = Len(Archivo.Split("-"c)(0))
Dim LnkArchivo As LinkButton = e.Row.FCLinkButton("LnkArchivo")
LnkArchivo.Text = Archivo.Substring(start + 1)
'link.NavigateUrl = String.Format("/Empresas/{0}/Contrato/{1}/Anexos/{2}", UsuarioActual.CveEmpresa, CveContrato, Archivo)
ScriptManager.GetCurrent(Me).RegisterPostBackControl(LnkArchivo)
End If
End Sub
Protected Sub LnkArchivo_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
Dim Archivo As String = GvRow.DataKey("Archivo").ToString
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", $"attachment; filename={Archivo}")
Response.TransmitFile($"{UsuarioActual.Empresa.Ruta}\Contrato\{CveContrato}\Anexos\{Archivo}")
Response.End()
End Sub
End Class