Ejemplo n.º 1
0
 public void addStudent(Classes.Student obj)
 {
     if (obj.status == "Applied")
     {
         Applied.Add(obj);
     }
     else if (obj.status == "Pass")
     {
         Pass.Add(obj);
     }
     else
     {
         Rejected.Add(obj);
     }
 }
Ejemplo n.º 2
0
        protected void ModifySubmit_Click(object sender, EventArgs e)
        {
            //modify by using a common student object in the session?
            Student s = new Classes.Student();

            if (s != null)
            {
                details.Visible = true;
                s.StudentID     = Student_ID.Text;
                s.FirstName     = FirstName.Text;
                s.LastName      = LastName.Text;
                s.Email         = Email.Text;
                RequestDirector.ModifyStudent(s);
                Response.Write("<script>alert(\"Student Modified Successfully\")</script>");
            }
            else
            {
                Response.Write("<script>alert(\"Did not modify student\")</script>");
            }
        }
Ejemplo n.º 3
0
        public Classes.Student searchStudentbyID(Classes.Student obj)
        {
            Classes.Student obj3 = null;

            if (obj.status == "Applied")
            {
                foreach (Classes.Student obj2 in Applied)
                {
                    if (obj2.id == obj.id)
                    {
                        obj3 = obj2;
                    }
                }
            }
            if (obj.status == "Pass")
            {
                foreach (Classes.Student obj2 in Pass)
                {
                    if (obj2.id == obj.id)
                    {
                        obj3 = obj2;
                    }
                }
            }
            if (obj.status == "Rejected")
            {
                foreach (Classes.Student obj2 in Rejected)
                {
                    if (obj2.id == obj.id)
                    {
                        obj3 = obj2;
                    }
                }
            }

            return(obj3);
        }
Ejemplo n.º 4
0
        private void addStudentToDatabase_Click(object sender, EventArgs e)
        {
            Classes.Student newStudent;
            Project_Team3.Classes.FunctionsForAllProgram funcs = new Classes.FunctionsForAllProgram();
            String username = this.username_box.Text;
            String id       = this.id_box.Text;
            int    id_int   = -1;

            if (checkFields() == false)
            {
                return;
            }

            try
            {
                id_int = Convert.ToInt32(id);
            }
            catch
            {
                MessageBox.Show("Unsuccessfull convertion attempt string ID to Int or ID field is empty!");
                return;
            }
            bool usernameExists = funcs.ifUserInDatabase(username);

            if (usernameExists)
            {
                MessageBox.Show("User with username " + username + " already exists");
            }

            bool userIdExists = funcs.ifUserIDinDatabase(id_int);

            if (userIdExists)
            {
                MessageBox.Show("User with id " + id_int + " already exists");
            }

            bool userExists = usernameExists || userIdExists;

            if (userExists == false)
            {
                String Name = this.firstname_box.Text, surename = this.secondName_box.Text, password = this.password_box.Text;
                int    semester;
                try
                {
                    semester = Convert.ToInt32(this.semester_box.Text);
                    if (semester < 0 || semester > 8)
                    {
                        MessageBox.Show("Semester value must been 1-8");
                        return;
                    }
                }
                catch
                {
                    semester = 1;
                }
                string email       = this.email_Box.Text;
                bool   emailExists = funcs.ifEmailInDatabase(email);
                if (emailExists)
                {
                    MessageBox.Show("User with email " + email + " already exists");
                    return;
                }
                newStudent = new Classes.Student(id, username, Name, surename, password, semester, email);
                DBconnect db = new DBconnect();
                try
                {
                    db.addStudentToDB(newStudent);
                    MessageBox.Show("New Student been added to database!");
                }
                catch
                {
                    MessageBox.Show("Something went wrong, user not been added! \ncheck your database connection and fields correctness and try again!");
                }
            }
        }