Exemple #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //Button Name   : btnSave_Click
            //Purpose       : calls for method SaveStudent()
            //Input         : none
            //Output        : save infomation about student



            bool hasValues = HasValues();

            if (hasValues)
            {
                student = new Student();
                bool isNum = IsNumber();
                if (isNum)
                {
                    int studentId = Convert.ToInt32(txtstudentNumber.Text);

                    students = myStudentProxy.ListStudents();

                    string studentName     = txtEnterStudentName.Text;
                    string studentPassword = txtStudentPassword.Text;

                    bool good = myStudentProxy.SaveStudent(studentId, studentName, studentPassword);
                    if (good == true)
                    {
                        MessageBox.Show(studentName + " " + "added Successfully ");
                        var showMenu = new MenueScreen();
                        showMenu.Show();
                    }
                    else
                    {
                        MessageBox.Show("student already exists!", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("make sure student number is a number!", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Please enter all values.", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            clearFields();
            LoadData();
        }
Exemple #2
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            //Button Name   : btnSearch_Click
            //Purpose       : calls for method GetStudentDetail() to check if student exists
            //Input         : studentId
            //Output        : student
            bool hasValues = HasValues();

            if (hasValues)
            {
                bool isNum = IsNumber();
                if (isNum)
                {
                    students = myStudentProxy.ListStudents();
                    string studentId = txtStudentId.Text;
                    studentDetail = myStudentProxy.GetStudentDetail(studentId);
                    if (studentDetail != null)
                    {
                        txtStudentName.Text     = studentDetail.StudentName.ToString();
                        txtStudentPassword.Text = studentDetail.StudentPassword.ToString();
                    }
                    else
                    {
                        MessageBox.Show("student does not exist", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("make sure student ID is a number!", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Please enter Id.", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            txtStudentName.IsEnabled     = true;
            txtStudentPassword.IsEnabled = true;
            txtStudentId.IsEnabled       = false;
        }