/// <summary>
        /// Set the column header of tableLayoutPanel
        /// </summary>
        /// <param name="date">The date value of the first column</param>
        public void SetColumnHeader(TableLayoutPanel calendarPanel, DateTime date)
        {
            int row = 0;

            for (int col = 1; col < calendarPanel.ColumnCount; col++)
            {
                DateTimeLabel dtLbl = calendarPanel.GetControlFromPosition(col, row) as DateTimeLabel;
                dtLbl.date = date;
                dtLbl.Text = dtLbl.ToString();
                date       = date.AddDays(1);
            }
        }
예제 #2
0
        /// <summary>
        /// An empty cell on the table is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void calendarPanel_MouseClick(object sender, MouseEventArgs e)
        {
            Point?position = calendarPanel.GetRowColIndex(new Point(e.X, e.Y));

            if (position == null || position.Value.X == 0 || position.Value.Y == 0)
            {
                return;
            }
            int           resourceID = position.Value.Y - 1;
            DateTimeLabel dtLbl      = calendarPanel.GetControlFromPosition(position.Value.X, 0) as DateTimeLabel;
            DateTime      startDate  = dtLbl.date;
            DateTime      endDate    = startDate.AddDays(1);

            this.currentReservation      = new Reservation(resourceID, startDate, endDate);
            this.currentReservLbl        = new ReservationLabel(currentReservation);
            currentReservLbl.MouseClick += this.ControlLbl_Click;
            DisplayReservationDetail();
            EnableEditPanel();
        }
 /// <summary>
 /// Find out the column number correspond to a specific date.
 /// </summary>
 /// <param name="calendarPanel"></param>
 /// <param name="date"></param>
 /// <returns>The column number. If date is not in any column, then return 1 if date too small, return max column number if date is too large. </returns>
 private int FindColumnByDate(TableLayoutPanel calendarPanel, DateTime date)
 {
     for (int col = 1; col < calendarPanel.ColumnCount; col++)
     {
         DateTimeLabel dtLbl   = (DateTimeLabel)calendarPanel.GetControlFromPosition(col, 0);
         DateTime      lblDate = dtLbl.date;
         if (date.Date > lblDate.Date)
         {
             continue;
         }
         if (date.Date == lblDate.Date)
         {
             return(col);
         }
         if (date.Date < lblDate.Date)
         {
             return(1);
         }
     }
     return(calendarPanel.ColumnCount);
 }