public void Page_Load(object sender, EventArgs e) { if (ViewState["LatestNb"] == null) { ViewState["LatestNb"] = 3; } List <DAL.Image> lstImages = new List <DAL.Image>(); List <DAL.Reviews> lstReviews = new List <Reviews>(); List <DAL.FoodCategory> lstFoodCategory = new List <FoodCategory>(); CrimsonCowardEntities db = new CrimsonCowardEntities(); var sliders = db.Sliders.Where(x => x.Active).ToList(); lstImages = (from s in db.Sliders join i in db.Images on s.ImageId equals i.Id select i).ToList(); lstReviews = db.Reviews.ToList(); lstFoodCategory = db.FoodCategories.ToList(); if (lstImages.Count > 0) { rptBanner.DataSource = lstImages; rptBanner.DataBind(); } if (lstReviews.Count > 0) { rptReviews.DataSource = lstReviews; rptReviews.DataBind(); } if (lstFoodCategory.Count > 0) { rptMenuCat.DataSource = lstFoodCategory; rptMenuCat.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { CrimsonCowardEntities db = new CrimsonCowardEntities(); FoodGridView.DataSource = db.FoodMenus.ToList(); FoodGridView.DataBind(); }
protected void btnSubscribe_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtSubscribe.Text)) { if (IsValidEmail(txtSubscribe.Text)) { CrimsonCowardEntities db = new CrimsonCowardEntities(); Subscriber subsc = new Subscriber(); if (db.Subscribers.Where(x => x.email.ToLower() == txtSubscribe.Text.ToLower()).Count() > 0) { lblSubscribe.Text = "Dear " + txtSubscribe.Text + ". Your Email already exists"; lblSubscribe.ForeColor = System.Drawing.Color.Yellow; return; } db.Subscribers.Add(new Subscriber() { email = txtSubscribe.Text }); db.SaveChanges(); lblSubscribe.Text = "Dear " + txtSubscribe.Text + ". Kindly note that your Email has been successfully added!"; lblSubscribe.ForeColor = System.Drawing.Color.White; } else { lblSubscribe.Text = "Please enter a valid email address!"; lblSubscribe.ForeColor = System.Drawing.Color.Yellow; } } }
protected void Page_Load(object sender, EventArgs e) { CrimsonCowardEntities db = new CrimsonCowardEntities(); FoodGridView.DataSource = db.FoodMenus.OrderBy(x => new { x.CategoryID, x.MENU_ORDER }).ToList(); FoodGridView.DataBind(); }
private void loadData() { CrimsonCowardEntities db = new CrimsonCowardEntities(); Article article = db.Articles.Where(x => x.position == "operation").FirstOrDefault(); if (article != null) { Body.Text = article.Body; } }
private void loadData() { CrimsonCowardEntities db = new CrimsonCowardEntities(); Article lftImg = db.Articles.Where(x => x.position == "left").FirstOrDefault(); if (lftImg != null) { DAL.Image data = db.Images.Where(x => x.Id == lftImg.imageId).FirstOrDefault(); if (data != null) { if (!string.IsNullOrEmpty(data.FILE_LOCATION)) { lftimgview.ImageUrl = ResolveUrl("~/") + "Thumbnail.aspx?imageId=" + lftImg.imageId; lftimgview.Visible = true; } } } }
protected void CatGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edit") { Response.Redirect("~/Admin/CategoryAdminEdit.aspx?id=" + e.CommandArgument); } else if (e.CommandName == "del") { CrimsonCowardEntities db = new CrimsonCowardEntities(); Guid _id = Guid.Parse(e.CommandArgument.ToString()); List <FoodMenu> items = db.FoodMenus.Where(x => x.CategoryID == _id).ToList(); db.FoodMenus.RemoveRange(items); FoodCategory foodcat = db.FoodCategories.Where(x => x.Id == _id).FirstOrDefault(); db.FoodCategories.Remove(foodcat); db.SaveChanges(); CatGridView.DataSource = db.FoodCategories.ToList(); CatGridView.DataBind(); } }
private void loadData(string pp) { CrimsonCowardEntities db = new CrimsonCowardEntities(); Guid _id = new Guid(pp); Reviews reviews = db.Reviews.Where(x => x.Id == _id).FirstOrDefault(); if (reviews != null) { DAL.Image data = db.Images.Where(x => x.Id == reviews.ImageID).FirstOrDefault(); if (data != null) { lblID.Text = data.Id.ToString(); if (!string.IsNullOrEmpty(data.FILE_LOCATION)) { imgview.ImageUrl = ResolveUrl("~/") + "Thumbnail.aspx?ReviewsId=" + _id + "&secImg=HomeTips"; imgview.Visible = true; } } } }
private void loadData(string p) { CrimsonCowardEntities db = new CrimsonCowardEntities(); int _id = int.Parse(p); Slider slider = db.Sliders.Where(x => x.Id == _id).FirstOrDefault(); if (slider != null) { DAL.Image data = db.Images.Where(x => x.Id == slider.ImageId).FirstOrDefault(); if (data != null) { lblID.Text = data.Id.ToString(); if (!string.IsNullOrEmpty(data.FILE_LOCATION)) { imgview.ImageUrl = ResolveUrl("~/") + "Thumbnail.aspx?SliderId=" + _id + "&secImg=HomeTips"; imgview.Visible = true; } } } }
protected void btnReview_Click(object sender, EventArgs e) { CrimsonCowardEntities db = new CrimsonCowardEntities(); if (string.IsNullOrEmpty(hdnRating.Value)) { lblReview.Text = "Please select star rating"; lblReview.ForeColor = System.Drawing.Color.Red; } if (string.IsNullOrEmpty(txtReviewTitle.Text)) { lblReview.Text = "Please enter your name"; lblReview.ForeColor = System.Drawing.Color.Red; } if (string.IsNullOrEmpty(txtReviewTitle.Text)) { lblReview.Text = "Please enter your review"; lblReview.ForeColor = System.Drawing.Color.Red; } if (!string.IsNullOrEmpty(txtReviewTitle.Text) && !string.IsNullOrEmpty(txtReview.Text) && !string.IsNullOrEmpty(hdnRating.Value)) { DAL.Reviews review = new Reviews { Id = Guid.NewGuid(), IsActive = false, Date = DateTime.Now, Text = txtReview.Text, Rating = int.Parse(hdnRating.Value.Length > 0?hdnRating.Value:"0"), Title = txtReviewTitle.Text }; db.Reviews.Add(review); db.SaveChanges(); lblReview.Text = "Thank you for your review"; lblReview.ForeColor = System.Drawing.Color.Green; txtReview.Text = ""; txtReviewTitle.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values.Count == 1) { if (Page.RouteData.Values["Prl"].ToString() != null && Page.RouteData.Values["Prl"].ToString().ToLower() != "Prl") { PageTitle.Text = "Intrested in this property"; ContactText.Visible = false; Prl.Text = "Ref#: " + Page.RouteData.Values["Prl"].ToString(); map.Visible = false; PropertyDetails.Visible = true; CrimsonCowardEntities db = new CrimsonCowardEntities(); string _prl = Page.RouteData.Values["Prl"].ToString(); } else { PageTitle.Text = "Contact US"; ContactText.Visible = true; Prl.Text = "Contact Form"; PropertyDetails.Visible = false; map.Visible = true; } } }
private void Page_Load(object sender, System.EventArgs e) { byte[] b = new byte[] { }; CrimsonCowardEntities db = new CrimsonCowardEntities(); if (Request.Params["id"] != null) { var _id = int.Parse(Request.Params["id"]); DAL.Image img = db.Images.Where(x => x.Id == _id).FirstOrDefault(); if (img != null) { if (img.File == null || img.File.Length == 0) { b = File.ReadAllBytes(MapPath("~/assets/logo.png")); } else { b = img.File; } } else { b = File.ReadAllBytes(MapPath("~/assets/logo.png")); } } else if (Request.Params["SliderId"] != null) { var _id = int.Parse(Request.Params["SliderId"]); DAL.Slider slider = db.Sliders.Where(x => x.Id == _id).FirstOrDefault(); DAL.Image img = db.Images.Where(x => x.Id == slider.ImageId).FirstOrDefault(); if (img != null) { if (img.File == null || img.File.Length == 0) { b = File.ReadAllBytes(MapPath("~/assets/logo.png")); } else { b = img.File; } } else { b = File.ReadAllBytes(MapPath("~/assets/logo.png")); } } else { b = File.ReadAllBytes(MapPath("~/assets/logo.png")); } //} MemoryStream imageStream = new MemoryStream(); MemoryStream imageStream1 = new MemoryStream(b); // create an image object, using the filename we just retrieved System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream1); // create the actual thumbnail image System.Drawing.Image thumbnailImage = null; if (Request.Params["secImg"] == "footer") { thumbnailImage = ScaleImage(image, 100, 60); //thumbnailImage = image.GetThumbnailImage(100, 60, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "search") { thumbnailImage = ScaleImage(image, 150, 113); //thumbnailImage = image.GetThumbnailImage(150, 113, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "HomeTips") { thumbnailImage = ScaleImage(image, 1160, 510); //thumbnailImage = image.GetThumbnailImage(1160, 510, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "Latest") { thumbnailImage = ScaleImage(image, 370, 250); //thumbnailImage = image.GetThumbnailImage(370, 250, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "HomeNewsThumb") { thumbnailImage = ScaleImage(image, 535, 200); //thumbnailImage = image.GetThumbnailImage(535, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "logo") { thumbnailImage = ScaleImage(image, 95, 95); //thumbnailImage = image.GetThumbnailImage(95, 95, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "PartnershipThumb") { thumbnailImage = ScaleImage(image, 565, 280); //thumbnailImage = image.GetThumbnailImage(565, 280, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "thumb") { thumbnailImage = ScaleImage(image, 220, 122); //thumbnailImage = image.GetThumbnailImage(220, 122, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "big") { thumbnailImage = ScaleImage(image, 350, 280); //thumbnailImage = image.GetThumbnailImage(350, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else if (Request.Params["secImg"] == "large") { thumbnailImage = ScaleImage(image, 600, 450); //thumbnailImage = image.GetThumbnailImage(600, 450, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } else { thumbnailImage = ScaleImage(image, 400, 300); //thumbnailImage = image.GetThumbnailImage(400, 300, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); } if (thumbnailImage != null) { thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png); } byte[] imageContent = new Byte[imageStream.Length]; imageStream.Position = 0; imageStream.Read(imageContent, 0, (int)imageStream.Length); // return byte array to caller with image type Response.ContentType = "image/png"; Response.BinaryWrite(imageContent); }