Пример #1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         FileUtility file = new FileUtility();
         String[] _tipos = { ".jpg" };
         file.Tipos = _tipos;
         file.KeepFileNames = false;
         file.MaxTam = 10000000;
         file.SubFolder = "Banner/";
         file.FixedFileName = "header_image";
         file.UploadFile(this, this.fuArchivo.Name);
     }
     catch (Exception ex)
     {
         this.lblError.Text = ex.Message;
         SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex, "");
     }
 }
Пример #2
0
        protected void btnAddFile_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.fuArchivo.HasFile && this.fuArchivo.Visible == true)
                {
                    FileUtility file = new FileUtility();
                    //String[] _tipos = { ".mp3", ".jpg", ".bmp", ".flv", ".png", ".png", ".png", ".png", ".png" };
                    //file.Tipos = _tipos;
                    file.IDGrupo = Request.QueryString["NoticiaId"];
                    file.KeepFileNames = true;
                    file.MaxTam = 10000000;
                    file.SubFolder = "Noticias/" + file.IDGrupo;
                    file.UploadFile(this);

                    this.FillGrid();
                }
            }
            catch (Exception ex)
            {
                this.lblErrorArchivo.Text = ex.Message;
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex, "");
            }
        }
Пример #3
0
        protected void btnViewTorneo_Click(object sender, EventArgs e)
        {
            try
            {
                String nombrearchivo = Server.MapPath("~/Uploads/tmp/");

                if (fuTorneo.HasFile && fuTorneo.PostedFile.ContentLength > 0)
                {
                    if (fuTorneo.PostedFile.ContentType != "application/vnd.ms-excel" &&
                        fuTorneo.PostedFile.ContentType !=
                        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                        throw new Exception("El formato del archivo no es válido.");

                    var fu = new FileUtility();
                    fu.KeepFileNames = true;
                    fu.PathVirtual = "Uploads";
                    fu.SubFolder = "tmp";
                    fu.UploadFile(this);

                    var oEx = new Excel(nombrearchivo + fuTorneo.FileName);
                    dt = oEx.Read("Hoja1", true);

                    CleanDataTable();

                    gvTorneo.DataSource = dt;
                    gvTorneo.DataBind();

                    btnAddTorneo.Visible = true;
                }
                else
                {
                    throw new Exception("No se encontró el archivo.");
                }
            }
            catch (Exception ex)
            {
                lblErrorTorneo.Text = ex.Message;
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex,
                            "Disciplina : " + ddlDisciplinaTorneo.SelectedItem.Text);
            }
        }