protected void rptrTattooGallery_ItemCommand(object source, RepeaterCommandEventArgs e) { try { crazyTattoosEntities data = new crazyTattoosEntities(); if (e.CommandName.Equals("del")) //// delete one image { int ImageID = int.Parse(e.CommandArgument.ToString()); ImageInfo cid = new ImageInfo(); cid = data.ImageInfoes.Single(v => v.ImageID == ImageID); if (cid != null) { string path = Server.MapPath("~/Admin/Gallery/" + cid.ImageName); if (File.Exists(path)) { File.Delete(path); data.ImageInfoes.Attach(cid); data.ImageInfoes.Remove(cid); data.SaveChanges(); ViewImages(); } } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
//Get All Slider Images private void ViewBanner() { crazyTattoosEntities data = new crazyTattoosEntities(); rptrBanner.DataSource = data.ImageSliders.ToList(); rptrBanner.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { crazyTattoosEntities nidata = new crazyTattoosEntities(); var count = (from b in nidata.ImageSliders select b).Count(); // total banners if (count.ToString() != null) { lblBanner.Text = count.ToString(); } var count1 = (from i in nidata.ImageInfoes select i).Count(); // total Gallery images if (count1.ToString() != null) { lblGallery.Text = count1.ToString(); } var count2 = (from i in nidata.Testimonials select i).Count(); // total testimonials if (count2.ToString() != null || count2.ToString() != "") { lblTestimonials.Text = count2.ToString(); } var count3 = (from i in nidata.categoryInfoes select i).Count(); // total categories if (count3.ToString() != null || count3.ToString() != "") { lblCategory.Text = count3.ToString(); } }
//Get All Categories on page Load private void ViewCategory() { crazyTattoosEntities data = new crazyTattoosEntities(); rptrCategory.DataSource = data.categoryInfoes.ToList(); rptrCategory.DataBind(); }
private void ViewTestimonial() { crazyTattoosEntities data = new crazyTattoosEntities(); rptrViewTestimonial.DataSource = data.Testimonials.ToList(); rptrViewTestimonial.DataBind(); }
//Get All Categories private void BindRepCategories() { crazyTattoosEntities data = new crazyTattoosEntities(); repCategories.DataSource = data.categoryInfoes.ToList(); repCategories.DataBind(); }
//get gallrey images on page load - implementation private void ViewImages() { crazyTattoosEntities data = new crazyTattoosEntities(); var img = from p in data.ImageInfoes join c in data.categoryInfoes on p.CategoryId equals c.CategoryId select new { p.ImageID, p.ImageType, p.ImageSize, p.ImageName, p.ImageExtension, c.CategoryName }; rptGallery.DataSource = img.ToList(); rptGallery.DataBind(); }
//Get All Gallery Images private void BindGalleryPortfolio() { crazyTattoosEntities data = new crazyTattoosEntities(); var img = from v in data.ImageInfoes select v; reptGallery.DataSource = img.ToList(); reptGallery.DataBind(); }
//Bind all the categories to select private void BindDdlCategory() { crazyTattoosEntities data = new crazyTattoosEntities(); ddlCategory.DataSource = data.categoryInfoes.ToList(); ddlCategory.DataValueField = "CategoryId"; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem("Select Category..", "-1")); }
protected void Page_Load(object sender, EventArgs e) { //Get All the Testimonials Here if (!IsPostBack) { crazyTattoosEntities data = new crazyTattoosEntities(); rptrTestimonials.DataSource = data.Testimonials.ToList(); rptrTestimonials.DataBind(); } }
// Get all images for home slider / banner private void BindHomeSlider() { crazyTattoosEntities data = new crazyTattoosEntities(); //Get all slider images on page load var ban = from b in data.ImageSliders select b; rptrbanner.DataSource = ban.ToList(); rptrbanner.DataBind(); }
protected void rptrBanner_ItemCommand(object source, RepeaterCommandEventArgs e) { try { crazyTattoosEntities Cdata = new crazyTattoosEntities(); if (e.CommandName.Equals("del")) // to delete any slider image { int BannerID = int.Parse(e.CommandArgument.ToString()); ImageSlider data = new HomeImageInfoAction().ViewPhoto1(BannerID); // retrive the info for slider image if (data != null) { Cdata.ImageSliders.Attach(data); Cdata.ImageSliders.Remove(data); // remove image slider info from database Cdata.SaveChanges(); string path = Server.MapPath("~/Banner/" + data.PhotoName); if (File.Exists(path)) { File.Delete(path); //delete the image from path ViewBanner(); // bind the banners again } } } else if (e.CommandName.Equals("delall")) // to delete all the slider images at once { var dbBannerId = from b in Cdata.ImageSliders select b.PhotoId; // Get all Slider Image Id(s) string path; foreach (var bid in dbBannerId) { ImageSlider bt = new ImageSlider(); bt = Cdata.ImageSliders.Single(c => c.PhotoId == bid); // lamda expression path = Server.MapPath("~/Banner/" + bt.PhotoName); if (File.Exists(path)) { File.Delete(path); // remove images from the path } Cdata.ImageSliders.Attach(bt); Cdata.ImageSliders.Remove(bt); // remove banners info } Cdata.SaveChanges(); ViewBanner(); // method calling } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
protected void rptrCategory_ItemCommand(object source, RepeaterCommandEventArgs e) { try { crazyTattoosEntities n = new crazyTattoosEntities(); if (e.CommandName.Equals("del")) { int CategoryId = int.Parse(e.CommandArgument.ToString()); categoryInfo cid = new categoryInfo(); cid = n.categoryInfoes.Single(v => v.CategoryId == CategoryId); if (cid != null) { n.categoryInfoes.Attach(cid); n.categoryInfoes.Remove(cid); n.SaveChanges(); ViewCategory(); lblmsg.Text = "*New Deleted!"; } } // crazyTattoosEntities n = new crazyTattoosEntities(); if (e.CommandName.Equals("delall")) { var CateIds = from b in n.categoryInfoes select b.CategoryId; // Get all news Id(s) foreach (var nid in CateIds) { categoryInfo bt = new categoryInfo(); bt = n.categoryInfoes.Single(c => c.CategoryId == nid); // lamda expression n.categoryInfoes.Attach(bt); n.categoryInfoes.Remove(bt); // delete category } n.SaveChanges(); // submit changes ViewCategory(); // Bind Categories again } else if (e.CommandName.Equals("edit")) { int categoryID = int.Parse(e.CommandArgument.ToString()); categoryInfo data = new CategoryInfoAction().ViewCategory(categoryID); if (data != null) { hfCategoryId.Value = data.CategoryId.ToString(); txtCategory.Text = data.CategoryName; lnkaddTest.Text = "Update Category"; } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
protected void rptrNews_ItemCommand(object source, RepeaterCommandEventArgs e) { try { crazyTattoosEntities n = new crazyTattoosEntities(); if (e.CommandName.Equals("del")) // delete one testimonial { int testimonialID = int.Parse(e.CommandArgument.ToString()); Testimonial data = new TestimonialInfoAction().ViewTestimonial(testimonialID); // getting a testimonial to delete if (data != null) { n.Testimonials.Attach(data); n.Testimonials.Remove(data); n.SaveChanges(); ViewTestimonial(); lblmsg.Text = "*Testimonial Deleted!"; } } else if (e.CommandName.Equals("delall")) { var IDs = from b in n.Testimonials select b.TestimonialId; // Get all Testimonial Id(s) foreach (var nid in IDs) { Testimonial bt = new Testimonial(); bt = n.Testimonials.Single(c => c.TestimonialId == nid); // lamda expression n.Testimonials.Attach(bt); n.Testimonials.Remove(bt); } n.SaveChanges(); ViewTestimonial(); } else if (e.CommandName.Equals("edit")) { int TestID = int.Parse(e.CommandArgument.ToString()); Testimonial data = new TestimonialInfoAction().ViewTestimonial(TestID); // getting a testimonial to Edit if (data != null) { lblnewsid.Text = data.TestimonialId.ToString(); txtnewsup.Text = data.Testimonial1; txtnewsheadup.Text = data.CustomerName; pnlEditTestimonal.Visible = true; } } } catch (Exception ex) { Response.Write(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { crazyTattoosEntities data = new crazyTattoosEntities(); //Get all slider images on page load BindHomeSlider(); //Get All Testimonials on page Load var test = from t in data.Testimonials select t; rptTesti.DataSource = test.ToList(); rptTesti.DataBind(); //Method calling to get gallrey images on page load ViewImages(); } }
protected void repCategories_ItemCommand(object source, RepeaterCommandEventArgs e) { try { //get Gallery images according to selected Category if (e.CommandName.Equals("vw")) { crazyTattoosEntities data = new crazyTattoosEntities(); int CategoryId = int.Parse(e.CommandArgument.ToString()); var pro = from p in data.ImageInfoes join c in data.categoryInfoes on p.CategoryId equals c.CategoryId where p.CategoryId == CategoryId select new { p.ImageID, p.ImageType, p.ImageSize, p.ImageName, p.ImageExtension, c.CategoryName }; reptGallery.DataSource = pro.ToList(); reptGallery.DataBind(); } } catch (Exception ex) { throw ex; } }