📄 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 = "供应商:"
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 = "数量:"
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 "数据丢失,清重试!", vbOKOnly + vbExclamation, "办理退货"
GetJinJia = ""
Exit Function
End If
Exit Function
errEnd:
MsgBox "找不到该品种的进价!", vbOKOnly + vbExclamation, "检索数据库出错"
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 "请填写退货的数量.", 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 "数据丢失,清重试!", 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 "请填写退货金额.", vbOKOnly + vbExclamation, "办理退货"
TxtJinE.SetFocus
Exit Sub
End If
If TxtYuanYin.Text = "" Then
MsgBox "请填写退货原因.", 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!供应商编号 = GongYingShangID
Adodc1.Recordset!图书编号 = TuShuBianHao
Adodc1.Recordset!进价 = TxtJinJia.Text
Adodc1.Recordset!退货数量 = 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 "数据丢失,清重试!", 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 "更新数据库失败!无法完成退货操作!", 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 "连接数据库失败!", vbOKOnly + vbExclamation, "打开数据库出错"
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 "图书数量填写错误!", 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -