
namespace 点餐系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2;
this.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2;
foreach (Control control in flowLayoutPanel1.Controls)
{
Button btn = new Button();
foreach (Control item in control.Controls)
{
if (item.Tag.ToString()=="index")
{
btn.Text = item.Text;
btn.Size = new Size(50,50);
btn.Font = new Font("", 15);
}
}
flowLayoutPanel10.Controls.Add(btn);
btn.Click += Btn_Click;
btn.Tag = control;
}
}
int count = 0;
private void Btn_Click(object sender, EventArgs e)
{
Button clickbtn = (Button)sender;
Control menu = (Control)clickbtn.Tag;
Label label = new Label();
foreach (Control item in menu.Controls)
{
if (item.Tag.ToString()=="name")
{
label.Text = item.Text;
}
if (item.Tag.ToString()=="money")
{
count += int.Parse(item.Text);
label.Tag = item.Text;
}
}
label.Font = new Font("", 15);
flowLayoutPanel11.Controls.Add(label);
label28.Text = count + "¥";
label.Click += Label_Click;
}
private void Label_Click(object sender, EventArgs e)
{
Label label = (Label)sender;
label.Dispose();
count -=int.Parse(label.Tag.ToString());
label28.Text = count + "¥";
}
}
}