예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["UserName"] == null)
                {
                    Response.Redirect("index.aspx");
                }
                else
                {
                    UserName = Session["UserName"].ToString();
                }

                lblGreet.Text = "Hello " + UserName;
                SearchFile srch = new SearchFile();
                GridView1.DataSource = srch.SearchByUser(UserName);
                GridView1.DataBind();

                UploadDocument up = new UploadDocument();
                DataTable      dt = up.RetrieveSpace(lblGreet.Text.Substring(6));
                lblSpaceAllocated.Text = "Space Allocated : " + dt.Rows[0]["SpaceAllocated"].ToString();
                lblSpaceUsed.Text      = "Space Used : " + dt.Rows[0]["SpaceUsed"].ToString();
            }
            catch (Exception ex)
            {
                Response.Redirect("index.aspx");
            }
        }
예제 #2
0
        protected void btnSearchFile_Click(object sender, EventArgs e)
        {
            SearchFile ws = new SearchFile();

            GridView1.DataSource = ws.SearchByName(txtSearch.Text);
            GridView1.DataBind();
        }
예제 #3
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Download")
            {
                int        index        = Convert.ToInt32(e.CommandArgument);
                string     TextToSearch = txtSearch.Text.Trim();
                SearchFile ws           = new SearchFile();
                DataSet    FetchedDS    = ws.SearchByName(txtSearch.Text);
                byte[]     File_Byte    = (byte[])FetchedDS.Tables[0].Rows[index][3];
                string     File_Name    = FetchedDS.Tables[0].Rows[index][0].ToString();

                Context.Session["FileName"]  = File_Name;
                Context.Session["FileBytes"] = File_Byte;
                Response.Redirect("Download.aspx");
            }
        }
예제 #4
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Download")
     {
         int        index     = Convert.ToInt32(e.CommandArgument);
         SearchFile ws        = new SearchFile();
         DataSet    FetchedDS = ws.SearchByUser(UserName);
         byte[]     File_Byte = (byte[])FetchedDS.Tables[0].Rows[index][3];
         string     File_Name = FetchedDS.Tables[0].Rows[index][0].ToString();
         File.WriteAllBytes("C:\\DataUsage\\" + File_Name, File_Byte.ToArray());
         Response.AppendHeader("Content-Disposition", "attachment; filename=" + File_Name);
         Response.TransmitFile("C:\\DataUsage\\" + File_Name);
         Response.End();
     }
     else if (e.CommandName == "ToggleAccess")
     {
         int        index       = Convert.ToInt32(e.CommandArgument);
         SearchFile ws          = new SearchFile();
         DataSet    FetchedDS   = ws.SearchByUser(UserName);
         byte[]     File_Byte   = (byte[])FetchedDS.Tables[0].Rows[index][3];
         string     File_Name   = FetchedDS.Tables[0].Rows[index][0].ToString().Trim();
         string     File_Access = FetchedDS.Tables[0].Rows[index][2].ToString().Trim();
         if (File_Access.Equals("Private"))
         {
             File_Access = "Public";
         }
         else
         {
             File_Access = "Private";
         }
         SearchFile srch = new SearchFile();
         int        ret  = srch.UpdateAccess(File_Name, UserName, File_Access);
         ws                   = new SearchFile();
         FetchedDS            = new DataSet();
         FetchedDS            = ws.SearchByUser(UserName);
         GridView1.DataSource = FetchedDS.Tables[0];
         GridView1.DataBind();
     }
 }