protected void MakeItMain(object sender, EventArgs e) { int i = int.Parse(((Button)sender).CommandArgument.Substring(((Button)sender).CommandArgument.IndexOf("#") + 1)); string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection Conn = new SqlConnection(con)) { SqlCommand cmd = new SqlCommand("dbo.UpdateArticleMainPhoto", Conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ((Button)PhotosList.Items[i].FindControl("btn_EditCap")).CommandArgument.Substring(0, ((Button)PhotosList.Items[i].FindControl("btn_EditCap")).CommandArgument.IndexOf("#"))); if (((Button)PhotosList.Items[i].FindControl("btn_MainPhoto")).CommandArgument.Substring(0, ((Button)PhotosList.Items[i].FindControl("btn_MainPhoto")).CommandArgument.IndexOf("#")) == "False") { cmd.Parameters.AddWithValue("@Main", 1); } else { cmd.Parameters.AddWithValue("@Main", 0); } Conn.Open(); cmd.ExecuteNonQuery(); Conn.Close(); } PhotosList.DataBind(); // EditMainbutton(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String artID = null; if (Request.QueryString["artID"] != null) { artID = General.b64decode(Request.QueryString["artID"]); } if (!HttpContext.Current.User.Identity.IsAuthenticated) { Response.Redirect("~/Account/Login.aspx"); } if (!string.IsNullOrEmpty(artID)) { LoadArticle(int.Parse(artID)); lbl_ID.Text = artID; } } PhotosList.DataBind(); if (PhotosList.Items.Count == 0) { div_show.Visible = false; } else { div_show.Visible = true; } }
private async Task GetSearchResultList(string text) { if (PageNumber <= PageCount) { PageNumber++; ProgressVisibility = true; var photosresult = await _photosDataServices.GetPhotosSearchResultAsync(PageNumber, text); if (photosresult.Successful) { if (photosresult.Content != null && photosresult.Content.Photo.Count > 0) { PageCount = int.Parse(photosresult.Content.Pages); foreach (var item in photosresult.Content.Photo) { PhotosList.Add(item); } } } else { ShowError(photosresult.Message); } ProgressVisibility = false; AppSettings.AddSetting(Constants.LastSearchKey, text); } }
protected void Delete_Click(object sender, EventArgs e) { string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection Conn = new SqlConnection(con)) { SqlCommand cmd = new SqlCommand("dbo.DeletePhoto", Conn); //Conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ((Button)sender).CommandArgument); Conn.Open(); cmd.ExecuteNonQuery(); Conn.Close(); } PhotosList.DataBind(); if (PhotosList.Items.Count == 0) { div_show.Visible = false; } else { div_show.Visible = true; } this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('تم مسح الصورة')", true); }
public void SearchClick(object sender, RoutedEventArgs e) { Button _myButton = (Button)sender; SearchTerm = _myButton.CommandParameter.ToString(); PhotosList.Clear(); LoadSearchResultList(); }
/// <summary> /// Deletes given photo. /// </summary> /// <param name="photoToDelete"></param> public void DeletePhoto(Photo photoToDelete) { //Delete files. File.Delete(photoToDelete.OriginPathThumbnail); File.Delete(photoToDelete.OriginPathFullSize); PhotosList.Remove(photoToDelete); }
/// <summary> /// Update photos list. /// </summary> private void UpdatePhotosList() { //Save path to remove. string pathToRemove = Path.GetDirectoryName(OutputDirPath); //Get files in directory. string[] thumbnailPhotos = Directory.GetFiles(OutputDirPath + "\\Thumbnails", "*", SearchOption.AllDirectories); string[] normalSizePhotos = Directory.GetFiles(OutputDirPath, "*", SearchOption.AllDirectories); //Remove thumbnail photos from normal size photos. foreach (string file in thumbnailPhotos) { normalSizePhotos = normalSizePhotos.Where(val => val != file).ToArray(); } foreach (string fileNormal in normalSizePhotos) { try { //Get file name. string fileNameNormal = Path.GetFileNameWithoutExtension(fileNormal); string fileThumbnail = null; //Find thumbnail file. foreach (var file in thumbnailPhotos) { if (file.Contains(fileNameNormal)) { fileThumbnail = file; break; } } //Get directory name. string parentDirectory = Path.GetDirectoryName(fileNormal); //Get month and year. string month = Path.GetFileName(parentDirectory); string year = Path.GetFileName(Path.GetDirectoryName(parentDirectory)); //Create file path to handle from web. string fileThumbnailPath = @"~\" + fileThumbnail.Replace(pathToRemove, ""); string fileNormalPath = @"~\" + fileNormal.Replace(pathToRemove, ""); //Create new photo. Photo newPhoto = new Photo(fileNameNormal, year, month, fileThumbnailPath, fileNormalPath, fileThumbnail, fileNormal); //Add new photo to list. PhotosList.Add(newPhoto); } catch (Exception ex) { throw new Exception(ex.Message); } } }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (!this._isInitialized) { this._mode = ((Page)this).NavigationContext.QueryString["ViewerMode"]; this._photosCount = int.Parse(((Page)this).NavigationContext.QueryString["PhotosCount"]); this._selectedPhotoIndex = int.Parse(((Page)this).NavigationContext.QueryString["SelectedPhotoIndex"]); string serStr = ((Page)this).NavigationContext.QueryString["Photos"]; this._photosList = new PhotosList(); CacheManager.TryDeserializeFromString((IBinarySerializable)this._photosList, serStr); this._isInitialized = true; } if (this._imageViewerDecorator.IsShown || !this._isLoadedAtLeastOnce) { return; } this.InitializeImageViewerDecorator(); }
protected void ADD_Click(object sender, EventArgs e) { String artID = null; if (Request.QueryString["artID"] != null) { artID = General.b64decode(Request.QueryString["artID"]); } HttpPostedFile pf = File_AddImage.PostedFile; System.Drawing.Image bm = System.Drawing.Image.FromStream(pf.InputStream); bm = General.ResizeBitmap((Bitmap)bm, 200, 200); /// new width, height bm.Save(Server.MapPath("/Images/Articles/" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + File_AddImage.FileName)); //if (File_AddImage.FileName != null) // File_AddImage.PostedFile.SaveAs(Server.MapPath("/Images/Articles/"+ DateTime.Now.ToString("yyyyMMdd_HHmmss")+File_AddImage.FileName)); string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection Conn = new SqlConnection(con)) { SqlCommand cmd = new SqlCommand("dbo.AddPhoto", Conn); //Conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Art_ID", artID); cmd.Parameters.AddWithValue("@Caption", txt_img_caption.Text); cmd.Parameters.AddWithValue("@Path", DateTime.Now.ToString("yyyyMMdd_HHmmss") + File_AddImage.FileName); Conn.Open(); cmd.ExecuteNonQuery(); Conn.Close(); } txt_img_caption.Text = ""; PhotosList.DataBind(); PhotosList.DataBind(); if (PhotosList.Items.Count == 0) { div_show.Visible = false; } else { div_show.Visible = true; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('تم إضافة صورة')", true); } }
protected void Edit_CAP(object sender, EventArgs e) { int index = int.Parse(((Button)sender).CommandArgument.Substring(((Button)sender).CommandArgument.IndexOf("#") + 1)); txt_Photo_cap.Text = ((TextBox)PhotosList.Items[index].FindControl("txt_cap")).Text; string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection Conn = new SqlConnection(con)) { SqlCommand cmd = new SqlCommand("dbo.UpdatePhotoCaption", Conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ((Button)sender).CommandArgument.Substring(0, ((Button)sender).CommandArgument.IndexOf("#"))); cmd.Parameters.AddWithValue("@Caption", txt_Photo_cap.Text); Conn.Open(); cmd.ExecuteNonQuery(); Conn.Close(); } PhotosList.DataBind(); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('تم تعديل النبذة')", true); }
public void SearchQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { SearchTerm = sender.Text; PhotosList.Clear(); LoadSearchResultList(); }