public static List <Stylist> GetAll() { string orderBy = "id"; string order = "ASC"; List <Object> objects = new List <Object>() { }; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM " + _tableName + " ORDER BY " + orderBy + " " + order + ";"); DB.ReadTable(DelegateGetAll, objects); DB.CloseConnection(); return(objects.Cast <Stylist>().ToList()); }
public void AddSpecialty(Specialty newSpecialty) { string columns = "speciltyId,stylistId"; List <string> valueNames = new List <string>() { "@SpecialtyId,@StylistId" }; List <Object> values = new List <Object>() { newSpecialty.GetId(), _id }; DB.OpenConnection(); DB.SaveToTable(_tableName, columns, valueNames, values); DB.CloseConnection(); }
public void Save() { string columns = "name"; List <string> valueNames = new List <string>() { "@Name" }; List <Object> values = new List <Object>() { _name }; DB.OpenConnection(); DB.SaveToTable(_tableName, columns, valueNames, values); _id = DB.LastInsertId(); DB.CloseConnection(); }
public static Stylist Find(int id) { int stylistId = -1; string name = ""; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM stylists WHERE id=@thisId;"); DB.AddParameter("@thisId", id); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { stylistId = rdr.GetInt32(0); name = rdr.GetString(1); } DB.CloseConnection(); return(new Stylist(name, stylistId)); }
public static Specialty Find(int id) { int sid = -1; string specialty = ""; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM " + _tableName + " WHERE id=@thisId;"); DB.AddParameter("@thisId", id); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { sid = rdr.GetInt32(0); specialty = rdr.GetString(1); } DB.CloseConnection(); return(new Specialty(specialty, sid)); }
public List <Specialty> GetSpecialties(string orderBy = "id", string order = "ASC") { List <Specialty> specialties = new List <Specialty>() { }; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM " + _tableRelational + " WHERE stylistId=@thisId ORDER BY " + orderBy + " " + order + ";"); DB.AddParameter("@thisId", _id); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { Specialty newSpeciality = Specialty.Find(rdr.GetInt32(1)); specialties.Add(newSpeciality); } DB.CloseConnection(); return(specialties); }
public static List <Stylist> GetStylists(int id, string orderBy = "id", string order = "ASC") { List <Stylist> stylists = new List <Stylist>() { }; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM " + _tableRelational + " WHERE specialtyId=@thisId ORDER BY " + orderBy + " " + order + ";"); DB.AddParameter("@thisId", id); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { Stylist newStylist = Stylist.Find(rdr.GetInt32(2)); stylists.Add(newStylist); } DB.CloseConnection(); return(stylists); }
public static List <Specialty> GetAll(string orderBy = "id", string order = "ASC") { List <Specialty> specialties = new List <Specialty>() { }; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM " + _tableName + " ORDER BY " + orderBy + " " + order + ";"); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { int id = rdr.GetInt32(0); string specialty = rdr.GetString(1); Specialty newSpeciality = new Specialty(specialty, id); specialties.Add(newSpeciality); } DB.CloseConnection(); return(specialties); }
public List <Client> GetClients(string orderBy = "id", string order = "ASC") { List <Client> clients = new List <Client>() { }; DB.OpenConnection(); DB.SetCommand(@"SELECT * FROM clients WHERE stylistId=@Id ORDER BY " + orderBy + " " + order + ";"); DB.AddParameter("@Id", _id); MySqlDataReader rdr = DB.ReadSqlCommand(); while (rdr.Read()) { int id = rdr.GetInt32(0); string name = rdr.GetString(2); Client newClient = new Client(name, _id, id); clients.Add(newClient); } DB.CloseConnection(); return(clients); }