?? frmgys.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmGYS
BorderStyle = 3 'Fixed Dialog
Caption = "新書入庫 選擇供應商"
ClientHeight = 5160
ClientLeft = 45
ClientTop = 330
ClientWidth = 8850
Icon = "FrmGYS.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5160
ScaleWidth = 8850
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 4200
Top = 3960
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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
Begin VB.Frame Frame2
Caption = "信息管理"
Height = 975
Left = 120
TabIndex = 14
Top = 3960
Width = 8535
Begin VB.CommandButton CmdSelect
Caption = "選中供應商(&G)"
Height = 375
Left = 2440
TabIndex = 10
Top = 360
Width = 1575
End
Begin VB.CommandButton CmdClose
Cancel = -1 'True
Caption = "關閉(&C)"
Height = 375
Left = 6600
TabIndex = 12
Top = 360
Width = 1575
End
Begin VB.CommandButton CmdUpdate
Caption = "修改資料(&U)"
Height = 375
Left = 4520
TabIndex = 11
Top = 360
Width = 1575
End
Begin VB.CommandButton CmdNewGYS
Caption = "供應商登記(&N)"
Height = 375
Left = 360
TabIndex = 9
Top = 360
Width = 1575
End
End
Begin VB.Frame Frame1
Caption = "選擇供應商"
Height = 3615
Left = 120
TabIndex = 13
Top = 120
Width = 8535
Begin VB.TextBox TxtJianJie
Height = 1935
Left = 5160
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 8
Top = 1335
Width = 3135
End
Begin VB.TextBox TxtWeb
Height = 390
Left = 5160
TabIndex = 7
Top = 840
Width = 3135
End
Begin VB.TextBox TxtLianXiRen
Height = 390
Left = 5160
TabIndex = 6
Top = 360
Width = 3135
End
Begin VB.TextBox TxtMail
Height = 390
Left = 1440
TabIndex = 5
Top = 2880
Width = 2535
End
Begin VB.TextBox TxtChuanZhen
Height = 390
Left = 1440
TabIndex = 4
Top = 2400
Width = 2535
End
Begin VB.TextBox TxtDianHua
Height = 390
Left = 1440
TabIndex = 3
Top = 1890
Width = 2535
End
Begin VB.TextBox TxtDiZhi
Height = 390
Left = 1440
TabIndex = 2
Top = 1380
Width = 2535
End
Begin VB.TextBox TxtDanWei
Height = 390
Left = 1440
TabIndex = 1
Top = 870
Width = 2535
End
Begin VB.ComboBox ComboDanWei
Height = 300
Left = 1440
TabIndex = 0
Text = "請選擇供應商"
Top = 360
Width = 2535
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "單位簡介:"
Height = 180
Left = 4200
TabIndex = 23
Top = 1440
Width = 900
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "單位主頁:"
Height = 180
Left = 4200
TabIndex = 22
Top = 960
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "聯系人:"
Height = 180
Left = 4380
TabIndex = 21
Top = 480
Width = 720
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "E-mail:"
Height = 180
Left = 600
TabIndex = 20
Top = 3000
Width = 720
End
Begin VB.Label Label6
Caption = "傳真:"
Height = 255
Left = 705
TabIndex = 19
Top = 2520
Width = 615
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "電話:"
Height = 180
Left = 780
TabIndex = 18
Top = 2010
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "單位地址:"
Height = 180
Left = 420
TabIndex = 17
Top = 1515
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "單位名稱:"
Height = 180
Left = 420
TabIndex = 16
Top = 1005
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "選擇供應商:"
Height = 180
Left = 240
TabIndex = 15
Top = 480
Width = 1080
End
End
End
Attribute VB_Name = "FrmGYS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function checkGYSID(UID As String) As Boolean
Dim userDB As Database
Dim userRD As Recordset
Dim dbName As String
Dim STRSQL As String
Screen.MousePointer = 11
On Error GoTo errEnd
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
STRSQL = "select [供應商] from [供應商] where [供應商編號]=""" & UID & """"
'打開數據庫
Set userDB = DBEngine.Workspaces(0).OpenDatabase(dbName, False, True)
'檢索用戶,驗證密碼
Set userRD = userDB.OpenRecordset(STRSQL, dbOpenSnapshot)
If userRD.RecordCount > 0 Then
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
checkGYSID = True
Screen.MousePointer = vbDefault
Else
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
Screen.MousePointer = vbDefault
checkGYSID = False
End If
Exit Function
errEnd:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbOKOnly + vbExclamation, "供應商登記"
Err.Clear
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
End Function
Private Sub CmdClose_Click()
Unload Me
End Sub
Private Sub CmdNewGYS_Click()
Unload Me
Load FrmDJGYS
FrmDJGYS.Show vbModal
End Sub
Private Sub CmdSelect_Click()
If ComboDanWei.Text <> "" And ComboDanWei.Text <> "請選擇供應商" Then
If checkGYSID(ComboDanWei.Text) Then
'新書登記
GongYingShangID = ComboDanWei.Text
Unload Me
Load FrmBook
FrmBook.Show vbModal
Else
MsgBox "該供應商不存在,請先選擇或登記!", vbOKOnly + vbExclamation, "選擇供應商"
ComboDanWei.SetFocus
End If
Else
MsgBox "請選擇供應商!", vbOKOnly + vbExclamation, "選擇供應商"
ComboDanWei.SetFocus
End If
End Sub
Private Sub CmdUpdate_Click()
On Error GoTo errEnd
Dim res As Integer
res = MsgBox("你確定要修改當前記錄嗎?", vbYesNo + vbQuestion, "確認更新")
If res = vbNo Then Exit Sub
If TxtDanWei.Text = "" Then
MsgBox "請輸入單位名稱!", vbOKOnly + vbExclamation, "供應商資料修改"
TxtDanWei.SetFocus
Exit Sub
End If
If TxtDiZhi.Text = "" Then
MsgBox "請輸入供應商聯系地址!", vbOKOnly + vbExclamation, "供應商資料修改"
TxtDiZhi.SetFocus
Exit Sub
End If
If TxtDianHua.Text = "" Then
MsgBox "請輸入供應商聯系電話!", vbOKOnly + vbExclamation, "供應商資料修改"
TxtDianHua.SetFocus
Exit Sub
End If
If TxtChuanZhen.Text = "" Then TxtChuanZhen.Text = "未知"
If TxtMail.Text = "" Then TxtMail.Text = "無"
If TxtLianXiRen.Text = "" Then
MsgBox "請輸入聯系人姓名!", vbOKOnly + vbExclamation, "供應商資料修改"
TxtLianXiRen.SetFocus
Exit Sub
End If
If TxtWeb.Text = "" Then TxtWeb.Text = "無"
If TxtJianJie.Text = "" Then TxtJianJie.Text = "無"
Adodc1.Recordset!供應商 = TxtDanWei.Text
Adodc1.Recordset!地址 = TxtDiZhi.Text
Adodc1.Recordset!網址 = TxtWeb.Text
Adodc1.Recordset!聯系人 = TxtLianXiRen.Text
Adodc1.Recordset!電話 = TxtDianHua.Text
Adodc1.Recordset!傳真 = TxtChuanZhen.Text
Adodc1.Recordset!電子郵件 = TxtMail.Text
Adodc1.Recordset!單位簡介 = TxtJianJie.Text
Adodc1.Recordset.Update
MsgBox "供應商資料修改成功!", vbOKOnly + vbInformation, "供應商資料修改"
Exit Sub
errEnd:
MsgBox "更新數據庫失敗!", vbOKOnly + vbExclamation, "數據庫出錯"
End Sub
Private Sub ComboDanWei_Click()
On Error GoTo errEnd
If ComboDanWei.Text <> "" And ComboDanWei.Text <> "請選擇供應商" Then
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [供應商] where [供應商編號]=""" & ComboDanWei.Text & """"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
TxtDanWei.Text = Adodc1.Recordset!供應商 & ""
GongYingShang = Adodc1.Recordset!供應商 & ""
TxtDiZhi.Text = Adodc1.Recordset!地址 & ""
TxtWeb.Text = Adodc1.Recordset!網址 & ""
TxtLianXiRen.Text = Adodc1.Recordset!聯系人 & ""
TxtDianHua.Text = Adodc1.Recordset!電話 & ""
TxtChuanZhen.Text = Adodc1.Recordset!傳真 & ""
TxtMail.Text = Adodc1.Recordset!電子郵件 & ""
TxtJianJie.Text = Adodc1.Recordset!單位簡介 & ""
End If
Exit Sub
errEnd:
MsgBox "檢索數據庫失敗!", vbOKOnly + vbExclamation, "數據庫出錯"
End Sub
Private Sub Form_Activate()
On Error GoTo errEnd
ComboDanWei.Text = "請選擇供應商"
If Adodc1.Recordset.RecordCount > 0 Then
While Not Adodc1.Recordset.EOF
ComboDanWei.AddItem Adodc1.Recordset!供應商編號
Adodc1.Recordset.MoveNext
Wend
Else
MsgBox "目前沒有供應商,請先登記供應商情況!", vbOKOnly + vbExclamation, "沒有記錄"
CmdSelect.Enabled = False
CmdUpdate.Enabled = False
End If
Exit Sub
errEnd:
MsgBox "檢索數據庫失敗!", vbOKOnly + vbExclamation, "數據庫出錯"
End Sub
Private Sub Form_Load()
Dim dbName As String
Dim connSTR As String
On Error GoTo errEnd
ChDir App.Path
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
connSTR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbName & ";Persist Security Info=False"
Adodc1.ConnectionString = connSTR
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "供應商"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
Exit Sub
errEnd:
MsgBox "連接數據庫失敗!", vbOKOnly + vbExclamation, "打開數據庫出錯"
End
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -