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

            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            QueryManufacturers queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersName  = textManufacturersName.Text.Trim();
            queryManufacturers.ManufacturersSite  = textManufacturersSite.Text.Trim();
            queryManufacturers.ManufacturersPhone = textManufacturersPhone.Text.Trim();

            manufacturersList = manufacturersStorage.ListManufacturers(queryManufacturers);

            dgvManufacturers.AutoGenerateColumns = true;
            dgvManufacturers.DataSource          = manufacturersList;

            dgvManufacturers.Columns[0].Visible = false;

            dgvManufacturers.Columns[1].Width = 130;
            dgvManufacturers.Columns[2].Width = 130;
            dgvManufacturers.Columns[3].Width = 125;
            dgvManufacturers.Columns[4].Width = 130;
            dgvManufacturers.Columns[5].Width = 130;
        }
Exemplo n.º 2
0
        public void ManufacturersUpdateSuccessFive()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                "供应商4",
                "浙江温州4",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            Assert.AreNotEqual(
                0,
                createdManufacturers.ManufacturersID,
                string.Format("Could not create Manufacturers:{0}",
                              createdManufacturers.ManufacturersID));

            myManufacturers.ManufacturersDoe = Convert.ToDateTime("2016-06-30");

            manufacturersStorage.UpdateManufacturers(myManufacturers);

            Manufacturers updatedManufacturers = manufacturersStorage.ReadManufacturers(
                createdManufacturers.ManufacturersID);

            AssertManufacturersItemEqual(myManufacturers, updatedManufacturers);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         manufacturers        = new Manufacturers();

            if (textManufacturersName.Text.Trim() == "" || textManufacturersSite.Text.Trim() == "" ||
                textManufacturersPhone.Text.Trim() == "" || dtpManufacturersDom.Text.Trim() == "" ||
                dtpManufacturersDoe.Text.Trim() == "")
            {
                MessageBox.Show("请输入全部信息,不要有遗漏。");
            }
            else
            {
                manufacturers.ManufacturersName  = textManufacturersName.Text.Trim();
                manufacturers.ManufacturersSite  = textManufacturersSite.Text.Trim();
                manufacturers.ManufacturersPhone = textManufacturersPhone.Text.Trim();
                manufacturers.ManufacturersDom   = Convert.ToDateTime(dtpManufacturersDom.Text.Trim());
                manufacturers.ManufacturersDoe   = Convert.ToDateTime(dtpManufacturersDoe.Text.Trim());

                manufacturersStorage.CreateManufacturers(manufacturers);

                MessageBox.Show("增加成功!");

                textManufacturersName.Text  = "";
                textManufacturersSite.Text  = "";
                textManufacturersPhone.Text = "";
                dtpManufacturersDom.Text    = "";
                dtpManufacturersDoe.Text    = "";
            }
        }
        private void btnModfiy_Click(object sender, EventArgs e)
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         manufacturers        = new Manufacturers();

            if (textManufacturersName.Text.Trim() == "" || textManufacturersSite.Text.Trim() == "" ||
                textManufacturersPhone.Text.Trim() == "" || dtpManufacturersDom.Text.Trim() == "" ||
                dtpManufacturersDoe.Text.Trim() == "")
            {
                MessageBox.Show("请双击需要修改的记录!");
            }
            else
            {
                manufacturers.ManufacturersName  = textManufacturersName.Text;
                manufacturers.ManufacturersSite  = textManufacturersSite.Text;
                manufacturers.ManufacturersPhone = textManufacturersPhone.Text;
                manufacturers.ManufacturersDom   = Convert.ToDateTime(dtpManufacturersDom.Text);
                manufacturers.ManufacturersDoe   = Convert.ToDateTime(dtpManufacturersDoe.Text);
                manufacturers.ManufacturersID    = Convert.ToInt32(dgvManufacturers[0, dgvManufacturers.CurrentCell.RowIndex].Value.ToString());

                manufacturersStorage.UpdateManufacturers(manufacturers);

                MessageBox.Show("更新成功!");

                textManufacturersName.Text  = "";
                textManufacturersSite.Text  = "";
                textManufacturersPhone.Text = "";
                dtpManufacturersDom.Text    = "";
                dtpManufacturersDoe.Text    = "";
            }
        }
        public static int getVaccineID()
        {
            IManufacturersStorage pManufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers       = CreateManufacturersForTest(
                "供应商",
                "浙江温州",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                pManufacturersStorage.CreateManufacturers(myManufacturers);


            IVaccineStorage pVaccineStorage = new VaccineStorage();
            Vaccine         myVaccine       = CreateVaccineForTest(
                "狂犬疫苗",
                "处方",
                createdManufacturers.ManufacturersID,
                "68.00",
                "45");

            Vaccine createdVaccine =
                pVaccineStorage.CreateVaccine(myVaccine);

            return(createdVaccine.VaccineID);
        }
Exemplo n.º 6
0
        public void ManufacturersCreateFailureManufacturersNameArgumentNullException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                null,
                "浙江温州2",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            manufacturersStorage.CreateManufacturers(myManufacturers);
        }
Exemplo n.º 7
0
        public void ManufacturersCreateFailureManufacturersSiteArgumentException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                "供应商1",
                "",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            manufacturersStorage.CreateManufacturers(myManufacturers);
        }
Exemplo n.º 8
0
        public void ManufacturersReadFailureManufacturersIdArgumentException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            //    Manufacturers myManufacturers = CreateManufacturersForTest(
            //    "供应商3",
            //    "浙江温州3",
            //    "17733117779",
            //    "2013-06-30",
            //    "2016-06-30");

            //    Manufacturers createdManufacturers =
            //    manufacturersStorage.CreateManufacturers(myManufacturers);
            manufacturersStorage.ReadManufacturers(-1);
        }
Exemplo n.º 9
0
        private static int getManufacturersIDtwo()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                "供应商21",
                "浙江温州21",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            return(createdManufacturers.ManufacturersID);
        }
Exemplo n.º 10
0
        public void ManufacturersUpdateFailureManufacturersIdArgumentException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                "供应商4",
                "浙江温州4",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            manufacturersStorage.CreateManufacturers(myManufacturers);

            myManufacturers.ManufacturersID = int.MaxValue;

            manufacturersStorage.UpdateManufacturers(myManufacturers);
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        public void ManufacturersCreateSuccess()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers      = CreateManufacturersForTest(
                "供应商",
                "浙江温州",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            Assert.AreNotEqual(
                0,
                createdManufacturers.ManufacturersID,
                string.Format("Could not create Manufacturers:{0}",
                              createdManufacturers.ManufacturersID));

            AssertManufacturersItemEqual(myManufacturers, createdManufacturers);
        }
Exemplo n.º 13
0
        //这个属性其实非常有用处,它表明这个函数会抛出一个预期的异常。
        public void ManufacturersCreateFailureManufacturersArgumentNullException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            manufacturersStorage.CreateManufacturers(null);
        }
Exemplo n.º 14
0
        public void ManufacturersListFailureManufacturersArgumentNullException()
        {
            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            manufacturersStorage.ListManufacturers(null);
        }
Exemplo n.º 15
0
        public void ManufacturersListSuccess()
        {
            List <Manufacturers> manufacturersList = new List <Manufacturers>();

            IManufacturersStorage manufacturersStorage = new ManufacturersStorage();

            Manufacturers myManufacturers = CreateManufacturersForTest(
                "供应商11",
                "浙江温州11",
                "17733117711",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            myManufacturers = CreateManufacturersForTest(
                "供应商12",
                "浙江温州11",
                "17733117711",
                "2013-06-30",
                "2016-06-30");

            createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            myManufacturers = CreateManufacturersForTest(
                "供应商12",
                "浙江温州12",
                "17733117711",
                "2013-06-30",
                "2016-06-30");

            createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            myManufacturers = CreateManufacturersForTest(
                "供应商12",
                "浙江温州12",
                "17733117712",
                "2013-06-30",
                "2016-06-30");

            createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            myManufacturers = CreateManufacturersForTest(
                "供应商12",
                "浙江温州12",
                "17733117712",
                "2013-06-29",
                "2016-06-30");

            createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            myManufacturers = CreateManufacturersForTest(
                "供应商12",
                "浙江温州12",
                "17733117712",
                "2013-06-29",
                "2016-06-29");

            createdManufacturers =
                manufacturersStorage.CreateManufacturers(myManufacturers);

            manufacturersList.Add(createdManufacturers);

            QueryManufacturers queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = null;
            queryManufacturers.ManufacturersSite  = null;
            queryManufacturers.ManufacturersPhone = null;
            queryManufacturers.ManufacturersDom   = null;
            queryManufacturers.ManufacturersDoe   = null;

            IList <Manufacturers> readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);

            manufacturersList.RemoveAt(0);

            queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = "供应商12";
            queryManufacturers.ManufacturersSite  = null;
            queryManufacturers.ManufacturersPhone = null;
            queryManufacturers.ManufacturersDom   = null;
            queryManufacturers.ManufacturersDoe   = null;

            readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);

            manufacturersList.RemoveAt(0);

            queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = null;
            queryManufacturers.ManufacturersSite  = "浙江温州12";
            queryManufacturers.ManufacturersPhone = null;
            queryManufacturers.ManufacturersDom   = null;
            queryManufacturers.ManufacturersDoe   = null;

            readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);

            manufacturersList.RemoveAt(0);

            queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = null;
            queryManufacturers.ManufacturersSite  = null;
            queryManufacturers.ManufacturersPhone = "17733117712";
            queryManufacturers.ManufacturersDom   = null;
            queryManufacturers.ManufacturersDoe   = null;

            readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);

            manufacturersList.RemoveAt(0);

            queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = null;
            queryManufacturers.ManufacturersSite  = null;
            queryManufacturers.ManufacturersPhone = null;
            queryManufacturers.ManufacturersDom   = Convert.ToDateTime("2013-06-29");
            queryManufacturers.ManufacturersDoe   = null;

            readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);

            manufacturersList.RemoveAt(0);

            queryManufacturers = new QueryManufacturers();

            queryManufacturers.ManufacturersID    = null;
            queryManufacturers.ManufacturersName  = null;
            queryManufacturers.ManufacturersSite  = null;
            queryManufacturers.ManufacturersPhone = null;
            queryManufacturers.ManufacturersDom   = null;
            queryManufacturers.ManufacturersDoe   = Convert.ToDateTime("2016-06-29");

            readedManufacturersList =
                manufacturersStorage.ListManufacturers(queryManufacturers);

            AssertManufacturersListsEqual(manufacturersList, readedManufacturersList);
        }