Ejemplo n.º 1
0
        public CleaningLog addCleaningLog(CleaningLog cleaningLog)
        {
            Connection con = Connection.getConnection();

            con.db.CleaningLog.Add(cleaningLog);
            con.db.SaveChanges();
            return(cleaningLog);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public int getLastID()
        {
            Connection  con         = Connection.getConnection();
            CleaningLog cleaningLog = (from c in con.db.CleaningLog orderby c.cleaningLogID descending select c).FirstOrDefault();

            if (cleaningLog == null)
            {
                return(0);
            }
            else
            {
                return(cleaningLog.cleaningLogID);
            }
        }
Ejemplo n.º 4
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();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public CleaningLog addCleaningLog(CleaningLog cleaningLog)
        {
            CleaningLogRepository repository = new CleaningLogRepository();

            return(repository.addCleaningLog(cleaningLog));
        }