protected void Page_Load(object sender, EventArgs e) { btnUpdate.ServerClick += BtnUpdate_ServerClick; btnClear.ServerClick += BtnClear_ServerClick; btnClear.Value = Resources.Index.Clean; btnUpdate.Value = Resources.Index.Add; slidercategoriess = jobs.Slidercategories(); languagess = jobs.Languages(); if (Request.QueryString["Process"] != null) { string Processs = Request.QueryString["Process"]; if (Processs == "EditCategoryName") { Prcs = AddSliderCategory.Process.EditCategoryName; id = Request.QueryString["id"].Clean(); Dictionary <string, string> condition = new Dictionary <string, string>(); condition.Add("id", id); slidercategoriess = jobs.Slidercategories(condition); btnUpdate.Value = Resources.Index.Update; if (slidercategoriess.Count > 0) { PageTitle = Resources.Index.EditGalleryCategory; { if (!Page.IsPostBack) { txtCategoryNameTR.Value = slidercategoriess[0].SliderCategoryNameTR.ToString().Clean(); txtCategoryNameEN.Value = slidercategoriess[0].SliderCategoryNameEN.ToString().Clean(); } } } else { PageTitle = Resources.Index.DataNotFound; Prcs = AddSliderCategory.Process.DataNotFound; } } else if (Processs == "DeleteCategoryName") { PageTitle = Resources.Index.DeleteSliderCategory; Prcs = AddSliderCategory.Process.DeleteCategoryName; id = Request.QueryString["id"].Clean(); int result = jobs.query("Delete slidercategories where id='" + id + "'"); if (result > 0) { Response.Redirect("/AddSliderCategory.aspx"); } else { Response.Write("Error"); } } else { PageTitle = Resources.Index.WrongParameter; } } else { btnUpdate.Value = Resources.Index.Add; PageTitle = Resources.Index.AddGalleryCategory; Prcs = Process.AddCategoryName; } }
protected void Page_Load(object sender, EventArgs e) { if (ddlCategory.Items.Count != 0) { slidercategoriess = jobs.Slidercategories(); foreach (var item in slidercategoriess) { ddlCategory.Items.Add(item.SliderCategoryNameEN.ToString()); ddlCategory.Items[ddlCategory.Items.Count - 1].Value = item.id.ToString().Clean(); } } btnUpdate.ServerClick += BtnUpdate_ServerClick; btnClear.ServerClick += BtnClear_ServerClick; BtnUpload.Text = Resources.Index.Upload; btnClear.Value = Resources.Index.Clean; if (Request.QueryString["Process"] != null) { string Processs = Request.QueryString["Process"]; if (Processs == "EditSlider") { Prcs = AddNewSlider.Process.EditSlider; id = Request.QueryString["id"].Clean(); Dictionary <string, string> condition = new Dictionary <string, string>(); condition.Add("id", id); sliderss = jobs.Sliders(condition); btnUpdate.Value = Resources.Index.Update; if (sliderss.Count > 0) { PageTitle = Resources.Index.EditSlider; { if (!Page.IsPostBack) { string CategoryName = sliderss[0].id.ToString().Clean(); ddlCategory.SelectedValue = CategoryName; lblturkish.Text = Resources.Index.Turkish; lblenglish.Text = Resources.Index.English; txtTurkishTitle.Value = sliderss[0].SliderNameTR.ToString().Clean(); txtEnglishTitle.Value = sliderss[0].SliderNameEN.ToString().Clean(); image1.ImageUrl = sliderss[0].SliderPhoto1.ToString().Clean(); image2.ImageUrl = sliderss[0].SliderPhoto2.ToString().Clean(); image3.ImageUrl = sliderss[0].SliderPhoto3.ToString().Clean(); image4.ImageUrl = sliderss[0].SliderPhoto4.ToString().Clean(); imageuploading.Visible = false; } } } else { PageTitle = Resources.Index.DataNotFound; Prcs = AddNewSlider.Process.DataNotFound; } } else if (Processs == "DeleteSlider") { PageTitle = Resources.Index.DeleteSlider; Prcs = AddNewSlider.Process.DeleteSlider; id = Request.QueryString["id"].Clean(); int result = jobs.query("Delete sliders where id='" + id + "'"); if (result > 0) { Response.Redirect("/SliderList.aspx"); } else { Response.Write("Error"); } } else { Title = Resources.Index.WrongParameter; } } else { btnUpdate.Value = Resources.Index.AddSlider; PageTitle = Resources.Index.AddSlider; Prcs = Process.AddSlider; Viewingimages.Visible = false; uploadbuttondiv.Visible = false; } if (FileUpload1.HasFile) { if (Path.GetExtension(FileUpload1.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload1.PostedFile.FileName) == ".png") { Random rndm = new Random(); string PhotoExtensions = Path.GetExtension(FileUpload1.PostedFile.FileName); string PhotoName = FileUpload1.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/; //Firstly we will save chosen images to \\images\\ folder as temporary FileUpload1.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); //After we are converting as bitmap Bitmap Photo = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); int Width = 300; int Height = 285; //Resizing the photo Size Size = new Size(Width, Height); //Resmi boyutlandırıyoruz. Bitmap ResizedPhoto = new Bitmap(Photo, Size); string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName; //We are saving resized photo to \\images\\userphotos\\ folder ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg); Photo.Dispose(); ResizedPhoto.Dispose(); //we delete the photo we saved as temporary FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); Firstuploadedphoto.Delete(); image1.ImageUrl = Resizedandsavedphoto.Clean(); } } if (FileUpload2.HasFile) { if (Path.GetExtension(FileUpload2.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload2.PostedFile.FileName) == ".png") { Random rndm = new Random(); string PhotoExtensions = Path.GetExtension(FileUpload2.PostedFile.FileName); string PhotoName = FileUpload2.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/; //Firstly we will save chosen images to \\images\\ folder as temporary FileUpload2.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); //After we are converting as bitmap Bitmap Photo = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); int Width = 300; int Height = 285; //Resizing the photo Size Size = new Size(Width, Height); //Resmi boyutlandırıyoruz. Bitmap ResizedPhoto = new Bitmap(Photo, Size); string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName; //We are saving resized photo to \\images\\userphotos\\ folder ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg); Photo.Dispose(); ResizedPhoto.Dispose(); //we delete the photo we saved as temporary FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); Firstuploadedphoto.Delete(); image2.ImageUrl = Resizedandsavedphoto.Clean(); } } if (FileUpload3.HasFile) { if (Path.GetExtension(FileUpload3.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload3.PostedFile.FileName) == ".png") { Random rndm = new Random(); string PhotoExtensions = Path.GetExtension(FileUpload3.PostedFile.FileName); string PhotoName = FileUpload3.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/; //Firstly we will save chosen images to \\images\\ folder as temporary FileUpload3.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); //After we are converting as bitmap Bitmap Photo = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); int Width = 300; int Height = 285; //Resizing the photo Size Size = new Size(Width, Height); //Resmi boyutlandırıyoruz. Bitmap ResizedPhoto = new Bitmap(Photo, Size); string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName; //We are saving resized photo to \\images\\userphotos\\ folder ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg); Photo.Dispose(); ResizedPhoto.Dispose(); //we delete the photo we saved as temporary FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); Firstuploadedphoto.Delete(); image3.ImageUrl = Resizedandsavedphoto.Clean(); } } if (FileUpload4.HasFile) { if (Path.GetExtension(FileUpload4.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload4.PostedFile.FileName) == ".png") { Random rndm = new Random(); string PhotoExtensions = Path.GetExtension(FileUpload4.PostedFile.FileName); string PhotoName = FileUpload4.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/; //Firstly we will save chosen images to \\images\\ folder as temporary FileUpload4.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); //After we are converting as bitmap Bitmap Photo = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); int Width = 300; int Height = 285; //Resizing the photo Size Size = new Size(Width, Height); //Resmi boyutlandırıyoruz. Bitmap ResizedPhoto = new Bitmap(Photo, Size); string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName; //We are saving resized photo to \\images\\userphotos\\ folder ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg); Photo.Dispose(); ResizedPhoto.Dispose(); //we delete the photo we saved as temporary FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName); Firstuploadedphoto.Delete(); image4.ImageUrl = Resizedandsavedphoto.Clean(); } } }