199 lines
8.3 KiB
VB.net
199 lines
8.3 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Partial Class Contratos_PopUpBuscarContrato
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private ReadOnly Property Vinculacion As String
|
|
Get
|
|
Return ViewState("Vinculacion").ToString
|
|
End Get
|
|
End Property
|
|
Private ReadOnly Property CveProveedor As String
|
|
Get
|
|
Return ViewState("CveProveedor").ToString
|
|
End Get
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
CType(Me.Master, BaseMasterPage).EsPopup = True
|
|
|
|
ChkEstatus.Checked = True
|
|
loadComboTipoContrato()
|
|
CargaProyecto()
|
|
CargaDatos()
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlCliente.DataBind()
|
|
DdlProveedor.DataBind()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaProyecto()
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubProtecto, LblProyecto, LblSubProyecto)
|
|
'If UsuarioActual.Empresa.GralSoloProyecto Then
|
|
' CargaSubProyectoContrato(-1)
|
|
'Else
|
|
' DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa)
|
|
' DdlProyecto.DataBind()
|
|
'End If
|
|
'DdlProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
'DdlSubProtecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargaSubProyectoContrato(DdlProyecto.SelectedValue.ToEntero)
|
|
End Sub
|
|
Protected Sub CargaSubProyectoContrato(CveProyecto As Integer)
|
|
DdlSubProtecto.Items.Clear()
|
|
DdlSubProtecto.DataSource = GlobalDTSubProyectos(CveProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubproyecto", "SubProyecto"})
|
|
DdlSubProtecto.DataBind()
|
|
DdlSubProtecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
UPFiltros.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub loadComboTipoContrato()
|
|
|
|
|
|
If DdlTipo.SelectedValue.ToEntero = 1 Then
|
|
'3 cliente
|
|
'4 proveedor
|
|
GV.Columns(3).Visible = False
|
|
GV.Columns(2).Visible = True
|
|
ltlContratante.Text = "Cliente"
|
|
DdlCliente.Visible = True
|
|
DdlProveedor.Visible = False
|
|
DdlCliente.SelectedValue = "-1"
|
|
Else
|
|
ltlContratante.Text = "Proveedor"
|
|
GV.Columns(3).Visible = True
|
|
GV.Columns(2).Visible = False
|
|
DdlProveedor.Visible = True
|
|
DdlCliente.Visible = False
|
|
DdlProveedor.SelectedValue = "-1"
|
|
End If
|
|
UPFiltros.Update()
|
|
UPDatos.Update()
|
|
|
|
Try
|
|
DdlTipoContrato.DataSource = GlobalDTContratosTipos(UsuarioActual.CveEmpresa).FiltraParametros($" TipoMovimiento = {DdlTipo.SelectedValue }")
|
|
DdlTipoContrato.DataBind()
|
|
DdlTipoContrato.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
|
|
|
Catch ex As Exception
|
|
Alert(ex.Message, TipoMensaje.MsgError)
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnVincular_Click(sender As Object, e As EventArgs)
|
|
Dim CveContrato As String = ""
|
|
Dim NumeroContrato As String = ""
|
|
For i As Integer = 0 To (GV.Rows.Count - 1)
|
|
If GV.Rows(i).FCCheckBox("CheckVincular").Checked = True Then
|
|
If CveContrato <> "" Then
|
|
CveContrato &= String.Format(",{0}", GV.Rows(i).DataKey("CveContrato").ToString)
|
|
NumeroContrato &= String.Format(",{0}", GV.Rows(i).DataKey("NumeroContrato").ToString)
|
|
Else
|
|
CveContrato = GV.Rows(i).DataKey("CveContrato").ToString
|
|
NumeroContrato = GV.Rows(i).DataKey("NumeroContrato").ToString
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If CveContrato <> "" AndAlso CveContrato.Length > 0 Then
|
|
RegistraScript(String.Format("javascript:Ir2('{0}','{1}');", CveContrato, NumeroContrato))
|
|
Else
|
|
Alert("No seleccionó ningún Contrato, Por lo cual no se puede vincular.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipo.SelectedIndexChanged
|
|
loadComboTipoContrato()
|
|
|
|
End Sub
|
|
Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs) Handles BtnBuscar.Click
|
|
|
|
|
|
|
|
Dim NumeroContrato As String = "-1"
|
|
Dim Estatus As Integer = 1
|
|
Dim Descripcion As String = "-1"
|
|
Dim Ubicacion As String = "-1"
|
|
Dim Responsable As String = "-1"
|
|
|
|
|
|
|
|
If ChkEstatus.Checked Then Estatus = 1 Else Estatus = 0
|
|
If TxtDescripcion.Text.Trim.Length > 0 Then Descripcion = TxtDescripcion.Text
|
|
If TxtUbicacion.Text.Trim.Length > 0 Then Ubicacion = TxtUbicacion.Text
|
|
If TxtResponsable.Text.Trim.Length > 0 Then Responsable = TxtResponsable.Text
|
|
If TxtNumeroContrato.Text.Trim.Length > 0 Then NumeroContrato = TxtNumeroContrato.Text
|
|
|
|
If ValidarUnFiltroSeleccionado() Then
|
|
Dim objContratos As New ClsContratos
|
|
If (objContratos.GetContratosBusquedaRep(DdlTipo.SelectedValue.ToEntero, DdlTipoContrato.SelectedValue.ToEntero, NumeroContrato, Descripcion, Ubicacion, Responsable, Estatus,
|
|
DdlProyecto.SelectedValue.ToEntero, DdlSubProtecto.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, DdlCliente.SelectedValue.ToEntero,
|
|
DdlProveedor.SelectedValue.ToEntero, TopSelect:=100)) Then
|
|
GV.DataSource = objContratos.DtResultados
|
|
LtlTotalRegistros.Text = objContratos.DtResultados.Rows.Count.ToString
|
|
Else
|
|
GV.DataSource = Nothing
|
|
LtlTotalRegistros.Text = "0"
|
|
End If
|
|
|
|
|
|
|
|
objContratos.Dispose()
|
|
GV.DataBind()
|
|
UPDatos.Update()
|
|
Else
|
|
Alert("Seleccione un criterio de busqueda", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub GV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GV.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim Liga As String = String.Format("<a class='Texto' href='/Contratos/Contrato.aspx?CveContrato={0}' target='_blank'>", e.Row.DBCampo("CveContrato"))
|
|
Dim LigaCliente As String = String.Format("<a class='Texto' href='/Ventas/Clientes.aspx?CveCliente={0}' target='_blank'>", e.Row.DBCampo("CveCliente"))
|
|
Dim LigaProveedor As String = String.Format("<a class='Texto' href='/Compras/Proveedores.aspx?CveProveedor={0}' target='_blank'>", e.Row.DBCampo("CveProveedor"))
|
|
|
|
e.Row.FCLiteral("LtlNumeroContrato").Text = String.Format("<div class='truncate' style='width:100px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("NumeroContrato"))
|
|
e.Row.FCLiteral("LtlDescripcionContrato").Text = String.Format("<div class='truncate' style='width:200px;'>{0}</div>", e.Row.DBCampo("DescripcionContrato"))
|
|
|
|
e.Row.FCLiteral("LtlCliente").Text = String.Format("<div class='truncate' style='width:200px;'>{0}{1}</a></div>", LigaCliente, e.Row.DBCampo("Cliente"))
|
|
e.Row.FCLiteral("LtlProveedor").Text = String.Format("<div class='truncate' style='width:200px;'>{0}{1}</a></div>", LigaProveedor, e.Row.DBCampo("Proveedor"))
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function ValidarUnFiltroSeleccionado() As Boolean
|
|
If TxtDescripcion.Text.Trim.Length > 0 Then Return True
|
|
If TxtUbicacion.Text.Trim.Length > 0 Then Return True
|
|
If TxtResponsable.Text.Trim.Length > 0 Then Return True
|
|
If TxtNumeroContrato.Text.Trim.Length > 0 Then Return True
|
|
'If DdlTipo.SelectedValue.ToEntero > 0 Then Return True
|
|
If DdlTipoContrato.SelectedValue.ToEntero > 0 Then Return True
|
|
If DdlProyecto.SelectedValue.ToEntero > 0 Then Return True
|
|
If DdlSubProtecto.SelectedValue.ToEntero > 0 Then Return True
|
|
If DdlCliente.SelectedValue.ToEntero > 0 Then Return True
|
|
If DdlProveedor.SelectedValue.ToEntero > 0 Then Return True
|
|
Return False
|
|
End Function
|
|
End Class |