Пример #1
0
        public static List <Stylist> GetAll()
        {
            List <Stylist> allItems = new List <Stylist> {
            };
            MySqlConnection conn    = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM stylists order by level desc;";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                Stylist newItem = new Stylist();
                newItem.SetName(rdr.GetString(1));
                newItem.SetId(rdr.GetInt32(0));
                newItem.SetDescription(rdr.GetString(2));
                newItem.SetLevel(rdr.GetInt32(3));
                newItem.SetHair(rdr.GetInt32(4));
                newItem.SetScissors(rdr.GetInt32(5));
                newItem.SetScissorsName(rdr.GetString(6));
                allItems.Add(newItem);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allItems);
        }
Пример #2
0
        public static Stylist Find(int check)
        {
            Stylist         ret  = new Stylist();
            MySqlConnection conn = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM stylists where id = " + check + ";";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            rdr.Read();
            if (rdr.IsDBNull(0) == false)
            {
                ret.SetName(rdr.GetString(1));
                ret.SetId(rdr.GetInt32(0));
                ret.SetDescription(rdr.GetString(2));
                ret.SetLevel(rdr.GetInt32(3));
                ret.SetHair(rdr.GetInt32(4));
                ret.SetScissors(rdr.GetInt32(5));
                ret.SetScissorsName(rdr.GetString(6));
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(ret);
        }