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