Beispiel #1
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            IList <Injector> injectorList = new List <Injector>();

            IInjectorStorage injectorStorage = new InjectorStorage();

            QueryInjector queryInjector = new QueryInjector();

            queryInjector.InjectorName  = textInjectorName.Text.Trim();
            queryInjector.InjectorSex   = textInjectorSex.Text.Trim();
            queryInjector.InjectorPhone = textInjectorPhone.Text.Trim();

            injectorList = injectorStorage.ListInjector(queryInjector);

            dgvInjector.AutoGenerateColumns = true;
            dgvInjector.DataSource          = injectorList;

            dgvInjector.Columns[0].Visible = false;

            dgvInjector.Columns[1].Width = 130;
            dgvInjector.Columns[2].Width = 130;
            dgvInjector.Columns[3].Width = 125;
            dgvInjector.Columns[4].Width = 130;
            dgvInjector.Columns[5].Width = 130;
        }
        //数据源动态绑定
        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  = "";
        }
        public void InjectorListFailureInjectorArgumentNullException()
        {
            IInjectorStorage injectorStorage = new InjectorStorage();

            injectorStorage.ListInjector(null);
        }
        public void InjectorListSuccess()
        {
            List <Injector> injectorList = new List <Injector>();

            IInjectorStorage injectorStorage = new InjectorStorage();

            Injector myInjector = CreateInjectorForTest(
                "李某某11",
                "男11",
                "17733441111",
                "3",
                "2013-10-09");

            Injector createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            myInjector = CreateInjectorForTest(
                "李某某12",
                "男11",
                "17733441111",
                "3",
                "2013-10-09");

            createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            myInjector = CreateInjectorForTest(
                "李某某12",
                "男12",
                "17733441111",
                "3",
                "2013-10-09");

            createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            myInjector = CreateInjectorForTest(
                "李某某12",
                "男12",
                "17733441112",
                "3",
                "2013-10-09");

            createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            myInjector = CreateInjectorForTest(
                "李某某12",
                "男12",
                "17733441112",
                "2",
                "2013-10-09");

            createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            myInjector = CreateInjectorForTest(
                "李某某12",
                "男12",
                "17733441112",
                "2",
                "2013-11-09");

            createdInjector =
                injectorStorage.CreateInjector(myInjector);

            injectorList.Add(createdInjector);

            QueryInjector queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = null;
            queryInjector.InjectorSex    = null;
            queryInjector.InjectorPhone  = null;
            queryInjector.InjectorNumber = null;
            queryInjector.InjectorTime   = null;

            IList <Injector> readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);

            injectorList.RemoveAt(0);

            queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = "李某某12";
            queryInjector.InjectorSex    = null;
            queryInjector.InjectorPhone  = null;
            queryInjector.InjectorNumber = null;
            queryInjector.InjectorTime   = null;

            readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);

            injectorList.RemoveAt(0);

            queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = null;
            queryInjector.InjectorSex    = "男12";
            queryInjector.InjectorPhone  = null;
            queryInjector.InjectorNumber = null;
            queryInjector.InjectorTime   = null;

            readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);

            injectorList.RemoveAt(0);

            queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = null;
            queryInjector.InjectorSex    = null;
            queryInjector.InjectorPhone  = "17733441112";
            queryInjector.InjectorNumber = null;
            queryInjector.InjectorTime   = null;

            readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);

            injectorList.RemoveAt(0);

            queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = null;
            queryInjector.InjectorSex    = null;
            queryInjector.InjectorPhone  = null;
            queryInjector.InjectorNumber = Convert.ToInt32("2");
            queryInjector.InjectorTime   = null;

            readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);

            injectorList.RemoveAt(0);

            queryInjector = new QueryInjector();

            queryInjector.InjectorID     = null;
            queryInjector.InjectorName   = null;
            queryInjector.InjectorSex    = null;
            queryInjector.InjectorPhone  = null;
            queryInjector.InjectorNumber = null;
            queryInjector.InjectorTime   = Convert.ToDateTime("2013-11-09");

            readedInjectorList =
                injectorStorage.ListInjector(queryInjector);

            AssertInjectorListsEqual(injectorList, readedInjectorList);
        }