Ejemplo n.º 1
0
        public void EquipmentColourMinPlusOne()
        {
            clsEquipment anEquipment     = new clsEquipment();
            String       Error           = "";
            string       EquipmentColour = "aa";

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
        }
Ejemplo n.º 2
0
        public void EquipmentDescriptionMinLessOne()
        {
            clsEquipment anEquipment          = new clsEquipment();
            string       Error                = "";
            string       EquipmentDescription = "0";

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
        }
Ejemplo n.º 3
0
        public void ValidMethodOK()
        {
            clsEquipment anEquipment = new clsEquipment();
            String       Error       = "";

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 4
0
        public void EquipmentPriceExtremeMax()
        {
            clsEquipment anEquipment    = new clsEquipment();
            string       Error          = "";
            int          EquipmentPrice = 1000;

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 5
0
        public void EquipmentColourMid()
        {
            clsEquipment anEquipment     = new clsEquipment();
            String       Error           = "";
            string       EquipmentColour = "";

            EquipmentColour.PadRight(10, 'a');

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 6
0
        public void EquipmentDateAddedMin()
        {
            clsEquipment anEquipment = new clsEquipment();
            String       Error       = "";
            DateTime     TestDate;

            TestDate = DateTime.Now.Date;
            TestDate = TestDate.AddYears(-100);
            string EquipmentDateAdded = TestDate.ToString();

            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 7
0
        public void EquipmentDateAddedExtremeMin()
        {
            //create an instance of the class we want to create
            clsEquipment anEquipment = new clsEquipment();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

            //set the date totodays date
            TestDate = DateTime.Now.Date;
            //change the date to whatever the date is less 100 years
            TestDate = TestDate.AddYears(-100);
            //convert the date variable to a string variable
            string EquipmentDateAdded = TestDate.ToString();

            //invoke the method
            Error = anEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
            Assert.AreNotEqual(Error, "");
        }
    protected void tbnOK_Click(object sender, EventArgs e)
    {
        //create a new instance of clsEquipment
        clsEquipment AnEquipment          = new clsEquipment();
        string       EquipmentDescription = txtEquipmentDescription.Text;
        string       EquipmentColour      = txtEquipmentColour.Text;
        string       EquipmentDateAdded   = txtDateAdded.Text;
        Int32        EquipmentPrice       = Convert.ToInt32(txtEquipmentPrice.Text);
        string       Error = "";

        Error = AnEquipment.Valid(EquipmentDescription, EquipmentColour, EquipmentDateAdded, EquipmentPrice);
        if (Error == "")
        {
            AnEquipment.EquipmentNo = EquipmentNo;

            AnEquipment.EquipmentDescription = EquipmentDescription;
            AnEquipment.EquipmentColour      = EquipmentColour;
            AnEquipment.EquipmentDateAdded   = Convert.ToDateTime(EquipmentDateAdded);
            AnEquipment.EquipmentPrice       = Convert.ToInt32(EquipmentPrice);
            AnEquipment.EquipmentAvailable   = chkAvailable.Checked;
            clsEquipmentCollection EquipmentList = new clsEquipmentCollection();

            if (EquipmentNo == -1)
            {
                EquipmentList.ThisEquipment = AnEquipment;
                EquipmentList.Add();
            }
            else
            {
                EquipmentList.ThisEquipment.Find(EquipmentNo);
                EquipmentList.ThisEquipment = AnEquipment;
                EquipmentList.Update();
            }

            Response.Redirect("EquipmentList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }