Example #1
0
        protected void rptrSlider_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Down":
            {
                MAINPAGESLIDER self  = DALMainPageSlider.Get(Int32.Parse(e.CommandArgument.ToString()));
                MAINPAGESLIDER upper = DALMainPageSlider.GetBySort(self.SORT + 1);
                self.SORT++;
                upper.SORT--;
                DALMainPageSlider.Update(self);
                DALMainPageSlider.Update(upper);
                fillSlider();
                break;
            }

            case "Up":
            {
                MAINPAGESLIDER self  = DALMainPageSlider.Get(Int32.Parse(e.CommandArgument.ToString()));
                MAINPAGESLIDER upper = DALMainPageSlider.GetBySort(self.SORT - 1);
                self.SORT--;
                upper.SORT++;
                DALMainPageSlider.Update(self);
                DALMainPageSlider.Update(upper);
                fillSlider();
                break;
            }
            }
        }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         MAINPAGESLIDER rec = DALMainPageSlider.Get(Int32.Parse(Request.QueryString["ID"]));
         if (rec != null)
         {
             DALMainPageSlider.Delete(rec.ID);
         }
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ClosePage", "CloseModal(true);", true);
         NotificationAdd(NotificationType.success, "Kayıt Silindi.");
     }
     catch (Exception ex)
     {
         if (ex is SqlException)
         {
             if ((ex as SqlException).Number == 547)
             {
                 NotificationAdd(NotificationType.error, "Kayıt başka yerlerde kullanıdı.");
             }
         }
         else
         {
             throw ex;
         }
     }
 }
 private void InitializePage()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
     {
         RECid = Convert.ToInt16(Request.QueryString["ID"]);
         MAINPAGESLIDER item = DALMainPageSlider.Get(RECid);
         if (item != null)
         {
             if (string.IsNullOrEmpty(item.IMAGE))
             {
                 tdImage.Visible = true;
             }
             else
             {
                 tdImage.Visible        = true;
                 tdImagePreview.Visible = true;
             }
             imgImage.ImageUrl          = Functions.SITEURL.PathAndQuery + "Admin/assets/images/" + item.IMAGE + "_s.jpg";
             imgImage.Width             = new Unit(GetPrameterValue("SLIDERADMINWIDTH"));
             imgImage.Height            = new Unit(GetPrameterValue("SLIDERADMINHEIGHT"));
             txtAlt.Text                = item.ALT;
             txtMottto.Text             = item.MAINTEXT;
             txtTitle.Text              = item.TITLE;
             chkActive.Checked          = item.ISACTIVE;
             drpDirection.SelectedValue = item.DIRECTION;
             btnDelete.Visible          = true;
             btnSave.Text               = "Güncelle";
         }
     }
     else
     {
         tdImage.Visible = true;
     }
 }
 protected void btnUploadFile_Click(object sender, EventArgs e)
 {
     if (fuImage.HasFile)
     {
         string   path         = Server.MapPath("~") + "Admin\\assets\\images\\";
         string   extension    = Path.GetExtension(fuImage.FileName);
         string   orgImagePath = string.Empty;
         string[] name         = fuImage.FileName.Split(new string[] { extension }, StringSplitOptions.None);
         IMAGE = name[0];
         if (DALMainPageSlider.HasImage(IMAGE))
         {
             // once orjinal dosyayi bir kaydedelim
             orgImagePath = path + IMAGE + extension;
             fuImage.SaveAs(orgImagePath);
             // simdi sizelara gore kaydedelim
             SaveImage(orgImagePath, Convert.ToInt32(GetPrameterValue("SLIDERWIDTH")), Convert.ToInt32(GetPrameterValue("SLIDERHEIGHT")), "_l");
             SaveImage(orgImagePath, Convert.ToInt32(GetPrameterValue("SLIDERADMINWIDTH")), Convert.ToInt32(GetPrameterValue("SLIDERADMINHEIGHT")), "_s");
             tdImage.Visible        = false;
             tdImagePreview.Visible = true;
             imgImage.ImageUrl      = Functions.SITEURL.PathAndQuery + "Admin/assets/images/" + IMAGE + "_s" + extension;
             imgImage.Width         = new Unit(GetPrameterValue("SLIDERADMINWIDTH"));
             imgImage.Height        = new Unit(GetPrameterValue("SLIDERADMINHEIGHT"));
         }
         else
         {
             NotificationAdd(NotificationType.error, "Lütfen Resmin Adını Değiştiriniz");
         }
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (ValidateItem())
     {
         MAINPAGESLIDER rec = new MAINPAGESLIDER();
         if (RECid > 0)
         {
             rec = DALMainPageSlider.Get(RECid);
             if (!string.IsNullOrEmpty(IMAGE))
             {
                 rec.IMAGE = IMAGE;
             }
             rec.ALT       = txtAlt.Text;
             rec.ISACTIVE  = chkActive.Checked;
             rec.MAINTEXT  = txtMottto.Text;
             rec.TITLE     = txtTitle.Text;
             rec.DIRECTION = drpDirection.SelectedValue;
             DALMainPageSlider.Update(rec);
         }
         else
         {
             rec.IMAGE     = IMAGE;
             rec.SORT      = Convert.ToInt16(DALMainPageSlider.GetLastSort() + 1);
             rec.ALT       = txtAlt.Text;
             rec.ISACTIVE  = chkActive.Checked;
             rec.MAINTEXT  = txtMottto.Text;
             rec.TITLE     = txtTitle.Text;
             rec.DIRECTION = drpDirection.SelectedValue;
             DALMainPageSlider.Insert(rec);
         }
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ClosePage", "CloseModal(true);", true);
         btnDelete.Visible = false;
         btnCancel.Visible = false;
     }
 }
Example #6
0
        private void fillSlider()
        {
            rptCountSlider = DALMainPageSlider.getCount();
            rptrSlider.Bind(DALMainPageSlider.GetAll().OrderBy(p => p.SORT));
            lblCountImages.Text = "(" + rptCountSlider.ToString() + ")";

            foreach (RepeaterItem item in rptrSlider.Items)
            {
                HiddenField hdn = item.FindControl("hdnImage") as HiddenField;
                Image       img = item.FindControl("imgImage") as Image;
                img.ImageUrl = Functions.SITEURL.PathAndQuery + "Admin/assets/images/" + hdn.Value + "_s.jpg";
                img.Width    = new Unit(GetPrameterValue("SLIDERADMINWIDTH"));
                img.Height   = new Unit(GetPrameterValue("SLIDERADMINHEIGHT"));
            }
        }