/// <summary>
 /// Initial form when start take order.
 /// (Call this method from outside)
 /// </summary>
 public override void UpdateForm()
 {
     LoadMenus();
     // Check for reserve mode
     takeOutMode = (tableInfo.TableID == 0);
     OrderService.OrderService service = new OrderService.OrderService();
     if (!takeOrderResume)
     {
         // Load old table order information (Web Services)
         if (!takeOutMode)
         {
             orderInfo = service.GetOrder(tableInfo.TableID);
             if (orderInfo != null)
             {
                 if (tableInfo.TableID != orderInfo.TableID)
                 {
                     TableService.TableService tabService = new TableService.TableService();
                     tableInfo = tabService.GetTableInformation(orderInfo.TableID);
                 }
                 tableIDList = service.GetTableReference(orderInfo.OrderID);
             }
             else
                 tableIDList = null;
         }
         else if (takeOutOrderID > 0)
         {
             orderInfo = service.GetOrderByOrderID(takeOutOrderID);
             tableIDList = null;
         }
         else
         {
             orderInfo = null;
             tableIDList = null;
         }
         // Reset input
         isChanged = false;
     }
     else
     {
         if (!takeOutMode)
             orderInfo = service.GetOrder(tableInfo.TableID);
     }
     // Check exist order information
     if (orderInfo != null)
     {
         // Found (Edit order)
         guestNumber = orderInfo.NumberOfGuest;
         billNumber = orderInfo.Bills.Length;
     }
     else if (guestNumber <= 0)
     {
         // Not found (New order)
         guestNumber = billNumber = 1;
     }
     // Check Demo version
     if (AppParameter.IsDemo())
     {
         ListOrderItem.ItemWidth = 240;
         ListOrderCount.Left = 248;
         ListOrderItemBy.Visible = true;
         LblGuest.Text = "Guest";
     }
     else
     {
         ListOrderItem.ItemWidth = 280;
         ListOrderCount.Left = 288;
         ListOrderItemBy.Visible = false;
         LblGuest.Text = "Seat";
     }
     ListOrderCount.Left = ListOrderItem.Left + ListOrderItem.ItemWidth;
     // Clear Input
     selectedBill = null;
     selectedItem = null;
     selectedType = null;
     if (orderInfo != null && orderInfo.Bills != null)
     {
         for (int i = 0;i < orderInfo.Bills.Length;i++)
             if (orderInfo.Bills[i].CloseBillDate == DateTime.MinValue)
             {
                 selectedBill = orderInfo.Bills[i];
                 break;
             }
     }
     // Update screen
     LblPageID.Text = "Employee ID:" + ((MainForm)MdiParent).UserID + " | ";
     if (takeOutMode)
         LblPageID.Text += "STTO021";
     else
         LblPageID.Text += "STTO011";
     PanCustName.Visible = takeOutMode;
     BtnSearch.Visible = takeOutMode;
     OptionPad.AutoRefresh = false;
     OptionPad.Red = OptionPad.Green = OptionPad.Blue = 1;
     OptionPad.AutoRefresh = true;
     ListOrderItem.Reset();
     ListOrderCount.Reset();
     ListOrderItemBy.Reset();
     UpdateTableInformation();
     StartInputMenu();
 }
 /// <summary>
 /// This method call TableService.GetTableList() for get all tables' information
 /// and create objects in TableInfo array list.
 /// </summary>
 private void LoadTableInformation()
 {
     TableService.TableService service = new TableService.TableService();
     tableInfo = service.GetTableList();
     while (tableInfo == null)
     {
         DialogResult result = MessageBox.Show("Can't load table information.", "Error",
             MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         if (result == DialogResult.Cancel)
             ((MainForm)this.MdiParent).Exit();
         else
             tableInfo = service.GetTableList();
     }
     // Search table object by table id = 0 (Take Out Table)
     for (int i = 0;i < tableInfo.Length;i++)
     {
         if (tableInfo[i].TableID == 0)
         {
             takeOutTable = tableInfo[i];
             break;
         }
     }
 }
Exemplo n.º 3
0
 private void LoadTableInformation()
 {
     smartRestaurant.TableService.TableService service = new smartRestaurant.TableService.TableService();
     this.tableInfo = service.GetTableList();
     while (this.tableInfo == null)
     {
         if (MessageBox.Show("Can't load table information.", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand) == DialogResult.Cancel)
         {
             ((MainForm) base.MdiParent).Exit();
         }
         else
         {
             this.tableInfo = service.GetTableList();
         }
     }
     for (int i = 0; i < this.tableInfo.Length; i++)
     {
         if (this.tableInfo[i].TableID == 0)
         {
             this.takeOutTable = this.tableInfo[i];
             return;
         }
     }
 }
 /*private void AddTableButton()
 {
     try
     {
         // Get table status from web service
         TableService.TableService service = new TableService.TableService();
         TableStatus[] tableStatus = service.GetTableStatus();
         // Create button to screen
         ImageButton button;
         Image img = ButtonImgList.Images[0];
         Image imgClick = ButtonImgList.Images[1];
         int x, y;
         bool newButton = false;
         x = 13; y = 48;
         if (tableStatus != null && tableStatus.Length > 1)
         {
             // Table not include ID = 0
             if (tableButtons == null || tableButtons.Length != tableStatus.Length - 1)
             {
                 TablePanel.Controls.Clear();
                 tableButtons = new ImageButton[tableStatus.Length - 1];
                 newButton = true;
             }
             for (int cnt = 0;cnt < tableStatus.Length - 1;cnt++)
             {
                 if (newButton)
                 {
                     button = new ImageButton();
                     button.Image = img;
                     button.ImageClick = imgClick;
                     button.Left = x;
                     button.Top = y;
                     button.Text = tableStatus[cnt + 1].TableName;
                 }
                 else
                     button = tableButtons[cnt];
                 // Check Table Status
                 if (tableStatus[cnt + 1].InUse)
                 {
                     button.ObjectValue = -tableStatus[cnt + 1].TableID;
                     button.Red = 1;
                     button.Green = 2;
                     button.Blue = 2;
                 }
                 else
                 {
                     button.ObjectValue = tableStatus[cnt + 1].TableID;
                     button.Red = 1;
                     button.Green = 1;
                     button.Blue = 1;
                 }
                 // Add event and control
                 if (newButton)
                 {
                     button.Click += new EventHandler(this.Table_Click);
                     TablePanel.Controls.Add(button);
                     tableButtons[cnt] = button;
                 }
                 x += button.Width + 10;
                 if (((cnt + 1) % 8) == 0)
                 {
                     x = 13; y += button.Height + 10;
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }*/
 /// <summary>
 /// This method use for check all table information and create button item on
 /// table list button.
 /// </summary>
 private void AddTableButton()
 {
     try
     {
         TablePad.AutoRefresh = false;
         TablePad.Red = 1;
         TablePad.Green = 1;
         TablePad.Blue = 1;
         TablePad.Items.Clear();
         // Get table status from web service
         TableService.TableService service = new TableService.TableService();
         tableStatus = service.GetTableStatus();
         // Create button to screen
         if (tableStatus != null && tableStatus.Length > 1)
         {
             // Table not include ID = 0
             for (int cnt = 0;cnt < tableStatus.Length - 1;cnt++)
             {
                 ButtonItem item = new ButtonItem(tableStatus[cnt + 1].TableName, null);
                 TablePad.Items.Add(item);
                 // Check Table Status
                 if (tableStatus[cnt + 1].InUse)
                     item.Value = ((int)(-tableStatus[cnt + 1].TableID)).ToString();
                 else
                     item.Value = tableStatus[cnt + 1].TableID.ToString();
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
     finally
     {
         TablePad.AutoRefresh = true;
     }
 }
Exemplo n.º 5
0
 public override void UpdateForm()
 {
     if (AppParameter.DeliveryModeOnly)
     {
         this.BtnMain.Visible = false;
         this.BtnManager.Visible = ((MainForm) base.MdiParent).User.IsManager() || ((MainForm) base.MdiParent).User.IsAuditor();
         this.BtnExit.Visible = true;
     }
     else
     {
         this.BtnMain.Visible = true;
         this.BtnManager.Visible = false;
         this.BtnExit.Visible = false;
     }
     if (this.tableInfo == null)
     {
         smartRestaurant.TableService.TableService service = new smartRestaurant.TableService.TableService();
         TableInformation[] tableList = service.GetTableList();
         while (tableList == null)
         {
             if (MessageBox.Show("Can't load table information.", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand) == DialogResult.Cancel)
             {
                 ((MainForm) base.MdiParent).Exit();
             }
             else
             {
                 tableList = service.GetTableList();
             }
         }
         for (int i = 0; i < tableList.Length; i++)
         {
             if (tableList[i].TableID == 0)
             {
                 this.tableInfo = tableList[i];
                 break;
             }
         }
         if (this.tableInfo == null)
         {
             ((MainForm) base.MdiParent).Exit();
         }
     }
     this.selectedTakeOut = null;
     this.selectedRoad = null;
     this.roadIgnoreFlag = false;
     this.roadLstIgnoreFlag = false;
     this.LblPageID.Text = "Employee ID:" + ((MainForm) base.MdiParent).UserID + " | STTO020";
     this.UpdateTakeOutList();
     if (this.FieldFName.Text == "")
     {
         this.BtnCustList_Click(null, null);
     }
     else
     {
         this.BtnCustSearch_Click(null, null);
     }
     this.FieldPhone.Focus();
 }