avance a continuación en documentos
This commit is contained in:
@@ -50,6 +50,31 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
}
|
||||
}
|
||||
|
||||
private int CveUsuarioSeleccionado
|
||||
{
|
||||
get
|
||||
{
|
||||
return ViewState["CveUsuarioSeleccionado"].ToString().ToEntero();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
ViewState["CveUsuarioSeleccionado"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int CveAsignacion
|
||||
{
|
||||
get
|
||||
{
|
||||
return ViewState["CveAsignacion"].ToString().ToEntero();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
ViewState["CveAsignacion"] = value;
|
||||
}
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
@@ -77,7 +102,8 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
if (MensajeNuevoEditado == "Nuevo")
|
||||
{
|
||||
Alert("El Documento ha sido creado correctamente");
|
||||
}else if(MensajeNuevoEditado == "Editado")
|
||||
}
|
||||
else if (MensajeNuevoEditado == "Editado")
|
||||
{
|
||||
Alert("Los cambios en el Documento han sido guardado correctamente");
|
||||
}
|
||||
@@ -85,10 +111,33 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
|
||||
private void CargarUsuarios()
|
||||
{
|
||||
GvUsuarios.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa);
|
||||
if (this.CveDocumento > 0)
|
||||
{
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
if (ObjOI.GetDocumentoAutorizacion(this.CveDocumento))
|
||||
{
|
||||
GvUsuarios.DataSource = ObjOI.DtResultados;
|
||||
}
|
||||
ObjOI.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
GvUsuarios.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa);
|
||||
}
|
||||
GvUsuarios.DataBind();
|
||||
}
|
||||
|
||||
protected void GvUsuarios_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
LinkButton LkbSubirPropuestaAux = e.Row.FCLinkButton("LkbSubirPropuesta");
|
||||
ScriptManager.GetCurrent(this).RegisterPostBackControl(LkbSubirPropuestaAux);
|
||||
LinkButton LkbDescargarPropuestaAux = e.Row.FCLinkButton("LkbDescargarPropuesta");
|
||||
ScriptManager.GetCurrent(this).RegisterPostBackControl(LkbDescargarPropuestaAux);
|
||||
}
|
||||
}
|
||||
|
||||
private void CargarSubCategoria()
|
||||
{
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
@@ -122,13 +171,13 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
TxtObs.InnerText = Documento["Observacion"].ToString();
|
||||
|
||||
ArchivoAdjuntoNombre = Documento["ArchivoFisico"].ToString();
|
||||
if (ArchivoAdjuntoNombre.Contains("_"))
|
||||
{
|
||||
string[] ArchivoAux = Documento["ArchivoFisico"].ToString().Split('_');
|
||||
string ArchivoAdjunto = ArchivoAux[1];
|
||||
LkbDescargarArchivo.Text = ArchivoAdjunto;
|
||||
DivDescargarArchivo.Visible = true;
|
||||
}
|
||||
LkbDescargarArchivo.Text = ArchivoAdjuntoNombre;
|
||||
DivDescargarArchivo.Visible = true;
|
||||
//if (ArchivoAdjuntoNombre.Contains("_"))
|
||||
//{
|
||||
// string[] ArchivoAux = Documento["ArchivoFisico"].ToString().Split('_');
|
||||
// string ArchivoAdjunto = ArchivoAux[1];
|
||||
//}
|
||||
}
|
||||
}
|
||||
ObjOI.Dispose();
|
||||
@@ -152,15 +201,19 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
|
||||
private void ConfiguracionActualizar()
|
||||
{
|
||||
LkbGuardar.Text = "Actualizar";
|
||||
LkbGuardar.Visible = false;
|
||||
LkbActualizar.Visible = true;
|
||||
GvUsuarios.Columns[1].Visible = false;
|
||||
GvUsuarios.Columns[2].Visible = true;
|
||||
GvUsuarios.Columns[3].Visible = true;
|
||||
}
|
||||
|
||||
private void Cargar()
|
||||
{
|
||||
CargarUsuarios();
|
||||
CargarSubCategoria();
|
||||
CargarResponsable();
|
||||
CargarCveDocumento();
|
||||
CargarUsuarios();
|
||||
if (this.CveDocumento > 0)
|
||||
{
|
||||
CargarDocumentoYaExistente();
|
||||
@@ -172,8 +225,6 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
#endregion
|
||||
|
||||
#region "GENERAR DOCUMENTO"
|
||||
|
||||
|
||||
protected void LblGuardar_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
@@ -191,7 +242,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
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);
|
||||
ArchivoNotifiacion = GenerarArchivoByte(CveDocumento, RutaArchivo);
|
||||
NotificarPorCorreo(CorreosNotificacion, RutaArchivo, ArchivoNotifiacion);
|
||||
}
|
||||
|
||||
@@ -254,7 +305,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
if (GvRow.FCCheckBox("ChkUnir").Checked && !TieneError)
|
||||
{
|
||||
int CveUsuario = GvRow.DataKey("CveUsuario").ToEntero();
|
||||
if (!ObjOI.AddDocumentoAutorizacion(CveDocumento, CveUsuario, RutaArchivo))
|
||||
if (!ObjOI.AddDocumentoAutorizacion(CveDocumento, CveUsuario, ""))
|
||||
{
|
||||
TieneError = true;
|
||||
this.ErrorMensaje = "Hubo un error al asignar los usuarios a este documento";
|
||||
@@ -271,12 +322,57 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region "ACTUALIZAR DOCUMENTO"
|
||||
protected void LbkActualizar_Click(object sender, EventArgs e)
|
||||
{
|
||||
string Archivo = ActualizarArchivoEnDirectorio();
|
||||
ActualizarDocumentoYaExistente(Archivo);
|
||||
Cargar();
|
||||
UpCliente.Update();
|
||||
Alert("Documento actualizado");
|
||||
}
|
||||
|
||||
private string ActualizarArchivoEnDirectorio()
|
||||
{
|
||||
string ArchivoFisicoActualizado = ArchivoAdjuntoNombre;
|
||||
if (TxtDocumentoFile.Text != "[]")
|
||||
{
|
||||
string RutaArchivo = string.Format(@"{0}DocumentosRepo\{1}\{2}", UsuarioActual.Empresa.Ruta, this.CveDocumento, ArchivoAdjuntoNombre);
|
||||
if (File.Exists(RutaArchivo))
|
||||
{
|
||||
File.Delete(RutaArchivo);
|
||||
}
|
||||
|
||||
ArchivoFisicoActualizado = GuardarArchivo(this.CveDocumento);
|
||||
}
|
||||
return ArchivoFisicoActualizado;
|
||||
}
|
||||
|
||||
private void ActualizarDocumentoYaExistente(string ArchivoFisico)
|
||||
{
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
if (!ObjOI.UpdateDocumento(this.CveDocumento, DdlSubCategoria.SelectedValue.ToEntero(), TxtDescripcion.Text, TxtObs.InnerText, TxtVersion.Text, DdlEstatus.SelectedValue.ToEntero(),
|
||||
ArchivoFisico, UsuarioActual.Nombre, ModExtensiones.MinFecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
Alert("Error al actualizar", ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
ObjOI.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region "ARCHIVO ADJUNTO"
|
||||
|
||||
private string GuardarArchivo(int CveDocumento)
|
||||
{
|
||||
string RutaArchivo = "-1";
|
||||
List<Archivo> Filesgral = TxtDocumentoFile.getfiles().Archivos;
|
||||
|
||||
//Si no existe la carpeta donde se guardan se crea
|
||||
if (!Directory.Exists(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo\" + CveDocumento))
|
||||
{
|
||||
Directory.CreateDirectory(UsuarioActual.Empresa.Ruta + @"\DocumentosRepo\" + CveDocumento);
|
||||
}
|
||||
|
||||
if (TxtDocumentoFile.Text != "[]")
|
||||
{
|
||||
foreach (Archivo fileItem in Filesgral)
|
||||
@@ -286,17 +382,12 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
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;
|
||||
//string NombreArchivoGuardado = NombreArchivo;
|
||||
string RutaDestino = string.Format(@"{0}DocumentosRepo\{1}\{2}", UsuarioActual.Empresa.Ruta, CveDocumento, NombreArchivo);
|
||||
|
||||
//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;
|
||||
RutaArchivo = NombreArchivo;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -310,7 +401,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
|
||||
protected void LkbDescargarArchivo_Click(object sender, EventArgs e)
|
||||
{
|
||||
string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, ArchivoAdjuntoNombre);
|
||||
string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}/{3}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, this.CveDocumento, ArchivoAdjuntoNombre);
|
||||
byte[] archivoBytes = File.ReadAllBytes(Ruta);
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
@@ -357,9 +448,9 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] GenerarArchivoByte(string NombreArchivo)
|
||||
private byte[] GenerarArchivoByte(int CveDocumento, string NombreArchivo)
|
||||
{
|
||||
string ArchivoEnviar = string.Format(@"{0}DocumentosRepo\{1}", UsuarioActual.Empresa.Ruta, NombreArchivo);
|
||||
string ArchivoEnviar = string.Format(@"{0}DocumentosRepo\{1}\{2}", UsuarioActual.Empresa.Ruta, CveDocumento, NombreArchivo);
|
||||
if (File.Exists(ArchivoEnviar))
|
||||
{
|
||||
System.IO.FileStream fs = System.IO.File.Open(ArchivoEnviar, System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
||||
@@ -376,4 +467,87 @@ public partial class OI_DocumentoDetalle : ClsPaginas
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region "PROPUESTAS DE USUARIOS"
|
||||
private DataRow GetUsuarioParticipante(int CveUsuario)
|
||||
{
|
||||
DataRow UsuarioRetorno = null;
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
if (ObjOI.GetDocumentoAutorizacion(this.CveDocumento))
|
||||
{
|
||||
UsuarioRetorno = ObjOI.DtResultados.FiltroPrimero(string.Format("CveUsuario = {0}",CveUsuario));
|
||||
}
|
||||
ObjOI.Dispose();
|
||||
return UsuarioRetorno;
|
||||
}
|
||||
|
||||
protected void LkbSubirPropuesta_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
int CveUsuarioSeleccionado = GvRow.DataKey("CveUsuario").ToEntero();
|
||||
DataRow UsuarioSeleccionado = GetUsuarioParticipante(CveUsuarioSeleccionado);
|
||||
this.CveUsuarioSeleccionado = CveUsuarioSeleccionado;
|
||||
this.CveAsignacion = UsuarioSeleccionado["CveAutorizacion"].ToString().ToEntero();
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarPropuesta"));
|
||||
}
|
||||
|
||||
protected void LkbDescargarPropuesta_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
int CveUsuario = GvRow.DataKey("CveUsuario").ToEntero();
|
||||
DataRow UsuarioSeleccionado = GetUsuarioParticipante(CveUsuario);
|
||||
string Propuesta = UsuarioSeleccionado["Adjunto"] == null?"": UsuarioSeleccionado["Adjunto"].ToString();
|
||||
string Ruta = string.Format("{0}Empresas/{1}/DocumentosRepo/{2}/{3}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, this.CveDocumento, Propuesta);
|
||||
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}", Propuesta));
|
||||
HttpContext.Current.Response.AddHeader("Content-Length", archivoBytes.Length.ToString());
|
||||
HttpContext.Current.Response.OutputStream.Write(archivoBytes, 0, archivoBytes.Length);
|
||||
HttpContext.Current.Response.End();
|
||||
}
|
||||
|
||||
protected void BtnAgregarPropuesta_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
string Archivo = SubirPropuestaEnDirectorio(this.CveUsuarioSeleccionado);
|
||||
ActualizarUsuario(this.CveAsignacion, Archivo);
|
||||
}
|
||||
|
||||
private string SubirPropuestaEnDirectorio(int CveUsuario)
|
||||
{
|
||||
List<Archivo> Filesgral = TxtArchivoPropuesta.getfiles().Archivos;
|
||||
string fileNameReturn = "-1";
|
||||
if (TxtArchivoPropuesta.Text != "[]")
|
||||
{
|
||||
foreach (Archivo fileItem in Filesgral)
|
||||
{
|
||||
try
|
||||
{
|
||||
string NombreArchivo = fileItem.filenameO;
|
||||
fileNameReturn = string.Format("{0}_{1}",CveUsuario,NombreArchivo);
|
||||
string RutaDestino = string.Format(@"{0}DocumentosRepo\{1}\{2}_{3}", UsuarioActual.Empresa.Ruta, this.CveDocumento, CveUsuario, NombreArchivo);
|
||||
System.IO.File.Move(fileItem.FileUrl, RutaDestino);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Alert(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileNameReturn;
|
||||
}
|
||||
|
||||
private void ActualizarUsuario(int CveAutorizacion, string Archivo)
|
||||
{
|
||||
ClsOIEventos ObjOI = new ClsOIEventos();
|
||||
if (!ObjOI.UpdateDocumentoAutorizacion(CveAutorizacion,this.CveDocumento,TxtComentarios.InnerText,Archivo,ModExtensiones.MinFecha))
|
||||
{
|
||||
Alert("Error al actualizar el archivo subido propuesto por el usuario");
|
||||
}
|
||||
ObjOI.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user