private void mi_Log_Click(object sender, RoutedEventArgs e) { if (!Signing) { Login Login = new Login(); Login.Owner = this; Login.ShowDialog(); if (Login.DialogResult.HasValue && Login.DialogResult.Value) { User = Login.LoginingUser; mi_Log.Header = "Log out"; mi_Account.Header = User.UserName; } } else if (Signing) { User = new User(); mi_Log.Header = "Log in"; mi_Account.Header = "Log in!"; } }
public static List<User> Load() { using (SqlCommand sqlcmd = new SqlCommand()) { List<User> ListUsers = new List<User>(); sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); sqlcmd.CommandText = "SELECT * FROM Users"; sqlcmd.Connection.Open(); using (var sqlreader = sqlcmd.ExecuteReader()) { if (sqlreader.HasRows) { while (sqlreader.Read()) { var User = new User(); User.Id = (Guid)sqlreader[0]; User.FirstName = (string)sqlreader[1]; User.LastName = (string)sqlreader[2]; User.UserName = (string)sqlreader[3]; User.Password = (string)sqlreader[4]; User.Email = (string)sqlreader[5]; ListUsers.Add(User); } } sqlcmd.Connection.Close(); return ListUsers; } } }
public WindowOpenComposition(User User) { InitializeComponent(); CurrentUser = User; }
public static User Find(Guid id) { using (SqlCommand sqlcmd = new SqlCommand()) { User User = null; sqlcmd.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); sqlcmd.CommandText = "SELECT * FROM Users WHERE Id = @id"; sqlcmd.Parameters.AddWithValue("@id", id); sqlcmd.Connection.Open(); using (var sqlreader = sqlcmd.ExecuteReader()) { if (sqlreader.HasRows) { sqlreader.Read(); User = new User(); User.Id = (Guid)sqlreader[0]; User.FirstName = (string)sqlreader[1]; User.LastName = (string)sqlreader[2]; User.UserName = (string)sqlreader[3]; User.Password = (string)sqlreader[4]; User.Email = (string)sqlreader[5]; } } sqlcmd.Connection.Close(); return User; } }
/// <summary> /// Loading of all instances from database /// </summary> /// <returns></returns> public static List<Composition> Load() { 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()) { Composition Composition = new Composition(); Composition = new Composition(); Composition.Id = (Guid)sqlreader[0]; Composition.Title = (string)sqlreader[1]; Composition.Subtitle = (string)sqlreader[2]; Composition.Words = (string)sqlreader[3]; Composition.Music = (string)sqlreader[4]; Composition.Tabs = (string)sqlreader[5]; Composition.Copyright = (string)sqlreader[6]; Composition.Notice = (string)sqlreader[7]; Composition.Album = (Album)Album.FindThisInstanceInDB((Guid)sqlreader[8]); Composition.Artist = (Artist)Artist.FindThisInstanceInDB((Guid)sqlreader[9]); Composition.Author = (User)User.Find((Guid)sqlreader[10]); //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 Find(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 = new Composition(); Composition.Id = (Guid)sqlreader[0]; Composition.Title = (string)sqlreader[1]; Composition.Subtitle = (string)sqlreader[2]; Composition.Words = (string)sqlreader[3]; Composition.Music = (string)sqlreader[4]; Composition.Tabs = (string)sqlreader[5]; Composition.Copyright = (string)sqlreader[6]; Composition.Notice = (string)sqlreader[7]; Composition.Album = (Album)Album.FindThisInstanceInDB((Guid)sqlreader[8]); Composition.Artist = (Artist)Artist.FindThisInstanceInDB((Guid)sqlreader[9]); Composition.Author = (User)User.Find((Guid)sqlreader[10]); //Composition.DateCreated = (DateTime)sqlreader[9]; } sqlcmd.Connection.Close(); return Composition; } } }
public Composition(string title, string subtitle, string words, string music, string tabs, string copyright, string notice, Album album, Artist artist, User author)//, DateTime datecreated) { this.Id = Guid.NewGuid(); this.Title = title; this.Subtitle = subtitle; this.Words = words; this.Music = music; this.Tabs = tabs; this.Copyright = copyright; this.Notice = notice; //this.DateCreated = datecreated; this.Album = album; this.Artist = artist; this.Author = author; this.Save(); }
public Composition() { this.Title = ""; this.Subtitle = ""; this.Words = ""; this.Music = ""; this.Tabs = ""; this.Copyright = ""; this.Notice = ""; //this.DateCreated = DateTime.Now; this.Album = null; this.Artist = null; this.Author = null; }