Exemplo n.º 1
0
        private void dtStart_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            Controller.RoomController            roomController       = new Controller.RoomController();
            Controller.BasicRenovationController renovationController = new Controller.BasicRenovationController();
            List <Model.Room> rooms;

            lvDataBinding.Items.Clear();
            foreach (Model.Room room in roomController.GetAllRooms())
            {
                bool add = true;
                foreach (Model.BasicRenovation renovation in renovationController.GetAllRenovations())
                {
                    if (room.RoomId == renovation.room.RoomId)
                    {
                        if ((DateTime.Compare(renovation.StartTime, DateTime.Parse(dtStart.SelectedDate.ToString())) <= 0) && (DateTime.Compare(renovation.EndTime, DateTime.Parse(dtStart.SelectedDate.ToString())) >= 0))
                        {
                            add = false;
                        }
                    }
                }
                if (add)
                {
                    room.free = "Slobodna";
                }
                else
                {
                    room.free = "Zauzeta";
                }
                lvDataBinding.Items.Add(room);
            }
        }
 private void addRenovation()
 {
     Controller.BasicRenovationController controller = new Controller.BasicRenovationController();
     controller.GetAllRenovations();
     Model.BasicRenovation basicRenovation = new Model.BasicRenovation(controller.renovationService.renovationRepository.getNextRenovationId(),
                                                                       int.Parse(lbuID.Content.ToString()), DateTime.Parse(renovationSeparation.dpDateRenovationStart.Text.ToString() + " " + renovationSeparation.tbStartTime.Text.ToString()),
                                                                       DateTime.Parse(renovationSeparation.dpDateRenovationEnd.Text.ToString() + " " + renovationSeparation.tbEndTime.Text.ToString()), "Create room");
     controller.CreateRenovation(basicRenovation);
 }
        public RenovationGeneral(RenovationAdd renovationAdd)
        {
            InitializeComponent();
            this.DataContext = this;
            roomController   = new Controller.RoomController();

            addRenovation        = renovationAdd;
            renovationController = addRenovation.renovationController;
            LoadRooms();
        }
 private void DeleteRoom()
 {
     if (int.Parse(lbArea.Content.ToString()) == 0)
     {
         Controller.BasicRenovationController basicRenovationController = new Controller.BasicRenovationController();
         basicRenovationController.GetAllRenovations();
         Model.BasicRenovation basicRenovation = new Model.BasicRenovation(basicRenovationController.renovationService.renovationRepository.getNextRenovationId(),
                                                                           int.Parse(cbRooms.SelectedItem.ToString()), DateTime.Parse(dpDateRenovationStart.Text.ToString() + " " + tbStartTime.Text.ToString()),
                                                                           DateTime.Parse(dpDateRenovationEnd.Text.ToString() + " " + tbEndTime.Text.ToString()), "Separating room");
         basicRenovationController.CreateRenovation(basicRenovation);
         roomController.DeleteRoom(int.Parse(cbRooms.SelectedItem.ToString()));
     }
 }
Exemplo n.º 5
0
        public bool IsRoomFreeRenovations(DateTime newStartTime, DateTime newEndTime, int roomId)
        {
            Controller.BasicRenovationController renovationController = new Controller.BasicRenovationController();
            List <Model.BasicRenovation>         renovations          = renovationController.GetAllRenovations();

            foreach (BasicRenovation renovation in renovations)
            {
                //if(((ex.StartTime<=newTime1) && (ex.EndTime>newTime1)) || ((ex.StartTime<newTime2)&&(ex.EndTime>=newTime2)))
                int start1 = DateTime.Compare(renovation.StartTime, newStartTime);
                int start2 = DateTime.Compare(renovation.EndTime, newStartTime);
                int end1   = DateTime.Compare(renovation.StartTime, newEndTime);
                int end2   = DateTime.Compare(renovation.EndTime, newEndTime);


                if (((start1 <= 0 && start2 >= 0) || (end1 <= 0 && end2 >= 0) || (start1 >= 0 && end2 <= 0)) && (roomId == renovation.room.RoomId))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 6
0
 public RenovationAdd(RenovationList renovationList)
 {
     InitializeComponent();
     this.RenovationList  = renovationList;
     renovationController = RenovationList.renovationController;
 }
Exemplo n.º 7
0
 public RenovationList()
 {
     InitializeComponent();
     renovationController = new Controller.BasicRenovationController();
     LoadAllRenovations();
 }