476 lines
14 KiB
VB.net
476 lines
14 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports Extensiones
|
|
Imports GemBox.Spreadsheet
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class AF_OrdenTrabajo
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES"
|
|
|
|
Property CveOrdenTrabajo As Integer
|
|
Get
|
|
If ViewState("CveOrdenTrabajo") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveOrdenTrabajo").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveOrdenTrabajo") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property CveOrdenCompra As Integer
|
|
Get
|
|
If ViewState("CveOrdenCompra") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveOrdenCompra").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveOrdenCompra") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
|
|
CargaCombos()
|
|
|
|
If Request("CveOrdenTrabajo") IsNot Nothing Then
|
|
CveOrdenTrabajo = Request("CveOrdenTrabajo").ToEntero
|
|
|
|
If CveOrdenTrabajo > 0 Then
|
|
|
|
DVFechaFin.Visible = True
|
|
DVFolioAsignado.Visible = True
|
|
DVEstatus.Visible = True
|
|
|
|
Tab.Visible = True
|
|
CargaDatos()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " CARGA PARAMETROS "
|
|
|
|
#End Region
|
|
|
|
#Region " CARGA COMBOS "
|
|
Protected Sub CargaCombos()
|
|
|
|
|
|
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto)
|
|
|
|
DdlAF.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa, -1)
|
|
DdlAF.DataBind()
|
|
|
|
DdlAF.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetTiposServicios(-1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlTipoServicio.DataSource = ObjAF.DtResultados
|
|
Else
|
|
DdlTipoServicio.DataSource = Nothing
|
|
End If
|
|
|
|
|
|
If ObjAF.GetOrdenesTrabajoEstatus(UsuarioActual.CveEmpresa) Then
|
|
DdlOrdenesTrabajoEstatus.DataSource = ObjAF.DtResultados
|
|
Else
|
|
DdlOrdenesTrabajoEstatus.DataSource = Nothing
|
|
End If
|
|
|
|
|
|
ObjAF.Dispose()
|
|
|
|
DdlTipoServicio.DataBind()
|
|
DdlOrdenesTrabajoEstatus.DataBind()
|
|
|
|
DdlTipoServicio.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
DdlOrdenesTrabajoEstatus.SelectedValueExist(1)
|
|
|
|
UpFiltro.Update()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " GV DATOS "
|
|
|
|
Private Sub CargaDatos()
|
|
|
|
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetOrdenesTrabajo(CveOrdenTrabajo, -1, -1, -1, -1, -1, MinFecha, MaxFecha, Nothing, -1, UsuarioActual.CveEmpresa) Then
|
|
|
|
If ObjAF.DtResultados IsNot Nothing AndAlso ObjAF.DtResultados.Rows.Count > 0 Then
|
|
|
|
LblFolio.Text = ObjAF.DtResultados(0)("Folio").ToString
|
|
LblAsiganado.Text = ObjAF.DtResultados(0)("NombreCompleto").ToString
|
|
|
|
DdlSubProyecto.SelectedValueExist(ObjAF.DtResultados(0)("CveSubProyecto").ToString)
|
|
DdlAF.SelectedValueExist(ObjAF.DtResultados(0)("CveAF").ToString)
|
|
DdlTipoServicio.SelectedValueExist(ObjAF.DtResultados(0)("CveTipoServicio").ToString)
|
|
TxtServicio.Text = ObjAF.DtResultados(0)("Servicio").ToString
|
|
DdlPrioridad.SelectedValueExist(ObjAF.DtResultados(0)("Prioridad").ToString)
|
|
txtFechaI.Text = ObjAF.DtResultados(0)("FechaInicio").ToString.ToDate.ToString("dd/MM/yyyy")
|
|
|
|
CveOrdenCompra = ObjAF.DtResultados(0)("CveOrdenCompra").ToString.ToEntero
|
|
|
|
If ObjAF.DtResultados(0)("FechaFin").ToString.Length > 0 Then
|
|
txtFechaF.Text = ObjAF.DtResultados(0)("FechaFin").ToString.ToDate.ToString("dd/MM/yyyy")
|
|
End If
|
|
|
|
'txtFechaFinReal.Text ""
|
|
DdlOrdenesTrabajoEstatus.SelectedValueExist(ObjAF.DtResultados(0)("CveEstatusOT").ToString)
|
|
Else
|
|
Alert("No se encontro la orden de trabajo", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
|
|
CargaMaterial()
|
|
CargaActividades()
|
|
CargaCheckList()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub LnkEliminarMetricaValor_Click(sender As Object, e As EventArgs)
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
|
|
If CveOrdenTrabajo <= 0 Then
|
|
|
|
|
|
Dim ObjAF As New ClsAF
|
|
ObjAF.IniciaTransacSQL()
|
|
Dim ErrorProceso As Boolean = False
|
|
|
|
If Not ObjAF.AddOrdenesTrabajo(DdlTipoServicio.SelectedValue.ToEntero, DdlAF.SelectedValue.ToEntero, TxtServicio.Text.Trim, DdlSubProyecto.SelectedValue.ToEntero, DdlPrioridad.SelectedValue.ToEntero, txtFechaI.Text.ToDate, MaxFecha, MaxFecha, DdlOrdenesTrabajoEstatus.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
ErrorProceso = True
|
|
|
|
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
ObjAF.Commit()
|
|
Alert($"Orden de trabajo guardada corectamente <a href='./OrdenTrabajo.aspx?CveOrdenTrabajo={ObjAF.CveOrdenTrabajo}' class='Texto'> Folio {ObjAF.FolioOT}</a>")
|
|
Else
|
|
ObjAF.RollBack()
|
|
End If
|
|
|
|
|
|
|
|
ObjAF.Dispose()
|
|
|
|
|
|
Else
|
|
|
|
If DdlOrdenesTrabajoEstatus.SelectedValue.ToEntero = 3 Then
|
|
If txtFechaF.Text.Length = 0 Then
|
|
Alert("La fecha fin es requerida.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim ObjAF As New ClsAF
|
|
ObjAF.IniciaTransacSQL()
|
|
Dim ErrorProceso As Boolean = False
|
|
|
|
|
|
Dim FechaFinal As Date = MaxFecha
|
|
Dim FechaFinReal As Date = MaxFecha
|
|
|
|
|
|
If txtFechaF.Text.ToDate > MinFecha Then
|
|
FechaFinal = txtFechaF.Text.ToDate
|
|
End If
|
|
|
|
If Not ObjAF.UpdateOrdenesTrabajo(CveOrdenTrabajo, DdlTipoServicio.SelectedValue.ToEntero, DdlAF.SelectedValue.ToEntero, TxtServicio.Text.Trim, DdlSubProyecto.SelectedValue.ToEntero, DdlPrioridad.SelectedValue.ToEntero, txtFechaI.Text.ToDate, FechaFinal, MaxFecha, DdlOrdenesTrabajoEstatus.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1) Then
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
For Each GvRow As GridViewRow In GvActividades.Rows
|
|
|
|
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
Dim TxtObservaciones As TextBox = GvRow.FCTextBox("TxtObservaciones")
|
|
Dim CveOrdenTrabajoActividad As Integer = GvRow.DataKey("CveOrdenTrabajoActividad").ToEntero
|
|
|
|
If Not ObjAF.UpdateOrdenesTrabajoActividades(CveOrdenTrabajoActividad, "-1", If(Chk.Checked, 1, 0), TxtObservaciones.Text, UsuarioActual.CveEmpresa) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
For Each GvRow As GridViewRow In GvCheckList.Rows
|
|
|
|
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
Dim TxtObservaciones As TextBox = GvRow.FCTextBox("TxtObservaciones")
|
|
Dim CveOrdenTrabajoCheckList As Integer = GvRow.DataKey("CveOrdenTrabajoCheckList").ToEntero
|
|
Dim RBL As RadioButtonList = GvRow.FCRadioButtonList("RDLSINOND")
|
|
Dim Estatus As Integer = 0
|
|
|
|
If RBL.SelectedValue.ToEntero > 0 Then
|
|
Estatus = RBL.SelectedValue.ToEntero
|
|
End If
|
|
|
|
If CveOrdenTrabajoCheckList > 0 Then
|
|
|
|
If Not ObjAF.UpdateOrdenesTrabajoCheckList(CveOrdenTrabajoCheckList, "-1", If(Chk.Checked, 1, 0), TxtObservaciones.Text, Estatus, UsuarioActual.CveEmpresa) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
ObjAF.Commit()
|
|
Alert($"Orden de trabajo actualizada correctamente.")
|
|
Else
|
|
ObjAF.RollBack()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
#Region "FOLIOS"
|
|
|
|
|
|
Private Function CargaFolios() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
If DdlSubProyecto.SelectedValue.ToEntero() <= 0 Then
|
|
Alert("No se tienen asignadas sucursales", TipoMensaje.MsgError)
|
|
Return False
|
|
Exit Function
|
|
End If
|
|
|
|
Dim ObjFolios As New ClsGralFolios()
|
|
|
|
If ObjFolios.GetFolios("OT", UsuarioActual.CveEmpresa) Then
|
|
|
|
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", DdlSubProyecto.SelectedValue))
|
|
|
|
If DT.Rows.Count > 0 Then
|
|
Respuesta = True
|
|
Else
|
|
|
|
Alert("No tiene registrados Folios para " & DdlSubProyecto.SelectedItem.Text & " ", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
DT.Dispose()
|
|
|
|
End If
|
|
|
|
ObjFolios.Dispose()
|
|
|
|
|
|
Return Respuesta
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
|
|
Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
If CargaFolios() Then
|
|
BtnGuardar.Enabled = True
|
|
Else
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
|
|
UpGuardar.Update()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaMaterial()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
Dim MaterialFaltante As Decimal = 0
|
|
|
|
If ObjAF.GetOrdenesTrabajoMateriales(CveOrdenTrabajo, UsuarioActual.CveEmpresa) Then
|
|
GvMaterial.DataSource = ObjAF.DtResultados
|
|
MaterialFaltante = ObjAF.DtResultados.SUMD("Faltante")
|
|
Else
|
|
GvMaterial.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
|
|
|
|
|
|
If MaterialFaltante > 0 AndAlso CveOrdenCompra <= 0 Then
|
|
|
|
GvMaterial.Columns(4).Visible = True
|
|
End If
|
|
|
|
GvMaterial.DataBind()
|
|
|
|
UpGvMaterial.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaActividades()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
|
|
If ObjAF.GetOrdenesTrabajoActividades(CveOrdenTrabajo, UsuarioActual.CveEmpresa) Then
|
|
GvActividades.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvActividades.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
GvActividades.DataBind()
|
|
UpGvActividades.Update()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaCheckList()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
|
|
If ObjAF.GetOrdenesTrabajoCheckList(CveOrdenTrabajo, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
|
GvCheckList.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvCheckList.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
GvCheckList.DataBind()
|
|
UpGvCheckList.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvMaterial_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If GvMaterial.Columns(4).Visible Then
|
|
|
|
If e.Row.DataKey("Faltante").ToDecimal > 0 Then
|
|
Dim HLOC As HyperLink = e.Row.FCHyperLink("HLOC")
|
|
HLOC.Visible = True
|
|
HLOC.NavigateUrl = $"../OC/OC.aspx?CveOrdenTrabajo={CveOrdenTrabajo}"
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub GvActividades_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Chk As CheckBox = e.Row.FCCheckBox("Chk")
|
|
|
|
If Boolean.Parse(e.Row.DataKey("Terminado")) Then
|
|
Chk.Checked = True
|
|
Else
|
|
Chk.Checked = False
|
|
End If
|
|
End If
|
|
|
|
|
|
End Sub
|
|
Protected Sub GvCheckList_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim Chk As CheckBox = e.Row.FCCheckBox("Chk")
|
|
Dim RDLSINOND As RadioButtonList = e.Row.FCRadioButtonList("RDLSINOND")
|
|
Dim TxtObservaciones As TextBox = e.Row.FCTextBox("TxtObservaciones")
|
|
|
|
If e.Row.DataKey("CveOrdenTrabajoCheckList").ToEntero = 0 Then
|
|
|
|
e.Row.FCLiteral("LtlNROW").Text = e.Row.DataKey("CheckListActividadGrupo").ToString
|
|
e.Row.Attributes.Add("style", "background-color:#DDD")
|
|
|
|
Chk.Visible = False
|
|
RDLSINOND.Visible = False
|
|
TxtObservaciones.Visible = False
|
|
Else
|
|
Dim Estatus As String = e.Row.DataKey("Estatus")
|
|
|
|
RDLSINOND.SelectedValuesIfExist(Estatus)
|
|
|
|
If Boolean.Parse(e.Row.DataKey("Terminado")) Then
|
|
Chk.Checked = True
|
|
Else
|
|
Chk.Checked = False
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
End Class
|