828 lines
25 KiB
VB.net
828 lines
25 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_TipoOrdenTrabajo
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES"
|
|
|
|
Property CveTipoServicio As Integer
|
|
Get
|
|
If ViewState("CveTipoServicio") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveTipoServicio").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTipoServicio") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property DTMateriales As DataTable
|
|
Get
|
|
If ViewState("DTMateriales") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTMateriales"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTMateriales") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property DTActividades As DataTable
|
|
Get
|
|
If ViewState("DTActividades") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTActividades"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTActividades") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property DTACheckList As DataTable
|
|
Get
|
|
If ViewState("DTACheckList") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTACheckList"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTACheckList") = 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
|
|
|
|
|
|
If Request("CveTipoServicio") IsNot Nothing Then
|
|
CveTipoServicio = Request("CveTipoServicio").ToEntero
|
|
End If
|
|
|
|
CargaCombos()
|
|
|
|
|
|
If CveTipoServicio = -1 Then
|
|
CrearTablas()
|
|
CargaActividades()
|
|
CargaCheckList()
|
|
Else
|
|
CargaDatos()
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Region " CARGA PARAMETROS "
|
|
|
|
#End Region
|
|
|
|
#Region " CARGA COMBOS "
|
|
|
|
Protected Sub CargaCombos()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetTiposMantenimiento(-1) Then
|
|
DdlTipoMantenimiento.DataSource = ObjAF.DtResultados
|
|
Else
|
|
DdlTipoMantenimiento.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
DdlTipoMantenimiento.DataBind()
|
|
DdlTipoMantenimiento.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
UpFiltro.Update()
|
|
|
|
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "CREAR TABLAS"
|
|
|
|
Private Sub CrearTablas()
|
|
'CveTipoServicioMaterial CveTipoServicio Cantidad CveUM CvePS Tipo
|
|
|
|
Dim DtTempMaterial As New DataTable
|
|
Dim DtTempActividades As New DataTable
|
|
|
|
DtTempMaterial.Columns.Add("CveTipoServicioMaterial", GetType(Integer))
|
|
DtTempMaterial.Columns.Add("CveTipoServicio", GetType(Integer))
|
|
DtTempMaterial.Columns.Add("Cantidad", GetType(Decimal))
|
|
DtTempMaterial.Columns.Add("CveUM", GetType(Integer))
|
|
DtTempMaterial.Columns.Add("CvePS", GetType(Integer))
|
|
DtTempMaterial.Columns.Add("Tipo", GetType(Integer))
|
|
DtTempMaterial.Columns.Add("PS", GetType(String))
|
|
DtTempMaterial.Columns.Add("Abreviatura", GetType(String))
|
|
DtTempMaterial.AcceptChanges()
|
|
|
|
DTMateriales = DtTempMaterial
|
|
|
|
|
|
'CveTipoServicioActividad CveActividad Duracion Observaciones
|
|
|
|
DtTempActividades.Columns.Add("CveTipoServicioActividad", GetType(String))
|
|
DtTempActividades.Columns.Add("CveActividad", GetType(String))
|
|
DtTempActividades.Columns.Add("Duracion", GetType(Decimal))
|
|
DtTempActividades.Columns.Add("Observaciones", GetType(String))
|
|
DtTempActividades.AcceptChanges()
|
|
|
|
DTActividades = DtTempActividades
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
'Protected Sub BtnFiltrar_Click(sender As Object, e As EventArgs)
|
|
' CargaDatos()
|
|
|
|
'End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " GV DATOS "
|
|
|
|
Private Sub CargaDatos()
|
|
|
|
Dim ErrorProceso As Boolean = False
|
|
|
|
Dim ObjAf As New ClsAF
|
|
|
|
If ObjAf.GetTiposServicios(CveTipoServicio, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
|
If ObjAf.DtResultados.Rows.Count > 0 Then
|
|
TxtTipoServicio.Text = ObjAf.DtResultados(0)("Nombre").ToString
|
|
DdlTipoMantenimiento.SelectedValueExist(ObjAf.DtResultados(0)("CveTipoMantenimiento").ToString)
|
|
End If
|
|
|
|
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
ObjAf.Dispose()
|
|
|
|
CargaMateriales()
|
|
CargaActividades()
|
|
CargaCheckList()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaMateriales()
|
|
|
|
If CveTipoServicio > 0 Then
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetTiposServiciosMaterial(-1, CveTipoServicio, UsuarioActual.CveEmpresa) Then
|
|
|
|
DTMateriales = ObjAF.DtResultados
|
|
GvMaterial.DataSource = DTMateriales
|
|
|
|
Else
|
|
GvMaterial = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
GvMaterial.DataBind()
|
|
Else
|
|
GvMaterial.DataSource = DTMateriales
|
|
GvMaterial.DataBind()
|
|
End If
|
|
|
|
UpGvMaterial.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaActividades()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If CveTipoServicio > 0 Then
|
|
|
|
If ObjAF.GetTiposServiciosActividades(-1, CveTipoServicio, -1) Then
|
|
GvActividades.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvActividades.DataSource = Nothing
|
|
End If
|
|
|
|
Else
|
|
If ObjAF.GetActividades(-1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvActividades.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvActividades.DataSource = Nothing
|
|
End If
|
|
End If
|
|
|
|
|
|
ObjAF.Dispose()
|
|
|
|
GvActividades.DataBind()
|
|
UpGvActividades.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaCheckList()
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If CveTipoServicio > 0 Then
|
|
|
|
If ObjAF.GetCheckList(-1, CveTipoServicio, -1, UsuarioActual.CveEmpresa) Then
|
|
GvCheckList.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvCheckList.DataSource = Nothing
|
|
End If
|
|
|
|
Else
|
|
If ObjAF.GetCheckListActividad(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvCheckList.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvCheckList.DataSource = Nothing
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
ObjAF.Dispose()
|
|
|
|
GvCheckList.DataBind()
|
|
UpGvCheckList.Update()
|
|
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")
|
|
|
|
|
|
If e.Row.DataKey("CveCheckListActividad").ToEntero = 0 Then
|
|
|
|
e.Row.FCLiteral("LtlNROW").Text = e.Row.DataKey("CheckListActividadGrupo").ToString
|
|
e.Row.Attributes.Add("style", "background-color:#DDD")
|
|
|
|
Chk.Visible = False
|
|
|
|
|
|
End If
|
|
|
|
|
|
If e.Row.DataKey("CveTipoServicio").ToEntero > 0 Then
|
|
Chk.Checked = True
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Region "DESCARGA EXCEL"
|
|
|
|
'Public Sub ExportToExcelG(Gv1 As GridView, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100, Optional filtros As String = "")
|
|
|
|
|
|
|
|
' For Each GvRow As GridViewRow In Gv1.Rows
|
|
|
|
' Dim IDX_LIMPIAR As Integer = 1
|
|
|
|
' For IDX_LIMPIAR = 1 To 15
|
|
' GvRow.Cells(IDX_LIMPIAR).Text = GvRow.FCTextBox($"TxtMetrica{IDX_LIMPIAR}").Text
|
|
' Next
|
|
|
|
' If GvRow.FCDropDownList("DDLPersonal").SelectedValue.ToEntero > 0 Then
|
|
' GvRow.Cells(16).Text = GvRow.FCDropDownList("DDLPersonal").SelectedItem.Text
|
|
' Else
|
|
' GvRow.Cells(16).Text = ""
|
|
' End If
|
|
|
|
' Next
|
|
|
|
|
|
|
|
' Dim sw1 As New StringWriter()
|
|
' Dim htw1 As New HtmlTextWriter(sw1)
|
|
' Gv1.RenderControl(htw1)
|
|
|
|
' Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault
|
|
' Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString()))
|
|
|
|
' htmlStream1.Position = 0
|
|
' Dim sr1 As New StreamReader(htmlStream1)
|
|
' Dim myStr1 = sr1.ReadToEnd()
|
|
|
|
' sr1.Dispose()
|
|
' htmlStream1.Dispose()
|
|
' sw1.Dispose()
|
|
|
|
' Dim HtmlCompleto As String = myStr1
|
|
|
|
|
|
' HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "")
|
|
|
|
' Dim asd As String = ""
|
|
|
|
|
|
' Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto))
|
|
|
|
' GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet())
|
|
|
|
' Dim excel As GemBox.Spreadsheet.ExcelFile
|
|
|
|
' excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options)
|
|
|
|
' If Usuario IsNot Nothing Then
|
|
' Dim TotalRowHeader As Integer = 8
|
|
' Dim TotalRowFooter As Integer = 2
|
|
|
|
' Dim worksheet = excel.Worksheets(0)
|
|
' worksheet.Rows.InsertEmpty(0, TotalRowHeader)
|
|
' Dim celdasConTexto = worksheet.GetUsedCellRange(True)
|
|
' celdasConTexto.Style.Font.Name = "Calibri Light"
|
|
|
|
' Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex)
|
|
' RangoNombreEmpresa.Merged = True
|
|
' RangoNombreEmpresa.Value = Usuario.Empresa.Empresa
|
|
' RangoNombreEmpresa.Style.Font.Size = 18 * 20
|
|
' RangoNombreEmpresa.Style.Font.Name = "Calibri Light"
|
|
' RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
|
' RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
|
|
|
|
|
' Dim RangoFiltros = worksheet.Cells.GetSubrangeAbsolute(6, celdasConTexto.FirstColumnIndex, 6, celdasConTexto.LastColumnIndex)
|
|
' RangoFiltros.Merged = True
|
|
' RangoFiltros.Value = filtros
|
|
' RangoFiltros.Style.Font.Size = 15 * 20
|
|
' RangoFiltros.Style.Font.Name = "Calibri Light"
|
|
' RangoFiltros.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Left
|
|
' RangoFiltros.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
|
|
|
|
|
' Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
|
|
' RangoTitulo.Merged = True
|
|
' RangoTitulo.Value = Titulo
|
|
' RangoTitulo.Style.Font.Size = 20 * 20
|
|
' RangoTitulo.Style.Font.Name = "Calibri Light"
|
|
' RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
|
' RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
|
|
|
' For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
|
' worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20
|
|
' worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
|
' worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
|
|
|
' worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255))
|
|
' worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)
|
|
|
|
|
|
|
|
|
|
' If i > 0 Then
|
|
' Try
|
|
' worksheet.Columns(i).AutoFit(1)
|
|
' Catch ex As Exception
|
|
' End Try
|
|
' End If
|
|
|
|
' Next
|
|
|
|
' Dim IndexEndTable As Integer = Gv1.Rows.Count + 4 + TotalRowHeader + TotalRowFooter
|
|
|
|
' worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió"
|
|
' worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre
|
|
|
|
' worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión"
|
|
' worksheet.Rows(IndexEndTable + 1).Cells(2).Value = NowADS().ToString("dd/MM/yyyy")
|
|
|
|
' Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta))
|
|
|
|
' If Imagen.Exists Then
|
|
' Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)
|
|
' Using sr As New StreamReader(Ruta)
|
|
' Dim ms As New MemoryStream()
|
|
' sr.BaseStream.CopyTo(ms)
|
|
' worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel)
|
|
' End Using
|
|
' End If
|
|
|
|
' End If
|
|
|
|
|
|
|
|
|
|
' Dim memoryStream As New MemoryStream()
|
|
' excel.Save(memoryStream, SaveOptions.XlsxDefault)
|
|
' ReporteBytes = memoryStream.ToArray()
|
|
' memoryStream.Dispose()
|
|
|
|
'End Sub
|
|
|
|
|
|
'Protected Sub LnkDescargaReporte_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
' Response.ContentType = "application/force-download"
|
|
' Response.AppendHeader("Content-Disposition", $"attachment;filename=RegistroRevision{NowADS().ToString("yyyyMMddmmss")}.xlsx")
|
|
' Response.BinaryWrite(ReporteBytes)
|
|
' Response.End()
|
|
|
|
'End Sub
|
|
|
|
|
|
'Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
Protected Sub LnkAgregarMaterial_Click(sender As Object, e As EventArgs)
|
|
|
|
RegistraScript("$('#ModalMateriales').modal('show');")
|
|
ResetModalMaterial()
|
|
End Sub
|
|
|
|
Private Sub ResetModalMaterial()
|
|
|
|
DdlPS.txtValue.Value = ""
|
|
DdlPS.txtText.Value = ""
|
|
TxtCantidad.Text = ""
|
|
|
|
UpModalMaterialesBody.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Protected Sub BtnGuardarMaterial_Click(sender As Object, e As EventArgs)
|
|
|
|
If DdlPS.txtValue.Value.ToString.ToEntero <= 0 Then
|
|
Alert("Debe seleccionar un producto o servicio", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim CveUnidadMedida As Integer = -1
|
|
Dim CvePS As Integer = DdlPS.txtValue.Value.ToEntero
|
|
Dim Tipo As Integer = -1
|
|
Dim UMAbreviatura As String = ""
|
|
|
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
CveUnidadMedida = drPS("CveUM").ToString.ToEntero
|
|
Tipo = drPS("CveTipoPS").ToString.ToEntero
|
|
UMAbreviatura = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Abreviatura", $"CveUnidadMedida = {CveUnidadMedida}")
|
|
|
|
If CveTipoServicio > 0 Then
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.AddTiposServiciosMaterial(CveTipoServicio, TxtCantidad.Text.ToDecimal, CveUnidadMedida, CvePS, Tipo) Then
|
|
Alert("Material agregado correctamente")
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
Else
|
|
|
|
Dim nRow As DataRow = DTMateriales.NewRow
|
|
|
|
nRow("CveTipoServicioMaterial") = -1
|
|
nRow("CveTipoServicio") = -1
|
|
nRow("Cantidad") = TxtCantidad.Text.ToEntero
|
|
nRow("CveUM") = CveUnidadMedida
|
|
nRow("CvePS") = DdlPS.txtValue.Value.ToEntero
|
|
nRow("Tipo") = Tipo
|
|
nRow("Abreviatura") = UMAbreviatura
|
|
nRow("PS") = DdlPS.txtText.Value
|
|
|
|
DTMateriales.Rows.Add(nRow)
|
|
Alert("Material agregado correctamente")
|
|
|
|
End If
|
|
|
|
CargaMateriales()
|
|
|
|
ResetModalMaterial()
|
|
|
|
RegistraScript("$('#ModalMateriales').modal('hide');")
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminarMaterial_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow)
|
|
If CveTipoServicio > 0 Then
|
|
|
|
|
|
Dim CveTipoServicioMaterial As Integer = GvRow.DataKey("CveTipoServicioMaterial").ToEntero
|
|
|
|
Dim ObjAF As New ClsAF
|
|
If ObjAF.DeleteTiposServiciosMaterial(CveTipoServicioMaterial, UsuarioActual.CveEmpresa) Then
|
|
Alert("Material agregado correctamente")
|
|
End If
|
|
ObjAF.Dispose()
|
|
Else
|
|
|
|
|
|
Dim dr As DataRow = DTMateriales.Rows(GvRow.RowIndex)
|
|
dr.Delete()
|
|
DTMateriales.AcceptChanges()
|
|
Alert("Material agregado correctamente")
|
|
End If
|
|
|
|
CargaMateriales()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjAF As New ClsAF
|
|
Dim ErrorProceso As Boolean = False
|
|
Dim SBError As New StringBuilder
|
|
|
|
ObjAF.IniciaTransacSQL()
|
|
|
|
'validacion?
|
|
|
|
If CveTipoServicio = -1 Then
|
|
|
|
If ObjAF.AddTiposServicios(TxtTipoServicio.Text.Trim, DdlTipoMantenimiento.SelectedValue.ToEntero, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
|
CveTipoServicio = ObjAF.CveTipoServicio
|
|
|
|
For Each GvRow As GridViewRow In GvMaterial.Rows
|
|
|
|
If Not ObjAF.AddTiposServiciosMaterial(CveTipoServicio, GvRow.DataKey("Cantidad").ToDecimal, GvRow.DataKey("CveUM").ToEntero, GvRow.DataKey("CvePS").ToEntero, GvRow.DataKey("Tipo").ToEntero) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
For Each GvRow As GridViewRow In GvActividades.Rows
|
|
|
|
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
Dim Horas As Decimal = GvRow.FCTextBox("TxtHoras").Text.ToDecimal
|
|
|
|
If Chk.Checked Then
|
|
If Not ObjAF.AddTiposServiciosActividades(GvRow.DataKey("CveActividad").ToEntero, CveTipoServicio, Horas, "") Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
For Each GvRow As GridViewRow In GvCheckList.Rows
|
|
|
|
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
Dim CveCheckListActividad As Integer = GvRow.DataKey("CveCheckListActividad").ToEntero
|
|
|
|
If Chk.Checked Then
|
|
If Not ObjAF.AddCheckList(CveTipoServicio, CveCheckListActividad) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
If Not ObjAF.UpdateTiposServicios(CveTipoServicio, TxtTipoServicio.Text.Trim, DdlTipoMantenimiento.SelectedValue.ToEntero, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 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 CveTipoServicioActividad As Integer = GvRow.DataKey("CveTipoServicioActividad").ToEntero
|
|
Dim CveActividad As Integer = GvRow.DataKey("CveActividad").ToEntero
|
|
|
|
Dim Horas As Decimal = GvRow.FCTextBox("TxtHoras").Text.ToDecimal
|
|
|
|
If Chk.Checked Then
|
|
|
|
If CveTipoServicioActividad > 0 Then
|
|
If Not ObjAF.UpdateTiposServiciosActividades(CveTipoServicioActividad, CveActividad, Horas, "") Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
If Not ObjAF.AddTiposServiciosActividades(CveActividad, CveTipoServicio, Horas, "") Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
|
|
If CveTipoServicioActividad > 0 Then
|
|
If Not ObjAF.DeleteTiposServiciosActividades(CveTipoServicioActividad, UsuarioActual.CveEmpresa) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorProceso Then
|
|
|
|
For Each GvRow As GridViewRow In GvCheckList.Rows
|
|
Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
|
|
|
|
If Chk.Visible Then
|
|
|
|
Dim CveTipoServicioTmp As Integer = GvRow.DataKey("CveTipoServicio").ToEntero
|
|
Dim CveCheckList As Integer = GvRow.DataKey("CveCheckList").ToEntero
|
|
Dim CveCheckListActividad As Integer = GvRow.DataKey("CveCheckListActividad").ToEntero
|
|
|
|
If CveTipoServicioTmp > 0 Then
|
|
|
|
If Not Chk.Checked Then
|
|
|
|
If Not ObjAF.DeleteCheckList(CveCheckList) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
|
|
If Chk.Checked Then
|
|
If Not ObjAF.AddCheckList(CveTipoServicio, CveCheckListActividad) Then
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If ErrorProceso Then
|
|
ObjAF.RollBack()
|
|
Else
|
|
ObjAF.Commit()
|
|
Alert("Tipo servicio guardado correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
|
|
ObjAF.Dispose()
|
|
|
|
CargaDatos()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub Chk_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, CheckBox).BindingContainer, GridViewRow)
|
|
'Dim Chk As CheckBox = GvRow.FCCheckBox("Chk")
|
|
|
|
'Dim CveTipoServicioActividad As Integer = GvRow.DataKey("CveTipoServicioActividad").ToEntero
|
|
'Dim CveActividad As Integer = GvRow.DataKey("CveActividad").ToEntero
|
|
|
|
'Dim Horas As Decimal = GvRow.FCTextBox("TxtHoras").Text.ToDecimal
|
|
|
|
'Dim ObjAF As New ClsAF
|
|
|
|
|
|
'If Chk.Checked Then
|
|
|
|
' If CveTipoServicioActividad > 0 Then
|
|
' If ObjAF.UpdateTiposServiciosActividades(CveTipoServicioActividad, CveActividad, Horas, "") Then
|
|
|
|
' End If
|
|
' Else
|
|
' If ObjAF.AddTiposServiciosActividades(CveActividad, CveTipoServicio, Horas, "") Then
|
|
|
|
' End If
|
|
' End If
|
|
|
|
'Else
|
|
|
|
|
|
' If CveTipoServicioActividad > 0 Then
|
|
|
|
' If ObjAF.DeleteTiposServiciosActividades(CveTipoServicioActividad, UsuarioActual.CveEmpresa) Then
|
|
|
|
' End If
|
|
|
|
' End If
|
|
|
|
'End If
|
|
|
|
|
|
'ObjAF.Dispose()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub GvActividades_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim CveTipoServicioActividad As Integer = e.Row.DataKey("CveTipoServicioActividad").ToEntero
|
|
Dim TxtHoras As TextBox = e.Row.FCTextBox("TxtHoras")
|
|
Dim Chk As CheckBox = e.Row.FCCheckBox("Chk")
|
|
|
|
If CveTipoServicioActividad > 0 Then
|
|
|
|
Chk.Checked = True
|
|
TxtHoras.Text = e.Row.DataKey("Duracion")
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
End Class
|