/// <summary> /// btnUploadPhotoSave_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUploadPhotoSave_Click(object sender, ImageClickEventArgs e) { try { // Create a new Employee Object _currentUserPhoto = new UsersPhotoDL(); // Set whether Add / Edit //if (hfUserPhotoID.Value.ToString() != "0") //{ //_currentUserPhoto.AddEditOption = 1; //_currentUserPhoto.UserPhotoID = Convert.ToInt32(hfUserPhotoID.Value.ToString()); //} //else //{ //_currentUserPhoto.AddEditOption = 0; //_currentUserPhoto.UserPhotoID = 0; //} _currentUserPhoto.UserID = _userID; _currentUserPhoto.Photo = txtImageURL.Value.ToString(); // Add / Edit the User Photo TransactionResult result; _currentUserPhoto.ScreenMode = ScreenMode.Add; result = _currentUserPhoto.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); //// If successful get and display the saved Company if (result.Status == TransactionStatus.Success) { GetUserPhoto(); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Menu.ascx", "", "btnUploadPhotoSave_Click", ex.Message.ToString(), new ACEConnection()); } }
/// <summary> /// GetUserPhoto /// </summary> private void GetUserPhoto() { try { _currentUserPhoto = new UsersPhotoDL(_userID, true); //hfUserPhotoID.Value = _currentUserPhoto.UserPhotoID.ToString(); string picPath = ""; //if (hfUserPhotoID.Value != "0" && _currentUserPhoto.Photo.ToString() != "") //{ picPath = _currentUserPhoto.Photo.ToString().Replace("../", ""); // } System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(@"~/" + picPath)); if (!fi.Exists) { imgAddPhoto.ImageUrl = "~/images/No_photo.jpg"; // imgPicture.ImageUrl = "~/images/No_photo.jpg"; // btnAddPhoto.Text = "Add Photo"; return; } else { if (_currentUserPhoto.Photo.Trim().Length != 0) { imgAddPhoto.ImageUrl = @"~/" + picPath; //imgPicture.ImageUrl = @"~/" + picPath; // btnAddPhoto.Text = "Change Photo"; } else { imgAddPhoto.ImageUrl = "~/images/No_photo.jpg"; // imgPicture.ImageUrl = "~/images/No_photo.jpg"; // btnAddPhoto.Text = "Add Photo"; } } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Menu.ascx", "", "GetUserPhoto", ex.Message.ToString(), new ACEConnection()); } }