diff --git a/AF/AF.aspx.vb b/AF/AF.aspx.vb index 7d5ffee83..bd527c324 100644 --- a/AF/AF.aspx.vb +++ b/AF/AF.aspx.vb @@ -6,19 +6,19 @@ Imports System.IO Imports System.Data Imports Microsoft.Reporting.WebForms Imports ZXing -Imports Newtonsoft.Json.Linq - +Imports Newtonsoft.Json.Linq + Partial Class AF_AF - Inherits ClsPaginas - - 'Configuración + Inherits ClsPaginas + + 'Configuración #Region "PROPIEDADES" Private Property CveActivoFijo As Integer - Get - - If ViewState("CveActivoFijo") Is Nothing Then - ViewState("CveActivoFijo") = -1 - End If + Get + + If ViewState("CveActivoFijo") Is Nothing Then + ViewState("CveActivoFijo") = -1 + End If Return ViewState("CveActivoFijo").ToString.ToEntero End Get Set(value As Integer) @@ -26,9 +26,9 @@ Partial Class AF_AF End Set End Property Private Property CodigoAF As String - Get - If ViewState("CodigoAF") Is Nothing Then - ViewState("CodigoAF") = "" + Get + If ViewState("CodigoAF") Is Nothing Then + ViewState("CodigoAF") = "" End If Return ViewState("CodigoAF").ToString End Get @@ -112,7 +112,7 @@ Partial Class AF_AF Set(value As Integer) ViewState("AFInvCveAlmacen") = value End Set - End Property + End Property Private Property AFInvCveSeccionAlmacen As Integer Get Return If(ViewState("AFInvCveSeccionAlmacen") Is Nothing, -1, ViewState("AFInvCveSeccionAlmacen").ToString.ToEntero()) @@ -184,11 +184,11 @@ Partial Class AF_AF Set(value As DataTable) ViewState("DTCompras") = value End Set - End Property - - + End Property + + #Region "CLASIFICACIONES" - + Private Property DTAFCaracteristicas As DataTable Get Return CType(ViewState("DTAFCaracteristicas"), DataTable) @@ -205,10 +205,10 @@ Partial Class AF_AF Set(value As Integer) ViewState("CveCaracteristica") = value End Set - End Property + End Property #End Region - - + + #Region "G P S" Public Property CveClienteGPS As Integer Get @@ -248,129 +248,129 @@ Partial Class AF_AF Set(value As DataTable) ViewState("DTDescargas") = value End Set - End Property - + 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 + 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 - + End Property + Private Property IndexProduccion As Integer - Get - If ViewState("IndexProduccion") Is Nothing Then - ViewState("IndexProduccion") = -1 - End If - Return ViewState("IndexProduccion").ToString.ToEntero + 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 - - + End Property + + Private Property CveMantenimiento As Integer - Get - If ViewState("CveMantenimiento") Is Nothing Then - ViewState("CveMantenimiento") = -1 - End If - Return ViewState("CveMantenimiento").ToString.ToEntero + Get + If ViewState("CveMantenimiento") Is Nothing Then + ViewState("CveMantenimiento") = -1 + End If + Return ViewState("CveMantenimiento").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMantenimiento") = value End Set - End Property - - + End Property + + Private Property IndexMantenimiento As Integer - Get - If ViewState("IndexMantenimiento") Is Nothing Then - ViewState("IndexMantenimiento") = -1 - End If - Return ViewState("IndexMantenimiento").ToString.ToEntero + 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 - + End Property + Private Property CvePlagaEnfermedad As Integer - Get - If ViewState("CvePlagaEnfermedad") Is Nothing Then - ViewState("CvePlagaEnfermedad") = -1 - End If - Return ViewState("CvePlagaEnfermedad").ToString.ToEntero + 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 - - + End Property + + Private Property IndexPlagaEnfermedad As Integer - Get - If ViewState("IndexPlagaEnfermedad") Is Nothing Then - ViewState("IndexPlagaEnfermedad") = -1 - End If - Return ViewState("IndexPlagaEnfermedad").ToString.ToEntero + 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 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) + 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 - - + 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) + 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 - - + 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) + 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 - - + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then @@ -386,13 +386,13 @@ Partial Class AF_AF ViewState("CveActivoFijo") = Request("CveActivoFijo") CargaDatos() CargaEventos() - CargaActividades() - CargaProduccion() - CargaMantenimento() - CargaPlagaEnfermedad() - ModalidadesPaginaAF() - - 'Configuración de Modalidad Update + CargaActividades() + CargaProduccion() + CargaMantenimento() + CargaPlagaEnfermedad() + ModalidadesPaginaAF() + + 'Configuración de Modalidad Update BtnGuardar.Text = "Guardar Cambios" LtlTitulo.Text = "Consulta del Activo Fijo:" @@ -400,10 +400,10 @@ Partial Class AF_AF 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 + ViewState("CveActivoFijo") = -1 + + + 'Configuración de Modalidad Insert ImgAddObs.Visible = False LblFechaCaptura.Text = Now.ToShortDateString() LblUsuarioCapturo.Text = UsuarioActual.Usuario @@ -422,68 +422,68 @@ Partial Class AF_AF - If Request("Op") IsNot Nothing Then - ModalidadesPaginaAFInicial(Request("Op").ToString) - End If - - - + 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() + 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" @@ -511,137 +511,147 @@ Partial Class AF_AF 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 - + 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) + + 'If UsuarioActual.CveEmpresa.Contiene(172, 173) Then + ' lblProyecto.Text = "Proyecto:" + ' lblProyecto.Visible = True + ' DdlProyecto.Visible = True + + ' LblSubProyecto.Text = "SubProyecto:" + 'End If + RowProyecto.Visible = DdlProyecto.Visible + 'CargaCliente() CargaGrupos() CargaMarcas() @@ -744,79 +754,79 @@ Partial Class AF_AF ' DdlClientes.DataBind() 'End Sub - Private Sub CargaCultivos() - DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}") - DdlModalCultivosCuadro.DataBind() - DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + 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 - + 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 - + 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 - + 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 @@ -874,7 +884,9 @@ Partial Class AF_AF End If ObjFolios.Dispose() - CargaSubTipoActivoFijo() + If CveActivoFijo <= 0 Then + CargaSubTipoActivoFijo() + End If UpDatos.Update() End Sub @@ -888,7 +900,7 @@ Partial Class AF_AF DdlAFInvAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) DdlAFInvAlmacen.SelectedValue = "-1" DdlAFInvAlmacen.DataBind() - DdlAFInvAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + DdlAFInvAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) DdlAFInvPS.setEsWebService(True) 'DdlAFInvPS.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2", "PSCodigo") @@ -907,16 +919,15 @@ Partial Class AF_AF 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 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() @@ -932,10 +943,10 @@ Partial Class AF_AF TxtDescripcion.Text = ObjActivoFijo.Descripcion TxtCodigo.Text = ObjActivoFijo.Codigo TxtValorCompra.Text = ObjActivoFijo.ValorCompra.ToString.FormatoNumero - TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString - - - + TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString + + + TxtFechaBaja.Text = If(ObjActivoFijo.FechaBaja = New Date(1900, 1, 1), "", ObjActivoFijo.FechaBaja.ToString("dd/MM/yyyy")) @@ -1013,8 +1024,8 @@ Partial Class AF_AF CargaPlacas() CargaLicencias() - CargaSeguros() - + CargaSeguros() + CargaFallas() CargaAccidentes() @@ -1024,13 +1035,13 @@ Partial Class AF_AF DdlEstadoActivoFijo.SelectedValue = ObjActivoFijo.DtResultados.Rows(0)("CveEstadoActivoFijo").ToString DdlResponsable.SelectedValue = ObjActivoFijo.DtResultados.Rows(0)("CvePersonaResponsable").ToString - DdlProyecto.SelectedValue = ObjActivoFijo.CveProyecto.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 + 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) @@ -1059,8 +1070,8 @@ Partial Class AF_AF End If End If ObjActivoFijo.Dispose() - End Sub - + End Sub + #Region "P L A C A S" Public Sub CargaPlacas() Dim ObjAF As New ClsAF() @@ -1173,9 +1184,9 @@ Partial Class AF_AF End If End If End If - End Sub + End Sub #End Region - + #Region "L I C E N C I A S" Public Sub CargaLicencias() Dim ObjAF As New ClsAF() @@ -1302,7 +1313,7 @@ Partial Class AF_AF extencion = array(array.Length - 1) End If - If Adjunto.Trim.Length > 0 Then + 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 @@ -1316,9 +1327,9 @@ Partial Class AF_AF End If End If End If - End Sub + End Sub #End Region - + #Region "S E G U R O S" Public Sub CargaSeguros() Dim ObjAF As New ClsAF() @@ -1415,30 +1426,30 @@ Partial Class AF_AF CargaSeguros() ObjAF.Dispose() UpDatos.Update() - End Sub - - + 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 + '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() @@ -1646,9 +1657,9 @@ Partial Class AF_AF OnError("Ocurrió error al mandar MAIL", ex) End Try - End Sub + End Sub #End Region - + #Region "A C C I D E N T E S " Public Sub CargaAccidentes() Dim ObjAF As New ClsAF() @@ -1832,9 +1843,9 @@ Partial Class AF_AF OnError("Ocurrió error al mandar MAIL", ex) End Try - End Sub + 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) @@ -1968,10 +1979,10 @@ Partial Class AF_AF e.Row.Cells(5).Text = "Horómetro Final" End If End If - End Sub - + 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 = "" @@ -2025,81 +2036,81 @@ Partial Class AF_AF End If ObjEventos.Dispose() - End Sub + 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 - + + '#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 @@ -2155,102 +2166,102 @@ Partial Class AF_AF 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 - - + 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 @@ -2332,35 +2343,35 @@ Partial Class AF_AF nombreArchivoFormateado = nombreArchivoFormateado.Replace("~", "_") nombreArchivoFormateado = nombreArchivoFormateado.Replace("^", "_") Return nombreArchivoFormateado - End Function - + 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 - + '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 @@ -2414,9 +2425,9 @@ Partial Class AF_AF ObjActivoFijo.Dispose() End If - End Sub + End Sub #End Region - + Private Sub CargarArchivo() Dim StrBuilder As New StringBuilder Dim TmpDT As DataTable = Nothing @@ -2489,80 +2500,80 @@ Partial Class AF_AF 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 - - - - + 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 @@ -2648,10 +2659,10 @@ Partial Class AF_AF Alert("El Activo Fijo se Eliminó correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/AF/CatAF.aspx""") End If ObjActivoFijo.Dispose() - End Sub - + 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 @@ -2756,125 +2767,125 @@ Partial Class AF_AF 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 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 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 @@ -2952,10 +2963,10 @@ Partial Class AF_AF HttpContext.Current.Response.End() Archivo = Nothing - End Sub + 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 @@ -2983,10 +2994,10 @@ Partial Class AF_AF ObjHistorial.Dispose() GVHistorial.DataBind() - End Sub + 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 @@ -3012,10 +3023,10 @@ Partial Class AF_AF ObjGral.Dispose() GVHistModificaciones.DataBind() - End Sub + End Sub #End Region - - + + #Region "GUARDAR ARCHIVO" Protected Sub BtnGuardaArchivo1_Click(sender As Object, e As ImageClickEventArgs) Dim objResguardos As New ClsAF @@ -3091,18 +3102,18 @@ Partial Class AF_AF GvResguardos.DataBind() - End Sub + End Sub #End Region - + Protected Sub DdlSubTipoActivoFijo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubTipoActivoFijo.SelectedIndexChanged CargaCaracteristicas() CargaDispositivos() ModalidadesPaginaAF() - End Sub - + End Sub + #Region "CARGAR CUENTA CONTABLE" - + Private Sub CargaCuentasContables() trCuentaContable.Visible = True @@ -3183,12 +3194,12 @@ Partial Class AF_AF ObjContaAC.Dispose() ObjAF.Dispose() UpDatos.Update() - End Sub - - + End Sub + + #End Region - - + + #Region "IMPRESIÓN FULL" Private Sub GenerarPDF(Optional Formato As String = "PDF") @@ -3219,7 +3230,7 @@ Partial Class AF_AF Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) + params.Add(New ReportParameter("LogoPath", $"file://{Imagen.FullName}")) Else params.Add(New ReportParameter("LogoPath", "")) End If @@ -3284,12 +3295,12 @@ Partial Class AF_AF Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click GenerarPDF("PDF") - End Sub + End Sub #End Region - - + + #Region "Codigo Barras" - 'Codigo barras/QR se retorna como una imagen bmp + '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 @@ -3480,18 +3491,18 @@ Partial Class AF_AF Catch ex As Exception End Try - End Sub - - + 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 + If DdlAFInvPS.SelectedValue.ToEntero <= 0 Then + Alert("Seleccione un producto.") + Exit Sub End If Dim CveSeccionAlmacen As Integer = -1 AFInvSerie = "" @@ -3500,14 +3511,14 @@ Partial Class AF_AF AFInvCveSeccionAlmacen = -1 Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlAFInvPS.SelectedValue.ToEntero).FiltroPrimero("") - If DrPS Is Nothing Then Exit Sub - + 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") - - + 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 @@ -3532,7 +3543,7 @@ Partial Class AF_AF TxtDescripcion.Text = DdlAFInvPS.SelectedText TxtValorCompra.Text = Costo.FormatoNumero - TxtFechaCompra.Text = Now.ToShortDateString + TxtFechaCompra.Text = Now.ToShortDateString TxtFechaBaja.Text = "" TxtNoSerie.Text = TxtAFInvSerie.Text.Trim @@ -3549,11 +3560,11 @@ Partial Class AF_AF DivAFInvAdvertencia.Visible = True UpDatos.Update() - End Sub - - + End Sub + + #End Region - + #Region "AF GRUPOS" Private Sub BtnAgregarGrupo_Click(sender As Object, e As EventArgs) Handles BtnAgregarGrupo.Click TxtGrupoAF.Text = "" @@ -3695,15 +3706,15 @@ Partial Class AF_AF End If ObjAF.Dispose() UpDatos.Update() - End Sub + 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 Sub #End Region - + #Region "AF PADRE E HIJOS" Public Sub CargaAFPAdreEHijos() CargaAFPadres() @@ -3741,10 +3752,10 @@ Partial Class AF_AF ObjAF.Dispose() UpDatos.Update() - End Sub - + End Sub + #End Region - + #Region "G P S" Protected Sub DdlDispositivo_SelectedIndexChanged(sender As Object, e As EventArgs) CargaUltimaPosicion(DdlDispositivo.SelectedValue.ToEntero) @@ -4092,27 +4103,27 @@ Partial Class AF_AF UpGeocercas.Update() RegistraScript(SBJS.ToString()) End Try - End Sub + 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 - - + 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() @@ -4156,728 +4167,728 @@ Partial Class AF_AF Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) + params.Add(New ReportParameter("LogoPath", $"file://{Imagen.FullName}")) Else params.Add(New ReportParameter("LogoPath", "")) End If 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 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 \ No newline at end of file