コード例 #1
0
        private void addTableToControl(Control inControl, DTOReservable inTable)
        {
            ReservableTableView newTableView = new ReservableTableView();

            int tableCountInControl = inControl.Controls.Count;

            newTableView.Name = string.Format(@"table{0}", tableCountInControl);
            newTableView.Size = new System.Drawing.Size(TableWidth, TableHeight);

            int x = Convert.ToInt16(inTable.X);
            int y = Convert.ToInt16(inTable.Y);

            int width  = Convert.ToInt16(inTable.Width);
            int height = Convert.ToInt16(inTable.Height);

            newTableView.Location = new System.Drawing.Point(x, y);
            newTableView.Size     = new System.Drawing.Size(width, height);
            newTableView.TabIndex = tableCountInControl;
            newTableView.Caption  = inTable.Name;
            newTableView.TabIndex = tableCountInControl;

            newTableView.MouseDown += canvasTable_MouseDown;

            scaleTableView(inControl, editingFloorPlan.currentLocation, inTable, newTableView);
            selectTableView(newTableView, false);

            //.................................

            inControl.Controls.Add(newTableView);
        }
コード例 #2
0
        private void addNewTable(DTOLocation inLocation, int inTableShape)
        {
            int    tableNumber = Helper.nextTableNumber();
            string tableName   = string.Format(@"Table{0}", tableNumber);
            int    tableShape  = inTableShape; // Table Shape: 0 => Square "e",  1 => Round "r"

            string[] tableShapes = { @"r", @"e" };

            DialogResult dialogResult = Helper.TableInputBox(@"New Table", @"Table Name", @"Table Number", ref tableName, ref tableShape, ref tableNumber);

            switch (dialogResult)
            {
            case DialogResult.OK:
                resetRectTracker();

                DTOReservable newTable = new DTOReservable();
                newTable.Name   = tableName;
                newTable.Number = tableNumber;
                newTable.Shape  = tableShapes[tableShape];
                newTable.X      = 20;
                newTable.Y      = 20;
                newTable.Width  = TableWidth;
                newTable.Height = TableHeight;

                editingFloorPlan.addNewTable(newTable);
                editingFloorPlan.signalTablesChanged();

                selectTableView(addTableToCanvas(canvas, inLocation, newTable));
                this.toolStripDropDownButtonTables.Enabled = true;

                break;
            }
        }
コード例 #3
0
        private void addRoundTableToControl(Control inControl, DTOReservable inTable)
        {
            ReservableRoundTableView newTable = new ReservableRoundTableView();

            int tableCountInControl = inControl.Controls.Count;

            newTable.Name = string.Format(@"table{0}", tableCountInControl);
            newTable.Size = new System.Drawing.Size(TableWidth, TableHeight);

            int x = Convert.ToInt16(inTable.X);
            int y = Convert.ToInt16(inTable.Y);

            newTable.Location = new System.Drawing.Point(x, y);
            newTable.TabIndex = tableCountInControl;
            newTable.Caption  = inTable.Name;
            newTable.TabIndex = tableCountInControl;

            newTable.MouseDown += canvasTable_MouseDown;

            selectTableView(newTable, false);

            //.................................

            inControl.Controls.Add(newTable);
        }
コード例 #4
0
        private void scaleTableViews(Control inCanvas, DTOLocation inLocation)
        {
            clearBckImgage();

            DTOReservable[] tablesInLocation = getTablesInLocation(inLocation);

            double xScale = 1;
            double yScale = 1;

            calculateScaleFactors(inCanvas, inLocation, ref xScale, ref yScale);

            int i = 0;

            foreach (Control tableView in inCanvas.Controls)
            {
                try
                {
                    DTOReservable table = tablesInLocation[i++];
                    tableView.Left = bckImgOrigin.X + Convert.ToInt16(table.X * xScale);
                    tableView.Top  = bckImgOrigin.Y + Convert.ToInt16(table.Y * yScale);

                    tableView.Width  = Convert.ToInt16(table.Width * xScale);
                    tableView.Height = Convert.ToInt16(table.Height * yScale);
                }
                catch
                {
                }
            }
        }
コード例 #5
0
ファイル: EditingFloorPlan.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="document"></param>
        /// <exceptions>
        ///    <exception name="TableNotFoundException" description="Unknown table for the curent location"></exception>
        /// </exceptions>
        /// <returns></returns>
        public int indexOfTable(DTOReservable inTable)
        {
            int result = -1;

            //...................................

            int i = 0;

            foreach (DTOReservable table in _tablesInLocation)
            {
                if (inTable.Id == table.Id)
                {
                    result = i;
                    break;
                }
                i++;
            }

            //...................................

            if (result > -1)
            {
                return(result);
            }
            else
            {
                throw new TableNotFoundException(inTable.Name, this.currentLocation.Name);
            }
        }
コード例 #6
0
        private void showSquareTableInCanvas(Control inCanvas, DTOReservable inTable)
        {
            addTableToControl(inCanvas, inTable);

            //addTableToControl(inCanvas, inTable, @"round square lightgray lightocean 90x72 T.png");
            //addTableToControl(inCanvas, inTable, @"C:\software\source\menumate\5.3\MenuMate\Services\Menumate.Services\client\img\png\round square lightgray lightocean 90x72 T.png");
        }
コード例 #7
0
        private void updateCurrentTableName(string inName)
        {
            try
            {
                DTOReservable table = editingFloorPlan.currentTable;

                if (table.Name != inName)
                {
                    table.Name = inName;
                    editingFloorPlan.signalTablesChanged();

                    currentTableView.Caption = inName;

                    toolStripDropDownButtonTables.DropDownItems.Clear();

                    foreach (DTOReservable tb in editingFloorPlan.tablesInLocation)
                    {
                        addItemsToToolStripDropDownButton(toolStripDropDownButtonTables, tb.Name);
                        //addItemsToToolStripDropDownButton(toolStripDropDownButtonTables, string.Format(@"{0} - {1}", tb.Name, tb.Number));
                    }

                    toolStripDropDownButtonTables.Text = inName;
                }
            }
            catch
            {
            }
        }
コード例 #8
0
ファイル: PosIntegrationService.cs プロジェクト: radtek/Pos
        // ---------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OperationResult UpdateReservable(DTOReservable tableDTO)
        {
            OperationResult result = new OperationResult();

            //::::::::::::::::::::::::::::::::::::::::::

            using (TransactionScope scope = new TransactionScope(TransactionMode.New, OnDispose.Commit))
            {
                try
                {
                    Table    tableToUpdate = Table.Find(tableDTO.Id);
                    Location location      = Location.Find(tableToUpdate.ParentLocation.Id);

                    location.UpdateTable(tableToUpdate, tableDTO.Name, tableDTO.MaxGuests, tableDTO.X, tableDTO.Y, tableDTO.Width, tableDTO.Height, tableDTO.Shape, tableDTO.Number);

                    result.Success        = true;
                    result.ObjectAffected = tableDTO.Id;
                    result.Message        = string.Format("Table id => {0} update ok", tableDTO.Id);

                    ServiceLogger.Log(result.Message);
                }
                catch (ReservableAlreadyExistsException rae)
                {
                    scope.VoteRollBack();

                    // TODO: logging, proper message in result

                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = rae.ToString();

                    ServiceLogger.LogException(string.Format("Table already exists => {0}.", tableDTO.ToString()), rae);
                }
                catch (Castle.ActiveRecord.NotFoundException nfe)
                {
                    scope.VoteRollBack();
                    // TODO: logging, proper message in result
                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = nfe.ToString();

                    ServiceLogger.LogException(string.Format("Table not found => {0}.", tableDTO.ToString()), nfe);
                }
                catch (ActiveRecordException are)
                {
                    scope.VoteRollBack();
                    // TODO: logging, proper message in result
                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = are.ToString();

                    ServiceLogger.LogException(string.Format("Table => {0}.", tableDTO.ToString()), are);
                }
            }

            //::::::::::::::::::::::::::::::::::::::::::

            return(result);
        }
コード例 #9
0
ファイル: PosIntegrationService.cs プロジェクト: radtek/Pos
        // ---------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OperationResult AddReservable(DTOReservable tableDTO, DTOLocation locationDTO)
        {
            OperationResult result = new OperationResult();

            //::::::::::::::::::::::::::::::::::::::::::

            using (TransactionScope scope = new TransactionScope(TransactionMode.New, OnDispose.Commit))
            {
                try
                {
                    DTOHelpers.ValidateReservableDTO(tableDTO);
                    DTOHelpers.ValidateLocationDTO(locationDTO);

                    Location location = Location.Find(locationDTO.Id);
                    Table    table    = DTOHelpers.TableFromDTO(tableDTO);

                    location.AddTable(table);

                    result.Success        = true;
                    result.ObjectAffected = table.Id;
                    result.Message        = String.Format("{0} added successfully to {1}", tableDTO.ToString(), location.ToString());

                    ServiceLogger.Log(string.Format("Table {0} added to location {1}", tableDTO.Name, location.Name));
                }
                catch (ActiveRecordException are)
                {
                    scope.VoteRollBack();
                    result.Success = false;
                    result.Message = string.Format("Could not add table {0};{1}{2}", tableDTO.Name, Environment.NewLine, are.ToString());

                    ServiceLogger.LogException(string.Format("Could not add table {0}", tableDTO.Name), are);
                }
                catch (ReservableAlreadyExistsException rree)
                {
                    scope.VoteRollBack();
                    result.Success = false;
                    result.Message = string.Format("A table called => {0} already exists;{1}{2}", tableDTO.Name, Environment.NewLine, rree.ToString());

                    ServiceLogger.LogException(string.Format("A table called => {0} already exists", tableDTO.Name), rree);
                }
                catch (InvalidDTOException ide)
                {
                    scope.VoteRollBack();
                    result.Success = false;
                    result.Message = string.Format("Problem with supplied information, cannot add table {0}; {1}{2}", tableDTO.Name, Environment.NewLine, ide.ToString());

                    ServiceLogger.LogException(string.Format("Problem with supplied information, cannot add table {0}", tableDTO.Name), ide);
                }
            }

            //::::::::::::::::::::::::::::::::::::::::::

            return(result);
        }
コード例 #10
0
ファイル: EditingFloorPlan.cs プロジェクト: radtek/Pos
 /// <summary>
 ///
 /// </summary>
 /// <param name="document"></param>
 /// <exceptions>
 ///    <exception name="PosIntegration client Exception" description="Any Exception coming from PosIntegration client"></exception>
 ///    <exception name="NoCurrentLocationException" description="Could not save a table as no current location has been set"></exception>
 /// </exceptions>
 /// <returns></returns>
 protected void saveTable(DTOReservable inTable)
 {
     // Exceptions are caught in saveTables method !!!!
     if (inTable.Id == 0)
     {
         _posIntegrationClient.AddReservable(inTable, this.currentLocation);
     }
     else
     {
         _posIntegrationClient.UpdateReservable(inTable);
     }
 }
コード例 #11
0
ファイル: EditingFloorPlan.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="document"></param>
        /// <exceptions>
        ///    <exception name="Exception" description="Try to remove an unknown table"></exception>
        /// </exceptions>
        /// <returns></returns>
        public void removeTable(DTOReservable inTable)
        {
            try
            {
                if (inTable.Id > 0)
                {
                    _removedTables.Add(inTable);
                }

                _tablesInLocation.Remove(inTable);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #12
0
        private void updateCurrentTableNumber(int inNumber)
        {
            try
            {
                DTOReservable table = editingFloorPlan.currentTable;

                if (table.Number != inNumber)
                {
                    table.Number = inNumber;
                    editingFloorPlan.signalTablesChanged();
                }
            }
            catch
            {
            }
        }
コード例 #13
0
ファイル: PosIntegrationService.cs プロジェクト: radtek/Pos
        // ---------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OperationResult DeleteReservable(DTOReservable tableDTO, DTOLocation locationDTO)
        {
            OperationResult result = new OperationResult();

            //::::::::::::::::::::::::::::::::::::::::::

            using (TransactionScope txnScope = new TransactionScope(TransactionMode.New, OnDispose.Commit))
            {
                try
                {
                    Table table = Table.Find(tableDTO.Id);

                    // remove the reference to the table from the location
                    Location loc = Location.Find(locationDTO.Id);
                    loc.RemoveTable(table);

                    result.Success        = true;
                    result.Message        = string.Format("Table => {0} deleted ok.", tableDTO.Name);
                    result.ObjectAffected = tableDTO.Id;

                    ServiceLogger.Log(result.Message);
                }
                catch (InvalidOperationException ioe)
                {
                    txnScope.VoteRollBack();
                    result.Success        = false;
                    result.Message        = string.Format("Cannot delete table => {0}{1}{2}.", tableDTO.ToString(), Environment.NewLine, ioe.ToString());
                    result.ObjectAffected = tableDTO.Id;

                    ServiceLogger.LogException(string.Format("Cannot delete table => {0}.", tableDTO.ToString()), ioe);
                }
                catch (ActiveRecordException are)
                {
                    txnScope.VoteRollBack();

                    result.Success        = false;
                    result.Message        = string.Format("Error when trying to delete Table => {0};{1}{2}", tableDTO.Name, Environment.NewLine, are.ToString());
                    result.ObjectAffected = tableDTO.Id;

                    ServiceLogger.LogException(string.Format("Error when trying to delete Table => {0}", tableDTO.Name), are);
                }
            }

            //::::::::::::::::::::::::::::::::::::::::::

            return(result);
        }
コード例 #14
0
        private void scaleDTOTable(Control inCanvas, DTOLocation inLocation, DTOReservable inTable, ReservableTableView inTableView)
        {
            double xScale = 1;
            double yScale = 1;

            calculateScaleFactors(inCanvas, inLocation, ref xScale, ref yScale);

            try
            {
                inTable.X = (inTableView.Left - bckImgOrigin.X) / xScale;
                inTable.Y = (inTableView.Top - bckImgOrigin.Y) / yScale;

                inTable.Width  = inTableView.Width / xScale;
                inTable.Height = inTableView.Height / yScale;
            }
            catch
            {
            }
        }
コード例 #15
0
        private void scaleTableView(Control inCanvas, DTOLocation inLocation, DTOReservable inTable, ReservableTableView inTableView)
        {
            double xScale = 1;
            double yScale = 1;

            calculateScaleFactors(inCanvas, inLocation, ref xScale, ref yScale);

            try
            {
                inTableView.Left = bckImgOrigin.X + Convert.ToInt16(inTable.X * xScale);
                inTableView.Top  = bckImgOrigin.Y + Convert.ToInt16(inTable.Y * yScale);

                inTableView.Width  = Convert.ToInt16(inTable.Width * xScale);
                inTableView.Height = Convert.ToInt16(inTable.Height * yScale);
            }
            catch
            {
            }
        }
コード例 #16
0
        private void deleteTable(ReservableTableView inTableView, DTOLocation inLocation, Control inCanvas)
        {
            if (inTableView != null)
            {
                DTOReservable tableDTO = editingFloorPlan.tablesInLocation[inTableView.TabIndex];

                if (doThis(string.Format(@"Delete table: {0}", tableDTO.Name)))
                {
                    inCanvas.Controls.Remove(inTableView);
                    editingFloorPlan.removeTable(tableDTO);
                    editingFloorPlan.signalTableDeleted();

                    resetRectTracker();
                    clearSelectedTableView();

                    this.toolStripDropDownButtonTables.Enabled = posIntegrationOK() && (editingFloorPlan.tablesInLocation.Length > 0);
                }
            }
        }
コード例 #17
0
ファイル: FloorPlanRunner.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="inTable"></param>
        /// <param name="inLocation"></param>
        private void pSaveDTOTable(TableInfo inTable, DTOLocation inLocation)
        {
            if (inTable.Modified)
            {
                DTOReservable dtoTable = new DTOReservable();

                dtoTable.Id     = inTable.ID;
                dtoTable.Name   = inTable.Name;
                dtoTable.Number = inTable.Number;
                dtoTable.X      = inTable.PosX;
                dtoTable.Y      = inTable.PosY;
                dtoTable.Height = inTable.Height;
                dtoTable.Width  = inTable.Width;
                dtoTable.Shape  = (inTable.Shape == TableShape.Rectangle) ? @"r" : @"s";

                _posIntegrationClient.UpdateReservable(dtoTable);

                _tableInfoBuilder.MakeTableNoLongerModified(inTable);
            }
        }
コード例 #18
0
ファイル: FloorPlanRunner.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="inID"></param>
        /// <returns></returns>
        private DTOReservable pDTOTableWithID(int inID)
        {
            DTOReservable result = null;

            //:::::::::::::::::::::::::::::::::

            DTOReservable[] dtoTables = _posIntegrationClient.GetTablesForLocation(LocationInUse.ID);

            foreach (DTOReservable dtoTable in dtoTables)
            {
                if (dtoTable.Id == inID)
                {
                    result = dtoTable;
                    break;
                }
            }

            //:::::::::::::::::::::::::::::::::

            return(result);
        }
コード例 #19
0
ファイル: FloorPlanRunner.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="inLocation"></param>
        private void pAddNewDTOTable(TableInfo inTable, DTOLocation inDTOLocation)
        {
            DTOReservable dtoTable = new DTOReservable();

            dtoTable.Name   = inTable.Name;
            dtoTable.Number = inTable.Number;
            dtoTable.X      = inTable.PosX;
            dtoTable.Y      = inTable.PosY;
            dtoTable.Height = inTable.Height;
            dtoTable.Width  = inTable.Width;
            dtoTable.Shape  = (inTable.Shape == TableShape.Rectangle) ? @"r" : @"e";

            _posIntegrationClient.AddReservable(dtoTable, inDTOLocation);

            DTOReservable[] dtoTables = _posIntegrationClient.GetTablesForLocation(inDTOLocation.Id);
            int             tableID   = dtoTables[dtoTables.Length - 1].Id;

            _tableInfoBuilder.AssignTableID(inTable, tableID);
            _tableInfoBuilder.MakeTableNoLongerNew(inTable);
            _tableInfoBuilder.MakeTableNoLongerModified(inTable);
        }
コード例 #20
0
        public TableInfo BuildTableInfo(DTOReservable inDTOReservable)
        {
            TableInfo result = new TableInfo();

            //::::::::::::::::::::::::::::::::::::::::::::::::::

            result.Shape = (inDTOReservable.Shape.ToUpper() == @"R") ? TableShape.Rectangle : TableShape.Elipse;

            result._new      = false;
            result._id       = inDTOReservable.Id;
            result.Name      = inDTOReservable.Name;
            result.Number    = inDTOReservable.Number;
            result.PosX      = inDTOReservable.X;
            result.PosY      = inDTOReservable.Y;
            result.Width     = inDTOReservable.Width;
            result.Height    = inDTOReservable.Height;
            result._modified = false;

            //::::::::::::::::::::::::::::::::::::::::::::::::::

            return(result);
        }
コード例 #21
0
ファイル: EditingFloorPlan.cs プロジェクト: radtek/Pos
        /// <summary>
        ///
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public void addNewTable(DTOReservable inNewTable)
        {
            inNewTable.Id = 0;

            _tablesInLocation.Add(inNewTable);
        }
コード例 #22
0
        private ReservableTableView addTableToCanvas(Control inCanvas, DTOLocation inLocation, DTOReservable inNewTable)
        {
            switch (inNewTable.Shape)
            {
            case @"r":
                showSquareTableInCanvas(inCanvas, inNewTable);
                break;

            case @"e":
                showRoundTableInCanvas(inCanvas, inNewTable);
                break;
            }

            ReservableTableView newTableView = (ReservableTableView)(inCanvas.Controls[inCanvas.Controls.Count - 1]);

            scaleTableView(inCanvas, inLocation, inNewTable, newTableView);

            addItemsToToolStripDropDownButton(toolStripDropDownButtonTables, inNewTable.Name);

            return(newTableView);
        }
コード例 #23
0
        private void showRoundTableInCanvas(Control inCanvas, DTOReservable inTable)
        {
            addRoundTableToControl(inCanvas, inTable);

            //addTableToControl(inCanvas, inTable, @"circle lightgray orange 90x72 T.png");
        }