📄 frmspinfo.frm
字号:
VERSION 5.00
Begin VB.Form frmsp
BorderStyle = 3 'Fixed Dialog
Caption = "商品设置"
ClientHeight = 5400
ClientLeft = 45
ClientTop = 330
ClientWidth = 5895
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5400
ScaleWidth = 5895
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame2
Height = 855
Left = 240
TabIndex = 11
Top = 4320
Width = 5415
Begin VB.CommandButton Command1
Caption = "重设"
Height = 375
Left = 600
TabIndex = 14
Top = 240
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "保存"
Height = 375
Left = 1920
TabIndex = 13
Top = 240
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "返回"
Height = 375
Left = 3240
TabIndex = 12
Top = 240
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "商品设置"
Height = 3855
Left = 240
TabIndex = 0
Top = 240
Width = 5415
Begin VB.TextBox Text
Height = 1455
Index = 4
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 10
Top = 2160
Width = 4935
End
Begin VB.TextBox Text
Height = 270
Index = 3
Left = 1680
TabIndex = 9
Top = 1560
Width = 1815
End
Begin VB.TextBox Text
Height = 270
Index = 2
Left = 1680
TabIndex = 8
Top = 1200
Width = 1815
End
Begin VB.TextBox Text
Height = 270
Index = 1
Left = 1680
TabIndex = 7
Top = 840
Width = 1815
End
Begin VB.TextBox Text
Height = 270
Index = 0
Left = 1680
TabIndex = 6
Top = 480
Width = 1815
End
Begin VB.Label Label1
Caption = "其它信息:"
Height = 255
Index = 5
Left = 360
TabIndex = 5
Top = 1920
Width = 855
End
Begin VB.Label Label1
Caption = "批发价:"
Height = 255
Index = 3
Left = 360
TabIndex = 4
Top = 1560
Width = 855
End
Begin VB.Label Label1
Caption = "零售价:"
Height = 255
Index = 2
Left = 360
TabIndex = 3
Top = 1200
Width = 855
End
Begin VB.Label Label1
Caption = "商品名称:"
Height = 255
Index = 1
Left = 360
TabIndex = 2
Top = 840
Width = 855
End
Begin VB.Label Label1
Caption = "商品编号:"
Height = 255
Index = 0
Left = 360
TabIndex = 1
Top = 480
Width = 855
End
End
End
Attribute VB_Name = "frmsp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim t As Integer
t = 0
For t = 0 To 4
Text(t) = ""
Next
End Sub
Private Sub Command2_Click()
Dim t As Integer
Dim oldSpId As String '保存选择的商品编号
For t = 0 To 3
If Text(t) = "" Then
MsgBox "请将信息输入完整!", vbExclamation, "输入提示"
Exit Sub
End If
Next
Dim sqlsp As String
Dim sqlsp2 As String
Dim rssp As ADODB.Recordset
oldSpId = Trim(frmspinfo.msgList.TextMatrix(frmspinfo.msgList.Row, 1))
'//查询记录,如果存在采用覆盖方式来更新数据
If gintDHmode <> 2 Then 'gintDHmode=2为编辑,否则为添加
'添加商品类型
sqlsp = "select 商品编号 from 商品表 where 商品编号='" & Trim(Text(0).Text) & "'"
Set rssp = ExeSQL(sqlsp)
If Not rssp.EOF Then
MsgBox "该商品编号已经使用,请更换商品编号后重试.", vbInformation + vbOKOnly, "系统提示"
rssp.Close
Set rssp = Nothing
Exit Sub
End If
Else
'编辑商品类型
sqlsp2 = "delete from 商品表 where 商品编号='" & oldSpId & "'"
ExeSQL (sqlsp2)
sqlsp = "select 商品编号 from 商品表 where 商品编号='" & Trim(Text(0).Text) & "'"
Set rssp = ExeSQL(sqlsp)
If Not rssp.EOF Then
MsgBox "该商品编号已经使用,请更换商品编号后重试.", vbInformation + vbOKOnly, "系统提示"
rssp.Close
Set rssp = Nothing
Exit Sub
End If
End If
'************插入数据**********
sqlsp = "insert into 商品表(商品编号,商品名称,零售价,批发价,备注) values('" & Trim(Text(0).Text) & "','" & Trim(Text(1).Text) & "'," & Val(Trim(Text(2).Text)) & "," & Val(Trim(Text(3).Text)) & ",'" & Trim(Text(4).Text) & "')"
ExeSQL (sqlsp)
'**********更新销售表中的商品编号************
If gintDHmode = 2 Then
If oldSpId <> Trim(Text(0).Text) Then
Dim sqlUpData As String
sqlUpData = "update 销售表 set 商品编号='" & Trim(Text(0).Text) & "' where 商品编号='" & oldSpId & "'"
ExeSQL (sqlUpData)
End If
gintDHmode = 0
End If
'***************模块结束****************
MsgBox "输入成功,请返回", vbInformation, "系统提示"
Call Command1_Click
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Call Command1_Click
End Sub
Public Sub showdata(txtsql As String)
Dim rsshow As ADODB.Recordset
Dim i As Integer
If txtsql = "" Then
txtsql = "select * from 商品表"
End If
Set rsshow = ExeSQL(txtsql)
For i = 0 To 3
Text(i) = rsshow.Fields(i)
Next
rsshow.Close
Set rsshow = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmspinfo.ShowTitle
frmspinfo.showdata
Set frmsp = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -