diff --git a/AF/AF.aspx b/AF/AF.aspx index d4756bf89..68957ccb4 100644 --- a/AF/AF.aspx +++ b/AF/AF.aspx @@ -218,21 +218,21 @@
- +
- +
- - + + @@ -248,6 +248,35 @@
+ + + +
+
+ +
+ +
+
+
+ + + + +
+ + + + + + + + + +
+
+ +
@@ -1156,65 +1185,79 @@ -
-
-
- Servicios + + + + + + +
+
+
+
+
+ + Mantenimientos + +
+
+
+ Agregar +
+
+ +
+ <%-- + + + --%> + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
-
- - - - -
+ + + + + + @@ -2076,7 +2119,87 @@ + + + + + + + + + +
+
+
+
+
+ + Producción + +
+
+
+ Agregar +
+
+ +
+ <%-- + + + --%> + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + +
+ +
+
+ + + +
+
+ + + + + + + + @@ -3106,6 +3229,200 @@
+ + + <%--MODAL PRODUCCION--%> + + + + + + + <%--MODAL MANTENIMIENTO--%> + + + + + diff --git a/AF/AF.aspx.vb b/AF/AF.aspx.vb index 8dad34b1f..4695bad3b 100644 --- a/AF/AF.aspx.vb +++ b/AF/AF.aspx.vb @@ -245,6 +245,31 @@ Partial Class AF_AF #End Region + + Private Property CveProduccion As Integer + Get + If ViewState("CveProduccion") Is Nothing Then + ViewState("CveProduccion") = -1 + End If + Return ViewState("CveProduccion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveProduccion") = value + End Set + End Property + + Private Property CveMantenimiento As Integer + Get + If ViewState("CveMantenimiento") Is Nothing Then + ViewState("CveMantenimiento") = -1 + End If + Return ViewState("CveMantenimiento").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMantenimiento") = value + End Set + End Property + #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load @@ -260,9 +285,11 @@ Partial Class AF_AF ViewState("CveActivoFijo") = Request("CveActivoFijo") CargaDatos() CargaEventos() - CargaActividades() - - 'Configuración de Modalidad Update + CargaActividades() + CargaProduccion() + CargaMantenimento() + + 'Configuración de Modalidad Update BtnGuardar.Text = "Guardar Cambios" LtlTitulo.Text = "Consulta del Activo Fijo:" @@ -271,8 +298,9 @@ Partial Class AF_AF HlEvento.NavigateUrl = String.Format("/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveActivoFijo=" & CveActivoFijo & "&TB_iframe=true&height=370&width=600;") Else ViewState("CveActivoFijo") = -1 - CargaCombos() - 'Configuración de Modalidad Insert + CargaCombos() + + 'Configuración de Modalidad Insert ImgAddObs.Visible = False LblFechaCaptura.Text = Now.ToShortDateString() LblUsuarioCapturo.Text = UsuarioActual.Usuario @@ -288,6 +316,13 @@ Partial Class AF_AF CargaAFInv() cargaOrdenesdeservicio() + + + + If Request("Op") IsNot Nothing Then + ModalidadesPaginaAF(Request("Op").ToString) + End If + End If End Sub Private Sub cargaOrdenesdeservicio() @@ -373,6 +408,20 @@ Partial Class AF_AF CveEmpresaActual = UsuarioActual.CveEmpresa End Sub + Private Sub ModalidadesPaginaAF(Op As String) + + Select Case Op + Case "AR" 'Arbol Frutal etc + LblFechaCompra.Text = "Fecha de Nacimiento" + LblFechaBaja.Text = "Fecha de Muerte" + TabProduccion.Visible = True + Exit Select + Case Else + Exit Select + End Select + + + End Sub #Region " CARGA COMBOS " Private Sub CargaCombos() @@ -398,6 +447,8 @@ Partial Class AF_AF DdlResponsable.Enabled = False End If + CargaCultivos() + End Sub Private Sub CargaTipoActivoFijo() DdlTipoActivoFijo.DataSource = GlobalDTTipoActivoFijo(CveEmpresaActual).FiltraParametros("", "TipoActivoFijo") @@ -476,6 +527,11 @@ Partial Class AF_AF ' DdlClientes.DataBind() 'End Sub + Private Sub CargaCultivos() + DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}") + DdlModalCultivosCuadro.DataBind() + DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + End Sub Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged CargaSubProyecto() End Sub @@ -562,6 +618,13 @@ Partial Class AF_AF DdlModelos.DataBind() DdlModelos.Items.Insert(0, New ListItem("-", "-1")) End Sub + + Private Sub CargaProduccionCuadros() + DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue}") + DdlModalCultivosCuadro.DataBind() + DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + End Sub + #End Region Private Sub CargaDatos() @@ -579,7 +642,13 @@ Partial Class AF_AF TxtDescripcion.Text = ObjActivoFijo.Descripcion TxtCodigo.Text = ObjActivoFijo.Codigo TxtValorCompra.Text = ObjActivoFijo.ValorCompra.ToString.FormatoNumero - TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString + TxtFechaCompra.Text = ObjActivoFijo.FechaCompra.ToShortDateString + + + + TxtFechaBaja.Text = If(ObjActivoFijo.FechaBaja = New Date(1900, 1, 1), "", ObjActivoFijo.FechaBaja.ToString("dd/MM/yyyy")) + + DdlTipoActivoFijo.SelectedValue = ObjActivoFijo.CveTipoActivoFijo.ToString CargaSubTipoActivoFijo() DdlSubTipoActivoFijo.SelectedValue = ObjActivoFijo.CveSubTipoActivoFijo.ToString @@ -654,8 +723,8 @@ Partial Class AF_AF CargaPlacas() CargaLicencias() - CargaSeguros() - CargaServicios() + CargaSeguros() + CargaFallas() CargaAccidentes() @@ -1062,31 +1131,22 @@ Partial Class AF_AF #End Region #Region "S E R V I C I O S - M A N T E M I E N T O" - Public Sub CargaServicios() - Dim TmpServicios As New DataTable - TmpServicios.Columns.Add("CveProveedor", GetType(Integer)) - TmpServicios.Columns.Add("CveCompra", GetType(Integer)) - TmpServicios.Columns.Add("Tipo", GetType(String)) - TmpServicios.Columns.Add("Fecha", GetType(Date)) - TmpServicios.Columns.Add("Proveedor", GetType(String)) - TmpServicios.Columns.Add("Factura", GetType(String)) - TmpServicios.Columns.Add("OdHorometro", GetType(Double)) - TmpServicios.Columns.Add("Observaciones", GetType(String)) - - 'Dim Row As DataRow = TmpServicios.NewRow - 'Row("CveProveedor") = 3100 - 'Row("CveCompra") = 181656 - 'Row("Tipo") = "Preventivo" - 'Row("Fecha") = "01/02/2016" - 'Row("Proveedor") = "EMPRESAS MATCO, S.A. DE C.V." - 'Row("Factura") = "HERAA-158591" - 'Row("OdHorometro") = "198,567" - 'Row("Observaciones") = "Servicio Preventivo 200,000 Kilometros - Servicio Completo" - 'TmpServicios.Rows.Add(Row) - - GvServiciosMant.DataSource = TmpServicios - GvServiciosMant.DataBind() - End Sub + 'Public Sub CargaServicios() + ' Dim TmpServicios As New DataTable + ' TmpServicios.Columns.Add("CveProveedor", GetType(Integer)) + ' TmpServicios.Columns.Add("CveCompra", GetType(Integer)) + ' TmpServicios.Columns.Add("Tipo", GetType(String)) + ' TmpServicios.Columns.Add("Fecha", GetType(Date)) + ' TmpServicios.Columns.Add("Proveedor", GetType(String)) + ' TmpServicios.Columns.Add("Factura", GetType(String)) + ' TmpServicios.Columns.Add("OdHorometro", GetType(Double)) + ' TmpServicios.Columns.Add("Observaciones", GetType(String)) + + + + ' GvServiciosMant.DataSource = TmpServicios + ' GvServiciosMant.DataBind() + 'End Sub #End Region #Region "F A L L A S" @@ -2106,6 +2166,8 @@ Partial Class AF_AF Dim ObjContabilidad As New ClsContabilidad(ObjAF.IniciaTransacSQL()) Dim ErrorGuardar As Boolean = False + Dim FechaBaja As Date = If(TxtFechaBaja.Text = "", MinFecha, TxtFechaBaja.Text.ToDate) + If CveActivoFijo <= 0 Then 'SALIDA DE ALMACEN PARA IMPORTACION @@ -2123,12 +2185,15 @@ Partial Class AF_AF End If + + If Not ErrorGuardar Then If ObjAF.AddActivosFijos(TxtCodigo.Text.Trim, TxtDescripcion.Text.Trim, TxtValorCompra.Text.Trim.ToDouble, TxtFechaCompra.Text.Trim.ToDate, DdlSubTipoActivoFijo.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, TxtNoSerie.Text.Trim, TxtAño.Text.Trim.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.Trim.ToEntero, DdlEstadoActivoFijo.SelectedValue.ToEntero, DdlCtaContableDepreciacion.SelectedValue.ToEntero, TxtPorDepreciacion.Text.Trim.ToDouble, - TxtObservaciones.Text.Trim, DdlClientes.SelectedValue.ToEntero, CveMovimientoSalidaInv, UsuarioActual.CveUsuario, CveEmpresaActual, CveMarca:=DdlMarcas.SelectedValue.ToEntero, - CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero) > 0 Then + TxtObservaciones.Text.Trim, Ddlclientes.SelectedValue.ToEntero, CveMovimientoSalidaInv, UsuarioActual.CveUsuario, CveEmpresaActual, CveMarca:=DdlMarcas.SelectedValue.ToEntero, + CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero, + FechaBaja:=FechaBaja) > 0 Then ViewState("CveActivoFijo") = ObjAF.CveActivoFijo Else ErrorGuardar = True @@ -2155,8 +2220,9 @@ Partial Class AF_AF If Not ObjAF.UpdateActivosFijos(CveActivoFijo.ToString.ToEntero, TxtCodigo.Text.Trim, TxtDescripcion.Text.Trim, TxtValorCompra.Text.Trim.ToDouble, TxtFechaCompra.Text.Trim.ToDate, DdlSubTipoActivoFijo.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, TxtNoSerie.Text.Trim, TxtAño.Text.Trim.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.Trim.ToEntero, DdlEstadoActivoFijo.SelectedValue.ToEntero, DdlCtaContableDepreciacion.SelectedValue.ToEntero, - TxtPorDepreciacion.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, DdlClientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, CveEmpresaActual, - CveMarca:=DdlMarcas.SelectedValue.ToEntero, CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero) Then + TxtPorDepreciacion.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, Ddlclientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, CveEmpresaActual, + CveMarca:=DdlMarcas.SelectedValue.ToEntero, CveModelo:=DdlModelos.SelectedValue.ToEntero, CveGrupo:=DdlGrupo.SelectedValue.ToEntero, CveAFPadre:=DdlAFPadres.SelectedValue.ToEntero, CveDispositivo:=DdlDispositivo.SelectedValue.ToEntero, + FechaBaja:=FechaBaja) Then 'Comentado porque te redirecciona no se ocupa - 22 Enero 2016 - Israel Piña 'CargaDatos() @@ -3097,7 +3163,8 @@ Partial Class AF_AF TxtDescripcion.Text = DdlAFInvPS.SelectedText TxtValorCompra.Text = Costo.FormatoNumero - TxtFechaCompra.Text = Now.ToShortDateString + TxtFechaCompra.Text = Now.ToShortDateString + TxtFechaBaja.Text = "" TxtNoSerie.Text = TxtAFInvSerie.Text.Trim TxtValorCompra.Enabled = False @@ -3727,5 +3794,373 @@ Partial Class AF_AF ImprimirPDF("Empresas/Grales/Formatos/RepComprasInsumos.rdlc", DTCompras, params, "RepComprasInsumos", Formato) - End Sub + End Sub + + +#Region "Produccion" + + + + Private Sub CargaProduccion() + + Dim ObjAF As New ClsAF + + If ObjAF.GetProduccion(CveActivoFijo, UsuarioActual.CveEmpresa) Then + GvProduccion.DataSource = ObjAF.DtResultados + Else + GvProduccion.DataSource = Nothing + End If + + ObjAF.Dispose() + GvProduccion.DataBind() + + UpProduccion.Update() + + End Sub + + + Protected Sub LnkAgregarProduccion_Click(sender As Object, e As EventArgs) + + LblModaProduccionTitulo.Text = "Agregar Producción" + LnkModalAgregarProduccion.Text = "Agregar" + CveProduccion = -1 + + DdlModalCultivosCuadro.SelectedValueExist(-1) + TxtModalProduccionCantidad.Text = "" + TxtModalProduccionFecha.Text = "" + + RegistraScript("$('#DVModalProduccion').modal('show');") + + UpModalProduccion.Update() + End Sub + + Protected Sub LnkGvProduccionEdit_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + CveProduccion = GvRow.DataKey("CveProduccion").ToEntero + Dim CveCultivoCuadroDetalle As Integer = GvRow.DataKey("CveCultivoCuadroDetalle").ToEntero + Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal + Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate + + DdlModalCultivosCuadro.SelectedValueExist(CveCultivoCuadroDetalle) + TxtModalProduccionCantidad.Text = Cantidad.ToString("###,###,###.00") + TxtModalProduccionFecha.Text = Fecha.ToString("dd/MM/yyyy") + + + LblModaProduccionTitulo.Text = "Actualizar Producción" + LnkModalAgregarProduccion.Text = "Actualizar" + + UpModalProduccion.Update() + + + RegistraScript("$('#DVModalProduccion').modal('show');") + End Sub + + Protected Sub LnkGvProduccionRemove_Click(sender As Object, e As EventArgs) + + Dim ErrorProceso As Boolean = False + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveProduccionEliminar As Integer = GvRow.DataKey("CveProduccion").ToEntero + + Dim ObjAF As New ClsAF + + If ObjAF.RemoveProduccion(CveProduccionEliminar, UsuarioActual.CveEmpresa) Then + ErrorProceso = False + Else + ErrorProceso = True + End If + + + ObjAF.Dispose() + + + If Not ErrorProceso Then + Alert("Producción Eliminada Correctamente.") + CargaProduccion() + End If + + End Sub + + + + Protected Sub LnkModalAgregarProduccion_Click(sender As Object, e As EventArgs) + Dim ErrorProceso As Boolean = False + Dim ObjAF As New ClsAF + + If CveProduccion > 0 Then + If ObjAF.UpdateProduccion(CveProduccion, CveActivoFijo, DdlModalCultivosCuadro.SelectedValue.ToEntero, TxtModalProduccionCantidad.Text.ToDecimal, TxtModalProduccionFecha.Text.ToDate, UsuarioActual.CveUsuario) Then + ErrorProceso = False + Else + ErrorProceso = True + End If + Else + If ObjAF.AddProduccion(CveActivoFijo, DdlModalCultivosCuadro.SelectedValue.ToEntero, TxtModalProduccionCantidad.Text.ToDecimal, TxtModalProduccionFecha.Text.ToDate, UsuarioActual.CveUsuario) Then + ErrorProceso = False + Else + ErrorProceso = True + End If + End If + + + + ObjAF.Dispose() + + If Not ErrorProceso Then + RegistraScript("$('#DVModalMantenimiento').modal('hide');") + Alert("Producción Agregada Correctamente.") + CargaProduccion() + End If + + End Sub + +#End Region + +#Region "MANTENIMIENTO" + + + + + Private Sub CargaMantenimento() + + Dim ObjAF As New ClsAF + + If ObjAF.GetMantenimientos(CveActivoFijo, UsuarioActual.CveEmpresa) Then + GvMantenimientos.DataSource = ObjAF.DtResultados + Else + GvMantenimientos.DataSource = Nothing + End If + + ObjAF.Dispose() + GvMantenimientos.DataBind() + + UpMantenimientos.Update() + + End Sub + + + Protected Sub LnkAgregarMantenimiento_Click(sender As Object, e As EventArgs) + + LblModaMantenimientoTitulo.Text = "Agregar Mantenimiento" + LnkModalAgregarMantenimiento.Text = "Agregar" + + CveMantenimiento = -1 + + TxtModalMantenimiento.Text = "" + TxtModalMantenimientoObservaciones.Text = "" + TxtModalMantenimientoFecha.Text = "" + TxtArchivoMantenimiento.Text = "[]" + + RegistraScript("$('#DVModalMantenimiento').modal('show');") + + UpModalMantenimiento.Update() + End Sub + + Protected Sub LnkGvMantenimientoEdit_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + 'CveMantenimiento, CveActivoFijo, Mantenimiento, Observaciones, Fecha, FechaIng, CveUsuario, Codigo, Descripcion, Usuario + + CveMantenimiento = GvRow.DataKey("CveMantenimiento").ToEntero + + Dim Mantenimiento As String = GvRow.DataKey("Mantenimiento") + Dim Observaciones As String = GvRow.DataKey("Observaciones") + Dim Fecha As Date = GvRow.DataKey("Fecha").ToDate + + TxtModalMantenimiento.Text = Mantenimiento + TxtModalMantenimientoObservaciones.Text = Observaciones + TxtModalMantenimientoFecha.Text = Fecha.ToString("dd/MM/yyyy") + TxtArchivoMantenimiento.Text = "[]" + + + LblModaMantenimientoTitulo.Text = "Actualizar Mantenimiento" + LnkModalAgregarMantenimiento.Text = "Actualizar" + + UpModalMantenimiento.Update() + + + RegistraScript("$('#DVModalMantenimiento').modal('show');") + End Sub + + Protected Sub LnkGvMantenimientoRemove_Click(sender As Object, e As EventArgs) + + Dim ErrorProceso As Boolean = False + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveMantenimientoEliminar As Integer = GvRow.DataKey("CveMantenimiento").ToEntero + + Dim ObjAF As New ClsAF + + If ObjAF.RemoveMantenimientos(CveMantenimientoEliminar, UsuarioActual.CveEmpresa) Then + ErrorProceso = False + Else + ErrorProceso = True + End If + + + ObjAF.Dispose() + + + If Not ErrorProceso Then + Alert("Mantenimiento Eliminado Correctamente.") + CargaMantenimento() + End If + + End Sub + + + + Protected Sub LnkModalAgregarMantenimiento_Click(sender As Object, e As EventArgs) + Dim ErrorProceso As Boolean = False + Dim ObjAF As New ClsAF + ObjAF.IniciaTransacSQL() + + + If CveMantenimiento > 0 Then + + Dim FileExtension As String = "" + Dim Filesgral As List(Of Archivo) = TxtArchivoMantenimiento.getfiles().Archivos + Dim Filename As String = "-1" + + If Filesgral.Count > 0 Then + + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Filename = fileItem.filename + Exit For + Next + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Mantenimientos\{1}", UsuarioActual.Empresa.Ruta, $"{CveMantenimiento}.{FileExtension}")) + If Archivo.Exists() Then + Archivo.Delete() + End If + + + If Not Filename.FilesMove(String.Format("{0}", CveMantenimiento.ToString), String.Format("{0}AF\Mantenimientos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Then + ErrorProceso = True + Alert("Error al mover Archivo", TipoMensaje.MsgError) + End If + + End If + + If Not ErrorProceso Then + If Not ObjAF.UpdateMantenimientos(CveMantenimiento, CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, $"{CveMantenimiento}.{FileExtension}") Then + ErrorProceso = True + End If + End If + + + Else + + + Dim CveMantenimientoTemp As Integer = -1 + + + CveMantenimientoTemp = ObjAF.AddMantenimientos(CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, "-1") + If CveMantenimientoTemp > 0 Then + ErrorProceso = False + Else + ErrorProceso = True + End If + + If Not ErrorProceso Then + + Dim FileExtension As String = "" + Dim Filesgral As List(Of Archivo) = TxtArchivoMantenimiento.getfiles().Archivos + Dim Filename As String = "" + + If Filesgral.Count > 0 Then + + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Filename = fileItem.filename + Exit For + Next + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}AF\Mantenimientos\{1}", UsuarioActual.Empresa.Ruta, $"{CveMantenimientoTemp}.{FileExtension}")) + If Archivo.Exists() Then + Archivo.Delete() + End If + + + If Not Filename.FilesMove(String.Format("{0}", CveMantenimientoTemp.ToString), String.Format("{0}AF\Mantenimientos", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Then + ErrorProceso = True + Alert("Error al mover Archivo", TipoMensaje.MsgError) + End If + + If Not ErrorProceso Then + If Not ObjAF.UpdateMantenimientos(CveMantenimientoTemp, CveActivoFijo, TxtModalMantenimiento.Text, TxtModalMantenimientoObservaciones.Text, TxtModalMantenimientoFecha.Text.ToDate, UsuarioActual.CveUsuario, $"{CveMantenimientoTemp}.{FileExtension}") Then + ErrorProceso = True + End If + End If + + + End If + + + End If + + + End If + + + + + + + If Not ErrorProceso Then + ObjAF.Commit() + ObjAF.Dispose() + + RegistraScript("$('#DVModalMantenimiento').modal('hide');") + Alert("Mantenimiento Guardado Correctamente.") + CargaMantenimento() + Else + ObjAF.RollBack() + ObjAF.Dispose() + End If + + End Sub + + Protected Sub LnkDescargaArcgivo_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim Archivo As String = GvRow.DataKey("Archivo") + Dim InfArchivo As New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}") + + If InfArchivo.Exists Then + Response.Clear() + Response.AppendHeader("Content-Disposition", "attachment; filename=" + InfArchivo.Name) + Response.AppendHeader("Content-Length", InfArchivo.Length.ToString()) + Response.ContentType = "application/octet-stream" + Response.WriteFile(InfArchivo.FullName) + + Response.End() + End If + + + + End Sub + + Protected Sub GvMantenimientos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim Archivo As String = e.Row.DataKey("Archivo") + Dim InfArchivo As New FileInfo($"{UsuarioActual.Empresa.Ruta}\AF\Mantenimientos\{Archivo}") + + If InfArchivo.Exists Then + e.Row.FCLinkButton("LnkDescargaArcgivo").Visible = True + ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkDescargaArcgivo")) + End If + + End If + + End Sub + +#End Region + + + + + + End Class \ No newline at end of file diff --git a/App_Code/ClsAF.vb b/App_Code/ClsAF.vb index ad8c046c4..94a279be0 100644 --- a/App_Code/ClsAF.vb +++ b/App_Code/ClsAF.vb @@ -47,6 +47,7 @@ Public Class ClsAF Public Property CveCompra As Integer Public Property ValorCompra As Double Public Property FechaCompra As Date + Public Property FechaBaja As Date Public Property CuentaInicial As Integer Public Property CveTipoActivoFijo As Integer Public Property TipoActivoFijo As String @@ -230,6 +231,7 @@ Public Class ClsAF Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero Me.Usuario = Data.Rows(0)("Usuario").ToString Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + Me.FechaBaja = Data.Rows(0)("FechaBaja").ToString.ToDate End If Retorno = True Catch ex As Exception @@ -344,6 +346,9 @@ Public Class ClsAF Me.CveGrupoAF = Data.Rows(0)("CveGrupo").ToString.ToEntero Me.CveAFPadre = Data.Rows(0)("CveAFPadre").ToString.ToEntero Me.CveDispositivo = Data.Rows(0)("CveDispositivo").ToString.ToEntero + Me.FechaBaja = Data.Rows(0)("FechaBaja").ToString.ToDate + + End If Retorno = True Catch ex As Exception @@ -397,7 +402,7 @@ Public Class ClsAF Public Function AddActivosFijos(Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, Cuenta As Integer, CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, CveMovimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, - Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Integer + Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1, Optional FechaBaja As Date = MinFecha) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_AF_ActivosFijosAdd") @@ -427,6 +432,7 @@ Public Class ClsAF .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@FechaBaja", SqlDbType.Date).Value = FechaBaja .Add("@CveActivoFijo", SqlDbType.Int).Direction = ParameterDirection.Output .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue @@ -458,7 +464,7 @@ Public Class ClsAF CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, IdCtaContActivoFijo As Integer, CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, CveUsuarioModifico As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, - Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Boolean + Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1, Optional FechaBaja As Date = MinFecha) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_AF_ActivosFijosUpdate") @@ -490,6 +496,7 @@ Public Class ClsAF .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@FechaBaja", SqlDbType.Date).Value = FechaBaja End With Try @@ -4512,6 +4519,230 @@ Public Class ClsAF #End Region +#End Region + +#Region " P R O D U C C C I Ó N " + + Public Function AddProduccion(CveActivoFijo As Integer, CveCultivoCuadroDetalle As Integer, Cantidad As Decimal, Fecha As Date, CveUsuario As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ProduccionAdd") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCultivoCuadroDetalle", SqlDbType.Int).Value = CveCultivoCuadroDetalle + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la producción", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + Public Function UpdateProduccion(CveProduccion As Integer, CveActivoFijo As Integer, CveCultivoCuadroDetalle As Integer, Cantidad As Decimal, Fecha As Date, CveUsuario As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ProduccionUpdate") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveProduccion", SqlDbType.Int).Value = CveProduccion + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCultivoCuadroDetalle", SqlDbType.Int).Value = CveCultivoCuadroDetalle + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la producción", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + + Public Function GetProduccion(CveActivoFijo As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ProduccionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar la producción", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + Public Function RemoveProduccion(CveProduccion As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ProduccionRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProduccion", SqlDbType.Int).Value = CveProduccion + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la producción", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + +#End Region + +#Region " M A N T E N I M I E N T O S " + + + + + + Public Function AddMantenimientos(CveActivoFijo As Integer, Mantenimiento As String, Observaciones As String, Fecha As Date, CveUsuario As Integer, Archivo As String) As Integer + + Dim Retorno As Integer = -1 + + DataAdapter("PA_AF_MantenimientosAdd") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@Mantenimiento", SqlDbType.VarChar).Value = Mantenimiento + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Archivo", SqlDbType.VarChar).Value = Archivo + .Add("@CveMantenimiento", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CveMantenimiento").Value.ToString.ToEntero + + Catch ex As Exception + OnError("Ocurrió un error al agregar el mantenimiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + Public Function UpdateMantenimientos(CveMantenimiento As Integer, CveActivoFijo As Integer, Mantenimiento As String, Observaciones As String, Fecha As Date, CveUsuario As Integer, Archivo As String) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MantenimientosUpdate") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveMantenimiento", SqlDbType.Int).Value = CveMantenimiento + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@Mantenimiento", SqlDbType.VarChar).Value = Mantenimiento + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Archivo", SqlDbType.VarChar).Value = Archivo + + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el mantenimiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + + Public Function GetMantenimientos(CveActivoFijo As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MantenimientosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los mantenimientos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + Public Function RemoveMantenimientos(CveMantenimiento As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MantenimientosRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMantenimiento", SqlDbType.Int).Value = CveMantenimiento + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el mantenimiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + + #End Region diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 77de3378d..2d7da6a41 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -1287,7 +1287,8 @@ Public Class ClsInventarios Optional CveSeccionAlmacen As Integer = -1, Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Observaciones As String = "", Optional CveMovimientoDetalleEntrada As Integer = -1, Optional PUTC As Decimal = -1, Optional CostoIndirecto As Decimal = 0, Optional CveCompraDetalle As Integer = -1, Optional CveOrdenCompraDetalle As Integer = -1, Optional CveVentaDetalle As Integer = -1, - Optional CveContratoDetalle As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional EsInterno As Integer = -1, Optional CveVentaDetalleRemision As Integer = -1) As Boolean + Optional CveContratoDetalle As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional EsInterno As Integer = -1, Optional CveVentaDetalleRemision As Integer = -1, + Optional CveCultivoCuadroDetalle As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_MovimientosDetalleAdd") @@ -1314,6 +1315,7 @@ Public Class ClsInventarios .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico .Add("@EsInterno", SqlDbType.Int).Value = EsInterno .Add("@CveVentaDetalleRemision", SqlDbType.Int).Value = CveVentaDetalleRemision + .Add("@CveCultivoCuadroDetalle", SqlDbType.Int).Value = CveCultivoCuadroDetalle .Add("@CveMovimientoDetalle", SqlDbType.Int).Direction = ParameterDirection.Output End With @@ -1349,7 +1351,7 @@ Public Class ClsInventarios Return Retorno End Function Public Function UpdateMovimientoDetalle(Cantidad As Double, CveUM As Integer, CvePS As Integer, PU As Double, CveAF As Integer, CveMovimientoDetalle As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional Serie As String = "", - Optional Observaciones As String = "-1", Optional PUTC As Double = -1, Optional CveUsuarioModifico As Integer = -1) As Boolean + Optional Observaciones As String = "-1", Optional PUTC As Double = -1, Optional CveUsuarioModifico As Integer = -1, Optional CveCultivoCuadroDetalle As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_MovimientosDetalleUpdate") @@ -1366,6 +1368,7 @@ Public Class ClsInventarios .Add("@Serie", SqlDbType.VarChar).Value = Serie .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + .Add("@CveCultivoCuadroDetalle", SqlDbType.Int).Value = CveCultivoCuadroDetalle End With Try diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx index 43b2d9b89..cefd8ec94 100644 --- a/Inventarios/EntradasSalidas.aspx +++ b/Inventarios/EntradasSalidas.aspx @@ -1701,6 +1701,25 @@ + + + + +
+ + + + + + +
+ + + + +