示例#1
0
        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());
        }
示例#2
0
        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();
        }
示例#3
0
        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();
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }