Beispiel #1
0
        public static Stylist Find(int id)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM stylists WHERE id=@id;";
            cmd.Parameters.Add(new MySqlParameter("@id", id));

            MySqlDataReader rdr        = cmd.ExecuteReader() as MySqlDataReader;
            string          tempName   = "";
            int             tempId     = 0;
            string          tempNumber = "";

            while (rdr.Read())
            {
                tempId     = rdr.GetInt32(0);
                tempName   = rdr.GetString(1);
                tempNumber = rdr.GetString(2);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }

            Stylist thisStylist = new Stylist(tempName, tempNumber);

            thisStylist.SetId(tempId);
            return(thisStylist);
        }
Beispiel #2
0
        public static List <Stylist> GetAllStylists()
        {
            List <Stylist> myStylists = 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())
            {
                int     id         = rdr.GetInt32(0);
                string  name       = rdr.GetString(1);
                string  number     = rdr.GetString(2);
                Stylist newStylist = new Stylist(name, number);
                newStylist.SetId(id);
                myStylists.Add(newStylist);
            }

            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }

            return(myStylists);
        }
Beispiel #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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public Stylist GetStylist()
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT stylists.* FROM specialties JOIN specialty_stylist ON (specialties.id = specialty_stylist.specialty_id) JOIN stylists ON (specialty_stylist.stylist_id = stylists.id) WHERE specialties.id = @SpecialtyId;";

            MySqlParameter specialtyId = new MySqlParameter("@SpecialtyId", _id);

            cmd.Parameters.Add(specialtyId);

            MySqlDataReader rdr           = cmd.ExecuteReader() as MySqlDataReader;
            int             id            = 0;
            string          stylistName   = "";
            string          stylistNumber = "";

            while (rdr.Read())
            {
                id            = rdr.GetInt32(0);
                stylistName   = rdr.GetString(1);
                stylistNumber = rdr.GetString(2);
            }
            conn.Dispose();
            Stylist myStylist = new Stylist(stylistName, stylistNumber);

            myStylist.SetId(id);
            return(myStylist);
        }
Beispiel #7
0
        public static List <Stylist> GetAll()
        {
            List <Stylist> allStylists = new List <Stylist> {
            };

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = @"SELECT * FROM `stylists`;";

            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                string  name        = rdr.GetString(0);
                int     id          = rdr.GetInt32(1);
                Stylist nextStylist = new Stylist(name);
                nextStylist.SetId(id);
                allStylists.Add(nextStylist);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }

            return(allStylists);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public static Stylist Find(int id = 0)
        {
            string foundName = "Id Not Found";

            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM `stylists` WHERE id = @searchId;";
            MySqlParameter searchId = new MySqlParameter();

            searchId.ParameterName = "@searchId";
            searchId.Value         = id;
            cmd.Parameters.Add(searchId);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                foundName = rdr.GetString(0);
            }
            Stylist wantedStylist = new Stylist(foundName);

            wantedStylist.SetId(id);
            return(wantedStylist);
        }
        public static Stylist Find(int searchId)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM stylists WHERE id = @searchId;";
            cmd.Parameters.AddWithValue("@searchId", searchId);
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            rdr.Read();
            int     id           = rdr.GetInt32(0);
            string  name         = rdr.GetString(1);
            string  bio          = rdr.GetString(2);
            Stylist foundStylist = new Stylist(name, bio);

            foundStylist.SetId(id);
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }

            return(foundStylist);
        }
Beispiel #11
0
        public static List <Stylist> StylistsWithSpeciality(Speciality inputSpeciality)
        {
            List <Stylist> stylistOutput = new List <Stylist> {
            };
            MySqlConnection conn         = DB.Connection();

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

            cmd.CommandText = @"SELECT stylists.* FROM specialities JOIN stylists_specialities ON (specialities.id = stylists_specialities.speciality_id) JOIN stylists ON (stylists_specialities.stylist_id = stylists.id) WHERE specialities.id = @SpecialityId;";

            MySqlParameter specialityId = new MySqlParameter();

            specialityId.ParameterName = "@SpecialityId";
            specialityId.Value         = inputSpeciality.GetId();
            cmd.Parameters.Add(specialityId);

            var rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int     stylistId   = (int)rdr.GetInt32(0);
                string  stylistName = rdr.GetString(1);
                Stylist myStylist   = new Stylist(stylistName);
                myStylist.SetId(stylistId);
                stylistOutput.Add(myStylist);
            }

            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(stylistOutput);
        }
Beispiel #12
0
        public static Stylist Find(int id)
        {
            Query findStylist = new Query("SELECT (name) FROM stylists WHERE stylist_id = @Id");

            findStylist.AddParameter("@Id", id.ToString());
            var    rdr  = findStylist.Read();
            string name = "";

            while (rdr.Read())
            {
                name = rdr.GetString(0);
            }
            Stylist found = new Stylist(name);

            found.SetId(id);
            return(found);
        }
Beispiel #13
0
        public static List <Stylist> GetAll()
        {
            Query          getStylists = new Query("SELECT * FROM stylists");
            List <Stylist> stylistList = new List <Stylist> {
            };
            var rdr = getStylists.Read();

            while (rdr.Read())
            {
                int    stylistId   = rdr.GetInt32(0);
                string stylistName = rdr.GetString(1);

                Stylist newStylist = new Stylist(stylistName);
                newStylist.SetId(stylistId);
                stylistList.Add(newStylist);
            }
            return(stylistList);
        }