Ejemplo n.º 1
0
        private void textBox_TrackCount_Leave(object sender, EventArgs e)
        {
            try
            {
                if (textBox_TrackCount.Text.Length == 0)
                {
                    theSong.TrackNumber = 0;
                    Error7.SetError(textBox_TrackCount, "");
                }
                else if (Convert.ToInt32(textBox_TrackCount.Text) == 0)
                {
                    theSong.TrackNumber = 0;
                    Error7.SetError(textBox_TrackCount, "");
                }
                else
                {
                    theSong.TrackNumber = Convert.ToInt32(textBox_TrackCount.Text);
                    Error7.SetError(textBox_TrackCount, "");
                }


                if (Convert.ToInt32(textBox_TrackNumber.Text) < Convert.ToInt32(textBox_TrackCount.Text))
                {
                    Error6.SetError(textBox_TrackCount, "");
                    Error5.SetError(textBox_TrackNumber, "");
                }
            }
            catch (FormatException)
            {
                Error7.SetError(textBox_TrackCount, "Invalid Format!");
            }
            catch (Exception Ex)
            {
                Error7.SetError(textBox_TrackCount, Ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void textBox_TrackCount_Leave(object sender, EventArgs e)
 {
     try
     {
         if (textBox_TrackCount.Text.Length == 0)
         {
             theSong.TrackCount = 0;
             Error7.SetError(textBox_TrackCount, "");
         }
         else if (Convert.ToInt32(textBox_TrackCount.Text) >= 1 && Convert.ToInt32(textBox_TrackCount.Text) <= 1000)
         {
             theSong.TrackCount = Convert.ToInt32(textBox_TrackCount.Text);
             Error7.SetError(textBox_TrackCount, "");
         }
         else
         {
             throw new System.ArgumentException();
         }
     }
     catch
     {
         Error7.SetError(textBox_TrackCount, "Your Track Count is invalid...");
     }
 }
Ejemplo n.º 3
0
        private bool IsValid()
        {
            bool valid = true;

            try
            {
                theSong.SongName   = textBox_SongName.Text;
                theSong.ArtistName = textBox_ArtistName.Text;
                theSong.AlbumName  = textBox_AlbumName.Text;
                if (textBox_YearReleased.Text.Length == 0)
                {
                    theSong.YearReleased = 0;
                    Error4.SetError(textBox_YearReleased, "");
                }
                else if (Convert.ToInt32(textBox_YearReleased.Text) >= 1500 && Convert.ToInt32(textBox_YearReleased.Text) <= DateTime.Now.Year)
                {
                    theSong.YearReleased = Convert.ToInt32(textBox_YearReleased.Text);
                    Error4.SetError(textBox_YearReleased, "");
                }
                else
                {
                    throw new System.ArgumentException();
                }

                if (textBox_DurationInSeconds.Text.Length == 0)
                {
                    theSong.DurationInSeconds = 0;
                    Error5.SetError(textBox_DurationInSeconds, "");
                }
                else
                {
                    theSong.DurationInSeconds = Convert.ToInt32(textBox_DurationInSeconds.Text);
                    Error5.SetError(textBox_DurationInSeconds, "");
                }

                if (textBox_TrackNumber.Text.Length == 0)
                {
                    theSong.TrackNumber = 0;
                    Error6.SetError(textBox_TrackNumber, "");
                }
                else if (Convert.ToInt32(textBox_TrackNumber.Text) == 0)
                {
                    theSong.TrackNumber = 0;
                    Error6.SetError(textBox_TrackNumber, "");
                }
                else
                {
                    theSong.TrackNumber = Convert.ToInt32(textBox_TrackNumber.Text);
                    Error6.SetError(textBox_TrackNumber, "");
                }

                if (textBox_TrackCount.Text.Length == 0)
                {
                    theSong.TrackCount = 0;
                    Error7.SetError(textBox_TrackCount, "");
                }
                else
                {
                    theSong.TrackCount = Convert.ToInt32(textBox_TrackCount.Text);
                    Error7.SetError(textBox_TrackCount, "");
                }
            }
            catch
            {
                valid = false;
            }
            return(valid);
        }