//数据源动态绑定
        private void InjectionMessageForm_Load(object sender, EventArgs e)
        {
            IList <Injector> injectorList    = new List <Injector>();
            IInjectorStorage injectorStorage = new InjectorStorage();
            QueryInjector    queryInjector   = new QueryInjector();

            IList <Vaccine> vaccineList    = new List <Vaccine>();
            IVaccineStorage vaccineStorage = new VaccineStorage();
            QueryVaccine    queryVaccine   = new QueryVaccine();

            injectorList = injectorStorage.ListInjector(queryInjector);
            vaccineList  = vaccineStorage.ListVaccine(queryVaccine);

            cmbInjectorName.DataSource = injectorList;
            DataTable dtInjector = new DataTable();

            cmbVaccineName.DataSource = vaccineList;
            DataTable dtVaccine = new DataTable();

            dtInjector.Columns.Add("InjectorID", typeof(System.Int32));
            dtInjector.Columns.Add("InjectorName", typeof(System.String));

            dtVaccine.Columns.Add("VaccineID", typeof(System.Int32));
            dtVaccine.Columns.Add("VaccineName", typeof(System.String));

            foreach (Injector pInjectorlist in injectorList)
            {
                dtInjector.Rows.Add(
                    pInjectorlist.InjectorID,
                    pInjectorlist.InjectorName
                    );
            }

            foreach (Vaccine pVaccinelist in vaccineList)
            {
                dtVaccine.Rows.Add(
                    pVaccinelist.VaccineID,
                    pVaccinelist.VaccineName
                    );
            }

            cmbInjectorName.DisplayMember = Convert.ToString(dtInjector.Columns[1]);
            cmbInjectorName.ValueMember   = Convert.ToString(dtInjector.Columns[0]);

            cmbVaccineName.DisplayMember = Convert.ToString(dtVaccine.Columns[1]);
            cmbVaccineName.ValueMember   = Convert.ToString(dtVaccine.Columns[0]);

            cmbInjectorName.Text = "";
            cmbVaccineName.Text  = "";
        }
Exemple #2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            IList <Vaccine> vaccineList = new List <Vaccine>();

            IVaccineStorage vaccineStorage = new VaccineStorage();

            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            QueryVaccine queryVaccine = new QueryVaccine();

            if (cmbManufacturersName.Text.Trim() == "")
            {
                queryVaccine.VaccineName = textVaccineName.Text.Trim();
                queryVaccine.VaccineSort = textVaccineSort.Text.Trim();
            }
            else
            {
                queryVaccine.VaccineName     = textVaccineName.Text.Trim();
                queryVaccine.VaccineSort     = textVaccineSort.Text.Trim();
                queryVaccine.ManufacturersID = Convert.ToInt32(cmbManufacturersName.SelectedValue.ToString());
            }

            vaccineList = vaccineStorage.ListVaccine(queryVaccine);

            foreach (Vaccine vaccine in vaccineList)                 //对vaccineList数组遍历
            {
                vaccine.ManufacturersName = (manufacturersStorage.ReadManufacturers(vaccine.ManufacturersID)).ManufacturersName;
            }

            dgvVaccine.AutoGenerateColumns = true;
            dgvVaccine.DataSource          = vaccineList;

            dgvVaccine.Columns[0].Visible = false;
            dgvVaccine.Columns[3].Visible = false;

            dgvVaccine.Columns[1].Width = 130;
            dgvVaccine.Columns[2].Width = 130;
            dgvVaccine.Columns[4].Width = 130;
            dgvVaccine.Columns[5].Width = 130;
            dgvVaccine.Columns[6].Width = 130;
        }
Exemple #3
0
        public void VaccineListFailureVaccineArgumentNullException()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();

            vaccineStorage.ListVaccine(null);
        }
Exemple #4
0
        public void VaccineListSuccess()
        {
            List <Vaccine> vaccineList = new List <Vaccine>();

            IVaccineStorage vaccineStorage = new VaccineStorage();

            Vaccine myVaccine = CreateVaccineForTest(
                "狂犬疫苗11",
                "处方11",
                getManufacturersID(),
                "68.00",
                "45");

            Vaccine createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方11",
                createdVaccine.ManufacturersID,
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                getManufacturersIDtwo(),
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "72.80",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "72.80",
                "60");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            QueryVaccine queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            IList <Vaccine> readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = "狂犬疫苗12";
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = "处方12";
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = createdVaccine.ManufacturersID;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = Convert.ToDecimal("72.80");
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = Convert.ToInt32("60");

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);
        }