// string tc_no;
        protected void Page_Load(object sender, EventArgs e)
        {
            object kullanici = Session["KullaniciAdi"];

            if (kullanici == null)
            {
                Response.Write("<script>alert('Oturum Süreniz Geçmiş!');</script>");
                System.Threading.Thread.Sleep(1000);
                Server.Transfer("Login.aspx");
            }

            BLL.Staj blStaj = new BLL.Staj();
            if (!IsPostBack)
            {
                listStajDosyalari.DataSource = blStaj.ListeGetir();
                listStajDosyalari.DataBind();
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            kullanici = Session["KullaniciAdi"];
            if (kullanici == null)
            {
                Response.Write("<script>alert('Oturum Süreniz Geçmiş!');</script>");
                System.Threading.Thread.Sleep(1000);
                Server.Transfer("Login.aspx");
            }
            staj_id = Convert.ToInt32(Session["stj_id"]);
            BLL.Kullanici blkullanici = new BLL.Kullanici();
            BLL.Staj      blstaj      = new BLL.Staj();
            BLL.Bolum     blbolum     = new BLL.Bolum();
            ogrenci = blstaj.ListeGetir2(staj_id).FirstOrDefault().tc_no;
            string temp = ogrenci;

            LabelOgrNo.Text = blkullanici.Getir(temp).ogrenci_no;
            bolum_id        = blkullanici.Getir(temp).bolum_id;
            LabelBolum.Text = blbolum.Getir(bolum_id).bolum_adi;
            LabelAdsoy.Text = blkullanici.Getir(temp).ad + blkullanici.Getir(temp).soyad;
        }
        protected void btnStajDosyasi_Click(object sender, EventArgs e)
        {
            BLL.Dosya blDosya = new BLL.Dosya();
            BLL.Staj  blStaj  = new BLL.Staj();
            ListView  lv      = listStajDosyalari as ListView;

            lv.Items.Count.ToString();
            foreach (var item in lv.Items)
            {
                if (item.ItemType == ListViewItemType.DataItem)
                {
                    CheckBox checkBoxSec = item.FindControl("CheckHStaj") as CheckBox;
                    if (checkBoxSec.Checked)
                    {
                        staj_id = Convert.ToInt32(checkBoxSec.Text);
                        try
                        {
                            dosyaAdresi = blDosya.Getir(staj_id).dosya_adresi;
                            ogr_no      = blStaj.ListeGetir2(staj_id).FirstOrDefault().Kullanici.ogrenci_no;
                        }
                        catch (Exception)
                        {
                            dosyaAdresi = null;
                            ogr_no      = null;
                        }
                        if (dosyaAdresi != null)
                        {
                            string path = (dosyaAdresi);           //serverdan dosya yolu alınıyor.
                            string name = Path.GetFileName(path);  //dosya ismi alınıyor.
                            string ext  = Path.GetExtension(path); //dosya uzantısı alınıyor.
                            string type = "";

                            // dosyanın uzantısı set ediliyor.
                            if (ext != null)
                            {
                                switch (ext.ToLower())
                                {
                                case ".pdf":
                                    type = "Application/pdf";
                                    break;

                                case ".doc":
                                case ".rtf":
                                    type = "Application/msword";
                                    break;
                                }
                            }

                            Response.AppendHeader("content-disposition", "attachment; filename=" + ogr_no + name);

                            if (type != "")//Dosyayı indirmek için pop veriliyor.
                            {
                                Response.ContentType = type;
                            }
                            Response.WriteFile(path);

                            Response.End();
                        }
                        else
                        {
                            Response.Write("<script>alert('Staj Dosyası yüklü değil!');</script>");
                            Server.Transfer("H_StajDosyalari.aspx");
                        }
                    }
                    else
                    {
                        //Response.Write("<script>alert('Herhangi bir seçim yapmadınız!');</script>");
                    }
                }
            }
        }