コード例 #1
0
        public ICollection<Track> TracksInComposition()
        {
            using (SqlCommand sqlcmd = new SqlCommand())
            {
                List<Track> TracksInComposition = new List<Track>();
                sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString);
                sqlcmd.CommandText = @"
                            SELECT * 
                            FROM Tracks
                            WHERE CompositionId = @compositionid";
                sqlcmd.Parameters.AddWithValue("@compositionid", this.Id);
                sqlcmd.Connection.Open();
                using (var sqlreader = sqlcmd.ExecuteReader())
                {
                    if (sqlreader.HasRows)
                    {
                        while (sqlreader.Read())
                        {
                            Track Track = new Track();
                            Track.Id = (Guid)sqlreader[0];
                            Track.Id = (Guid)sqlreader[0];
                            Track.Composition = (Composition)Composition.FindThisInstanceInDB((Guid)sqlreader[1]);
                            Track.FullName = (string)sqlreader[2];
                            Track.ShortName = (string)sqlreader[3];
                            Track.Family = (InstrumentFamily)Enum.Parse(typeof(InstrumentFamily), (string)sqlreader[4]);
                            Track.Type = (InstrumentType)Enum.Parse(typeof(InstrumentType), (string)sqlreader[5]);
                            Track.Feature = (InstrumentFeature)Enum.Parse(typeof(InstrumentFeature), (string)sqlreader[6]);
                            Track.Color = (string)sqlreader[7];

                            TracksInComposition.Add(Track);
                        }
                    }
                    sqlcmd.Connection.Close();
                    return TracksInComposition;
                }
            }
        }          
コード例 #2
0
        private void mi_AddTrack_Click(object sender, RoutedEventArgs e)
        {
            WindowAddTrack = new WindowAddTrack();
            WindowAddTrack.Owner = this;
            WindowAddTrack.ShowDialog();
            if (WindowAddTrack.DialogResult.HasValue && WindowAddTrack.DialogResult.Value)
            {
                Controller.CreateTrack(Composition, WindowAddTrack.FullName, WindowAddTrack.ShortName, WindowAddTrack.Family, WindowAddTrack.Type, WindowAddTrack.Feature, "Red");
                Track = Controller.FindTrack(WindowAddTrack.FullName);
            }
            TabItem ti = new TabItem();
            ti.Header = Track.ShortName;
            ti.IsSelected = true;
            TabTracks.Items.Add(ti);

        }
コード例 #3
0
ファイル: Track.cs プロジェクト: kirillbeldyaga/GameIntoMusic
 /// <summary>
 /// Search by name
 /// </summary>
 /// <param name="fullname"></param>
 /// <returns></returns>
 public static Track FindThisInstanceInDB(String fullname)
 {
     using (SqlCommand sqlcmd = new SqlCommand())
     {
         Track Track = null;
         sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString);
         sqlcmd.CommandText = "SELECT * FROM Tracks WHERE FullName=@fullname";
         sqlcmd.Parameters.AddWithValue("@fullname", fullname);
         sqlcmd.Connection.Open();
         using (var sqlreader = sqlcmd.ExecuteReader())
         {
             if (sqlreader.HasRows)
             {
                 sqlreader.Read();
                 Track = new Track();
                 Track.Id = (Guid)sqlreader[0];
                 Track.Composition = (Composition)Composition.FindThisInstanceInDB((Guid)sqlreader[1]);
                 Track.FullName = (string)sqlreader[2];
                 Track.ShortName = (string)sqlreader[3];
                 Track.Family = (InstrumentFamily)Enum.Parse(typeof(InstrumentFamily), (string)sqlreader[4]);
                 Track.Type = (InstrumentType)Enum.Parse(typeof(InstrumentType), (string)sqlreader[5]);
                 Track.Feature = (InstrumentFeature)Enum.Parse(typeof(InstrumentFeature), (string)sqlreader[5]);
                 Track.Color = (string)sqlreader[7];
             }
             sqlcmd.Connection.Close();
             return Track;
         }
     }
 }
コード例 #4
0
ファイル: Track.cs プロジェクト: kirillbeldyaga/GameIntoMusic
        /// <summary>
        /// Loading of all instances from database
        /// </summary>
        /// <returns></returns>
        public static List<Track> LoadAllFromDB()
        {
            using (SqlCommand sqlcmd = new SqlCommand())
            {
                List<Track> ListTracks = new List<Track>();
                sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString);
                sqlcmd.CommandText = "SELECT * FROM Tracks";
                sqlcmd.Connection.Open();
                using (var sqlreader = sqlcmd.ExecuteReader())
                {
                    if (sqlreader.HasRows)
                    {
                        while (sqlreader.Read())
                        {
                            var Track = new Track();
                            Track.Id = (Guid)sqlreader[0];
                            Track.Id = (Guid)sqlreader[0];
                            Track.Composition = (Composition)Composition.FindThisInstanceInDB((Guid)sqlreader[1]);
                            Track.FullName = (string)sqlreader[2];
                            Track.ShortName = (string)sqlreader[3];
                            Track.Family = (InstrumentFamily)Enum.Parse(typeof(InstrumentFamily), (string)sqlreader[4]);
                            Track.Type = (InstrumentType)Enum.Parse(typeof(InstrumentType), (string)sqlreader[5]);
                            Track.Feature = (InstrumentFeature)Enum.Parse(typeof(InstrumentFeature), (string)sqlreader[6]);
                            Track.Color = (string)sqlreader[7];
                            ListTracks.Add(Track);

                        }
                    }
                    sqlcmd.Connection.Close();
                    return ListTracks;
                }
            }
        #endregion
        }