From 67aba388f54267718e2743d38733fdc56d4a31f4 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Fri, 17 Jul 2020 13:42:46 -0700 Subject: [PATCH 01/12] avance --- App_Code/ClsOIEventos.vb | 283 ++++++++++++++++++++++++++++ App_Code/ClsPaginas.vb | 2 + OI/CatDocumentoCategoria.aspx | 76 ++++++++ OI/CatDocumentoCategoria.aspx.cs | 104 ++++++++++ OI/CatDocumentoSubCategoria.aspx | 76 ++++++++ OI/CatDocumentoSubCategoria.aspx.cs | 114 +++++++++++ OI/Documentos.aspx | 49 +++++ OI/Documentos.aspx.cs | 30 +++ 8 files changed, 734 insertions(+) create mode 100644 OI/CatDocumentoCategoria.aspx create mode 100644 OI/CatDocumentoCategoria.aspx.cs create mode 100644 OI/CatDocumentoSubCategoria.aspx create mode 100644 OI/CatDocumentoSubCategoria.aspx.cs create mode 100644 OI/Documentos.aspx create mode 100644 OI/Documentos.aspx.cs diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index 551593b30..8a65a1f30 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -2743,8 +2743,291 @@ Public Class ClsOIEventos Return Retorno End Function + + #End Region +#Region "OI_Documentos" + +#Region "OI_DocumentosCategorias" + Public Function GetDocumentoCategoria(Optional CveCategoria As Integer = -1, Optional Categoria As String = "-1") As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosCategoriasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@Categoria", SqlDbType.NVarChar).Value = Categoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la categoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddDocumentoCategoria(Categoria As String, Estado As Boolean) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosCategoriasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Categoria", SqlDbType.NVarChar).Value = Categoria + .Add("@Estado", SqlDbType.Bit).Value = Estado + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la categoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateDocumentoCategoria(CveCategoria As Integer, Categoria As String, Estado As Boolean) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosCategoriasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@Categoria", SqlDbType.NVarChar).Value = Categoria + .Add("@Estado", SqlDbType.Bit).Value = Estado + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la categoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveDocumentoCategoria(CveCategoria As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosCategoriasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCategoria", SqlDbType.NVarChar).Value = CveCategoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la categoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "OI_DocumentosSubCategoria" + Public Function GetDocumentoSubCategoria(Optional CveSubCategoria As Integer = -1, Optional SubCategoria As String = "-1") As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosSubCategoriasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubCategoria", SqlDbType.Int).Value = CveSubCategoria + .Add("@SubCategoria", SqlDbType.NVarChar).Value = SubCategoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la subcategoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddDocumentoSubCategoria(SubCategoria As String, CveCategoria As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosSubCategoriasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@SubCategoria", SqlDbType.NVarChar).Value = SubCategoria + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la subcategoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateDocumentoSubCategoria(CveSubCategoria As Integer, SubCategoria As String, CveCategoria As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosSubCategoriasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubCategoria", SqlDbType.Int).Value = CveSubCategoria + .Add("@SubCategoria", SqlDbType.NVarChar).Value = SubCategoria + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la subcategoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveDocumentoSubCategoria(CveSubCategoria As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosSubCategoriasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubCategoria", SqlDbType.NVarChar).Value = CveSubCategoria + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la subcategoria", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "Documentos" + Public Function GetDocumento(CveDocumento As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveDocumento", SqlDbType.Int).Value = CveDocumento + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddDocumento(CveSubCategoria As Integer, Descripcion As String, Observacion As String, Version As String, CveEstatus As Integer, ArchivoFisico As String, + Responsable As String, FechaAprobacion As Date, CveDocumentoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubCategoria", SqlDbType.Int).Value = CveSubCategoria + .Add("@Descripcion", SqlDbType.NVarChar).Value = Descripcion + .Add("@Observacion", SqlDbType.NVarChar).Value = Observacion + .Add("@Version", SqlDbType.NVarChar).Value = Version + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@ArchivoFisico", SqlDbType.NVarChar).Value = ArchivoFisico + .Add("@Responsable", SqlDbType.NVarChar).Value = Responsable + .Add("@FechaAprobacion", SqlDbType.Date).Value = FechaAprobacion + .Add("@CveDocumentoPadre", SqlDbType.Int).Value = CveDocumentoPadre + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateDocumento(CveDocumento As Integer, CveSubCategoria As Integer, Descripcion As String, Observacion As String, Version As String, CveEstatus As Integer, ArchivoFisico As String, + Responsable As String, FechaAprobacion As Date, CveDocumentoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveDocumento", SqlDbType.Int).Value = CveDocumento + .Add("@CveSubCategoria", SqlDbType.Int).Value = CveSubCategoria + .Add("@Descripcion", SqlDbType.NVarChar).Value = Descripcion + .Add("@Observacion", SqlDbType.NVarChar).Value = Observacion + .Add("@Version", SqlDbType.NVarChar).Value = Version + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@ArchivoFisico", SqlDbType.NVarChar).Value = ArchivoFisico + .Add("@Responsable", SqlDbType.NVarChar).Value = Responsable + .Add("@FechaAprobacion", SqlDbType.Date).Value = FechaAprobacion + .Add("@CveDocumentoPadre", SqlDbType.Int).Value = CveDocumentoPadre + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveDocumento(CveDocumento As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveDocumento", SqlDbType.Int).Value = CveDocumento + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#End Region ' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 9a4c0c915..5e207a0c5 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4552,6 +4552,8 @@ Public Class ClsPaginas PaginaDict.Add("/OI/RepDesarrollo.aspx".ToUpper(), 475) PaginaDict.Add("/OI/DesarrolloWizard.aspx".ToUpper(), 474) PaginaDict.Add("/OI/SubidasADS.aspx".ToUpper(), 476) + PaginaDict.Add("/OI/CatDocumentoCategoria.aspx".ToUpper(), 760) + PaginaDict.Add("/OI/CatDocumentoSubCategoria.aspx".ToUpper(), 761) #End Region #Region "Planeacion" 'PLANEACIÓN diff --git a/OI/CatDocumentoCategoria.aspx b/OI/CatDocumentoCategoria.aspx new file mode 100644 index 000000000..e935eec64 --- /dev/null +++ b/OI/CatDocumentoCategoria.aspx @@ -0,0 +1,76 @@ +<%@ Page Title="OI - Catálogo de Categorías de Documentos" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CatDocumentoCategoria.aspx.cs" Inherits="OI_CatDocumentoCategoria" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Catálogo de Categorías de Documentos + + + + +
  • + +
  • + +
    +
    +
    + + + + + + + + + + + <%----%> + + + + + + + + + + + diff --git a/OI/CatDocumentoCategoria.aspx.cs b/OI/CatDocumentoCategoria.aspx.cs new file mode 100644 index 000000000..8efdf08c4 --- /dev/null +++ b/OI/CatDocumentoCategoria.aspx.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Extensiones; +using System.Data; + +public partial class OI_CatDocumentoCategoria : ClsPaginas +{ + + private int CveCategoria + { + get + { + return ViewState["CveCategoria"].ToString().ToEntero(); + } + + set + { + ViewState["CveCategoria"] = value; + } + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaDatos(); + } + } + + private void CargaDatos() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumentoCategoria()) + { + GvDatos.DataSource = ObjOI.DtResultados; + GvDatos.DataBind(); + } + ObjOI.Dispose(); + } + + protected void BtnAgregarCategoria_Click(object sender, EventArgs e) + { + BtnAgregarCategoriaDoc.Text = "Agregar"; + TxtCategoria.Text = ""; + ChkEstatus.Checked = true; + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void LnkEditar_Click(object sender, EventArgs e) + { + BtnAgregarCategoriaDoc.Text = "Actualizar"; + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + CveCategoria = GvRow.DataKey("CveCategoria").ToEntero(); + TxtCategoria.Text = GvRow.DataKey("Categoria"); + ChkEstatus.Checked = GvRow.DataKey("Estado").ToString() == "True"; + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void LnkEliminar_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + CveCategoria = GvRow.DataKey("CveCategoria").ToEntero(); + ClsCompras ObjCompras = new ClsCompras(); + if (ObjCompras.RemoveTipoGasto(CveCategoria)) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se eliminó la Categoría de Documento correctamente"); + } + ObjCompras.Dispose(); + } + + protected void BtnAgregarCategoriaDoc_Click(object sender, EventArgs e) + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (BtnAgregarCategoriaDoc.Text == "Agregar") + { + if (ObjOI.AddDocumentoCategoria(TxtCategoria.Text,ChkEstatus.Checked)) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se agregó la Categoría de Documento correctamente"); + } + }else + { + if (ObjOI.UpdateDocumentoCategoria(CveCategoria,TxtCategoria.Text,ChkEstatus.Checked)) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se actualizó la Categoría de Documento correctamente"); + } + } + ObjOI.Dispose(); + } +} \ No newline at end of file diff --git a/OI/CatDocumentoSubCategoria.aspx b/OI/CatDocumentoSubCategoria.aspx new file mode 100644 index 000000000..a7986a1bd --- /dev/null +++ b/OI/CatDocumentoSubCategoria.aspx @@ -0,0 +1,76 @@ +<%@ Page Title="OI - Catálogo de Subcategorías de Documentos" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CatDocumentoSubCategoria.aspx.cs" Inherits="OI_CatDocumentoSubCategoria" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Catálogo de Subcategorías de Documentos + + + + +
  • + +
  • + +
    +
    +
    + + + + + + + + + + + <%----%> + + + + + + + + + + + diff --git a/OI/CatDocumentoSubCategoria.aspx.cs b/OI/CatDocumentoSubCategoria.aspx.cs new file mode 100644 index 000000000..709f6e89a --- /dev/null +++ b/OI/CatDocumentoSubCategoria.aspx.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Extensiones; +using System.Data; + +public partial class OI_CatDocumentoSubCategoria : ClsPaginas +{ + private int CveSubCategoria + { + get + { + return ViewState["CveSubCategoria"].ToString().ToEntero(); + } + + set + { + ViewState["CveSubCategoria"] = value; + } + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaDatos(); + CargaCategoria(); + } + } + + private void CargaDatos() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumentoSubCategoria()) + { + GvDatos.DataSource = ObjOI.DtResultados; + GvDatos.DataBind(); + } + ObjOI.Dispose(); + } + + private void CargaCategoria() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumentoCategoria()) + { + DdlCategorias.DataSource = ObjOI.DtResultados.FiltraParametros("Estado = 1"); + DdlCategorias.DataBind(); + } + ObjOI.Dispose(); + } + + protected void BtnAgregarSubCategoria_Click(object sender, EventArgs e) + { + BtnAgregarSubCategoriaDoc.Text = "Agregar"; + TxtSubCategoria.Text = ""; + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void LnkEditar_Click(object sender, EventArgs e) + { + BtnAgregarSubCategoriaDoc.Text = "Actualizar"; + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + CveSubCategoria = GvRow.DataKey("CveSubCategoria").ToEntero(); + TxtSubCategoria.Text = GvRow.DataKey("SubCategoria"); + UpModalTiposD.Update(); + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); + } + + protected void LnkEliminar_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + CveSubCategoria = GvRow.DataKey("CveSubCategoria").ToEntero(); + ClsCompras ObjCompras = new ClsCompras(); + if (ObjCompras.RemoveTipoGasto(CveSubCategoria)) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se eliminó la Categoría de Documento correctamente"); + } + ObjCompras.Dispose(); + } + + protected void BtnAgregarSubCategoriaDoc_Click(object sender, EventArgs e) + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (BtnAgregarSubCategoriaDoc.Text == "Agregar") + { + if (ObjOI.AddDocumentoSubCategoria(TxtSubCategoria.Text, DdlCategorias.SelectedValue.ToEntero())) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se agregó la Categoría de Documento correctamente"); + } + } + else + { + if (ObjOI.UpdateDocumentoSubCategoria(CveSubCategoria, TxtSubCategoria.Text, DdlCategorias.SelectedValue.ToEntero())) + { + CargaDatos(); + UpDatos.Update(); + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); + Alert("Se actualizó la Categoría de Documento correctamente"); + } + } + ObjOI.Dispose(); + } +} \ No newline at end of file diff --git a/OI/Documentos.aspx b/OI/Documentos.aspx new file mode 100644 index 000000000..31ddb86a4 --- /dev/null +++ b/OI/Documentos.aspx @@ -0,0 +1,49 @@ +<%@ Page Title="OI - Documentos" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Documentos.aspx.cs" Inherits="OI_Documentos" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Documentos + + + + +
  • + +
  • + +
    +
    +
    + + + + + + + + + + + + + + <%-- + --%> + + + + + + + + + + diff --git a/OI/Documentos.aspx.cs b/OI/Documentos.aspx.cs new file mode 100644 index 000000000..e087c71c9 --- /dev/null +++ b/OI/Documentos.aspx.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Extensiones; +using System.Data; + +public partial class OI_Documentos : ClsPaginas +{ + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaDatos(); + } + } + + private void CargaDatos() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumento(-1,UsuarioActual.CveEmpresa)) + { + GvDatos.DataSource = ObjOI.DtResultados; + GvDatos.DataBind(); + } + ObjOI.Dispose(); + } +} \ No newline at end of file From aaed1507dffb78e3974da8722f684e469ade8968 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Fri, 17 Jul 2020 15:31:07 -0700 Subject: [PATCH 02/12] - --- App_Code/ClsPaginas.vb | 2 ++ OI/DocumentoDetalle.aspx | 33 +++++++++++++++++++++++++++++++++ OI/DocumentoDetalle.aspx.cs | 16 ++++++++++++++++ OI/Documentos.aspx | 11 ++++++++--- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 OI/DocumentoDetalle.aspx create mode 100644 OI/DocumentoDetalle.aspx.cs diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 5e207a0c5..724b8b4e4 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4554,6 +4554,8 @@ Public Class ClsPaginas PaginaDict.Add("/OI/SubidasADS.aspx".ToUpper(), 476) PaginaDict.Add("/OI/CatDocumentoCategoria.aspx".ToUpper(), 760) PaginaDict.Add("/OI/CatDocumentoSubCategoria.aspx".ToUpper(), 761) + PaginaDict.Add("/OI/Documentos.aspx".ToUpper(), 762) + PaginaDict.Add("/OI/DocumentoDetalle.aspx".ToUpper(), 763) #End Region #Region "Planeacion" 'PLANEACIÓN diff --git a/OI/DocumentoDetalle.aspx b/OI/DocumentoDetalle.aspx new file mode 100644 index 000000000..c68c94b1e --- /dev/null +++ b/OI/DocumentoDetalle.aspx @@ -0,0 +1,33 @@ +<%@ Page Title="OI - Documentos detalle" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="DocumentoDetalle.aspx.cs" Inherits="OI_DocumentoDetalle" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Documentos detalle + + + + + <%--
  • + +
  • +
  • + Imprimir PDF +
  • +
  • + Imprimir Excel +
  • --%> +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs new file mode 100644 index 000000000..bc578cd90 --- /dev/null +++ b/OI/DocumentoDetalle.aspx.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Extensiones; +using System.Data; + +public partial class OI_DocumentoDetalle : ClsPaginas +{ + protected void Page_Load(object sender, EventArgs e) + { + + } +} \ No newline at end of file diff --git a/OI/Documentos.aspx b/OI/Documentos.aspx index 31ddb86a4..724ec70d8 100644 --- a/OI/Documentos.aspx +++ b/OI/Documentos.aspx @@ -16,15 +16,20 @@
  • - +
  • + Imprimir PDF +
  • +
  • + Imprimir Excel +
  • - From 1868bffe8c21ca98ed41a9082471a6e4d2de51fa Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 20 Jul 2020 18:22:26 -0700 Subject: [PATCH 03/12] avance de insert y update --- App_Code/ClsOIEventos.vb | 52 +++++++- OI/DocumentoDetalle.aspx | 93 ++++++++++++- OI/DocumentoDetalle.aspx.cs | 253 +++++++++++++++++++++++++++++++++++- 3 files changed, 391 insertions(+), 7 deletions(-) diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index 8a65a1f30..4e36ab9e0 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -2944,9 +2944,9 @@ Public Class ClsOIEventos End Function Public Function AddDocumento(CveSubCategoria As Integer, Descripcion As String, Observacion As String, Version As String, CveEstatus As Integer, ArchivoFisico As String, - Responsable As String, FechaAprobacion As Date, CveDocumentoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Responsable As String, CveDocumentoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Boolean = False + Dim Retorno As Integer = -1 DataAdapter("PA_OI_DocumentosAdd") @@ -2958,15 +2958,15 @@ Public Class ClsOIEventos .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus .Add("@ArchivoFisico", SqlDbType.NVarChar).Value = ArchivoFisico .Add("@Responsable", SqlDbType.NVarChar).Value = Responsable - .Add("@FechaAprobacion", SqlDbType.Date).Value = FechaAprobacion .Add("@CveDocumentoPadre", SqlDbType.Int).Value = CveDocumentoPadre .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDocumento", SqlDbType.Int).Direction = ParameterDirection.Output End With Try SqlAdapter.Fill(Data) - Retorno = True + Retorno = SqlAdapter.SelectCommand.Parameters("@CveDocumento").Value.ToString().ToEntero() Catch ex As Exception OnError("Ocurrió un error al agregar el Documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try @@ -3027,6 +3027,50 @@ Public Class ClsOIEventos End Function #End Region +#Region "OI_DocumentosAutorizacion" + Public Function AddDocumentoAutorizacion(CveDocumento As Integer, CveUsuario As Integer, Adjunto As String) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("OI_DocumentosAutorizacionesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveDocumento", SqlDbType.Int).Value = CveDocumento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Adjunto", SqlDbType.NVarChar).Value = Adjunto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el usuario para autorizar el documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetDocumentoAutorizacion(CveDocumento As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_DocumentosAutorizacionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveDocumento", SqlDbType.Int).Value = CveDocumento + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el usuario o usuarios para autorizar el documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + #End Region ' IDisposable diff --git a/OI/DocumentoDetalle.aspx b/OI/DocumentoDetalle.aspx index c68c94b1e..f84a72807 100644 --- a/OI/DocumentoDetalle.aspx +++ b/OI/DocumentoDetalle.aspx @@ -26,8 +26,97 @@ - + + +
    +
    + + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +

    +
    + " style="display: inline-block; margin-right: -20px; width: 150px; height: 25px; border-color: #89C4F4; border:1px solid #e5e5e5" /> + " class="btn btn-circle btn-sm label-info"> +
    + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    - \ No newline at end of file + diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs index bc578cd90..315d1512b 100644 --- a/OI/DocumentoDetalle.aspx.cs +++ b/OI/DocumentoDetalle.aspx.cs @@ -6,11 +6,262 @@ using System.Web.UI; using System.Web.UI.WebControls; using Extensiones; using System.Data; +using System.IO; public partial class OI_DocumentoDetalle : ClsPaginas { + private int CveDocumento + { + get + { + return ViewState["CveDocumento"].ToString().ToEntero(); + } + + set + { + ViewState["CveDocumento"] = value; + } + } + + private string ErrorMensaje + { + get + { + return ViewState["ErrorMensaje"].ToString(); + } + + set + { + ViewState["ErrorMensaje"] = value; + } + } + protected void Page_Load(object sender, EventArgs e) { - + if (!IsPostBack) + { + //CargarUsuarios(); + //CargarSubCategoria(); + //CargarResponsable(); + //CargarCveDocumento(); + //if (this.CveDocumento > 0) + //{ + // CargarDocumentoYaExistente(); + // CargarUsuariosAutorizo(); + // ConfiguracionActualizar(); + //} + Cargar(); + } } + #region "CARGAS" + private void CargarCveDocumento() + { + string CveDocumentoAux = Page.Request["CveDocumento"]; + if (CveDocumentoAux != null) + { + this.CveDocumento = CveDocumentoAux.ToEntero(); + } + else + { + this.CveDocumento = -1; + } + } + + private void CargarUsuarios() + { + GvUsuarios.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa); + GvUsuarios.DataBind(); + } + + private void CargarSubCategoria() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumentoSubCategoria()) + { + DdlSubCategoria.DataSource = ObjOI.DtResultados; + DdlSubCategoria.DataBind(); + } + ObjOI.Dispose(); + } + + private void CargarResponsable() + { + TxtResponsable.Text = UsuarioActual.Nombre; + } + + private void CargarDocumentoYaExistente() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumento(this.CveDocumento, UsuarioActual.CveEmpresa)) + { + if (ObjOI.DtResultados.Rows.Count > 0) + { + DataRow Documento = ObjOI.DtResultados.Rows[0]; + + TxtDescripcion.Text = Documento["Descripcion"].ToString(); + DdlSubCategoria.SelectedValue = Documento["CveSubCategoria"].ToString(); + DdlEstatus.SelectedValue = Documento["CveEstatus"].ToString(); + TxtVersion.Text = Documento["Version"].ToString(); + TxtResponsable.Text = Documento["Responsable"].ToString(); + TxtObs.InnerText = Documento["Observacion"].ToString(); + + } + } + ObjOI.Dispose(); + } + + private void CargarUsuariosAutorizo() + { + ClsOIEventos ObjOI = new ClsOIEventos(); + if (ObjOI.GetDocumentoAutorizacion(this.CveDocumento)) + { + DataTable UsuariosAutorizo = ObjOI.DtResultados; + GridViewRowCollection UsuariosRowCollection = GvUsuarios.Rows; + foreach (GridViewRow UsuarioRow in UsuariosRowCollection) + { + int CveUsuarioRow = UsuarioRow.DataKey("CveUsuario").ToEntero(); + UsuarioRow.FCCheckBox("ChkUnir").Checked = UsuariosAutorizo.COUNT("CveUsuario", string.Format("CveUsuario = {0}", CveUsuarioRow)) > 0; + } + } + ObjOI.Dispose(); + } + + private void ConfiguracionActualizar() + { + LkbGuardar.Text = "Actualizar"; + } + + private void Cargar() + { + CargarUsuarios(); + CargarSubCategoria(); + CargarResponsable(); + CargarCveDocumento(); + if (this.CveDocumento > 0) + { + CargarDocumentoYaExistente(); + CargarUsuariosAutorizo(); + ConfiguracionActualizar(); + } + } + #endregion + + #region "GENERAR DOCUMENTO" + private string GuardarArchivo(int CveDocumento) + { + string RutaArchivo = "-1"; + List Filesgral = TxtDocumentoFile.getfiles().Archivos; + + foreach (Archivo fileItem in Filesgral) + { + try + { + string Version = TxtVersion.Text; + string NombreArchivo = fileItem.filenameO; + //Preparamos la ruta donde moveremos el archivo cargado + string NombreArchivoGuardado = string.Format("{0}_{1}_{2}", CveDocumento, Version, NombreArchivo); + string RutaDestino = UsuarioActual.Empresa.Ruta + @"DocumentosRepo\" + NombreArchivoGuardado; + + //Si no existe la carpeta donde se guardan se crea + if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo")) + { + Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo"); + } + //Movemos el archivo de la carpeta temporal hacia la carpeta de la empresa + System.IO.File.Move(fileItem.FileUrl, RutaDestino); + RutaArchivo = RutaDestino; + } + catch (Exception e) + { + Alert(e.Message); + } + } + return RutaArchivo; + } + + protected void LblGuardar_Click(object sender, EventArgs e) + { + ClsOIEventos ObjOI = new ClsOIEventos(); + ObjOI.IniciaTransacSQL(); + bool TieneError = false; + + //Esta variable es requerida más adelante + int CveDocumento = 0; + string RutaArchivo = "-1"; + + CveDocumento = GuardarDocumento(ref ObjOI, ref TieneError);//Se crea el Documento + if (!TieneError) { RutaArchivo = AsignarArchivoAlDocumento(CveDocumento, ref ObjOI, ref TieneError); }//Se guarda el archivo fisico y se asigna al Documento generado + if (!TieneError) { GuardarUsuariosQueAutorizan(CveDocumento, RutaArchivo, ref ObjOI, ref TieneError); }//asignamos a los usuarios que participaran en aprovar este documento + + + //Gestión de errores y resultados + if (!TieneError) + { + ObjOI.Commit(); + Alert("Documento guardado correctamente"); + } + else + { + ObjOI.RollBack(); + Alert(this.ErrorMensaje, ModExtensiones.TipoMensaje.MsgError); + this.CveDocumento = CveDocumento; + Cargar(); + UpCliente.Update(); + } + ObjOI.Dispose(); + } + + private int GuardarDocumento(ref ClsOIEventos ObjOI, ref bool TieneError) + { + int CveDocumentoPadre = this.CveDocumento > 0 ? this.CveDocumento : -1; //Asociamos el nuevo insert con un CveDocumento ya generado en caso de ser una nueva versión del documento + + int CveDocumento = ObjOI.AddDocumento(DdlSubCategoria.SelectedValue.ToEntero(), TxtDescripcion.Text, TxtObs.InnerText, TxtVersion.Text, DdlEstatus.SelectedValue.ToEntero(), + "", TxtResponsable.Text, CveDocumentoPadre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa); + if (!(CveDocumento > 0)) + { + TieneError = true; + this.ErrorMensaje = "Hubo un error al guardr el Documento"; + } + return CveDocumento; + } + + private string AsignarArchivoAlDocumento(int CveDocumento, ref ClsOIEventos ObjOI, ref bool TieneError) + { + string RutaArchivo = GuardarArchivo(CveDocumento); + if (RutaArchivo != "-1") + { + if (!ObjOI.UpdateDocumento(CveDocumento, -1, "-1", "-1", "-1", -1, RutaArchivo, "-1", ModExtensiones.MinFecha, -1, -1, -1)) + { + TieneError = true; + this.ErrorMensaje = "Hubo un error al asignar el archivo"; + } + } + else + { + TieneError = true; + this.ErrorMensaje = "Hubo un error al guardar el archivo"; + } + return RutaArchivo; + } + + private void GuardarUsuariosQueAutorizan(int CveDocumento, string RutaArchivo, ref ClsOIEventos ObjOI, ref bool TieneError) + { + GridViewRowCollection GridUsuarios = GvUsuarios.Rows; + foreach (GridViewRow GvRow in GridUsuarios) + { + if (GvRow.FCCheckBox("ChkUnir").Checked && !TieneError) + { + int CveUsuario = GvRow.DataKey("CveUsuario").ToEntero(); + if (!ObjOI.AddDocumentoAutorizacion(CveDocumento, CveUsuario, RutaArchivo)) + { + TieneError = true; + this.ErrorMensaje = "Hubo un error al asignar los usuarios a este documento"; + break; + } + } + } + } + #endregion + + } \ No newline at end of file From 1096d1907d9591787055ca95e22e4b5aac62c5ae Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 21 Jul 2020 09:03:00 -0700 Subject: [PATCH 04/12] avance aun falta probar cosas --- OI/DocumentoDetalle.aspx | 11 ++++- OI/DocumentoDetalle.aspx.cs | 99 ++++++++++++++++++++++++++----------- 2 files changed, 78 insertions(+), 32 deletions(-) diff --git a/OI/DocumentoDetalle.aspx b/OI/DocumentoDetalle.aspx index f84a72807..fd387dcc1 100644 --- a/OI/DocumentoDetalle.aspx +++ b/OI/DocumentoDetalle.aspx @@ -72,8 +72,15 @@
    - - +
    + + + +
    +
    + + +
    diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs index 315d1512b..d8a3f2ac5 100644 --- a/OI/DocumentoDetalle.aspx.cs +++ b/OI/DocumentoDetalle.aspx.cs @@ -36,20 +36,23 @@ public partial class OI_DocumentoDetalle : ClsPaginas } } + private string ArchivoAdjuntoNombre + { + get + { + return ViewState["ArchivoAdjuntoNombre"].ToString(); + } + + set + { + ViewState["ArchivoAdjuntoNombre"] = value; + } + } + protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { - //CargarUsuarios(); - //CargarSubCategoria(); - //CargarResponsable(); - //CargarCveDocumento(); - //if (this.CveDocumento > 0) - //{ - // CargarDocumentoYaExistente(); - // CargarUsuariosAutorizo(); - // ConfiguracionActualizar(); - //} Cargar(); } } @@ -105,6 +108,10 @@ public partial class OI_DocumentoDetalle : ClsPaginas TxtResponsable.Text = Documento["Responsable"].ToString(); TxtObs.InnerText = Documento["Observacion"].ToString(); + ArchivoAdjuntoNombre = Documento["ArchivoFisico"].ToString(); + string[] ArchivoAux = Documento["ArchivoFisico"].ToString().Split('_'); + string ArchivoAdjunto = ArchivoAux[2]; + LkbDescargarArchivo.Text = string.Format("Descargar Archivo: {0}",ArchivoAdjunto); } } ObjOI.Dispose(); @@ -151,29 +158,31 @@ public partial class OI_DocumentoDetalle : ClsPaginas { string RutaArchivo = "-1"; List Filesgral = TxtDocumentoFile.getfiles().Archivos; - - foreach (Archivo fileItem in Filesgral) + if (TxtDocumentoFile.Text != "") { - try + foreach (Archivo fileItem in Filesgral) { - string Version = TxtVersion.Text; - string NombreArchivo = fileItem.filenameO; - //Preparamos la ruta donde moveremos el archivo cargado - string NombreArchivoGuardado = string.Format("{0}_{1}_{2}", CveDocumento, Version, NombreArchivo); - string RutaDestino = UsuarioActual.Empresa.Ruta + @"DocumentosRepo\" + NombreArchivoGuardado; - - //Si no existe la carpeta donde se guardan se crea - if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo")) + try { - Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo"); + string Version = TxtVersion.Text; + string NombreArchivo = fileItem.filenameO; + //Preparamos la ruta donde moveremos el archivo cargado + string NombreArchivoGuardado = string.Format("{0}_{1}_{2}", CveDocumento, Version, NombreArchivo); + string RutaDestino = UsuarioActual.Empresa.Ruta + @"DocumentosRepo\" + NombreArchivoGuardado; + + //Si no existe la carpeta donde se guardan se crea + if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo")) + { + Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo"); + } + //Movemos el archivo de la carpeta temporal hacia la carpeta de la empresa + System.IO.File.Move(fileItem.FileUrl, RutaDestino); + RutaArchivo = NombreArchivoGuardado; + } + catch (Exception e) + { + Alert(e.Message); } - //Movemos el archivo de la carpeta temporal hacia la carpeta de la empresa - System.IO.File.Move(fileItem.FileUrl, RutaDestino); - RutaArchivo = RutaDestino; - } - catch (Exception e) - { - Alert(e.Message); } } return RutaArchivo; @@ -220,7 +229,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas if (!(CveDocumento > 0)) { TieneError = true; - this.ErrorMensaje = "Hubo un error al guardr el Documento"; + this.ErrorMensaje = "Hubo un error al guardar el Documento"; } return CveDocumento; } @@ -263,5 +272,35 @@ public partial class OI_DocumentoDetalle : ClsPaginas } #endregion + #region "DESCARGAR ARCHIVO" + protected void LkbSubirNuevoArchivo_Click(object sender,EventArgs e) + { + DivDescargarArchivo.Visible = false; + DivSubirArchivo.Visible = true; + UpDerecha.Update(); + } + + protected void LkbDescargarNuevoArchivo_Click(object sender,EventArgs e) + { + DivDescargarArchivo.Visible = true; + DivSubirArchivo.Visible = false; + UpDerecha.Update(); + } + + protected void LkbDescargarArchivo_Click(object sender,EventArgs e) + { + string Ruta = string.Format("{0}Empresas/{1}/Temp/RH/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoAdjuntoNombre); + byte[] archivoBytes = File.ReadAllBytes(Ruta); + + HttpContext.Current.Response.Clear(); + HttpContext.Current.Response.ClearContent(); + HttpContext.Current.Response.ContentType = "application/octet-stream"; + HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", ArchivoAdjuntoNombre)); + HttpContext.Current.Response.AddHeader("Content-Length", archivoBytes.Length.ToString()); + HttpContext.Current.Response.OutputStream.Write(archivoBytes, 0, archivoBytes.Length); + HttpContext.Current.Response.End(); + } + #endregion + } \ No newline at end of file From 40de8a7e6c02143a31e65b3a2965223adeee7be4 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 21 Jul 2020 15:47:55 -0700 Subject: [PATCH 05/12] update listo --- OI/DocumentoDetalle.aspx | 10 ++-- OI/DocumentoDetalle.aspx.cs | 93 +++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 54 deletions(-) diff --git a/OI/DocumentoDetalle.aspx b/OI/DocumentoDetalle.aspx index fd387dcc1..ad0062d3e 100644 --- a/OI/DocumentoDetalle.aspx +++ b/OI/DocumentoDetalle.aspx @@ -72,17 +72,19 @@
    -
    +
    -
    -
    +
    + -
    + + + diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs index d8a3f2ac5..23c3b49e7 100644 --- a/OI/DocumentoDetalle.aspx.cs +++ b/OI/DocumentoDetalle.aspx.cs @@ -110,8 +110,9 @@ public partial class OI_DocumentoDetalle : ClsPaginas ArchivoAdjuntoNombre = Documento["ArchivoFisico"].ToString(); string[] ArchivoAux = Documento["ArchivoFisico"].ToString().Split('_'); - string ArchivoAdjunto = ArchivoAux[2]; - LkbDescargarArchivo.Text = string.Format("Descargar Archivo: {0}",ArchivoAdjunto); + string ArchivoAdjunto = ArchivoAux[1]; + LkbDescargarArchivo.Text = ArchivoAdjunto; + DivDescargarArchivo.Visible = true; } } ObjOI.Dispose(); @@ -154,39 +155,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas #endregion #region "GENERAR DOCUMENTO" - private string GuardarArchivo(int CveDocumento) - { - string RutaArchivo = "-1"; - List Filesgral = TxtDocumentoFile.getfiles().Archivos; - if (TxtDocumentoFile.Text != "") - { - foreach (Archivo fileItem in Filesgral) - { - try - { - string Version = TxtVersion.Text; - string NombreArchivo = fileItem.filenameO; - //Preparamos la ruta donde moveremos el archivo cargado - string NombreArchivoGuardado = string.Format("{0}_{1}_{2}", CveDocumento, Version, NombreArchivo); - string RutaDestino = UsuarioActual.Empresa.Ruta + @"DocumentosRepo\" + NombreArchivoGuardado; - - //Si no existe la carpeta donde se guardan se crea - if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo")) - { - Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo"); - } - //Movemos el archivo de la carpeta temporal hacia la carpeta de la empresa - System.IO.File.Move(fileItem.FileUrl, RutaDestino); - RutaArchivo = NombreArchivoGuardado; - } - catch (Exception e) - { - Alert(e.Message); - } - } - } - return RutaArchivo; - } + protected void LblGuardar_Click(object sender, EventArgs e) { @@ -208,13 +177,13 @@ public partial class OI_DocumentoDetalle : ClsPaginas { ObjOI.Commit(); Alert("Documento guardado correctamente"); + //this.CveDocumento = CveDocumento; + Response.Redirect(string.Format("/OI/DocumentoDetalle.aspx?CveDocumento={0}",CveDocumento)); } else { ObjOI.RollBack(); Alert(this.ErrorMensaje, ModExtensiones.TipoMensaje.MsgError); - this.CveDocumento = CveDocumento; - Cargar(); UpCliente.Update(); } ObjOI.Dispose(); @@ -236,6 +205,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas private string AsignarArchivoAlDocumento(int CveDocumento, ref ClsOIEventos ObjOI, ref bool TieneError) { + string RutaArchivo = GuardarArchivo(CveDocumento); if (RutaArchivo != "-1") { @@ -245,7 +215,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas this.ErrorMensaje = "Hubo un error al asignar el archivo"; } } - else + else if(RutaArchivo == "Error") { TieneError = true; this.ErrorMensaje = "Hubo un error al guardar el archivo"; @@ -272,24 +242,47 @@ public partial class OI_DocumentoDetalle : ClsPaginas } #endregion - #region "DESCARGAR ARCHIVO" - protected void LkbSubirNuevoArchivo_Click(object sender,EventArgs e) + #region "ARCHIVO ADJUNTO" + private string GuardarArchivo(int CveDocumento) { - DivDescargarArchivo.Visible = false; - DivSubirArchivo.Visible = true; - UpDerecha.Update(); + string RutaArchivo = "-1"; + List Filesgral = TxtDocumentoFile.getfiles().Archivos; + if (TxtDocumentoFile.Text != "[]") + { + foreach (Archivo fileItem in Filesgral) + { + try + { + string Version = TxtVersion.Text; + string NombreArchivo = fileItem.filenameO; + //Preparamos la ruta donde moveremos el archivo cargado + string NombreArchivoGuardado = string.Format("{0}_{1}", CveDocumento, NombreArchivo); + string RutaDestino = UsuarioActual.Empresa.Ruta + @"DocumentosRepo\" + NombreArchivoGuardado; + + //Si no existe la carpeta donde se guardan se crea + if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo")) + { + Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo"); + } + //Movemos el archivo de la carpeta temporal hacia la carpeta de la empresa + System.IO.File.Move(fileItem.FileUrl, RutaDestino); + RutaArchivo = NombreArchivoGuardado; + } + catch (Exception e) + { + Alert(e.Message); + RutaArchivo = "Error"; + } + } + } + return RutaArchivo; } - protected void LkbDescargarNuevoArchivo_Click(object sender,EventArgs e) - { - DivDescargarArchivo.Visible = true; - DivSubirArchivo.Visible = false; - UpDerecha.Update(); - } + protected void LkbDescargarArchivo_Click(object sender,EventArgs e) { - string Ruta = string.Format("{0}Empresas/{1}/Temp/RH/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoAdjuntoNombre); + string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoAdjuntoNombre); byte[] archivoBytes = File.ReadAllBytes(Ruta); HttpContext.Current.Response.Clear(); From d8dc66900b852286b9e69cc95d34867f1d5fdbba Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 21 Jul 2020 19:27:50 -0700 Subject: [PATCH 06/12] integrando el endpoint para descargar las firmas --- TareasProgramadas/Tareas72.ashx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/TareasProgramadas/Tareas72.ashx b/TareasProgramadas/Tareas72.ashx index 1edc5d88a..f3d4ba7aa 100644 --- a/TareasProgramadas/Tareas72.ashx +++ b/TareasProgramadas/Tareas72.ashx @@ -66,13 +66,31 @@ public class Tareas72 : IHttpHandler string JsonStringFormat = JsonString.Replace("Resultado(", "{\"Resultado\":").Replace(")", "}"); DataSet dataSet = JsonConvert.DeserializeObject(JsonStringFormat); DataTable dataTable = dataSet.Tables["Resultado"]; - if (dataTable.Rows[0]["eventoId"].ToString() == "Hdc") + string eventoId = dataTable.Rows[0]["eventoId"].ToString(); + if (eventoId == "Hdc" | eventoId == "HDC") { int EstatusEntregado = 3; //MANDAMOS A ACTUALIZAR CON ESTATUS DE ENTREGADO if (ObjGenerales.UpdatePaqueteriasGuias(CvePaqueteriaGuia, -1, -1, -1, EstatusEntregado, "-1", "", "", -1, -1, "-1", "-1", "")) { + #region 'DESCARGAR IMAGEN' + string rastreo = Guia["Rastreo"].ToString(); + string uriConsultaFirma = string.Format("https://cc.paquetexpress.com.mx/ptxws/rest/api/v1/entrega/firma/{0}/@1@2@3@4@5", rastreo); + + HttpClient ClientFirma = new HttpClient(); + HttpResponseMessage ResponseMessageFirma = ClientFirma.GetAsync(uriConsultaFirma).Result; + string JsonStringFirma = ResponseMessageFirma.Content.ReadAsStringAsync().Result; + string JsonStringFormatFirma = JsonStringFirma.Replace("callback(", "{\"callback\":").Replace(")", "}"); + DataSet dataSetFirma = JsonConvert.DeserializeObject(JsonStringFormatFirma); + DataTable dataTableFirma = dataSetFirma.Tables["callback"]; + + string ImagenBase64 = dataTableFirma.Rows[0]["imagen"].ToString(); + byte[] ImagenByteArray = Convert.FromBase64String(ImagenBase64); + string rutaDestino = ModExtensiones.DirectorioEmpresas + "72\\" + "Documentos\\Guias\\" + CvePaqueteriaGuia + ".jpg"; + File.WriteAllBytes(rutaDestino,ImagenByteArray); + #endregion + #region 'MANDAR CORREOS' int CveCliente = Guia["CveCliente"].ToString().ToEntero(); int CveVenta = Guia["CveAgrupador"].ToString().ToEntero(); @@ -123,7 +141,7 @@ public class Tareas72 : IHttpHandler ObjVentas.Dispose(); ObjVendedores.Dispose(); ObjEmpresa.Dispose(); - return false; + return retorno; } public bool IsReusable From d9f3fb126104f5c2f80aa8df72ae08db70a9dedc Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 21 Jul 2020 19:44:12 -0700 Subject: [PATCH 07/12] =?UTF-8?q?correcci=C3=B3n=20de=20ortograf=C3=ADa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RH/Personal.aspx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RH/Personal.aspx b/RH/Personal.aspx index b9c257e6c..fdad5f44e 100644 --- a/RH/Personal.aspx +++ b/RH/Personal.aspx @@ -4614,7 +4614,7 @@ - +
    @@ -3538,7 +3538,7 @@ diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 390c3f3f6..f7f4d4d35 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -4671,12 +4671,17 @@ Partial Class RH_Personal Dim Fecha As String = DateTime.Now.ToString("dd/MM/yyyy") Dim Solicitante As String = UsuarioActual.Nombre Dim anio As Integer = GvRow.DataKey("FechaInicio").ToDate().Year + Dim FechaPeriodo As String = GvRow.DataKey("Periodo") + + + + If Periodoingreso > PeriodoInicio Then anio = anio - 1 - End If - - - Dim FechaPeriodo As String = String.Format("{0:dd/MM}/{1}", fechaIngreso, anio) + End If + + + If File.Exists(RutaFormato) Then Dim objGemDocument As New clsGemBoxDocument(RutaFormato) @@ -6123,10 +6128,36 @@ Partial Class RH_Personal End If If TxtFIPrimaVacacional.Text = "0" Or TxtFIPrimaVacacional.Text = "" Or TxtFIAguinaldo.Text = "-1" Then TxtFIPrimaVacacional.Text = "25" - End If + End If + + + TxtFISalariodiarioImss.Text = TxtSalarioCotizado.Text TxtFactordeIntegracion.Text = "" - TxtFISalarioDiarioIntegrado.Text = "" + TxtFISalarioDiarioIntegrado.Text = "" + + + + Dim objRH As New ClsRH + + If objRH.VacacionesResumenGet(CvePersonal, UsuarioActual.Empresa.CveEmpresa) Then + If objRH.DtResultados.Rows.Count > 0 Then + + If objRH.DtResultados.Rows.Count > 0 Then + TxtFIDiasVacaciones.Text = objRH.DtResultados(0)("Dias").ToString + Else + TxtFIDiasVacaciones.Text = "6" + End If + Else + + End If + End If + + objRH.Dispose() + + + + RegistraScript("$('#DmodalFactordeIntegraccion').modal()") UpFactordeintegracion.Update() End Sub diff --git a/RH/RepPersonalInconsistencias.aspx.vb b/RH/RepPersonalInconsistencias.aspx.vb index bf9d0b4e9..763ea5656 100644 --- a/RH/RepPersonalInconsistencias.aspx.vb +++ b/RH/RepPersonalInconsistencias.aspx.vb @@ -181,7 +181,7 @@ Partial Class RH_RepPersonalInconsistencias Dim ObjAF As New ClsAF() If ObjAF.GetLicenciasVencidas(-1, -1, UsuarioActual.CveEmpresa, Estatus:=1) Then - GvLicencias.DataSource = ObjAF.DtResultados + GvLicencias.DataSource = ObjAF.DtResultados.FiltraParametros("CveEstatusPersonal = 1") Else GvLicencias.DataSource = Nothing diff --git a/vwd.webinfo b/vwd.webinfo index 6a84ef014..4edae1c8c 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -80,6 +80,10 @@ + + + + From 4c74ec5d46f99c2b7ae873a3e1b05af6d3f1ece4 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 22 Jul 2020 19:47:27 -0700 Subject: [PATCH 11/12] =?UTF-8?q?notificac=C3=B3n=20por=20correo=20agregad?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsOIEventos.vb | 20 +++++++++ OI/DocumentoDetalle.aspx | 2 +- OI/DocumentoDetalle.aspx.cs | 84 ++++++++++++++++++++++++++++++++----- OI/Documentos.aspx | 19 ++++----- OI/Documentos.aspx.cs | 2 +- 5 files changed, 103 insertions(+), 24 deletions(-) diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index 4e36ab9e0..6abe367d1 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -2922,6 +2922,26 @@ Public Class ClsOIEventos #End Region #Region "Documentos" + Public Function ListadoDocumentos(CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_OI_ListarDocumentos") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el listado de documento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetDocumento(CveDocumento As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/OI/DocumentoDetalle.aspx b/OI/DocumentoDetalle.aspx index ad0062d3e..d5af82e6c 100644 --- a/OI/DocumentoDetalle.aspx +++ b/OI/DocumentoDetalle.aspx @@ -97,7 +97,7 @@ - diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs index 23c3b49e7..6955095d9 100644 --- a/OI/DocumentoDetalle.aspx.cs +++ b/OI/DocumentoDetalle.aspx.cs @@ -7,6 +7,7 @@ using System.Web.UI.WebControls; using Extensiones; using System.Data; using System.IO; +using System.Text; public partial class OI_DocumentoDetalle : ClsPaginas { @@ -155,7 +156,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas #endregion #region "GENERAR DOCUMENTO" - + protected void LblGuardar_Click(object sender, EventArgs e) { @@ -166,19 +167,24 @@ public partial class OI_DocumentoDetalle : ClsPaginas //Esta variable es requerida más adelante int CveDocumento = 0; string RutaArchivo = "-1"; + string CorreosNotificacion = ""; + byte[] ArchivoNotifiacion = null; CveDocumento = GuardarDocumento(ref ObjOI, ref TieneError);//Se crea el Documento if (!TieneError) { RutaArchivo = AsignarArchivoAlDocumento(CveDocumento, ref ObjOI, ref TieneError); }//Se guarda el archivo fisico y se asigna al Documento generado - if (!TieneError) { GuardarUsuariosQueAutorizan(CveDocumento, RutaArchivo, ref ObjOI, ref TieneError); }//asignamos a los usuarios que participaran en aprovar este documento - + if (!TieneError) { CorreosNotificacion = GuardarUsuariosQueAutorizan(CveDocumento, RutaArchivo, ref ObjOI, ref TieneError); }//asignamos a los usuarios que participaran en aprovar este documento + if (!TieneError) + { + ArchivoNotifiacion = GenerarArchivoByte(RutaArchivo); + NotificarPorCorreo(CorreosNotificacion, RutaArchivo, ArchivoNotifiacion); + } //Gestión de errores y resultados if (!TieneError) { ObjOI.Commit(); Alert("Documento guardado correctamente"); - //this.CveDocumento = CveDocumento; - Response.Redirect(string.Format("/OI/DocumentoDetalle.aspx?CveDocumento={0}",CveDocumento)); + Response.Redirect(string.Format("/OI/DocumentoDetalle.aspx?CveDocumento={0}", CveDocumento)); } else { @@ -215,7 +221,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas this.ErrorMensaje = "Hubo un error al asignar el archivo"; } } - else if(RutaArchivo == "Error") + else if (RutaArchivo == "Error") { TieneError = true; this.ErrorMensaje = "Hubo un error al guardar el archivo"; @@ -223,8 +229,9 @@ public partial class OI_DocumentoDetalle : ClsPaginas return RutaArchivo; } - private void GuardarUsuariosQueAutorizan(int CveDocumento, string RutaArchivo, ref ClsOIEventos ObjOI, ref bool TieneError) + private string GuardarUsuariosQueAutorizan(int CveDocumento, string RutaArchivo, ref ClsOIEventos ObjOI, ref bool TieneError) { + StringBuilder CorreosReturn = new StringBuilder(""); GridViewRowCollection GridUsuarios = GvUsuarios.Rows; foreach (GridViewRow GvRow in GridUsuarios) { @@ -237,12 +244,19 @@ public partial class OI_DocumentoDetalle : ClsPaginas this.ErrorMensaje = "Hubo un error al asignar los usuarios a este documento"; break; } + else + { + CorreosReturn.AppendFormat("{0},", GvRow.DataKey("Correo")); + } } } + + return CorreosReturn.ToString(); } #endregion #region "ARCHIVO ADJUNTO" + private string GuardarArchivo(int CveDocumento) { string RutaArchivo = "-1"; @@ -278,9 +292,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas return RutaArchivo; } - - - protected void LkbDescargarArchivo_Click(object sender,EventArgs e) + protected void LkbDescargarArchivo_Click(object sender, EventArgs e) { string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoAdjuntoNombre); byte[] archivoBytes = File.ReadAllBytes(Ruta); @@ -295,5 +307,57 @@ public partial class OI_DocumentoDetalle : ClsPaginas } #endregion + #region "NOTIFICACIONES CORREO" + private void NotificarPorCorreo(string Para, string NombreArchivo, byte[] Adjunto) + { + string Descripcion = TxtDescripcion.Text; + string Asunto = "Se le ha agregado como participante en el desarrollo de un Documento"; + string a = string.Format("{0} -- {1} --- {2}", Descripcion, Para, ""); + a.GuardaLog(); + + ClsSisMail Mail = new ClsSisMail(); + + if (Adjunto != null) + { + List LSRutasMail = new List(); + ClsSisMail.ArchivoMail itemMail = new ClsSisMail.ArchivoMail(); + + { + var withBlock = itemMail; + itemMail.ArchivoBinario = Adjunto; + itemMail.NombreArchivo = NombreArchivo; + } + + LSRutasMail.Add(itemMail); + + + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Descripcion, "", LSRutasMail); + Mail = null/* TODO Change to default(_) if this is not a reference type */; + } + else + { + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Descripcion, ""); + Mail = null/* TODO Change to default(_) if this is not a reference type */; + } + } + + private byte[] GenerarArchivoByte(string NombreArchivo) + { + string ArchivoEnviar = string.Format(@"{0}DocumentosRepo\{1}", UsuarioActual.Empresa.Ruta, NombreArchivo); + if (File.Exists(ArchivoEnviar)) + { + System.IO.FileStream fs = System.IO.File.Open(ArchivoEnviar, System.IO.FileMode.Open, System.IO.FileAccess.Read); + byte[] buff = new byte[fs.Length + 1]; + if (fs.Length > 0) + { + fs.Read(buff, 0, (fs.Length.ToString().ToEntero() - 1)); + fs.Close(); + } + return buff; + } + + return new byte[] { }; + } + #endregion } \ No newline at end of file diff --git a/OI/Documentos.aspx b/OI/Documentos.aspx index 724ec70d8..5a202ebaa 100644 --- a/OI/Documentos.aspx +++ b/OI/Documentos.aspx @@ -32,18 +32,13 @@ EmptyDataText="No se encontraron Documentos Registrados" ToolTip="Listado de Documentos" CssClass="table table-striped table-advance table-hover" Style="margin-top: -10px; text-align: center; width: 100%" GridLines="None"> - - - - - - - - - <%-- - --%> - - + + + + + + <%----%> + diff --git a/OI/Documentos.aspx.cs b/OI/Documentos.aspx.cs index e087c71c9..2f162df73 100644 --- a/OI/Documentos.aspx.cs +++ b/OI/Documentos.aspx.cs @@ -20,7 +20,7 @@ public partial class OI_Documentos : ClsPaginas private void CargaDatos() { ClsOIEventos ObjOI = new ClsOIEventos(); - if (ObjOI.GetDocumento(-1,UsuarioActual.CveEmpresa)) + if (ObjOI.ListadoDocumentos(UsuarioActual.CveEmpresa)) { GvDatos.DataSource = ObjOI.DtResultados; GvDatos.DataBind(); From 782891be9269fe58339e61c3e3f37b19275730de Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 23 Jul 2020 09:12:39 -0700 Subject: [PATCH 12/12] correcciones y agregados --- OI/DocumentoDetalle.aspx.cs | 17 +++++++++++++++-- OI/Documentos.aspx | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/OI/DocumentoDetalle.aspx.cs b/OI/DocumentoDetalle.aspx.cs index 6955095d9..0c35f9eb6 100644 --- a/OI/DocumentoDetalle.aspx.cs +++ b/OI/DocumentoDetalle.aspx.cs @@ -71,6 +71,18 @@ public partial class OI_DocumentoDetalle : ClsPaginas } } + private void CargarMensajeNuevoEditado() + { + string MensajeNuevoEditado = Page.Request["Mensaje"]; + if (MensajeNuevoEditado == "Nuevo") + { + Alert("El Documento ha sido creado correctamente"); + }else if(MensajeNuevoEditado == "Editado") + { + Alert("Los cambios en el Documento han sido guardado correctamente"); + } + } + private void CargarUsuarios() { GvUsuarios.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa); @@ -151,6 +163,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas CargarDocumentoYaExistente(); CargarUsuariosAutorizo(); ConfiguracionActualizar(); + CargarMensajeNuevoEditado(); } } #endregion @@ -183,8 +196,8 @@ public partial class OI_DocumentoDetalle : ClsPaginas if (!TieneError) { ObjOI.Commit(); - Alert("Documento guardado correctamente"); - Response.Redirect(string.Format("/OI/DocumentoDetalle.aspx?CveDocumento={0}", CveDocumento)); + string ParamMensaje = LkbGuardar.Text == "Guardar" ? "Nuevo" : "Editado";//Esto indica la acción de usuario la cual se mostrará como alert al cargar la página + Response.Redirect(string.Format("/OI/DocumentoDetalle.aspx?CveDocumento={0}&Mensaje={1}", CveDocumento, ParamMensaje)); } else { diff --git a/OI/Documentos.aspx b/OI/Documentos.aspx index 5a202ebaa..818d0df70 100644 --- a/OI/Documentos.aspx +++ b/OI/Documentos.aspx @@ -14,7 +14,7 @@
  • - +
  • Imprimir PDF