public void DeleteMethodOK()
        {
            ClsStaffCollection allStaff = new ClsStaffCollection();
            ClsStaff           testItem = new ClsStaff();

            int primaryKey = 0;

            testItem.StaffID       = 1;
            testItem.StaffName     = "Bill Gates";
            testItem.OfficeCode    = 1;
            testItem.PositionID    = 1;
            testItem.ContactNumber = "12345678910";
            testItem.Address       = "10 Park Road, Leicester, LE1 2PR";
            testItem.HireDate      = DateTime.Now.Date;
            testItem.IsEmployed    = true;

            allStaff.ThisStaff = testItem;
            primaryKey         = allStaff.Add();
            testItem.StaffID   = primaryKey;
            allStaff.ThisStaff.Find(primaryKey);

            allStaff.Delete();
            bool found = allStaff.ThisStaff.Find(primaryKey);

            Assert.IsFalse(found);
        }
        public void UpdateMethodOK()
        {
            ClsStaffCollection allStaff = new ClsStaffCollection();
            ClsStaff           testItem = new ClsStaff();

            int primaryKey = 0;

            testItem.StaffID       = 1;
            testItem.StaffName     = "Bill Gates";
            testItem.OfficeCode    = 1;
            testItem.PositionID    = 1;
            testItem.ContactNumber = "12345678910";
            testItem.Address       = "10 Park Road, Leicester, LE1 2PR";
            testItem.HireDate      = DateTime.Now.Date;
            testItem.IsEmployed    = true;

            allStaff.ThisStaff = testItem;
            primaryKey         = allStaff.Add();

            testItem.StaffName     = "Steve Ballmer";
            testItem.OfficeCode    = 2;
            testItem.PositionID    = 3;
            testItem.ContactNumber = "9876543210";
            testItem.Address       = "11 Ground Road, Liverpool, LP1 2RP";
            testItem.HireDate      = DateTime.Now.Date;
            testItem.IsEmployed    = true;

            allStaff.ThisStaff = testItem;
            allStaff.Update();
            allStaff.ThisStaff.Find(primaryKey);

            Assert.AreEqual(allStaff.ThisStaff, testItem);
        }
Exemplo n.º 3
0
    protected void BtnFind_Click(object sender, EventArgs e)
    {
        ClsStaff member = new ClsStaff();
        int      staffID;
        Boolean  Found = false;

        if (System.Text.RegularExpressions.Regex.IsMatch(TbStaffID.Text, "^[a-zA-Z]*$"))
        {
            Response.Redirect("StaffPage.aspx");
        }

        staffID = Convert.ToInt32(TbStaffID.Text);
        Found   = member.Find(staffID);

        if (Found == true)
        {
            TbStaffName.Text     = member.StaffName;
            TbOfficeCode.Text    = member.OfficeCode.ToString();
            TbPositionID.Text    = member.PositionID.ToString();
            TbContactNumber.Text = member.ContactNumber;
            TbAddress.Text       = member.Address;
            TbHireDate.Text      = member.HireDate.ToShortDateString();
            CbIsEmployed.Checked = member.IsEmployed;
        }
    }
Exemplo n.º 4
0
        public void OfficeCodePropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            int      testData = 03;

            member.OfficeCode = testData;
            Assert.AreEqual(member.OfficeCode, testData);
        }
Exemplo n.º 5
0
        public void ContactNumberPropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            string   testData = "07456330713";

            member.ContactNumber = testData;
            Assert.AreEqual(member.ContactNumber, testData);
        }
Exemplo n.º 6
0
        public void StaffNamePropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            string   testData = "Bill Gates";

            member.StaffName = testData;
            Assert.AreEqual(member.StaffName, testData);
        }
Exemplo n.º 7
0
        public void AddressPropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            string   testData = "1 Park Road, Leicester, LE2 1PK";

            member.Address = testData;
            Assert.AreEqual(member.Address, testData);
        }
Exemplo n.º 8
0
        public void HireDatePropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            DateTime testData = DateTime.Now.Date;

            member.HireDate = testData;
            Assert.AreEqual(member.HireDate, testData);
        }
Exemplo n.º 9
0
        public void IsEmployedPropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            bool     testData = true;

            member.IsEmployed = testData;
            Assert.AreEqual(member.IsEmployed, testData);
        }
Exemplo n.º 10
0
        public void PositionIDPropertyOK()
        {
            ClsStaff member   = new ClsStaff();
            int      testData = 1;

            member.PositionID = testData;
            Assert.AreEqual(member.PositionID, testData);
        }
Exemplo n.º 11
0
        public void AddressMinPlus1()
        {
            ClsStaff member  = new ClsStaff();
            string   error   = "";
            string   address = "AA";

            error = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreEqual(error, "");
        }
Exemplo n.º 12
0
        public void ContactNumberMaxPlus1()
        {
            ClsStaff member        = new ClsStaff();
            string   error         = "";
            string   contactNumber = "0122345547859736";

            error = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 13
0
        public void ContactNumberMax()
        {
            ClsStaff member        = new ClsStaff();
            string   error         = "";
            string   contactNumber = "012234567898765";

            error = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreEqual(error, "");
        }
Exemplo n.º 14
0
        public void DateInvalid()
        {
            ClsStaff member   = new ClsStaff();
            string   error    = "";
            string   hireDate = "This is a date!";

            error = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 15
0
        public void ValidMethodOK()
        {
            ClsStaff member = new ClsStaff();

            String Error = "";

            Error = member.Valid(staffName, contactNumber, address, hireDate);

            Assert.AreEqual(Error, "");
        }
Exemplo n.º 16
0
        public void AddressMaxLess1()
        {
            ClsStaff member  = new ClsStaff();
            string   error   = "";
            string   address = "";

            address = address.PadRight(49, 'A');
            error   = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreEqual(error, "");
        }
Exemplo n.º 17
0
        public void AddressMaxExtreme()
        {
            ClsStaff member  = new ClsStaff();
            string   error   = "";
            string   address = "";

            contactNumber = contactNumber.PadRight(500, 'A');
            error         = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Create a new instance of ClsStaff
        ClsStaff member = new ClsStaff();

        // Get the data from the session object
        member = (ClsStaff)Session["member"];
        // Display the staff name for this entry
        Response.Write(member.StaffName);
    }
Exemplo n.º 19
0
        public void FindMethodOK()
        {
            ClsStaff member = new ClsStaff();

            bool Found   = false;
            int  StaffID = 1;

            Found = member.Find(StaffID);

            Assert.IsTrue(Found);
        }
Exemplo n.º 20
0
        public void StaffNameMin()
        {
            ClsStaff member = new ClsStaff();

            String error     = "";
            string staffName = "A";

            error = member.Valid(staffName, contactNumber, address, hireDate);

            Assert.AreEqual(error, "");
        }
Exemplo n.º 21
0
        public void DateMin()
        {
            ClsStaff member = new ClsStaff();
            string   error  = "";
            DateTime testDate;

            testDate = DateTime.Now.Date;
            string hireDate = testDate.ToString();

            error = member.Valid(staffName, contactNumber, address, hireDate);
            Assert.AreEqual(error, "");
        }
Exemplo n.º 22
0
        public void StaffNameMaxPlus1()
        {
            ClsStaff member = new ClsStaff();

            String error     = "";
            string staffName = "";

            staffName = staffName.PadRight(31, 'A');

            error = member.Valid(staffName, contactNumber, address, hireDate);

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 23
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        ClsStaff member = new ClsStaff();

        string staffName     = TbStaffName.Text;
        string officeCode    = TbOfficeCode.Text;
        string positionID    = TbPositionID.Text;
        string contactNumber = TbContactNumber.Text;
        string address       = TbAddress.Text;
        string hireDate      = TbHireDate.Text;

        string error = "";

        error = member.Valid(staffName, contactNumber, address, hireDate);

        if (error == "")
        {
            member.StaffID       = staffID;
            member.StaffName     = staffName;
            member.OfficeCode    = Convert.ToInt32(officeCode);
            member.PositionID    = Convert.ToInt32(positionID);
            member.ContactNumber = contactNumber;
            member.Address       = address;
            member.HireDate      = Convert.ToDateTime(hireDate);
            member.IsEmployed    = CbIsEmployed.Checked;

            ClsStaffCollection members = new ClsStaffCollection();

            if (staffID == -1)
            {
                members.ThisStaff = member;
                members.Add();
            }
            else
            {
                members.ThisStaff.Find(staffID);
                members.ThisStaff = member;
                members.Update();
            }

            Response.Redirect("StaffList.aspx");
        }
        else
        {
            LblError.Text = error;
        }
    }
Exemplo n.º 24
0
        public void ThisStaffPropertyOK()
        {
            ClsStaffCollection allStaff  = new ClsStaffCollection();
            ClsStaff           testStaff = new ClsStaff();

            testStaff.StaffID       = 1;
            testStaff.StaffName     = "Bill Gates";
            testStaff.OfficeCode    = 1;
            testStaff.PositionID    = 1;
            testStaff.ContactNumber = "12345678910";
            testStaff.Address       = "10 Park Road, Leicester, LE1 2PR";
            testStaff.HireDate      = DateTime.Now.Date;
            testStaff.IsEmployed    = true;

            allStaff.ThisStaff = testStaff;
            Assert.AreEqual(allStaff.ThisStaff, testStaff);
        }
Exemplo n.º 25
0
        public void TestPositionIDFound()
        {
            ClsStaff member = new ClsStaff();

            bool Found = false;
            bool OK    = true;
            int  ID    = 1;

            Found = member.Find(ID);

            if (member.PositionID != 3)
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 26
0
        public void TestContactNumberFound()
        {
            ClsStaff member = new ClsStaff();

            bool Found = false;
            bool OK    = true;
            int  ID    = 1;

            Found = member.Find(ID);

            if (member.ContactNumber != "09876543210")
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 27
0
        public void TestAddressFound()
        {
            ClsStaff member = new ClsStaff();

            bool found = false;
            bool OK    = true;
            int  ID    = 1;

            found = member.Find(ID);

            if (member.Address != "11 Ground Road, Liverpool, LP1 2RP")
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 28
0
        public void TestHireDateFound()
        {
            ClsStaff member = new ClsStaff();

            bool Found   = false;
            bool OK      = true;
            int  StaffID = 1;

            Found = member.Find(StaffID);

            if (member.HireDate != DateTime.Now.Date)
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 29
0
        public void TestIsEmployedFound()
        {
            ClsStaff member = new ClsStaff();

            bool Found = false;
            bool OK    = true;
            int  ID    = 1;

            Found = member.Find(ID);

            if (member.IsEmployed != true)
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 30
0
        public void TestOfficeCodeFound()
        {
            ClsStaff member = new ClsStaff();

            bool Found = false;
            bool OK    = true;
            int  ID    = 1;

            Found = member.Find(ID);

            if (member.OfficeCode != 2)
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }