Пример #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 List <Stylist> GetListOfStylists()
        {
            List <Stylist> allStylists = new List <Stylist> {
            };
            MySqlConnection conn       = DB.Connection();

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

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

            while (rdr.Read())
            {
                Stylist newStylist = new Stylist();
                newStylist.SetId(rdr.GetInt32(0));
                newStylist.SetName(rdr.GetString(1));
                newStylist.SetDescription(rdr.GetString(2));
                newStylist.SetTimestamp(rdr.GetDateTime(3));
                allStylists.Add(newStylist);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allStylists);
        }
Пример #3
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);
        }
Пример #4
0
        public static Stylist Find(int id)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM `stylists` WHERE id = '" + id + "';";
            var     rdr          = cmd.ExecuteReader() as MySqlDataReader;
            Stylist foundStylist = new Stylist();

            while (rdr.Read())
            {
                int      stylistId          = rdr.GetInt32(0);
                string   stylistName        = rdr.GetString(1);
                string   stylistDescription = rdr.GetString(2);
                DateTime timestamp          = rdr.GetDateTime(3);
                foundStylist.SetId(stylistId);
                foundStylist.SetName(stylistName);
                foundStylist.SetDescription(stylistDescription);
                foundStylist.SetTimestamp(timestamp);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(foundStylist);
        }