//----------------------------------------------- //SaveFiles //----------------------------------------------- protected override void SaveFiles(object obj) { AdvertismentsEntity ad = (AdvertismentsEntity)obj; //File----------------------------- if (fuFile.HasFile) { if (pageType == PagesTypes.AdminEdit) { string fileExtension = (string)ViewState["FileExtension"]; if (fileExtension.Length > 0) { string oldFileVirtualPath = ad.GetFileVirtualPath(fileExtension); string oldFilePhysicalPath = DCServer.MapPath(oldFileVirtualPath); File.Delete(oldFilePhysicalPath); } } //----------------------------------- string newFilePhysicalPath = DCServer.MapPath(ad.GetFileVirtualPath()); fuFile.PostedFile.SaveAs(newFilePhysicalPath); } }
//----------------------------------------------- //LoadControls //----------------------------------------------- protected override bool LoadControls() { int advertiseID = Convert.ToInt32(Request.QueryString["id"]); AdvertismentsEntity advertisments = AdvertismentsFactory.GetObject(advertiseID); if (advertisments != null) { if (SiteSettings.Languages_HasMultiLanguages) { ddlLanguages.SelectedValue = ((int)advertisments.LangID).ToString(); } Load_ddlAdvPlaces(); ddlAdvPlaces.SelectedValue = advertisments.PlaceID.ToString(); txtUrl.Text = advertisments.Url; if (advertiseID == 45) { txtUrl.Enabled = false; ddlAdvPlaces.Enabled = false; } if (advertisments.FileExtension.Length > 0) { ltrAdvertiseFile.Text = AdvertismentsFactory.GetAdvertiseFileForAdmin(advertiseID); hlFile.NavigateUrl = advertisments.GetFileVirtualPath(); hlFile.Text = Resources.AdminText.DownLoadExistFile; } else { hlFile.Visible = false; trAdvertisePreview.Visible = false; } //------------------------------------------ ViewState["FileExtension"] = advertisments.FileExtension; //------------------------------------------ //txtFileType.Text = advertisments.FileType.ToString(); //------------------------------------------ cbIsActive.Checked = advertisments.IsActive; //------------------------------------------ if (SiteSettings.Adv_EnableSeparatedAd) { cbIsSmall.Checked = advertisments.IsSmall; } //------------------------------------------ if (SiteSettings.Adv_HasWeight) { ddlWeight.SelectedValue = advertisments.Weight.ToString(); } //------------------------------------------ if (SiteSettings.Adv_HasMaxApperance) { txtMaxApperance.Text = advertisments.MaxApperance.ToString(); } //------------------------------------------ if (SiteSettings.Adv_HasMaxClicks) { txtMaxClicks.Text = advertisments.MaxClicks.ToString(); } //------------------------------------------ txtTitle.Text = advertisments.Title; return(true); } else { return(false); } }