Ejemplo n.º 1
0
 public Student(string id, long changed)
 {
     Given    = new Flowers();
     Returned = new Flowers();
     ID       = id;
     Changed  = changed;
 }
Ejemplo n.º 2
0
 public Student()
 {
     Given    = new Flowers(MainWindow.Box);
     Returned = new Flowers(MainWindow.Box);
     ID       = Guid.NewGuid().ToString("N");
     Changed  = DateTime.UtcNow.Ticks;
 }
Ejemplo n.º 3
0
 public Flowers(Flowers b)
 {
     Small   = b.Small;
     Wreaths = b.Wreaths;
     Large   = b.Large;
     Pins    = b.Pins;
 }
Ejemplo n.º 4
0
 public Settings(Flowers box, Flowers price, int bonus)
 {
     Box   = new Flowers(box);
     Price = new Flowers(price);
     Bonus = bonus;
     InitializeComponent();
 }
Ejemplo n.º 5
0
        public MainWindow()
        {
            Schools = new ObservableCollection <School>();
            Box     = new Flowers(20, 10, 6, 8);
            Price   = new Flowers(20, 40, 20, 60);
            Bonus   = 28;

            InitializeComponent();

            CommandManager.AddPreviewExecutedHandler(dataGrid, PreviewPaste);
            dataGrid.PasteFinished += new CustomDataGrid.PasteFinishedEventHandler(DataGrid_PasteFinished);
        }
Ejemplo n.º 6
0
        private int CalculateBonus()
        {
            int     bonus = 0;
            Flowers t     = Total;

            while (t.Small >= MainWindow.Box.Small && t.Wreaths >= MainWindow.Box.Wreaths && t.Large >= MainWindow.Box.Large && t.Pins >= MainWindow.Box.Pins)
            {
                t     -= MainWindow.Box;
                bonus += MainWindow.Bonus;
            }

            return(bonus);
        }
Ejemplo n.º 7
0
        private void Open_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var dialog = new OpenFileDialog {
                Filter = "XML Filer (*.xml)|*.xml|Alla Filer (*.*)|*.*"
            };

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            filename = dialog.FileName;

            Schools.Clear();
            School      school      = null;
            SchoolClass schoolClass = null;
            Student     student     = null;

            using (var reader = XmlReader.Create(filename))
            {
                while (reader.Read())
                {
                    if (!reader.IsStartElement())
                    {
                        continue;
                    }
                    switch (reader.Name)
                    {
                    case "Box":
                        Box = new Flowers(int.Parse(reader["Small"]), int.Parse(reader["Wreaths"]), int.Parse(reader["Large"]), int.Parse(reader["Pins"]));
                        break;

                    case "Price":
                        Price = new Flowers(int.Parse(reader["Small"]), int.Parse(reader["Wreaths"]), int.Parse(reader["Large"]), int.Parse(reader["Pins"]));
                        break;

                    case "Bonus":
                        Bonus = reader.ReadElementContentAsInt();
                        break;

                    case "School":
                        school = new School(reader["Name"], reader["ID"], long.Parse(reader["Changed"]));
                        Schools.Add(school);
                        break;

                    case "Class":
                        schoolClass = new SchoolClass(reader["Name"], reader["ID"], long.Parse(reader["Changed"]));
                        school?.Classes.Add(schoolClass);
                        break;

                    case "Student":
                        student = new Student(reader["ID"], long.Parse(reader["Changed"]));
                        schoolClass?.Students.Add(student);
                        break;

                    case "Firstname":
                        student.Firstname = reader.ReadElementContentAsString();
                        break;

                    case "Surname":
                        student.Surname = reader.ReadElementContentAsString();
                        break;

                    case "Telephone":
                        student.Telephone = reader.ReadElementContentAsString();
                        break;

                    case "GivSmall":
                        student.Given.Small = reader.ReadElementContentAsInt();
                        break;

                    case "GivWreaths":
                        student.Given.Wreaths = reader.ReadElementContentAsInt();
                        break;

                    case "GivLarge":
                        student.Given.Large = reader.ReadElementContentAsInt();
                        break;

                    case "GivPins":
                        student.Given.Pins = reader.ReadElementContentAsInt();
                        break;

                    case "GivSign":
                        student.GivSign = reader.ReadElementContentAsString();
                        break;

                    case "RetSmall":
                        student.Returned.Small = reader.ReadElementContentAsInt();
                        break;

                    case "RetWreaths":
                        student.Returned.Wreaths = reader.ReadElementContentAsInt();
                        break;

                    case "RetLarge":
                        student.Returned.Large = reader.ReadElementContentAsInt();
                        break;

                    case "RetPins":
                        student.Returned.Pins = reader.ReadElementContentAsInt();
                        break;

                    case "Received":
                        student.Received = reader.ReadElementContentAsInt();
                        break;

                    case "Sign":
                        student.Sign = reader.ReadElementContentAsString();
                        break;

                    case "Note":
                        student.Note = reader.ReadElementContentAsString();
                        break;
                    }
                }
            }

            if (Schools.Count > 0)
            {
                CurrentSchool = Schools[0];
            }
        }