コード例 #1
0
ファイル: tstStaffing.cs プロジェクト: xIMzEr/DeMon_Tutoring
        public void AddMethodOK()
        {
            //Create an instance of the collections class
            StaffingCollection aStaffCollection = new StaffingCollection();
            //create an instance of test data
            Staffing TestItem = new Staffing();
            //Primary key storage
            Int32 primaryKey = 0;

            //Initiate properties of test data
            TestItem.staffName   = new Name("Thomas", "Barnes");
            TestItem.staffNumber = "01706844505";
            TestItem.staffEmail  = "*****@*****.**";
            TestItem.staffDOB    = Convert.ToDateTime("08/09/1990");
            TestItem.staffValid  = true;
            //Set test data into collections
            aStaffCollection.ThisStaff = TestItem;
            //Add the record
            primaryKey = aStaffCollection.Add();
            //Set the primary key of the test data
            TestItem.staffID = primaryKey;
            //Find the record
            aStaffCollection.ThisStaff.Find(primaryKey);
            //Test to see that the two values are the same
            Assert.AreEqual(aStaffCollection.ThisStaff, TestItem);
        }
コード例 #2
0
    protected void OkButton_Click(object sender, EventArgs e)
    {
        //Create a new instance of staff
        Staffing staff = new Staffing();
        //String to store any error messages
        String Error = "";

        //Validate the data
        Error = staff.Valid(txtFirstName.Text, txtLastName.Text, txtEmail.Text, txtNumber.Text, txtDOB.Text);
        if (Error == "")
        {
            //capture the staff ID
            staff.staffID = StaffID;
            //Capture the Staff name
            staff.staffName = new Name(txtFirstName.Text, txtLastName.Text);
            //Capture the email
            staff.staffEmail = txtEmail.Text;
            //Capture the staff
            staff.staffNumber = txtNumber.Text;
            //Capture the staff DOB
            staff.staffDOB = Convert.ToDateTime(txtDOB.Text);
            //Capture the staff Validity
            staff.staffValid = StaffValid.Checked;
            //Create a new instance of the staffing collection
            StaffingCollection staffList = new StaffingCollection();

            if (StaffID == -1)
            {
                staffList.ThisStaff = staff;
                staffList.Add();
            }
            else
            {
                staffList.ThisStaff.Find(StaffID);
                staffList.ThisStaff = staff;
                staffList.Update();
            }
            //redirect to the aTutor page
            Response.Redirect("Staffing_List.aspx");
        }
        else
        {
            txtError.Visible = true;
            //display the error message
            txtError.Text = "Error! " + Error;
        }
    }