private void btnSelect_Click(object sender, EventArgs e)
        {
            IList <InjectionMessage> injectionMessageList = new List <InjectionMessage>();

            IInjectionMessageStorage injectionMessageStorage = new InjectionMessageStorage();

            IInjectorStorage injectorStorage = new InjectorStorage();

            IVaccineStorage vaccineStorage = new VaccineStorage();

            QueryInjectionMessage queryInjectionMessage = new QueryInjectionMessage();

            #region pspselect
            if (cmbInjectorName.Text.Trim() != "" && cmbVaccineName.Text.Trim() != "")
            {
                queryInjectionMessage.InjectorID             = Convert.ToInt32(cmbInjectorName.SelectedValue.ToString());
                queryInjectionMessage.VaccineID              = Convert.ToInt32(cmbVaccineName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else if (cmbInjectorName.Text.Trim() == "" && cmbVaccineName.Text.Trim() != "")
            {
                queryInjectionMessage.VaccineID              = Convert.ToInt32(cmbVaccineName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else if (cmbInjectorName.Text.Trim() != "" && cmbVaccineName.Text.Trim() == "")
            {
                queryInjectionMessage.InjectorID             = Convert.ToInt32(cmbInjectorName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else
            {
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            #endregion

            injectionMessageList = injectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            foreach (InjectionMessage injectionMessage in injectionMessageList)                 //对injectionMessageList数组遍历
            {
                injectionMessage.InjectorName = (injectorStorage.ReadInjector(injectionMessage.InjectorID)).InjectorName;
                injectionMessage.VaccineName  = (vaccineStorage.ReadVaccine(injectionMessage.VaccineID)).VaccineName;
            }

            dgvInjectionMessage.AutoGenerateColumns = true;
            dgvInjectionMessage.DataSource          = injectionMessageList;

            dgvInjectionMessage.Columns[0].Visible = false;
            dgvInjectionMessage.Columns[1].Visible = false;
            dgvInjectionMessage.Columns[3].Visible = false;

            dgvInjectionMessage.Columns[2].Width = 130;
            dgvInjectionMessage.Columns[4].Width = 130;
            dgvInjectionMessage.Columns[5].Width = 130;
            dgvInjectionMessage.Columns[6].Width = 130;
            dgvInjectionMessage.Columns[7].Width = 130;
        }
        public void InjectionMessageListFailureInjectionMessageArgumentNullException()
        {
            IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage();

            pInjectionMessageStorage.ListInjectionMessage(null);
        }
        public void InjectionMessageListSuccess()
        {
            List <InjectionMessage> injectionMessageList = new List <InjectionMessage>();

            IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage();
            IInjectorStorage         pInjectorStorage         = new InjectorStorage();
            IVaccineStorage          pVaccineStorage          = new VaccineStorage();

            int pgetInjectorID = getInjectorID();
            int pgetVaccineID  = getVaccineID();

            InjectionMessage myInjectionMessage = CreateInjectionMessageForTest(
                pgetInjectorID,
                pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName,
                pgetVaccineID,
                pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            InjectionMessage createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            pgetInjectorID = getInjectorID();

            myInjectionMessage = CreateInjectionMessageForTest(
                pgetInjectorID,
                pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            pgetVaccineID = getVaccineID();

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                pgetVaccineID,
                pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-04-25",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-04-25",
                "欧阳医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            QueryInjectionMessage queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            IList <InjectionMessage> readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = createdInjectionMessage.InjectorID;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = createdInjectionMessage.VaccineID;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = "海口市中医院";
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = Convert.ToDateTime("2016-04-25");
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = "欧阳医生";

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);
        }