• 简单的点餐系统


    使用了menuStrip 菜单组件,">"为button1,"<"为button2,"下单"为button3 ,两个ListBox

    画好菜单后

    private void button1_Click(object sender, EventArgs e)
            {
    
                for (int i = 0; i < listBox1.SelectedItems.Count; i++)  //选择菜品然后计数
                {
                    string menu = listBox1.SelectedItems[i].ToString();  
                    listBox2.Items.Add(menu);
                }
            }
            private void button2_Click(object sender, EventArgs e)
            {
                for (int i = listBox2.SelectedItems.Count-1; i >=0 ; i--)  //重最后一个开始删除
                {
                    listBox2.Items.Remove(listBox2.SelectedItems[i]);
                }
            }
    

      

     private void SetListMenu(string[] data)   //定义一个方法
            {
                listBox1.Items.Clear();
                for (int i = 0; i < data.Length; i++)
                {
                    listBox1.Items.Add(data[i]);
                }
            }
    

      

    插入菜品

     private void 中餐ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "辣子鸡丁", "红烧排骨", "麻婆豆腐", "香脆里脊",
                                    "糖醋排骨", "宫保鸡丁", "香酥鸡",
                                    "醋熘白菜", "小鸡炖蘑菇", "猪肉炖粉条", "芹菜香干", "鱼香肉丝" };
                SetListMenu(data);
            }                                                    
     
    
            private void 西餐ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "牛排", "猪扒", "意大利面", "鸡扒", "香辣鸡腿堡", "培根汉堡" };
                SetListMenu(data);
            }
    
            private void 红酒ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "拉斐", "长城干红", "华夏干红", "张裕" };
                SetListMenu(data);
            }
    
            private void 饮料ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "雪碧", "可乐", "奶茶", "红茶", "咖啡", "果汁", "开水" };
                SetListMenu(data);
            }
    
            private void 汤ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "冬瓜排骨汤", "罗宋汤", "老鸭汤", "老母鸡汤", "紫菜蛋花汤", "三鲜汤" };
                SetListMenu(data);
            }
    
            private void 冰激凌ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "草莓", "巧尔滋", "圣代", "哈根达斯" };
                SetListMenu(data);
            }
    
            private void 点心ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "巧克力蛋糕", "草莓蛋糕", "苹果派", "水果" };
                SetListMenu(data);
            }
    
            private void 小食ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string[] data = { "汉堡", "炸鸡腿", "薯条", "鸡块" };
                SetListMenu(data);
            }
    
          
    

    前面有几个组合菜品没有添加,因为我没有想到有什么菜!!!  

    最后面下单显示

     private void button3_Click(object sender, EventArgs e)
            {
                string msg = string.Format("	您共点餐{0}项
    
    点餐时间:{1}", listBox2.Items.Count,DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                MessageBox.Show(msg);
            }
    

      

  • 相关阅读:
    Flask常用插件
    Mac使用Pyenv管理Python版本
    JS类似于C#中List的Where取FirstOrDefault写法
    MSSQL中Repalce函数处理长字符串时报异常的解决方案
    sqlcmd执行含中文等字符的sql脚本时报错解决方案
    使用7z程序CLI实现基础功能
    VBA中Selection.TypeText长度限制的替代写法
    .Net中Aspose组件调试技巧
    使用Foxit Reader实现批量打印以及一页多版设置技巧
    html2canvas中toDataURL方法返回值为:data,解决方案
  • 原文地址:https://www.cnblogs.com/zhouyon/p/7995207.html
Copyright © 2020-2023  润新知