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 (DALDiseases.HasImage(IMAGE)) { // once orjinal dosyayi bir kaydedelim orgImagePath = path + IMAGE + extension; fuImage.SaveAs(orgImagePath); // simdi sizelara gore kaydedelim SaveImage(orgImagePath, Convert.ToInt32(GetPrameterValue("DISEASESWIDTH")), Convert.ToInt32(GetPrameterValue("DISEASESHEIGHT")), "_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 rptrDiseases_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Down": { DISEASES self = DALDiseases.Get(Int32.Parse(e.CommandArgument.ToString())); DISEASES upper = DALDiseases.GetBySort(self.SORT + 1); self.SORT++; upper.SORT--; DALDiseases.Update(self); DALDiseases.Update(upper); fillDiseases(); break; } case "Up": { DISEASES self = DALDiseases.Get(Int32.Parse(e.CommandArgument.ToString())); DISEASES upper = DALDiseases.GetBySort(self.SORT - 1); self.SORT--; upper.SORT++; DALDiseases.Update(self); DALDiseases.Update(upper); fillDiseases(); break; } } }
private void InitializePage() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { RECid = Convert.ToInt16(Request.QueryString["ID"]); DISEASES item = DALDiseases.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; hdnDescription.Value = Server.HtmlDecode(item.MAINTEXT); txtTitle.Text = item.TITLE; chkActive.Checked = item.ISACTIVE; btnDelete.Visible = true; btnSave.Text = "Güncelle"; } } else { tdImage.Visible = true; } }
protected bool ValidateItem() { bool retval = true; if (RECid == 0 && string.IsNullOrEmpty(IMAGE)) { NotificationAdd(NotificationType.error, "Resim yükleyiniz"); retval = false; } if (string.IsNullOrEmpty(txtAlt.Text)) { NotificationAdd(NotificationType.error, "Alt Alanını Giriniz"); retval = false; } if (string.IsNullOrEmpty(txtTitle.Text)) { NotificationAdd(NotificationType.error, "Başlık Alanını Giriniz"); retval = false; } if (string.IsNullOrEmpty(hdnDescription.Value)) { NotificationAdd(NotificationType.error, "Ana Yazı Alanını Giriniz"); retval = false; } if (DALDiseases.HasTitle(txtTitle.Text)) { NotificationAdd(NotificationType.error, "Title Alanını Değiştiriniz."); retval = false; } return(retval); }
protected void btnSave_Click(object sender, EventArgs e) { if (ValidateItem()) { DISEASES rec = new DISEASES(); if (RECid > 0) { rec = DALDiseases.Get(RECid); if (!string.IsNullOrEmpty(IMAGE)) { rec.IMAGE = IMAGE; } rec.ALT = txtAlt.Text; rec.ISACTIVE = chkActive.Checked; rec.MAINTEXT = Server.HtmlEncode(hdnDescription.Value); rec.TITLE = txtTitle.Text; rec.URLSEO = Code.Helper.SEOUrl(txtTitle.Text); DALDiseases.Update(rec); } else { rec.IMAGE = IMAGE; rec.SORT = Convert.ToInt16(DALDiseases.GetLastSort() + 1); rec.ALT = txtAlt.Text; rec.ISACTIVE = chkActive.Checked; rec.MAINTEXT = Server.HtmlEncode(hdnDescription.Value); rec.TITLE = txtTitle.Text; rec.URLSEO = Code.Helper.SEOUrl(txtTitle.Text); DALDiseases.Insert(rec); } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ClosePage", "CloseModal(true);", true); btnDelete.Visible = false; btnCancel.Visible = false; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { DISEASES rec = DALDiseases.Get(Int32.Parse(Request.QueryString["ID"])); if (rec != null) { DALDiseases.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 fillDiseases() { rptCountDiseases = DALDiseases.getCount(); rptrDiseases.Bind(DALDiseases.GetAll().OrderBy(p => p.SORT)); lblCountImages.Text = "(" + rptCountDiseases.ToString() + ")"; foreach (RepeaterItem item in rptrDiseases.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")); } }