Exemplo n.º 1
0
 protected void ButtonSubir_Click(object sender, EventArgs e)
 {
     try
     {
         if (DropDownDocumento.Text != "0")
         {
             if (FileUploadDocumento.PostedFile.FileName != "")
             {
                 try
                 {
                     string extension = Path.GetExtension(FileUploadDocumento.PostedFile.FileName);
                     FileUploadDocumento.PostedFile.SaveAs(Path.Combine(Path.Combine(Request.PhysicalApplicationPath, "Documento"), Path.GetFileName(FileUploadDocumento.PostedFile.FileName)));
                     Usuario   USU = (Usuario)Session["Usuario"];
                     Resultado RES = new Resultado("", DropDownDocumento.Text, USU.IDUSUARIO, FileUploadDocumento.PostedFile.FileName);
                     if (RES.ConsultaResultadoDocumento(RES.RES_IDDOCUMENTO, RES.RES_IDUSUARIO))
                     {
                         if (RES.ReistrarResultadoDocumento(RES))
                         {
                             Alerta.Visible  = true;
                             Alerta.CssClass = "alert alert-success";
                             Alert.Text      = "Registro Exitoso.";
                         }
                         else
                         {
                             Alerta.Visible  = true;
                             Alerta.CssClass = "alert alert-danger";
                             Alert.Text      = "el registro no fue digilenciado en una forma adecuada";
                         }
                     }
                     else
                     {
                         if (RES.ModificarResultadoDocumento(RES))
                         {
                             Alerta.Visible  = true;
                             Alerta.CssClass = "alert alert-success";
                             Alert.Text      = "Modificación Exitoso.";
                         }
                         else
                         {
                             Alerta.Visible  = true;
                             Alerta.CssClass = "alert alert-danger";
                             Alert.Text      = "el registro no fue digilenciado en una forma adecuada";
                         }
                     }
                 }
                 catch
                 {
                     Alerta.Visible  = true;
                     Alerta.CssClass = "alert alert-danger";
                     Alert.Text      = "Error en la subida del archivo";
                 }
             }
             else
             {
                 Alerta.Visible  = true;
                 Alerta.CssClass = "alert alert-danger";
                 Alert.Text      = "No agrego el archivo";
             }
         }
         else
         {
             Alerta.Visible  = true;
             Alerta.CssClass = "alert alert-danger";
             Alert.Text      = "Debe seleccionar un documento";
         }
     }
     catch
     {
         Response.Redirect("../Index.aspx");
     }
 }