예제 #1
0
            public void AddListener(FloorSelect floorSelect)
            {
                if (button == null)
                {
                    return;
                }

                button.onClick.AddListener(() => floorSelect(m_floor));
            }
예제 #2
0
 public void Awake()
 {
     _instance = this;
 }
예제 #3
0
        public MainVM()
        {
            StorageLocationHandler.Instance.Load();
            locationsView = new ObservableCollection <StorageLocation>(StorageLocationHandler.Instance.GetStorageLocations());
            ResponsiblePersonHandler.Instance.Load();
            DocumentHandler.Instance.Load();
            documentsView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));

            foreach (var item in StorageLocationHandler.Instance.GetStorageLocations())
            {
                FloorSelect.Add(item.Floor);
            }

            foreach (var item in ResponsiblePersonHandler.Instance.GetResponsiblePerson())
            {
                NameSelect.Add(item.Name);
            }

            NewLocation = new RelayCommand((o) =>
            {
                Window start = new NewLocationView();
                start.ShowDialog();

                foreach (var item in StorageLocationHandler.Instance.GetStorageLocations())
                {
                    FloorSelect.Add(item.Floor);
                }
            });

            NewPerson = new RelayCommand((o) =>
            {
                Window start = new NewPersonView();
                start.ShowDialog();

                foreach (var item in ResponsiblePersonHandler.Instance.GetResponsiblePerson())
                {
                    NameSelect.Add(item.Name);
                }
            });

            SaveCommand = new RelayCommand((o) =>
            {
                Document vorhanden = DocumentHandler.Instance.GetDocument().Find(r => r.DocumentNumber == documentNumber);
                if (vorhanden == null && documentNumber > 0 && Location != null && StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) != null &&
                    Person != null && ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(p => p == Person) != null)
                {
                    StorageLocation l = new StorageLocation()
                    {
                        Floor       = Floor,
                        RoomNumber  = RoomNumber,
                        ShelfNumber = ShelfNumber,
                        Shelf       = Shelf
                    };

                    ResponsiblePerson p = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };

                    Document d = new Document()
                    {
                        DocumentNumber   = DocumentNumber,
                        CreationDate     = DateTime.Parse(CreationDate),
                        Location         = l,
                        Person           = p,
                        BriefDescription = BriefDescription
                    };
                    DocumentHandler.Instance.AddDocument(d);
                    documentsView.Add(d);
                    DocumentHandler.Instance.Save(d);
                    Cancel(o);
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("Document already exists!");
                }
                else if (documentNumber <= 0)
                {
                    MessageBox.Show("Document number can not be under 0!");
                }
                else if (Location == null)
                {
                    MessageBox.Show("Location missing!");
                }
                else if (StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) == null)
                {
                    MessageBox.Show($"There is no {Location}");
                }
                else if (ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(l => l == Person) == null)
                {
                    MessageBox.Show($"There is no {Person}");
                }
            });

            CancelCommand = new RelayCommand(Cancel);

            ExitCommand = new RelayCommand(Exit);

            SearchCommand = new RelayCommand((o) =>
            {
                DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().FindAll(d => d.DocumentNumber.Equals(DocumentSearch)));
            });

            SortCommand = new RelayCommand((o) =>
            {
                if (Sortieren == "Rechnung sortieren")
                {
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));
                    Sortieren    = "Kunden sortieren";
                }
                else if (Sortieren == "Kunden sortieren")
                {
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(r => r.DocumentNumber));
                    Sortieren    = "Rechnung sortieren";
                }
            });

            SelectCommand = new RelayCommand(SelectDocument);

            ChangeCommand = new RelayCommand((o) =>
            {
                Document vorhanden = DocumentHandler.Instance.GetDocument().Find(r => r.DocumentNumber == DocumentNumber);
                bool[] geandert    = new bool[4] {
                    false, false, false, false
                };
                if (vorhanden == null && documentNumber > 0 && Location != null && StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) != null &&
                    Person != null && ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(p => p == Person) != null)
                {
                    StorageLocation l = new StorageLocation()
                    {
                        Floor       = Floor,
                        RoomNumber  = RoomNumber,
                        ShelfNumber = ShelfNumber,
                        Shelf       = Shelf
                    };

                    ResponsiblePerson p = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };

                    Document d = new Document()
                    {
                        DocumentNumber   = DocumentNumber,
                        CreationDate     = DateTime.Parse(CreationDate),
                        Location         = l,
                        Person           = p,
                        BriefDescription = BriefDescription
                    };
                    if (d.CreationDate != vorhanden.CreationDate)
                    {
                        geandert[0] = true;
                    }
                    if (d.Location != vorhanden.Location)
                    {
                        geandert[1] = true;
                    }
                    if (d.Person != vorhanden.Person)
                    {
                        geandert[2] = true;
                    }
                    if (d.BriefDescription != vorhanden.BriefDescription)
                    {
                        geandert[3] = true;
                    }
                    DocumentHandler.Instance.RemoveDocument(vorhanden);
                    DocumentHandler.Instance.AddDocument(d);
                    documentsView.Add(d);
                    DocumentHandler.Instance.Change(d, geandert);
                    Cancel(o);
                    DocumentView = new ObservableCollection <Document>(DocumentHandler.Instance.GetDocument().OrderBy(docu => docu.DocumentNumber));
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("Document already exists!");
                }
                else if (documentNumber <= 0)
                {
                    MessageBox.Show("Document number can not be under 0!");
                }
                else if (Location == null)
                {
                    MessageBox.Show("Location missing!");
                }
                else if (StorageLocationHandler.Instance.GetStorageLocations().Find(l => l == Location) == null)
                {
                    MessageBox.Show($"There is no {Location}");
                }
            });
        }