Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Make sure the name is is not already in use
            if (txtName.Text != "")
                if (!mUserManager.IsUserATutor(txtName.Text))
                    if (txtPassword.Text != "")
                        if (txtClass.Text != "")
                        {
                            // Add a new tutor
                            TutorDetails iNewTutor = new TutorDetails();
                            iNewTutor.Name = txtName.Text;
                            iNewTutor.Password = txtPassword.Text;
                            iNewTutor.Class = txtClass.Text;
                            mUserManager.AddTutor(iNewTutor);

                            DisplayTutors();    // Redisplay tutor list
                            mTutorsListModified = true;
                        }
                        else
                            MessageBox.Show("Tutors class is missing, use NA if unknown", "Class missing");
                    else
                        MessageBox.Show("Starting password is missing", "Password missing");
                else
                    MessageBox.Show("Name is already in use", "Name taken");
            else
                MessageBox.Show("Tutor name is missing", "Name missing");
        }
Example #2
0
        // Add a new tutor to the list
        public void AddTutor(TutorDetails prTutor)
        {
            if (mTutors == null)
                mTutors = new Dictionary<int, TutorDetails>();

            if (mTutors.Count == 0)
                mTutors.Add(0, prTutor);
            else
                mTutors.Add(mTutors.Last().Key + 1, prTutor);
        }
Example #3
0
        private void lstTutors_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstTutors.SelectedIndex > -1)
            {
                btnModify.Enabled = true;
                btnDelete.Enabled = true;
                txtName.Enabled = false;
                // Get the tutor
                mTutorDetails = mUserManager.GetTutorDetails(lstTutors.SelectedItem.ToString());

                if (mTutorDetails != null)
                {
                    // Display the details
                    txtName.Text = mTutorDetails.Name;
                    txtPassword.Text = mTutorDetails.Password;
                    txtClass.Text = mTutorDetails.Class;
                }
            }
            else
            {
                btnModify.Enabled = false;
                btnDelete.Enabled = false;
            }
        }