Example #1
0
        public ActionResult Create(int?id)
        {
            SLIDER s = new SLIDER();

            if (id != null)
            {
                s = db.SLIDERs.Find(id);
                if (s == null)
                {
                    s = new SLIDER();
                }
            }

            return(View(s));     // model binding
        }
        public ActionResult Edit(SLIDER model)
        {
            if (ModelState.IsValid)
            {
                var bulunan = Db.SLIDER.Find(model.SliderID);
                TryUpdateModel(bulunan);

                Db.SaveChanges();
            }
            else
            {
                return(View(model));
            }
            return(RedirectToAction("Slider"));
        }
Example #3
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            // SİL
            if (txtSLIDER_REFNO.Text != "")
            {
                SLIDER s = db.SLIDERs.Find(Convert.ToInt32(txtSLIDER_REFNO.Text));
                db.SLIDERs.Remove(s);
                db.SaveChanges();

                GridView1.DataSource = db.SLIDERs.ToList();
                GridView1.DataBind();

                pnlKAYIT.Visible = false;
                pnlLISTE.Visible = true;
            }
        }
Example #4
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    refno = Convert.ToInt32(GridView1.SelectedDataKey.Value.ToString());
            SLIDER s     = db.SLIDERs.Find(refno);

            if (s != null)
            {
                txtSLIDER_REFNO.Text    = s.SLIDER_REFNO.ToString();
                txtBASLIK.Text          = s.BASLIK;
                txtLINK.Text            = s.LINK;
                ddlDURUMU.SelectedValue = s.DURUMU.ToString();
            }

            pnlKayit.Visible = true;
            pnlListe.Visible = false;
        }
        public ActionResult Create(SLIDER slider, HttpPostedFileBase RESIM)
        {
            if (ModelState.IsValid)
            {
                if (slider.BASLIK != null)
                {
                    db.SLIDERs.Add(slider);
                }
                if (slider.LINK != null)
                {
                    db.SLIDERs.Add(slider);
                }
                if (RESIM != null)
                {
                    slider.RESIM = RESIM.FileName;
                }
                if (slider.SLIDER_REFNO == 0)
                {
                    db.SLIDERs.Add(slider);
                }
                else
                {
                    db.Entry(slider).State = System.Data.Entity.EntityState.Modified;
                }
                db.SaveChanges();

                if (RESIM != null)
                {
                    RESIM.SaveAs(Request.PhysicalApplicationPath + "/images/" + RESIM.FileName); //resim kaydediliyor
                }
            }
            else
            {
                string hatalar = "";
                foreach (var item in ModelState.Values)
                {
                    for (int i = 0; i < item.Errors.Count; i++)
                    {
                        hatalar += item.Errors[i].ErrorMessage;
                    }
                }
                ViewData["hatalar"] = hatalar;
                return(View(slider));
            }

            return(RedirectToAction("Index"));
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    refno = Convert.ToInt32(GridView1.SelectedDataKey.Value);
            SLIDER k     = db.SLIDERs.Find(refno);

            if (k != null)
            {
                //fuRESIM
                ddlDURUMU.SelectedValue = k.DURUMU.ToString();
                txtLINK.Text            = k.LINK;
                txtBASLIK.Text          = k.BASLIK;
                txtSLIDER_REFNO.Text    = k.SLIDER_REFNO.ToString();
            }
            //kayıt panelini ac liste panelini kapat
            pnlSliderKayit.Visible = true;
            pnlSliderListe.Visible = false;
        }
Example #7
0
 public bool UpdateSlider(SLIDER entity, int id)
 {
     try// su ly ngoai le
     {
         var update = db.SLIDERs.Find(id);
         update.sliderName      = entity.sliderName;
         update.slider_Image    = entity.slider_Image;
         update.type0           = entity.type0;
         db.Entry(update).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
 public ActionResult Create(SLIDER slider)
 {
     if (ModelState.IsValid)
     {
         if (slider.SLIDER_REFNO == 0)
         {
             db.SLIDERs.Add(slider);
         }
         else
         {
             db.Entry(slider).State = System.Data.Entity.EntityState.Modified;
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));//listeleme yapılıyor.
     }
     //hata var kayıt ekranı acılacak
     return(View(slider));//model binding
 }
        protected void Button5_Click(object sender, EventArgs e)
        {
            //sil
            if (txtSLIDER_REFNO.Text != "")
            {
                int    refno = Convert.ToInt32(txtSLIDER_REFNO.Text);
                SLIDER k     = db.SLIDERs.Find(refno);

                db.SLIDERs.Remove(k);

                db.SaveChanges();

                GridView1.DataSource = db.SLIDERs.ToList();
                GridView1.DataBind();
                pnlSliderKayit.Visible = false;
                pnlSliderListe.Visible = true;
            }
        }
Example #10
0
        public SLIDER Put([FromBody] SLIDER slider)
        {
            SLIDER slder = context.SLIDER.Where(c => c.id == slider.id).SingleOrDefault();

            if (slder != null)
            {
                slder.active = true;
                slder.img    = slider.img;
                slder.header = slider.header;
                slder.text   = slider.text;
                slder.label  = slider.label;
                slder.name   = slider.name;
                slder.editor = slider.editor;
                slder.date   = DateTime.Now.ToString();
                context.SaveChanges();
                return(slder);
            }
            return(new SLIDER());
        }
Example #11
0
        protected void Button3_Click(object sender, EventArgs e)
        {       // KAYDET
            if (txtSLIDER_REFNO.Text != "")
            {
                int    refno = Convert.ToInt32(txtSLIDER_REFNO.Text);
                SLIDER s     = db.SLIDERs.Find(refno);
                s.BASLIK = txtBASLIK.Text;
                s.LINK   = txtLINK.Text;
                s.DURUMU = Convert.ToBoolean(ddlDURUMU.SelectedValue);

                s.RESIM = RESIM1.FileName;

                RESIM1.SaveAs(Request.PhysicalApplicationPath + "/images/" + RESIM1.FileName);


                db.SaveChanges();
            }

            else
            {
                SLIDER s = new SLIDER();
                s.BASLIK = txtBASLIK.Text;
                s.LINK   = txtLINK.Text;
                s.DURUMU = Convert.ToBoolean(ddlDURUMU.SelectedValue);

                s.RESIM = RESIM1.FileName;


                RESIM1.SaveAs(Request.PhysicalApplicationPath + "/images/" + RESIM1.FileName);

                db.SLIDERs.Add(s);
                db.SaveChanges();
            }


            GridView1.DataSource = db.SLIDERs.ToList();
            GridView1.DataBind();

            pnlKayit.Visible = false;
            pnlListe.Visible = true;
        }
        public ActionResult Edit(SliderModel slidermodel, int id)
        {
            if (ModelState.IsValid)//kiem tra xem form co rong hay khong
            {
                var slider = new SLIDER();
                var dao    = new SliderDao();
                slider.sliderName   = slidermodel.sliderName;
                slider.slider_Image = slidermodel.slider_Image;
                slider.type0        = slidermodel.type0;

                var result = dao.UpdateSlider(slider, id);
                if (result)
                {
                    //ViewData["success"] = "Sửa thương hiệu thành công";
                    return(RedirectToAction("Sliderlist"));
                }
                else
                {
                    ModelState.AddModelError("", "Sửa slider thất bại");
                }
            }
            return(View());
        }
Example #13
0
 public ActionResult Create([Bind(Include = "ID_SLIDE,TITLE,IMG,DATEBEGIN,META,ORDER,LINK,HIDE")] SLIDER sLIDER, HttpPostedFileBase img)
 {
     try
     {
         var path     = "";
         var filename = "";
         var date     = DateTime.Now.ToString();    // get datetime at present
         date             = date.Replace(" ", "_"); // replace space by _
         date             = date.Replace("/", "_"); // replace / by _
         date             = date.Replace(":", "_"); // replace : by _
         date             = date + "_";             // insert character _ in the end of string
         sLIDER.META      = Help.Functions.ConvertToUnSign(sLIDER.TITLE);
         sLIDER.DATEBEGIN = DateTime.Now;
         if (ModelState.IsValid)
         {
             if (img != null)
             {
                 filename = date + img.FileName;
                 path     = Path.Combine(Server.MapPath("~/Content/images/slider"), filename);
                 img.SaveAs(path);
                 sLIDER.IMG = filename;
             }
             db.SLIDERs.Add(sLIDER);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DbEntityValidationException e)
     {
         throw e;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(sLIDER));
 }
        protected void Button3_Click(object sender, EventArgs e)
        {
            //kaydet
            if (txtSLIDER_REFNO.Text != "") //ekranda kayıt varsa
            {
                int    refno = Convert.ToInt32(txtSLIDER_REFNO.Text);
                SLIDER k     = db.SLIDERs.Find(refno);

                k.SLIDER_REFNO = Convert.ToInt32(txtSLIDER_REFNO.Text);
                k.BASLIK       = txtBASLIK.Text;
                k.DURUMU       = Convert.ToBoolean(ddlDURUMU.SelectedValue);
                k.LINK         = txtLINK.Text;
                k.RESIM        = fuRESIM.FileName;



                if ((fuRESIM.PostedFile != null) && (fuRESIM.PostedFile.ContentLength > 0))
                {
                    string SaveLocation = Server.MapPath("Images/" + fuRESIM.FileName);

                    try
                    {
                        fuRESIM.PostedFile.SaveAs(SaveLocation);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                db.SaveChanges();
            }
            else
            {
                SLIDER k = new SLIDER();
                k.SLIDER_REFNO = Convert.ToInt32(txtSLIDER_REFNO.Text);
                k.BASLIK       = txtBASLIK.Text;
                k.DURUMU       = Convert.ToBoolean(ddlDURUMU.SelectedValue);
                k.LINK         = txtLINK.Text;
                k.RESIM        = fuRESIM.FileName;

                if ((fuRESIM.PostedFile != null) && (fuRESIM.PostedFile.ContentLength > 0))
                {
                    string SaveLocation = Server.MapPath("Images/" + fuRESIM.FileName);

                    try
                    {
                        fuRESIM.PostedFile.SaveAs(SaveLocation);
                    }
                    catch (Exception ex)
                    {
                    }
                }


                db.SLIDERs.Add(k);//yeni kayıt dbset e ekleniyor.
                db.SaveChanges();
            }
            //degisikliklerin ekrana yansıtılması için
            GridView1.DataSource = db.SLIDERs.ToList();
            GridView1.DataBind();
            //kaydet i kapat listeyi ac
            pnlSliderKayit.Visible = false;
            pnlSliderListe.Visible = true;
        }
Example #15
0
 public int AddSlider(SLIDER entity)
 {
     db.SLIDERs.Add(entity);
     db.SaveChanges();
     return(entity.sliderID);
 }