Пример #1
0
        public void AddBloodBank(BloodBank newBloodBank)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"INSERT INTO donors_bloodbanks (bloodBank_id, donor_id) VALUES (@BloodBankId, @DonorId);";

            MySqlParameter bloodBank_id = new MySqlParameter();

            bloodBank_id.ParameterName = "@BloodBankId";
            bloodBank_id.Value         = newBloodBank.GetId();
            cmd.Parameters.Add(bloodBank_id);

            MySqlParameter donor_id = new MySqlParameter();

            donor_id.ParameterName = "@DonorId";
            donor_id.Value         = _id;
            cmd.Parameters.Add(donor_id);

            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Пример #2
0
        public override bool Equals(System.Object otherBloodBank)
        {
            if (!(otherBloodBank is BloodBank))
            {
                return(false);
            }
            else
            {
                BloodBank newBloodBank    = (BloodBank)otherBloodBank;
                bool      idEquality      = this.GetId() == newBloodBank.GetId();
                bool      nameEquality    = this.GetName() == newBloodBank.GetName();
                bool      contactEquality = this.GetContact() == newBloodBank.GetContact();
                bool      addressEquality = this.GetAddress() == newBloodBank.GetAddress();


                return(idEquality && nameEquality && contactEquality && addressEquality);
            }
        }