Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using BusinessObjects;
- namespace Demo
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- private ModuleList store = new ModuleList();
- private Student s;
- public MainWindow()
- {
- InitializeComponent();
- }
- private void btnAdd_Click(object sender, RoutedEventArgs e)
- {
- s = new Student();
- //Store textbox text to the student properties
- //s.Matric = Int32.Parse(txtMatric.Text);
- if ((int.Parse(txtMatric.Text) <10001 || int.Parse(txtMatric.Text) >50000) || txtMatric.Text.Length == 0)
- {
- lblContents.Content ="Invalid input";
- }
- else
- {
- s.Matric = int.Parse(txtMatric.Text);
- txtMatric.Text = String.Empty;
- }
- if (txtFirstName.Text.Length == 0)
- {
- lblContents.Content = "Invalid Input";
- }
- else
- {
- s.firstName = txtFirstName.Text;
- txtFirstName.Text = String.Empty;
- }
- if (txtSurname.Text.Length == 0)
- {
- lblContents.Content = "Invalid Input";
- }
- else
- {
- s.Surname = txtSurname.Text;
- txtSurname.Text = String.Empty;
- }
- if (txtDate_Of_Birth.Text.Length == 0)
- {
- lblContents.Content = "Invalid Input";
- }
- else
- {
- s.dateOfBirth = txtDate_Of_Birth.Text;
- txtDate_Of_Birth.Text = String.Empty;
- }
- if ((int.Parse(txtCourseworkMark.Text) < 0 || int.Parse(txtCourseworkMark.Text) > 20) || txtCourseworkMark.Text.Length == 0)
- {
- lblContents.Content = "Invalid Input";
- }
- else
- {
- s.courseworkMark = int.Parse(txtCourseworkMark.Text);
- txtCourseworkMark.Text = String.Empty;
- }
- if ((int.Parse(txtExamMark.Text) < 0 || int.Parse(txtExamMark.Text) > 40) || txtExamMark.Text.Length == 0)
- {
- lblContents.Content = "Invalid Input";
- }
- else
- {
- s.examMark = int.Parse(txtExamMark.Text);
- txtExamMark.Text = String.Empty;
- }
- store.add(s);
- //s.firstName = txtFirstName.Text;
- //s.Surname = txtSurname.Text;
- //s.courseworkMark = Double.Parse(txtCourseworkMark.Text);
- //s.examMark = Double.Parse(txtExamMark.Text);
- //s.dateOfBirth = txtDate_Of_Birth.Text;
- ////Check if the data inputted in valid
- //if ((s.Matric >= 10001 & s.Matric <= 50000) )
- //{
- // S
- // //Student added to the store
- // store.add(s);
- // //Textbox text cleared
- // txtMatric.Text = String.Empty;
- // txtFirstName.Text = String.Empty;
- // txtSurname.Text = String.Empty;
- // txtCourseworkMark.Text = String.Empty;
- // txtDate_Of_Birth.Text = String.Empty;
- // txtExamMark.Text = String.Empty;
- //}
- ////Display message indicating that the data inputted is not valid
- //else
- //{
- // lblContents.Content = "Data inputted is not valid";
- //}
- }
- //Find matric number and store the matric number to the form.
- private void btnFind_Click(object sender, RoutedEventArgs e)
- {
- s = new Student();
- int matricNumber = Int32.Parse(txtMatric.Text);
- s = store.find(matricNumber);
- lblContents.Content = s.Matric + " " + s.firstName + " " + s.Surname + " " + s.courseworkMark + " " + s.examMark + " " + s.getMark();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement