void InsertDocumento()
{
ENTDocumento oENTDocumento = new ENTDocumento();
ENTResponse oENTResponse = new ENTResponse();
ENTSession oENTSession;
BPDocumento oBPDocumento = new BPDocumento();
try
{
// Validaciones
if (this.fupArchivo.PostedFile == null) { throw (new Exception("Es necesario seleccionar un Documento")); }
if (!this.fupArchivo.HasFile) { throw (new Exception("Es necesario seleccionar un Documento")); }
if (this.fupArchivo.PostedFile.ContentLength == 0) { throw (new Exception("Es necesario seleccionar un Documento")); }
// Obtener Sesion
oENTSession = (ENTSession)this.Session["oENTSession"];
// Formulario
oENTDocumento.SolicitudId = Int32.Parse(this.hddSolicitudId.Value);
oENTDocumento.ExpedienteId = 0;
oENTDocumento.ModuloId = 2; // Quejas
oENTDocumento.idUsuarioInsert = oENTSession.idUsuario;
oENTDocumento.Extension = Path.GetExtension(this.fupArchivo.PostedFile.FileName);
oENTDocumento.Nombre = this.fupArchivo.FileName;
oENTDocumento.Descripcion = this.ckeDescripcion.Text.Trim();
oENTDocumento.Ruta = oBPDocumento.UploadFile(this.fupArchivo.PostedFile, this.hddSolicitudId.Value, BPDocumento.RepositoryTypes.Solicitud );
// Transacción
oENTResponse = oBPDocumento.InsertDocumento(oENTDocumento);
// Errores y Warnings
if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); }
if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); }
// Estado inicial del formulario
this.ckeDescripcion.Text = "";
// Refrescar el formulario
SelectSolicitud();
// Foco
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Convert.ToString(Guid.NewGuid()), "function pageLoad(){ focusControl('" + this.fupArchivo.ClientID + "'); }", true);
}catch (Exception ex){
throw (ex);
}
}