public Track(Composition composition, string fullname, string shortname, InstrumentFamily family, InstrumentType type, InstrumentFeature feature, string color) { this.Composition = composition; this.FullName = fullname; this.ShortName = shortname; this.Instrument = new Instrument(family, type, feature); this.Family = family; this.Type = type; this.Feature = feature; this.Color = color; this.SaveToDB(); }
public Track(Composition composition, string fullname, string shortname, InstrumentFamily family, InstrumentType type, InstrumentFeature feature, string color) { this.Id = Guid.NewGuid(); this.Composition = composition; this.FullName = fullname; this.ShortName = shortname; this.Family = family.ToString(); this.Type = type.ToString(); this.Feature = feature.ToString(); this.Instrument = new Instrument(family, type, feature); this.Color = color; this.Notes = new List<Note>(); this.Save(); }
private void New_composition_Click(object sender, RoutedEventArgs e) { WindowAddComposition = new WindowAddComposition(); WindowAddComposition.Owner = this; WindowAddComposition.ShowDialog(); if (WindowAddComposition.DialogResult.HasValue && WindowAddComposition.DialogResult.Value) { Controller.CreateComposition(WindowAddComposition.Title, WindowAddComposition.Subtitle, WindowAddComposition.Words, WindowAddComposition.Music, WindowAddComposition.Tabs, WindowAddComposition.Copyright, WindowAddComposition.Notice, WindowAddComposition.Album, WindowAddComposition.Artist, User); Composition = Controller.FindComposition(WindowAddComposition.Title); TabItem ti = new TabItem(); ti.Header = Composition.Title; ti.IsSelected = true; TabCompositions.Items.Add(ti); } }
public ICollection<Composition> Composition() { using (SqlCommand sqlcmd = new SqlCommand()) { List<Composition> CompositionsOfUser = new List<Composition>(); sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); sqlcmd.CommandText = @" SELECT * FROM Compositions WHERE UserId = @userid"; sqlcmd.Parameters.AddWithValue("@userid", this.Id); sqlcmd.Connection.Open(); using (var sqlreader = sqlcmd.ExecuteReader()) { if (sqlreader.HasRows) { while (sqlreader.Read()) { Composition composition = new Composition(); composition.Id = (Guid)sqlreader[0]; //composition.User = (User)User.FindThisInstanceInDB((Guid)sqlreader[1]); sqlreader[i+1]; composition.Album = (Album)Album.FindThisInstanceInDB((Guid)sqlreader[1]); composition.Artist = (Artist)Artist.FindThisInstanceInDB((Guid)sqlreader[2]); composition.Title = (string)sqlreader[3]; composition.Subtitle = (string)sqlreader[4]; composition.Words = (string)sqlreader[5]; composition.Music = (string)sqlreader[6]; composition.Tabs = (string)sqlreader[7]; composition.Copyright = (string)sqlreader[8]; composition.Notice = (string)sqlreader[9]; //Composition.DateCreated = (DateTime)sqlreader[9]; CompositionsOfUser.Add(composition); } } sqlcmd.Connection.Close(); return CompositionsOfUser; } } }
private void TabCompositions_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { TabControl TabControl = sender as TabControl; TabItem SelectedTabItem = TabControl.SelectedItem as TabItem; this.Composition = Composition.Find(SelectedTabItem.Header.ToString()); TabTracks.Items.Clear(); foreach (Track NTrack in Composition.TracksInComposition()) { TabItem ti = new TabItem(); ti.Header = NTrack.ShortName; ti.IsSelected = true; TabTracks.Items.Add(ti); } } catch { } }
private void mi_Open_Composition_Click(object sender, RoutedEventArgs e) { WindowOpenComposition = new WindowOpenComposition(CurrentUser); WindowOpenComposition.Owner = this; WindowOpenComposition.ShowDialog(); if (WindowOpenComposition.DialogResult.HasValue && WindowOpenComposition.DialogResult.Value) { Composition = WindowOpenComposition.Composition; TabItem ti = new TabItem(); ti.Header = Composition.Title; ti.IsSelected = true; TabCompositions.Items.Add(ti); } }
private void lb_Compositions_SelectionChanged(object sender, SelectionChangedEventArgs e) { Composition = (Composition)lb_Compositions.SelectedItem; // Title = Composition.Title; // tb_Title.Text = Title; }
public WindowInformation(Composition SelectedComposition) { InitializeComponent(); CompositionInformation = SelectedComposition; }
/// <summary> /// Loading of all instances from database /// </summary> /// <returns></returns> public static List<Composition> LoadAllFromDB() { using (SqlCommand sqlcmd = new SqlCommand()) { List<Composition> ListCompositions = new List<Composition>(); sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); sqlcmd.CommandText = "SELECT * FROM Compositions"; sqlcmd.Connection.Open(); using (var sqlreader = sqlcmd.ExecuteReader()) { if (sqlreader.HasRows) { while (sqlreader.Read()) { var Composition = new Composition(); Composition.Id = (Guid)sqlreader[0]; Composition.Album = (Album)Album.FindThisInstanceInDB((Guid)sqlreader[1]); Composition.Artist = (Artist)Artist.FindThisInstanceInDB((Guid)sqlreader[2]); Composition.Title = (string)sqlreader[3]; Composition.Subtitle = (string)sqlreader[4]; Composition.Words = (string)sqlreader[5]; Composition.Music = (string)sqlreader[6]; Composition.Tabs = (string)sqlreader[7]; Composition.Copyright = (string)sqlreader[8]; Composition.Notice = (string)sqlreader[9]; //Composition.DateCreated = (DateTime)sqlreader[9]; //album.DateReleased = Convert.ToDateTime((string)sqlreader[2]); ListCompositions.Add(Composition); } } sqlcmd.Connection.Close(); return ListCompositions; } } #endregion }
/// <summary> /// Search by id /// </summary> /// <param name="id"></param> /// <returns></returns> public static Composition FindThisInstanceInDB(Guid id) { using (SqlCommand sqlcmd = new SqlCommand()) { Composition Composition = null; sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); sqlcmd.CommandText = "SELECT * FROM Compositions WHERE Id=@id"; sqlcmd.Parameters.AddWithValue("@id", id); sqlcmd.Connection.Open(); using (var sqlreader = sqlcmd.ExecuteReader()) { if (sqlreader.HasRows) { sqlreader.Read(); Composition = new Composition(); Composition.Id = (Guid)sqlreader[0]; Composition.Album = (Album)Album.FindThisInstanceInDB((Guid)sqlreader[1]); Composition.Artist = (Artist)Artist.FindThisInstanceInDB((Guid)sqlreader[2]); Composition.Title = (string)sqlreader[3]; Composition.Subtitle = (string)sqlreader[4]; Composition.Words = (string)sqlreader[5]; Composition.Music = (string)sqlreader[6]; Composition.Tabs = (string)sqlreader[7]; Composition.Copyright = (string)sqlreader[8]; Composition.Notice = (string)sqlreader[9]; //Composition.DateCreated = (DateTime)sqlreader[9]; } sqlcmd.Connection.Close(); return Composition; } } }