Esempio n. 1
0
 private void showOldResInfo(int resid)
 {
     try
     {
         ResourcesBLL  resource = new ResourcesBLL();
         ResourceModel res      = resource.GetResourcesById(resid);
         ViewState["ResID"]   = resid;
         this.txtResName.Text = res.ResName;
         this.txtjianjie.Text = res.ResDescription;
     }
     catch (Exception)
     {
     }
 }
Esempio n. 2
0
    protected void givshowFile_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int           id        = Convert.ToInt32(e.CommandArgument.ToString());
        ResourcesBLL  resource  = new ResourcesBLL();
        ResourceModel resuouces = resource.GetResourcesById(id);

        if (resuouces == null)
        {
            ScriptHelper.SetAlert(givshowFile, GetTran("001332", "该资料可能已经不存在") + "!!!");
            return;
        }

        if (e.CommandName.ToLower().Trim() == "del")
        {
            try
            {
                //从文件夹中删除指定的文件
                string path = Server.MapPath(@"..\company\upLoadRes\") + resuouces.FileName;

                System.IO.FileInfo file = new System.IO.FileInfo(path);
                if (file.Exists)
                {
                    file.Delete();
                }

                //删除数据库中文件的信息

                resource.DelResurces(Convert.ToInt32(id));
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("000008", "删除成功") + "!');</script>");
                PageBind();
            }
            catch
            {
            }
        }
        else if (e.CommandName.ToLower().Trim() == "download")
        {
            try
            {
                string             dlDir = "upLoadRes/";
                string             path  = Server.MapPath(dlDir + resuouces.FileName);
                System.IO.FileInfo file  = new System.IO.FileInfo(path);
                if (file.Exists)
                {
                    //修改最后下载时间
                    //  ResourcesBLL resource = new ResourcesBLL();
                    resource.UpdateResutcesResTime(Convert.ToInt32(id));

                    PageBind();

                    Response.Clear();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name).Replace('+', ' '));
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    Response.AddHeader("Content-Transfer-Encoding", "binary");
                    Response.ContentType     = "application/octet-stream";
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                    Response.WriteFile(file.FullName);
                    Response.Flush();
                    Response.End();
                    string wheret = ViewState["pagewhere"].ToString();
                    Pager  pager  = Page.FindControl("Pager1") as Pager;
                    pager.PageBind(0, 10, "Resources", "ResID, ResName, FileName, ResDescription, ResSize, ResDateTime, ResTimes", wheret, "ResID", "givshowFile");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("000666", "您下载的文件不在文件夹中") + "!');</script>");
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                PageBind();
            }
        }
    }