示例#1
0
        // public void AddClient(Client c){ MyClients.Add(c); }

        public void AddSpecialty(Specialty newSpecialty)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"INSERT INTO stylists_specialties (stylist_ID, specialty_ID) VALUES (@stylistID, @specialtyID);";
            MySqlParameter stylist_ID = new MySqlParameter();

            stylist_ID.ParameterName = "@stylistID";
            stylist_ID.Value         = MyID;
            cmd.Parameters.Add(stylist_ID);
            MySqlParameter specialty_ID = new MySqlParameter();

            specialty_ID.ParameterName = "@specialtyID";
            specialty_ID.Value         = newSpecialty.GetID();
            cmd.Parameters.Add(specialty_ID);
            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
示例#2
0
        public void AddSpecialty(Specialty specialty)
        {
            if (specialty.GetID() == -1 || _id == -1)
            {
                throw new Exception("Can't add a specialty unless both objects are saved;");
            }

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = $"INSERT INTO stylists_specialties (stylist_id, specialty_id) VALUES ({_id}, {specialty.GetID()});";

            cmd.ExecuteNonQuery();

            DB.Close(conn);
        }
示例#3
0
 public override bool Equals(System.Object otherSpecialty)
 {
     if (!(otherSpecialty is Specialty))
     {
         return(false);
     }
     else
     {
         Specialty newSpecialty      = (Specialty)otherSpecialty;
         bool      specialtyEquality = (this.GetDescription() == newSpecialty.GetDescription() && this.GetID() == newSpecialty.GetID());
         return(specialtyEquality);
     }
 }