protected void btnImgUpdate_Click(object sender, EventArgs e) { int ID = 0; if (int.TryParse(txtGameID.Text, out ID)) { Games_Arena_DB_Context dbContext = new Games_Arena_DB_Context(); StringBuilder errorMessage = new StringBuilder(); string message; Game_Images game_Images = null; try { game_Images = dbContext.Game_Images.FirstOrDefault(x => x.Game_ID == ID); if (ValidateFileUpload(fu_Game_Images_1.PostedFile, out message)) { game_Images.Large_Image_1 = ConvertImageToByte(fu_Game_Images_1.PostedFile); } errorMessage.Append(message); if (ValidateFileUpload(fu_Game_Images_2.PostedFile, out message)) { game_Images.Large_Image_2 = ConvertImageToByte(fu_Game_Images_2.PostedFile); } errorMessage.Append(message); if (ValidateFileUpload(fu_Game_Images_3.PostedFile, out message)) { game_Images.Large_Image_3 = ConvertImageToByte(fu_Game_Images_3.PostedFile); } errorMessage.Append(message); if (ValidateFileUpload(fu_Game_Images_4.PostedFile, out message)) { game_Images.Large_Image_4 = ConvertImageToByte(fu_Game_Images_4.PostedFile); } errorMessage.Append(message); if (ValidateFileUpload(fu_Game_Images_5.PostedFile, out message)) { game_Images.Small_Image = ConvertImageToByte(fu_Game_Images_5.PostedFile); } errorMessage.Append(message); dbContext.SaveChanges(); if (errorMessage.Length > 10) { ErrorMessageImageUploads(errorMessage.ToString(), true); } else { ErrorMessageImageUploads("", false); } GameImages_Select(ID); } catch (Exception ex) { ErrorMessageImageUploads(ex.Message, true); } } else { ErrorMessageImageUploads("ID = " + txtGameID.Text + " Does not Exsist !", true); } }
private void GameImages_Select(int Game_ID) { Games_Arena_DB_Context dbContext = new Games_Arena_DB_Context(); Game_Images game_Images = dbContext.Game_Images.FirstOrDefault(x => x.Game_ID == Game_ID); if (game_Images != null) { Image1.ImageUrl = ""; Image2.ImageUrl = ""; Image3.ImageUrl = ""; Image4.ImageUrl = ""; Image5.ImageUrl = ""; if (game_Images.Large_Image_1 != null) { Image1.ImageUrl = ConvertBytesToImage(game_Images.Large_Image_1); } if (game_Images.Large_Image_2 != null) { Image2.ImageUrl = ConvertBytesToImage(game_Images.Large_Image_2); } if (game_Images.Large_Image_3 != null) { Image3.ImageUrl = ConvertBytesToImage(game_Images.Large_Image_3); } if (game_Images.Large_Image_4 != null) { Image4.ImageUrl = ConvertBytesToImage(game_Images.Large_Image_4); } if (game_Images.Small_Image != null) { Image5.ImageUrl = ConvertBytesToImage(game_Images.Small_Image); } ErrorMessageImageUploads("", false); } else { ErrorMessageImageUploads("ID = " + Game_ID + " Does not Exsist !", true); } }