Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _userDao        = new UserDao();
     _reservationDAO = new ReservationDAO();
     if (!IsPostBack)
     {
         ReservationGrid.DataSource = _reservationDAO.ReadAll(Status.Reserved);
         ReservationGrid.DataBind();
         Name.Text = _userDao.GetUserById(int.Parse(Context.User.Identity.Name)).FirstName;
     }
 }
Esempio n. 2
0
        private ReservationGrid CreateReservationGrid(Client client, Room room, Reservation reservation)
        {
            ReservationGrid rsvGrid = new ReservationGrid();

            rsvGrid.ID            = reservation.ID;
            rsvGrid.ClientName    = client.Name;
            rsvGrid.ClientCPF     = client.CPF;
            rsvGrid.RoomNumber    = room.Number;
            rsvGrid.EntryDate     = reservation.EntryDate;
            rsvGrid.DepartureDate = reservation.DepartureDate;

            return(rsvGrid);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FormsAuthenticationTicket cookie = FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName].Value);

            _reservationDao            = new ReservationDAO();
            ReservationGrid.DataSource = _reservationDao.GetReservationsByUserId(int.Parse(cookie.Name));
            ReservationGrid.DataBind();
            _userDao = new UserDao();
            foreach (GridViewRow r in ReservationGrid.Rows)
            {
                if (_reservationDao.GetReservationByReservationId(r.Cells[1].Text).Status != Status.Reserved)
                {
                    r.Cells[0].Controls.Clear();
                }
                Name.Text = _userDao.GetUserById(int.Parse(Context.User.Identity.Name)).FirstName;
            }
        }
 private bool ScanRowForOverlap(int maxColumns, ReservationGrid reservationGrid, LayoutInfo layoutInfo, int stopCol, int rowOffset) {
     for(int i = layoutInfo.ColumnStart; i < stopCol; i++) {
         if(reservationGrid.IsReserved(i, rowOffset)) {
             // If we hit reserved space, advance startCol past it.  If we hit the end of the row,
             // just stop.  AdvanceUntilFits will move to the next row and call us again.
             for(layoutInfo.ColumnStart = i + 1;
                 layoutInfo.ColumnStart < maxColumns && reservationGrid.IsReserved(layoutInfo.ColumnStart, rowOffset);
                 layoutInfo.ColumnStart++);
             return true;
         }
     }
     return false;
 }
 /// <devdoc>
 /// GetColStartAndStop: part of xAssignRowsAndColumns.
 ///     
 /// </devdoc>
 private void GetColStartAndStop(int maxColumns, ReservationGrid reservationGrid, LayoutInfo layoutInfo, out int colStop) {
     // Compute the column our element ends on
     colStop = layoutInfo.ColumnStart + layoutInfo.ColumnSpan;
     if(colStop > maxColumns) {
         if(layoutInfo.ColumnStart != 0) {
             // If we are not already at the beginning or a row, move down
             // to the next row.
             layoutInfo.ColumnStart = 0;
             layoutInfo.RowStart++;
         }
         // Cap colStop in case we have a element too large to fit on any row.
         colStop = Math.Min(layoutInfo.ColumnSpan, maxColumns);
     }
 }
 /// <devdoc>
 /// AdvanceUntilFits: part of xAssignRowsAndColumns.
 ///     Advances the position of layoutInfo until we have enough space and do not
 ///     collide with a rowSpanned element.  ColStop will be the column on which the
 ///     element ends (exclusive).
 /// </devdoc>
 private void AdvanceUntilFits(int maxColumns, ReservationGrid reservationGrid, LayoutInfo layoutInfo, out int colStop) {
     int prevRow = layoutInfo.RowStart;
     do {
         GetColStartAndStop(maxColumns, reservationGrid, layoutInfo, out colStop);
     } while(ScanRowForOverlap(maxColumns, reservationGrid, layoutInfo, colStop, layoutInfo.RowStart - prevRow));
 }
 /// <devdoc>
 /// IsOverlappingWithReservationGrid: part of xAssignRowsAndColumns.
 ///      check to see if the absolutely positioned layoutInfo fits in the reservation grid
 /// </devdoc>
 private bool IsOverlappingWithReservationGrid(LayoutInfo fixedLayoutInfo, ReservationGrid reservationGrid, int currentRow) {          
     //since we shall not put anything above our current row, this means that the fixedLayoutInfo overlaps with something already placed on the table
     if (fixedLayoutInfo.RowPosition < currentRow) {
         return true;
     }
     for (int rowOffset = fixedLayoutInfo.RowPosition - currentRow; rowOffset < fixedLayoutInfo.RowPosition - currentRow + fixedLayoutInfo.RowSpan; rowOffset++) {
         for (int colOffset = fixedLayoutInfo.ColumnPosition; colOffset < fixedLayoutInfo.ColumnPosition + fixedLayoutInfo.ColumnSpan; colOffset++) {
             if (reservationGrid.IsReserved(colOffset, rowOffset)) {
                 return true;
             }
         }
     }
     return false;
 }
        /// <devdoc>
        /// xAssignRowsAndColumns: part of AssignRowsAndColumns.
        ///   def: fixed element: has a specific row/column assignment (assigned by SetRow,SetColumn, or Add(c,row,column)
        ///   def: flow element: does NOT have a specific row/column assignment.
        ///
        ///   Determines the placement of fixed and flow elements.  Walks through the rows/columns - if there's a 
        ///   spot for the fixed element, place it, else place the next flow element.
        /// </devdoc>
        private bool xAssignRowsAndColumns(ContainerInfo containerInfo, LayoutInfo[] childrenInfo, int maxColumns, int maxRows, TableLayoutPanelGrowStyle growStyle) {
            Debug.Assert(maxColumns > 0, "maxColumn must be positive");
           
            int numColumns = 0;
            int numRows = 0;
            ReservationGrid reservationGrid = new ReservationGrid();
           
            int currentRow = 0;
            int currentCol = 0;

            int fixedElementIndex = -1;
            int flowElementIndex = -1;

            // make sure to snap these two collections as we're not in a "containerInfo.Valid" state
            // so we'll wind up building up the lists over and over again.          
            LayoutInfo[] fixedChildrenInfo = containerInfo.FixedChildrenInfo;
            
            
            //the element at the head of the absolutely positioned element queue
            LayoutInfo fixedElement = GetNextLayoutInfo(fixedChildrenInfo, ref fixedElementIndex, /*absolutelyPositioned*/true);
            
            //the element at the head of the non-absolutely positioned element queue
            LayoutInfo flowElement = GetNextLayoutInfo(childrenInfo, ref flowElementIndex, /*absolutelyPositioned*/false);
         
            while (fixedElement != null || flowElement != null) {

                int colStop = currentCol;
                int rowStop;
                if (flowElement != null) {
                    flowElement.RowStart = currentRow;
                    flowElement.ColumnStart = currentCol;
                    //try to layout the flowElement to see if it overlaps with the fixedElement
                    AdvanceUntilFits(maxColumns, reservationGrid, flowElement, out colStop);
                    //we have exceeded the row limit. just return
                    if (flowElement.RowStart >= maxRows) {
                        return false;
                    }
                }
                //test to see if either the absolutely positioned element is null or it fits. 
                if (flowElement != null && (fixedElement == null || (!IsCursorPastInsertionPoint(fixedElement, flowElement.RowStart, colStop) && !IsOverlappingWithReservationGrid(fixedElement, reservationGrid, currentRow)))) {                        
                    //Place the flow element.

                    //advance the rows in reservation grid
                    for (int j = 0; j < flowElement.RowStart - currentRow; j++) {
                        reservationGrid.AdvanceRow();
                    }
                    
                    currentRow = flowElement.RowStart;
                    rowStop = Math.Min(currentRow + flowElement.RowSpan, maxRows);
                    
                    //reserve spaces in the reservationGrid
                    reservationGrid.ReserveAll(flowElement, rowStop, colStop);
                    flowElement = GetNextLayoutInfo(childrenInfo, ref flowElementIndex, /*absolutelyPositioned*/false);
                }
                else {
                    //
                    //otherwise we place the fixed element.
                    //
                    if (currentCol >= maxColumns) {
                        //we have already passed the boundary. Go to next row
                        currentCol = 0;
                        currentRow++;
                        reservationGrid.AdvanceRow();
                    }
                    //set the rowStart and columnStart to fixedElement's specifed position
                    fixedElement.RowStart = Math.Min(fixedElement.RowPosition, maxRows - 1);
                    fixedElement.ColumnStart = Math.Min(fixedElement.ColumnPosition, maxColumns - 1);
                    if (currentRow > fixedElement.RowStart) {
                        //we have already passed the specifed position. set the start column to the current column
                        fixedElement.ColumnStart = currentCol;
                    }
                    else if (currentRow == fixedElement.RowStart) {
                        //set the start column to be the max of the specifed column and current column
                        fixedElement.ColumnStart = Math.Max(fixedElement.ColumnStart, currentCol);
                    }
                    else {
                        //set the start column to the specified column, which we have already done
                    }
                    fixedElement.RowStart = Math.Max(fixedElement.RowStart, currentRow);

                    //advance the reservation grid 
                    int j;
                    for (j = 0; j < fixedElement.RowStart - currentRow; j++) {
                        reservationGrid.AdvanceRow();
                    }

                    //try to layout the absolutely positioned element as if it were non-absolutely positioned.
                    //In this way we can tell whether this element overlapps with others or fits on the table.
                    AdvanceUntilFits(maxColumns, reservationGrid, fixedElement, out colStop);

                    //we have exceeded the row limit. just return
                    if (fixedElement.RowStart >= maxRows) {
                        return false;
                    }

                    for (; j < fixedElement.RowStart - currentRow; j++) {
                        //advance the reservation grid if the fixedElement's row position has changed during layout
                        reservationGrid.AdvanceRow();
                    }
                    currentRow = fixedElement.RowStart;
                    
                    //make sure that we truncate the element's column span if it is too big
                    colStop = Math.Min(fixedElement.ColumnStart + fixedElement.ColumnSpan, maxColumns); 
                    rowStop = Math.Min(fixedElement.RowStart + fixedElement.RowSpan, maxRows);             

                    //reserve space in the reservation grid
                    reservationGrid.ReserveAll(fixedElement, rowStop, colStop);    

                    fixedElement = GetNextLayoutInfo(fixedChildrenInfo, ref fixedElementIndex, /*absolutelyPositioned*/true);
                }               
                currentCol = colStop;
                numRows    = (numRows    == Int32.MaxValue) ? rowStop : Math.Max(numRows, rowStop);
                numColumns = (numColumns == Int32.MaxValue) ? colStop : Math.Max(numColumns, colStop);                     
            }  

            Debug.Assert(numRows <= maxRows, "number of rows allocated shouldn't exceed max number of rows");
            Debug.Assert(numColumns <= maxColumns, "number of columns allocated shouldn't exceed max number of columns");


            // we should respect columncount and rowcount as according to GrowStyle.
            if (growStyle == TableLayoutPanelGrowStyle.FixedSize) {
                // now that we've calculated the assignments - use the "max" as the actual number of rows.
                numColumns = maxColumns;
                numRows = maxRows;
            }
            else if (growStyle == TableLayoutPanelGrowStyle.AddRows) {
				numColumns = maxColumns;
				numRows = Math.Max(containerInfo.MaxRows, numRows);
            }
            else { // add columns
                numRows = (maxRows == Int32.MaxValue) ? numRows : maxRows;
                numColumns = Math.Max(containerInfo.MaxColumns, numColumns);
            }

            // PERF: prevent overallocation of Strip[] arrays.  We're going to null these guys out
            // anyways... so only allocate when the number of rows and columns is different.
            if (containerInfo.Rows == null || containerInfo.Rows.Length != numRows) {
                containerInfo.Rows = new Strip[numRows];
            }
            if (containerInfo.Columns == null || containerInfo.Columns.Length != numColumns) {
                containerInfo.Columns = new Strip[numColumns];
            }

            containerInfo.Valid = true;
            return true;

        }