コード例 #1
0
        // GET: ogrenci_belgeler/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString()))

            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                ogrenci_belge ogrenci_belge = db.ogrenciBelgeler.Find(id);
                if (ogrenci_belge == null)
                {
                    return(HttpNotFound());
                }
                ogrenci_belge.silindiMi       = true;
                db.Entry(ogrenci_belge).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("index", "ogrenci_belgeler"));
            }

            else
            {
                return(RedirectToAction("index", "giris"));
            }
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "id,belge_id,ogrenci_id,silindiMi")] ogrenci_belge ogrenci_belge)
        {
            if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString()))

            {
                if (ModelState.IsValid)
                {
                    ogrenci_belge.ogrenci  = db.ogrenciler.Find(ogrenci_belge.ogrenci_id);
                    ogrenci_belge.belge    = db.belgeler.Find(ogrenci_belge.belge_id);
                    ogrenci_belge.donem    = db.donemler.FirstOrDefault(d => d.baslangicTarihi <= DateTime.Now && d.bitisTarihi > DateTime.Now);
                    ogrenci_belge.donem_id = ogrenci_belge.donem.id;
                    //http://stackoverflow.com/questions/6826921/write-text-on-an-image-in-c-sharp
                    if (ogrenci_belge.belge.isim == "Takdir Belgesi")
                    {
                        string firstText      = "Okulumuzun öğrencilerinden" + ogrenci_belge.ogrenci.okulNo + "numaralı" + ogrenci_belge.ogrenci.adSoyad;
                        string secondText     = ogrenci_belge.donem.baslangicTarihi.ToShortDateString() + " - " + ogrenci_belge.donem.bitisTarihi.ToShortDateString() + "döneminde okul içinde ve dışında";
                        string thirdText      = "göstermiş olduğu erdemli davranışlarından bu takdir belgesini almaya hak kazanmıştır.";
                        PointF firstLocation  = new PointF(10f, 10f);
                        PointF secondLocation = new PointF(10f, 50f);
                        PointF thirdLocation  = new PointF(10f, 90f);
                        string imageFilePath  = ogrenci_belge.belge.belgeYolu;
                        Bitmap bitmap         = (Bitmap)Image.FromFile(Path.Combine(Server.MapPath(imageFilePath)));//load the image file

                        using (Graphics graphics = Graphics.FromImage(bitmap))
                        {
                            using (Font arialFont = new Font("Arial", 10))
                            {
                                graphics.DrawString(firstText, arialFont, Brushes.Black, firstLocation);
                                graphics.DrawString(secondText, arialFont, Brushes.Black, secondLocation);
                                graphics.DrawString(thirdText, arialFont, Brushes.Black, thirdLocation);
                            }
                        }

                        string ogrenciBelge = "~/OgrenciBelgeler/";

                        //bitmap.Save(Path.Combine(Server.MapPath(ogrenciBelge)));//save the image file
                        //bitmap.Save(@"C:\");
                    }



                    ogrenci_belge.donem_id = db.donemler.FirstOrDefault(d => d.baslangicTarihi <= DateTime.Now && d.bitisTarihi > DateTime.Now).id;

                    db.ogrenciBelgeler.Add(ogrenci_belge);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.ogrenci_id = new SelectList(db.ogrenciler.Where(o => o.silindiMi == false), "id", "adSoyad", ogrenci_belge.ogrenci_id);
                ViewBag.belge_id   = new SelectList(db.belgeler.Where(b => b.silindiMi == false), "id", "isim", ogrenci_belge.belge_id);
                return(View(ogrenci_belge));
            }

            else
            {
                return(RedirectToAction("index", "giris"));
            }
        }
コード例 #3
0
 // GET: ogrenci_belgeler/Details/5
 public ActionResult Details(int?id)
 {
     if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString()))
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         ogrenci_belge ogrenci_belge = db.ogrenciBelgeler.Find(id);
         if (ogrenci_belge == null)
         {
             return(HttpNotFound());
         }
         return(View(ogrenci_belge));
     }
     else
     {
         return(RedirectToAction("index", "giris"));
     }
 }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "id,belgeYolu,belge_id,ogrenci_id,silindiMi")] ogrenci_belge ogrenci_belge)
        {
            if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString()))

            {
                if (ModelState.IsValid)
                {
                    db.Entry(ogrenci_belge).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.ogrenci_id = new SelectList(db.ogrenciler.Where(o => o.silindiMi == false), "id", "adSoyad", ogrenci_belge.ogrenci_id);
                ViewBag.belge_id   = new SelectList(db.belgeler.Where(b => b.silindiMi == false), "id", "isim", ogrenci_belge.belge_id);
                return(View(ogrenci_belge));
            }

            else
            {
                return(RedirectToAction("index", "giris"));
            }
        }
コード例 #5
0
        // GET: ogrenci_belgeler/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString()))

            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                ogrenci_belge ogrenci_belge = db.ogrenciBelgeler.Find(id);
                if (ogrenci_belge == null)
                {
                    return(HttpNotFound());
                }

                ViewBag.ogrenci_id = new SelectList(db.ogrenciler.Where(o => o.silindiMi == false && o.devamDurumu == true), "id", "adSoyad", ogrenci_belge.ogrenci_id);
                ViewBag.belge_id   = new SelectList(db.belgeler.Where(b => b.silindiMi == false), "id", "isim", ogrenci_belge.belge_id);
                return(View(ogrenci_belge));
            }
            else
            {
                return(RedirectToAction("index", "giris"));
            }
        }