예제 #1
0
        public CleaningLog createNewCleaningLog(int roomID, string desc, DateTime?cleaningDate)
        {
            CleaningLogMediator mediator = new CleaningLogMediator();

            CleaningLog cleaningLog = new CleaningLog();

            cleaningLog.cleaningLogID = mediator.getLastID() + 1;
            cleaningLog.roomID        = roomID;
            cleaningLog.description   = desc;
            cleaningLog.cleaningDate  = cleaningDate;

            return(cleaningLog);
        }
예제 #2
0
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            string   roomIDStr    = roomIDTxt.Text.Trim();
            string   desc         = descTxt.Text;
            DateTime?cleaningDate = cleaningDatePicker.SelectedDate;
            int      roomID;

            if (roomIDStr == "" || desc == "" || !cleaningDate.HasValue)
            {
                errorLbl.Text = "Please input all field!";
            }
            else
            {
                bool success = int.TryParse(roomIDStr, out roomID);
                if (!success)
                {
                    errorLbl.Text = "RoomID must be a number!";
                }
                else
                {
                    if (new RoomMediator().getRoom(roomID) == null)
                    {
                        errorLbl.Text = "Room doesn't exist";
                    }
                    else
                    {
                        CleaningLogFactory  factory  = new CleaningLogFactory();
                        CleaningLogMediator mediator = new CleaningLogMediator();

                        CleaningLog cleaningLog = mediator.addCleaningLog(factory.createNewCleaningLog(roomID, desc, cleaningDate));
                        if (cleaningLog == null)
                        {
                            MessageBox.Show("Add cleaning log failed!");
                        }
                        else
                        {
                            MessageBox.Show("Add cleaning log success!");
                        }
                        this.Close();
                    }
                }
            }
        }
예제 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CleaningLogMediator mediator = new CleaningLogMediator();

            cleaningLogView.ItemsSource = mediator.getAllCleaningLog();
        }