コード例 #1
0
        public void AddDonor(Donor newDonor)
        {
            MySqlConnection conn = DB.Connection();

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

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

            MySqlParameter donor_id = new MySqlParameter();

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

            MySqlParameter bloodBank_id = new MySqlParameter();

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

            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
コード例 #2
0
ファイル: Donor.cs プロジェクト: denniseortega/blood_bank
        public override bool Equals(System.Object otherDonor)
        {
            if (!(otherDonor is Donor))
            {
                return(false);
            }
            else
            {
                Donor newDonor              = (Donor)otherDonor;
                bool  idEquality            = this.GetId() == newDonor.GetId();
                bool  nameEquality          = this.GetName() == newDonor.GetName();
                bool  contactEquality       = this.GetContact() == newDonor.GetContact();
                bool  dateOfBirthEquality   = this.GetDateOfBirth() == newDonor.GetDateOfBirth();
                bool  bloodTypeEquality     = this.GetBloodType() == newDonor.GetBloodType();
                bool  medicalRecordEquality = this.GetMedicalRecord() == newDonor.GetMedicalRecord();

                return(idEquality && nameEquality && contactEquality && dateOfBirthEquality && bloodTypeEquality && medicalRecordEquality);
            }
        }