饭店点菜系统一、开发简介(一)背景本学期系统学习了VB程序设计课程,按照惯例,在学期结束时进行VB程序设计课程软件的开发,也就是本次课程设计。
(二)课题名称这次课程设计的课题为饭店点菜系统(三)开发工具及开发环境开发工具:Microsoft Visual Basic 6.0开发环境:Windows 20003 Server二、开发流程其中软件设计部分采用的流程:三、需求分析(1).登录打开饭店菜式管理系统程序,进入主界面。
通过输入用户名和密码登录到菜品式管理界面两个按钮可以分别进入菜式管理系统和退出系统。
(2).菜式管理系统通过输入用户名和密码进入到了菜式管理界面,点击菜式管理菜单,对菜式进行添加和删除,以及退出程序。
三个按钮可以分别进入到点菜系统、菜式浏览系统以及返回主界面。
(3).点菜系统通过点击菜式管理系统的点菜按钮进入到点菜系统。
此界面有两个列表框,分别放饭店里所有菜式以及已点的菜,再通过点菜按钮将饭店菜式列表框里的菜点到已点列表框里,通过退菜按钮对已点列表框里的菜进行删除。
在点菜和退菜的同时还对菜式价格进行计算。
点菜完成后进行落单,点击返回管理界面按钮返回管理系统界面。
(4).菜式管理系统通过点击菜式管理系统的菜式浏览按钮进入到菜式浏览系统。
通过点击按菜名、价格和菜系浏览菜单,对菜式分别进行浏览。
点击返回管理界面按钮返回管理里系统。
四、软件设计(一)解决方案和软件特色解决方案:由于本人才刚接触VB,所学的知识还比较浅,所以就用比较简单的语句来完整本次设计。
软件特色:本软件具有操作简单方便,能给服务员和顾客朋友们提供很大的便利,这是本系统的一大特色!(二)具体设计下面我就从软件的使用流程来具体介绍软件的功能和实现原理:(1)各模块之间的关系以及代码和图列:Public i As IntegerPublic sum As SingleType caidan cm As Stringcx As Stringjg As Integeryl As Stringzk As SingleEnd TypePublic s() As caidanFunction chazhao(ByVal n As String) As IntegerDim j As IntegerFor j = 1 To iIf n = s(j).cm Then chazhao = jIf n = s(j).cx Then chazhao = jIf n = Str(s(j).jg) Then chazhao = jIf n = s(j).yl Then chazhao = jIf n = Str(s(j).zk) Then chazhao = jNext jEnd Function1.酒店菜单登陆系统:附本窗体代码:Private Sub Command1_Click()Dim mes%If Text1.Text = "jane" And Text2.Text = "123456" ThenForm1.HideForm2.ShowElsemes = MsgBox("用户名或密码错误,请重新输入!") Text1.Text = "" Text2.Text = ""End IfEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()Text2.PasswordChar = "*"End Sub2.菜式管理系统:Private Sub mnufileadd_Click()ReDim Preserve s(1 To (i + 1)) As caidani = i + 1s(i).cm = InputBox("请输入菜名", "新增")s(i).cx = InputBox("请输入菜系", "新增")s(i).jg = InputBox("请输入价格", "新增")s(i).yl = InputBox("请输入原料", "新增")s(i).zk = InputBox("请输入折扣", "新增") End SubPrivate Sub mnufiledel_Click()Dim j As IntegerDim k As IntegerDim n As Stringn = InputBox("请输入查找的关键字", "查找")j = chazhao(n)For k = j To i - 1s(k) = s(k + 1)Next ki = i – 1End SubPrivate Sub mnufileqiute_Click()EndEnd SubPublic Function chazhao(ByVal n As String) As IntegerDim j As IntegerFor j = 1 To iIf n = s(j).cm Then chazhao = jIf n = s(j).cx Then chazhao = jIf n = Str(s(j).jg) Then chazhao = jIf n = s(j).yl Then chazhao = jIf n = Str(s(j).zk) Then chazhao = jNext jEnd Function3.点菜系统:主要由a 菜品类别选择b显示所选菜品c显示菜品的样图三部分实现,用到了select case语句对项目进行选择a点comb1进行选则菜品类别,包括热菜,凉菜,点心,主食,饮品、Comb1中自动加载菜品的几大种类,代码为:Private Sub Form_Load()Combo1.AddItem "凉菜"Combo1.AddItem "热菜"Combo1.AddItem "饮品"Combo1.AddItem "点心"Combo1.AddItem "主食"End Subb单击comb1中的不同的项,comb2加载相应的菜品内容单击凉菜,comb2清除原有内容,显示凉菜种类及价格Private Sub Combo1_Click()Select Case Combo1.TextCase "凉菜" ‘单击“凉菜”Combo2.ClearCombo2.AddItem "拌黑白木耳 15"‘comb2添加 "拌黑白木耳 15Combo2.AddItem "酱汁牛肚 20"‘comb2添加项”酱汁牛肚 20”Combo2.AddItem "凉拌海带丝 15"‘comb2添加项"凉拌海带丝 15"Combo2.AddItem "凉拌海蜇皮 10"‘comb2添加项凉拌海蜇皮 10Combo2.AddItem "凉拌胡萝卜 10" ‘comb2添加项凉拌胡萝卜 10 、Combo2.AddItem "麻辣黄瓜 10" ‘comb2添加项麻辣黄瓜 10Combo2.AddItem "什锦大拌菜 20" ‘comb2添加项什锦大拌菜 20Combo2.AddItem "香鲁鸡爪 25" ‘comb2添加项香鲁鸡爪 25单击热菜,comb2中加在相应热菜的名称及价格Case "热菜"Combo2.ClearCombo2.AddItem "炒茄丝 15"Combo2.AddItem "海陆包 15"Combo2.AddItem "荷叶蒸粉肉 20"Combo2.AddItem "糖醋排骨 30"Combo2.AddItem "虾子面筋 25"Combo2.AddItem "杏仁炖肉 25"Combo2.AddItem "云蒸西芹炒肉片 25"Combo2.AddItem "炸鸡肉串 20"Combo2.AddItem "鲍汁扣鹅掌 30"Combo2.AddItem "叉烧 25"Combo2.AddItem "二头鲍鱼 30"Combo2.AddItem "佛手咸水鱼 35"Combo2.AddItem "海虾咸水饺 20"Combo2.AddItem "肉酱蒸河粉 20"单击”饮品”,comb2中加在相应饮品的名称及价格Case "饮品"Combo2.ClearCombo2.AddItem "山城啤酒 3"Combo2.AddItem "泸州老窖 60"Combo2.AddItem "橙汁 8"Combo2.AddItem "葡萄酒 50"Combo2.AddItem "花生奶 15"Combo2.AddItem "芒果饮料 15"Combo2.AddItem "花样饮乳 20"单击主食,comb2中加载主食的名称及价格Case "主食"Combo2.ClearCombo2.AddItem "米饭 5"Combo2.AddItem "香菜饺 10"Combo2.AddItem "肉混沌 15"单击点心,comb2中加载主食及其价格Case "点心"Combo2.ClearCombo2.AddItem "草莓点心 20"Combo2.AddItem "脆锅饼 15"Combo2.AddItem "凉粉卷 15"Combo2.AddItem "糖果点心 15"Combo2.AddItem "银耳果羹 20"Combo2.AddItem "早茶 20"End Select ‘结束筛选End Suc在image1中显示所选菜品的图片用if end if语句, 代码及解释Private Sub Combo2_Click() ‘单击comb2中的项Dim str As Stringstr = Combo2.List(Combo2.ListIndex)List1.AddItem Combo2.TextIf Combo2.Text = "米饭 5" ThenImage1.Picture = LoadPicture(App.Path & "\图片\主食\米饭.jpg")‘在其同源文件夹中加载图片名为米饭,属性为jpg的图片,到image1中End IfIf Combo2.Text = "香菜饺 10" ThenImage1.Picture = LoadPicture(App.Path & "\图片\主食\香菜饺.jpg")‘在其同源文件夹中加载图片名为香菜饺,属性为jpg的图片,到image1中 End IfIf Combo2.Text = "肉混沌 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\主食\肉混沌.jpg")‘在其同源文件夹中加载图片名为肉混沌,属性为jpg的图片,到image1 End IfIf Combo2.Text = "草莓点心 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\草莓点心.jpg")End IfIf Combo2.Text = "脆锅饼 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\脆锅饼.jpg")End IfIf Combo2.Text = "凉粉卷 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\凉粉卷.jpg")If Combo2.Text = "银耳果羹 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\银耳果羹.jpg")End IfIf Combo2.Text = "糖果点心 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\糖果点心.jpg")End IfIf Combo2.Text = "早茶 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\点心\早茶.jpg")End IfIf Combo2.Text = "拌黑白木耳 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\拌黑白木耳.jpg")End IfIf Combo2.Text = "酱汁牛肚 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\酱汁牛肚.jpg")End IfIf Combo2.Text = "凉拌海带丝 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\凉拌海带丝.jpg")End IfIf Combo2.Text = "凉拌海蜇皮 10" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\凉拌海蜇皮.jpg")End IfIf Combo2.Text = "凉拌胡萝卜 10" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\凉拌胡萝卜.jpg")End IfIf Combo2.Text = "麻辣黄瓜 10" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\麻辣黄瓜.jpg") End If If Combo2.Text = "什锦大拌菜 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\什锦大拌菜.jpg")End IfIf Combo2.Text = "酱汁牛肚 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\酱汁牛肚.jpg")End IfIf Combo2.Text = "香鲁鸡爪 25" ThenImage1.Picture = LoadPicture(App.Path & "\图片\凉菜\香鲁鸡爪.jpg")End IfIf Combo2.Text = "炒茄丝 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\炒茄丝.jpg")End IfIf Combo2.Text = "海陆包 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\海陆包.jpg")End IfIf Combo2.Text = "荷叶蒸粉肉 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\荷叶蒸粉肉.jpg")If Combo2.Text = "糖醋排骨 30" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\糖醋排骨.jpg")End IfIf Combo2.Text = "虾子面筋 25" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\虾子面筋.jpg")End IfIf Combo2.Text = "杏仁炖肉 25" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\杏仁炖肉.jpg")End IfIf Combo2.Text = "云蒸西芹炒肉片 25" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\云蒸西芹炒肉片.jpg") End IfIf Combo2.Text = "炸鸡肉串 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\炸鸡肉串.jpg")End IfIf Combo2.Text = "鲍汁扣鹅掌 30" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\鲍汁扣鹅掌.jpg") End IfIf Combo2.Text = "叉烧 25" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\叉烧.jpg")End IfIf Combo2.Text = "二头鲍鱼 30" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\二头鲍鱼.jpg")End IfIf Combo2.Text = "佛手咸水鱼 35" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\佛手咸水鱼.jpg") End IfIf Combo2.Text = "海虾咸水饺 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\海虾咸水饺.jpg") End IfIf Combo2.Text = "肉酱蒸河粉 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\热菜\肉酱蒸河粉.jpg") End IfIf Combo2.Text = "山城啤酒 3" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\山城啤酒.jpg")End IfIf Combo2.Text = "泸州老窖 60" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\泸州老窖.jpg")End IfIf Combo2.Text = "橙汁 8" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\橙汁.jpg")End IfIf Combo2.Text = "葡萄酒 50" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\葡萄酒.jpg") End IfIf Combo2.Text = "花样饮乳 20" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\花样饮乳.jpg") End IfIf Combo2.Text = "芒果饮料 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\芒果饮料.jpg") End IfIf Combo2.Text = "花生奶 15" ThenImage1.Picture = LoadPicture(App.Path & "\图片\饮品\花生奶.jpg") End Ifd计价模块在label 5中计算消费金额其代码为Sum = Sum + Val(Right(List1.Text, 2))Label5 = "消费金额:" & Sum & "元"End Sube删除不需要的菜品单击command1事件触发代码为rivate Sub Command1_Click()If List1.ListIndex <> -1 Then‘如果list1中选中的项目不为空X = List1.ListIndexList1.RemoveItem X ‘删除X项ElseEnd If4.菜式浏览器:Private Sub cm_Click()For j = 1 To i - 1For k = i To j + 1 Step -1If s(k).cm < s(k - 1).cm Thenm = s(k).cm: s(k).cm = s(k - 1).cm: s(k - 1).cm = mm = s(k).cx: s(k).cx = s(k - 1).cx: s(k - 1).cx = mm = s(k).jg: s(k).jg = s(k - 1).jg: s(k - 1).jg = mm = s(k).yl: s(k).yl = s(k - 1).yl: s(k - 1).yl = mm = s(k).zk: s(k).zk = s(k - 1).zk: s(k - 1).zk = mEnd IfNext kNext jClsPrint Chr(13), Chr(13), Chr(13), Chr(13), Chr(13) For j = 1 To iPrint s(j).cm, s(j).cx, s(j).jg, s(j).yl, s(j).zkNext jEnd SubPrivate Sub Command1_Click()Unload Form4Form3.ShowEnd SubPrivate Sub cx_Click()For j = 1 To i - 1For k = i To j + 1 Step -1 If s(k).cx < s(k - 1).cx Then m = s(k).cm: s(k).cm = s(k - 1).cm: s(k - 1).cm = mm = s(k).cx: s(k).cx = s(k - 1).cx: s(k - 1).cx = mm = s(k).jg: s(k).jg = s(k - 1).jg: s(k - 1).jg = mm = s(k).yl: s(k).yl = s(k - 1).yl: s(k - 1).yl = mm = s(k).zk: s(k).zk = s(k - 1).zk: s(k - 1).zk = mEnd IfNext kNext jClsPrint Chr(13), Chr(13), Chr(13), Chr(13), Chr(13)For j = 1 To iPrint s(j).cm, s(j).cx, s(j).jg, s(j).yl, s(j).zkNext jEnd SubPrivate Sub Form_Load()ShowPrintPrint Chr(13), Chr(13), Chr(13), Chr(13), Chr(13)For j = 1 To iPrint s(j).cm, s(j).cx, s(j).jg, s(j).yl, s(j).zkNext jEnd SubPrivate Sub jg_Click()For j = 1 To i - 1For k = i To j + 1 Step -1If s(k).jg < s(k - 1).jg Thenm = s(k).cm: s(k).cm = s(k - 1).cm: s(k - 1).cm = mm = s(k).cx: s(k).cx = s(k - 1).cx: s(k - 1).cx = mm = s(k).jg: s(k).jg = s(k - 1).jg: s(k - 1).jg = mm = s(k).yl: s(k).yl = s(k - 1).yl: s(k - 1).yl = mm = s(k).zk: s(k).zk = s(k - 1).zk: s(k - 1).zk = mEnd IfNext kNext jClsPrint Chr(13), Chr(13), Chr(13), Chr(13), Chr(13)For j = 1 To iPrint s(j).cm, s(j).cx, s(j).jg, s(j).yl, s(j).zkNext jEnd Sub5.留言板系统:Private Sub Command1_Click()If Text1.Text = "" ThenMsgBox "留言不能为空!", vbOKOnly + vbExclamation, "注意" '留言为空时,弹出对话框,提醒顾客留言Text1.SetFocusEnd IfIf Text2.Text = "" ThenMsgBox "签名不能为空!", vbOKOnly + vbExclamation, "注意" '签名为空时,弹出对话框,提醒顾客签名Text2.SetFocusEnd IfIf Text1.Text <> "" And Text2.Text <> "" ThenList1.AddItem Text2.Text & "说:" & Text1.Text & " " & Now Open App.Path & "\data\留言.dat" For Append As #1Write #1, Text2.Text & "说:" & Text1.Text & " " & Now '把留言内容保存到文件夹内Close #1Text1.Text = "" '清空留言和Text2.Text = ""End IfEnd SubPrivate Sub Command2_Click()Form2.Show '关闭留言板界面加载主界面Form5.Hide End SubPrivate Sub Command3_Click()End '退出程序End SubPrivate Sub Command4_Click()Open App.Path & "\data\留言.dat" For Output As #1 '点击清楚时,保存在文件中的所有留言被清空Write #1, ""Close #1Dim a As StringList1.Clear End SubPrivate Sub Form_Load()Open App.Path & "\data\留言.dat" For Input As #1 '当留言板窗体被载入,系统读取文件夹中所有留言,并将其显示在留言板中While Not EOF(1)Line Input #1, aList1.AddItem aWendClose #1label1.Left = Form1.ScaleWidthEnd SubPrivate Sub Timer1_Timer()If label1.Left + label1.Width > 0 Then '滚动字幕label1.Move label1.Left – 50Elselabel1.Left = Form1.ScaleWidthEnd IfEnd SubPrivate Sub Timer3_Timer()Label2.Caption = "小老鼠报时: " & Now '显示当前的日期和时间End6抽奖系统:Dim i As Integer, j As Integer, k As Integer, m As IntegerPrivate Sub Form_Load()Timer1.Interval = 100 '设置时间间隔为100毫秒Timer1.Enabled = False 'timer1事件不允许执行End SubPrivate Sub Timer1_Timer()Label5.Caption = Round(Rnd() * 9, 0)i = Label5.Caption 'i 等于Label5上产生的0-9间的随机数 Label6.Caption = Round(Rnd() * 9, 0)j = Label6.Caption 'j 等于Label6上产生的0-9间的随机数 Label7.Caption = Round(Rnd() * 9, 0)k = Label7.Caption 'k 等于Label7上产生的0-9间的随机数 Label8.Caption = Round(Rnd() * 9, 0)m = Label8.Caption 'm 等于Label8上产生的0-9间的随机数End SubPrivate Sub Command1_Click() 'command1单击事件Timer1.Enabled = True 'timer1事件允许执行Command1.Enabled = False 'command1事件不允许执行 End Sub Private Sub Command2_Click() 'command2单击事件Timer1.Enabled = False 'timer1事件不允许执行If i = j And j = k And k = m Then '进入if then循环Label10.Caption = "恭喜您获得特等奖!!"Image1.Picture = LoadPicture(App.Path & "\菜谱\奖品\特等奖.jpg") 'Image1加载特等奖图片ElseIf i = j And j = k Then '当前三个相同时Label10.Caption = "恭喜您获得一等奖!!"Image1.Picture = LoadPicture(App.Path & "\菜谱\奖品\一等奖.jpg")'Image1加载一等奖图片ElseIf i <> j And j = k And k <> m Then '当只有中间二个相同时Label10.Caption = "恭喜您获得二等奖!!"Image1.Picture = LoadPicture(App.Path & "\菜谱\奖品\二等奖.jpg") 'Image1加载二等奖图片ElseIf i <> k And j <> k And k = m Then '当最后二个相同时 Label10.Caption = "恭喜您获得三等奖!!"Image1.Picture = LoadPicture(App.Path & "\菜谱\奖品\三等奖.jpg") 'Image1加载三等奖图片 ElseLabel10.Caption = "谢谢回顾"Image1.Picture = LoadPicture(App.Path & "\菜谱\奖品\谢谢.gif") 'Image1加载谢谢图片End IfCommand2.Enabled = False'command2不允许执行 End SubPrivate Sub Command3_Click() 'command3单击事件Form4.Hide 'form4隐藏Form2.Show 'form2显示End Sub五、设计心得经过这几天的VB课程设计,我解决实际问题的能力提高了并学会了自主学习,自我提高和自我完善,用已学过VB知识及的自学数据库技术编写程序。