📄 form4.frm
字号:
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 4800
TabIndex = 0
Top = 4440
Width = 1215
End
Begin VB.Label Label2
Caption = "销售金额"
Height = 255
Index = 12
Left = 360
TabIndex = 29
Top = 3960
Width = 975
End
Begin VB.Label Label2
Caption = "销售数量"
Height = 255
Index = 7
Left = 4680
TabIndex = 27
Top = 3480
Width = 975
End
Begin VB.Label Label2
Caption = "销售时间"
Height = 255
Index = 6
Left = 360
TabIndex = 25
Top = 3480
Width = 975
End
End
Attribute VB_Name = "form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_Click()
Dim sMeg As String
Dim mrcc As ADODB.Recordset
Dim MsgText As String
Dim xsbh, cpbh As String
Dim xssj As Date
Dim sl, je As Double
Dim cnn As ADODB.Connection
Dim cmdinsert As New ADODB.Command
Dim cmddele As New ADODB.Command
Select Case flagadd
Case 1 '添加销售信息
If Trim(Combo1.Text & " ") = "" Then
sMeg = "销售商编号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
End If
If Trim(Combo2.Text & " ") = "" Then
sMeg = "产品编号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
End If
If Trim(txtItem(8).Text & " ") = "" Then
sMeg = "销售时间不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
End If
If Trim(txtItem(9).Text & " ") = "" Then
sMeg = "销售数量不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
End If
If Trim(txtItem(10).Text & " ") = "" Then
sMeg = "销售金额不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
End If
xsbh = Combo1.Text
cpbh = Combo2.Text
xssj = CDate(txtItem(8).Text)
sl = CDbl(txtItem(9).Text)
je = CDbl(txtItem(10).Text)
Set cnn = New ADODB.Connection
cnn.Open ConnectString
Set cmdinsert.ActiveConnection = cnn
cmdinsert.CommandText = "xscp_insert"
cmdinsert.CommandType = adCmdStoredProc
cmdinsert.Parameters.Append cmdinsert.CreateParameter("xsbh0", adChar, adParamInput, 6, xsbh)
cmdinsert.Parameters.Append cmdinsert.CreateParameter("cpbh0", adChar, adParamInput, 6, cpbh)
cmdinsert.Parameters.Append cmdinsert.CreateParameter("xssj0", adVarChar, adParamInput, 10, [xssj])
cmdinsert.Parameters.Append cmdinsert.CreateParameter("sl0", adDouble, adParamInput, , sl)
cmdinsert.Parameters.Append cmdinsert.CreateParameter("je0", adDouble, adParamInput, , je)
cmdinsert.Parameters.Append cmdinsert.CreateParameter("flag", adInteger, adParamOutput)
cmdinsert.Execute
If cmdinsert("flag") > 0 Then
MsgBox "数据已添加!", vbOKOnly + vbExclamation, "提示"
Else
MsgBox "数据添加失败!", vbOKOnly + vbExclamation, "提示"
End If
cnn.Close
End Select
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Combo1_Click()
Dim MsgText As String
Dim xsbh As String
Dim i As Integer
xsbh = Combo1.Text
txtSQL = "select * from xss where xsbh='" & xsbh & "'"
Set mrc = ExecuteSQL(txtSQL)
If Not mrc.EOF Then
For i = 0 To 4
If Not IsNull(mrc.Fields(i + 1)) Then
txtItem(i).Text = mrc.Fields(i + 1)
Else
txtItem(i).Text = ""
End If
Next i
End If
mrc.Close
End Sub
Private Sub Combo2_Click()
Dim MsgText As String
Dim cpbh As String
cpbh = Combo2.Text
txtSQL = "select * from cp where cpbh='" & cpbh & "'"
Set mrc = ExecuteSQL(txtSQL)
If Not mrc.EOF Then
txtItem(5).Text = mrc.Fields(1)
txtItem(6).Text = CDbl(mrc.Fields(2))
txtItem(7).Text = CInt(mrc.Fields(3))
End If
mrc.Close
End Sub
Private Sub Combo3_Click()
Dim ssh As String
Dim MsgText As String
If brflagadd = 2 Then '还书
ssh = Trim(Combo3.Text)
txtSQL = "select book.ISBN,书名,作者,出版社,价格,复本量,库存量,xs.借书证号,姓名,专业名,性别,出生时间,借书数,索书号 from jy,book,xs where jy.借书证号=xs.借书证号 and jy.ISBN=book.ISBN and 索书号='" & ssh & " '"
Set mrc = ExecuteSQL(txtSQL, MsgText)
ftag = 0
Do While Not mrc.EOF
If ftag = 0 Then
ftag = 1
Text1.Text = mrc.Fields(0)
txtItem(0).Text = mrc.Fields(1)
txtItem(1).Text = mrc.Fields(2)
txtItem(2).Text = mrc.Fields(3)
txtItem(3).Text = CDbl(mrc.Fields(4))
txtItem(4).Text = CInt(mrc.Fields(5))
txtItem(5).Text = CInt(mrc.Fields(6))
Text2.Text = mrc.Fields(7)
txtItem(6).Text = mrc.Fields(8)
txtItem(7).Text = mrc.Fields(9)
txtItem(8).Text = mrc.Fields(11)
txtItem(9).Text = CStr(mrc.Fields(12))
If mrc.Fields(10) Then
Option1(1).Value = True
Else
Option1(0).Value = True
End If
End If
mrc.MoveNext
Loop
mrc.Close
End If
End Sub
Private Sub Form_Activate()
Dim MsgText As String
Dim ftag As Integer
'添加销售信息
txtSQL = "select * from xss"
Set mrc = ExecuteSQL(txtSQL)
ftag = 0
Do While Not mrc.EOF
Combo1.AddItem Trim(mrc.Fields(0))
If ftag = 0 Then
ftag = 1
Combo1.Text = mrc.Fields(0)
txtItem(0).Text = mrc.Fields(1)
txtItem(1).Text = mrc.Fields(2)
txtItem(2).Text = mrc.Fields(3)
txtItem(3).Text = mrc.Fields(4)
txtItem(4).Text = mrc.Fields(5)
End If
mrc.MoveNext
Loop
mrc.Close
txtSQL = "select * from cp"
Set mrc = ExecuteSQL(txtSQL)
ftag = 0
If Not mrc.EOF Then
Do While Not mrc.EOF
Combo2.AddItem Trim(mrc.Fields(0))
If ftag = 0 Then
ftag = 1
Combo2.Text = mrc.Fields(0)
txtItem(5).Text = mrc.Fields(1)
txtItem(6).Text = mrc.Fields(2)
txtItem(7).Text = mrc.Fields(3)
End If
mrc.MoveNext
Loop
End If
mrc.Close
End Sub
Private Sub Form_Load()
Me.Caption = "销售信息"
Me.Caption = Me.Caption & "添加"
cmd.Caption = "保存 (&S)"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -