Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "汽車")
            {
                ClsCar cc = new ClsCar();
                TotalMile.Text = cc.ClsTools1(int.Parse(Miletext.Text), int.Parse(Oiltext.Text)).ToString();
            }
            else if (comboBox1.Text == "船")
            {
                if (checkBox1.Checked == true)
                {
                    ClsSailBoat csb = new ClsSailBoat();
                    TotalMile.Text = csb.ClsTools1(int.Parse(Miletext.Text), int.Parse(Oiltext.Text)).ToString();
                }
                else
                {
                    ClsBoat cb = new ClsBoat();
                    TotalMile.Text = cb.ClsTools1(int.Parse(Miletext.Text), int.Parse(Oiltext.Text)).ToString();
                }
            }

            checkBox1.Enabled = false;

            // TotalMile.Text = ct.ClsTools1(int.Parse(Miletext.Text), int.Parse(Oiltext.Text)).ToString();
        }
Пример #2
0
        public void ListAndCountOK()

        {
            ClsCarCollection AllCars = new ClsCarCollection();
            //create some test data to asign to the property
            //in this cas the data needs to be a list of objects
            List <ClsCar> TestList = new List <ClsCar>();
            //add an item to the list
            //create the item of test data
            ClsCar TestItem = new ClsCar();

            //set its properties
            TestItem.CarID       = 0;
            TestItem.NumberPlate = "1234 ABCD";
            TestItem.Make        = "Nissan";
            TestItem.Model       = "Micra";
            TestItem.Colour      = "Blue";
            TestItem.Description = "4 wheeler";
            TestItem.Sold        = true;
            TestItem.Price       = 100.00;
            TestItem.OfficeCode  = 1;
            //add the item to the list
            TestList.Add(TestItem);
            //assign the data to the property
            AllCars.CarList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.Count, TestList.Count);
        }
Пример #3
0
        public void DeleteMethodOK()
        {
            //create an instance of the calss we want to create
            ClsCarCollection AllCars = new ClsCarCollection();
            //create the item of test data
            ClsCar TestItem   = new ClsCar();
            int    PrimaryKey = 0;

            //set its propertiers
            TestItem.NumberPlate = "1234 ABCD";
            TestItem.Make        = "Nissan";
            TestItem.Model       = "Micra";
            TestItem.Colour      = "Blue";
            TestItem.Description = "4 wheeler";
            TestItem.Sold        = true;
            TestItem.Price       = 100.00;
            TestItem.OfficeCode  = 1;
            //set ThisAddress to the test data
            AllCars.ThisCar = TestItem;
            //add the record
            PrimaryKey = AllCars.Add();
            //set the primary key of the test data
            TestItem.CarID = PrimaryKey;
            //find the record
            AllCars.ThisCar.Find(PrimaryKey);
            //delete the record
            AllCars.Delete();
            //now find the record
            Boolean Found = AllCars.ThisCar.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Пример #4
0
        public void CarIDPropertyOK()
        {
            ClsCar car      = new ClsCar();
            int    TestData = 0;

            car.CarID = TestData;
            Assert.AreEqual(car.CarID, TestData);
        }
Пример #5
0
        public void NumberPlatePropertyOK()
        {
            ClsCar car      = new ClsCar();
            string TestData = "TestNumberPlate";

            car.NumberPlate = TestData;
            Assert.AreEqual(car.NumberPlate, TestData);
        }
Пример #6
0
        public void MakePropertyOK()
        {
            ClsCar car      = new ClsCar();
            String TestData = "TestMake";

            car.Make = TestData;
            Assert.AreEqual(car.Make, TestData);
        }
Пример #7
0
        public void ModelPropertyOK()
        {
            ClsCar car      = new ClsCar();
            String TestData = "TestModel";

            car.Model = TestData;
            Assert.AreEqual(car.Model, TestData);
        }
Пример #8
0
        public void ColourPropertyOK()
        {
            ClsCar car      = new ClsCar();
            String TestData = "TestColour";

            car.Colour = TestData;
            Assert.AreEqual(car.Colour, TestData);
        }
Пример #9
0
        public void OfficeCodePropertyOK()
        {
            ClsCar car      = new ClsCar();
            int    TestData = 1;

            car.OfficeCode = TestData;
            Assert.AreEqual(car.OfficeCode, TestData);
        }
Пример #10
0
        public void SoldPropertyOK()
        {
            ClsCar  car      = new ClsCar();
            Boolean TestData = true;

            car.Sold = TestData;
            Assert.AreEqual(car.Sold, TestData);
        }
Пример #11
0
        public void DescriptionPropertyOK()
        {
            ClsCar car      = new ClsCar();
            String TestData = "TestDescription";

            car.Description = TestData;
            Assert.AreEqual(car.Description, TestData);
        }
Пример #12
0
        public void PricePropertyOK()
        {
            ClsCar car      = new ClsCar();
            Double TestData = 100.00;

            car.Price = TestData;
            Assert.AreEqual(car.Price, TestData);
        }
Пример #13
0
        public void ValidMethodOK()
        {
            ClsCar car   = new ClsCar();
            String Error = "";

            Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price);
            Assert.AreEqual(Error, "");
        }
Пример #14
0
        public void FindMethodOK()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            Assert.IsTrue(Found);
        }
Пример #15
0
        /// <summary>
        /// Metodo para agrear un nuevo carro a la lista.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddCar_Click(object sender, EventArgs e)
        {
            ClsCar car1 = new ClsCar();

            car1.Model = txtModel.Text;
            car1.Year  = Convert.ToInt32(numYear.Value);
            car1.Maker = txtMake.Text;
            car1.Type  = (TypeCar)cmbType.SelectedIndex;
            _list.Add(car1);
            DisplayList();
        }
Пример #16
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        ClsCar ACar        = new ClsCar();
        String NumberPlate = txtNumberPlate.Text;
        String Make        = txtMake.Text;
        String Model       = txtModel.Text;
        String Colour      = txtColour.Text;
        String Description = txtDescription.Text;
        String Price       = txtPrice.Text;
        String OfficeCode  = txtOfficeCode.Text;

        String Error = "";

        Error = ACar.Valid(NumberPlate, Make, Model, Description, Colour, Price);
        if (Error == "")
        {
            ACar.NumberPlate = NumberPlate;
            ACar.Make        = Make;
            ACar.Model       = Model;
            ACar.Colour      = Colour;
            ACar.Description = Description;
            ACar.Price       = Convert.ToInt32(Price);
            ACar.OfficeCode  = Convert.ToInt32(OfficeCode);

            ClsCarCollection CarList = new ClsCarCollection();

            //if this is a new record i.e. NumberPlate != -1 then add the data
            if (CarID == -1)
            {
                //set the ThisCar Property
                CarList.ThisCar = ACar;
                //add the new record
                CarList.Add();
            }
            //otherwise it must be an update
            else
            {
                //find the record to update
                CarList.ThisCar.Find(CarID);
                //set the ThisCar property
                CarList.ThisCar = ACar;
                //update the record
                CarList.Update();
            }
            //redirect back to thte list page
            Response.Redirect("CarList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
Пример #17
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.Text == "汽車")
     {
         ClsCar cc = new ClsCar();
     }
     else if (comboBox1.Text == "船")
     {
         ClsBoat cb = new ClsBoat();
         checkBox1.Enabled = true;
     }
 }
Пример #18
0
        public void PriceMinPlusOne()
        {
            ClsCar car = new ClsCar();
            //error variable stores any error messages
            String Error = "";
            //test data to pass to method
            String Price = "00"; // this should be ok

            //invoke the method
            Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price);
            //test to see if the result is correct
            Assert.AreEqual(Error, "");
        }
Пример #19
0
        public void ColourMinLessOne()
        {
            ClsCar car = new ClsCar();
            //error variable stores any error messages
            String Error = "";
            //test data to pass to method
            String Colour = ""; //should trigger an error

            //invoke the method
            Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price);
            //test to see if the result is correct
            Assert.AreNotEqual(Error, "");
        }
Пример #20
0
        public void TestSoldFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.Sold != true)
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #21
0
        public void ColourExtremeMax()
        {
            ClsCar car = new ClsCar();
            //error variable stores any error messages
            String Error = "";
            //test data to pass to method
            String Colour = "";

            Colour = Colour.PadRight(500, 'a'); // this should fail
            //invoke the method
            Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price);
            //test to see if the result is correct
            Assert.AreNotEqual(Error, "");
        }
Пример #22
0
        public void DescriptionMid()
        {
            ClsCar car = new ClsCar();
            //error variable stores any error messages
            String Error = "";
            //test data to pass to method
            String Description = ""; // this should be ok

            Description = Description.PadRight(100, 'a');
            //invoke the method
            Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price);
            //test to see if the result is correct
            Assert.AreEqual(Error, "");
        }
Пример #23
0
        public void TestNumberPlateFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.NumberPlate != "1234ABCD")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #24
0
        public void TestMakeFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.Make != "Nissan")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #25
0
        public void TestModelFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.Model != "Micra")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #26
0
        public void TestColourFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.Colour != "Blue")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #27
0
        public void TestDescriptionFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.Description != "TestDescription")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #28
0
        public void TestOfficeCodeFound()
        {
            ClsCar  car   = new ClsCar();
            Boolean Found = false;
            Boolean OK    = true;
            Int32   CarID = 0;

            Found = car.Find(CarID);
            if (car.OfficeCode != 1)
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Пример #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsCar car = new ClsCar();

        car = (ClsCar)Session["ACar"];
        Response.Write(car.CarID);
        Response.Write(car.NumberPlate);
        Response.Write(car.Make);
        Response.Write(car.Model);
        Response.Write(car.Colour);
        Response.Write(car.Description);
        Response.Write(car.Price);
        Response.Write(car.Sold);
        Response.Write(car.OfficeCode);
    }
Пример #30
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        ClsCar  car = new ClsCar();
        int     CarID;
        Boolean Found = false;

        CarID = Convert.ToInt32(txtCarID.Text);
        Found = car.Find(CarID);
        if (Found == true)
        {
            txtNumberPlate.Text = car.NumberPlate;
            txtMake.Text        = car.Make;
            txtModel.Text       = car.Model;
            txtColour.Text      = car.Colour;
            txtDescription.Text = car.Description;
            txtPrice.Text       = car.Price.ToString();
            txtOfficeCode.Text  = car.OfficeCode.ToString();
        }
    }