This commit is contained in:
Antonio Gonzalez
2020-08-05 11:51:53 -07:00
parent d350f5fe63
commit 4e82e6a974
4 changed files with 279 additions and 134 deletions

View File

@@ -11,6 +11,19 @@ using System.Text;
public partial class OI_DocumentoDetalle : ClsPaginas
{
private int CveUsuarioResponsable
{
get
{
return ViewState["CveUsuarioResponsable"].ToString().ToEntero();
}
set
{
ViewState["CveUsuarioResponsable"] = value;
}
}
private int CveDocumento
{
get
@@ -111,22 +124,40 @@ public partial class OI_DocumentoDetalle : ClsPaginas
private void CargarUsuarios()
{
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.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa);
GvUsuarios.DataBind();
}
private void CargarUsuariosParticipantes()
{
DataTable UsuariosAux = null;
ClsOIEventos ObjOI = new ClsOIEventos();
if (ObjOI.GetDocumentoAutorizacion(this.CveDocumento))
{
GvUsuarios.DataSource = ObjOI.DtResultados;
UsuariosAux = ObjOI.DtResultados;
}
ObjOI.Dispose();
GvUsuarios.DataBind();
IndicarQuienesYaAutorizaron(UsuariosAux);
}
private void IndicarQuienesYaAutorizaron(DataTable Usuarios)
{
if (Usuarios != null)
{
GridViewRowCollection UsuariosEnGrid = GvUsuarios.Rows;
foreach (GridViewRow Usuario in UsuariosEnGrid)
{
int CveUsuario = Usuario.DataKey("CveUsuario").ToEntero();
string FechaAprobacion = Usuarios.FiltroPrimeroValor("FechaAprobacion", string.Format("CveUsuario = {0}", CveUsuario));
Usuario.FCCheckBox("ChkAprobar").Checked = FechaAprobacion != "" || (UsuarioActual.CveUsuario == CveUsuarioResponsable && CveUsuario == UsuarioActual.CveUsuario);
}
}
}
protected void GvUsuarios_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
@@ -163,6 +194,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
{
DataRow Documento = ObjOI.DtResultados.Rows[0];
CveUsuarioResponsable = Documento["CveUsuario"].ToString().ToEntero();
TxtDescripcion.Text = Documento["Descripcion"].ToString();
DdlSubCategoria.SelectedValue = Documento["CveSubCategoria"].ToString();
DdlEstatus.SelectedValue = Documento["CveEstatus"].ToString();
@@ -173,11 +205,6 @@ public partial class OI_DocumentoDetalle : ClsPaginas
ArchivoAdjuntoNombre = Documento["ArchivoFisico"].ToString();
LkbDescargarArchivo.Text = ArchivoAdjuntoNombre;
DivDescargarArchivo.Visible = true;
//if (ArchivoAdjuntoNombre.Contains("_"))
//{
// string[] ArchivoAux = Documento["ArchivoFisico"].ToString().Split('_');
// string ArchivoAdjunto = ArchivoAux[1];
//}
}
}
ObjOI.Dispose();
@@ -208,6 +235,36 @@ public partial class OI_DocumentoDetalle : ClsPaginas
GvUsuarios.Columns[3].Visible = true;
}
private void ConfigurarGridUsuariosParticipantes()
{
int CveUsuarioActual = UsuarioActual.CveUsuario;
GridViewRowCollection Usuarios = GvUsuarios.Rows;
foreach (GridViewRow Usuario in Usuarios)
{
int CveUsuarioIteracion = Usuario.DataKey("CveUsuario").ToEntero();
if (CveUsuarioIteracion != CveUsuarioActual)
{
Usuario.FCCheckBox("ChkAprobar").Enabled = false;
Usuario.FCLinkButton("LkbSubirPropuesta").Visible = false;
}
}
}
private void ConfigurarCamposDetalleSegunUsuario()
{
if (UsuarioActual.CveUsuario != CveUsuarioResponsable)
{
TxtDescripcion.Enabled = false;
DdlSubCategoria.Enabled = false;
DdlEstatus.Enabled = false;
TxtVersion.Enabled = false;
TxtResponsable.Enabled = false;
TxtObs.Disabled = true;
DivFileDropZone.Visible = false;
LkbActualizar.Visible = false;
}
}
private void Cargar()
{
CargarSubCategoria();
@@ -217,8 +274,11 @@ public partial class OI_DocumentoDetalle : ClsPaginas
if (this.CveDocumento > 0)
{
CargarDocumentoYaExistente();
CargarUsuariosParticipantes();
CargarUsuariosAutorizo();
ConfiguracionActualizar();
ConfigurarGridUsuariosParticipantes();
ConfigurarCamposDetalleSegunUsuario();
CargarMensajeNuevoEditado();
}
}
@@ -474,7 +534,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
ClsOIEventos ObjOI = new ClsOIEventos();
if (ObjOI.GetDocumentoAutorizacion(this.CveDocumento))
{
UsuarioRetorno = ObjOI.DtResultados.FiltroPrimero(string.Format("CveUsuario = {0}",CveUsuario));
UsuarioRetorno = ObjOI.DtResultados.FiltroPrimero(string.Format("CveUsuario = {0}", CveUsuario));
}
ObjOI.Dispose();
return UsuarioRetorno;
@@ -495,17 +555,24 @@ public partial class OI_DocumentoDetalle : ClsPaginas
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 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);
if (File.Exists(Ruta))
{
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();
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();
}
else
{
Alert("El Usuario no ha realizado una propuesta", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
}
protected void BtnAgregarPropuesta_Click(object sender, EventArgs e)
@@ -526,7 +593,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
try
{
string NombreArchivo = fileItem.filenameO;
fileNameReturn = string.Format("{0}_{1}",CveUsuario,NombreArchivo);
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);
}
@@ -542,7 +609,7 @@ public partial class OI_DocumentoDetalle : ClsPaginas
private void ActualizarUsuario(int CveAutorizacion, string Archivo)
{
ClsOIEventos ObjOI = new ClsOIEventos();
if (!ObjOI.UpdateDocumentoAutorizacion(CveAutorizacion,this.CveDocumento,TxtComentarios.InnerText,Archivo,ModExtensiones.MinFecha))
if (!ObjOI.UpdateDocumentoAutorizacion(CveAutorizacion, this.CveDocumento, TxtComentarios.InnerText, Archivo, ModExtensiones.MinFecha))
{
Alert("Error al actualizar el archivo subido propuesto por el usuario");
}
@@ -550,4 +617,67 @@ public partial class OI_DocumentoDetalle : ClsPaginas
}
#endregion
#region "APROBACIÓN DEL DOCUMENTO"
protected void ChkAprobar_Checked(object sender, EventArgs e)
{
CheckBox SelectedCheckBox = (CheckBox)sender;
GridViewRow UsuarioAux = (GridViewRow)((Control)sender).Parent.Parent;
int CveUsuario = UsuarioAux.DataKey("CveUsuario").ToEntero();
DataRow Usuario = GetUsuarioParticipante(CveUsuario);
AprobacionDeUsuario(Usuario, SelectedCheckBox.Checked);
}
private void AprobacionDeUsuario(DataRow Usuario, bool Autorizar)
{
int CveAutorizacion = Usuario["CveAutorizacion"].ToString().ToEntero();
ClsOIEventos ObjOI = new ClsOIEventos();
if (Autorizar)
{
if (ObjOI.UpdateDocumentoAutorizacion(CveAutorizacion, -1, "-1", "-1", DateTime.Now))
{
Alert("Haz aprobado la versión actual del Documento");
}
}
else
{
if (ObjOI.DesaprobarDocumentoAutorizacion(CveAutorizacion))
{
Alert("Haz desaprobado la versión actual del Documento");
}
}
ObjOI.Dispose();
}
protected void LkbPublicar_Click(object sender, EventArgs e)
{
GridViewRowCollection Usuarios = GvUsuarios.Rows;
bool Aprobado = true;
foreach (GridViewRow Usuario in Usuarios)
{
if (!Usuario.FCCheckBox("ChkAprobar").Checked)
{
Aprobado = false;
break;
}
}
if (Aprobado)
{
ClsOIEventos ObjOI = new ClsOIEventos();
if (ObjOI.UpdateDocumento(this.CveDocumento, DdlSubCategoria.SelectedValue.ToEntero(), TxtDescripcion.Text, TxtObs.InnerText, TxtVersion.Text, 2, "-1", TxtResponsable.Text,
DateTime.Now, -1, -1, UsuarioActual.CveEmpresa))
{
Cargar();
UpCliente.Update();
Alert("Documento publicado");
}
ObjOI.Dispose();
}
else
{
Alert("Los usuarios participantes aún no autorizan este Documento");
}
}
#endregion
}