예제 #1
0
        private void btnsignIn_Click(object sender, RoutedEventArgs e)
        {
            //Button Name   :btnsignIn_Click()
            //Purpose       : calls metthod GetStudentDetails to check if exists and logs in
            //Input         : studentId
            //Output        : MenuScreen window
            bool hasValues = HasValues();

            if (hasValues)
            {
                bool isNum = IsNumber();
                if (isNum)
                {
                    string studentId   = txtStudentId.Text;
                    string studentName = txtUserName.Text;
                    string studentPass = txtPassword.Text;
                    studentDetail = myStudentProxy.GetStudentDetail(studentId);
                    if (studentDetail != null)
                    {
                        if (studentDetail.StudentName == studentName)
                        {
                            if (studentDetail.StudentPassword == studentPass)
                            {
                                var showMenu = new MenueScreen();
                                showMenu.Show();
                            }
                            else
                            {
                                MessageBox.Show("wrong password ", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("wrong name ", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("login fail", "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);
            }
        }
예제 #2
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();
        }