eFacturas Vinculacion manual

This commit is contained in:
Rakcsle Supertramp
2020-10-30 10:49:56 -07:00
parent 4ffc8aab1f
commit 5359e4a186
7 changed files with 635 additions and 106 deletions

View File

@@ -46,22 +46,31 @@ Partial Class Contratos_ContratoAvance
Set(value As String)
ViewState("fecha") = 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
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BtnGuardar.Visible = False
btnanexogral.Visible = False
CargaContrato()
btnanexogral.Visible = False
CargaContrato()
End If
End Sub
#Region "Filtros"
Private Sub CargaContrato()
DdlContratos.DataSource = GlobalDTContratos.FiltraParametros(String.Format("CveContratoTipo=4"))
DdlContratos.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (4,30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DdlContratos.DataBind()
DDlContratosEstimaciones.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (4,30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DDlContratosEstimaciones.DataBind()
CargaddlAvance()
End Sub
@@ -124,8 +133,10 @@ Partial Class Contratos_ContratoAvance
End Sub
Protected Sub GV_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles Gv.RowDataBound
If e.Row.RowIndex > -1 Then
e.Row.FCTextBox("TxtCantidad").Visible = (fecha = "")
e.Row.FCLinkButton("LnkAnexo").Visible = Not (fecha = "")
e.Row.FCLinkButton("LnkAnexo").Visible = Not (fecha = "")
If e.Row.DBCampo("CveContratoDetalle").ToString.ToEntero = 0 Then
e.Row.FCTextBox("TxtCantidad").Visible = False
e.Row.FCLinkButton("LnkAnexo").Visible = False
@@ -140,9 +151,32 @@ Partial Class Contratos_ContratoAvance
e.Row.CssClass = "SubTotales3"
End If
End If
If e.Row.DataKey("CveContratoDetalle").ToEntero > 0 Then
Dim LnkAnexo As LinkButton = e.Row.FCLinkButton("LnkModalDropzone")
'LnkAnexo.Visible = True
Dim DVAnexo As Control = DirectCast(e.Row.FindControl("ModalAnexoEvidencia"), Control)
LnkAnexo.OnClientClick = $" $('#{DVAnexo.ClientID}').modal('show'); return false;"
If DdlAvances.SelectedIndex > 0 Then
LnkAnexo.Visible = False
Else
LnkAnexo.Visible = True
End If
End If
End If
End Sub
Protected Sub GetAnexos(sender As Object, e As System.EventArgs)
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 btn As LinkButton = DirectCast(sender, LinkButton)
Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
@@ -154,22 +188,49 @@ Partial Class Contratos_ContratoAvance
GvAnexos.Visible = True
Else
GvAnexos.Visible = False
End If
objContrato.Dispose()
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
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 link As HyperLink = e.Row.FCHyperLink("HPLArchivo")
link.Text = Archivo.Substring(start + 1)
link.NavigateUrl = String.Format("/Empresas/{0}/Contrato/{1}/Anexos/{2}", UsuarioActual.CveEmpresa, CveContrato, Archivo)
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
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\{DdlContratos.SelectedValue.ToEntero}\Anexos\{Archivo}")
Response.End()
End Sub
#End Region
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
Dim ObjContratos As New ClsContratos
ObjContratos.IniciaTransacSQL()
Dim TieneError = False
@@ -177,47 +238,58 @@ Partial Class Contratos_ContratoAvance
Dim Cantidad As Double
Dim filesgral As List(Of Archivo) = AnexoGral.getfiles().Archivos
Dim guardarArchivos As New List(Of Archivo)
For Each gvr As GridViewRow In Gv.Rows
CveContratoDetalle = gvr.DataKey("CveContratoDetalle").ToEntero
If CveContratoDetalle > 0 Then
Cantidad = gvr.FCTextBox("TxtCantidad").Text.ToDouble
For Each gvr As GridViewRow In Gv.Rows
CveContratoDetalle = gvr.DataKey("CveContratoDetalle").ToEntero
If CveContratoDetalle > 0 Then
Cantidad = gvr.FCTextBox("TxtCantidad").Text.ToDouble
If Cantidad > 0 Then
If ObjContratos.AddContratosAvance(CveContratoDetalle, Cantidad, TxtFecha.Text.ToDateTime, UsuarioActual.CveUsuario) Then
If ObjContratos.AddContratosAvance(CveContratoDetalle, Cantidad, TxtFecha.Text.ToDateTime, UsuarioActual.CveUsuario) Then
Dim CveContratoAvance As Integer = ObjContratos.DtResultados.Rows(0)("CveContratoAvance").ToString.ToEntero
Dim files As List(Of Archivo) = gvr.FCTextBox("TXTAnexo").getfiles().Archivos
For Each fileItem As Archivo In filesgral
guardarArchivos.Add(fileItem)
If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then
TieneError = True
Exit For
End If
Next
For Each fileItem As Archivo In files
'For Each fileItem As Archivo In filesgral 'GENERAL
' guardarArchivos.Add(fileItem)
' If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then
' TieneError = True
' Exit For
' End If
'Next
For Each fileItem As Archivo In files
guardarArchivos.Add(fileItem)
If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then
TieneError = True
Exit For
End If
Next
Else
TieneError = True
Exit For
End If
End If
End If
Next
If TieneError Then
ObjContratos.RollBack()
Alert("No se logro guardar el Presupuesto favor de intentarlo mas tarde o comuniquese con soporte", TipoMensaje.MsgAdvertencia)
Else
Dim urlsave As String = String.Format("Empresas\{0}\Contrato\{1}\Anexos", UsuarioActual.CveEmpresa, CveContrato)
For Each fileItem As Archivo In filesgral
fileItem.filename.filesMove(fileItem.filename, urlsave)
Next
Dim urlsave As String = String.Format("Empresas\{0}\Contrato\{1}\Anexos", UsuarioActual.CveEmpresa, CveContrato)
For Each fileItem As Archivo In filesgral
fileItem.filename.FilesMove(fileItem.filename, urlsave)
Next
For Each fileItem As Archivo In guardarArchivos
fileItem.filename.filesMove(fileItem.filename, urlsave)
fileItem.filename.FilesMove(fileItem.filename.Replace($".{fileItem.Extencion}", ""), urlsave)
Next
ObjContratos.Commit()
Alert("se guardo Correctamente")
@@ -226,8 +298,84 @@ Partial Class Contratos_ContratoAvance
ObjContratos.Dispose()
CargaddlAvance()
CargaDatosAvance()
End Sub
End Sub
#Region "ESTIMACION"
Private Sub CargaAvancesParaEstimar()
Dim ObjContratos As New ClsContratos()
Dim DTEstimaciones As New DataTable
If ObjContratos.GetContratosAvanceEstimacion(DDlContratosEstimaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
DTEstimaciones = ObjContratos.DtResultados
BtnGuardarEstimacion.Visible = True
Else
BtnGuardarEstimacion.Visible = False
End If
ObjContratos.Dispose()
If DTEstimaciones.Rows.Count > 0 Then
GvEstimaciones.DataSource = DTEstimaciones
Else
GvEstimaciones.DataSource = Nothing
End If
GvEstimaciones.DataBind()
UpEstimaciones.Update()
End Sub
Private Sub BtnConsultarEstimaciones_Click(sender As Object, e As EventArgs) Handles BtnConsultarEstimaciones.Click
CargaAvancesParaEstimar()
End Sub
Private Sub GvEstimaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstimaciones.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveContratoDetalle").ToString.ToEntero = 0 Then
If e.Row.DBCampo("CveSubFamilias").ToString.ToEntero = 0 Then
If e.Row.DBCampo("CveFamilias").ToString.ToEntero = 0 Then
e.Row.CssClass = "SubTotales"
Else
e.Row.CssClass = "SubTotales2"
End If
Else
e.Row.CssClass = "SubTotales3"
End If
End If
End If
End Sub
Private Sub BtnGuardarEstimacion_Click(sender As Object, e As EventArgs) Handles BtnGuardarEstimacion.Click
Dim ObjContratos As New ClsContratos()
ObjContratos.Dispose()
End Sub
#End Region
End Class