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");
            }
        }
        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 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();
        }
Example #4
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);
            }
        }