Ejemplo n.º 1
0
 /// <summary>
 /// Called when the user double clicks a cell in the room booking view. If the cell matches the HH:mm-regex, a new EditView is opened on the specified hour, with the logged in person and on the room on that row. Else the cell is marked as yellow until un-hovered
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void HandleCellDoubleClick(object sender, CellClickEventArgs e)
 {
     if (e.ColumnIndex > 4)
     {
         e.SubItem.BackColor = System.Drawing.Color.Yellow;
         if (e.ClickCount == 2 && this.LoggedInUser != null)
         {
             string itemText = e.SubItem.Text;
             if (Regex.IsMatch(itemText, "[0-9]{2}:[0-9]{2}"))
             {
                 // Updating logged in user
                 this.LoggedInUser = (Person) new DAL(this).Get(LoggedInUser).First();
                 Room    targetRoom = (Room)e.Model;
                 Booking b          = new Booking();
                 b.RoomId   = targetRoom.Id;
                 b.PersonId = this.LoggedInUser.Id;
                 DateTime parsedDate = DateTime.Parse(e.SubItem.Text);
                 DateTime startDate  = new DateTime(OnDateFilter.Year, OnDateFilter.Month, OnDateFilter.Day, parsedDate.Hour, parsedDate.Minute, 0);
                 b.Start_time = startDate;
                 b.End_time   = b.Start_time.AddHours(1);
                 EditView           ev             = new EditView(b, false);
                 EditViewController editController = new EditViewController(ev, guiMainController: this, disableBookingTimePicker: true);
                 ev.Show();
             }
         }
         else if (this.LoggedInUser == null)
         {
             this.NotifyExceptionToView("Vänligen logga in för att boka rum");
         }
     }
 }
        /// <summary>
        /// Shows a new EditView when the user edits a person and right clicks a booking item and clicks Edit
        /// </summary>
        /// <param name="selectedBookingInRightClickMenu">The Booking item to be edited</param>
        public void ShowNewEditView(Booking selectedBookingInRightClickMenu)
        {
            EditView           innerEditView   = new EditView(selectedBookingInRightClickMenu, true);
            EditViewController innerController = new EditViewController(innerEditView, outerEditViewController: this);

            innerEditView.Show();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Show an EditView with the param IModel
 /// </summary>
 /// <param name="model">The model that sets the controls. Its attributes can be set or empty.</param>
 /// <param name="isExistingItemInDatabase">If the IModel is an existing item in the database, to know if the ID should be updated or inserted when Save is clicked.</param>
 private void ShowEditView(IModel model, bool isExistingItemInDatabase)
 {
     if (model != null)
     {
         EditView           ev             = new EditView(model, isExistingItemInDatabase);
         EditViewController editController = new EditViewController(ev, this);
         ev.Show();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Called when the user clicks my profile in the MenuStrip
 /// </summary>
 public void HandleMyProfileMenuStripClick()
 {
     if (this.LoggedInUser != null)
     {
         DAL dal = new DAL(this);
         this.LoggedInUser = (Person)dal.Get(this.LoggedInUser).First();
         EditView           ev             = new EditView(this.LoggedInUser, isExistingItemInDatabase: true, isMyProfileClick: true);
         EditViewController editController = new EditViewController(ev);
         ev.Show();
     }
 }
        public EditViewController(EditView editView, AdminTabController adminController = null, EditViewController outerEditViewController = null, GUIMainController guiMainController = null, bool disableBookingTimePicker = false)
        {
            this.EditView                    = editView;
            this.EditView.Controller         = this;
            this.isExistingObjectInDatabase  = this.EditView.IsExistingItemInDatabase;
            this.AdminController             = adminController;
            this.OuterEditViewController     = outerEditViewController;
            this.GuiMainController           = guiMainController;
            this.identifyingAttributesValues = new Dictionary <string, object>();

            this.DisableBookingTimePicker = disableBookingTimePicker;

            this.InitialStatusOnReferencingModels = new Dictionary <Type, Dictionary <IModel, bool> >();
            this.changedStatusOnReferencingModels = new Dictionary <Type, Dictionary <IModel, bool> >();

            this.EditView.InitializeLoad();
        }