Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 private void AddTableButton()
 {
     try
     {
         // Get table status from web service
         TableService.TableService service = new TableService.TableService();
         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 (tableSelect != null && tableStatus[cnt + 1].TableID == tableSelect.TableID)
                 {
                     // Selected Table
                     button.ObjectValue = tableStatus[cnt + 1].TableID;
                     button.Red = 1.75f;
                     button.Green = 1.75f;
                     button.Blue = 1;
                 }
                 else if (multiTemp != null && multiTemp.Contains(tableInfo[cnt + 1]))
                 {
                     // Multi Selected Table
                     button.ObjectValue = tableStatus[cnt + 1].TableID;
                     tableStatus[cnt + 1].InUse = false;
                     button.Red = 2;
                     button.Green = 2;
                     button.Blue = 1;
                 }
                 else if (tableStatus[cnt + 1].InUse)
                 {
                     // Use table
                     button.ObjectValue = -tableStatus[cnt + 1].TableID;
                     button.Red = 1;
                     button.Green = 2;
                     button.Blue = 2;
                 }
                 else
                 {
                     // No select
                     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) % 7) == 0)
                 {
                     x = 13; y += button.Height + 10;
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }