4872 lines
210 KiB
VB.net
4872 lines
210 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports System.Data
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports ZXing
|
|
Imports Newtonsoft.Json.Linq
|
|
|
|
Partial Class AF_AF
|
|
Inherits ClsPaginas
|
|
|
|
'Configuración
|
|
#Region "PROPIEDADES"
|
|
Private Property CveActivoFijo As Integer
|
|
Get
|
|
|
|
If ViewState("CveActivoFijo") Is Nothing Then
|
|
ViewState("CveActivoFijo") = -1
|
|
End If
|
|
Return ViewState("CveActivoFijo").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveActivoFijo") = value
|
|
End Set
|
|
End Property
|
|
Private Property CodigoAF As String
|
|
Get
|
|
If ViewState("CodigoAF") Is Nothing Then
|
|
ViewState("CodigoAF") = ""
|
|
End If
|
|
Return ViewState("CodigoAF").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("CodigoAF") = value
|
|
End Set
|
|
End Property
|
|
Private Property AutoFolioAF As Integer
|
|
Get
|
|
Return ViewState("AutoFolioAF").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("AutoFolioAF") = value
|
|
End Set
|
|
End Property
|
|
Private Property UltimaFecha As Date
|
|
Get
|
|
Return ViewState("UltimaFecha").ToString.ToDate
|
|
End Get
|
|
Set(value As Date)
|
|
ViewState("UltimaFecha") = value
|
|
End Set
|
|
End Property
|
|
Private Property UltimoHodometro As Integer
|
|
Get
|
|
Return ViewState("UltimoHodometro").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("UltimoHodometro") = value
|
|
End Set
|
|
End Property
|
|
Private ReadOnly Property ImgConsecutivo As String
|
|
Get
|
|
Return ViewState("ImgConsecutivo").ToString
|
|
End Get
|
|
End Property
|
|
Private Property CaracClasif As String
|
|
Get
|
|
Return ViewState("CaracClasif").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("CaracClasif") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveEmpresaActual As Integer
|
|
Get
|
|
Return ViewState("CveEmpresaActual").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveEmpresaActual") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveResguardoPadre As Integer
|
|
Get
|
|
Return ViewState("CveResguardoPadre").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveResguardoPadre") = value
|
|
End Set
|
|
End Property
|
|
Private Property EsURL2 As Boolean
|
|
Get
|
|
Return CType(ViewState("EsURL2"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsURL2") = value
|
|
End Set
|
|
End Property
|
|
Private Property AFInvCvePS As Integer
|
|
Get
|
|
Return If(ViewState("AFInvCvePS") Is Nothing, -1, ViewState("AFInvCvePS").ToString.ToEntero())
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("AFInvCvePS") = value
|
|
End Set
|
|
End Property
|
|
Private Property AFInvCveAlmacen As Integer
|
|
Get
|
|
Return If(ViewState("AFInvCveAlmacen") Is Nothing, -1, ViewState("AFInvCveAlmacen").ToString.ToEntero())
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("AFInvCveAlmacen") = value
|
|
End Set
|
|
End Property
|
|
Private Property AFInvCveSeccionAlmacen As Integer
|
|
Get
|
|
Return If(ViewState("AFInvCveSeccionAlmacen") Is Nothing, -1, ViewState("AFInvCveSeccionAlmacen").ToString.ToEntero())
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("AFInvCveSeccionAlmacen") = value
|
|
End Set
|
|
End Property
|
|
Private Property AFInvSerie As String
|
|
Get
|
|
Return If(ViewState("AFInvSerie") Is Nothing, "", ViewState("AFInvSerie").ToString())
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("AFInvSerie") = value
|
|
End Set
|
|
End Property
|
|
Private Property Placas As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("Placas")), Nothing, CType(ViewState("Placas"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("Placas") = value
|
|
End Set
|
|
End Property
|
|
Private Property Licencias As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("Licencias")), Nothing, CType(ViewState("Licencias"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("Licencias") = value
|
|
End Set
|
|
End Property
|
|
Private Property Polizas As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("Polizas")), Nothing, CType(ViewState("Polizas"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("Polizas") = value
|
|
End Set
|
|
End Property
|
|
Private Property Eventos As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("Eventos")), Nothing, CType(ViewState("Eventos"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("Eventos") = value
|
|
End Set
|
|
End Property
|
|
Private Property AFHijos As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("AFHijos")), Nothing, CType(ViewState("AFHijos"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("AFHijos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTGrupos As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("DTGrupos")), Nothing, CType(ViewState("DTGrupos"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTGrupos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTCompras As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("DTCompras")), Nothing, CType(ViewState("DTCompras"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTCompras") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
#Region "CLASIFICACIONES"
|
|
|
|
Private Property DTAFCaracteristicas As DataTable
|
|
Get
|
|
Return CType(ViewState("DTAFCaracteristicas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTAFCaracteristicas") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveCaracteristica As Integer
|
|
Get
|
|
Return ViewState("CveCaracteristica").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCaracteristica") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
|
|
#Region "G P S"
|
|
Public Property CveClienteGPS As Integer
|
|
Get
|
|
Return IfNull(ViewState("CveClienteGPS"), -1).ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClienteGPS") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Offset() As Integer
|
|
Get
|
|
Return DirectCast(IfNull(ViewState("Offset"), 0), Integer)
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
ViewState("Offset") = value
|
|
End Set
|
|
End Property
|
|
Public ReadOnly Property FechaClienteGPS() As DateTime
|
|
Get
|
|
Return DateTime.UtcNow.AddMinutes(10).AddMinutes(Offset)
|
|
End Get
|
|
End Property
|
|
|
|
Private Property DTCargas As DataTable
|
|
Get
|
|
Return CType(ViewState("DTCargas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTCargas") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTDescargas As DataTable
|
|
Get
|
|
Return CType(ViewState("DTDescargas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDescargas") = value
|
|
End Set
|
|
End Property
|
|
|
|
#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 IndexProduccion As Integer
|
|
Get
|
|
If ViewState("IndexProduccion") Is Nothing Then
|
|
ViewState("IndexProduccion") = -1
|
|
End If
|
|
Return ViewState("IndexProduccion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexProduccion") = 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
|
|
|
|
|
|
Private Property IndexMantenimiento As Integer
|
|
Get
|
|
If ViewState("IndexMantenimiento") Is Nothing Then
|
|
ViewState("IndexMantenimiento") = -1
|
|
End If
|
|
Return ViewState("IndexMantenimiento").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexMantenimiento") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CvePlagaEnfermedad As Integer
|
|
Get
|
|
If ViewState("CvePlagaEnfermedad") Is Nothing Then
|
|
ViewState("CvePlagaEnfermedad") = -1
|
|
End If
|
|
Return ViewState("CvePlagaEnfermedad").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePlagaEnfermedad") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property IndexPlagaEnfermedad As Integer
|
|
Get
|
|
If ViewState("IndexPlagaEnfermedad") Is Nothing Then
|
|
ViewState("IndexPlagaEnfermedad") = -1
|
|
End If
|
|
Return ViewState("IndexPlagaEnfermedad").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexPlagaEnfermedad") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
Private Property DT_Produccion As DataTable
|
|
Get
|
|
If ViewState("DT_Produccion") Is Nothing Then
|
|
ViewState("DT_Produccion") = CreaDTProduccion()
|
|
End If
|
|
Return DirectCast(ViewState("DT_Produccion"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DT_Produccion") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DT_PlgaEfermedad As DataTable
|
|
Get
|
|
If ViewState("DT_PlgaEfermedad") Is Nothing Then
|
|
ViewState("DT_PlgaEfermedad") = CreaDTPlagaEngermedad()
|
|
End If
|
|
Return DirectCast(ViewState("DT_PlgaEfermedad"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DT_PlgaEfermedad") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DT_Mantenimiento As DataTable
|
|
Get
|
|
If ViewState("DT_Mantenimiento") Is Nothing Then
|
|
ViewState("DT_Mantenimiento") = CreaDTMantenimiento()
|
|
End If
|
|
Return DirectCast(ViewState("DT_Mantenimiento"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DT_Mantenimiento") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
InicializaValores()
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso (UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.UsaContabilidad) Then
|
|
CargaCuentasContables()
|
|
End If
|
|
|
|
CargaCombos()
|
|
|
|
If Request("CveActivoFijo") IsNot Nothing AndAlso IsNumeric(Request("CveActivoFijo")) AndAlso Request("CveActivoFijo").ToEntero > 0 Then
|
|
ViewState("CveActivoFijo") = Request("CveActivoFijo")
|
|
CargaDatos()
|
|
CargaEventos()
|
|
CargaActividades()
|
|
CargaProduccion()
|
|
CargaMantenimento()
|
|
CargaPlagaEnfermedad()
|
|
ModalidadesPaginaAF()
|
|
|
|
'Configuración de Modalidad Update
|
|
BtnGuardar.Text = "Guardar Cambios"
|
|
LtlTitulo.Text = "Consulta del Activo Fijo:"
|
|
|
|
If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero
|
|
HlEvento.Visible = True
|
|
HlEvento.NavigateUrl = String.Format("/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveActivoFijo=" & CveActivoFijo & "&TB_iframe=true&height=370&width=600;")
|
|
Else
|
|
ViewState("CveActivoFijo") = -1
|
|
|
|
|
|
'Configuración de Modalidad Insert
|
|
ImgAddObs.Visible = False
|
|
LblFechaCaptura.Text = Now.ToShortDateString()
|
|
LblUsuarioCapturo.Text = UsuarioActual.Usuario
|
|
|
|
BtnEliminar.Visible = False
|
|
CargaAFPadres()
|
|
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.UsaContabilidad Then
|
|
ActivarRegistroCuentaAF()
|
|
End If
|
|
|
|
CargaAFInv()
|
|
cargaOrdenesdeservicio()
|
|
|
|
|
|
|
|
If Request("Op") IsNot Nothing Then
|
|
ModalidadesPaginaAFInicial(Request("Op").ToString)
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
Private Sub cargaOrdenesdeservicio()
|
|
Dim dt As New DataTable()
|
|
dt.Columns.Add("Folio", GetType(String))
|
|
dt.Columns.Add("Fecha", GetType(Date))
|
|
dt.Columns.Add("Obra", GetType(String))
|
|
dt.Columns.Add("TipodeServicio", GetType(String))
|
|
dt.Columns.Add("Servicio", GetType(String))
|
|
dt.Columns.Add("Estatus", GetType(String))
|
|
dt.Columns.Add("Duracion", GetType(String))
|
|
dt.Columns.Add("Atendio", GetType(String))
|
|
|
|
Dim dr As DataRow = dt.NewRow()
|
|
dr("Folio") = "101"
|
|
dr("Fecha") = "2019/08/23"
|
|
dr("Obra") = "Ganaderos"
|
|
dr("TipodeServicio") = "Preventivo"
|
|
dr("Servicio") = "100 Hrs"
|
|
dr("Estatus") = "Terminada"
|
|
dr("Duracion") = "5 Hrs"
|
|
dr("Atendio") = "Juan perez"
|
|
dt.Rows.Add(dr)
|
|
dr = dt.NewRow()
|
|
dr("Folio") = "190"
|
|
dr("Fecha") = "2019/09/30"
|
|
dr("Obra") = "Ganaderos"
|
|
dr("TipodeServicio") = "Preventivo"
|
|
dr("Servicio") = "200 Hrs"
|
|
dr("Estatus") = "Terminada"
|
|
dr("Duracion") = "5 hrs"
|
|
dr("Atendio") = "Ernesto Lopez"
|
|
dt.Rows.Add(dr)
|
|
dr = dt.NewRow()
|
|
dr("Folio") = "501"
|
|
dr("Fecha") = "2019/11/30"
|
|
dr("Obra") = "Vildósola"
|
|
dr("TipodeServicio") = "Preventivo"
|
|
dr("Servicio") = "400 Hrs"
|
|
dr("Estatus") = "Terminada"
|
|
dr("Duracion") = "8 hrs"
|
|
dr("Atendio") = "Juan perez"
|
|
dt.Rows.Add(dr)
|
|
dr = dt.NewRow()
|
|
dr("Folio") = "505"
|
|
dr("Fecha") = "2019/12/14"
|
|
dr("Obra") = "Vildósola"
|
|
dr("TipodeServicio") = "Correctivo"
|
|
dr("Servicio") = "Rep. Mayor motor"
|
|
dr("Estatus") = "En proceso"
|
|
dr("Duracion") = "ND"
|
|
dr("Atendio") = "Juan perez"
|
|
dt.Rows.Add(dr)
|
|
|
|
GVOrdenesdeServicio.DataSource = dt
|
|
GVOrdenesdeServicio.DataBind()
|
|
End Sub
|
|
Private Sub CargaFechaGPS()
|
|
TxtFechaIH.Text = $"01/{DateTime.Now.ToString("MM")}/{DateTime.Now.Year} 00:00"
|
|
TxtFechaFH.Text = $"{DateTime.Now.ToString("dd/MM/yyyy")} 23:59"
|
|
|
|
TxtFechaIC.Text = $"01/{DateTime.Now.ToString("MM")}/{DateTime.Now.Year} 00:00"
|
|
TxtFechaFC.Text = $"{DateTime.Now.ToString("dd/MM/yyyy")} 23:59"
|
|
|
|
TxtFechaID.Text = $"01/{DateTime.Now.ToString("MM")}/{DateTime.Now.Year} 00:00"
|
|
TxtFechaFD.Text = $"{DateTime.Now.ToString("dd/MM/yyyy")} 23:59"
|
|
|
|
TxtFechaIG.Text = $"01/{DateTime.Now.ToString("MM")}/{DateTime.Now.Year} 00:00"
|
|
TxtFechaFG.Text = $"{DateTime.Now.ToString("dd/MM/yyyy")} 23:59"
|
|
End Sub
|
|
|
|
Private Sub InicializaValores()
|
|
Session("FileUpload") = ""
|
|
|
|
ViewState("Orden") = ""
|
|
ViewState("OTipo") = "Tipo DESC"
|
|
ViewState("OTipoReferencia") = "TipoReferencia DESC"
|
|
ViewState("OEstado") = "Estado DESC"
|
|
ViewState("OFechaIng") = "FechaIng DESC"
|
|
ViewState("OUsuario") = "Usuario DESC"
|
|
AFInvSerie = ""
|
|
|
|
CveEmpresaActual = UsuarioActual.CveEmpresa
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub ModalidadesPaginaAFInicial(Optional Op As String = "")
|
|
|
|
TabProduccion.Visible = False
|
|
TabPlagaEnfermedad.Visible = False
|
|
TabServyMant.Visible = False
|
|
|
|
LblFechaCompra.Text = "Fecha de Compra:"
|
|
LblFechaBaja.Text = "Fecha de Baja:"
|
|
|
|
|
|
If Op.Length > 0 Then
|
|
|
|
'Arbol Frutal
|
|
If Op = "AR" Then
|
|
|
|
Dim CveTipoActivoFijoTmp As Integer = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo").FiltroPrimeroValor("CveTipoActivoFijo", $"TipoActivoFijo = 'ARBOLES FRUTALES'").ToEntero
|
|
DdlTipoActivoFijo.SelectedValueExist(CveTipoActivoFijoTmp)
|
|
DdlTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
Dim CveSubTipoActivoFijoTemp As Integer = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltraParametros(String.Format(" CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo").FiltroPrimeroValor("CveSubTipoActivoFijo", $"SubTipoActivoFijo = 'ARBOLES FRUTALES'").ToEntero
|
|
DdlSubTipoActivoFijo.SelectedValueExist(CveSubTipoActivoFijoTemp)
|
|
DdlSubTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
|
|
LblFechaCompra.Text = "Fecha de Nacimiento"
|
|
LblFechaBaja.Text = "Fecha de Muerte"
|
|
TabProduccion.Visible = True
|
|
|
|
End If
|
|
|
|
'Arbol Apicola
|
|
If Op = "AP" Then
|
|
|
|
|
|
Dim CveTipoActivoFijoTmp As Integer = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo").FiltroPrimeroValor("CveTipoActivoFijo", $"TipoActivoFijo = 'APICOLAS'").ToEntero
|
|
DdlTipoActivoFijo.SelectedValueExist(CveTipoActivoFijoTmp)
|
|
DdlTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
Dim CveSubTipoActivoFijoTemp As Integer = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltraParametros(String.Format(" CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo").FiltroPrimeroValor("CveSubTipoActivoFijo", $"SubTipoActivoFijo = 'APICOLAS'").ToEntero
|
|
DdlSubTipoActivoFijo.SelectedValueExist(CveSubTipoActivoFijoTemp)
|
|
DdlSubTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
TabPlagaEnfermedad.Visible = True
|
|
|
|
End If
|
|
|
|
'Pozos
|
|
If Op = "PO" Then
|
|
|
|
|
|
Dim CveTipoActivoFijoTmp As Integer = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo").FiltroPrimeroValor("CveTipoActivoFijo", $"TipoActivoFijo = 'POZOS'").ToEntero
|
|
DdlTipoActivoFijo.SelectedValueExist(CveTipoActivoFijoTmp)
|
|
DdlTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
Dim CveSubTipoActivoFijoTemp As Integer = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltraParametros(String.Format(" CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo").FiltroPrimeroValor("CveSubTipoActivoFijo", $"SubTipoActivoFijo = 'POZOS'").ToEntero
|
|
DdlSubTipoActivoFijo.SelectedValueExist(CveSubTipoActivoFijoTemp)
|
|
DdlSubTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
TabServyMant.Visible = True
|
|
End If
|
|
|
|
'Inmuebles
|
|
If Op = "IN" Then
|
|
|
|
Dim CveTipoActivoFijoTmp As Integer = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo").FiltroPrimeroValor("CveTipoActivoFijo", $"TipoActivoFijo = 'INMUEBLES'").ToEntero
|
|
DdlTipoActivoFijo.SelectedValueExist(CveTipoActivoFijoTmp)
|
|
DdlTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
Dim CveSubTipoActivoFijoTemp As Integer = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltraParametros(String.Format(" CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo").FiltroPrimeroValor("CveSubTipoActivoFijo", $"SubTipoActivoFijo = 'INMUEBLES'").ToEntero
|
|
DdlSubTipoActivoFijo.SelectedValueExist(CveSubTipoActivoFijoTemp)
|
|
DdlSubTipoActivoFijo_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub ModalidadesPaginaAF()
|
|
|
|
TabProduccion.Visible = False
|
|
TabPlagaEnfermedad.Visible = False
|
|
TabServyMant.Visible = False
|
|
|
|
LblFechaCompra.Text = "Fecha de Compra:"
|
|
LblFechaBaja.Text = "Fecha de Baja:"
|
|
|
|
|
|
If DdlTipoActivoFijo.SelectedItem.Text = "ARBOLES FRUTALES" And DdlSubTipoActivoFijo.SelectedItem.Text = "ARBOLES FRUTALES" Then
|
|
LblFechaCompra.Text = "Fecha de Nacimiento"
|
|
LblFechaBaja.Text = "Fecha de Muerte"
|
|
TabProduccion.Visible = True
|
|
End If
|
|
|
|
'Arbol Apicola
|
|
If DdlTipoActivoFijo.SelectedItem.Text = "APICOLAS" And DdlSubTipoActivoFijo.SelectedItem.Text = "APICOLAS" Then
|
|
TabPlagaEnfermedad.Visible = True
|
|
End If
|
|
|
|
'Pozos
|
|
If DdlTipoActivoFijo.SelectedItem.Text = "POZOS" And DdlSubTipoActivoFijo.SelectedItem.Text = "POZOS" Then
|
|
TabServyMant.Visible = True
|
|
End If
|
|
|
|
'Inmuebles
|
|
If DdlTipoActivoFijo.SelectedItem.Text = "INMUEBLES" And DdlSubTipoActivoFijo.SelectedItem.Text = "INMUEBLES" Then
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
|
|
#Region " CARGA COMBOS "
|
|
Private Sub CargaCombos()
|
|
CargaTipoActivoFijo()
|
|
CargaResponsable()
|
|
CargaEstatusActivoFijo()
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, lblProyecto, LblSubProyecto)
|
|
RowProyecto.Visible = DdlProyecto.Visible
|
|
'CargaCliente()
|
|
CargaGrupos()
|
|
CargaMarcas()
|
|
CargaTiposAgenda()
|
|
CargaTipoFallas()
|
|
CargaDdlActividades()
|
|
CargaDdlOperadores()
|
|
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
If Not UsuarioActual.TienePermisoProceso(167) Then
|
|
DdlProyecto.Enabled = False
|
|
DdlSubProyecto.Enabled = False
|
|
DdlEstadoActivoFijo.Enabled = False
|
|
End If
|
|
DdlResponsable.Enabled = False
|
|
End If
|
|
|
|
CargaCultivos()
|
|
|
|
End Sub
|
|
Private Sub CargaTipoActivoFijo()
|
|
DdlTipoActivoFijo.DataSource = GlobalDTTipoActivoFijo(CveEmpresaActual).FiltraParametros("", "TipoActivoFijo")
|
|
DdlTipoActivoFijo.DataBind()
|
|
CargaSubTipoActivoFijo()
|
|
End Sub
|
|
Private Sub CargaSubTipoActivoFijo()
|
|
|
|
DdlSubTipoActivoFijo.Items.Clear()
|
|
DdlSubTipoActivoFijo.DataSource = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltraParametros(String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo")
|
|
DdlSubTipoActivoFijo.DataBind()
|
|
DdlSubTipoActivoFijo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubTipoActivoFijo.SelectedIndex = 0
|
|
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
Private Sub CargaDispositivos()
|
|
DivDispositivo.Visible = False
|
|
Dim AplicaGPSStr = GlobalDTSubTipoActivoFijo(CveEmpresaActual).FiltroPrimeroValor("AplicaGPS", $"CveSubTipoActivoFijo = {DdlSubTipoActivoFijo.SelectedValue.ToEntero}")
|
|
Dim AplicaGPS As Boolean = CBool(If(String.IsNullOrEmpty(AplicaGPSStr), "False", AplicaGPSStr))
|
|
If AplicaGPS Then
|
|
Dim ObjGPS As New ClsGPS
|
|
Try
|
|
If ObjGPS.GetClientesEmpresa(UsuarioActual.CveEmpresa) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
CveClienteGPS = ObjGPS.DtResultados.Rows(0)("CveCliente").ToString().ToEntero()
|
|
Offset = ObjGPS.DtResultados.Rows(0)("UTCOffset").ToString().ToEntero()
|
|
|
|
DdlDispositivo.Items.Clear()
|
|
DdlDispositivo.DataSource = GlobalDTDispositivosUsuarios(CveClienteGPS)
|
|
DdlDispositivo.DataBind()
|
|
DdlDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlDispositivo.SelectedIndex = 0
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
Finally
|
|
ObjGPS.Dispose()
|
|
DivDispositivo.Visible = True
|
|
TabGPS.Visible = True
|
|
End Try
|
|
End If
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub CargaGrupos()
|
|
Dim ObjAF As New ClsAF
|
|
|
|
DdlGrupo.Items.Clear()
|
|
If ObjAF.GetGrupoAF(-1, UsuarioActual.CveEmpresa) Then
|
|
DdlGrupo.DataSource = ObjAF.DtResultados
|
|
Else
|
|
DdlGrupo.DataSource = Nothing
|
|
End If
|
|
DdlGrupo.DataBind()
|
|
ObjAF.Dispose()
|
|
DdlGrupo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
Private Sub CargaResponsable()
|
|
Dim DtPersonal = GlobalDTRHPersonal(CveEmpresaActual).FiltraParametros("", "NombreCompleto")
|
|
DdlResponsable.DataSource = DtPersonal
|
|
DdlResponsable.DataBind()
|
|
End Sub
|
|
Private Sub CargaSubProyecto()
|
|
DdlSubProyecto.Items.Clear()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero, -1, CveEmpresaActual, 1)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Sin SubProyecto asignado", "-1"))
|
|
End Sub
|
|
'Private Sub CargaProyecto()
|
|
' DdlProyecto.DataSource = GlobalDTProyectos(CveEmpresaActual)
|
|
' DdlProyecto.DataBind()
|
|
'End Sub
|
|
Private Sub CargaEstatusActivoFijo()
|
|
DdlEstadoActivoFijo.DataSource = GlobalDTEstadoActivoFijo
|
|
DdlEstadoActivoFijo.DataBind()
|
|
End Sub
|
|
'Private Sub CargaCliente()
|
|
' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
' 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
|
|
|
|
|
|
Private Function CreaDTProduccion() As DataTable
|
|
'CveProduccion, CveActivoFijo, CveCultivoCuadroDetalle, Cantidad, Fecha, CveUsuario, FechaIng, Codigo, Descripcion, Usuario, Cuadro
|
|
|
|
Dim DTProduccion As New DataTable
|
|
|
|
|
|
DTProduccion.Columns.Add("CveProduccion", GetType(Integer))
|
|
DTProduccion.Columns.Add("CveActivoFijo", GetType(Integer))
|
|
DTProduccion.Columns.Add("CveCultivoCuadroDetalle", GetType(Integer))
|
|
DTProduccion.Columns.Add("Cantidad", GetType(Decimal))
|
|
DTProduccion.Columns.Add("Fecha", GetType(Date))
|
|
DTProduccion.Columns.Add("Cuadro", GetType(String))
|
|
|
|
DTProduccion.Columns.Add("CveUsuario", GetType(Integer))
|
|
DTProduccion.Columns.Add("FechaIng", GetType(Date))
|
|
DTProduccion.Columns.Add("Codigo", GetType(String))
|
|
DTProduccion.Columns.Add("Descripcion", GetType(String))
|
|
DTProduccion.Columns.Add("Usuario", GetType(String))
|
|
|
|
|
|
Return DTProduccion
|
|
|
|
End Function
|
|
|
|
Private Function CreaDTPlagaEngermedad() As DataTable
|
|
'CvePlagaEnfermedad,CveActivoFijo,Observaciones,Fecha,CveUsuario,FechaIng
|
|
Dim DTPlgaEfermedad As New DataTable
|
|
|
|
DTPlgaEfermedad.Columns.Add("CvePlagaEnfermedad", GetType(Integer))
|
|
DTPlgaEfermedad.Columns.Add("CveActivoFijo", GetType(Integer))
|
|
|
|
DTPlgaEfermedad.Columns.Add("Observaciones", GetType(String))
|
|
DTPlgaEfermedad.Columns.Add("Fecha", GetType(Date))
|
|
|
|
DTPlgaEfermedad.Columns.Add("CveUsuario", GetType(Integer))
|
|
DTPlgaEfermedad.Columns.Add("FechaIng", GetType(Date))
|
|
|
|
DTPlgaEfermedad.Columns.Add("Usuario", GetType(String))
|
|
|
|
|
|
|
|
Return DTPlgaEfermedad
|
|
|
|
End Function
|
|
|
|
Private Function CreaDTMantenimiento() As DataTable
|
|
'CveMantenimiento, CveActivoFijo, Mantenimiento, Observaciones, Fecha, FechaIng, CveUsuario, Codigo, Descripcion,Usuario,Archivo
|
|
Dim DTMantenimiento As New DataTable
|
|
|
|
DTMantenimiento.Columns.Add("CveMantenimiento", GetType(Integer))
|
|
DTMantenimiento.Columns.Add("CveActivoFijo", GetType(Integer))
|
|
|
|
DTMantenimiento.Columns.Add("Mantenimiento", GetType(String))
|
|
DTMantenimiento.Columns.Add("Observaciones", GetType(String))
|
|
DTMantenimiento.Columns.Add("Fecha", GetType(Date))
|
|
DTMantenimiento.Columns.Add("FechaIng", GetType(Date))
|
|
|
|
DTMantenimiento.Columns.Add("CveUsuario", GetType(Integer))
|
|
DTMantenimiento.Columns.Add("Codigo", GetType(String))
|
|
DTMantenimiento.Columns.Add("Descripcion", GetType(String))
|
|
DTMantenimiento.Columns.Add("Usuario", GetType(String))
|
|
DTMantenimiento.Columns.Add("Archivo", GetType(String))
|
|
|
|
|
|
Return DTMantenimiento
|
|
|
|
End Function
|
|
|
|
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargaSubProyecto()
|
|
End Sub
|
|
|
|
Private Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyecto.SelectedIndexChanged
|
|
CargaFolios()
|
|
CargaCultivos()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoActivoFijo_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlTipoActivoFijo.SelectedIndexChanged
|
|
CargaFolios()
|
|
ModalidadesPaginaAF()
|
|
End Sub
|
|
|
|
Private Sub CargaFolios()
|
|
Dim ObjFolios As New ClsGralFolios()
|
|
|
|
If CveActivoFijo > 0 Then
|
|
If GlobalDTTipoActivoFijo(CveEmpresaActual).FiltroPrimeroValor("AutoFolio", $"CveTipoActivoFijo = '{DdlTipoActivoFijo.SelectedValue}'").ToString = "Activo" Then
|
|
If ObjFolios.GetFolios("AF", 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
|
|
TxtCodigo.Enabled = False
|
|
TxtCodigo.Text = $"{DT.Rows(0)("Serie").ToString}-{DT.Rows(0)("FActual").ToString}"
|
|
Else
|
|
TxtCodigo.Enabled = True
|
|
TxtCodigo.Text = CodigoAF
|
|
Alert("No tiene registrados Folios para Activos Fijos en esta sucursal.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
Else
|
|
TxtCodigo.Enabled = True
|
|
TxtCodigo.Text = CodigoAF
|
|
End If
|
|
Else
|
|
If GlobalDTTipoActivoFijo(CveEmpresaActual).FiltroPrimeroValor("AutoFolio", $"CveTipoActivoFijo = '{DdlTipoActivoFijo.SelectedValue}'").ToString = "Activo" Then
|
|
If ObjFolios.GetFolios("AF", 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
|
|
TxtCodigo.Enabled = False
|
|
TxtCodigo.Text = $"{DT.Rows(0)("Serie").ToString}-{DT.Rows(0)("FActual").ToString}"
|
|
Else
|
|
TxtCodigo.Enabled = True
|
|
TxtCodigo.Text = ""
|
|
Alert("No tiene registrados Folios para Activos Fijos en esta sucursal.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
Else
|
|
TxtCodigo.Enabled = True
|
|
TxtCodigo.Text = ""
|
|
End If
|
|
End If
|
|
|
|
ObjFolios.Dispose()
|
|
CargaSubTipoActivoFijo()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaAFInv()
|
|
If UsuarioActual.Empresa.UsaInventarios AndAlso CveActivoFijo <= 0 Then
|
|
|
|
HLAFInv.Visible = True
|
|
|
|
Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,15)"
|
|
DdlAFInvAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, CveEmpresaActual, CveTipoAlmacen:=-1).FiltraParametros(StrAlmacenes)
|
|
DdlAFInvAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAFInvAlmacen.SelectedValue = "-1"
|
|
DdlAFInvAlmacen.DataBind()
|
|
DdlAFInvAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
DdlAFInvPS.setEsWebService(True)
|
|
|
|
'DdlAFInvPS.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2", "PSCodigo")
|
|
'DdlAFInvPS.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
'DdlAFInvPS.DataBind()
|
|
'DdlAFInvPS.SelectedValue = "-1"
|
|
End If
|
|
End Sub
|
|
Private Sub CargaMarcas()
|
|
DdlMarcas.DataSource = GlobalDTMarcaActivoFijo(UsuarioActual.CveEmpresa)
|
|
DdlMarcas.DataBind()
|
|
DdlMarcas.Items.Insert(0, New ListItem("-", "-1"))
|
|
End Sub
|
|
Private Sub CargaModelos(CveMarca As Integer)
|
|
DdlModelos.Items.Clear()
|
|
DdlModelos.DataSource = GlobalDTModeloActivoFijo(UsuarioActual.CveEmpresa, CveMarca)
|
|
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()
|
|
Dim ObjActivoFijo As New ClsAF()
|
|
|
|
If ObjActivoFijo.GetActivosFijos(CveActivoFijo, CveEmpresaActual, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, BuscaGrupoEmpresa:=-1) Then
|
|
If ObjActivoFijo.DtResultados.Rows.Count > 0 Then
|
|
|
|
'CARGA LA EMPRESA QUE PERTENECE EL AF
|
|
CveEmpresaActual = ObjActivoFijo.CveEmpresa
|
|
CargaCombos()
|
|
|
|
'Pestaña Datos Generales
|
|
LtlActivoFijo.Text = ObjActivoFijo.Descripcion
|
|
TxtDescripcion.Text = ObjActivoFijo.Descripcion
|
|
TxtCodigo.Text = ObjActivoFijo.Codigo
|
|
TxtValorCompra.Text = ObjActivoFijo.ValorCompra.ToString.FormatoNumero
|
|
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
|
|
|
|
If ObjActivoFijo.CveMovimientoInv > 0 Then
|
|
UpAFInvMovimiento.Visible = True
|
|
HLAFInvMovimiento.Text = ObjActivoFijo.FolioInv
|
|
HLAFInvMovimiento.NavigateUrl = $"/Inventarios/EntradasSalidas.aspx?CveMovimiento={ObjActivoFijo.CveMovimientoInv}"
|
|
LbAFInvAlmacen.Text = ObjActivoFijo.AlmacenInv
|
|
End If
|
|
|
|
'DdlEstadoActivoFijo.SelectedValueExist(ObjActivoFijo.CveEstadoActivoFijo.ToString)
|
|
'DdlProyecto.SelectedValueExist(ObjActivoFijo.CveProyecto.ToString)
|
|
'DdlSubProyecto.SelectedValueExist(ObjActivoFijo.CveSubProyecto.ToString)
|
|
'DdlResponsable.SelectedValueExist(ObjActivoFijo.CvePersonaResponsable.ToString)
|
|
'If ObjActivoFijo.CvePersonaResponsable > 0 Then
|
|
' DdlResponsable.Enabled = False
|
|
' DdlProyecto.Enabled = False
|
|
' DdlSubProyecto.Enabled = False
|
|
' DdlEstadoActivoFijo.Enabled = False
|
|
'End If
|
|
CodigoAF = ObjActivoFijo.Codigo
|
|
If GlobalDTTipoActivoFijo(CveEmpresaActual).FiltroPrimeroValor("AutoFolio", $"CveTipoActivoFijo = '{ObjActivoFijo.CveTipoActivoFijo}'").ToString = "Activo" Then
|
|
TxtCodigo.Enabled = False
|
|
Else
|
|
TxtCodigo.Enabled = True
|
|
End If
|
|
|
|
If ObjActivoFijo.MedidaVehicular = 2 Then
|
|
LabelInicial.InnerText = "Odómetro Inicial"
|
|
LabelFinal.InnerText = "Odómetro Final"
|
|
|
|
ElseIf ObjActivoFijo.MedidaVehicular = 3 Then
|
|
LabelInicial.InnerText = "Horómetro Inicial"
|
|
LabelFinal.InnerText = "Horómetro Final"
|
|
Else
|
|
TabActividades.Visible = False
|
|
TabIncidentes.Visible = False
|
|
LnkAddActividad.Visible = False
|
|
LnkAddAccidente.Visible = False
|
|
LnkAddFalla.Visible = False
|
|
End If
|
|
|
|
TxtNoSerie.Text = ObjActivoFijo.NoSerie
|
|
TxtAño.Text = ObjActivoFijo.Año.ToString
|
|
'CargaSubProyecto()
|
|
DdlCtaContable.SelectedValue = ObjActivoFijo.Cuenta.ToString
|
|
LblFechaCaptura.Text = ObjActivoFijo.FechaIng.ToShortDateString
|
|
LblUsuarioCapturo.Text = ObjActivoFijo.Usuario
|
|
DdlCtaContableDepreciacion.SelectedValue = ObjActivoFijo.IdCtaContDepreciacion.ToString
|
|
TxtPorDepreciacion.Text = ObjActivoFijo.PorDepreciacion.ToString
|
|
LtlFechaUltimaDepreciacion.Text = ObjActivoFijo.FechaUltimaDepreciacion.ToString
|
|
TxtObservaciones.Text = ObjActivoFijo.Observaciones
|
|
|
|
If ObjActivoFijo.CveCompra > 0 Then
|
|
TxtValorCompra.Enabled = False
|
|
TxtFechaCompra.Enabled = False
|
|
|
|
DivCompra.Visible = True
|
|
HLCompra.NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", ObjActivoFijo.CveCompra)
|
|
End If
|
|
CargarArchivo()
|
|
'CargaBitacora()
|
|
CargaEventoBitacora()
|
|
|
|
CargarHistorialModificaciones()
|
|
CargaEventos()
|
|
'AQUI ESTABA LA CARGA DE PLACAS, LICENCIAS Y SEGUROS
|
|
CargaProveedor()
|
|
'AQUI ESTABA LA CARGA DE SERVICIOS E INCIDENTES
|
|
|
|
|
|
CargaPlacas()
|
|
CargaLicencias()
|
|
CargaSeguros()
|
|
|
|
CargaFallas()
|
|
CargaAccidentes()
|
|
|
|
CargaResguardos()
|
|
CargarHistorial()
|
|
CargaCaracteristicas()
|
|
|
|
DdlEstadoActivoFijo.SelectedValue = ObjActivoFijo.DtResultados.Rows(0)("CveEstadoActivoFijo").ToString
|
|
DdlResponsable.SelectedValue = ObjActivoFijo.DtResultados.Rows(0)("CvePersonaResponsable").ToString
|
|
DdlProyecto.SelectedValue = ObjActivoFijo.CveProyecto.ToString
|
|
CargaSubProyecto()
|
|
DdlSubProyecto.SelectedValue = ObjActivoFijo.DtResultados.Rows(0)("CveSubProyecto").ToString
|
|
Ddlclientes.SelectedValue = ObjActivoFijo.CveCliente.ToString
|
|
If ObjActivoFijo.CveCliente > 0 Then
|
|
Ddlclientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=ObjActivoFijo.CveCliente).FiltroPrimeroValor("NombreComercial")
|
|
End If
|
|
DdlMarcas.SelectedValueExist(ObjActivoFijo.CveMarcaActivoFijo)
|
|
CargaModelos(DdlMarcas.SelectedValue.ToEntero)
|
|
DdlModelos.SelectedValueExist(ObjActivoFijo.CveModeloActivoFijo)
|
|
DdlGrupo.SelectedValueExist(ObjActivoFijo.CveGrupoAF)
|
|
|
|
'DEPRECIACIONES
|
|
LtImporteCompra.Text = ObjActivoFijo.ValorCompra.ToString.FormatoNumero
|
|
LtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString
|
|
|
|
If LtFechaCompra.Text <> "" Then
|
|
LtFechaFinDepreciación.Text = ObjActivoFijo.FechaCompra.AddMonths(ObjActivoFijo.MesesDepreciacion).ToShortDateString
|
|
End If
|
|
|
|
CargaAFPAdreEHijos()
|
|
DdlAFPadres.SelectedValue = ObjActivoFijo.CveAFPadre.ToString
|
|
|
|
If ObjActivoFijo.CveDispositivo > 0 Then
|
|
CargaFechaGPS()
|
|
CargaDispositivos()
|
|
CargaUltimaPosicion(ObjActivoFijo.CveDispositivo)
|
|
DdlDispositivo.SelectedValueExist(ObjActivoFijo.CveDispositivo)
|
|
End If
|
|
Else
|
|
Alert("El Activo Fijo Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
End If
|
|
ObjActivoFijo.Dispose()
|
|
End Sub
|
|
|
|
#Region "P L A C A S"
|
|
Public Sub CargaPlacas()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetPlacas(-1, CveActivoFijo, UsuarioActual.CveEmpresa, CveDispositivo:=-1, CveCliente:=-1) Then
|
|
GvPlacas.DataSource = ObjAF.DtResultados
|
|
Placas = ObjAF.DtResultados
|
|
GvPlacas.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidad.Value = "U"
|
|
HdnID.Value = GvRow.DataKey("CvePlaca")
|
|
UpDatos.Update()
|
|
BtnAgregarPlaca.Text = "Actualizar"
|
|
myModalLabel.InnerText = "Actualizar Placa"
|
|
TxtPlaca.Text = GvRow.DataKey("Placa")
|
|
TxtObservacionPlacas.Text = GvRow.DataKey("Observacion")
|
|
UpAddPlacas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddPlacas"))
|
|
End Sub
|
|
Public Sub Delete_Click(sender As Object, e As EventArgs)
|
|
Dim ObjAF As New ClsAF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnID.Value = GvRow.DataKey("CvePlaca")
|
|
UpDatos.Update()
|
|
If ObjAF.RemovePlaca(HdnID.Value.ToEntero) Then
|
|
CargaPlacas()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddPlacas_Click(sender As Object, e As EventArgs) Handles LnkAddPlacas.Click
|
|
HdnModalidad.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarPlaca.Text = "Agregar"
|
|
myModalLabel.InnerText = "Agregar Placa"
|
|
TxtPlaca.Text = ""
|
|
TxtObservacionPlacas.Text = ""
|
|
TxtArchivo.Text = ""
|
|
|
|
UpAddPlacas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddPlacas"))
|
|
End Sub
|
|
Private Sub BtnAgregarPlaca_Click(sender As Object, e As EventArgs) Handles BtnAgregarPlaca.Click
|
|
Dim ObjAF As New ClsAF
|
|
|
|
Dim FileExtension As String = ""
|
|
Dim Filesgral As List(Of Archivo) = TxtArchivo.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
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
|
|
Next
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Placas\{1}", AppDomain.CurrentDomain.BaseDirectory, Filename))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("{0}", Archivo.Name), String.Format("{0}AF\Placas", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
If HdnModalidad.Value = "A" Then
|
|
If ObjAF.AddPlacas(CveActivoFijo, TxtPlaca.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Observacion:=TxtObservacionPlacas.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ElseIf HdnModalidad.Value = "U" Then
|
|
If ObjAF.UpdatePlacas(HdnID.Value.ToEntero, TxtPlaca.Text.Trim, Observacion:=TxtObservacionPlacas.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
TxtArchivo.Text = ""
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddPlacas"))
|
|
CargaPlacas()
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub GvPlacas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPlacas.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
|
|
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
|
|
Dim separado As Char() = ".".ToCharArray
|
|
Dim array() As String = Adjunto.Split(separado)
|
|
Dim extencion As String = ""
|
|
|
|
If array.Length > 0 Then
|
|
extencion = array(array.Length - 1)
|
|
End If
|
|
|
|
If Adjunto.Trim.Length > 0 Then
|
|
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/AF/Placas/" & Adjunto & "." & extencion
|
|
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "AF/Placas/" & Adjunto & "." & extencion
|
|
|
|
If File.Exists(linkDescargaArchivo) Then
|
|
ImgDownLoad.Visible = True
|
|
If extencion.Length > 0 Then
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Placa" & "." & extencion)
|
|
Else
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Placa")
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "L I C E N C I A S"
|
|
Public Sub CargaLicencias()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetLicencias(-1, CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
|
GvLicencias.DataSource = ObjAF.DtResultados
|
|
Licencias = ObjAF.DtResultados
|
|
GvLicencias.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Public Sub EditLicencia_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidadLicencia.Value = "U"
|
|
HdnIDLicencia.Value = GvRow.DataKey("CveLicencia")
|
|
UpDatos.Update()
|
|
BtnAgregarLicencia.Text = "Actualizar"
|
|
LabelLicencia.InnerText = "Actualizar Licencia"
|
|
TxtLicencia.Text = GvRow.DataKey("Licencia")
|
|
TxtFechaExpLicencia.Text = GvRow.DataKey("FechaExpedicion")
|
|
TxtFechaVencLicencia.Text = GvRow.DataKey("FechaVencimiento")
|
|
TxtObservacionLicencia.Text = GvRow.DataKey("Observacion")
|
|
UpAddLicencias.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddLicencias"))
|
|
End Sub
|
|
Public Sub DeleteLicencia_Click(sender As Object, e As EventArgs)
|
|
Dim ObjAF As New ClsAF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnIDLicencia.Value = GvRow.DataKey("CveLicencia")
|
|
UpDatos.Update()
|
|
If ObjAF.RemoveLicencia(HdnIDLicencia.Value.ToEntero) Then
|
|
CargaLicencias()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddLicencias_Click(sender As Object, e As EventArgs) Handles LnkAddLicencias.Click
|
|
HdnModalidadLicencia.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarLicencia.Text = "Agregar"
|
|
LabelLicencia.InnerText = "Agregar Licencia"
|
|
TxtLicencia.Text = ""
|
|
TxtFechaExpLicencia.Text = ""
|
|
TxtFechaVencLicencia.Text = ""
|
|
|
|
UpAddLicencias.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddLicencias"))
|
|
End Sub
|
|
Private Sub BtnAgregarLicencia_Click(sender As Object, e As EventArgs) Handles BtnAgregarLicencia.Click
|
|
Dim ObjAF As New ClsAF
|
|
|
|
Dim FileExtension As String = ""
|
|
Dim Filesgral As List(Of Archivo) = TxtArchivoLicencia.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
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
|
|
Next
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Licencias\{1}", UsuarioActual.Empresa.Ruta, Filename))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("{0}", Archivo.Name), String.Format("{0}AF\Licencias", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
If HdnModalidadLicencia.Value = "A" Then
|
|
If ObjAF.AddLicencia(CveActivoFijo, TxtLicencia.Text.Trim, TxtFechaExpLicencia.Text.ToDateTime, TxtFechaVencLicencia.Text.ToDateTime, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Observacion:=TxtObservacionLicencia.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ElseIf HdnModalidadLicencia.Value = "U" Then
|
|
If ObjAF.UpdateLicencia(HdnIDLicencia.Value.ToEntero, TxtLicencia.Text.Trim, TxtFechaExpLicencia.Text.ToDateTime, TxtFechaVencLicencia.Text.ToDateTime, Observacion:=TxtObservacionLicencia.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
TxtArchivoLicencia.Text = "[]"
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddLicencias"))
|
|
CargaLicencias()
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub GvLicencias_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvLicencias.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
|
|
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
|
|
Dim separado As Char() = ".".ToCharArray
|
|
Dim array() As String = Adjunto.Split(separado)
|
|
Dim extencion As String = ""
|
|
|
|
If array.Length > 0 Then
|
|
extencion = array(array.Length - 1)
|
|
End If
|
|
|
|
If Adjunto.Trim.Length > 0 Then
|
|
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/AF/Licencias/" & Adjunto & "." & extencion
|
|
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "AF/Licencias/" & Adjunto & "." & extencion
|
|
|
|
If File.Exists(linkDescargaArchivo) Then
|
|
ImgDownLoad.Visible = True
|
|
If extencion.Length > 0 Then
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Licencia" & "." & extencion)
|
|
Else
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Licencia")
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub GvPolizas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPolizas.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
|
|
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
|
|
Dim separado As Char() = ".".ToCharArray
|
|
Dim array() As String = Adjunto.Split(separado)
|
|
Dim extencion As String = ""
|
|
|
|
If array.Length > 0 Then
|
|
extencion = array(array.Length - 1)
|
|
End If
|
|
|
|
If Adjunto.Trim.Length > 0 Then
|
|
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/AF/Polizas/" & Adjunto & "." & extencion
|
|
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "AF/Polizas/" & Adjunto & "." & extencion
|
|
|
|
If File.Exists(linkDescargaArchivo) Then
|
|
ImgDownLoad.Visible = True
|
|
If extencion.Length > 0 Then
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Poliza" & "." & extencion)
|
|
Else
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, "Poliza")
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "S E G U R O S"
|
|
Public Sub CargaSeguros()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetPolizasSeguro(-1, CveActivoFijo, -1, UsuarioActual.CveEmpresa) Then
|
|
GvPolizas.DataSource = ObjAF.DtResultados
|
|
Polizas = ObjAF.DtResultados
|
|
GvPolizas.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub CargaProveedor()
|
|
'DdlProveedor.Items.Clear()
|
|
'DdlProveedor.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
'DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
'DdlProveedor.DataBind()
|
|
|
|
UpAddPolizas.Update()
|
|
End Sub
|
|
Public Sub EditPoliza_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidadPoliza.Value = "U"
|
|
HdnIDPoliza.Value = GvRow.DataKey("CvePolizaSeguro")
|
|
UpDatos.Update()
|
|
BtnAgregarPoliza.Text = "Actualizar"
|
|
LabelPolizas.InnerText = "Actualizar Poliza"
|
|
TxtPolizaSeguro.Text = GvRow.DataKey("PolizaSeguro")
|
|
TxtFechaExpPoliza.Text = GvRow.DataKey("FechaExpedicion")
|
|
TxtFechaVenPoliza.Text = GvRow.DataKey("FechaVencimiento")
|
|
TxtObservacionPoliza.Text = GvRow.DataKey("Observacion")
|
|
UpAddPolizas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddPolizas"))
|
|
End Sub
|
|
Public Sub DeletePoliza_Click(sender As Object, e As EventArgs)
|
|
Dim ObjAF As New ClsAF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnIDPoliza.Value = GvRow.DataKey("CvePolizaSeguro")
|
|
UpDatos.Update()
|
|
If ObjAF.RemovePoliza(HdnIDPoliza.Value.ToEntero) Then
|
|
CargaSeguros()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddPolizaSeguro_Click(sender As Object, e As EventArgs) Handles LnkAddPolizaSeguro.Click
|
|
HdnModalidadPoliza.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarPoliza.Text = "Agregar"
|
|
LabelPolizas.InnerText = "Agregar Póliza de seguro"
|
|
'DdlProveedor.SelectedIndex = 0
|
|
TxtPolizaSeguro.Text = ""
|
|
TxtFechaExpPoliza.Text = ""
|
|
TxtFechaVenPoliza.Text = ""
|
|
TxtObservacionPoliza.Text = ""
|
|
|
|
UpAddPolizas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddPolizas"))
|
|
End Sub
|
|
Private Sub BtnAgregarPoliza_Click(sender As Object, e As EventArgs) Handles BtnAgregarPoliza.Click
|
|
Dim ObjAF As New ClsAF
|
|
|
|
Dim FileExtension As String = ""
|
|
Dim Filesgral As List(Of Archivo) = TxtArchivoPoliza.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
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
|
|
Next
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Polizas\{1}", UsuarioActual.Empresa.Ruta, Filename))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("{0}", Archivo.Name), String.Format("{0}AF\Polizas", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
If HdnModalidadPoliza.Value = "A" Then
|
|
If ObjAF.AddPolizasSeguro(CveActivoFijo, DdlProveedor.SelectedValue.ToEntero, TxtPolizaSeguro.Text.Trim, TxtFechaExpPoliza.Text.ToDateTime, TxtFechaVenPoliza.Text.ToDateTime, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Observacion:=TxtObservacionPoliza.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ElseIf HdnModalidadPoliza.Value = "U" Then
|
|
If ObjAF.UpdatePolizaSeguro(HdnIDPoliza.Value.ToEntero, DdlProveedor.SelectedValue.ToEntero, TxtPolizaSeguro.Text.Trim, TxtFechaExpPoliza.Text.ToDateTime, TxtFechaVenPoliza.Text.ToDateTime, Observacion:=TxtObservacionPoliza.Text.Trim, Adjunto:=If(Filename <> "", Archivo.Name, "-1")) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
TxtArchivoPoliza.Text = "[]"
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddPolizas"))
|
|
CargaSeguros()
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
|
|
#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))
|
|
|
|
|
|
|
|
' GvServiciosMant.DataSource = TmpServicios
|
|
' GvServiciosMant.DataBind()
|
|
'End Sub
|
|
#End Region
|
|
|
|
#Region "F A L L A S"
|
|
Public Sub CargaTipoFallas()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
DdlTipoFallas.Items.Clear()
|
|
DdlTipoFallaAccidente.Items.Clear()
|
|
|
|
If ObjAF.GetTipoFallas(-1, UsuarioActual.CveEmpresa, 2) Then
|
|
DdlTipoFallas.DataSource = ObjAF.DtResultados
|
|
DdlTipoFallas.DataBind()
|
|
End If
|
|
|
|
If ObjAF.GetTipoFallas(-1, UsuarioActual.CveEmpresa, 1) Then
|
|
DdlTipoFallaAccidente.DataSource = ObjAF.DtResultados
|
|
DdlTipoFallaAccidente.DataBind()
|
|
End If
|
|
|
|
DdlTipoFallas.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTipoFallaAccidente.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Public Sub CargaFallas()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetFallas(-1, CveActivoFijo, UsuarioActual.CveEmpresa, -1, 2) Then
|
|
GvFallas.DataSource = ObjAF.DtResultados
|
|
GvFallas.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Public Sub EditIndicente_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidadFalla.Value = "U"
|
|
HdnIDFalla.Value = GvRow.DataKey("CveFalla")
|
|
UpDatos.Update()
|
|
BtnAgregarFalla.Text = "Actualizar"
|
|
LabelIndicente.InnerText = "Actualizar Falla"
|
|
DdlPrioridad.SelectedValueExist(GvRow.DataKey("Prioridad"))
|
|
TxtAsuntoFalla.Text = GvRow.DataKey("Asunto")
|
|
TxtDescripcionFalla.Text = GvRow.DataKey("Descripcion")
|
|
TxtAFMedida.Text = GvRow.DataKey("AFMedida")
|
|
TxtFechaFalla.Text = GvRow.DataKey("FechaFalla")
|
|
TxtCorreoNotificacion.Text = GvRow.DataKey("CorreoNotificacion")
|
|
DdlTipoFallas.SelectedValueExist(GvRow.DataKey("CveTipoFalla"))
|
|
UpAddFallas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddFallas"))
|
|
End Sub
|
|
Public Sub DeleteIncidente_Click(sender As Object, e As EventArgs)
|
|
Dim ObjAF As New ClsAF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnIDFalla.Value = GvRow.DataKey("CveFalla")
|
|
UpDatos.Update()
|
|
If ObjAF.RemoveFalla(HdnIDFalla.Value.ToEntero) Then
|
|
CargaFallas()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddFalla_Click(sender As Object, e As EventArgs) Handles LnkAddFalla.Click
|
|
HdnModalidadFalla.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarFalla.Text = "Agregar"
|
|
LabelIndicente.InnerText = "Agregar Falla"
|
|
DdlPrioridad.SelectedIndex = 0
|
|
TxtAsuntoFalla.Text = ""
|
|
TxtDescripcionFalla.Text = ""
|
|
TxtAFMedida.Text = ""
|
|
TxtFechaFalla.Text = ""
|
|
DdlTipoFallas.SelectedIndex = 0
|
|
TxtCorreoNotificacion.Text = ""
|
|
|
|
UpAddFallas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddFallas"))
|
|
End Sub
|
|
Private Sub BtnAgregarFalla_Click(sender As Object, e As EventArgs) Handles BtnAgregarFalla.Click
|
|
Dim ObjAF As New ClsAF
|
|
Dim TieneError = False
|
|
|
|
If HdnModalidadFalla.Value = "A" Then
|
|
If ObjAF.AddFalla(CveActivoFijo, TxtAsuntoFalla.Text.Trim, TxtDescripcionFalla.Text.Trim, TxtAFMedida.Text.ToEntero, DdlPrioridad.SelectedValue.ToEntero, TxtFechaFalla.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlTipoFallas.SelectedValue.ToEntero, TxtCorreoNotificacion.Text.Trim) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
ElseIf HdnModalidadFalla.Value = "U" Then
|
|
If ObjAF.UpdateFalla(HdnIDFalla.Value.ToEntero, TxtAsuntoFalla.Text.Trim, TxtDescripcionFalla.Text.Trim, TxtAFMedida.Text.ToEntero, DdlPrioridad.SelectedValue.ToEntero, TxtFechaFalla.Text.ToDate, DdlTipoFallas.SelectedValue.ToEntero, TxtCorreoNotificacion.Text) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddFallas"))
|
|
CargaFallas()
|
|
|
|
If Not TieneError AndAlso HdnModalidadFalla.Value = "A" Then
|
|
EnviaCorreoFallas()
|
|
End If
|
|
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub EnviaCorreoFallas()
|
|
Try
|
|
Dim Para = TxtCorreoNotificacion.Text.Trim
|
|
Dim Asunto = "Registro de Falla de Activo Fijo"
|
|
Dim Body = ""
|
|
Dim strBody As New StringBuilder
|
|
|
|
strBody.Append("Registro de Falla de Activo Fijo")
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
|
|
strBody.AppendFormat(" <div id=""C_divOC"" style=""width: 550px""> <fieldset> <legend><b>Datos del Activo Fijo</b></legend> ")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Activo FIjo:</td><td style=""width: 125px""><b>{0}</b></td>", LtlActivoFijo.Text)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
|
|
|
|
'Cargo el detalle
|
|
strBody.Append(" <div style='width: 550px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Fallas</legend> ")
|
|
strBody.Append(" <table width=""550px""> <tr style='background-color:gray;color:White;font-family:Verdana;font-size:10px;text-align:center;vertical-align:middle;font-weight:bold;height:20px;text-decoration:none;'>
|
|
<th scope='col' style='width: 50px'>Fecha</th>
|
|
<th scope='col' style='width: 50px'>Asunto</th>
|
|
<th scope='col' style='width: 225px'>Descripción</th>
|
|
<th scope ='col' style='width: 85px'>Prioridad</th>
|
|
<th scope ='col' style='width: 85px'>Horómetro / Odómetro</th>
|
|
<th scope ='col' style='width: 85px'>Tipo Falla</th>")
|
|
|
|
strBody.AppendFormat("<tr class='Texto'> <td style='width:50px;'>{0}</td> <td style='width:250px;'>{1}</td> <td align='left' style='width:225px;'>{2}</td> <td align='left' style='width:150px;'>{3}</td> <td align='left' style='width:225px;'>{4}</td> <td align='left' style='width:225px;'>{5}</td> </tr>",
|
|
TxtFechaFalla.Text, TxtAsuntoFalla.Text, TxtDescripcionFalla.Text, DdlPrioridad.SelectedItem, TxtAFMedida.Text, DdlTipoFallas.SelectedItem)
|
|
|
|
|
|
|
|
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.Append("</body></html>")
|
|
|
|
Body = strBody.ToString
|
|
|
|
Dim Mail As New ClsSisMail()
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body)
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "A C C I D E N T E S "
|
|
Public Sub CargaAccidentes()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetFallas(-1, CveActivoFijo, UsuarioActual.CveEmpresa, -1, 1) Then
|
|
GvAccidentes.DataSource = ObjAF.DtResultados
|
|
GvAccidentes.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Public Sub EditAccidente_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidadAccidente.Value = "U"
|
|
HdnIDAccidente.Value = GvRow.DataKey("CveFalla")
|
|
UpDatos.Update()
|
|
BtnRegistrarAccidente.Text = "Actualizar"
|
|
LabelAccidente.InnerText = "Actualizar Accidente"
|
|
DdlPrioridadAccidente.SelectedValueExist(GvRow.DataKey("Prioridad"))
|
|
TxtAsuntoAccidente.Text = GvRow.DataKey("Asunto")
|
|
TxtDescripcionAccidente.Text = GvRow.DataKey("Descripcion")
|
|
TxtAFMedidaAccidente.Text = GvRow.DataKey("AFMedida")
|
|
TxtFechaAccidente.Text = GvRow.DataKey("FechaFalla")
|
|
TxtCorreoNotificacionAccidente.Text = GvRow.DataKey("CorreoNotificacion")
|
|
DdlTipoFallaAccidente.SelectedValueExist(GvRow.DataKey("CveTipoFalla"))
|
|
UpAddAccidente.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddAccidentes"))
|
|
End Sub
|
|
Public Sub DeleteAccidente_Click(sender As Object, e As EventArgs)
|
|
Dim ObjAF As New ClsAF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnIDAccidente.Value = GvRow.DataKey("CveFalla")
|
|
UpDatos.Update()
|
|
If ObjAF.RemoveFalla(HdnIDFalla.Value.ToEntero) Then
|
|
CargaAccidentes()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddAccidente_Click(sender As Object, e As EventArgs) Handles LnkAddAccidente.Click
|
|
HdnModalidadAccidente.Value = "A"
|
|
UpDatos.Update()
|
|
BtnRegistrarAccidente.Text = "Agregar"
|
|
LabelAccidente.InnerText = "Agregar Accidente"
|
|
DdlPrioridadAccidente.SelectedIndex = 0
|
|
TxtAsuntoAccidente.Text = ""
|
|
TxtDescripcionAccidente.Text = ""
|
|
TxtAFMedidaAccidente.Text = ""
|
|
TxtFechaAccidente.Text = ""
|
|
DdlTipoFallaAccidente.SelectedIndex = 0
|
|
TxtCorreoNotificacionAccidente.Text = ""
|
|
|
|
UpAddAccidente.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddAccidentes"))
|
|
End Sub
|
|
Private Sub BtnRegistrarAccidente_Click(sender As Object, e As EventArgs) Handles BtnRegistrarAccidente.Click
|
|
Dim ObjAF As New ClsAF
|
|
Dim TieneError = False
|
|
|
|
If HdnModalidadAccidente.Value = "A" Then
|
|
If ObjAF.AddFalla(CveActivoFijo, TxtAsuntoAccidente.Text.Trim, TxtDescripcionAccidente.Text.Trim, TxtAFMedidaAccidente.Text.ToEntero, DdlPrioridadAccidente.SelectedValue.ToEntero, TxtFechaAccidente.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlTipoFallaAccidente.SelectedValue.ToEntero, TxtCorreoNotificacionAccidente.Text.Trim) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
ElseIf HdnModalidadAccidente.Value = "U" Then
|
|
If ObjAF.UpdateFalla(HdnIDAccidente.Value.ToEntero, TxtAsuntoAccidente.Text.Trim, TxtDescripcionAccidente.Text.Trim, TxtAFMedidaAccidente.Text.ToEntero, DdlPrioridadAccidente.SelectedValue.ToEntero, TxtFechaAccidente.Text.ToDate, DdlTipoFallaAccidente.SelectedValue.ToEntero, TxtCorreoNotificacionAccidente.Text) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
If Not TieneError AndAlso HdnModalidadAccidente.Value = "A" Then
|
|
EnviaCorreoAccidente()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddAccidentes"))
|
|
CargaAccidentes()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub EnviaCorreoAccidente()
|
|
Try
|
|
Dim Para = TxtCorreoNotificacion.Text.Trim
|
|
Dim Asunto = "Registro de Accidente de Activo Fijo"
|
|
Dim Body = ""
|
|
Dim strBody As New StringBuilder
|
|
|
|
strBody.Append("Registro de Accidente de Activo Fijo")
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
|
|
strBody.AppendFormat(" <div id=""C_divOC"" style=""width: 550px""> <fieldset> <legend><b>Datos del Activo Fijo</b></legend> ")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Activo FIjo:</td><td style=""width: 125px""><b>{0}</b></td>", LtlActivoFijo.Text)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
|
|
|
|
'Cargo el detalle
|
|
strBody.Append(" <div style='width: 550px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Fallas</legend> ")
|
|
strBody.Append(" <table width=""550px""> <tr style='background-color:gray;color:White;font-family:Verdana;font-size:10px;text-align:center;vertical-align:middle;font-weight:bold;height:20px;text-decoration:none;'>
|
|
<th scope='col' style='width: 50px'>Fecha</th>
|
|
<th scope='col' style='width: 50px'>Asunto</th>
|
|
<th scope='col' style='width: 225px'>Descripción</th>
|
|
<th scope ='col' style='width: 85px'>Prioridad</th>
|
|
<th scope ='col' style='width: 85px'>Horómetro / Odómetro</th>
|
|
<th scope ='col' style='width: 85px'>Tipo Falla</th>")
|
|
|
|
strBody.AppendFormat("<tr class='Texto'> <td style='width:50px;'>{0}</td> <td style='width:250px;'>{1}</td> <td align='left' style='width:225px;'>{2}</td> <td align='left' style='width:150px;'>{3}</td> <td align='left' style='width:225px;'>{4}</td> <td align='left' style='width:225px;'>{5}</td> </tr>",
|
|
TxtFechaAccidente.Text, TxtAsuntoAccidente.Text, TxtDescripcionAccidente.Text, DdlPrioridadAccidente.SelectedItem, TxtAFMedidaAccidente.Text, DdlTipoFallaAccidente.SelectedItem)
|
|
|
|
|
|
|
|
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.Append("</body></html>")
|
|
|
|
Body = strBody.ToString
|
|
|
|
Dim Mail As New ClsSisMail()
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body)
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "A C T I V I D A D E S "
|
|
Private Sub CargaDdlActividades()
|
|
DdlActividad.DataSource = GlobalDTMFActividad(UsuarioActual.CveEmpresa, 1)
|
|
DdlActividad.DataBind()
|
|
DdlActividad.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpDatos.Update()
|
|
UpAgregarBitacora.Update()
|
|
End Sub
|
|
Private Sub CargaDdlOperadores()
|
|
DdlOperador.DataSource = GlobalDTMFOperador(UsuarioActual.CveEmpresa, 1)
|
|
DdlOperador.DataBind()
|
|
DdlOperador.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpDatos.Update()
|
|
UpAgregarBitacora.Update()
|
|
End Sub
|
|
Public Sub CargaActividades()
|
|
Dim ObjMF As New ClsMF()
|
|
|
|
If ObjMF.GetBitacoraAF(-1, CveActivoFijo, -1, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa) Then
|
|
ViewState("UltimaFecha") = ObjMF.DtResultados.MAX("Fecha").ToDate
|
|
ViewState("UltimoHodometro") = ObjMF.DtResultados.MAX("Final")
|
|
CalendarExtender9.StartDate() = UltimaFecha
|
|
GvActividades.DataSource = ObjMF.DtResultados.FiltraParametros("CveBitacora > 0")
|
|
GvActividades.DataBind()
|
|
End If
|
|
|
|
ObjMF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub LnkAddActividad_Click(sender As Object, e As EventArgs) Handles LnkAddActividad.Click
|
|
HdnActividades.Value = "A"
|
|
HdnHorometroAnterior.Value = "-1"
|
|
HdnHorometroSiguiente.Value = "-1"
|
|
UpDatos.Update()
|
|
BtnAgregarActividades.Text = "Agregar"
|
|
LabelActividad.InnerText = "Agregar Actividad"
|
|
DdlActividad.SelectedIndex = 0
|
|
TxtFechaActividad.Text = ""
|
|
TxtObservacion.Text = ""
|
|
TxtHorometroInicial.Text = ""
|
|
TxtHorometroFinal.Text = ""
|
|
UpAgregarBitacora.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivActividades"))
|
|
End Sub
|
|
Public Sub EditActividades_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnActividades.Value = "U"
|
|
HdnIDActividades.Value = GvRow.DataKey("CveBitacora")
|
|
HdnHorometroAnterior.Value = GvRow.DataKey("HorometroAnterior")
|
|
HdnHorometroSiguiente.Value = GvRow.DataKey("HorometroSiguiente")
|
|
UpDatos.Update()
|
|
BtnAgregarActividades.Text = "Actualizar"
|
|
LabelActividad.InnerText = "Actualizar Actividad"
|
|
DdlActividad.SelectedValueExist(GvRow.DataKey("CveActividad"))
|
|
|
|
If GvRow.DataKey("CveOperador").ToEntero > 0 Then
|
|
DdlOperador.SelectedValueExist(GvRow.DataKey("CveOperador"))
|
|
Else
|
|
DdlOperador.SelectedIndex = 0
|
|
End If
|
|
|
|
TxtFechaActividad.Text = GvRow.DataKey("Fecha")
|
|
TxtObservacion.Text = GvRow.DataKey("Observacion")
|
|
TxtHorometroInicial.Text = GvRow.DataKey("HorometroInicial")
|
|
TxtHorometroFinal.Text = GvRow.DataKey("HorometroFinal")
|
|
UpAgregarBitacora.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivActividades"))
|
|
End Sub
|
|
Public Sub DeleteActividades_Click(sender As Object, e As EventArgs)
|
|
Dim ObjMF As New ClsMF()
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnIDActividades.Value = GvRow.DataKey("CveBitacora")
|
|
UpDatos.Update()
|
|
|
|
If ObjMF.RemoveBitacora(HdnIDActividades.Value.ToEntero) Then
|
|
CargaActividades()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjMF.Dispose()
|
|
End Sub
|
|
Private Sub BtnAgregarActividades_Click(sender As Object, e As EventArgs) Handles BtnAgregarActividades.Click
|
|
Dim TieneError = False
|
|
|
|
If HdnIDActividades.Value.ToEntero > 0 Then
|
|
If TxtHorometroInicial.Text.ToEntero < HdnHorometroAnterior.Value.ToEntero Then
|
|
Alert("Horómetro/Odómetro Inicial no puede ser menor al último registro", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
ElseIf TxtHorometroInicial.Text.ToEntero > HdnHorometroAnterior.Value.ToEntero Then
|
|
Alert("Horómetro/Odómetro Inicial no puede ser mayor al último registro", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
If TxtHorometroInicial.Text.ToEntero < UltimoHodometro.ToEntero Then
|
|
Alert("Horómetro/Odómetro Inicial no puede ser menor al último registro", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
Dim ObjMF As New ClsMF()
|
|
|
|
If HdnActividades.Value = "A" And Not TieneError Then
|
|
If ObjMF.AddBitacora(CveActivoFijo, -1, -1, TxtFechaActividad.Text.ToDate, DdlActividad.SelectedValue.ToEntero, DdlOperador.SelectedValue.ToEntero, TxtObservacion.Text, TxtHorometroInicial.Text.ToEntero, TxtHorometroFinal.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
ElseIf HdnActividades.Value = "U" And Not TieneError Then
|
|
If ObjMF.UpdateBitacora(HdnIDActividades.Value.ToEntero, CveActivoFijo, -1, -1, TxtFechaActividad.Text.ToDate, DdlActividad.SelectedValue.ToEntero, DdlOperador.SelectedValue.ToEntero, TxtObservacion.Text, TxtHorometroInicial.Text.ToEntero, TxtHorometroFinal.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) Then
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivActividades"))
|
|
CargaActividades()
|
|
End If
|
|
|
|
ObjMF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub GvActividades_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvActividades.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.Header Then
|
|
If LabelInicial.InnerText = "Odómetro Inicial" Then
|
|
e.Row.Cells(4).Text = "Odómetro Inicial"
|
|
e.Row.Cells(5).Text = "Odómetro Final"
|
|
ElseIf LabelInicial.InnerText = "Horómetro Inicial" Then
|
|
e.Row.Cells(4).Text = "Horómetro Inicial"
|
|
e.Row.Cells(5).Text = "Horómetro Final"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "P R O G R A M A C I Ó N - D E - E V E N T O S"
|
|
Private Sub LnkAddEvento_Click(sender As Object, e As EventArgs) Handles LnkAddEvento.Click
|
|
TxtAsuntoEvento.Text = ""
|
|
DdlAgedaTipoAdd.SelectedIndex = 0
|
|
DdlPrioridadAdd.SelectedIndex = 0
|
|
TxtDescripcionAdd.Text = ""
|
|
TxtFechaInicioEvento.Text = ""
|
|
TxtFechaFinEvento.Text = ""
|
|
UpAddEvento.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddEvento"))
|
|
End Sub
|
|
Private Sub BtnGuardarEvento_Click(sender As Object, e As EventArgs) Handles BtnGuardarEvento.Click
|
|
Dim ObjEventos As New ClsOIEventos
|
|
|
|
If ObjEventos.AddEvento(2, DdlAgedaTipoAdd.SelectedValue.ToEntero, TxtAsuntoEvento.Text, TxtDescripcionAdd.Text, DdlPrioridadAdd.SelectedValue.ToEntero, -1, -1, TxtFechaInicioEvento.Text.ToDate, TxtFechaFinEvento.Text.ToDate, -1, -1, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveActivoFijo) Then
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al agrega evento.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjEventos.Dispose()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddEvento"))
|
|
CargaEventos()
|
|
UpDatos.Update()
|
|
Response.Redirect("/OC/OC.aspx?Tipo=OC")
|
|
|
|
End Sub
|
|
Public Sub CargaEventos()
|
|
Dim ObjEventos As New ClsOIEventos
|
|
If ObjEventos.GetEventos(-1, -1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", CveActivoFijo, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjEventos.DtResultados
|
|
Eventos = ObjEventos.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
GvDatos.DataBind()
|
|
|
|
ObjEventos.Dispose()
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
End If
|
|
End Sub
|
|
Private Sub CargaTiposAgenda()
|
|
Dim ObjEventos As New ClsOIEventos
|
|
|
|
If ObjEventos.GetAgendaTipo() Then
|
|
DdlAgedaTipoAdd.DataSource = ObjEventos.DtResultados
|
|
DdlAgedaTipoAdd.DataBind()
|
|
Else
|
|
Alert("Ocurrió un error al obtener los tipos de agenda.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjEventos.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " R E S G U A R D O S"
|
|
|
|
'#Region "Ordenamiento"
|
|
' Protected Sub LbNombre_Click(sender As Object, e As System.EventArgs) Handles LbNombre.Click, ImgNombre.Click
|
|
' If ViewState("ONombre").ToString() = "Nombre DESC" Then
|
|
' ViewState("ONombre") = "Nombre ASC"
|
|
' ImgNombre.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("ONombre") = "Nombre DESC"
|
|
' ImgNombre.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("ONombre")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
' Protected Sub LbFechaInicio_Click(sender As Object, e As System.EventArgs) Handles LbFechaInicio.Click, ImgFechaInicio.Click
|
|
' If ViewState("OFechaInicio").ToString() = "FechaInicio DESC" Then
|
|
' ViewState("OFechaInicio") = "FechaInicio ASC"
|
|
' ImgFechaInicio.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("OFechaInicio") = "FechaInicio DESC"
|
|
' ImgFechaInicio.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("OFechaInicio")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
' Protected Sub LbFechaFin_Click(sender As Object, e As System.EventArgs) Handles LbFechaFin.Click, ImgFechaFin.Click
|
|
' If ViewState("OFechaFin").ToString() = "FechaFin DESC" Then
|
|
' ViewState("OFechaFin") = "FechaFin ASC"
|
|
' ImgFechaFin.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("OFechaFin") = "FechaFin DESC"
|
|
' ImgFechaFin.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("OFechaFin")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
' Protected Sub LbObservaciones_Click(sender As Object, e As System.EventArgs) Handles LbObservaciones.Click, ImgObservaciones.Click
|
|
' If ViewState("OObservaciones").ToString() = "Observaciones DESC" Then
|
|
' ViewState("OObservaciones") = "Observaciones ASC"
|
|
' ImgObservaciones.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("OObservaciones") = "Observaciones DESC"
|
|
' ImgObservaciones.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("OObservaciones")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
' Protected Sub LbURL_Click(sender As Object, e As System.EventArgs) Handles LbURL.Click, ImgURL.Click
|
|
' If ViewState("OURL").ToString() = "URL DESC" Then
|
|
' ViewState("OURL") = "URL ASC"
|
|
' ImgURL.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("OURL") = "URL DESC"
|
|
' ImgURL.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("OURL")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
' Protected Sub LbUsuario_Click(sender As Object, e As System.EventArgs) Handles LbUsuario.Click, ImgUsuario.Click
|
|
' If ViewState("OUsuario").ToString() = "Usuario DESC" Then
|
|
' ViewState("OUsuario") = "Usuario ASC"
|
|
' ImgUsuario.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
' Else
|
|
' ViewState("OUsuario") = "Usuario DESC"
|
|
' ImgUsuario.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
' End If
|
|
' ViewState("Orden") = ViewState("OUsuario")
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' End Sub
|
|
|
|
'#End Region
|
|
|
|
Private Sub CargaResguardos()
|
|
Dim ObjResguardos As New ClsAF
|
|
If ObjResguardos.GetActivosFijosResguardos(CveActivoFijo, -1, -1, -1) Then
|
|
GvResguardos.DataSource = ObjResguardos.DtResultados
|
|
Else
|
|
GvResguardos.DataSource = Nothing
|
|
End If
|
|
ObjResguardos.Dispose()
|
|
GvResguardos.DataBind()
|
|
End Sub
|
|
Protected Sub GvResguardos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvResguardos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If Not UsuarioActual.TienePermisoPagina(574) Then
|
|
e.Row.FCLabel("LbImprimir1").Text = ""
|
|
e.Row.FCLabel("LbImprimir2").Text = ""
|
|
'e.Row.FCImageButton("imgE").Enabled = False
|
|
End If
|
|
|
|
If e.Row.RowState = DataControlRowState.Edit Then
|
|
e.Row.FCImageButton("BtnGuardaArchivo1").CommandArgument = e.Row.DBCampo("CveActivoFijoResguardo")
|
|
e.Row.FCImageButton("BtnGuardaArchivo2").CommandArgument = e.Row.DBCampo("CveActivoFijoResguardo")
|
|
Else
|
|
'ARCHIVOS DE RESGUARDOS
|
|
If e.Row.FCLiteral("LblFechaInicio").Text <> "" Then
|
|
e.Row.FCLabel("LbImprimir1").Text = String.Format("<a target='_blank' class=""btn btn-sm btn-circle gray"" href=""/Compras/PopUpVerFactura.aspx?P={0}""><i class='fa fa-print font-white' aria-hidden='true'></i></a> ", Encripta(String.Format("OP=AFR&CVEAFR={0}&TIPO={1}", e.Row.DBCampo("CveActivoFijoResguardo"), If(e.Row.DBCampo("Tipo").ToString = "1", 1, 2))))
|
|
End If
|
|
If e.Row.FCLabel("LblFechaFin").Text <> "" Then
|
|
e.Row.FCLabel("LbImprimir2").Text = String.Format("<a target='_blank' class=""btn btn-sm btn-circle gray"" href=""/Compras/PopUpVerFactura.aspx?P={0}""><i class='fa fa-print font-white' aria-hidden='true'></i></a> ", Encripta(String.Format("OP=AFR&CVEAFR={0}&TIPO={1}", e.Row.DBCampo("CveActivoFijoResguardo"), If(e.Row.DBCampo("Tipo").ToString = "1", 4, 3))))
|
|
End If
|
|
End If
|
|
|
|
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
|
|
Dim DescargarArchivo As String = "N/D"
|
|
If File.Exists(String.Format("{0}AF\Resguardos\{1}", UsuarioActual.Empresa.Ruta, e.Row.DBCampo("URL"))) Then
|
|
DescargarArchivo = String.Format("<a Class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Ver</a> ", Encripta(String.Format("OP=OI&Archivo=\Empresas\{0}\AF\Resguardos\{1}", CveEmpresaActual, e.Row.DBCampo("URL"))))
|
|
e.Row.FCImageButton("ImgArchivo").Visible = False
|
|
Else
|
|
e.Row.FCImageButton("ImgArchivo").Visible = True
|
|
End If
|
|
e.Row.FCLiteral("LtlURL").Text = DescargarArchivo
|
|
End If
|
|
|
|
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
|
|
Dim DescargarArchivo As String = "N/D"
|
|
If File.Exists(String.Format("{0}AF\Resguardos\", UsuarioActual.Empresa.Ruta) + e.Row.DBCampo("URL2")) Then
|
|
DescargarArchivo = String.Format("<a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Ver</a> ", Encripta(String.Format("OP=OI&Archivo=\Empresas\{0}\AF\Resguardos\{1}", CveEmpresaActual, e.Row.DBCampo("URL2"))))
|
|
e.Row.FCImageButton("ImgArchivo2").Visible = False
|
|
Else
|
|
e.Row.FCImageButton("ImgArchivo2").Visible = True
|
|
End If
|
|
e.Row.FCLiteral("LtlURL2").Text = DescargarArchivo
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
'Protected Sub GvResguardos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvResguardos.RowCancelingEdit
|
|
' GvResguardos.EditIndex = -1
|
|
' GvResguardos.DataBind()
|
|
' CargaResguardos()
|
|
'End Sub
|
|
|
|
'Protected Sub GvResguardos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvResguardos.RowEditing
|
|
' GvResguardos.EditIndex = e.NewEditIndex
|
|
' CargaResguardos()
|
|
'End Sub
|
|
|
|
'Protected Sub GvResguardos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvResguardos.RowUpdating
|
|
|
|
' Dim ObjResguardos As New ClsAF
|
|
|
|
' ' Dim FechaFin As String = DirectCast(GvResguardos.Rows(e.RowIndex).FindControl("TxtFechaFin"), TextBox).Text
|
|
' ' FechaFin = If(IsDate(FechaFin), FechaFin, "-1")
|
|
' Dim Observaciones As String = DirectCast(GvResguardos.Rows(e.RowIndex).FindControl("TxtObservaciones"), TextBox).Text.Trim
|
|
' Dim URL As String = "-1"
|
|
' Dim URL2 As String = "-1"
|
|
' Dim RutaGuardar = ""
|
|
' Dim RutaArchivo = ""
|
|
' Dim RutaArchivo2 = ""
|
|
' Dim Archivo As String = ""
|
|
' Dim Archivo2 As String = ""
|
|
' Dim CveActivoFijoResguardo As Integer = GvResguardos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
' 'If Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(String.Format("{0}Temp\{1}", UsuarioActual.Empresa.Ruta, Session("FileUpload").ToString)) Then
|
|
' ' Dim TmpArchivo As String = String.Format("{0}Temp\{1}", UsuarioActual.Empresa.Ruta, Session("FileUpload").ToString)
|
|
' ' Dim TmpRuta As String = String.Format("{0}ActivosFijos\Resguardos\", UsuarioActual.Empresa.Ruta)
|
|
' ' Dim Extension As String = Path.GetExtension(TmpArchivo)
|
|
' ' TmpRuta.DirectoryExistsCreate()
|
|
' ' 'If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Resguardos\") Then Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Resguardos\")
|
|
' ' TmpRuta = String.Format("{0}{1}{2}", TmpRuta, CveActivoFijoResguardo, Extension)
|
|
' ' File.Move(TmpArchivo, TmpRuta)
|
|
' ' Session("FileUpload") = ""
|
|
|
|
' ' If File.Exists(TmpRuta) Then
|
|
' ' URL = URL & Extension
|
|
' ' Else
|
|
' ' URL = ""
|
|
' ' End If
|
|
' 'Else
|
|
' ' URL = URLOld
|
|
' 'End If
|
|
|
|
|
|
' 'RutaGuardar = String.Format("{0}OI\", UsuarioActual.Empresa.Ruta)
|
|
' 'If A2.HRef <> "" Then RutaArchivo = String.Format("{0}{1}", ModExtensiones.DirectorioBaseEmpresas, A2.HRef.Substring(1))
|
|
|
|
|
|
' 'End If
|
|
|
|
' 'If UsuarioActual.CveRol = 1037 Then
|
|
' ' RutaGuardar = String.Format("{0}Empresas\70\OI\", ModExtensiones.DirectorioBaseEmpresas)
|
|
' ' RutaGuardar.DirectoryExistsCreate()
|
|
' 'End If
|
|
' 'Else
|
|
' RutaGuardar = String.Format("{0}AF\Resguardos\", UsuarioActual.Empresa.Ruta)
|
|
' RutaArchivo = String.Format("{0}AF\Resguardos\Temp\{1}", UsuarioActual.Empresa.Ruta, Session("AF"))
|
|
' RutaArchivo2 = (String.Format("{0}AF\Resguardos\Temp\{1}", UsuarioActual.Empresa.Ruta, Session("AF1")))
|
|
|
|
' If Session("AF") IsNot Nothing AndAlso File.Exists(RutaArchivo) Then
|
|
' If Not Directory.Exists(RutaGuardar) Then Directory.CreateDirectory(RutaGuardar)
|
|
' Archivo = Path.GetExtension(Session("AF").ToString)
|
|
' File.Move(RutaArchivo, String.Format("{0}{1}", RutaGuardar, CveActivoFijoResguardo.ToString + "_1" + Archivo))
|
|
' Session("AF") = ""
|
|
' URL = CveActivoFijoResguardo.ToString + "_1" + Archivo
|
|
' End If
|
|
|
|
|
|
' If Session("AF1") IsNot Nothing AndAlso File.Exists(RutaArchivo2) Then
|
|
' If Not Directory.Exists(RutaGuardar) Then Directory.CreateDirectory(RutaGuardar)
|
|
' Archivo2 = Path.GetExtension(Session("AF1").ToString)
|
|
' File.Move(RutaArchivo2, String.Format("{0}{1}", RutaGuardar, CveActivoFijoResguardo.ToString + "_2" + Archivo2))
|
|
' Session("AF1") = ""
|
|
' URL2 = CveActivoFijoResguardo.ToString + "_2" + Archivo2
|
|
' End If
|
|
|
|
|
|
' If ObjResguardos.UpdateActivosFijosResguardos("-1", Observaciones, URL, CveActivoFijoResguardo, -1, URL2) Then
|
|
' GvResguardos.EditIndex = -1
|
|
' ViewState("DTResguardos") = ObjResguardos.DtResultados
|
|
' GvResguardos.DataSource = ObjResguardos.DtResultados
|
|
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
' 'If FechaFin <> "-1" Then DdlResponsable.Enabled = True : DdlResponsable.SelectedValue = "-1"
|
|
' UPEstatus.Update()
|
|
' End If
|
|
|
|
' ObjResguardos.Dispose()
|
|
' GvResguardos.DataBind()
|
|
'End Sub
|
|
|
|
|
|
#Region " ARCHIVO "
|
|
Protected Sub ImgArchivo_Click(sender As Object, e As ImageClickEventArgs)
|
|
CveResguardoPadre = CType(sender, ImageButton).CommandArgument.ToEntero
|
|
EsURL2 = False
|
|
RegistraScript("$('#DivArchivo').modal()")
|
|
End Sub
|
|
Protected Sub ImgArchivo2_Click(sender As Object, e As ImageClickEventArgs)
|
|
CveResguardoPadre = CType(sender, ImageButton).CommandArgument.ToEntero
|
|
EsURL2 = True
|
|
RegistraScript("$('#DivArchivo').modal()")
|
|
End Sub
|
|
Protected Sub btnAddArchivo_Click(sender As Object, e As EventArgs) Handles btnAddArchivo.Click
|
|
Dim FileExtension As String = "-1"
|
|
Dim filesgral As List(Of Archivo) = TxtUpFormato.getfiles().Archivos
|
|
Dim filemove As String = ""
|
|
|
|
|
|
Dim objAF As New ClsAF
|
|
objAF.IniciaTransacSQL()
|
|
Dim HuboError As Boolean = False
|
|
|
|
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(".", "")
|
|
filemove = fileItem.filename
|
|
Next
|
|
|
|
If EsURL2 Then
|
|
If objAF.UpdateActivosFijosResguardosURL("-1", $"AFT{CveResguardoPadre}.{FileExtension}", CveResguardoPadre) Then
|
|
If filemove <> "" Then
|
|
filemove.FilesMove(String.Format("AFT{0}", CveResguardoPadre), String.Format("{0}AF\Resguardos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
Else
|
|
If objAF.UpdateActivosFijosResguardosURL($"AFR{CveResguardoPadre}.{FileExtension}", "-1", CveResguardoPadre) Then
|
|
If filemove <> "" Then
|
|
filemove.FilesMove(String.Format("AFR{0}", CveResguardoPadre), String.Format("{0}AF\Resguardos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If HuboError Then
|
|
objAF.RollBack()
|
|
Alert("Ocurrió un error al guardar el archivo.", TipoMensaje.MsgError)
|
|
Else
|
|
objAF.Commit()
|
|
Alert("El archivo se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
TxtUpFormato.Text = "[]"
|
|
RegistraScript("$('#DivArchivo').modal('hide');")
|
|
End If
|
|
|
|
objAF.Dispose()
|
|
CargaResguardos()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Public Function FormatearNombreArchivo(nombreArchivoOriginal As String) As String
|
|
Dim nombreArchivoFormateado As String
|
|
nombreArchivoFormateado = nombreArchivoOriginal.Replace(" ", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("'", "")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace(Chr(34), "")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("$", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("#", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("%", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("!", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("&", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("?", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("¿", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("¡", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("*", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("~", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("^", "_")
|
|
Return nombreArchivoFormateado
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "GALERIA DE IMAGENES"
|
|
'Protected Sub BtnCargarArchivo_Click(sender As Object, e As System.EventArgs) Handles BtnCargarArchivo.Click
|
|
' If Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\Temp\" & Session("FileUpload").ToString) Then
|
|
' Dim Extension As String = Path.GetExtension(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\Temp\" & Session("FileUpload").ToString)
|
|
' If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Imagenes") Then Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Imagenes")
|
|
' File.Move(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\Temp\" & Session("FileUpload").ToString, ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\" & CveActivoFijo & "_" & ImgConsecutivo & Extension)
|
|
' Session("FileUpload") = ""
|
|
|
|
' If File.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Imagenes" & CveActivoFijo & "_" & ImgConsecutivo & Extension) Then
|
|
' Dim ObjActivosFijos As New ClsAF
|
|
' If ObjActivosFijos.AddActivosFijosImagenes(CveActivoFijo, CveActivoFijo & "_" & ImgConsecutivo & Extension, UsuarioActual.CveUsuario) Then
|
|
' CargarArchivo()
|
|
' Else
|
|
' File.Delete(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & CveEmpresaActual & "\ActivosFijos\Imagenes" & CveActivoFijo & "_" & ImgConsecutivo & Extension)
|
|
' End If
|
|
|
|
' ObjActivosFijos.Dispose()
|
|
|
|
' End If
|
|
' End If
|
|
'End Sub
|
|
|
|
Private Sub BtnUpFotos_Click(sender As Object, e As EventArgs) Handles BtnUpFotos.Click
|
|
|
|
Dim FilesGral As List(Of Archivo) = TxtUpFotos.getfiles().Archivos
|
|
Dim FileMove As String = ""
|
|
Dim NewName As String
|
|
For Each FileItem As Archivo In FilesGral
|
|
Dim Retorno As Boolean = False
|
|
NewName = DateTime.Now.Ticks.ToString
|
|
Dim ObjActivosFijos As New ClsAF
|
|
Try
|
|
FileMove = FileItem.filename
|
|
Dim DirectorioOld As New StringBuilder
|
|
Dim DirectorioNew As New StringBuilder
|
|
DirectorioOld.AppendFormat("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, FileMove)
|
|
DirectorioNew.AppendFormat("{0}AF\", UsuarioActual.Empresa.Ruta)
|
|
If Not Directory.Exists(DirectorioNew.ToString) Then
|
|
Directory.CreateDirectory(DirectorioNew.ToString)
|
|
End If
|
|
NewName = String.Format("{0}{1}", NewName, IO.Path.GetExtension(DirectorioOld.ToString()))
|
|
DirectorioNew.Append(NewName)
|
|
If ObjActivosFijos.AddActivosFijosImagenes(CveActivoFijo, String.Format("AF/{0}", NewName), UsuarioActual.CveUsuario) Then
|
|
CargarArchivo()
|
|
My.Computer.FileSystem.MoveFile(DirectorioOld.ToString, DirectorioNew.ToString)
|
|
Else
|
|
End If
|
|
Retorno = True
|
|
Catch ex As Exception
|
|
End Try
|
|
|
|
ObjActivosFijos.Dispose()
|
|
RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();")
|
|
TxtUpFotos.Text = "[]"
|
|
UpUpFotos.Update()
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminarFoto_Click(sender As Object, e As System.EventArgs)
|
|
Dim CveImagenActivoFijo As Integer = 0
|
|
CveImagenActivoFijo = Integer.Parse(DirectCast(sender, Button).CommandArgument)
|
|
|
|
If (CveImagenActivoFijo > 0) Then
|
|
Dim ObjActivoFijo As New ClsAF
|
|
If ObjActivoFijo.RemoveActivosFijosImagenes(CveImagenActivoFijo) Then
|
|
File.Delete(String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjActivoFijo.DtResultados.Rows(0)("URL")))
|
|
CargarArchivo()
|
|
RegistraScript("initcarusel();")
|
|
End If
|
|
ObjActivoFijo.Dispose()
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
Private Sub CargarArchivo()
|
|
Dim StrBuilder As New StringBuilder
|
|
Dim TmpDT As DataTable = Nothing
|
|
Dim ObjActivoFijo As New ClsAF
|
|
|
|
If ObjActivoFijo.GetActivosFijosImagenes(CveActivoFijo) Then
|
|
TmpDT = ObjActivoFijo.DtResultados
|
|
Else
|
|
TmpDT = Nothing
|
|
End If
|
|
ObjActivoFijo.Dispose()
|
|
RptFotos.DataSource = TmpDT
|
|
RptFotos.DataBind()
|
|
upGaleria.Update()
|
|
'myGallery.InnerHtml = ""
|
|
'If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
|
|
' For Each Row As DataRow In TmpDT.Rows
|
|
' StrBuilder.AppendFormat("<li><img src=""/ashx/SIGWeb.ashx?Metodo=GetImg&r={0}"" /></li>", Encripta(Row("URL").ToString))
|
|
' Next
|
|
' myGallery.InnerHtml = StrBuilder.ToString
|
|
' ViewState("ImgConsecutivo") = TmpDT.Rows(0)("ImgConsecutivo").ToString
|
|
' TmpDT.Dispose()
|
|
' RegistraScript("$(function () { $('#myGallery').galleryView(); });")
|
|
'Else
|
|
' ViewState("ImgConsecutivo") = "1"
|
|
'End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
|
|
BtnGuardar2()
|
|
End Sub
|
|
|
|
Private Sub BtnGuardar2()
|
|
Dim ObjAF As New ClsAF
|
|
Dim ObjInventarios As New ClsInventarios(ObjAF.IniciaTransacSQL())
|
|
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
|
|
Dim CveMovimientoSalidaInv = -1
|
|
If AFInvCvePS > 0 AndAlso AFInvCveAlmacen > 0 Then
|
|
Dim CveUMInv = GlobalDTPS(CveEmpresaActual, CvePS:=AFInvCvePS).FiltroPrimeroValor("CveUM").ToEntero
|
|
If CveUMInv > 0 Then
|
|
CveMovimientoSalidaInv = ObjInventarios.AddMovimiento(AFInvCveAlmacen, 3, 1, Now, -1, UsuarioActual.CveUsuario, CveEmpresaActual, -1, -1, -1, -1, Observaciones:=$"Salida de inventario para Activo Fijo | {TxtCodigo.Text.Trim}", Modulo:="AF1")
|
|
If Not ObjInventarios.AddMovimientoDetalle(CveMovimientoSalidaInv, 1, CveUMInv, AFInvCvePS, 0, -1, Serie:=AFInvSerie, CveSeccionAlmacen:=AFInvCveSeccionAlmacen) Then
|
|
ErrorGuardar = True
|
|
End If
|
|
Else
|
|
ErrorGuardar = True
|
|
End If
|
|
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,
|
|
FechaBaja:=FechaBaja) > 0 Then
|
|
ViewState("CveActivoFijo") = ObjAF.CveActivoFijo
|
|
Else
|
|
ErrorGuardar = True
|
|
End If
|
|
|
|
If Not ErrorGuardar Then
|
|
|
|
For Each GvRowProduccion As GridViewRow In GvProduccion.Rows
|
|
If Not ObjAF.AddProduccion(ObjAF.CveActivoFijo, GvRowProduccion.DataKey("CveCultivoCuadroDetalle").ToEntero, GvRowProduccion.DataKey("Cantidad").ToDecimal, GvRowProduccion.DataKey("Fecha").ToDate, UsuarioActual.CveUsuario) Then
|
|
ErrorGuardar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
|
|
If Not ErrorGuardar Then
|
|
For Each GvRowPlagaEnfermedad As GridViewRow In GvPlagaEnfermedad.Rows
|
|
If Not ObjAF.AddPlagaEnfermedad(ObjAF.CveActivoFijo, GvRowPlagaEnfermedad.DataKey("Observaciones"), GvRowPlagaEnfermedad.DataKey("Fecha").ToDate, UsuarioActual.CveUsuario) Then
|
|
ErrorGuardar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
|
|
If Not ErrorGuardar Then
|
|
|
|
|
|
For Each GvRowMantenimiento As GridViewRow In GvMantenimientos.Rows
|
|
|
|
Dim CveMantenimientoTemp As Integer = ObjAF.AddMantenimientos(ObjAF.CveActivoFijo, GvRowMantenimiento.DataKey("Mantenimiento"), GvRowMantenimiento.DataKey("Observaciones"), GvRowMantenimiento.DataKey("Fecha").ToDate, UsuarioActual.CveUsuario, "")
|
|
|
|
If CveMantenimientoTemp > 0 Then
|
|
|
|
If GvRowMantenimiento.DataKey("Archivo").Trim.Length > 0 Then
|
|
|
|
Dim fi As New FileInfo(GvRowMantenimiento.DataKey("Archivo").Trim)
|
|
|
|
If fi.Exists Then
|
|
|
|
Dim Filename As String = fi.Name
|
|
Dim FileExtension As String = IO.Path.GetExtension(fi.FullName)
|
|
|
|
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
|
|
ErrorGuardar = True
|
|
Alert("Error al mover Archivo", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
If Not ErrorGuardar Then
|
|
If Not ObjAF.UpdateMantenimientos(CveMantenimientoTemp, ObjAF.CveActivoFijo, GvRowMantenimiento.DataKey("Mantenimiento"), GvRowMantenimiento.DataKey("Observaciones"), GvRowMantenimiento.DataKey("Fecha").ToDate, UsuarioActual.CveUsuario, $"{CveMantenimientoTemp}{FileExtension}") Then
|
|
ErrorGuardar = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
ErrorGuardar = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
'PREPOLIZA DE IMPORTACION DESDE ALMACEN
|
|
If AFInvCvePS > 0 AndAlso AFInvCveAlmacen > 0 Then
|
|
Dim IDCtaContableInv = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={AFInvCveAlmacen}").ToEntero
|
|
'Dim CveCuentaInv = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen={AFInvCveAlmacen}").ToEntero
|
|
If Not ErrorGuardar Then
|
|
Dim CvePrePoliza As Integer = ObjContabilidad.AddPrePolizas("AF/ImportadoInv", 4, TxtValorCompra.Text.ToDouble, TxtValorCompra.Text.ToDouble, 1, Now, $"AF importado de Almacén {TxtCodigo.Text.Trim}", UsuarioActual.CveUsuario, CveEmpresaActual)
|
|
If ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, False, TxtValorCompra.Text.ToDecimal, $"{TxtCodigo.Text.Trim} - {TxtDescripcion.Text.Trim}", 49, $"{TxtCodigo.Text.Trim} - {TxtDescripcion.Text.Trim}", Now, DdlCtaContable.SelectedValue.Trim.ToEntero, -1, CveActivoFijo:=CveActivoFijo, ImporteMX:=TxtValorCompra.Text.ToDecimal, CveCuenta:=If(UsuarioActual.Empresa.UsaContabilidad AndAlso UsuarioActual.Empresa.UsaContabilidadSIG, ObtenerCuentaDobleConta(DdlCtaContable.SelectedValue.Trim.ToEntero, UsuarioActual.CveEmpresa), -1)) Then
|
|
If Not ErrorGuardar Then
|
|
If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, True, TxtValorCompra.Text.ToDecimal, TxtCodigo.Text.Trim, 68, TxtCodigo.Text.Trim, Now, IDCtaContableInv, -1, CveMovimientoAlmacen:=CveMovimientoSalidaInv, ImporteMX:=TxtValorCompra.Text.ToDecimal) Then
|
|
ErrorGuardar = True
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
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,
|
|
FechaBaja:=FechaBaja) Then
|
|
|
|
'Comentado porque te redirecciona no se ocupa - 22 Enero 2016 - Israel Piña
|
|
'CargaDatos()
|
|
'GVHistModificaciones.DataSource = ObjAF.DtResultados
|
|
'GVHistModificaciones.DataBind()
|
|
'UPHistModificaciones.Update()
|
|
'UpDatos.Update()
|
|
' GuardaValores()
|
|
ErrorGuardar = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorGuardar Then
|
|
For Each DR As GridViewRow In GvC.Rows
|
|
Dim CveCaracteristicaOpcion As Integer = -1
|
|
Dim CveValor As Integer = DR.FCHiddenField("HdnCveValor").Value.ToEntero
|
|
Dim Valor As String = DR.FCTextBox("TxtValor").Text.Trim
|
|
Dim tCveCaracteristica As Integer = DR.FCHiddenField("HdnCveCaracteristica").Value.ToEntero
|
|
Select Case DR.FCHiddenField("HdnEsOpcion").Value
|
|
Case "1" 'Listado o DropDownList
|
|
CveCaracteristicaOpcion = DR.FCDropDownList("DdlRespuesta").SelectedValue.ToEntero
|
|
Case "2" 'Radio o RadioButtonList
|
|
CveCaracteristicaOpcion = DR.FCRadioButtonList("RbRespuesta").SelectedValue.ToEntero
|
|
Case "5"
|
|
Valor = DR.FCCheckBox("ChbValor").Checked.ToString
|
|
Case "6" 'Numerico
|
|
Valor = DR.FCTextBox("TxtValorNum").Text.Trim
|
|
End Select
|
|
|
|
If Not ObjAF.AddUpdActivosFijosValores(CveActivoFijo, tCveCaracteristica, CveCaracteristicaOpcion, If(Valor = "", "-1", Valor), UsuarioActual.CveUsuario) Then
|
|
ErrorGuardar = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If Not ErrorGuardar Then
|
|
'Comentado porque te redirecciona no se ocupa - 22 Enero 2016 - Israel Piña
|
|
' GVHistModificaciones.DataSource = ObjAF.DtResultados
|
|
' GVHistModificaciones.DataBind()
|
|
' UPHistModificaciones.Update()
|
|
|
|
ObjAF.Commit()
|
|
Alert("El Activo Fijo se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/AF/CatAF.aspx"";")
|
|
Else
|
|
ObjAF.RollBack()
|
|
Alert("Ocurrió un error al actualizar el Activo Fijo. Por favor vuelva a intentar o comuniquese con servicio técnico", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click
|
|
Dim ObjActivoFijo As New ClsAF()
|
|
If ObjActivoFijo.RemoveActivosFijos(CveActivoFijo) Then
|
|
Alert("El Activo Fijo se Eliminó correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/AF/CatAF.aspx""")
|
|
End If
|
|
ObjActivoFijo.Dispose()
|
|
End Sub
|
|
|
|
#Region "CLASIFICACIONES CARACTERISTICAS"
|
|
|
|
Protected Sub GvCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvC.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If CaracClasif <> e.Row.DBCampo("CaracteristicaClasificacion") OrElse e.Row.RowIndex = 0 Then
|
|
CaracClasif = e.Row.DBCampo("CaracteristicaClasificacion")
|
|
e.Row.FCLabel("LblClasif").Text = e.Row.DBCampo("CaracteristicaClasificacion")
|
|
e.Row.FindControl("PnlClasif").Visible = True
|
|
End If
|
|
|
|
Dim TipoCampo As Integer = e.Row.DBCampo("TipoCampo").ToEntero
|
|
Dim tCveCaracteristica As Integer = e.Row.DBCampo("CveCaracteristica").ToEntero
|
|
Select Case TipoCampo
|
|
Case 0, 4 'Texto, Multiline
|
|
With e.Row.FCTextBox("TxtValor")
|
|
.Visible = True
|
|
If TipoCampo = 4 Then
|
|
.Rows = 3
|
|
.TextMode = TextBoxMode.MultiLine
|
|
End If
|
|
.Text = e.Row.DBCampo("Valor")
|
|
If e.Row.DBCampo("Requerida") = "True" Then
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").Enabled = True
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").ControlToValidate = "TxtValor"
|
|
End If
|
|
End With
|
|
Case 1, 2 'DropDownList, Radios
|
|
Dim dt As DataTable = DTAFCaracteristicas.FiltraParametros(String.Format("CveCaracteristica = {0} And EstatusOpcion ='True' AND CveCaracteristicaOpcion > 0 ", tCveCaracteristica))
|
|
If TipoCampo = 1 Then
|
|
With e.Row.FCDropDownList("DdlRespuesta")
|
|
.Visible = True
|
|
.DataTextField = "CaracteristicaOpcion"
|
|
.DataValueField = "CveCaracteristicaOpcion"
|
|
.DataSource = dt
|
|
.DataBind()
|
|
.Items.Insert(0, New ListItem("Seleccione", "-1")) '63636363636363
|
|
'.SelectedValue = e.Row.DBCampo("CveValor")
|
|
.SelectedValue = e.Row.DBCampo("CveOpcion")
|
|
If e.Row.DBCampo("Requerida") = "True" Then
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").Enabled = True
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").ControlToValidate = "DdlRespuesta"
|
|
End If
|
|
End With
|
|
ElseIf TipoCampo = 2 Then
|
|
With e.Row.FCRadioButtonList("RbRespuesta")
|
|
.Visible = True
|
|
.DataSource = dt
|
|
.DataBind()
|
|
.SelectedValue = e.Row.DBCampo("CveOpcion")
|
|
End With
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").ErrorMessage = String.Format("ERROR: Falta contestar la pregunta: <b>{0}</b>", e.Row.DBCampo("Caracteristica"))
|
|
End If
|
|
Case 3 'Fecha
|
|
With e.Row.FCTextBox("TxtValor")
|
|
.Visible = True
|
|
.Width = New Unit(80)
|
|
.Text = e.Row.DBCampo("Valor")
|
|
End With
|
|
e.Row.FCImageButton("ImgTxtValor").Visible = True
|
|
e.Row.FCMaskedEditExtender("MEETxtValor").Enabled = True
|
|
e.Row.FCCalendarExtender("CETxtValor").Enabled = True
|
|
e.Row.FCCompareValidator("CVTxtValor").Enabled = True
|
|
e.Row.FCCompareValidator("CVTxtValor").Type = ValidationDataType.Date
|
|
Case 5 'Checkbox
|
|
With e.Row.FCCheckBox("ChbValor")
|
|
.Visible = True
|
|
.Text = e.Row.DBCampo("Caracteristica")
|
|
'.Checked = CBool(e.Row.DBCampo("Valor").ToEntero)
|
|
.Checked = (e.Row.DBCampo("Valor") = "True")
|
|
End With
|
|
|
|
Case 6 ' Numerico
|
|
With e.Row.FCTextBox("TxtValorNum")
|
|
.Visible = True
|
|
.Text = e.Row.DBCampo("Valor")
|
|
e.Row.FCCompareValidator("CVTxtValor").Enabled = True
|
|
e.Row.FCCompareValidator("CVTxtValor").Type = ValidationDataType.Integer
|
|
|
|
If e.Row.DBCampo("Requerida") = "True" Then
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").Enabled = True
|
|
e.Row.FCRequiredFieldValidator("RFVRbRespuesta").ControlToValidate = "TxtValorNum"
|
|
End If
|
|
End With
|
|
|
|
|
|
End Select
|
|
End If
|
|
'End If
|
|
End Sub
|
|
Private Sub CargaCaracteristicas()
|
|
|
|
CaracClasif = ""
|
|
Dim ObjAFCaracteristicas As New ClsAF
|
|
If ObjAFCaracteristicas.GetActivosFijosValores(CveActivoFijo, CveEmpresaActual) Then
|
|
|
|
Dim Filtro = If(DdlSubTipoActivoFijo.SelectedValue.ToEntero > 0, String.Format("CveSubTipoActivoFijo = {0} OR (CveTipoActivoFijo = {1} AND CveSubTipoActivoFijo IS NULL)", DdlSubTipoActivoFijo.SelectedValue, DdlTipoActivoFijo.SelectedValue), String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue))
|
|
GvC.DataSource = ObjAFCaracteristicas.DtResultados.FiltraParametros(Filtro, "CaracteristicaClasificacion, Orden")
|
|
|
|
If ObjAFCaracteristicas.GetCaracteristicasOpcionesSubTipo(-1, DdlSubTipoActivoFijo.SelectedValue.ToEntero, CveEmpresaActual) Then
|
|
DTAFCaracteristicas = ObjAFCaracteristicas.DtResultados '.FiltraParametros("SubtipoActivoFijo = '" + DdlSubTipoActivoFijo.SelectedValue + "'") 'FiltraParametros("EstatusOpcion = 'True'")
|
|
End If
|
|
|
|
End If
|
|
ObjAFCaracteristicas.Dispose()
|
|
GvC.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
'Protected Sub GuardaValores()
|
|
' Dim ObjActivoFijo As New ClsAF
|
|
|
|
' For Each DR As GridViewRow In GvC.Rows
|
|
' Dim CveCaracteristicaOpcion As Integer = -1
|
|
' Dim CveValor As Integer = DR.FCHiddenField("HdnCveValor").Value.ToEntero
|
|
' Dim Valor As String = DR.FCTextBox("TxtValor").Text.Trim
|
|
' Dim CveCaracteristica As Integer = DR.FCHiddenField("HdnCveCaracteristica").Value.ToEntero
|
|
' Select Case DR.FCHiddenField("HdnEsOpcion").Value
|
|
' Case "1" 'Listado o DropDownList
|
|
' CveCaracteristicaOpcion = DR.FCDropDownList("DdlRespuesta").SelectedValue.ToEntero
|
|
' Case "2" 'Radio o RadioButtonList
|
|
' CveCaracteristicaOpcion = DR.FCRadioButtonList("RbRespuesta").SelectedValue.ToEntero
|
|
' Case "5"
|
|
' Valor = DR.FCCheckBox("ChbValor").Checked.ToString
|
|
' Case "6" 'Numerico
|
|
' Valor = DR.FCTextBox("TxtValorNum").Text.Trim
|
|
' End Select
|
|
|
|
' ObjActivoFijo.AddUpdActivosFijosValores(CveActivoFijo, CveCaracteristica, CveCaracteristicaOpcion, If(Valor = "", "-1", Valor), UsuarioActual.CveUsuario)
|
|
|
|
' Next
|
|
' GVHistModificaciones.DataSource = ObjActivoFijo.DtResultados
|
|
' GVHistModificaciones.DataBind()
|
|
' UPHistModificaciones.Update()
|
|
' ObjActivoFijo.Dispose()
|
|
'End Sub
|
|
|
|
|
|
'Private Sub GuardarAFCaracteristica()
|
|
' If CveActivoFijo = -1 Then
|
|
|
|
' Dim Correcto As Boolean = True
|
|
' Dim ObjActivosFijos As New ClsAF
|
|
|
|
' Dim RetValue As Integer = ObjActivosFijos.AddActivosFijos2(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, TxtPorDeduccion.Text.Trim.ToDouble, UsuarioActual.CveUsuario, CveEmpresaActual)
|
|
|
|
' If RetValue > 0 OrElse RetValue = -2 Then
|
|
' Dim tCveActivoFijo As Integer = ObjActivosFijos.CveActivoFijo
|
|
' Dim Actualizar As Boolean = False
|
|
' 'registro la encuesta
|
|
' Dim Clave As Integer = 0
|
|
' 'verifico si ya existe una encuesta registrada
|
|
' If ObjActivosFijos.GetActivosFijosValores(tCveActivoFijo, CveEmpresaActual) Then
|
|
' If ObjActivosFijos.DtResultados.Rows.Count > 0 Then
|
|
' Clave = ObjActivosFijos.DtResultados(0)("CveCaracteristica").ToString.ToEntero
|
|
|
|
' Actualizar = True
|
|
|
|
' End If
|
|
' End If
|
|
|
|
' If Clave > 0 Then
|
|
|
|
|
|
' For Each gvr As GridViewRow In GvC.Rows
|
|
|
|
' Dim CveOpcion As Integer = -1
|
|
' Dim Valor As String = gvr.FCTextBox("TxtValor").Text.Trim
|
|
|
|
' Select Case gvr.DataKey("PreguntaTipo")
|
|
' Case "1" 'Listado o DropDownList
|
|
' CveOpcion = gvr.FCDropDownList("DdlRespuesta").SelectedValue.ToEntero
|
|
' Case "2" 'Radio o RadioButtonList
|
|
' CveOpcion = gvr.FCRadioButtonList("RbRespuesta").SelectedValue.ToEntero
|
|
' End Select
|
|
' Next
|
|
' Else
|
|
' Correcto = False
|
|
' Alert("El Prospecto ya tiene esta encuesta registrada")
|
|
' End If
|
|
' Else
|
|
' Correcto = False
|
|
' ObjActivosFijos.Dispose()
|
|
|
|
' End If
|
|
' End If
|
|
'End Sub
|
|
'Private Sub GuardarCaracteristicas()
|
|
' Dim ObjActivoFijoValores As New ClsAF
|
|
|
|
' For Each GridValores As GridViewRow In GvC.Rows
|
|
' Dim CveOpcion As Integer = -1
|
|
' Dim Valor As String = GridValores.FCTextBox("TxtValor").Text.Trim
|
|
|
|
' Select Case GridValores.DataKey("TipoCampo")
|
|
' Case "1" 'Listado o DropDownList
|
|
' CveOpcion = GridValores.FCDropDownList("DdlRespuesta").SelectedValue.ToEntero
|
|
' Case "2" 'Radio o RadioButtonList
|
|
' CveOpcion = GridValores.FCRadioButtonList("RbRespuesta").SelectedValue.ToEntero
|
|
' End Select
|
|
|
|
' If GridValores.DataKey("CveCaracteristica").ToEntero > 0 Then
|
|
' If CveActivoFijo > 0 Then
|
|
' If ObjActivoFijoValores.AddActivosFijosValores(CveActivoFijo, CveCaracteristica, CveOpcion, Valor, UsuarioActual.CveUsuario) Then
|
|
' Alert("por aqui pasó" & CveActivoFijo & "")
|
|
' Exit For
|
|
' End If
|
|
' ObjActivoFijoValores.Dispose()
|
|
|
|
' End If
|
|
' End If
|
|
' Next
|
|
|
|
'End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "B I T A C O R A"
|
|
|
|
Private Sub CargaBitacora()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "E V E N T O - B I T A C O R A"
|
|
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(200)
|
|
e.Row.Cells(1).Width = Unit.Pixel(200)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(500)
|
|
End If
|
|
|
|
If e.Row.DBCampo("Archivo").ToString <> "" Then
|
|
e.Row.FCLinkButton("LinkArchivo").Visible = True
|
|
e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString)
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
End If
|
|
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
Dim filemove As String = ""
|
|
|
|
For Each fileItem As Archivo In filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
filemove = fileItem.filename
|
|
Next
|
|
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, CveEmpresaActual, CveActivoFijo:=CveActivoFijo) Then
|
|
If filemove <> "" Then
|
|
filemove.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", CveEmpresaActual))
|
|
End If
|
|
|
|
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados
|
|
TxtEventoDescripcion.Text = ""
|
|
Anexo.Text = "[]"
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
CargaEventoBitacora()
|
|
UPAddEventoBitacora.Update()
|
|
End Sub
|
|
Private Sub CargaEventoBitacora()
|
|
|
|
Dim ObjEventoBitacora As New ClsOIEventos()
|
|
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, CveEmpresaActual, CveActivoFijo:=CveActivoFijo) Then
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
|
|
Else
|
|
GvEB.DataSource = Nothing
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
|
|
Dim Archivo As New System.IO.FileInfo(filePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
HttpContext.Current.Response.TransmitFile(filePath)
|
|
HttpContext.Current.Response.Flush()
|
|
HttpContext.Current.Response.End()
|
|
|
|
Archivo = Nothing
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " H I S T O R I A L"
|
|
Protected Sub GVHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVHistorial.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
ElseIf e.Row.FCLiteral("LtlFecha").Text = String.Empty Then
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Private Sub CargarHistorial()
|
|
Dim ObjHistorial As New ClsAF
|
|
If ObjHistorial.GetActivosFijosCompras(CveActivoFijo) Then
|
|
DTCompras = ObjHistorial.DtResultados
|
|
GVHistorial.DataSource = DTCompras
|
|
Else
|
|
GVHistorial.DataSource = Nothing
|
|
End If
|
|
|
|
If DTCompras IsNot Nothing And DTCompras.Rows.Count > 0 Then
|
|
BtnPDFCompras.Visible = True
|
|
BtnExcelCompras.Visible = True
|
|
End If
|
|
|
|
ObjHistorial.Dispose()
|
|
GVHistorial.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "H I S T O R I A L - M O D I F I C A C I O N E S"
|
|
Protected Sub GVHistModificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVHistModificaciones.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(160)
|
|
e.Row.Cells(1).Width = Unit.Pixel(70)
|
|
e.Row.Cells(2).Width = Unit.Pixel(150)
|
|
e.Row.Cells(3).Width = Unit.Pixel(300)
|
|
e.Row.Cells(4).Width = Unit.Pixel(300)
|
|
End If
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
Private Sub CargarHistorialModificaciones()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetHistorialBitacora(-1, -1, CveActivoFijo, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
GVHistModificaciones.DataSource = ObjGral.DtResultados
|
|
Else
|
|
GVHistModificaciones.DataSource = Nothing
|
|
End If
|
|
ObjGral.Dispose()
|
|
GVHistModificaciones.DataBind()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "GUARDAR ARCHIVO"
|
|
Protected Sub BtnGuardaArchivo1_Click(sender As Object, e As ImageClickEventArgs)
|
|
Dim objResguardos As New ClsAF
|
|
Dim cve = CType(sender, ImageButton).CommandArgument.ToEntero
|
|
Dim btn As ImageButton = CType(sender, ImageButton)
|
|
Dim URL As String = cve.ToString
|
|
Dim RutaGuardar = ""
|
|
Dim RutaArchivo = ""
|
|
|
|
Dim Archivo As String = ""
|
|
|
|
|
|
RutaGuardar = String.Format("{0}AF\Resguardos\", UsuarioActual.Empresa.Ruta)
|
|
RutaArchivo = String.Format("{0}AF\Resguardos\Temp\{1}", UsuarioActual.Empresa.Ruta, Session("AF"))
|
|
|
|
|
|
If Session("AF") IsNot Nothing AndAlso File.Exists(RutaArchivo) Then
|
|
If Not Directory.Exists(RutaGuardar) Then Directory.CreateDirectory(RutaGuardar)
|
|
Archivo = Path.GetExtension(Session("AF").ToString)
|
|
File.Move(RutaArchivo, String.Format("{0}{1}", RutaGuardar, cve.ToString + "_1" + Archivo))
|
|
Session("AF") = ""
|
|
End If
|
|
|
|
|
|
|
|
|
|
If objResguardos.UpdateActivosFijosResguardosURL(cve.ToString + "_1" + Archivo, "-1", cve) Then
|
|
GvResguardos.EditIndex = -1
|
|
ViewState("DTResguardos") = objResguardos.DtResultados
|
|
GvResguardos.DataSource = objResguardos.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
UPEstatus.Update()
|
|
End If
|
|
|
|
objResguardos.Dispose()
|
|
GvResguardos.DataBind()
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardaArchivo2_Click(sender As Object, e As ImageClickEventArgs)
|
|
Dim objResguardos As New ClsAF
|
|
Dim cve = CType(sender, ImageButton).CommandArgument.ToEntero
|
|
Dim btn As ImageButton = CType(sender, ImageButton)
|
|
Dim URL As String = cve.ToString
|
|
Dim RutaGuardar = ""
|
|
Dim RutaArchivo2 = ""
|
|
Dim Archivo2 As String = ""
|
|
|
|
|
|
RutaGuardar = String.Format("{0}AF\Resguardos\", UsuarioActual.Empresa.Ruta)
|
|
RutaArchivo2 = (String.Format("{0}AF\Resguardos\Temp\{1}", UsuarioActual.Empresa.Ruta, Session("AF1")))
|
|
|
|
|
|
|
|
If Session("AF1") IsNot Nothing AndAlso File.Exists(RutaArchivo2) Then
|
|
If Not Directory.Exists(RutaGuardar) Then Directory.CreateDirectory(RutaGuardar)
|
|
Archivo2 = Path.GetExtension(Session("AF1").ToString)
|
|
File.Move(RutaArchivo2, String.Format("{0}{1}", RutaGuardar, cve.ToString + "_2" + Archivo2))
|
|
Session("AF1") = ""
|
|
End If
|
|
|
|
If objResguardos.UpdateActivosFijosResguardosURL("-1", cve.ToString + "_2" + Archivo2, cve) Then
|
|
ViewState("DTResguardos") = objResguardos.DtResultados
|
|
GvResguardos.DataSource = objResguardos.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
UPEstatus.Update()
|
|
End If
|
|
|
|
objResguardos.Dispose()
|
|
GvResguardos.DataBind()
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub DdlSubTipoActivoFijo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubTipoActivoFijo.SelectedIndexChanged
|
|
CargaCaracteristicas()
|
|
CargaDispositivos()
|
|
ModalidadesPaginaAF()
|
|
|
|
End Sub
|
|
|
|
#Region "CARGAR CUENTA CONTABLE"
|
|
|
|
Private Sub CargaCuentasContables()
|
|
trCuentaContable.Visible = True
|
|
|
|
|
|
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim DtCuentas As New DataTable
|
|
Dim CuentaPadre = UsuarioActual.Empresa.Funcionalidad(221).ToEntero
|
|
|
|
If Conta.GetCuentasRecursiva(CuentaPadre, 1) Then
|
|
DtCuentas = Conta.DtResultados
|
|
Else
|
|
DtCuentas = Nothing
|
|
Alert("Ocurrió un error al obtener las Cuentas Contables.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Conta.Dispose()
|
|
|
|
DdlCtaContable.DataSource = DtCuentas
|
|
DdlCtaContable.DataBind()
|
|
|
|
DdlCtaContableDepreciacion.DataSource = DtCuentas
|
|
DdlCtaContableDepreciacion.DataBind()
|
|
|
|
End Sub
|
|
|
|
Private Sub ActivarRegistroCuentaAF()
|
|
If DdlCtaContable.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(221).ToEntero > 0 Then
|
|
BtnCtaContable.Visible = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnCtaContable_Click(sender As Object, e As EventArgs) Handles BtnCtaContable.Click
|
|
Dim IdCuentaContable As Integer = -1
|
|
Dim CtaCodigo As String = ""
|
|
Dim TieneError = False
|
|
|
|
Dim CuentaPadre = UsuarioActual.Empresa.Funcionalidad(221).ToEntero
|
|
|
|
Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim ObjAF As New ClsAF()
|
|
ObjContaAC.IniciaTransacSQL()
|
|
ObjAF.IniciaTransacSQL()
|
|
|
|
Dim NombreCuenta = If(TxtDescripcion.Text.Trim.Length > 50, TxtDescripcion.Text.Trim.Substring(0, 50), TxtDescripcion.Text.Trim)
|
|
|
|
IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, NombreCuenta, "D", 2)
|
|
If IdCuentaContable > 0 Then
|
|
ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1)
|
|
Dim dt = ObjContaAC.DtResultados
|
|
|
|
If dt.Rows.Count = 1 Then
|
|
|
|
Dim row As DataRow = dt.Rows(0)
|
|
CtaCodigo = CStr(row("CtaCodigo"))
|
|
|
|
If Not ObjAF.UpdateActivosFijosCuentaAC(CveActivoFijo, IdCuentaContable, UsuarioActual.CveUsuario) Then
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion))
|
|
DdlCtaContable.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString)) : DdlCtaContable.SelectedValueExist(IdCuentaContable.ToString)
|
|
BtnCtaContable.Visible = False
|
|
ObjAF.Commit()
|
|
ObjContaAC.Commit()
|
|
Else
|
|
Alert("Ocurrio un erro al registrar la Cuenta Contable", TipoMensaje.MsgError)
|
|
ObjAF.RollBack()
|
|
ObjContaAC.RollBack()
|
|
End If
|
|
|
|
ObjContaAC.Dispose()
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "IMPRESIÓN FULL"
|
|
Private Sub GenerarPDF(Optional Formato As String = "PDF")
|
|
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetActivosFijos(CveActivoFijo, CveEmpresaActual, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then
|
|
If ObjAF.DtResultados.Rows.Count > 0 Then
|
|
|
|
Dim datasource As DataTable = New DataTable
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("Codigo", ObjAF.Codigo))
|
|
params.Add(New ReportParameter("Descripcion", ObjAF.Descripcion))
|
|
params.Add(New ReportParameter("TipoAF", If(DdlTipoActivoFijo.SelectedValue = "-1", "", DdlTipoActivoFijo.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("SubTipoAF", If(DdlSubTipoActivoFijo.SelectedValue = "-1", "", DdlSubTipoActivoFijo.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("ValorCompra", ObjAF.ValorCompra.ToString.FormatoNumero))
|
|
params.Add(New ReportParameter("FechaCompra", ObjAF.FechaCompra.ToShortDateString))
|
|
params.Add(New ReportParameter("NoSerie", ObjAF.NoSerie))
|
|
params.Add(New ReportParameter("Año", ObjAF.Año.ToString))
|
|
params.Add(New ReportParameter("Estado", If(DdlEstadoActivoFijo.SelectedValue = "-1", "", DdlEstadoActivoFijo.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("Responsable", If(DdlResponsable.SelectedValue = "-1", "", DdlResponsable.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("Proyecto", If(DdlProyecto.SelectedValue = "-1", "", DdlProyecto.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("SubProyecto", If(DdlSubProyecto.SelectedValue = "-1", "", DdlSubProyecto.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("Observaciones", ObjAF.Observaciones))
|
|
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
|
|
|
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", $"file://{Imagen}"))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
Dim ObjHistorial As New ClsAF()
|
|
|
|
If ObjHistorial.GetActivosFijosCompras(CveActivoFijo) Then
|
|
datasource = ObjHistorial.DtResultados
|
|
Else
|
|
datasource = Nothing
|
|
End If
|
|
|
|
Dim datasource2 As DataTable = New DataTable
|
|
If ObjHistorial.GetActivosFijosResguardos(CveActivoFijo, -1, -1, -1) Then
|
|
datasource2 = ObjHistorial.DtResultados
|
|
End If
|
|
|
|
Dim lrds As New List(Of ReportDataSource)
|
|
Dim rds As New ReportDataSource
|
|
rds.Name = "DataSet1"
|
|
rds.Value = datasource
|
|
lrds.Add(rds)
|
|
|
|
Dim rds2 As New ReportDataSource
|
|
rds2.Name = "DataSet2"
|
|
rds2.Value = datasource2
|
|
lrds.Add(rds2)
|
|
|
|
Dim rds3 As New ReportDataSource
|
|
rds3.Name = "DataSet3"
|
|
rds3.Value = Placas
|
|
lrds.Add(rds3)
|
|
|
|
Dim rds4 As New ReportDataSource
|
|
rds4.Name = "DataSet4"
|
|
rds4.Value = Licencias
|
|
lrds.Add(rds4)
|
|
|
|
Dim rds5 As New ReportDataSource
|
|
rds5.Name = "DataSet5"
|
|
rds5.Value = Polizas
|
|
lrds.Add(rds5)
|
|
|
|
Dim rds6 As New ReportDataSource
|
|
rds6.Name = "DataSet6"
|
|
rds6.Value = Eventos
|
|
lrds.Add(rds6)
|
|
|
|
ObjHistorial.Dispose()
|
|
ImprimirPDFMultiDS("Empresas/Grales/Formatos/AF.rdlc", lrds, params, $"AF_{ObjAF.CveActivoFijo}", Formato)
|
|
Else
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
|
|
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
|
GenerarPDF("PDF")
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "Codigo Barras"
|
|
'Codigo barras/QR se retorna como una imagen bmp
|
|
Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String) As Byte()
|
|
|
|
Dim barcodeWriter As New BarcodeWriter
|
|
Dim opciones As New ZXing.Common.EncodingOptions
|
|
Dim FormatoBar As New BarcodeFormat
|
|
'Dim Respuesta As Byte()
|
|
|
|
opciones.Height = Alto
|
|
opciones.Width = Largo
|
|
opciones.Margin = Margen
|
|
|
|
barcodeWriter.Options = opciones
|
|
|
|
Select Case Formato
|
|
Case "All_1D"
|
|
barcodeWriter.Format = BarcodeFormat.All_1D
|
|
Exit Select
|
|
Case "AZTEC"
|
|
barcodeWriter.Format = BarcodeFormat.AZTEC
|
|
Exit Select
|
|
Case "CODABAR"
|
|
barcodeWriter.Format = BarcodeFormat.CODABAR
|
|
Exit Select
|
|
Case "CODE_128"
|
|
barcodeWriter.Format = BarcodeFormat.CODE_128
|
|
Exit Select
|
|
Case "CODE_39"
|
|
barcodeWriter.Format = BarcodeFormat.CODE_39
|
|
Exit Select
|
|
Case "CODE_93"
|
|
barcodeWriter.Format = BarcodeFormat.CODE_93
|
|
Exit Select
|
|
Case "DATA_MATRIX"
|
|
barcodeWriter.Format = BarcodeFormat.DATA_MATRIX
|
|
Exit Select
|
|
Case "EAN_13"
|
|
barcodeWriter.Format = BarcodeFormat.EAN_13
|
|
Exit Select
|
|
Case "EAN_8"
|
|
barcodeWriter.Format = BarcodeFormat.EAN_8
|
|
Exit Select
|
|
Case "IMB"
|
|
barcodeWriter.Format = BarcodeFormat.IMB
|
|
Exit Select
|
|
Case "ITF"
|
|
barcodeWriter.Format = BarcodeFormat.ITF
|
|
Exit Select
|
|
Case "MAXICODE"
|
|
barcodeWriter.Format = BarcodeFormat.MAXICODE
|
|
Exit Select
|
|
Case "MSI"
|
|
barcodeWriter.Format = BarcodeFormat.MSI
|
|
Exit Select
|
|
Case "PDF_417"
|
|
barcodeWriter.Format = BarcodeFormat.PDF_417
|
|
Exit Select
|
|
Case "PLESSEY"
|
|
barcodeWriter.Format = BarcodeFormat.PLESSEY
|
|
Exit Select
|
|
Case "QR_CODE"
|
|
barcodeWriter.Format = BarcodeFormat.QR_CODE
|
|
Exit Select
|
|
Case "RSS_14"
|
|
barcodeWriter.Format = BarcodeFormat.RSS_14
|
|
Exit Select
|
|
Case "RSS_EXPANDED"
|
|
barcodeWriter.Format = BarcodeFormat.RSS_EXPANDED
|
|
Exit Select
|
|
Case "UPC_A"
|
|
barcodeWriter.Format = BarcodeFormat.UPC_A
|
|
Exit Select
|
|
Case "UPC_E"
|
|
barcodeWriter.Format = BarcodeFormat.UPC_E
|
|
Exit Select
|
|
Case "UPC_EAN_EXTENSION"
|
|
barcodeWriter.Format = BarcodeFormat.UPC_EAN_EXTENSION
|
|
Exit Select
|
|
|
|
End Select
|
|
|
|
Dim imgCod As Drawing.Bitmap = barcodeWriter.Write(CodigoBarras)
|
|
Dim memoriStream As New System.IO.MemoryStream
|
|
imgCod.Save(memoriStream, Drawing.Imaging.ImageFormat.Bmp)
|
|
|
|
'Respuesta = Convert.ToBase64String(memoriStream.ToArray())
|
|
|
|
Return memoriStream.ToArray()
|
|
|
|
End Function
|
|
Private Sub LnkModalCodigoBarrasQr_Click(sender As Object, e As EventArgs) Handles LnkModalCodigoBarrasQr.Click
|
|
|
|
LnkDescargaImagen.Enabled = False
|
|
LnkDescargaImpresion.Enabled = False
|
|
UpModalBotonesCodigos.Update()
|
|
|
|
TxtCodigoBarrasModal.Text = TxtCodigo.Text.Trim
|
|
UpModalUploadCodigoBarras.Update()
|
|
RegistraScript("$('#ModalCodigoBarrasQR').modal({ backdrop: 'static', keyboard: false});")
|
|
|
|
End Sub
|
|
Private Sub LnkModalGenerarCodigoBarrasQR_Click(sender As Object, e As EventArgs) Handles LnkModalGenerarCodigoBarrasQR.Click
|
|
|
|
Dim Alto As Integer = 150
|
|
Dim Ancho As Integer = 150
|
|
Dim Base64Code As String
|
|
|
|
If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero
|
|
If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero
|
|
|
|
Try
|
|
Base64Code = Convert.ToBase64String(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue))
|
|
ImgModalCodigo.Attributes.Add("src", $"data:image/gif;base64,{Base64Code}")
|
|
ImgModalCodigo.Width = Ancho
|
|
ImgModalCodigo.Height = Alto
|
|
LnkDescargaImagen.Enabled = True
|
|
LnkDescargaImpresion.Enabled = True
|
|
UpModalBotonesCodigos.Update()
|
|
Catch ex As Exception
|
|
ImgModalCodigo.Attributes.Add("src", "")
|
|
ImgModalCodigo.Width = Ancho
|
|
ImgModalCodigo.Height = Alto
|
|
LnkDescargaImagen.Enabled = False
|
|
LnkDescargaImpresion.Enabled = False
|
|
UpModalBotonesCodigos.Update()
|
|
End Try
|
|
|
|
UpModalUploadCodigoBarras.Update()
|
|
|
|
End Sub
|
|
Private Sub LnkDescargaImagen_Click(sender As Object, e As EventArgs) Handles LnkDescargaImagen.Click
|
|
|
|
Dim Alto As Integer = 150
|
|
Dim Ancho As Integer = 150
|
|
|
|
|
|
If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero
|
|
If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero
|
|
|
|
Try
|
|
Dim memoryStream As New System.IO.MemoryStream(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue))
|
|
Response.Clear()
|
|
Response.ContentType = "application/bmp"
|
|
Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.bmp")
|
|
Response.Buffer = True
|
|
memoryStream.WriteTo(Response.OutputStream)
|
|
Response.End()
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Sub
|
|
Private Sub DDLCodigoFormato_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLCodigoFormato.SelectedIndexChanged
|
|
LnkDescargaImagen.Enabled = False
|
|
LnkDescargaImpresion.Enabled = False
|
|
UpModalBotonesCodigos.Update()
|
|
End Sub
|
|
Private Sub LnkDescargaImpresion_Click(sender As Object, e As EventArgs) Handles LnkDescargaImpresion.Click
|
|
Dim Alto As Integer = 150
|
|
Dim Ancho As Integer = 150
|
|
|
|
|
|
If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero
|
|
If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero
|
|
|
|
Try
|
|
|
|
Dim memoryStreamDoc As New System.IO.MemoryStream
|
|
|
|
Dim gemBox As New clsGemBoxDocument()
|
|
|
|
gemBox.AgregarImagen(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue))
|
|
gemBox.GuardarStreamPDF()
|
|
|
|
Dim memoryStream As New System.IO.MemoryStream(gemBox.GetBytesDocumento())
|
|
gemBox.Dispose()
|
|
Response.Clear()
|
|
Response.ContentType = "application/pdf"
|
|
Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.pdf")
|
|
Response.Buffer = True
|
|
memoryStream.WriteTo(Response.OutputStream)
|
|
Response.End()
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " AFInv "
|
|
Protected Sub BtnAFInv_Click(sender As Object, e As EventArgs)
|
|
|
|
If DdlAFInvPS.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Seleccione un producto.")
|
|
Exit Sub
|
|
End If
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
AFInvSerie = ""
|
|
AFInvCvePS = -1
|
|
AFInvCveAlmacen = -1
|
|
AFInvCveSeccionAlmacen = -1
|
|
|
|
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlAFInvPS.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If DrPS Is Nothing Then Exit Sub
|
|
|
|
Dim Inv_CveMetodoInventario As Integer = If(DrPS("AplicaSerie").ToString() = "True", 5, 1)
|
|
If CBool(DrPS("AplicaSeccion")) Then CveSeccionAlmacen = DdlSeccionAlmacen.SelectedValue.ToEntero
|
|
|
|
AFInvSerie = If(Inv_CveMetodoInventario = 5, TxtAFInvSerie.Text.Trim, "-1")
|
|
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim Existencia = ObjInventario.GetExistenciasPS(DdlAFInvPS.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, DdlAFInvAlmacen.SelectedValue.ToEntero, CveSeccionAlmacen:=CveSeccionAlmacen, FechaMovto:=Now.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=AFInvSerie)
|
|
Dim Costo As Decimal = 0
|
|
If Inv_CveMetodoInventario = 5 Then
|
|
Costo = ObjInventario.GetCostoPSSerie(DdlAFInvPS.SelectedValue.ToEntero, AFInvSerie, DdlAFInvAlmacen.SelectedValue.ToEntero, CveEmpresaActual)
|
|
Else
|
|
Costo = ObjInventario.GetCostoPS(DdlAFInvPS.SelectedValue.ToEntero, 1, DdlAFInvAlmacen.SelectedValue.ToEntero, AFInvSerie, Now)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
|
|
If Existencia <> 1 Then
|
|
AFInvSerie = ""
|
|
AFInvCvePS = -1
|
|
AFInvCveAlmacen = -1
|
|
AFInvCveSeccionAlmacen = -1
|
|
|
|
Alert("No hay existencias suficientes del producto. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
TxtDescripcion.Text = DdlAFInvPS.SelectedText
|
|
TxtValorCompra.Text = Costo.FormatoNumero
|
|
TxtFechaCompra.Text = Now.ToShortDateString
|
|
TxtFechaBaja.Text = ""
|
|
TxtNoSerie.Text = TxtAFInvSerie.Text.Trim
|
|
|
|
TxtValorCompra.Enabled = False
|
|
TxtFechaCompra.Enabled = False
|
|
TxtNoSerie.Enabled = False
|
|
Calendario.Enabled = False
|
|
|
|
AFInvCvePS = DdlAFInvPS.SelectedValue.ToEntero
|
|
AFInvCveAlmacen = DdlAFInvAlmacen.SelectedValue.ToEntero
|
|
AFInvCveSeccionAlmacen = DdlSeccionAlmacen.SelectedValue.ToEntero
|
|
RegistraScript("$('#ModalAFInv').modal('hide')", "hide")
|
|
|
|
DivAFInvAdvertencia.Visible = True
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "AF GRUPOS"
|
|
Private Sub BtnAgregarGrupo_Click(sender As Object, e As EventArgs) Handles BtnAgregarGrupo.Click
|
|
TxtGrupoAF.Text = ""
|
|
CreaDT()
|
|
CargaGvGrupo()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddGrupo"))
|
|
End Sub
|
|
Private Sub CreaDT()
|
|
Dim DTGruposTemp As New DataTable
|
|
|
|
Dim column As DataColumn = New DataColumn("No")
|
|
column.DataType = Type.GetType("System.Int32")
|
|
With column
|
|
.AutoIncrement = True
|
|
.AutoIncrementSeed = 1
|
|
.AutoIncrementStep = 1
|
|
End With
|
|
|
|
DTGruposTemp.Columns.Add(column)
|
|
DTGruposTemp.Columns.Add("Grupo", GetType(String))
|
|
DTGruposTemp.Columns.Add("Estado", GetType(String))
|
|
DTGrupos = DTGruposTemp.Clone
|
|
End Sub
|
|
Private Sub CargaGvGrupo()
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetGrupoAF(-1, UsuarioActual.CveEmpresa) Then
|
|
DTGrupos = ObjAF.DtResultados
|
|
GvGrupo.DataSource = DTGrupos
|
|
Else
|
|
GvGrupo.DataSource = Nothing
|
|
End If
|
|
GvGrupo.DataBind()
|
|
UpGvGrupo.Update()
|
|
ObjAF.Dispose()
|
|
End Sub
|
|
Private Sub CargaDTGrupos(DtTemp As DataTable)
|
|
GvGrupo.DataSource = DtTemp
|
|
GvGrupo.DataBind()
|
|
|
|
UpGvGrupo.Update()
|
|
End Sub
|
|
Private Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
Dim registro As DataRow = DTGrupos.NewRow
|
|
|
|
registro.Item("No") = DTGrupos.Rows.Count + 1
|
|
registro.Item("Grupo") = TxtGrupoAF.Text.Trim
|
|
registro.Item("Estado") = "I"
|
|
DTGrupos.Rows.Add(registro)
|
|
CargaDTGrupos(DTGrupos.FiltraParametros("Estado <> 'D' "))
|
|
|
|
TxtGrupoAF.Text = ""
|
|
End Sub
|
|
Protected Sub GvGrupo_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvGrupo.RowEditing
|
|
GvGrupo.EditIndex = e.NewEditIndex
|
|
|
|
CargaDTGrupos(DTGrupos.FiltraParametros("Estado <> 'D' "))
|
|
End Sub
|
|
Protected Sub GvGrupo_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvGrupo.RowCancelingEdit
|
|
GvGrupo.EditIndex = -1
|
|
|
|
CargaDTGrupos(DTGrupos.FiltraParametros("Estado <> 'D' "))
|
|
End Sub
|
|
Protected Sub GvGrupo_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvGrupo.RowUpdating
|
|
|
|
Dim No As Integer = GvGrupo.Rows(e.RowIndex).DataKey("No").ToEntero
|
|
Dim Drs As DataRow() = DTGrupos.Select(String.Format("No = {0}", No))
|
|
|
|
If Drs.Count > 0 Then
|
|
If Drs(0)("CveGrupo").ToString.ToEntero > 0 Then
|
|
Drs(0)("Grupo") = GvGrupo.Rows(e.RowIndex).FCTextBox("TxtGrupo").Text.Trim
|
|
Drs(0)("Estado") = "U"
|
|
Else
|
|
Drs(0)("Grupo") = GvGrupo.Rows(e.RowIndex).FCTextBox("TxtGrupo").Text.Trim
|
|
Drs(0)("Estado") = "I"
|
|
End If
|
|
End If
|
|
|
|
DTGrupos.AcceptChanges()
|
|
GvGrupo.EditIndex = -1
|
|
|
|
CargaDTGrupos(DTGrupos.FiltraParametros("Estado <> 'D' "))
|
|
|
|
End Sub
|
|
Protected Sub DeleteRow(sender As Object, e As EventArgs)
|
|
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
|
|
|
|
If DTGrupos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
|
|
Dim i As Integer
|
|
i = lnkRemove.CommandArgument.ToString.ToEntero
|
|
Dim Drs As DataRow() = DTGrupos.Select(String.Format("No = {0}", i))
|
|
If Drs.Count > 0 Then
|
|
If Drs(0)("CveGrupo").ToString.ToEntero > 0 Then
|
|
Drs(0)("Estado") = "D"
|
|
Else
|
|
Drs(0).Delete()
|
|
End If
|
|
End If
|
|
DTGrupos.AcceptChanges()
|
|
End If
|
|
|
|
GvGrupo.EditIndex = -1
|
|
|
|
CargaDTGrupos(DTGrupos.FiltraParametros("Estado <> 'D' "))
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarGrupoAF_Click(sender As Object, e As EventArgs) Handles BtnAgregarGrupoAF.Click
|
|
Dim ObjAF As New ClsAF
|
|
Dim CveGrupo As Integer
|
|
Dim TieneError = False
|
|
|
|
For Each Dr As DataRow In DTGrupos.Rows
|
|
|
|
If Dr("Estado").ToString = "I" Then
|
|
CveGrupo = ObjAF.AddGrupoAF(Dr("Grupo").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CveGrupo < 0 Then
|
|
TieneError = True
|
|
End If
|
|
|
|
ElseIf Dr("Estado").ToString = "U" Then
|
|
|
|
If Not ObjAF.UpdateGrupoAF(Dr("Grupo").ToString, True, Dr("CveGrupo").ToString.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
ElseIf Dr("Estado").ToString = "D" Then
|
|
|
|
If Not ObjAF.RemoveGrupoAF(UsuarioActual.CveEmpresa, Dr("CveGrupo").ToString.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
If TieneError = False Then
|
|
Alert("Los Grupos se Guardaron correctamente", TipoMensaje.MsgInformacion)
|
|
CargaGrupos()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddGrupo"))
|
|
End If
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "AF MARCAR / MODELOS"
|
|
Private Sub DdlMarcas_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlMarcas.SelectedIndexChanged
|
|
CargaModelos(DdlMarcas.SelectedValue.ToEntero)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "AF PADRE E HIJOS"
|
|
Public Sub CargaAFPAdreEHijos()
|
|
CargaAFPadres()
|
|
CargaAFHijos()
|
|
End Sub
|
|
|
|
Public Sub CargaAFPadres()
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then
|
|
|
|
DdlAFPadres.DataSource = ObjAF.DtResultados
|
|
DdlAFPadres.DataBind()
|
|
|
|
DdlAFPadres.Items.Remove(DdlAFPadres.Items.FindByValue(CveActivoFijo.ToString))
|
|
DdlAFPadres.Items.Insert(0, New ListItem("-", "-1"))
|
|
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Public Sub CargaAFHijos()
|
|
|
|
DivAFHijos.Visible = True
|
|
|
|
Dim ObjAF As New ClsAF()
|
|
|
|
If ObjAF.GetActivosFijosHijos(UsuarioActual.CveEmpresa, CveActivoFijo) Then
|
|
AFHijos = ObjAF.DtResultados
|
|
GvAFHijos.DataSource = AFHijos
|
|
GvAFHijos.DataBind()
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "G P S"
|
|
Protected Sub DdlDispositivo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaUltimaPosicion(DdlDispositivo.SelectedValue.ToEntero)
|
|
End Sub
|
|
|
|
Private Sub CargaUltimaPosicion(CveDispositivo As Integer)
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim SBJS As New StringBuilder
|
|
SBJS.Append("setTimeout(function(){initMapRastreo();")
|
|
|
|
Try
|
|
Dim Coord = "", Fecha = "", Vehiculo = "", Icono = "", Info As String = ""
|
|
If ObjGPS.UltimaPosicionEquipoGet($"{CveDispositivo};", CveClienteGPS) Then
|
|
If ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
Coord = SQLToGmaps(row("Posicion").ToString, "POINT")
|
|
Fecha = row("FechaTrama").ToString
|
|
Vehiculo = row("Vehiculo").ToString
|
|
Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", $" No. Pasajeros: {row("Pasajeros").ToString}", row("CveDispositivo").ToString.ToEntero, row, UsuarioActual.TienePermisoProceso(200))
|
|
|
|
Dim Diferencia As Long = DateDiff(DateInterval.Minute, Fecha.ToDateTime(), FechaClienteGPS)
|
|
|
|
If Diferencia >= 30 AndAlso Diferencia < 120 Then
|
|
Icono = $"/Imagenes/rsz_11rsz_car_disconnected.png"
|
|
ElseIf Diferencia >= 120 Then
|
|
Icono = $"/Imagenes/rsz_11rsz_car_disable.png"
|
|
Else
|
|
If row("SPD").ToString.ToDouble > 1 Then
|
|
Icono = $"/Imagenes/{row("Icono").ToString}green.png"
|
|
Else
|
|
Icono = $"/Imagenes/{row("Icono").ToString}.png"
|
|
End If
|
|
End If
|
|
SBJS.Append($"CreaMarcadorWatch({Coord},'{row("NombreVehiculo")}', '{Info}', '{Icono}');")
|
|
Next
|
|
Else
|
|
Alert($"No se encontraron resultados", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
Finally
|
|
ObjGPS.Dispose()
|
|
SBJS.Append(" IniciarRastreoContinuo();},1000);")
|
|
RegistraScript(SBJS.ToString())
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function InfoWindowCombustible(Header As String, ExtraBody As String, CveDispositivo As Integer, row As DataRow, Optional PermisoComandos As Boolean = True) As String
|
|
Dim SBuilder As New StringBuilder
|
|
SBuilder.Clear()
|
|
SBuilder.Append($"<div>")
|
|
SBuilder.Append($"<div><h5><b>{Header}</b></h5></div>")
|
|
SBuilder.Append($"<div><table>")
|
|
Try
|
|
SBuilder.Append($"<tr><td>Fecha : {row("FechaTrama")} </td></tr>")
|
|
SBuilder.Append($"<tr><td>Conductor : {row("Conductor").ToString}</td></tr>")
|
|
If row.Table.Columns.Contains("Combustible") Then
|
|
SBuilder.Append($"<tr><td>Combustible : {IfNull(row("Combustible"), "NO DISPONIBLE", $"{row("Combustible").ToString.FormatoNumero} lts").ToString}</td></tr>")
|
|
End If
|
|
If row("SPD").ToString <> "-1" Then
|
|
SBuilder.Append($"<tr><td>Velocidad : {row("SPD").ToString} KM/H </td></tr>")
|
|
End If
|
|
If ExtraBody <> "" AndAlso ExtraBody <> "-1" Then
|
|
SBuilder.Append(ExtraBody)
|
|
End If
|
|
'If PermisoComandos Then
|
|
'SBuilder.Append($"<tr><td><a href=""javascript:;"" onclick=""CargaComandos(\'{row("Vehiculo").ToString}\',{CveDispositivo});"">Comandos</a></td></tr>")
|
|
SBuilder.AppendFormat("<tr><td><a target=\'_blank\' href=\'https://www.google.com/maps/search/{0},{1}/\'>Ver en google maps</a></td></tr>", row("Lat").ToString, row("Lng").ToString)
|
|
'End If
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
SBuilder.Append($"</table></div><div></div></div>")
|
|
Return SBuilder.ToString
|
|
End Function
|
|
|
|
Protected Sub BtnConsultarHistorico_Click(sender As Object, e As EventArgs)
|
|
Dim ObjGPS As New ClsGPS
|
|
Try
|
|
Dim CveDispositivo = DdlDispositivo.SelectedValue.ToEntero
|
|
If ObjGPS.GetPosicionEquipo(CveDispositivo, TxtFechaIH.Text.ToDateTime(), TxtFechaFH.Text.ToDateTime()) Then
|
|
If ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
Dim SBJS As New StringBuilder
|
|
|
|
Dim StrPolyPath As New StringBuilder
|
|
StrPolyPath.Append("[")
|
|
Dim POLYPATH As String = "["
|
|
Dim Contador = 0
|
|
Dim RowDispositivo As DataRow = GlobalDTDispositivosUsuarios(CveClienteGPS).FiltroPrimero($"CveDispositivo = {CveDispositivo}")
|
|
Dim CordenadaAnterior As String = ""
|
|
Dim Coord = "", Fecha = "", Vehiculo = "", Icono = "", Info As String = ""
|
|
SBJS.Append("initMapHistorico();")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
Contador += 1
|
|
Coord = SQLToGmaps(row("Posicion").ToString, "POINT")
|
|
Fecha = row("FechaTrama").ToString
|
|
Vehiculo = row("Vehiculo").ToString
|
|
|
|
Dim Velocidad As Double = row("SPD").ToString.ToDouble
|
|
|
|
If Contador = ObjGPS.DtResultados.Rows.Count Then
|
|
Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, row, UsuarioActual.TienePermisoProceso(200))
|
|
|
|
If Velocidad > 1 Then
|
|
Icono = $"/Imagenes/{RowDispositivo("Icono")}green.png"
|
|
Else
|
|
Icono = $"/Imagenes/{RowDispositivo("Icono")}.png"
|
|
End If
|
|
StrPolyPath.AppendFormat("{0}]", Coord)
|
|
|
|
SBJS.Append($"creaPolyline({StrPolyPath.ToString}, '{RowDispositivo("ColorTrazo")}', '{Info}', {Coord}, '{Vehiculo}', '{Icono}',{CveDispositivo})")
|
|
Else
|
|
Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, row, UsuarioActual.TienePermisoProceso(200))
|
|
|
|
If Velocidad > 1 Then
|
|
Icono = $"/Imagenes/{RowDispositivo("Icono")}green.png"
|
|
Else
|
|
Icono = $"/Imagenes/{RowDispositivo("Icono")}.png"
|
|
End If
|
|
|
|
StrPolyPath.AppendFormat("{0},", Coord)
|
|
|
|
'If ObjGPS.DtResultados.Rows.Count < 1500 Then
|
|
' SBJS.Append($"CreaMarcadorHistorico({Coord},'{Vehiculo}', '{Info}', 0, '{Icono}');")
|
|
'End If
|
|
|
|
End If
|
|
CordenadaAnterior = Coord
|
|
Next
|
|
HdnHistorico.Value = SBJS.ToString
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString)
|
|
End Try
|
|
ObjGPS.Dispose()
|
|
UpHistorico.Update()
|
|
RegistraScript("consultaHistorico();")
|
|
End Sub
|
|
|
|
Private Sub CargaDatosCombustible()
|
|
'LtlUnidad.Text = DdlDispositivo.SelectedItem.Text
|
|
Dim CveDispositivo = DdlDispositivo.SelectedValue.ToEntero()
|
|
Dim FechaI = TxtFechaIC.Text.ToDateTime
|
|
Dim FechaF = TxtFechaFC.Text.ToDateTime
|
|
'UpReportes.Update()
|
|
Dim GPS As New ClsGPS
|
|
If GPS.RepCombustibleGet(DdlDispositivo.SelectedValue.ToEntero(), FechaI, FechaF) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim Arow As DataRow = GPS.DtResultados.Rows(0)
|
|
Dim TotalKilometros As Decimal = (Arow("Distancia").ToString().ToDecimal()) / 1000
|
|
Dim CombustibleConsumido As Decimal = ((Arow("CombustibleInicial").ToString().ToDecimal() + Arow("SumaCargas").ToString().ToDecimal()) - Arow("CombustibleFinal").ToString().ToDecimal())
|
|
Dim RendBruto As Decimal = If(CombustibleConsumido > 0, TotalKilometros / CombustibleConsumido, 0) '2.8
|
|
Dim CostoCombustible As Decimal = GlobalDTDispositivos(-1).FiltroPrimeroValor("CostoCombustible", $"CveDispositivo = {DdlDispositivo.SelectedValue}").ToDecimal
|
|
LtlDistancia.Text = TotalKilometros.ToString().FormatoNumero()
|
|
lblVelocidad.Text = $"{GPS.DtResultados.Rows(0)("VelocidadMaxima").ToString().FormatoNumero()}"
|
|
lblRendBruto.Text = $"{RendBruto.ToString().FormatoNumero()}"
|
|
LtlCombustibleConsumido.Text = CombustibleConsumido.ToString().FormatoNumero()
|
|
LtlCombustibleInicial.Text = $"{Arow("CombustibleInicial").ToString().ToDecimal():N2}"
|
|
LtlCombustibleFinal.Text = GPS.DtResultados.Rows(0)("CombustibleFinal").ToString().FormatoNumero()
|
|
LtlNoCargas.Text = $"{Arow("Cargas").ToString().ToDecimal():N2}"
|
|
LtlNoDescargas.Text = $"{Arow("Descargas").ToString().ToDecimal():N2}"
|
|
SumaCargas.Text = $"{Arow("SumaCargas").ToString().ToDecimal():N2}"
|
|
LtlCostoCargas.Text = $"{Arow("SumaCargas").ToString().ToDecimal() * CostoCombustible:N2}"
|
|
SumaDescargas.Text = $"{Arow("SumaDescargas").ToString().ToDecimal():N2}"
|
|
LtlCostoDescargas.Text = $"{Arow("SumaDescargas").ToString().ToDecimal() * CostoCombustible:N2}"
|
|
LtlDistanciaR.Text = TotalKilometros.ToString().FormatoNumero()
|
|
lCombustibleConsumido.Text = $"{(CombustibleConsumido - Arow("SumaDescargas").ToString().ToDecimal()):N2}"
|
|
LtlCostoConsumo.Text = $"${((CombustibleConsumido - Arow("SumaDescargas").ToString().ToDecimal()) * CostoCombustible).ToString().FormatoNumero()}"
|
|
LtlCostoCombustibleF.Text = $"${(GPS.DtResultados.Rows(0)("CombustibleFinal").ToString().ToDecimal * CostoCombustible).ToString().FormatoNumero()}"
|
|
LtlCostoInicial.Text = $"${(GPS.DtResultados.Rows(0)("CombustibleInicial").ToString().ToDecimal * CostoCombustible).ToString().FormatoNumero()}"
|
|
lblMuerto.Text = $"{((DateDiff(DateInterval.Minute, FechaI, FechaF).ToString().ToLong - GPS.DtResultados.Rows(0)("Horas").ToString().ToLong) / 60).ToString().FormatoNumero()} Hrs."
|
|
lblMovimiento.Text = $"{(GPS.DtResultados.Rows(0)("Horas").ToString().ToDecimal / 60).ToString().FormatoNumero()} Hrs"
|
|
LtlRalenti.Text = $"{GPS.DtResultados.Rows(0)("TiempoRalentiHoras").ToString().FormatoNumero()} Hrs. ({GPS.DtResultados.Rows(0)("TiempoRalentiMinutos").ToString()} Minutos)"
|
|
CargaHistoricoCombustible(GPS)
|
|
DvReporte.Visible = True
|
|
'lblRendEfectivo.Text = $"{(RendBruto + 1).ToString().FormatoNumero()} KM/L"
|
|
End If
|
|
GPS.Dispose()
|
|
UpReporte.Update()
|
|
UpDash.Update()
|
|
UPTabla.Update()
|
|
' bodyreportes.Visible = True
|
|
' UpReportes.Update()
|
|
End Sub
|
|
Private Sub CargaHistoricoCombustible(ByRef GPS As ClsGPS)
|
|
|
|
If GPS.GetCombustibleHistorico(DdlDispositivo.SelectedValue.ToEntero(), TxtFechaIC.Text.ToDateTime, TxtFechaFC.Text.ToDateTime) Then
|
|
Dim json As New StringBuilder
|
|
json.Append("data=[")
|
|
Dim color As String = ""
|
|
Dim encencido As Integer = -1
|
|
Dim encencidoC As Integer = -1
|
|
For Each gvrow As DataRow In GPS.DtResultados.Rows
|
|
encencidoC = gvrow("Encendido").ToString().ToEntero()
|
|
If encencido <> encencidoC Then
|
|
If encencidoC = 1 Then
|
|
color = ",lineColor:""#2498d2"""
|
|
Else
|
|
color = ",lineColor:""#F3565D"""
|
|
End If
|
|
Else
|
|
color = ""
|
|
End If
|
|
encencido = encencidoC
|
|
json.Append($",{{date: stringtodate(""{DirectCast(gvrow("FechaTrama"), DateTime).ToString("yyyy-MM-dd HH:mm:ss")}""), value: {gvrow("Valor").ToString().ToDecimal()} {color}}}")
|
|
Next
|
|
json.Append(" ]")
|
|
json.Remove(6, 1)
|
|
HdfVGrafica.Value = json.ToString()
|
|
RegistraScript($"CargaGraficaCombustible()")
|
|
End If
|
|
End Sub
|
|
Protected Sub lbCargas_Click(sender As Object, e As EventArgs) Handles lbCargas.Click
|
|
LtlTituloCD.Text = "Desglose de cargas de combustible"
|
|
Dim GPS As New ClsGPS
|
|
If GPS.GetCargasDescargas(DdlDispositivo.SelectedValue.ToEntero, TxtFechaIC.Text.ToDateTime, TxtFechaFC.Text.ToDateTime, 69) Then
|
|
GVHistorico.DataSource = GPS.DtResultados
|
|
DTCargas = GPS.DtResultados
|
|
Else
|
|
GVHistorico.DataSource = Nothing
|
|
End If
|
|
GPS.Dispose()
|
|
GVHistorico.DataBind()
|
|
UpdatePanel3.Update()
|
|
UpHistorico.Update()
|
|
RegistraScript("$('#dvHistorico').modal()")
|
|
End Sub
|
|
|
|
Protected Sub lbDesCargas_Click(sender As Object, e As EventArgs) Handles lbDescargas.Click
|
|
LtlTituloCD.Text = "Desglose de descargas de combustible"
|
|
Dim GPS As New ClsGPS
|
|
If GPS.GetCargasDescargas(DdlDispositivo.SelectedValue.ToEntero, TxtFechaIC.Text.ToDateTime, TxtFechaFC.Text.ToDateTime, 74) Then
|
|
GVHistorico.DataSource = GPS.DtResultados
|
|
DTDescargas = GPS.DtResultados
|
|
Else
|
|
GVHistorico.DataSource = Nothing
|
|
End If
|
|
GPS.Dispose()
|
|
GVHistorico.DataBind()
|
|
UpdatePanel3.Update()
|
|
UpHistorico.Update()
|
|
RegistraScript("$('#dvHistorico').modal()")
|
|
End Sub
|
|
|
|
Protected Sub GVHistorico_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVHistorico.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim RowID As String = $"row{e.Row.RowIndex}"
|
|
e.Row.Attributes("id") = RowID
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnConsultarCombistible_Click(sender As Object, e As EventArgs)
|
|
CargaDatosCombustible()
|
|
End Sub
|
|
Protected Sub BtnConsultarDriving_Click(sender As Object, e As EventArgs)
|
|
Dim ObjGPS As New ClsGPS
|
|
Try
|
|
If ObjGPS.GetRepDrivingAF(DdlDispositivo.SelectedValue.ToEntero, TxtFechaID.Text.ToDateTime(), TxtFechaFD.Text.ToDateTime()) Then
|
|
GvIgnicion.DataSource = ObjGPS.DtSetResultados.Tables(0)
|
|
GvIgnicion.DataBind()
|
|
|
|
GvExcesos.DataSource = ObjGPS.DtSetResultados.Tables(1)
|
|
GvExcesos.DataBind()
|
|
|
|
GvRalenti.DataSource = ObjGPS.DtSetResultados.Tables(2)
|
|
GvRalenti.DataBind()
|
|
|
|
GvEventos.DataSource = ObjGPS.DtSetResultados.Tables(3)
|
|
GvEventos.DataBind()
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
ObjGPS.Dispose()
|
|
UpDriving.Update()
|
|
End Sub
|
|
Protected Sub BtnConsultarGeoReferencia_Click(sender As Object, e As EventArgs)
|
|
Dim LastCoord As String = ""
|
|
Dim DtPosiciones As New DataTable
|
|
Dim Info = ""
|
|
Dim SBBody As New StringBuilder
|
|
Dim Icono As String = "/Imagenes/rsz_11rsz_car.png"
|
|
Dim CoordsPoligono As JArray
|
|
Dim Coords As JObject
|
|
Dim Titulo = ""
|
|
Dim COUNT = 0
|
|
Dim FechaI = If(TxtFechaIG.Text.Trim = "", MinFecha, TxtFechaIG.Text.Trim.ToDate)
|
|
Dim FechaF = If(TxtFechaFG.Text.Trim = "", MaxFecha, TxtFechaFG.Text.Trim.ToDate)
|
|
Dim CveDispositivo As Integer = DdlDispositivo.SelectedValue.ToEntero
|
|
Dim SBJS As New StringBuilder
|
|
Dim ArrayGeocercas As New JArray
|
|
Dim ArryaCoords As New JArray
|
|
|
|
Dim GPS As New ClsGPS
|
|
Try
|
|
Dim DtGeoReferencias As DataTable = Nothing
|
|
If GPS.GetReferenciaDetalle(-1, -1, CveDispositivo, CveClienteGPS) Then
|
|
DtGeoReferencias = GPS.DtResultados.FiltraParametros("Estatus = 1 AND Tipo = 'Geocerca'")
|
|
End If
|
|
If DtGeoReferencias IsNot Nothing Then
|
|
SBJS.Append("setTimeout(function(){initMapGeo();")
|
|
|
|
For Each Row As DataRow In DtGeoReferencias.Rows
|
|
CoordsPoligono = SQLToGmapsJArray(Row("Coordenadas").ToString, "POLYGON")
|
|
ArrayGeocercas.Add(New JObject(
|
|
New JProperty("Nombre", Row("GeoReferencia").ToString),
|
|
New JProperty("Coordenadas", CoordsPoligono),
|
|
New JProperty("Color", Row("Color").ToString)
|
|
))
|
|
'SBJS.Append($" creaPoligono([{CoordsPoligono}], '{Row("Color").ToString}'); ")
|
|
Next
|
|
|
|
|
|
|
|
SBJS.Append("creaPolygonosGeocercas();")
|
|
If GPS.GetRepEntradasSalidas(CveDispositivo, FechaI, FechaF) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
For Each Row As DataRow In GPS.DtResultados.Rows
|
|
Coords = JObject.Parse(SQLToGmapsJArray(Row("Posicion").ToString, "POINT")(0).ToString())
|
|
Info = InfoWindowCombustible(Row("Evento").ToString, If(Row("Pasajeros").ToString = "", $"<tr><td>Vehículo: {DdlDispositivo.SelectedItem.Text}</td></tr>", $"<tr><td>Vehículo: {DdlDispositivo.SelectedItem.Text}</td></tr><tr><td>Pasajeros: {Row("Pasajeros").ToString}</td></tr>"), CveDispositivo, Row)
|
|
|
|
ArryaCoords.Add(New JObject(
|
|
New JProperty("Coords", Coords),
|
|
New JProperty("Vehiculo", DdlDispositivo.SelectedItem.Text),
|
|
New JProperty("Info", Info),
|
|
New JProperty("Icono", Icono)
|
|
))
|
|
|
|
'SBJS.Append($" CreaMarcadorGeo({Coords},'{DdlDispositivo.SelectedItem.Text}', '{Info}', '{Icono}'); ")
|
|
Next
|
|
End If
|
|
End If
|
|
Dim JsonData As New JObject(
|
|
New JProperty("Geocercas", ArrayGeocercas),
|
|
New JProperty("Puntos", ArryaCoords)
|
|
)
|
|
HdnGeocercas.Value = JsonData.ToString()
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString)
|
|
Finally
|
|
GPS.Dispose()
|
|
SBJS.Append("},1000);")
|
|
UpGeocercas.Update()
|
|
RegistraScript(SBJS.ToString())
|
|
End Try
|
|
End Sub
|
|
#End Region
|
|
Protected Sub DdlAFInvPS_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlAFInvPS.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If drr IsNot Nothing Then
|
|
DivSerie.Visible = CBool(drr("AplicaSerie"))
|
|
DivSeccion.Visible = CBool(drr("AplicaSeccion"))
|
|
DdlSeccionAlmacen.Items.Clear()
|
|
If CBool(drr("AplicaSeccion")) Then
|
|
'CargaSeccionesAlmacen(DdlSeccionAlmacen, DdlAFInvAlmacen.SelectedValue.ToEntero, DdlAFInvPS.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
|
|
Dim dtt As DataTable = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAFInvAlmacen.SelectedValue.ToEntero, DdlAFInvPS.SelectedValue.ToEntero)
|
|
DdlSeccionAlmacen.DataSource = dtt
|
|
DdlSeccionAlmacen.DataBind()
|
|
|
|
dtt.Dispose()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
Protected Sub BtnPDFCompras_Click(sender As Object, e As EventArgs)
|
|
Imprime()
|
|
End Sub
|
|
Protected Sub BtnExcelCompras_Click(sender As Object, e As EventArgs)
|
|
Imprime("Excel")
|
|
'Dim dt As New DataTable
|
|
'dt.Columns.Add("Factura", GetType(String))
|
|
'dt.Columns.Add("Fecha", GetType(String))
|
|
'dt.Columns.Add("Cantidad", GetType(Double))
|
|
'dt.Columns.Add("UM", GetType(String))
|
|
'dt.Columns.Add("Clasificación", GetType(String))
|
|
'dt.Columns.Add("Producto o Servicio", GetType(String))
|
|
'dt.Columns.Add("Total", GetType(Double))
|
|
'dt.Columns.Add("Moneda", GetType(String))
|
|
'dt.Columns.Add("Proveedor", GetType(String))
|
|
|
|
'For Each Gv As GridViewRow In GVHistorial.Rows
|
|
' Dim Row As DataRow = Nothing
|
|
' Row = dt.NewRow()
|
|
' Row("Factura") = Gv.FCHyperLink("LtlFactura").Text
|
|
' Row("Fecha") = Gv.FCLiteral("LtlFecha").Text
|
|
' Row("Cantidad") = Gv.FCLiteral("LtlCantidad").Text.ToDouble
|
|
' Row("UM") = Gv.FCLiteral("LtlUM").Text
|
|
' Row("Clasificación") = Gv.FCLiteral("LtlIVA").Text
|
|
' Row("Producto o Servicio") = Gv.FCLiteral("LtlPS").Text
|
|
' Row("Total") = Gv.FCLiteral("LtlTotal").Text.ToDouble
|
|
' Row("Moneda") = Gv.FCLiteral("LtlMoneda").Text
|
|
' Row("Proveedor") = Gv.FCHyperLink("LtlProveedor").Text
|
|
' dt.Rows.Add(Row)
|
|
'Next
|
|
'ExportToExcel(dt, "Compras e Insumos")
|
|
End Sub
|
|
Private Sub Imprime(Optional Formato As String = "PDF")
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepComprasInsumos.rdlc", DTCompras, params, "RepComprasInsumos", Formato)
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "Produccion"
|
|
|
|
|
|
|
|
Private Sub CargaProduccion()
|
|
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetProduccion(CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
|
GvProduccion.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvProduccion.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
|
|
|
|
Else
|
|
GvProduccion.DataSource = DT_Produccion
|
|
End If
|
|
|
|
|
|
GvProduccion.DataBind()
|
|
|
|
UpProduccion.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkAgregarProduccion_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
CveProduccion = -1
|
|
IndexProduccion = -1
|
|
|
|
LblModaProduccionTitulo.Text = "Agregar Producción"
|
|
LnkModalAgregarProduccion.Text = "Agregar"
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
CveProduccion = GvRow.DataKey("CveProduccion").ToEntero
|
|
Else
|
|
IndexProduccion = GvRow.RowIndex
|
|
End If
|
|
|
|
|
|
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)
|
|
If CveActivoFijo > 0 Then
|
|
|
|
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()
|
|
|
|
Else
|
|
Dim IndexProduccionEliminar As Integer = GvRow.RowIndex
|
|
|
|
DT_Produccion.Rows(IndexProduccionEliminar).Delete()
|
|
DT_Produccion.AcceptChanges()
|
|
ErrorProceso = False
|
|
|
|
End If
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
|
|
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()
|
|
|
|
Else
|
|
|
|
|
|
If IndexProduccion >= 0 Then
|
|
DT_Produccion.Rows(IndexProduccion)("Cuadro") = DdlModalCultivosCuadro.SelectedItem.Text
|
|
DT_Produccion.Rows(IndexProduccion)("CveCultivoCuadroDetalle") = DdlModalCultivosCuadro.SelectedValue.ToEntero
|
|
DT_Produccion.Rows(IndexProduccion)("Fecha") = TxtModalProduccionFecha.Text.ToDate
|
|
DT_Produccion.Rows(IndexProduccion)("Cantidad") = TxtModalProduccionCantidad.Text.ToDecimal
|
|
Else
|
|
|
|
Dim nRow As DataRow = DT_Produccion.NewRow
|
|
|
|
nRow("Cuadro") = DdlModalCultivosCuadro.SelectedItem.Text
|
|
nRow("CveCultivoCuadroDetalle") = DdlModalCultivosCuadro.SelectedValue.ToEntero
|
|
nRow("Fecha") = TxtModalProduccionFecha.Text.ToDate
|
|
nRow("Cantidad") = TxtModalProduccionCantidad.Text.ToDecimal
|
|
|
|
DT_Produccion.Rows.Add(nRow)
|
|
ErrorProceso = False
|
|
|
|
End If
|
|
|
|
DT_Produccion.AcceptChanges()
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
RegistraScript("$('#DVModalProduccion').modal('hide');")
|
|
Alert("Producción Agregada Correctamente.")
|
|
CargaProduccion()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "MANTENIMIENTO"
|
|
|
|
|
|
|
|
|
|
Private Sub CargaMantenimento()
|
|
|
|
If CveActivoFijo > 0 Then
|
|
|
|
Dim ObjAF As New ClsAF
|
|
If ObjAF.GetMantenimientos(CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
|
GvMantenimientos.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvMantenimientos.DataSource = Nothing
|
|
End If
|
|
ObjAF.Dispose()
|
|
|
|
Else
|
|
GvMantenimientos.DataSource = DT_Mantenimiento
|
|
End If
|
|
|
|
|
|
GvMantenimientos.DataBind()
|
|
|
|
UpMantenimientos.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkAgregarMantenimiento_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
CveMantenimiento = -1
|
|
IndexMantenimiento = -1
|
|
|
|
LblModaMantenimientoTitulo.Text = "Agregar Mantenimiento"
|
|
LnkModalAgregarMantenimiento.Text = "Agregar"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
CveMantenimiento = GvRow.DataKey("CveMantenimiento").ToEntero
|
|
Else
|
|
IndexMantenimiento = GvRow.RowIndex
|
|
End If
|
|
|
|
|
|
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 IndexMantenimientoEliminar As Integer = GvRow.RowIndex
|
|
|
|
If CveActivoFijo > 0 Then
|
|
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()
|
|
|
|
Else
|
|
|
|
DT_Mantenimiento.Rows(IndexMantenimientoEliminar).Delete()
|
|
DT_Mantenimiento.AcceptChanges()
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
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 CveActivoFijo > 0 Then
|
|
|
|
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
|
|
TxtArchivoMantenimiento.Text = ""
|
|
UpModalMantenimiento.Update()
|
|
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
|
|
|
|
|
|
Else
|
|
|
|
Dim Filesgral As List(Of Archivo) = TxtArchivoMantenimiento.getfiles().Archivos
|
|
|
|
|
|
If IndexMantenimiento >= 0 Then
|
|
|
|
DT_Mantenimiento.Rows(IndexMantenimiento)("Mantenimiento") = TxtModalMantenimiento.Text
|
|
DT_Mantenimiento.Rows(IndexMantenimiento)("Observaciones") = TxtModalMantenimientoObservaciones.Text
|
|
DT_Mantenimiento.Rows(IndexMantenimiento)("Fecha") = TxtModalMantenimientoFecha.Text.ToDate
|
|
|
|
|
|
If Filesgral.Count > 0 Then
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
|
|
Dim fi As New FileInfo(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename))
|
|
|
|
If fi.Exists Then
|
|
DT_Mantenimiento.Rows(IndexMantenimiento)("Archivo") = fi.FullName
|
|
End If
|
|
|
|
Exit For
|
|
Next
|
|
End If
|
|
|
|
DT_Mantenimiento.AcceptChanges()
|
|
|
|
Else
|
|
|
|
Dim nRow As DataRow = DT_Mantenimiento.NewRow
|
|
|
|
nRow("Mantenimiento") = TxtModalMantenimiento.Text
|
|
nRow("Observaciones") = TxtModalMantenimientoObservaciones.Text
|
|
nRow("Fecha") = TxtModalMantenimientoFecha.Text.ToDate
|
|
|
|
If Filesgral.Count > 0 Then
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
|
|
Dim fi As New FileInfo(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename))
|
|
|
|
If fi.Exists Then
|
|
nRow("Archivo") = fi.FullName
|
|
End If
|
|
|
|
Exit For
|
|
Next
|
|
End If
|
|
|
|
DT_Mantenimiento.Rows.Add(nRow)
|
|
DT_Mantenimiento.AcceptChanges()
|
|
|
|
End If
|
|
|
|
TxtArchivoMantenimiento.Text = ""
|
|
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
RegistraScript("$('#DVModalMantenimiento').modal('hide');")
|
|
Alert("Mantenimiento Guardado Correctamente.")
|
|
CargaMantenimento()
|
|
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 FileInfo
|
|
|
|
If CveActivoFijo > 0 Then
|
|
InfArchivo = New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}")
|
|
Else
|
|
InfArchivo = New FileInfo(Archivo)
|
|
End If
|
|
|
|
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")
|
|
|
|
If Archivo.Length > 0 Then
|
|
|
|
|
|
Dim InfArchivo As FileInfo
|
|
|
|
If CveActivoFijo > 0 Then
|
|
InfArchivo = New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}")
|
|
Else
|
|
InfArchivo = New FileInfo(Archivo)
|
|
End If
|
|
|
|
If InfArchivo.Exists Then
|
|
e.Row.FCLinkButton("LnkDescargaArcgivo").Visible = True
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkDescargaArcgivo"))
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "PLAGA ENFERMEDAD"
|
|
|
|
|
|
|
|
Private Sub CargaPlagaEnfermedad()
|
|
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
Dim ObjAF As New ClsAF
|
|
If ObjAF.GetPlagaEnfermedad(CveActivoFijo, UsuarioActual.CveEmpresa) Then
|
|
GvPlagaEnfermedad.DataSource = ObjAF.DtResultados
|
|
Else
|
|
GvPlagaEnfermedad.DataSource = Nothing
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
Else
|
|
GvPlagaEnfermedad.DataSource = DT_PlgaEfermedad
|
|
End If
|
|
|
|
|
|
GvPlagaEnfermedad.DataBind()
|
|
|
|
UpPlagaEnfermedad.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkAgregarPlagaEnfermedad_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
CvePlagaEnfermedad = -1
|
|
Else
|
|
IndexProduccion = -1
|
|
End If
|
|
|
|
|
|
LblModalTituloPlagaEnfermedad.Text = "Agregar Plaga Enfermedad"
|
|
LnkModalAgregarProduccion.Text = "Agregar"
|
|
|
|
|
|
|
|
TxtModalPlagaEnfermedadObservaciones.Text = ""
|
|
TxtModalPlagaEnfermedadFecha.Text = ""
|
|
|
|
RegistraScript("$('#DVModalPlagaEnfermedad').modal('show');")
|
|
|
|
UpModalPlagaEnfermedad.Update()
|
|
End Sub
|
|
|
|
Protected Sub LnkGvPlagaEnfermedadEdit_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
If CveActivoFijo > 0 Then
|
|
CvePlagaEnfermedad = GvRow.DataKey("CvePlagaEnfermedad").ToEntero
|
|
Else
|
|
IndexPlagaEnfermedad = GvRow.RowIndex
|
|
End If
|
|
|
|
Dim Observaciones As String = GvRow.DataKey("Observaciones")
|
|
Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate
|
|
|
|
|
|
TxtModalPlagaEnfermedadObservaciones.Text = Observaciones
|
|
TxtModalPlagaEnfermedadFecha.Text = Fecha.ToString("dd/MM/yyyy")
|
|
|
|
|
|
LblModalTituloPlagaEnfermedad.Text = "Actualizar plaga enfermedad"
|
|
LnkModalAgregarPlagaEnfermedad.Text = "Actualizar"
|
|
|
|
UpModalPlagaEnfermedad.Update()
|
|
|
|
|
|
RegistraScript("$('#DVModalPlagaEnfermedad').modal('show');")
|
|
End Sub
|
|
|
|
Protected Sub LnkGvPlagaEnfermedadRemove_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
Dim ErrorProceso As Boolean = False
|
|
|
|
If CveActivoFijo > 0 Then
|
|
Dim CvePlagaEnfermedadEliminar As Integer = GvRow.DataKey("CvePlagaEnfermedad").ToEntero
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.RemovePlagaEnfermedad(CvePlagaEnfermedadEliminar, UsuarioActual.CveEmpresa) Then
|
|
ErrorProceso = False
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
Else
|
|
|
|
Dim IndexPlagaEnfermedadEliminar As Integer = GvRow.RowIndex
|
|
DT_PlgaEfermedad.Rows(IndexPlagaEnfermedadEliminar).Delete()
|
|
DT_PlgaEfermedad.AcceptChanges()
|
|
ErrorProceso = False
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
Alert("Plaga Enfermedad Eliminada Correctamente.")
|
|
CargaPlagaEnfermedad()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub LnkModalAgregarPlagaEnfermedad_Click(sender As Object, e As EventArgs)
|
|
Dim ErrorProceso As Boolean = False
|
|
|
|
|
|
If CveActivoFijo > 0 Then
|
|
|
|
Dim ObjAF As New ClsAF
|
|
If CvePlagaEnfermedad > 0 Then
|
|
If ObjAF.UpdatePlagaEnfermedad(CvePlagaEnfermedad, CveActivoFijo, TxtModalPlagaEnfermedadObservaciones.Text, TxtModalPlagaEnfermedadFecha.Text.ToDate, UsuarioActual.CveUsuario) Then
|
|
ErrorProceso = False
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
Else
|
|
If ObjAF.AddPlagaEnfermedad(CveActivoFijo, TxtModalPlagaEnfermedadObservaciones.Text, TxtModalPlagaEnfermedadFecha.Text.ToDate, UsuarioActual.CveUsuario) Then
|
|
ErrorProceso = False
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
End If
|
|
ObjAF.Dispose()
|
|
|
|
Else
|
|
|
|
If IndexPlagaEnfermedad >= 0 Then
|
|
|
|
DT_PlgaEfermedad.Rows(IndexPlagaEnfermedad)("Observaciones") = TxtModalPlagaEnfermedadObservaciones.Text
|
|
DT_PlgaEfermedad.Rows(IndexPlagaEnfermedad)("Fecha") = TxtModalPlagaEnfermedadFecha.Text.ToDate
|
|
DT_PlgaEfermedad.Rows(IndexPlagaEnfermedad)("Usuario") = UsuarioActual.Usuario
|
|
|
|
Else
|
|
|
|
Dim nRow As DataRow = DT_PlgaEfermedad.NewRow
|
|
|
|
nRow("Observaciones") = TxtModalPlagaEnfermedadObservaciones.Text
|
|
nRow("Fecha") = TxtModalPlagaEnfermedadFecha.Text.ToDate
|
|
nRow("Usuario") = UsuarioActual.Usuario
|
|
|
|
DT_PlgaEfermedad.Rows.Add(nRow)
|
|
|
|
DT_PlgaEfermedad.AcceptChanges()
|
|
|
|
|
|
|
|
End If
|
|
ErrorProceso = False
|
|
End If
|
|
|
|
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
RegistraScript("$('#DVModalPlagaEnfermedad').modal('hide');")
|
|
Alert("Plaga Enfermedad guardada Correctamente.")
|
|
CargaPlagaEnfermedad()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
End Class |