示例#1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                StudentClass         student  = new StudentClass();
                LandLordClass        landLord = new LandLordClass();
                LandlordBuildingForm bform    = new LandlordBuildingForm();
                TenantBuildingForm   sbform   = new TenantBuildingForm();
                int landLordCode = landLord.GetLoginCode();
                int password     = Convert.ToInt32(loginCodeTextBox.Text);

                if (landLordCode == Convert.ToInt32(loginCodeTextBox.Text))
                {
                    this.Hide();
                    bform.Show();
                }
                else if ((password == student.GetLoginCodeBuildingA()) || (password == student.GetLoginCodeBuildingB()) || (password == student.GetLoginCodeBuildingC()))
                {
                    studentCode = password;
                    this.Hide();
                    sbform.Show();
                }
                else
                {
                    MessageBox.Show("Please enter the correct password!");
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Please enter numbers only!");
            }
        }
        /**
         * Method to remove a student based on ID
         */
        public bool RemoveStudent(int id)
        {
            StudentClass student = this.GetStudent(id);

            if (student != null)
            {
                this.students.Remove(student);
                return(true);
            }
            return(false);
        }
 /**
  * Method to add a student to a building
  */
 public void AddStudentToBuilding(String name, String buildingName)
 {
     student     = new StudentClass();
     student.ID += idSeeder;
     idSeeder++;
     student.SetName(name);
     student.GetName();
     student.SetBuildingName(buildingName);
     student.GetBuildingName();
     students.Add(student);
 }