?? frmthgys.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmTHGYS
BorderStyle = 3 'Fixed Dialog
Caption = "辦理退貨"
ClientHeight = 5880
ClientLeft = 45
ClientTop = 330
ClientWidth = 7590
Icon = "FrmTHGYS.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5880
ScaleWidth = 7590
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox TxtJinJia
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 15
Top = 1080
Width = 4695
End
Begin VB.TextBox TxtYuanYin
Height = 1575
Left = 1200
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 2520
Width = 4695
End
Begin VB.CommandButton CmdOK
Caption = "入帳(&D)"
Height = 375
Left = 6240
TabIndex = 3
Top = 240
Width = 1095
End
Begin VB.CommandButton CmdCancel
Caption = "取消(&C)"
Height = 375
Left = 6240
TabIndex = 4
Top = 960
Width = 1095
End
Begin VB.TextBox TxtGYS
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 7
Top = 120
Width = 4695
End
Begin VB.TextBox TxtBook
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 6
Top = 600
Width = 4695
End
Begin VB.TextBox TxtShuLiang
Height = 375
Left = 1200
TabIndex = 0
Top = 1560
Width = 4695
End
Begin VB.TextBox TxtJinE
Height = 375
Left = 1200
TabIndex = 5
Top = 2040
Width = 4695
End
Begin VB.TextBox TxtMemo
Height = 1455
Left = 1200
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 4200
Width = 4695
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 6240
Top = 3840
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.Label Label5
AutoSize = -1 'True
Caption = "進價:"
Height = 180
Left = 540
TabIndex = 14
Top = 1200
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "退貨原因:"
Height = 180
Left = 180
TabIndex = 13
Top = 2640
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "供應(yīng)商:"
Height = 180
Left = 360
TabIndex = 12
Top = 240
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "品種:"
Height = 180
Left = 540
TabIndex = 11
Top = 720
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "數(shù)量:"
Height = 180
Left = 540
TabIndex = 10
Top = 1680
Width = 540
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "金額:"
Height = 180
Left = 540
TabIndex = 9
Top = 2160
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "備注信息:"
Height = 180
Left = 180
TabIndex = 8
Top = 4320
Width = 900
End
End
Attribute VB_Name = "FrmTHGYS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function GetJinJia(bianHao As String) As String
On Error GoTo errEnd
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select [單價] from [進書記錄] where [圖書編號]=""" & TuShuBianHao & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
GetJinJia = Adodc1.Recordset!單價 & ""
Else
MsgBox "數(shù)據(jù)丟失,清重試!", vbOKOnly + vbExclamation, "辦理退貨"
GetJinJia = ""
Exit Function
End If
Exit Function
errEnd:
MsgBox "找不到該品種的進價!", vbOKOnly + vbExclamation, "檢索數(shù)據(jù)庫出錯"
GetJinJia = ""
End Function
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo errEnd
Dim QD As Integer
If TxtShuLiang.Text = "" Then
MsgBox "請?zhí)顚懲素浀臄?shù)量.", vbOKOnly + vbExclamation, "辦理退貨"
TxtShuLiang.SetFocus
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [Book] where [圖書編號]=""" & TuShuBianHao & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "數(shù)據(jù)丟失,清重試!", vbOKOnly + vbExclamation, "辦理退貨"
Exit Sub
End If
Adodc1.Recordset.MoveFirst
If Adodc1.Recordset!庫存量 - CInt(TxtShuLiang.Text) < 0 Then
MsgBox "庫存不足,沒有足夠的圖書可以退回!", vbOKOnly + vbExclamation, "庫存不足"
TxtShuLiang.SetFocus
TxtShuLiang.SelStart = 0
TxtShuLiang.SelLength = Len(TxtShuLiang.Text)
Exit Sub
End If
If TxtJinJia.Text = "" Then
MsgBox "圖書進價信息丟失,無法完成退貨操作!", vbOKOnly + vbExclamation, "辦理退貨"
TxtShuLiang.SetFocus
Exit Sub
End If
If TxtJinE.Text = "" Then
MsgBox "請?zhí)顚懲素浗痤~.", vbOKOnly + vbExclamation, "辦理退貨"
TxtJinE.SetFocus
Exit Sub
End If
If TxtYuanYin.Text = "" Then
MsgBox "請?zhí)顚懲素浽?", vbOKOnly + vbExclamation, "辦理退貨"
TxtYuanYin.SetFocus
Exit Sub
End If
If TxtMemo.Text = "" Then TxtMemo.Text = "無"
QD = MsgBox("確定入帳嗎?", vbOKCancel + vbQuestion, "確認入帳")
If QD = vbCancel Then
'Unload Me
Exit Sub
End If
CmdOK.Enabled = False
Screen.MousePointer = 11
BeginTrans
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "退貨記錄"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset!供應(yīng)商編號 = GongYingShangID
Adodc1.Recordset!圖書編號 = TuShuBianHao
Adodc1.Recordset!進價 = TxtJinJia.Text
Adodc1.Recordset!退貨數(shù)量 = CInt(TxtShuLiang.Text)
Adodc1.Recordset!金額 = TxtJinE.Text
Adodc1.Recordset!退貨原因 = TxtYuanYin.Text
Adodc1.Recordset!退貨日期 = Now()
Adodc1.Recordset!備注 = TxtMemo.Text
Adodc1.Recordset.Update
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [Book] where [圖書編號]=""" & TuShuBianHao & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
Rollback
Screen.MousePointer = vbDefault
MsgBox "數(shù)據(jù)丟失,清重試!", vbOKOnly + vbExclamation, "辦理退貨"
CmdOK.Enabled = True
Exit Sub
End If
Adodc1.Recordset.MoveFirst
Adodc1.Recordset!庫存量 = Adodc1.Recordset!庫存量 - CInt(TxtShuLiang.Text)
Adodc1.Recordset.Update
CommitTrans
Screen.MousePointer = vbDefault
MsgBox "本次退貨操作成功!", vbOKOnly + vbInformation, "操作成功"
Unload Me
Exit Sub
errEnd:
Rollback
Screen.MousePointer = vbDefault
MsgBox "更新數(shù)據(jù)庫失敗!無法完成退貨操作!", vbOKOnly + vbExclamation, "更新失敗"
CmdOK.Enabled = True
End Sub
Private Sub Form_Activate()
TxtGYS.Text = GongYingShang
TxtBook.Text = ShuMing
TxtJinJia.Text = GetJinJia(TuShuBianHao)
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
Exit Sub
errEnd:
MsgBox "連接數(shù)據(jù)庫失敗!", vbOKOnly + vbExclamation, "打開數(shù)據(jù)庫出錯"
End
End Sub
Private Sub TxtJinE_KeyUp(KeyCode As Integer, Shift As Integer)
If Not (KeyCode >= 48 And KeyCode <= 57) Then
If Not (KeyCode >= 96 And KeyCode <= 105) Then
If KeyCode <> 13 And KeyCode <> 190 And KeyCode <> 110 And KeyCode <> 8 And KeyCode <> 46 Then
MsgBox "退貨金額填寫錯誤!", vbOKOnly + vbExclamation, "填寫錯誤"
TxtJinE.Text = ""
TxtJinE.SetFocus
End If
End If
End If
End Sub
Private Sub TxtShuLiang_KeyUp(KeyCode As Integer, Shift As Integer)
If Not (KeyCode >= 48 And KeyCode <= 57) Then
If Not (KeyCode >= 96 And KeyCode <= 105) Then
If KeyCode <> 13 And KeyCode <> 8 And KeyCode <> 46 Then
MsgBox "圖書數(shù)量填寫錯誤!", vbOKOnly + vbExclamation, "填寫錯誤"
TxtShuLiang.Text = ""
TxtShuLiang.SetFocus
End If
End If
End If
End Sub
Private Sub TxtShuLiang_LostFocus()
If TxtShuLiang.Text <> "" And TxtJinJia.Text <> "" Then
TxtJinE.Text = TxtShuLiang.Text * TxtJinJia.Text
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -