📄 frmqsupplier.frm
字号:
End If
End Sub
Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub CmdINT_Click()
id = 0
CmdQuery.Enabled = True
MSFlexGrid1.Clear
Dim X As Integer
For X = MSFlexGrid1.Rows - 1 To 2 Step -1
MSFlexGrid1.RemoveItem (X)
Next X
TxtID.Text = ""
TxtName.Text = ""
TxtCity.Text = ""
TxtState.Text = ""
TxtPhone.Text = ""
CmdModify.Enabled = False
CmdDel.Enabled = False
OptSPID.Value = True
CmdQuery.Enabled = True
ChkCity.Value = 0
ChkState.Value = 0
ChkPhone.Value = 0
id = 0
Call PreView
End Sub
Private Sub CmdModify_Click()
If MSFlexGrid1.Row > 0 And MSFlexGrid1.Row < MSFlexGrid1.Rows - 1 Then '判断是否选中有效记录
frmSupMOD.Show
Else
MsgBox "请选择要修改的记录!", vbInformation + vbOKOnly, "修改提示!"
Exit Sub
End If
End Sub
Private Sub CmdQuery_Click()
Dim strSQL As String
Dim intindex As Integer
intindex = 0
'分别判断个复选框是否被选中,如果选中则将起条件字符串赋值给查询字符串
If ChkCity.Value = 1 Then
If TxtCity <> "" Then
strSQL = " and city= " & "'" & TxtCity.Text & "'"
Else
MsgBox "城市输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
TxtCity.Text = ""
TxtCity.SetFocus
Exit Sub
End If
Else
strSQL = ""
End If
If ChkState.Value = 1 Then
If TxtState.Text <> "" Then
strSQL = strSQL & " and state= " & "'" & TxtState.Text & "'"
Else
MsgBox "省份输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
TxtState.Text = ""
TxtState.SetFocus
Exit Sub
End If
End If
If ChkPhone.Value = 1 Then
If TxtPhone <> "" Then
strSQL = strSQL & " and phone= " & "'" & TxtPhone.Text & "'"
Else
MsgBox "电话号码输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
TxtPhone.Text = ""
TxtPhone.SetFocus
Exit Sub
End If
End If
If OptSPID.Value = True Then '判断单选按钮是否被选中,如果选中,则结合复选条件一起组成查询条件
If TxtID.Text <> "" Then
strSQL = "select * from suppliers where suppliersid like " & "'" & "%" & TxtID.Text & "%" & "'" & strSQL
Else
MsgBox "厂商编号输入不能为空!", vbInformation + vbOKOnly, "输入提示!"
Exit Sub
End If
ElseIf OptSPNAME.Value = True Then
If TxtName.Text <> "" Then
strSQL = "select * from suppliers where companyname like " & "'" & "%" & TxtName.Text & "%" & "'" & strSQL
Else
MsgBox "厂商名称输入不能为空!", vbInformation + vbOKOnly, "输入提示!"
Exit Sub
End If
End If
Set rct = QueryXFInfo(strSQL)
If rct.EOF = True Then
MsgBox "无符合查询条件的记录!", vbInformation + vbOKOnly, "查询提示!"
Exit Sub
Else
rct.MoveFirst
End If
Do While Not rct.EOF
Call flexView
intindex = intindex + 1
rct.MoveNext
Loop
MsgBox "共有" & intindex & "条符合查询条件的记录!", vbInformation + vbOKOnly, "查询提示!"
CmdQuery.Enabled = False
CmdModify.Enabled = True
rct.MoveFirst
Dim str1 As String
str1 = "select * from employee "
Set rct1 = QueryXFInfo(str1)
rct1.MoveFirst
Do While Not rct1.EOF
If Trim(rct1.Fields.Item(1).Value) = strName Then '判断用户的权限,普通用户不能清空或删除记录
If rct1.Fields.Item(3).Value = "User" Then
Exit Do
Else
CmdDel.Enabled = True
Exit Do
End If
Else
rct1.MoveNext
End If
Loop
End Sub
Private Sub Form_Load()
CmdModify.Enabled = False
CmdDel.Enabled = False
OptSPID.Value = True
id = 0
Call PreView
End Sub
'声明初始化时表格显示函数
Private Sub PreView()
Dim intindex As Integer
MSFlexGrid1.ColWidth(0) = 12 * 25 * 3
MSFlexGrid1.ColWidth(1) = 12 * 25 * 6
MSFlexGrid1.ColWidth(2) = 12 * 25 * 8
MSFlexGrid1.ColWidth(3) = 12 * 25 * 8
MSFlexGrid1.ColWidth(4) = 12 * 25 * 4
MSFlexGrid1.ColWidth(5) = 12 * 25 * 4
MSFlexGrid1.ColWidth(6) = 12 * 25 * 6
MSFlexGrid1.ColWidth(7) = 12 * 25 * 6
MSFlexGrid1.Row = 0
For intindex = 0 To 7
MSFlexGrid1.Col = intindex
MSFlexGrid1.CellAlignment = 4
MSFlexGrid1.CellFontBold = True
Next intindex
MSFlexGrid1.TextMatrix(0, 0) = "序号"
MSFlexGrid1.TextMatrix(0, 1) = "厂商编号"
MSFlexGrid1.TextMatrix(0, 2) = "厂商名称"
MSFlexGrid1.TextMatrix(0, 3) = "地址"
MSFlexGrid1.TextMatrix(0, 4) = "城市"
MSFlexGrid1.TextMatrix(0, 5) = "省份"
MSFlexGrid1.TextMatrix(0, 6) = "电话"
MSFlexGrid1.TextMatrix(0, 7) = "银行帐号"
End Sub
Private Sub OptSPNAME_Click()
TxtName.SetFocus
End Sub
'判断文本框输入的合法性
Private Sub TxtCity_LostFocus()
If TxtCity.Text <> "" Then
If IsChar(TxtCity.Text) = False Then
MsgBox "城市输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
TxtCity.Text = ""
TxtCity.SetFocus
Exit Sub
End If
End If
End Sub
Private Sub txtID_LostFocus()
If TxtID.Text <> "" Then
If IsChar(TxtID.Text) = False Then
MsgBox "厂商编号输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
TxtID.Text = ""
TxtID.SetFocus
Exit Sub
End If
End If
End Sub
Private Sub TxtName_LostFocus()
If TxtName.Text <> "" Then
If IsChar(TxtName.Text) = False Then
MsgBox "厂商名称输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
TxtName.Text = ""
TxtName.SetFocus
Exit Sub
End If
End If
End Sub
Private Sub TxtPhone_LostFocus()
Dim str As String
str = TxtPhone.Text
Dim i As Integer
Dim intindex As Integer
intindex = 0
Dim length As Integer
length = Len(str)
For i = 1 To length
If Left(str, 1) >= "0" And Left(str, 1) <= "9" Or Left(str, 1) = "-" Then
If Left(str, 1) = "-" Then
intindex = intindex + 1
End If
Else
MsgBox "电话号码输入不合法,请重新输入", vbInformation + vbOKOnly, "输入提示!"
TxtPhone.Text = ""
TxtPhone.SetFocus
Exit Sub
End If
str = Right(str, Len(str) - 1) '此处的str动态变化!!
Next i
If intindex > 1 Then
MsgBox "电话号码输入不合法,请重新输入", vbInformation + vbOKOnly, "输入提示!"
TxtPhone.Text = ""
TxtPhone.SetFocus
Exit Sub
End If
End Sub
Private Sub TxtState_LostFocus()
If TxtState.Text <> "" Then
If IsChar(TxtState.Text) = False Then
MsgBox "省份输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
TxtState.Text = ""
TxtState.SetFocus
Exit Sub
End If
End If
End Sub
'声明查询函数
Public Function flexView() As Boolean
Dim intindex As Integer
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
For intindex = 0 To 7
MSFlexGrid1.Col = intindex
MSFlexGrid1.CellAlignment = 4
Next intindex
id = id + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = id
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = rct.Fields.Item(0).Value
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = rct.Fields.Item(1).Value
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = rct.Fields.Item(2).Value
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = rct.Fields.Item(3).Value
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = rct.Fields.Item(4).Value
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = rct.Fields.Item(5).Value
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = rct.Fields.Item(6).Value
MSFlexGrid1.AddItem (Empty)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -