コード例 #1
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;
     }
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }