Dim strSql As String '判断用户是否存在
strSql = \用户 where 用户编号='\登录密码='\从数数据库中查询相应首字母的词条
str.CursorLocation = adUseClient
str.Open strSql, conn, adOpenStatic, adLockReadOnly '执行SQL语句
With str
Static Try_Times As Integer If .State = adStateOpen Then .Close .Open strSql If .EOF Then
Try_Times = Try_Times + 1 If Try_Times >= 3 Then
MsgBox \您已连续三次输入错误,系统将自动关闭\vbOKOnly + vbCritical, \警告\
Unload Me '若用户连续输入3次错误密码,则系统关闭 Else
MsgBox \对不起,用户名不存在或密码错误 !\\警告\
Text1.SetFocus Text1.Text = \ Text2.Text = \ End If
Else
Unload Me '若登录成功,则隐藏当前窗体 主页.Show '然后显示Form窗体 End If End With End Sub
Private Sub Command3_Click() End End Sub
12
3.2主页
3.2.1主页界面设计
3.2.2 代码
Private Sub book_Click() Unload Me 菜单.Show End Sub
Private Sub clerk_Click() Unload Me 职员.Show End Sub
Private Sub food_Click() Unload Me 食品.Show End Sub
13
3.3 点餐管理
3.3.1点餐界面设计
3.3.2 代码
Private Sub Command3_Click()
If ListBox1.SelectedIndex >= 0 Then
ListBox1.items.RemoveAt (ListBox1.SelectedIndex) Else
MsgBox (\没有选中的菜单\End If End Sub
Private Sub Command4_Click() Dim i As Integer Dim a, b As Integer
For i = 0 To ListBox1.items.Count - 1
a = Mid(ListBox1.items(i), Len(ListBox1.items(i)) - 1, 3) b = b + a Next
MsgBox (\请您付账\End Sub
Private Sub Command5_Click() Load 主页 主页.Show Unload Me End Sub
由于尚存在问题,此处代码不完全。
14
3.4职员信息管理
3.4.1职员信息管理界面设计
3.4.2 代码
Private Sub Command1_Click()
Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim SqlStr As String
conn.Open \Security=SSPI;Persist Security Info=False;Initial Catalog=德克士餐饮信息管理系统;Data Source=PC-20140228RMFY\
SqlStr = \* from 职员 where 职员编号='\& Trim$(Text1.Text) & \姓名='\& Trim$(Text2.Text) & \
rst.CursorLocation = adUseClient
rst.Open SqlStr, conn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集 Set DataGrid1.DataSource = rst '给DataGrid修改数据源 End Sub
Private Sub Command2_Click()
Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim strSql As String
strSql = \* from 职员 where 职员编号='\& Trim$(Text1.Text) & \and 姓名='\& Trim$(Text2.Text) & \
conn.Open \Security=SSPI;Persist Security Info=False;Initial Catalog=德克士餐饮信息管理系统;Data Source=PC-20140228RMFY\Dim str As New ADODB.Recordset Set str = New ADODB.Recordset
15
str.CursorLocation = adUseClient
str.Open strSql, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close .Open strSql If .EOF Then
conn.Execute \职员 set 姓名='\& Text2.Text & \性别='\& Text3.Text & \职位='\& Text4.Text & \工作经验='\& Text5.Text & \出生日期='\& Text6.Text & \雇佣日期='\& Text7.Text & \健康状况='\& Text8.Text & \联系电话='\& Text9.Text & \家庭地址='\& Text3.Text & \职员编号='\MsgBox \修改成功!\提示\Else
MsgBox \对不起,该信息已存在,请重新修改!\警告\Text1.Text = \End If
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1 DataGrid1.Refresh Text1.SetFocus End With End Sub
Private Sub Command3_Click()
Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim strSql As String
strSql = \* from 职员 where 职员编号='\& Trim$(Text1.Text) & \and 姓名='\& Trim$(Text2.Text) & \
conn.Open \Security=SSPI;Persist Security Info=False;Initial Catalog=德克士餐饮信息管理系统;Data Source=PC-20140228RMFY\Dim str As New ADODB.Recordset Set str = New ADODB.Recordset str.CursorLocation = adUseClient
str.Open strSql, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close .Open strSql If .EOF Then
conn.Execute \职员 values ('\& Text4.Text & \& Text9.Text & \
MsgBox \添加成功!\提示信息\Else
MsgBox \对不起,该信息已存在,请重新添加!\警告\Text1.Text = \End If
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1 DataGrid1.Refresh Text1.SetFocus
16