public ViewAssetPageControl(FormMain form, int?userAssetID) { formMain = form; _userAssetID = userAssetID; DataBaseAccess dataBase = new DataBaseAccess(); dataBase.StartConnection(); _userAsset = dataBase.getAsset((int)userAssetID); dataBase.CloseConnection(); _curUserData = formMain.UsersAccounts.GetCurrentUser(); InitializeComponent(); if (formMain.UsersAccounts.GetCurrentUser() != null) { if (_userAsset == null) { formMain.ChangeToPage(FormMain.Pages.HomePage); } else { if (_curUserData.GetUserID() == _userAsset.GetAuthor().GetUserID()) { btnEdit.Show(); } } } galPictureGallery.SetToLarge(); galPictureGallery.IsEditable(false); galPictureGallery.AddPicturesToGallery(_userAsset.GetPicturesPath()); pictureBox1.ImageLocation = _userAsset.GetThumbNail(); lblTitleDisplay.Text = _userAsset.GetAssetTitle(); lblAssetTypeDisplay.Text = _userAsset.GetAssetType().ToString(); lblSoftwareDisplay.Text = _userAsset.GetSoftwareUsed(); lblPegiDisplay.Text = _userAsset.GetPegiRating().ToString(); lblAssetStatusDisplay.Text = _userAsset.GetAssetStatus().ToString(); lblCreatorDisplay.Text = _userAsset.GetAuthor().userName; lblDescription.Text = _userAsset.GetNotes(); starOverall._canSetRating = false; if (_curUserData == null) { starRating.Visible = false; lblRatingMessage.Visible = false; } else { starRating.valueChangedEvent += rating_Click; } }
public EditAssetPageControl(FormMain form, int?userAssetID) { _userAssetID = userAssetID; DataBaseAccess dataBase = new DataBaseAccess(); dataBase.StartConnection(); _curUserAsset = dataBase.getAsset((int)userAssetID); dataBase.CloseConnection(); InitializeComponent(); pictureGallery1.InitializePictureGallery((int)_curUserAsset.GetAuthor().GetUserID(), (int)_userAssetID); formMain = form; if (formMain.UsersAccounts.GetCurrentUser() != null) { if (_curUserAsset == null || userAssetID == null) { MessageBox.Show("Error: Asset Not Found"); } else { txtTitle.Text = _curUserAsset.GetAssetTitle(); cboAssetType.SelectedIndex = (int)_curUserAsset.GetAssetType(); txtSoftwareUsed.Text = _curUserAsset.GetSoftwareUsed(); cboPegi.SelectedIndex = (int)_curUserAsset.GetPegiRating(); cboAssetStatus.SelectedIndex = (int)_curUserAsset.GetAssetStatus() - 1; txtNotes.Text = _curUserAsset.GetNotes(); pictureGallery1.AddPicturesToGallery(_curUserAsset.GetPicturesPath()); picThumbnail.ImageLocation = _curUserAsset.GetThumbNail(); _userAsset.SetAssetTitle(_curUserAsset.GetAssetTitle()); _userAsset.SetAssetStatus(_curUserAsset.GetAssetStatus()); _userAsset.SetAssetType(_curUserAsset.GetAssetType()); _userAsset.SetSoftwareUsed(_curUserAsset.GetSoftwareUsed()); _userAsset.SetPegiRating(_curUserAsset.GetPegiRating()); _userAsset.SetNotes(_curUserAsset.GetNotes()); } } else { MessageBox.Show("Error: No user logged in"); } }