📄 frmgysgl.frm
字号:
Height = 210
Left = 5160
TabIndex = 13
Top = 2400
Width = 1260
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "邮 编:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 5160
TabIndex = 12
Top = 1800
Width = 1260
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "企 业 网 址:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 11
Top = 4200
Width = 1365
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "开 户 银 行:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 10
Top = 3600
Width = 1365
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "联 系 人:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 9
Top = 3000
Width = 1260
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "电 话:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 8
Top = 2400
Width = 1260
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "供应商地址:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 7
Top = 1800
Width = 1260
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "供应商全称:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 6
Top = 1200
Width = 1260
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "供应商简称:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 600
TabIndex = 5
Top = 600
Width = 1260
End
End
Begin VB.Frame Frame1
Caption = "请选择查询条件"
Height = 735
Left = 600
TabIndex = 0
Top = 240
Width = 9495
Begin VB.CommandButton cmdFind
Caption = "查 询"
Height = 375
Left = 7560
TabIndex = 3
Top = 240
Width = 1575
End
Begin VB.TextBox Text1
Height = 270
Left = 2760
TabIndex = 2
Top = 240
Width = 4575
End
Begin VB.ComboBox Combo1
Height = 300
Left = 240
TabIndex = 1
Text = "Combo1"
Top = 240
Width = 2535
End
End
Begin MSAdodcLib.Adodc adoGYSGL
Height = 375
Left = 8520
Top = 0
Visible = 0 'False
Width = 2055
_ExtentX = 3625
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Password=ecc;Persist Security Info=True;User ID=sa;Initial Catalog=PetrolStation System;Data Source=(local)"
OLEDBString = "Provider=SQLOLEDB.1;Password=ecc;Persist Security Info=True;User ID=sa;Initial Catalog=PetrolStation System;Data Source=(local)"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from PS_Suppliers"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "frmGYSGL"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x, i '定义变量
Private Sub CmdRefresh_Click()
adoGYSGL.CommandType = adCmdText
adoGYSGL.RecordSource = "select * from PS_Suppliers"
adoGYSGL.Refresh
End Sub
Private Sub cmdupdate_Click()
On Error GoTo myerr
If gys(0).Text <> "" And gys(1).Text <> "" Then '供应商简称和供应商全称不能为空
For i = 0 To 10
If gys(i).Text <> "" Then adoGYSGL.Recordset.Fields(i) = Trim(gys(i).Text)
Next i
adoGYSGL.Recordset.Update '更新数据
adoGYSGL.Refresh
For i = 0 To 10
gys(i).Enabled = False
Next i
For i = 0 To 3 '更新完毕后记录可以移动
cmdMD(i).Enabled = True
Next i
cmdAdd.Enabled = True
cmdDelete.Enabled = True
cmdUpdate.Enabled = False
cmdRefresh.Enabled = True
Else
If MsgBox("供应商简称和供应商全称都不能为空!", vbInformation, "提示") = vbOK Then
gys(0).SetFocus
End If
End If
myerr:
End Sub
Private Sub Form_Load()
adoGYSGL.CommandType = adCmdText
adoGYSGL.RecordSource = "select * from PS_Suppliers"
adoGYSGL.Refresh
x = Array("供应商简称", "供应商全称", "地址", "邮政编码", "电话", "传真", "联系人")
For i = 0 To 6
' 向combo1添加查询项目列表
Combo1.AddItem (x(i))
Next i
Combo1.ListIndex = 0
adoGYSGL.Refresh
If adoGYSGL.Recordset.RecordCount > 0 Then
For i = 0 To 10
'初始化给gys(i)赋值
If adoGYSGL.Recordset.Fields(i) <> "" Then
gys(i).Text = adoGYSGL.Recordset.Fields(i)
Else
gys(i).Text = ""
End If
Next i
End If
SSTab1.Tab = 0 '显示第一个选项卡
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Enabled = True
frmMain.Show
End Sub
Private Sub CmdFind_Click()
'查询供应商信息
adoGYSGL.CommandType = adCmdText
adoGYSGL.RecordSource = "select * from PS_Suppliers where " & Trim(Combo1.Text) & _
" like '" & Trim(Text1.Text) & "%'"
adoGYSGL.Refresh
If adoGYSGL.Recordset.RecordCount > 0 Then
adoGYSGL.Recordset.MoveFirst
For i = 0 To 10
'将查询结果的第一条记录的字段显示
If adoGYSGL.Recordset.Fields(i) <> "" Then
gys(i).Text = adoGYSGL.Recordset.Fields(i)
Else
gys(i).Text = ""
End If
Next i
End If
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
If adoGYSGL.Recordset.RecordCount > 0 Then
If SSTab1.Tab = 1 And cmdAdd.Enabled = False Then
'当增加记录时不能切换到“供应商列表”选项卡
MsgBox ("正在处理数据,请取消数据处理,再执行本操作!")
SSTab1.Tab = 0
Else
'切换时将“供应商信息”选项卡中信息更新为当前记录的信息
For i = 0 To 10
If adoGYSGL.Recordset.Fields(i) <> "" Then
gys(i).Text = adoGYSGL.Recordset.Fields(i)
Else
gys(i).Text = ""
End If
Next i
End If
dgdGYSGL.Refresh
End If
End Sub
Private Sub CmdMD_Click(Index As Integer)
Select Case Index
Case Is = 0 '移到第一条记录
If Not adoGYSGL.Recordset.BOF Then adoGYSGL.Recordset.MoveFirst
Case Is = 1 '移到上一条记录
If adoGYSGL.Recordset.RecordCount <> 0 Then
If adoGYSGL.Recordset.BOF = False Then adoGYSGL.Recordset.MovePrevious
If adoGYSGL.Recordset.BOF = True Then adoGYSGL.Recordset.MoveFirst
End If
Case Is = 2 '移到下一条记录
If adoGYSGL.Recordset.RecordCount <> 0 Then
If adoGYSGL.Recordset.EOF = False Then adoGYSGL.Recordset.MoveNext
If adoGYSGL.Recordset.EOF = True Then adoGYSGL.Recordset.MoveLast
End If
Case Is = 3 '移到最后一条记录
If adoGYSGL.Recordset.RecordCount <> 0 Then
If adoGYSGL.Recordset.EOF = False Then adoGYSGL.Recordset.MoveLast
If adoGYSGL.Recordset.EOF = True Then adoGYSGL.Recordset.MoveLast
End If
End Select
For i = 0 To 10
If adoGYSGL.Recordset.Fields(i) <> "" Then
gys(i).Text = adoGYSGL.Recordset.Fields(i)
Else
gys(i).Text = ""
End If
Next i
End Sub
Private Sub cmdAdd_Click() '允许用户添加新记录
adoGYSGL.CommandType = adCmdText
adoGYSGL.RecordSource = "select * from PS_Suppliers"
adoGYSGL.Refresh
adoGYSGL.Recordset.AddNew
For i = 0 To 10 '设置文本框可用,且初始值为空
gys(i).Text = ""
gys(i).Enabled = True
Next i
For i = 0 To 3 '增加记录时记录不可移动
cmdMD(i).Enabled = False
Next i
cmdAdd.Enabled = False
cmdUpdate.Enabled = True '增加记录时只可保存或退出
cmdRefresh.Enabled = False
cmdDelete.Enabled = False
SSTab1.Tab = 0 '在“供应商信息”选项卡中输入信息
gys(0).SetFocus '焦点转移到第一个字段上
End Sub
Private Sub cmdDelete_Click() '删除供应商信息
If adoGYSGL.Recordset.RecordCount > 0 Then
If MsgBox("您确实要删除这条数据吗?", vbYesNo + vbQuestion, "提示") = vbYes Then
adoGYSGL.Recordset.Delete
adoGYSGL.Refresh
adoGYSGL.Recordset.MoveFirst
For i = 0 To 3
cmdMD(i).Enabled = True
Next i
cmdAdd.Enabled = True
cmdUpdate.Enabled = True
cmdDelete.Enabled = True
cmdRefresh.Enabled = True
For i = 0 To 10
gys(i).Text = adoGYSGL.Recordset.Fields(i)
Next i
End If
Else
MsgBox ("没有要删除的数据!")
End If
End Sub
Private Sub cmdend_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -