141 lines
5.6 KiB
VB.net
141 lines
5.6 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports System.Data.SqlClient
|
|
Imports ADSNetLibrary.SIGAPI.Helpers
|
|
Imports Extensiones.ModExtensiones
|
|
|
|
Partial Class RepContratosCalendario
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
txtFechaI.Text = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
|
|
txtFechaF.Text = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
|
|
|
|
If Not IsPostBack Then
|
|
CargaCombos()
|
|
InicializaCalendar()
|
|
CargaDatos()
|
|
|
|
End If
|
|
InicializaCalendar()
|
|
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then
|
|
GvContratos.DataSource = ObjContratos.DtResultados
|
|
End If
|
|
ObjContratos.Dispose()
|
|
GvContratos.DataBind()
|
|
|
|
End Sub
|
|
Private Sub InicializaCalendar()
|
|
|
|
RegistraScript("InitCalendar();")
|
|
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
'Lista de Tipos de activo fijos
|
|
DdlTipoAF.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa)
|
|
DdlTipoAF.Items.Insert(0, New ListItem("-", ""))
|
|
DdlTipoAF.DataBind()
|
|
|
|
'Lista de Activos fijos
|
|
DdlAF.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa)
|
|
DdlAF.DataBind()
|
|
DdlAF.Items.Insert(0, New ListItem("-", ""))
|
|
|
|
'Lista Chofer'
|
|
DdlChofer.DataSource = GlobalDTRHPersonal(185)
|
|
DdlChofer.DataBind()
|
|
DdlChofer.Items.Insert(0, New ListItem("-", ""))
|
|
|
|
'Lista de Estatus
|
|
|
|
End Sub
|
|
|
|
Private Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim estatusContrato As String = DataBinder.Eval(e.Row.DataItem, "EstatusContrato").ToString()
|
|
|
|
Select Case estatusContrato
|
|
Case "1"
|
|
e.Row.BackColor = Drawing.Color.FromArgb(0, 165, 106)
|
|
Case "2"
|
|
e.Row.BackColor = Drawing.Color.FromArgb(43, 79, 214)
|
|
Case "3"
|
|
e.Row.BackColor = Drawing.Color.FromArgb(238, 96, 46)
|
|
End Select
|
|
End If
|
|
End Sub
|
|
Protected Sub MostrarModal(sender As Object, e As System.EventArgs)
|
|
RegistraScript("$('#ModalActualizar').modal('show');")
|
|
End Sub
|
|
|
|
Protected Sub Consultar(sender As Object, e As EventArgs)
|
|
If DdlClientesConsulta.SelectedValue = "" Then
|
|
Alert("Debe seleccionar al cliente", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim cliente As Integer = DdlClientesConsulta.SelectedValue.ToEntero
|
|
Dim estatus As Integer = DdlEstatusConsulta.SelectedValue.ToEntero
|
|
Dim fechaInicial As DateTime = txtFechaI.Text.ToDate
|
|
Dim fechaFinal As DateTime = txtFechaF.Text.ToDate
|
|
|
|
Dim query As String = "SELECT *, ISNULL(Cli.NombreComercial,'') AS NombreComercial, RH.NombreCompleto AS NombreCompleto FROM Con_Contratos C LEFT JOIN Clientes Cli with(nolock) ON Cli.CveCliente = C.CveCliente LEFT JOIN RH_Personal RH with(nolock) ON C.CveChofer = RH.CvePersonal WHERE C.CveCliente = @Cliente AND EstatusContrato = @Estatus AND FechaInicial BETWEEN @FechaInicial AND @FechaFinal"
|
|
|
|
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Conexion").ConnectionString)
|
|
Using command As New SqlCommand(query, connection)
|
|
command.Parameters.AddWithValue("@Cliente", cliente)
|
|
command.Parameters.AddWithValue("@Estatus", estatus)
|
|
command.Parameters.AddWithValue("@FechaInicial", fechaInicial)
|
|
command.Parameters.AddWithValue("@FechaFinal", fechaFinal)
|
|
|
|
connection.Open()
|
|
Dim reader As SqlDataReader = command.ExecuteReader()
|
|
GvContratos.DataSource = reader
|
|
GvContratos.DataBind()
|
|
End Using
|
|
End Using
|
|
|
|
UpTitulos.Update()
|
|
End Sub
|
|
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
ObjContratos.IniciaTransacSQL()
|
|
|
|
If ObjContratos.UpdateContratoAF(CveContrato.Value.ToEntero, DdlAF.SelectedValue.ToEntero, DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
ObjContratos.Commit()
|
|
Alert("Actualizado Correctamente.")
|
|
Else
|
|
ObjContratos.RollBack()
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
CargaDatos()
|
|
End Sub
|
|
Protected Sub UpdateModal(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
TxtObservaciones.Text = GvRow.DataKey("Observaciones")
|
|
TxtDescripcion.Text = GvRow.DataKey("DescripcionContrato")
|
|
TxtUbicacion.Text = GvRow.DataKey("Ubicacion")
|
|
TxtFechaSalida.Text = GvRow.DataKey("FechaInicial").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
|
|
TxtFechaRegreso.Text = GvRow.DataKey("FechaFinal").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
|
|
DdlClientes.SelectedValue = GvRow.DataKey("CveCliente")
|
|
DdlAF.SelectedValue = GvRow.DataKey("CveAF")
|
|
DdlChofer.SelectedValue = GvRow.DataKey("CveChofer")
|
|
|
|
UpModal.Update()
|
|
RegistraScript("$('#ModalActualizar').modal('show');")
|
|
End Sub
|
|
End Class
|