protected void gwCategory_SelectedIndexChanged(object sender, EventArgs e) { try { btnEditCategory.Attributes.Add("class", "btn btn-circle btn-icon-only btn-default"); btnchangeLBImageCT.Attributes.Add("class", "btn btn-circle btn-icon-only btn-default"); this.load_dlEditParent(); category = new CategoryBLL(); int ID = Convert.ToInt32((gwCategory.SelectedRow.FindControl("lblCategoryID") as Label).Text); Category cat = category.ListCategoryWithID(ID).FirstOrDefault(); txtENameVN.Text = cat.NameVN; txtENameEN.Text = cat.NameEN; txtEPermalink.Text = cat.Permalink; txtESeoTitle.Text = cat.SeoTitle; txtEMetaTitle.Text = cat.MetaTitle; txtEMetaKeywords.Text = cat.MetaKeywords; txtEMetaDescriptions.Text = cat.MetaDescriptions; dlEParent.Items.FindByValue(cat.Parent.ToString()).Selected = true; chkUpdateStatus.Checked = cat.CategoryStatus; chkShowHome.Checked = cat.ShowOnHome; images = new ImagesBLL(); Images img = images.ListWithID(cat.CateogryImage).FirstOrDefault(); ImageUpdate.ImageUrl = (img == null) ? "#" : "../../" + img.ImagesUrl; } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
private void LoadPostInfo() { try { posts = new PostBLL(); Post post = posts.ListPostWithPostCode(Request.QueryString["PostCode"]).FirstOrDefault(); txtPostTitleVN.Value = post.TitleVN; txtPostTitleEN.Value = post.TitleEN; EditorPostContentVN.Text = post.PostContentVN; EditorPostContentEN.Text = post.PostContentEN; txtMetaTitle.Text = post.MetaTitle; txtMetaKeywords.Text = post.MetaKeywords; txtMetaDescription.Text = post.MetaDescriptions; chkTopHot.Checked = post.TopHot; lblpost_status.Text = (post.PostStatus) ? " -- Đăng bài --" : " -- Chờ xét duyệt --"; dlpost_status.Items.FindByValue((post.PostStatus) ? "1" : "0").Selected = true; lblTimePost.Text = post.PostTime.ToString(); this.load_Checkcbltag(post.ID); images = new ImagesBLL(); imgpost.Src = (images.ListWithID(post.PostImages).FirstOrDefault() == null) ? "../../images/noimage.jpg.jpg" : "../../" + images.ListWithID(post.PostImages).FirstOrDefault().ImagesUrl; txtPostImgTemp.Text = (images.ListWithID(post.PostImages).FirstOrDefault() == null) ? "" : images.ListWithID(post.PostImages).FirstOrDefault().ImagesName; posts = new PostBLL(); this.checkedTreeBoxCategory(posts.ListPostWithPostCode(Request.QueryString["PostCode"]).FirstOrDefault().ID.ToString()); } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
static Provaider() { string typeDAL = ConfigurationManager.AppSettings["DAL"]; string typeBLL = ConfigurationManager.AppSettings["BLL"]; switch (typeDAL) { case "DataBase": { UsersDAL = new UsersDAL(); ImagesDAL = new ImagesDAL(); RelationsDAL = new UsersImagesDAL(); } break; default: { throw new ConfigurationFileException("error in configuration file"); } } switch (typeBLL) { case "DefaultLogic": { UsersBLL = new UsersBLL(UsersDAL, RelationsDAL); ImagesBLL = new ImagesBLL(ImagesDAL, RelationsDAL); RelationsBLL = new UsersImagesBLL(UsersDAL, ImagesDAL, RelationsDAL); } break; default: { throw new ConfigurationFileException("error in configuration file"); } } }
private int UploadImg(FileUpload fileupload) { images = new ImagesBLL(); string dateString = DateTime.Now.ToString("MM-dd-yyyy"); string dirFullPath = HttpContext.Current.Server.MapPath("../../images/SubSlider/" + dateString + "/"); if (!Directory.Exists(dirFullPath)) // CHECK IF THE FOLDER EXISTS. IF NOT, CREATE A NEW FOLDER. { Directory.CreateDirectory(dirFullPath); } string fileName = Path.GetFileName(fileupload.PostedFile.FileName); ImageCodecInfo jgpEncoder = null; string str_image = ""; string fileExtension = ""; if (!string.IsNullOrEmpty(fileName)) { fileExtension = Path.GetExtension(fileName); str_image = dateString + "-" + RandomName + fileExtension; string pathToSave = HttpContext.Current.Server.MapPath("../../images/SubSlider/" + dateString + "/") + str_image; //file.SaveAs(pathToSave); System.Drawing.Image image = System.Drawing.Image.FromStream(fileupload.FileContent); if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Gif.Guid) { jgpEncoder = GetEncoder(ImageFormat.Gif); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Jpeg.Guid) { jgpEncoder = GetEncoder(ImageFormat.Jpeg); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Bmp.Guid) { jgpEncoder = GetEncoder(ImageFormat.Bmp); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Png.Guid) { jgpEncoder = GetEncoder(ImageFormat.Png); } else { throw new System.ArgumentException("Invalid File Type"); } Bitmap bmp1 = new Bitmap(fileupload.FileContent); Encoder myEncoder = Encoder.Quality; EncoderParameters myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L); myEncoderParameters.Param[0] = myEncoderParameter; bmp1.Save(pathToSave, jgpEncoder, myEncoderParameters); this.images.NewImages(str_image, "images/SubSlider/" + dateString + "/" + str_image, Session.GetCurrentUser().ID); } Images img = images.ListWithImagesName(str_image).FirstOrDefault(); return((str_image == "") ? 0 : img.ID); }
protected int ImagesID(string filename) { int ImID = 0; images = new ImagesBLL(); if (string.IsNullOrWhiteSpace(filename)) { ImID = 0; } else { ImID = images.ImagesID(filename); } return(ImID); }
//Load Images private void GetImagesPageWise(int pageIndex) { try { images = new ImagesBLL(); int recordCount = 0; rpLstImg.DataSource = images.GetImagesPageWise(pageIndex, PageSize); recordCount = images.RecordCountImages(); rpLstImg.DataBind(); this.PopulatePager(recordCount, pageIndex); } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
protected void btnChangeCTImages_Click(object sender, EventArgs e) { try { category = new CategoryBLL(); images = new ImagesBLL(); int ctID = Convert.ToInt32((gwCategory.SelectedRow.FindControl("lblCategoryID") as Label).Text); string http = "http://" + Request.Url.Authority + "/"; string ImgNAme = HidImgUrlCT.Value.Remove(0, HidImgUrlCT.Value.LastIndexOf("/") + 1); Images img = images.ListWithImagesName(ImgNAme).FirstOrDefault(); if (category.UpdateImage(ctID, img.ID)) { this.GetPostCategoryPageWise(1); } } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
protected void gwSubSlider_SelectedIndexChanged(object sender, EventArgs e) { try { subslider = new SubSliderBLL(); images = new ImagesBLL(); btnfixSubSlider.Attributes.Add("class", "btn btn-default"); btnselectImg.Attributes.Add("class", "btn btn-default"); int ID = Convert.ToInt32((gwSubSlider.SelectedRow.FindControl("lblID") as Label).Text); SubSlider sub = subslider.ListWithID(ID).FirstOrDefault(); txtETitle.Text = sub.Title; txtEDescription.Text = sub.Descriptions; txtERedirectLink.Text = sub.RedirectLink; Images img = images.ListWithID(sub.SliderImg).FirstOrDefault(); ImgEditImages.ImageUrl = (img == null) ? "#" : "../../" + img.ImagesUrl; chkEditStatus.Checked = sub.SliderStatus; UploadEditImage.ToolTip = (img == null) ? "" : img.ImagesName; } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
protected void btnSaveNewCategory_Click(object sender, EventArgs e) { try { category = new CategoryBLL(); images = new ImagesBLL(); string titleVN = txtCategoryNameVN.Text; string titleEN = txtCategoryNameEN.Text; int Parent = Convert.ToInt32(dlParent.SelectedValue); //ItemIndex int itemindex = (Convert.ToInt32(dlParent.SelectedValue) == 0) ? category.MaxItemindexWithParentNull() + 1 : category.MaxItemindexWithParent(Convert.ToInt32(dlParent.SelectedValue)) + 1; string permlink = txtPermalink.Text; string seotitle = txtSeoTitle.Text; //Images List <Images> lstI = images.ListWithImagesName(txtImageTemp.Text); Images img = lstI.FirstOrDefault(); int ImgID = (img == null) ? 0 : img.ID; //Create By string metatile = txtMetaTitle.Text; string metakeyword = txtMetaKeywords.Text; string metadecription = txtMetaDescriptions.Text; Boolean showonhome = (chkShowOnHome.Checked == true) ? true : false; if (category.NewCategory(titleVN, titleEN, Parent, itemindex, permlink, seotitle, ImgID, Session.GetCurrentUser().ID, Convert.ToDateTime("12/12/1900"), 0, metatile, metakeyword, metadecription, true, showonhome)) { Response.Redirect(Request.Url.AbsoluteUri); } else { this.AlertPageValid(true, "False to create category . Error to connect server !", alertPageValid, lblPageValid); } } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
protected void btnPostNew_Click(object sender, EventArgs e) { try { post_category_relationships = new Post_Category_RelationshipsBLL(); category = new CategoryBLL(); images = new ImagesBLL(); tags = new TagsBLL(); tags_relationships = new Tags_relationshipsBLL(); string dateString = DateTime.Now.ToString("MM-dd-yyyy"); string PostCode = RandomName + "-" + dateString; if (NewPost(PostCode)) { this.New_Post_Category_relationships(PostCode); this.New_Tags_relationships(PostCode); Response.Redirect("http://" + Request.Url.Authority + "/Admin/Pages/Post-Update.aspx?PostCode=" + PostCode); } } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
protected void btndelete_ServerClick(object sender, EventArgs e) { images = new ImagesBLL(); try { //this.images.DeleteImages(HiddenImages.Value); List <Images> lst = images.ListWithImagesName(HiddenImages.Value); Images img = lst.FirstOrDefault(); string filename = Server.MapPath("../" + img.ImagesUrl); if (!string.IsNullOrWhiteSpace(filename)) { if ((System.IO.File.Exists(filename))) { System.IO.File.Delete(filename); Response.Redirect(Request.Url.AbsoluteUri); } } } catch (Exception ex) { Response.Write("<script>alert('" + ex.ToString() + "')</script>"); } }
protected void btnuploadImg_Click(object sender, EventArgs e) { try { images = new ImagesBLL(); string dateString = DateTime.Now.ToString("MM-dd-yyyy"); string dirFullPath = HttpContext.Current.Server.MapPath("../../images/Uploads/" + dateString + "/"); if (!Directory.Exists(dirFullPath)) // CHECK IF THE FOLDER EXISTS. IF NOT, CREATE A NEW FOLDER. { Directory.CreateDirectory(dirFullPath); } string fileName = Path.GetFileName(fileUploadImgPost.PostedFile.FileName); ImageCodecInfo jgpEncoder = null; string str_image = ""; string fileExtension = ""; if (!string.IsNullOrEmpty(fileName)) { fileExtension = Path.GetExtension(fileName); str_image = dateString + "-" + RandomName + fileExtension; string pathToSave = HttpContext.Current.Server.MapPath("../../images/Uploads/" + dateString + "/") + str_image; //file.SaveAs(pathToSave); System.Drawing.Image image = System.Drawing.Image.FromStream(fileUploadImgPost.FileContent); if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Gif.Guid) { jgpEncoder = GetEncoder(ImageFormat.Gif); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Jpeg.Guid) { jgpEncoder = GetEncoder(ImageFormat.Jpeg); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Bmp.Guid) { jgpEncoder = GetEncoder(ImageFormat.Bmp); } else if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Png.Guid) { jgpEncoder = GetEncoder(ImageFormat.Png); } else { throw new System.ArgumentException("Invalid File Type"); } Bitmap bmp1 = new Bitmap(fileUploadImgPost.FileContent); Encoder myEncoder = Encoder.Quality; EncoderParameters myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L); myEncoderParameters.Param[0] = myEncoderParameter; bmp1.Save(pathToSave, jgpEncoder, myEncoderParameters); this.images.NewImages(str_image, "images/Uploads/" + dateString + "/" + str_image, Session.GetCurrentUser().ID); txtPostImgTemp.Text = str_image; imgpost.Src = "../../images/Uploads/" + dateString + "/" + str_image; } else { Response.Write("<script>alert('Upload Image False !')</script>"); return; } string script = "window.onload = function() { callImagesPanelClickEvent(); };"; ClientScript.RegisterStartupScript(this.GetType(), "callImagesPanelClickEvent", script, true); } catch (Exception ex) { this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid); } }
public ActionResult GetPeopleDetail(long peopleId) { var peopleBll = new Domain.BLL.PeopleBLL(); var customerBll = new Domain.BLL.CustomerBLL(); var people = peopleBll.Get(peopleId); var peopleCustomers = peopleBll.GetPeopleCustomers(peopleId).Select(pe => new { peopleType = peopleBll.GetPeopleType(pe.PessoaTipoId).Descricao, customer = customerBll.GetCustomer(pe.EmpresaId).Nome }).ToList(); var picture = new Domain.BLL.ImagesBLL().GetNoImage().Url; if (people.ImagemId.HasValue) { picture = new ImagesBLL().Get(people.ImagemId.Value).Url; } var result = new { customers = peopleCustomers, picture = picture }; return Json(result, JsonRequestBehavior.AllowGet); }