using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
public partial class UserControl_acpFile : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();
        }
    }
    public void bind()
    { 
         MODEL.Employee emp = BLL.BLLemployee.getMobile(Session["user"].ToString());
        AccessDataSource1.SelectParameters[0].DefaultValue = emp.EmployeeID.ToString();
        AccessDataSource1.Select(DataSourceSelectArguments.Empty);
    
    }
    protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            string id = this.DataList1.DataKeys[e.Item.ItemIndex].ToString();
            AccessDataSource1.DeleteParameters[0].DefaultValue = id;
            AccessDataSource1.Delete();
        }
        bind();
    }
 
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "down")
        {
            string path = ((HiddenField)(this.DataList1.Items[e.Item.ItemIndex].FindControl("HiddenField1"))).Value;


            System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(path));
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name));
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.End();

        
        }
        bind();
    }
}
