}//end of valid() private void txtDuration_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9) && (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9) && e.KeyCode != Keys.Back) { ErrorDuration.SetError(txtDuration, "Duration must be positive integer!"); e.SuppressKeyPress = true; } else { ErrorDuration.Clear(); } }
public bool valid() { bool isError = false; if (txtID.Text.Equals("")) { ErrorID.SetError(txtID, "ID must not be empty!"); isError = true; } if (txtAlbum.Text.Equals("")) { ErrorAlbum.SetError(txtAlbum, "Album must not be empty!"); isError = true; } if (txtSinger.Text.Equals("")) { ErrorSinger.SetError(txtSinger, "Singer must not be empty!"); isError = true; } if (listSongs.Items.Count == 0) { ErrorSong.SetError(listSongs, "You must add at least one song"); isError = true; } if (isError) { return(false); } else { ErrorID.Clear(); ErrorAlbum.Clear(); ErrorDuration.Clear(); ErrorSinger.Clear(); ErrorSong.Clear(); return(true); } }//end of valid()