AF Pendientes, entradaSalida
This commit is contained in:
513
AF/AF.aspx.vb
513
AF/AF.aspx.vb
@@ -245,6 +245,31 @@ Partial Class AF_AF
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
Private Property CveProduccion As Integer
|
||||
Get
|
||||
If ViewState("CveProduccion") Is Nothing Then
|
||||
ViewState("CveProduccion") = -1
|
||||
End If
|
||||
Return ViewState("CveProduccion").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveProduccion") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveMantenimiento As Integer
|
||||
Get
|
||||
If ViewState("CveMantenimiento") Is Nothing Then
|
||||
ViewState("CveMantenimiento") = -1
|
||||
End If
|
||||
Return ViewState("CveMantenimiento").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveMantenimiento") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
@@ -260,9 +285,11 @@ Partial Class AF_AF
|
||||
ViewState("CveActivoFijo") = Request("CveActivoFijo")
|
||||
CargaDatos()
|
||||
CargaEventos()
|
||||
CargaActividades()
|
||||
|
||||
'Configuración de Modalidad Update
|
||||
CargaActividades()
|
||||
CargaProduccion()
|
||||
CargaMantenimento()
|
||||
|
||||
'Configuración de Modalidad Update
|
||||
BtnGuardar.Text = "Guardar Cambios"
|
||||
LtlTitulo.Text = "Consulta del Activo Fijo:"
|
||||
|
||||
@@ -271,8 +298,9 @@ Partial Class AF_AF
|
||||
HlEvento.NavigateUrl = String.Format("/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveActivoFijo=" & CveActivoFijo & "&TB_iframe=true&height=370&width=600;")
|
||||
Else
|
||||
ViewState("CveActivoFijo") = -1
|
||||
CargaCombos()
|
||||
'Configuración de Modalidad Insert
|
||||
CargaCombos()
|
||||
|
||||
'Configuración de Modalidad Insert
|
||||
ImgAddObs.Visible = False
|
||||
LblFechaCaptura.Text = Now.ToShortDateString()
|
||||
LblUsuarioCapturo.Text = UsuarioActual.Usuario
|
||||
@@ -288,6 +316,13 @@ Partial Class AF_AF
|
||||
|
||||
CargaAFInv()
|
||||
cargaOrdenesdeservicio()
|
||||
|
||||
|
||||
|
||||
If Request("Op") IsNot Nothing Then
|
||||
ModalidadesPaginaAF(Request("Op").ToString)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Private Sub cargaOrdenesdeservicio()
|
||||
@@ -373,6 +408,20 @@ Partial Class AF_AF
|
||||
CveEmpresaActual = UsuarioActual.CveEmpresa
|
||||
End Sub
|
||||
|
||||
Private Sub ModalidadesPaginaAF(Op As String)
|
||||
|
||||
Select Case Op
|
||||
Case "AR" 'Arbol Frutal etc
|
||||
LblFechaCompra.Text = "Fecha de Nacimiento"
|
||||
LblFechaBaja.Text = "Fecha de Muerte"
|
||||
TabProduccion.Visible = True
|
||||
Exit Select
|
||||
Case Else
|
||||
Exit Select
|
||||
End Select
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
#Region " CARGA COMBOS "
|
||||
Private Sub CargaCombos()
|
||||
@@ -398,6 +447,8 @@ Partial Class AF_AF
|
||||
DdlResponsable.Enabled = False
|
||||
End If
|
||||
|
||||
CargaCultivos()
|
||||
|
||||
End Sub
|
||||
Private Sub CargaTipoActivoFijo()
|
||||
DdlTipoActivoFijo.DataSource = GlobalDTTipoActivoFijo(CveEmpresaActual).FiltraParametros("", "TipoActivoFijo")
|
||||
@@ -476,6 +527,11 @@ Partial Class AF_AF
|
||||
' DdlClientes.DataBind()
|
||||
'End Sub
|
||||
|
||||
Private Sub CargaCultivos()
|
||||
DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}")
|
||||
DdlModalCultivosCuadro.DataBind()
|
||||
DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
||||
End Sub
|
||||
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
||||
CargaSubProyecto()
|
||||
End Sub
|
||||
@@ -562,6 +618,13 @@ Partial Class AF_AF
|
||||
DdlModelos.DataBind()
|
||||
DdlModelos.Items.Insert(0, New ListItem("-", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaProduccionCuadros()
|
||||
DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}")
|
||||
DdlModalCultivosCuadro.DataBind()
|
||||
DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
Private Sub CargaDatos()
|
||||
@@ -579,7 +642,13 @@ Partial Class AF_AF
|
||||
TxtDescripcion.Text = ObjActivoFijo.Descripcion
|
||||
TxtCodigo.Text = ObjActivoFijo.Codigo
|
||||
TxtValorCompra.Text = ObjActivoFijo.ValorCompra.ToString.FormatoNumero
|
||||
TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString
|
||||
TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString
|
||||
|
||||
|
||||
|
||||
TxtFechaBaja.Text = If(ObjActivoFijo.FechaBaja = New Date(1900, 1, 1), "", ObjActivoFijo.FechaBaja.ToString("dd/MM/yyyy"))
|
||||
|
||||
|
||||
DdlTipoActivoFijo.SelectedValue = ObjActivoFijo.CveTipoActivoFijo.ToString
|
||||
CargaSubTipoActivoFijo()
|
||||
DdlSubTipoActivoFijo.SelectedValue = ObjActivoFijo.CveSubTipoActivoFijo.ToString
|
||||
@@ -654,8 +723,8 @@ Partial Class AF_AF
|
||||
|
||||
CargaPlacas()
|
||||
CargaLicencias()
|
||||
CargaSeguros()
|
||||
CargaServicios()
|
||||
CargaSeguros()
|
||||
|
||||
CargaFallas()
|
||||
CargaAccidentes()
|
||||
|
||||
@@ -1062,31 +1131,22 @@ Partial Class AF_AF
|
||||
#End Region
|
||||
|
||||
#Region "S E R V I C I O S - M A N T E M I E N T O"
|
||||
Public Sub CargaServicios()
|
||||
Dim TmpServicios As New DataTable
|
||||
TmpServicios.Columns.Add("CveProveedor", GetType(Integer))
|
||||
TmpServicios.Columns.Add("CveCompra", GetType(Integer))
|
||||
TmpServicios.Columns.Add("Tipo", GetType(String))
|
||||
TmpServicios.Columns.Add("Fecha", GetType(Date))
|
||||
TmpServicios.Columns.Add("Proveedor", GetType(String))
|
||||
TmpServicios.Columns.Add("Factura", GetType(String))
|
||||
TmpServicios.Columns.Add("OdHorometro", GetType(Double))
|
||||
TmpServicios.Columns.Add("Observaciones", GetType(String))
|
||||
|
||||
'Dim Row As DataRow = TmpServicios.NewRow
|
||||
'Row("CveProveedor") = 3100
|
||||
'Row("CveCompra") = 181656
|
||||
'Row("Tipo") = "Preventivo"
|
||||
'Row("Fecha") = "01/02/2016"
|
||||
'Row("Proveedor") = "EMPRESAS MATCO, S.A. DE C.V."
|
||||
'Row("Factura") = "HERAA-158591"
|
||||
'Row("OdHorometro") = "198,567"
|
||||
'Row("Observaciones") = "Servicio Preventivo 200,000 Kilometros - Servicio Completo"
|
||||
'TmpServicios.Rows.Add(Row)
|
||||
|
||||
GvServiciosMant.DataSource = TmpServicios
|
||||
GvServiciosMant.DataBind()
|
||||
End Sub
|
||||
'Public Sub CargaServicios()
|
||||
' Dim TmpServicios As New DataTable
|
||||
' TmpServicios.Columns.Add("CveProveedor", GetType(Integer))
|
||||
' TmpServicios.Columns.Add("CveCompra", GetType(Integer))
|
||||
' TmpServicios.Columns.Add("Tipo", GetType(String))
|
||||
' TmpServicios.Columns.Add("Fecha", GetType(Date))
|
||||
' TmpServicios.Columns.Add("Proveedor", GetType(String))
|
||||
' TmpServicios.Columns.Add("Factura", GetType(String))
|
||||
' TmpServicios.Columns.Add("OdHorometro", GetType(Double))
|
||||
' TmpServicios.Columns.Add("Observaciones", GetType(String))
|
||||
|
||||
|
||||
|
||||
' GvServiciosMant.DataSource = TmpServicios
|
||||
' GvServiciosMant.DataBind()
|
||||
'End Sub
|
||||
#End Region
|
||||
|
||||
#Region "F A L L A S"
|
||||
@@ -2106,6 +2166,8 @@ Partial Class AF_AF
|
||||
Dim ObjContabilidad As New ClsContabilidad(ObjAF.IniciaTransacSQL())
|
||||
Dim ErrorGuardar As Boolean = False
|
||||
|
||||
Dim FechaBaja As Date = If(TxtFechaBaja.Text = "", MinFecha, TxtFechaBaja.Text.ToDate)
|
||||
|
||||
If CveActivoFijo <= 0 Then
|
||||
|
||||
'SALIDA DE ALMACEN PARA IMPORTACION
|
||||
@@ -2123,12 +2185,15 @@ Partial Class AF_AF
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
If Not ErrorGuardar Then
|
||||
If ObjAF.AddActivosFijos(TxtCodigo.Text.Trim, TxtDescripcion.Text.Trim, TxtValorCompra.Text.Trim.ToDouble, TxtFechaCompra.Text.Trim.ToDate, DdlSubTipoActivoFijo.SelectedValue.ToEntero,
|
||||
DdlResponsable.SelectedValue.ToEntero, TxtNoSerie.Text.Trim, TxtAño.Text.Trim.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.Trim.ToEntero,
|
||||
DdlEstadoActivoFijo.SelectedValue.ToEntero, DdlCtaContableDepreciacion.SelectedValue.ToEntero, TxtPorDepreciacion.Text.Trim.ToDouble,
|
||||
TxtObservaciones.Text.Trim, DdlClientes.SelectedValue.ToEntero, CveMovimientoSalidaInv, UsuarioActual.CveUsuario, CveEmpresaActual, CveMarca:=DdlMarcas.SelectedValue.ToEntero,
|
||||
CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero) > 0 Then
|
||||
TxtObservaciones.Text.Trim, Ddlclientes.SelectedValue.ToEntero, CveMovimientoSalidaInv, UsuarioActual.CveUsuario, CveEmpresaActual, CveMarca:=DdlMarcas.SelectedValue.ToEntero,
|
||||
CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero,
|
||||
FechaBaja:=FechaBaja) > 0 Then
|
||||
ViewState("CveActivoFijo") = ObjAF.CveActivoFijo
|
||||
Else
|
||||
ErrorGuardar = True
|
||||
@@ -2155,8 +2220,9 @@ Partial Class AF_AF
|
||||
If Not ObjAF.UpdateActivosFijos(CveActivoFijo.ToString.ToEntero, TxtCodigo.Text.Trim, TxtDescripcion.Text.Trim, TxtValorCompra.Text.Trim.ToDouble, TxtFechaCompra.Text.Trim.ToDate, DdlSubTipoActivoFijo.SelectedValue.ToEntero,
|
||||
DdlResponsable.SelectedValue.ToEntero, TxtNoSerie.Text.Trim, TxtAño.Text.Trim.ToEntero,
|
||||
DdlSubProyecto.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.Trim.ToEntero, DdlEstadoActivoFijo.SelectedValue.ToEntero, DdlCtaContableDepreciacion.SelectedValue.ToEntero,
|
||||
TxtPorDepreciacion.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, DdlClientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, CveEmpresaActual,
|
||||
CveMarca:=DdlMarcas.SelectedValue.ToEntero, CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero) Then
|
||||
TxtPorDepreciacion.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, Ddlclientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, CveEmpresaActual,
|
||||
CveMarca:=DdlMarcas.SelectedValue.ToEntero, CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero,
|
||||
FechaBaja:=FechaBaja) Then
|
||||
|
||||
'Comentado porque te redirecciona no se ocupa - 22 Enero 2016 - Israel Piña
|
||||
'CargaDatos()
|
||||
@@ -3097,7 +3163,8 @@ Partial Class AF_AF
|
||||
|
||||
TxtDescripcion.Text = DdlAFInvPS.SelectedText
|
||||
TxtValorCompra.Text = Costo.FormatoNumero
|
||||
TxtFechaCompra.Text = Now.ToShortDateString
|
||||
TxtFechaCompra.Text = Now.ToShortDateString
|
||||
TxtFechaBaja.Text = ""
|
||||
TxtNoSerie.Text = TxtAFInvSerie.Text.Trim
|
||||
|
||||
TxtValorCompra.Enabled = False
|
||||
@@ -3727,5 +3794,373 @@ Partial Class AF_AF
|
||||
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepComprasInsumos.rdlc", DTCompras, params, "RepComprasInsumos", Formato)
|
||||
|
||||
End Sub
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "Produccion"
|
||||
|
||||
|
||||
|
||||
Private Sub CargaProduccion()
|
||||
|
||||
Dim ObjAF As New ClsAF
|
||||
|
||||
If ObjAF.GetProduccion(CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
||||
GvProduccion.DataSource = ObjAF.DtResultados
|
||||
Else
|
||||
GvProduccion.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjAF.Dispose()
|
||||
GvProduccion.DataBind()
|
||||
|
||||
UpProduccion.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub LnkAgregarProduccion_Click(sender As Object, e As EventArgs)
|
||||
|
||||
LblModaProduccionTitulo.Text = "Agregar Producción"
|
||||
LnkModalAgregarProduccion.Text = "Agregar"
|
||||
CveProduccion = -1
|
||||
|
||||
DdlModalCultivosCuadro.SelectedValueExist(-1)
|
||||
TxtModalProduccionCantidad.Text = ""
|
||||
TxtModalProduccionFecha.Text = ""
|
||||
|
||||
RegistraScript("$('#DVModalProduccion').modal('show');")
|
||||
|
||||
UpModalProduccion.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkGvProduccionEdit_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
CveProduccion = GvRow.DataKey("CveProduccion").ToEntero
|
||||
Dim CveCultivoCuadroDetalle As Integer = GvRow.DataKey("CveCultivoCuadroDetalle").ToEntero
|
||||
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
|
||||
Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate
|
||||
|
||||
DdlModalCultivosCuadro.SelectedValueExist(CveCultivoCuadroDetalle)
|
||||
TxtModalProduccionCantidad.Text = Cantidad.ToString("###,###,###.00")
|
||||
TxtModalProduccionFecha.Text = Fecha.ToString("dd/MM/yyyy")
|
||||
|
||||
|
||||
LblModaProduccionTitulo.Text = "Actualizar Producción"
|
||||
LnkModalAgregarProduccion.Text = "Actualizar"
|
||||
|
||||
UpModalProduccion.Update()
|
||||
|
||||
|
||||
RegistraScript("$('#DVModalProduccion').modal('show');")
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkGvProduccionRemove_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim ErrorProceso As Boolean = False
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveProduccionEliminar As Integer = GvRow.DataKey("CveProduccion").ToEntero
|
||||
|
||||
Dim ObjAF As New ClsAF
|
||||
|
||||
If ObjAF.RemoveProduccion(CveProduccionEliminar, UsuarioActual.CveEmpresa) Then
|
||||
ErrorProceso = False
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
|
||||
|
||||
ObjAF.Dispose()
|
||||
|
||||
|
||||
If Not ErrorProceso Then
|
||||
Alert("Producción Eliminada Correctamente.")
|
||||
CargaProduccion()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Protected Sub LnkModalAgregarProduccion_Click(sender As Object, e As EventArgs)
|
||||
Dim ErrorProceso As Boolean = False
|
||||
Dim ObjAF As New ClsAF
|
||||
|
||||
If CveProduccion > 0 Then
|
||||
If ObjAF.UpdateProduccion(CveProduccion, CveActivoFijo, DdlModalCultivosCuadro.SelectedValue.ToEntero, TxtModalProduccionCantidad.Text.ToDecimal, TxtModalProduccionFecha.Text.ToDate, UsuarioActual.CveUsuario) Then
|
||||
ErrorProceso = False
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
Else
|
||||
If ObjAF.AddProduccion(CveActivoFijo, DdlModalCultivosCuadro.SelectedValue.ToEntero, TxtModalProduccionCantidad.Text.ToDecimal, TxtModalProduccionFecha.Text.ToDate, UsuarioActual.CveUsuario) Then
|
||||
ErrorProceso = False
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
ObjAF.Dispose()
|
||||
|
||||
If Not ErrorProceso Then
|
||||
RegistraScript("$('#DVModalMantenimiento').modal('hide');")
|
||||
Alert("Producción Agregada Correctamente.")
|
||||
CargaProduccion()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "MANTENIMIENTO"
|
||||
|
||||
|
||||
|
||||
|
||||
Private Sub CargaMantenimento()
|
||||
|
||||
Dim ObjAF As New ClsAF
|
||||
|
||||
If ObjAF.GetMantenimientos(CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
||||
GvMantenimientos.DataSource = ObjAF.DtResultados
|
||||
Else
|
||||
GvMantenimientos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjAF.Dispose()
|
||||
GvMantenimientos.DataBind()
|
||||
|
||||
UpMantenimientos.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub LnkAgregarMantenimiento_Click(sender As Object, e As EventArgs)
|
||||
|
||||
LblModaMantenimientoTitulo.Text = "Agregar Mantenimiento"
|
||||
LnkModalAgregarMantenimiento.Text = "Agregar"
|
||||
|
||||
CveMantenimiento = -1
|
||||
|
||||
TxtModalMantenimiento.Text = ""
|
||||
TxtModalMantenimientoObservaciones.Text = ""
|
||||
TxtModalMantenimientoFecha.Text = ""
|
||||
TxtArchivoMantenimiento.Text = "[]"
|
||||
|
||||
RegistraScript("$('#DVModalMantenimiento').modal('show');")
|
||||
|
||||
UpModalMantenimiento.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkGvMantenimientoEdit_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
'CveMantenimiento, CveActivoFijo, Mantenimiento, Observaciones, Fecha, FechaIng, CveUsuario, Codigo, Descripcion, Usuario
|
||||
|
||||
CveMantenimiento = GvRow.DataKey("CveMantenimiento").ToEntero
|
||||
|
||||
Dim Mantenimiento As String = GvRow.DataKey("Mantenimiento")
|
||||
Dim Observaciones As String = GvRow.DataKey("Observaciones")
|
||||
Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate
|
||||
|
||||
TxtModalMantenimiento.Text = Mantenimiento
|
||||
TxtModalMantenimientoObservaciones.Text = Observaciones
|
||||
TxtModalMantenimientoFecha.Text = Fecha.ToString("dd/MM/yyyy")
|
||||
TxtArchivoMantenimiento.Text = "[]"
|
||||
|
||||
|
||||
LblModaMantenimientoTitulo.Text = "Actualizar Mantenimiento"
|
||||
LnkModalAgregarMantenimiento.Text = "Actualizar"
|
||||
|
||||
UpModalMantenimiento.Update()
|
||||
|
||||
|
||||
RegistraScript("$('#DVModalMantenimiento').modal('show');")
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkGvMantenimientoRemove_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim ErrorProceso As Boolean = False
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveMantenimientoEliminar As Integer = GvRow.DataKey("CveMantenimiento").ToEntero
|
||||
|
||||
Dim ObjAF As New ClsAF
|
||||
|
||||
If ObjAF.RemoveMantenimientos(CveMantenimientoEliminar, UsuarioActual.CveEmpresa) Then
|
||||
ErrorProceso = False
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
|
||||
|
||||
ObjAF.Dispose()
|
||||
|
||||
|
||||
If Not ErrorProceso Then
|
||||
Alert("Mantenimiento Eliminado Correctamente.")
|
||||
CargaMantenimento()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Protected Sub LnkModalAgregarMantenimiento_Click(sender As Object, e As EventArgs)
|
||||
Dim ErrorProceso As Boolean = False
|
||||
Dim ObjAF As New ClsAF
|
||||
ObjAF.IniciaTransacSQL()
|
||||
|
||||
|
||||
If CveMantenimiento > 0 Then
|
||||
|
||||
Dim FileExtension As String = ""
|
||||
Dim Filesgral As List(Of Archivo) = TxtArchivoMantenimiento.getfiles().Archivos
|
||||
Dim Filename As String = "-1"
|
||||
|
||||
If Filesgral.Count > 0 Then
|
||||
|
||||
For Each fileItem As Archivo In Filesgral
|
||||
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
||||
Filename = fileItem.filename
|
||||
Exit For
|
||||
Next
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Mantenimientos\{1}", UsuarioActual.Empresa.Ruta, $"{CveMantenimiento}.{FileExtension}"))
|
||||
If Archivo.Exists() Then
|
||||
Archivo.Delete()
|
||||
End If
|
||||
|
||||
|
||||
If Not Filename.FilesMove(String.Format("{0}", CveMantenimiento.ToString), String.Format("{0}AF\Mantenimientos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Then
|
||||
ErrorProceso = True
|
||||
Alert("Error al mover Archivo", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If Not ErrorProceso Then
|
||||
If Not ObjAF.UpdateMantenimientos(CveMantenimiento, CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, $"{CveMantenimiento}.{FileExtension}") Then
|
||||
ErrorProceso = True
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
|
||||
|
||||
Dim CveMantenimientoTemp As Integer = -1
|
||||
|
||||
|
||||
CveMantenimientoTemp = ObjAF.AddMantenimientos(CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, "-1")
|
||||
If CveMantenimientoTemp > 0 Then
|
||||
ErrorProceso = False
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
|
||||
If Not ErrorProceso Then
|
||||
|
||||
Dim FileExtension As String = ""
|
||||
Dim Filesgral As List(Of Archivo) = TxtArchivoMantenimiento.getfiles().Archivos
|
||||
Dim Filename As String = ""
|
||||
|
||||
If Filesgral.Count > 0 Then
|
||||
|
||||
For Each fileItem As Archivo In Filesgral
|
||||
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
||||
Filename = fileItem.filename
|
||||
Exit For
|
||||
Next
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Mantenimientos\{1}", UsuarioActual.Empresa.Ruta, $"{CveMantenimientoTemp}.{FileExtension}"))
|
||||
If Archivo.Exists() Then
|
||||
Archivo.Delete()
|
||||
End If
|
||||
|
||||
|
||||
If Not Filename.FilesMove(String.Format("{0}", CveMantenimientoTemp.ToString), String.Format("{0}AF\Mantenimientos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Then
|
||||
ErrorProceso = True
|
||||
Alert("Error al mover Archivo", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
If Not ErrorProceso Then
|
||||
If Not ObjAF.UpdateMantenimientos(CveMantenimientoTemp, CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, $"{CveMantenimientoTemp}.{FileExtension}") Then
|
||||
ErrorProceso = True
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
If Not ErrorProceso Then
|
||||
ObjAF.Commit()
|
||||
ObjAF.Dispose()
|
||||
|
||||
RegistraScript("$('#DVModalMantenimiento').modal('hide');")
|
||||
Alert("Mantenimiento Guardado Correctamente.")
|
||||
CargaMantenimento()
|
||||
Else
|
||||
ObjAF.RollBack()
|
||||
ObjAF.Dispose()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkDescargaArcgivo_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim Archivo As String = GvRow.DataKey("Archivo")
|
||||
Dim InfArchivo As New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}")
|
||||
|
||||
If InfArchivo.Exists Then
|
||||
Response.Clear()
|
||||
Response.AppendHeader("Content-Disposition", "attachment; filename=" + InfArchivo.Name)
|
||||
Response.AppendHeader("Content-Length", InfArchivo.Length.ToString())
|
||||
Response.ContentType = "application/octet-stream"
|
||||
Response.WriteFile(InfArchivo.FullName)
|
||||
|
||||
Response.End()
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub GvMantenimientos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
Dim Archivo As String = e.Row.DataKey("Archivo")
|
||||
Dim InfArchivo As New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}")
|
||||
|
||||
If InfArchivo.Exists Then
|
||||
e.Row.FCLinkButton("LnkDescargaArcgivo").Visible = True
|
||||
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkDescargaArcgivo"))
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user