private void GetControlTable()
        {
            Panel newpanel = null;

            Function1.Connect con1 = null;
            DataTable         dt1  = new DataTable();
            DataTable         dt   = null;

            dt1 = con.laybang("Select* from R_Floor");

            for (int j = 0; j < dt1.Rows.Count; j++)
            {
                con1              = new Function1.Connect();
                dt                = new DataTable();
                newpanel          = new Panel();
                dt                = con1.laybang("Select TableName,TableNumber from R_Tables where FloorID='" + Convert.ToInt32(dt1.Rows[j]["ID"].ToString()) + "'");
                newpanel.Size     = new Size(571, 75);
                newpanel.AutoSize = true;
                newpanel.Name     = "pnFloor" + dt1.Rows[j]["ID"].ToString();
                if (dt.Rows.Count > 7)
                {
                    newpanel.Location = new Point(26, 48 + (j * 81) + 38);
                }
                else if (dt.Rows.Count > 14)
                {
                    newpanel.Location = new Point(26, 48 + (j * 81) + 72);
                }
                else
                {
                    newpanel.Location = new Point(26, 48 + (j * 81));
                }
                this.Controls.Add(newpanel);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Button newButton = new Button();
                    newButton.Text   = dt.Rows[i]["TableName"].ToString();
                    newButton.Name   = "btn" + dt.Rows[i]["TableNumber"].ToString();
                    newButton.Height = 35;
                    newButton.Width  = 70;
                    if (i > 7)
                    {
                        newButton.Location = new Point(3 + ((i - 8) * 81), 39 + 43);
                    }
                    else if (i > 14)
                    {
                        newButton.Location = new Point(3 + ((i - 15) * 81), 39 + 86);
                    }
                    else
                    {
                        newButton.Location = new Point(3 + (i * 81), 39);
                    }
                    newButton.Location = new Point(3 + (i * 81), 39);
                    newpanel.Controls.Add(newButton);
                }
                TextBox textbox = new TextBox();
                textbox.Text      = dt1.Rows[j]["FloorName"].ToString();
                textbox.BackColor = Color.LightGray;
                textbox.Name      = "txtfloor" + dt1.Rows[j]["ID"].ToString();
                textbox.Size      = new Size(563, 20);
                textbox.TextAlign = HorizontalAlignment.Center;
                textbox.Enabled   = false;
                textbox.Location  = new Point(3, 3);
                newpanel.Controls.Add(textbox);
                dt.Dispose();
                con1.dongketnoi();
            }
        }
Example #2
0
        private void GetControlTable()
        {
            con = new Connect();
            Panel newpanel  = null;
            Panel newpanel1 = null;

            newpanel1                   = new Panel();
            newpanel1.Size              = new Size(616, 455);
            newpanel1.AutoSize          = false;
            newpanel1.AutoScrollMinSize = new System.Drawing.Size(616, 455);
            newpanel1.Location          = new Point(26, 35);
            newpanel1.Name              = "pnTotal";
            this.Controls.Add(newpanel1);
            Function1.Connect con1 = null;
            DataTable         dt1  = new DataTable();
            DataTable         dt   = null;

            dt1 = con.laybang("Select* from R_Floor");

            for (int j = 0; j < dt1.Rows.Count; j++)
            {
                con1          = new Function1.Connect();
                dt            = new DataTable();
                newpanel      = new Panel();
                dt            = con1.laybang("Select * from R_Tables where FloorID='" + Convert.ToInt32(dt1.Rows[j]["ID"].ToString()) + "'");
                newpanel.Size = new Size(609, 87);
                //newpanel.AutoSize = true;
                newpanel.Name       = "pnFloor" + dt1.Rows[j]["ID"].ToString();
                newpanel.Location   = new Point(3, 3 + (j * 90));
                newpanel.AutoScroll = true;
                newpanel1.Controls.Add(newpanel);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Button newButton = new Button();
                    newButton.Text = dt.Rows[i]["TableName"].ToString();
                    newButton.Name = "btn" + dt.Rows[i]["TableNumber"].ToString();
                    string tesst      = dt.Rows[i]["Status"].ToString();
                    string tesstorder = dt.Rows[i]["TableOrder"].ToString();

                    newButton.Click   += new EventHandler(button_Click);
                    newButton.MouseUp += new MouseEventHandler(Control_DoubleClick);
                    newButton.Height   = 35;
                    newButton.Width    = 70;
                    if (tesst == "True" && tesstorder == "False")
                    {
                        newButton.BackColor = Color.Red;
                    }
                    else if (tesstorder == "True" && tesst == "False")
                    {
                        newButton.BackColor = Color.Yellow;
                        //newButton.MouseUp += new MouseEventHandler(Order_DoubleClick);
                    }
                    else
                    {
                        newButton.BackColor = Color.White;
                    }
                    if (i > 7 && i < 15)
                    {
                        newButton.Location = new Point(3 + ((i - 8) * 74), 90);
                    }
                    else if (i > 15)
                    {
                        newButton.Location = new Point(3 + ((i - 15) * 74), 151);
                    }
                    else
                    {
                        newButton.Location = new Point(3 + (i * 74), 29);
                    }
                    newpanel.Controls.Add(newButton);
                    CheckBox newcheckbox = new CheckBox();
                    newcheckbox.Name = "ckb" + dt.Rows[i]["TableNumber"].ToString();
                    if (tesst == "True")
                    {
                        newcheckbox.Enabled = false;
                        newcheckbox.Checked = false;
                    }
                    newcheckbox.Size = new Size(15, 14);
                    if (i > 7 && i < 15)
                    {
                        newcheckbox.Location = new Point(30 + ((i - 8) * 74), 131);
                    }
                    else if (i > 15)
                    {
                        newcheckbox.Location = new Point(30 + ((i - 15) * 74), 192);
                    }
                    else
                    {
                        newcheckbox.Location = new Point(30 + (i * 74), 70);
                    }
                    newpanel.Controls.Add(newcheckbox);
                }
                TextBox textbox = new TextBox();
                textbox.Text      = dt1.Rows[j]["FloorName"].ToString();
                textbox.BackColor = Color.LightGray;
                textbox.Name      = "txtfloor" + dt1.Rows[j]["ID"].ToString();
                textbox.Size      = new Size(595, 20);
                textbox.TextAlign = HorizontalAlignment.Center;
                textbox.Anchor    = AnchorStyles.Bottom;
                textbox.Anchor    = AnchorStyles.Top;
                textbox.Anchor    = AnchorStyles.Left;
                textbox.Anchor    = AnchorStyles.Right;
                textbox.Enabled   = false;
                textbox.Location  = new Point(3, 3);
                newpanel.Controls.Add(textbox);
                dt.Dispose();
                con1.dongketnoi();
            }
        }