Inheritance: NSWindow
Example #1
0
        private void addSongButton_Click(object sender, EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            if (!formHelper.TextBoxHasContents(addSongTxtBoxSongGenre))
            {
                MessageBox.Show("Please enter a genre.", "Input validation error");
                addSongTxtBoxSongGenre.Focus();
            }
            else
            {
                var newGenre = addSongTxtBoxSongGenre.Text.Trim();
                var genres = repository.SearchGenreByGenreName(newGenre);

                if (genres.Count > 0)
                {
                    MessageBox.Show("You wanted to add " + newGenre + ", but " + genres[0].GenreName + " already exsists.", "Genre must be unique");
                    addSongTxtBoxSongGenre.Focus();
                }
                else
                {
                    CreatedGenre = repository.CreateGenre(addSongTxtBoxSongGenre.Text.Trim());
                    Close();
                }
            }
        }
Example #2
0
        private void updateSongButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            int songRating = 0;

            //Check if textbox has an int and it is between 0 and 5 (inclusive)
            if (int.TryParse(updateSongTextBox.Text.Trim(), out songRating) && songRating >= 0 && songRating <= 5)
            {
                //if AlbumTitle not provided assing null to album
                var albums = AlbumTitleOfSong != null ? repository.SearchAlbumsByAlbumTitleExclusive(AlbumTitleOfSong) : null;
                //Send update to reposistory based on whether album name provided
                if (AlbumTitleOfSong == null)
                    repository.UpdateSongRating(SongTitleToUpdate, songRating);

                else
                    repository.UpdateSongRating(SongTitleToUpdate, songRating, albums[0]);
                Close();
            }
            else
            {
                MessageBox.Show("Please enter a rating can only be between 1 and 5", "Input validation error");
                updateSongTextBox.Focus();
                DialogResult = DialogResult.None;
            }
        }
Example #3
0
        private void findAlbumButton_Click(object sender, EventArgs e)
        {
            var formHelper = new FormHelper();

            if (findAlbumRadioButtonByAlbumName.Checked && formHelper.TextBoxHasContents(findAlbumTxtBoxAlbumName))
            {
                FoundAlbums = repository.SearchAlbumsByAlbumTitle(findAlbumTxtBoxAlbumName.Text);
                if (FoundAlbums.Count == 0)
                { 
                    MessageBox.Show("Unable to locate any matching albumns.");
                    DialogResult = DialogResult.None;
                }
            else
                Close();
            }
            else
            {
                FoundAlbums = repository.SearchAlbumsByArtistName(((Artist)findAlbumComboBoxArtist.SelectedItem).ArtistName);
                if (FoundAlbums.Count == 0)
                {
                    MessageBox.Show("Unable to locate any matching albumns.");
                    DialogResult = DialogResult.None;
                }
                else
                    Close();
            }
                //TODO: Move Close(); to here
        }
Example #4
0
        private void addArtistButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            if (!formHelper.TextBoxHasContents(addArtistTxtBoxArtistName))
            {
                MessageBox.Show("Please enter an artist name.", "Input validation error");
                addArtistTxtBoxArtistName.Focus();
            }
            else
            {
                var newArtist = addArtistTxtBoxArtistName.Text.Trim();
                var artists = repository.SearchArtistByArtistNameExclusive(newArtist);

                if (artists.Count > 0)
                {
                    MessageBox.Show("You wanted to add " + newArtist + ", but " + artists[0].ArtistName + " already exsists.", "Artist must be unique");
                    addArtistTxtBoxArtistName.Focus();
                }
                else
                {
                    CreatedArtist = repository.CreateArtist(addArtistTxtBoxArtistName.Text.Trim());
                    this.Close();
                }
            }
        }
Example #5
0
        private void findSongButton_Click(object sender, EventArgs e)
        {
            var formHelper = new FormHelper();

            //Check if form is used to find song or song and album
            if (FindBothSongAndAlbum)
            {
                var processor = new ProcessSongAlbumAggregator();
                if (findSongRadioButtonBySongTitle.Checked)
                {
                    FoundAlbumsAndSongs = processor.FindSongOrAlbumByTitle(findSongTextBoxSongTitle.Text.Trim());
                }
                //if searching by aritst
                else if (findSongRadioButtonByArtist.Checked)
                {
                    FoundAlbumsAndSongs = processor.FindSongOrAlbumByArtist(((Artist)findSongComboBoxArtist.SelectedItem).ArtistName);
                }
                //if searching by genre
                else
                {
                    FoundAlbumsAndSongs = processor.FindSongOrAlbumByGenre(((Genre)findSongComboBoxGenre.SelectedItem).GenreName);
                }
                //if no results were returnd show message box and prevent dialog from closing
                if (FoundAlbumsAndSongs.Count == 0)
                {
                    MessageBox.Show("Unable to locate any matching Albums or Songs.");
                    DialogResult = DialogResult.None;
                }
                else
                    Close();
            }
            else
            {
                //if searching by song title 
                if (findSongRadioButtonBySongTitle.Checked)
                {
                    FoundSongs = repository.SearchSongsBySongTitle(findSongTextBoxSongTitle.Text.Trim());
                }
                //if searching by aritst
                else if (findSongRadioButtonByArtist.Checked)
                {
                    FoundSongs = repository.SearchSongsByArtistName(((Artist)findSongComboBoxArtist.SelectedItem).ArtistName);
                }
                //if searching by genre
                else
                {
                    FoundSongs = repository.SearchSongsByGenreName(((Genre)findSongComboBoxGenre.SelectedItem).GenreName);
                }
                //if no results were returnd show message box and prevent dialog from closing
                if (FoundSongs.Count == 0)
                {
                    MessageBox.Show("Unable to locate any matching songs.");
                    DialogResult = DialogResult.None;
                }
                else
                    Close();
            }
        }
Example #6
0
        private void createPlaylistButton_Click(object sender, System.EventArgs e)
        {
            var formHelper = new FormHelper();
            int playlistLengthInMinutes;

            //Check that a number was entered into the textbox
            if (int.TryParse(createPlaylistTextBox.Text.Trim(), out playlistLengthInMinutes))
            {
                Playlist = repository.GeneratePlaylist(playlistLengthInMinutes);
                Close();
            }
            else
            {
                //if no number entered, display error message and prevent form from closing.
                MessageBox.Show("Please enter the number of minutes you'd like the playlist to be in length.", "Input validation error");
                DialogResult = DialogResult.None;
            }
        }
Example #7
0
        private void updateAlbumButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            int albumRating = 0;

            if (int.TryParse(updateAlbumTextBox.Text.Trim(), out albumRating) && albumRating >= 0 && albumRating <= 5)
            {
                repository.UpdateAlbumRating(AlbumTitle, albumRating, AlbumArtist);
                Close();
            }
            else
            {
                MessageBox.Show("Please enter a rating can only be between 1 and 5", "Input validation error");
                updateAlbumTextBox.Focus();
                DialogResult = DialogResult.None;
            }
        }
Example #8
0
        private void findGenreButton_Click(object sender, System.EventArgs e)
        {
            var formHelper = new FormHelper();

            if (formHelper.TextBoxHasContents(FindGenreTextBox))
            {
                FoundGenres = repository.SearchGenreByGenreName(FindGenreTextBox.Text);
                if (FoundGenres.Count > 0)
                {
                    Close();
                }
                else
                {
                    MessageBox.Show("Unable to locate any matching genres.");
                    DialogResult = DialogResult.None;
                }
            }
            else
            {
                MessageBox.Show("Please enter a genre.", "Data validation error");
                DialogResult = DialogResult.None;
            }
        }
Example #9
0
        private void InitData()
        {
            AuditGridInit();

            FormHelper gen = new FormHelper();

            gen.GenerateForm("CForm_FAuditHistory", this.pnlMain, new Point(6, 20));

            RejectBackNode = adInstance.GetVerifyTemplateRejectBack(ModuleCode, CurNode);

            MethodInvoker mm = new MethodInvoker(GetNextNode);

            mm.BeginInvoke(null, null);
        }
		protected override void CreateHandle ()
		{
			m_helper = new FormHelper (this, new RectangleF (50, 50, 400, 400), (NSWindowStyle)(1 | (1 << 1) | (1 << 2) | (1 << 3)), NSBackingStore.Buffered, false);
			m_helper.ContentView = new ViewHelper (this);
      		m_view = m_helper.ContentView;
			//m_helper.ContentView.ScaleUnitSquareToSize(Util.ScaleSize);
			m_helper.AcceptsMouseMovedEvents = true;
      base.CreateHandle();
		}
Example #11
0
        private void Employee_Load(object sender, EventArgs e)
        {
            FormHelper gen = new FormHelper();
            BindModelHelper helper = new BindModelHelper();
            //表单生成
            gen.GenerateForm("FEmp", this.groupBox1, new Point(6, 20));
            gen.GenerateForm("FOEmp", this.panel2, new Point(6, 20));
            gen.GenerateForm("FCEmp", this.panel1, new Point(6, 20));

            switch (operationType)
            {
                case OperationTypeEnum.Look:
                    this.btnSave.Enabled = false;
                    break;

            }

            //编辑或添加判断
            if (EmplyeeModel != null)
            {

                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.groupBox1.Controls, "");
                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.panel1.Controls, "");
                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.panel2.Controls, "");
            }
            else
            {
                EmplyeeModel = new Bse_Employee();
                //EmplyeeModel.Emp_Code = EmployeeInstance.GenerateEmpCode();
                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.groupBox1.Controls, "");
                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.panel1.Controls, "");
                helper.BindModelToControl<Bse_Employee>(EmplyeeModel, this.panel2.Controls, "");
            }

            btnSave.Click += new EventHandler(btnSave_Click);
            //btnOk.Click += new EventHandler(btnOk_Click);
            //Emp_Dept_Code.Click += new EventHandler(Emp_Dept_Code_Click);
            //Emp_Dept_Name.Click += new EventHandler(Emp_Dept_Code_Click);
            btnCancle.Click += new EventHandler(btnCancle_Click);

            //LoadDict();
        }