Example #1
0
        private void btnUploadAsset_Click(object sender, EventArgs e)
        {
            bool errorDetected = false;

            if (txtTitle.Text == string.Empty)
            {
                lblErrorTitle.Show();
                errorDetected = true;
            }
            if (cboProjectType.SelectedIndex < 0)
            {
                lblErrorAssetType.Show();
                errorDetected = true;
            }

            if (errorDetected == false)
            {
                DataBaseAccess dataBase = new DataBaseAccess();
                dataBase.StartConnection();
                formMain.curSelectedUserProjectID = dataBase.AddProject(_userProject.GetProjectTitle(), _userProject.GetProjectType(), _userProject.GetNotes(), (int)formMain.UsersAccounts.GetCurrentUser().GetUserID(), ProjectTag.Game, ProjectStatus.In_Development);
                dataBase.CloseConnection();

                formMain.ChangeToPage(FormMain.Pages.EditProjectPage);
            }
        }
        public MyAssetsPageControl(FormMain form, string message)
        {
            InitializeComponent();
            formMain = form;
            DataBaseAccess dataBase = new DataBaseAccess();

            dataBase.StartConnection();
            if (message == "project")
            {
                curUserProjects = dataBase.getOwnedProjectsOfUser((int)formMain.UsersAccounts.GetCurrentUser().GetUserID());
            }
            else if (message == "asset")
            {
                curUserAssets = dataBase.getAssetsOfUser((int)formMain.UsersAccounts.GetCurrentUser().GetUserID());
            }
            dataBase.CloseConnection();

            if (curUserAssets != null && message == "asset")
            {
                HelperTools.CreateAssetButtons(new Point(48, 104), formMain, this, curUserAssets.Count, 5, curUserAssets);
            }
            else if (curUserProjects != null && message == "project")
            {
                HelperTools.CreateAssetButtons(new Point(48, 104), formMain, this, curUserProjects.Count, 5, null, curUserProjects);
            }
        }
        public EditProjectPageControl(FormMain form, int?curUserProjectID)
        {
            InitializeComponent();
            formMain          = form;
            _curUserProjectID = curUserProjectID;

            if (formMain.UsersAccounts.GetCurrentUser() != null)
            {
                DataBaseAccess dataBase = new DataBaseAccess();
                dataBase.StartConnection();
                _curUserProject = dataBase.getProject((int)curUserProjectID);
                dataBase.CloseConnection();

                if (curUserProjectID == null || _curUserProject == null)
                {
                    MessageBox.Show("Error: Asset Not Found");
                }
                else
                {
                    txtTitle.Text = _curUserProject.GetProjectTitle();
                    cboProjectType.SelectedIndex = (int)_curUserProject.GetProjectType();
                    txtNotes.Text = _curUserProject.GetNotes();
                    picThumbnail.ImageLocation = _curUserProject.GetThumbNail();

                    _userProject.SetProjectTitle(_curUserProject.GetProjectTitle());
                    _userProject.SetProjectType(_curUserProject.GetProjectType());
                    _userProject.SetNotes(_curUserProject.GetNotes());
                }
            }
            else
            {
                MessageBox.Show("Error: No user logged in");
            }
        }
Example #4
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (!isAccountInfoEditable)
     {
         txtEmail.ReadOnly     = false;
         txtName.ReadOnly      = false;
         btnEdit.Text          = "Confirm Changes!";
         isAccountInfoEditable = true;
     }
     else
     {
         txtEmail.ReadOnly = true;
         txtName.ReadOnly  = true;
         DataBaseAccess dataBaseAccess = new DataBaseAccess();
         dataBaseAccess.StartConnection();
         if (txtEmail.Text.Contains('@') && formMain.UsersAccounts.RetrieveUserData(txtEmail.Text) == null)
         {
             dataBaseAccess.ChangeUserEmail(_currentUser.userName, txtEmail.Text);
         }
         if (txtName.Text.Count() >= 1 && txtName.Text.Count() < 12)
         {
             dataBaseAccess.ChangeUserFullName((int)_currentUser.GetUserID(), txtName.Text);
         }
         formMain.UsersAccounts.SetCurrentUser(dataBaseAccess.GetUser((int)_currentUser.GetUserID()));
         dataBaseAccess.CloseConnection();
         btnEdit.Text          = "Edit User Information";
         isAccountInfoEditable = false;
     }
 }
        public void AddUser(UserData _userData)
        {
            DataBaseAccess dataBase = new DataBaseAccess();

            dataBase.StartConnection();
            dataBase.AddUser(_userData._password, _userData.emailAddress, _userData.userName, UserType.Developer, _userData.fullName);
            dataBase.CloseConnection();
        }
Example #6
0
        private void btnChangeProfilePic_Click(object sender, EventArgs e)
        {
            string         file           = HelperTools.LoadFromFile();
            string         databasePath   = HelperTools.AddFileToStorage(file, (int)_currentUser.GetUserID());
            DataBaseAccess dataBaseAccess = new DataBaseAccess();

            dataBaseAccess.StartConnection();
            dataBaseAccess.ChangeUserProfile((int)_currentUser.GetUserID(), databasePath);
            dataBaseAccess.CloseConnection();
        }
        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 UserData RetrieveUserData(string UsernameOrEmail)
        {
            DataBaseAccess dataBase = new DataBaseAccess();

            dataBase.StartConnection();
            UserData userData = dataBase.GetUser(UsernameOrEmail);

            dataBase.CloseConnection();
            if (userData != null)
            {
                return(userData);
            }
            return(null);
        }
        private void updateOverallRating(object sender, EventArgs e)
        {
            DataBaseAccess database = new DataBaseAccess();

            database.StartConnection();

            // update the average stars

            int averageStars  = (int)Math.Round(database.GetAverageStarRating(_userAsset.GetID()));
            int numberRatings = database.GetAmountOfRatingsForAsset(_userAsset.GetID());

            starOverall.UpdateStarsGraphics(averageStars);
            lblRatingTotal.Text = numberRatings + " People Rated This Overall";
            database.CloseConnection();
        }
        private void btnUploadAsset_Click(object sender, EventArgs e)
        {
            bool errorDetected = false;

            if (txtTitle.Text == string.Empty)
            {
                lblErrorTitle.Show();
                errorDetected = true;
            }
            if (cboAssetType.SelectedIndex < 0)
            {
                lblErrorAssetType.Show();
                errorDetected = true;
            }
            if (txtSoftwareUsed.Text == string.Empty)
            {
                lblErrorSoftwareUsed.Show();
                errorDetected = true;
            }
            if (cboPegi.SelectedIndex < 0)
            {
                lblErrorPegi.Show();
                errorDetected = true;
            }
            if (cboAssetType.SelectedIndex < 0)
            {
                lblErrorAssetStatus.Show();
                errorDetected = true;
            }
            if (_assetUploaded == false)
            {
                lblErrorAssetStatus.Show();
                errorDetected = true;
            }

            if (errorDetected == false)
            {
                DataBaseAccess dataBase = new DataBaseAccess();
                dataBase.StartConnection();
                int assetDatabaseID = dataBase.AddAsset(_userAsset.GetAssetTitle(), (int)formMain.UsersAccounts.GetCurrentUser().GetUserID(), _userAsset.GetAssetStatus(), _userAsset.GetAssetType(), _userAsset.GetSoftwareUsed(), _userAsset.GetNotes(), "", _userAsset.GetPegiRating());
                dataBase.ChangeAssetPath(assetDatabaseID, HelperTools.AddFileToStorage(_assetFilePath, (int)_curUserID, assetDatabaseID));
                dataBase.CloseConnection();

                formMain.curSelectedAssetID = assetDatabaseID;

                formMain.ChangeToPage(FormMain.Pages.EditAssetPage);
            }
        }
        private void btnConfirmChanges_Click(object sender, EventArgs e)
        {
            bool errorDetected = false;

            if (txtTitle.Text == string.Empty || txtTitle.Text == "Title")
            {
                lblErrorTitle.Show();
                errorDetected = true;
            }
            if (cboProjectType.SelectedIndex < 0)
            {
                lblErrorProjectType.Show();
                errorDetected = true;
            }

            if (errorDetected == false)
            {
                DataBaseAccess dataBase = new DataBaseAccess();
                dataBase.StartConnection();
                if (_curUserProject.GetProjectTitle() != _userProject.GetProjectTitle())
                {
                    dataBase.ChangeProjectName((int)_curUserProjectID, _userProject.GetProjectTitle());
                }

                if (_curUserProject.GetProjectType() != _userProject.GetProjectType())
                {
                    dataBase.ChangeProjectType((int)_curUserProjectID, _userProject.GetProjectType());
                }

                if (_curUserProject.GetNotes() != _userProject.GetNotes())
                {
                    dataBase.ChangeProjectDescription((int)_curUserProjectID, _userProject.GetNotes());
                }

                if (_thumbNailPic != null)
                {
                    dataBase.ChangeProjectThumbnail((int)_curUserProjectID, _thumbNailPic);
                }

                dataBase.CloseConnection();

                formMain.curSelectedUserProjectID = _curUserProjectID;
                formMain.ChangeToPage(FormMain.Pages.ViewProjectPage);
            }
        }
        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");
            }
        }
        private void txtSearchAsset_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (_assetButtons != null)
                {
                    for (int i = 0; i < _assetButtons.Count; i++)
                    {
                        _assetButtons[i].Dispose();
                        this.Controls.Remove(_assetButtons[i]);
                    }
                }

                DataBaseAccess data = new DataBaseAccess();
                data.StartConnection();
                List <UserAsset> userAssets = data.SearchAsset(txtSearchAsset.Text);
                data.CloseConnection();
                _assetButtons = HelperTools.CreateAssetButtons(new Point(160, 150), formMain, this, userAssets.Count(), 2, userAssets);
            }
        }
        public ViewProjectPageControl(FormMain form, int?userProjectID)
        {
            InitializeComponent();

            formMain = form;

            _userProjectID = userProjectID;

            DataBaseAccess dataBase = new DataBaseAccess();

            dataBase.StartConnection();
            _userProject = dataBase.getProject((int)userProjectID);
            dataBase.CloseConnection();

            _curUserData = formMain.UsersAccounts.GetCurrentUser();
            InitializeComponent();

            if (formMain.UsersAccounts.GetCurrentUser() != null)
            {
                if (_userProject == null)
                {
                    formMain.ChangeToPage(FormMain.Pages.HomePage);
                }
                else
                {
                    if (_curUserData.GetUserID() == _userProject.GetAuthor().GetUserID())
                    {
                        btnEdit.Show();
                    }
                }
            }

            lblTitleDisplay.Text       = _userProject.GetProjectTitle();
            lblAssetTypeDisplay.Text   = _userProject.GetProjectType().ToString();
            lblCreatorDisplay.Text     = _userProject.GetAuthor().userName;
            lblDescriptionDisplay.Text = _userProject.GetNotes();
            picThumbNail.ImageLocation = _userProject.GetThumbNail();
            picThumbNail.Show();
        }
        private void rating_Click(object sender, EventArgs e)
        {
            DataBaseAccess database = new DataBaseAccess();

            database.StartConnection();

            // if already added a rating then change it
            if (database.UserRatedAsset((int)_curUserData.GetUserID(), _userAsset.GetID()))
            {
                int ratingId = -1;

                List <Classes.UserRating> ratingsOfAsset = database.GetRatingsOfAsset(_userAsset.GetID());

                // get the rating id of the previous rating
                for (int i = 0; i < ratingsOfAsset.Count; i++)
                {
                    if (ratingsOfAsset[i].ReviewerID == _curUserData.GetUserID())
                    {
                        ratingId = ratingsOfAsset[i].ID;
                        break;
                    }
                }

                if (ratingId != -1)
                {
                    database.ChangeRatingStars(ratingId, starRating._rating);
                }
            }
            // if not rated yet then add rating
            else
            {
                database.AddRating((int)_curUserData.GetUserID(), _userAsset.GetID(), starRating._rating, "");
            }

            updateOverallRating(sender, e);
            database.CloseConnection();
        }
        private void btnConfirmChanges_Click(object sender, EventArgs e)
        {
            bool errorDetected = false;

            if (txtTitle.Text == string.Empty || txtTitle.Text == "Title")
            {
                lblErrorTitle.Show();
                errorDetected = true;
            }
            if (cboAssetType.SelectedIndex < 0)
            {
                lblErrorAssetType.Show();
                errorDetected = true;
            }
            if (txtSoftwareUsed.Text == string.Empty || txtSoftwareUsed.Text == "Software Used")
            {
                lblErrorSoftwareUsed.Show();
                errorDetected = true;
            }
            if (cboPegi.SelectedIndex < 0)
            {
                lblErrorPegi.Show();
                errorDetected = true;
            }
            if (cboAssetStatus.SelectedIndex < 0)
            {
                lblErrorAssetStatus.Show();
                errorDetected = true;
            }

            if (errorDetected == false)
            {
                DataBaseAccess dataBase = new DataBaseAccess();
                dataBase.StartConnection();
                if (_curUserAsset.GetAssetTitle() != _userAsset.GetAssetTitle())
                {
                    dataBase.ChangeAssetName((int)_userAssetID, _userAsset.GetAssetTitle());
                }

                if (_curUserAsset.GetAssetType() != _userAsset.GetAssetType())
                {
                    dataBase.ChangeAssetType((int)_userAssetID, _userAsset.GetAssetType());
                }

                if (_curUserAsset.GetSoftwareUsed() != _userAsset.GetSoftwareUsed())
                {
                    dataBase.ChangeAssetSoftware((int)_userAssetID, _userAsset.GetSoftwareUsed());
                }

                if (_curUserAsset.GetAssetStatus() != _userAsset.GetAssetStatus())
                {
                    dataBase.ChangeAssetStatus((int)_userAssetID, _userAsset.GetAssetStatus());
                }

                if (_curUserAsset.GetNotes() != _userAsset.GetNotes())
                {
                    dataBase.ChangeAssetNotes((int)_userAssetID, _userAsset.GetNotes());
                }

                if (_thumbNailPic != null)
                {
                    dataBase.ChangeAssetThumbnail((int)_userAssetID, _thumbNailPic);
                }

                List <string> tempPictureHolder = pictureGallery1.GetPicturesPathFromGallery();
                _curUserAsset.SetPicturesPath(tempPictureHolder);
                if (tempPictureHolder.Count >= 1)
                {
                    dataBase.ChangeAssetGalleryOne((int)_userAssetID, tempPictureHolder[0]);
                }
                if (tempPictureHolder.Count >= 2)
                {
                    dataBase.ChangeAssetGalleryTwo((int)_userAssetID, tempPictureHolder[1]);
                }
                if (tempPictureHolder.Count >= 3)
                {
                    dataBase.ChangeAssetGalleryThree((int)_userAssetID, tempPictureHolder[2]);
                }
                if (tempPictureHolder.Count >= 4)
                {
                    dataBase.ChangeAssetGalleryFour((int)_userAssetID, tempPictureHolder[3]);
                }
                if (tempPictureHolder.Count >= 5)
                {
                    dataBase.ChangeAssetGalleryFive((int)_userAssetID, tempPictureHolder[4]);
                }

                dataBase.CloseConnection();


                formMain.curSelectedAssetID = _userAssetID;
                formMain.ChangeToPage(FormMain.Pages.ViewAssetPage);
            }
        }