📄 form3.frm
字号:
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2340
TabIndex = 5
Top = 2760
Width = 1455
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "日 期:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2340
TabIndex = 4
Top = 2280
Width = 1455
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "月 份:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2340
TabIndex = 3
Top = 1800
Width = 1455
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "年 份:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2340
TabIndex = 2
Top = 1320
Width = 1455
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "品 种:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2340
TabIndex = 1
Top = 840
Width = 1455
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "购入产品输入"
BeginProperty Font
Name = "黑体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 3120
TabIndex = 0
Top = 240
Width = 1890
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim f_max_number, f_unload_fee, f_transport_fee, f_buy_weigh
Private Sub Command1_Click()
Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粤丰饲料\粤丰饲料经营情况.mdb;"
Set cmd1 = New ADODB.Command
SQL = "SELECT count(*),MAX(编号) from 品种购入表"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
rs1.MoveFirst
If rs1.Fields(0) = 0 Then
f_max_number = 0
Else
f_max_number = rs1.Fields(1) + 1
End If
SQL = "INSERT INTO 品种购入表(编号,品种, 年份,月份,日期,单号,购入斤数,购入单价," & _
"购入金额,运费,卸车费) VALUES ( " & f_max_number & "," & " '" & Combo1.Text & "'" & "," & Text2.Text & "," & _
Text3.Text & "," & Text4.Text & ",'" & Text5.Text & "'" & "," & Text6.Text & "," & Round(Text7.Text, 3) & _
"," & Round(Text8.Text, 2) & "," & Text9.Text & "," & Text10.Text & ")"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
.Execute
End With
cnn1.Close
Set cnn1 = Nothing
Text4.Text = ""
Text5.Text = g_reckoning
Text6.Text = 0
Text7.Text = 0
Text8.Text = 0
Text9.Text = 0
Text10.Text = 0
MsgBox ("数据保存成功")
Text4.SetFocus
End Sub
Private Sub Form_Load()
Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim rs1 As ADODB.Recordset
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粤丰饲料\粤丰饲料经营情况.mdb;"
Set cmd1 = New ADODB.Command
SQL = "select 品种 from 品种类型表 order by 品种"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
rs1.MoveFirst
i = 0
While Not rs1.EOF
Combo1.AddItem rs1.Fields(0), i
rs1.MoveNext
i = i + 1
Wend
Combo1.Text = g_breed
Text2.Text = g_year
Text3.Text = g_month
Text5.Text = g_reckoning
Text6.Text = 0
Text7.Text = 0
Text8.Text = 0
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粤丰饲料\粤丰饲料经营情况.mdb;"
Set cmd1 = New ADODB.Command
SQL = "SELECT count(*),MAX(编号) from 品种购入表"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
rs1.MoveFirst
If rs1.Fields(0) = 0 Then
f_max_number = 0
Else
f_max_number = rs1.Fields(1) + 1
End If
cnn1.Close
Set cnn1 = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Select Case g_form
Case "form2"
Form2.Show
Case "form43"
Form43.Show
Case "form37"
Form37.Show
End Select
End Sub
Private Sub Text10_Gotfocus()
Text6.SetFocus
End Sub
Private Sub Text2_GotFocus()
Text5.SetFocus
End Sub
Private Sub Text3_GotFocus()
Text5.SetFocus
End Sub
Private Sub Text4_GotFocus()
Text5.SetFocus
End Sub
Private Sub Text5_LostFocus()
Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim rs1 As ADODB.Recordset
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粤丰饲料\粤丰饲料经营情况.mdb;"
Set cmd1 = New ADODB.Command
SQL = "select 年份,月份,日期,购入斤数 from 购入帐单表 where 帐单号 =" & "'" & Text5.Text & "'"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
If rs1.EOF Then
MsgBox ("购入帐单表中没有该帐单号,请重输!")
cnn1.Close
Set cnn1 = Nothing
Text5.SetFocus
f_buy_weigh = 0
GoSub exit_text5_lostfocus
Else
rs1.MoveFirst
Text2.Text = rs1.Fields(0)
Text3.Text = rs1.Fields(1)
Text4.Text = rs1.Fields(2)
f_buy_weigh = rs1.Fields(3)
End If
SQL = " select 金额 from 跟单费用表 where 帐单号 =" & "'" & Text5.Text & "'" & " and " & _
" 费用名称 = '运费'"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
If rs1.EOF Then
f_transport_fee = 0
Else
rs1.MoveFirst
f_transport_fee = rs1.Fields(0)
End If
SQL = " select 金额 from 跟单费用表 where 帐单号 =" & "'" & Text5.Text & "'" & " and " & _
" 费用名称 = '卸车费'"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
If rs1.EOF Then
f_unload_fee = 0
Else
rs1.MoveFirst
f_unload_fee = rs1.Fields(0)
End If
cnn1.Close
Set cnn1 = Nothing
exit_text5_lostfocus:
End Sub
Private Sub Text6_LostFocus()
Text8.Text = Round(Text7.Text * Text6.Text, 2)
If f_buy_weigh > 0 Then
Text9.Text = f_transport_fee * (Text6.Text / f_buy_weigh)
Text10.Text = f_unload_fee * (Text6.Text / f_buy_weigh)
End If
End Sub
Private Sub Text7_lostFocus()
Text8.Text = Text6.Text * Text7.Text
End Sub
Private Sub Text8_GotFocus()
Text8.Text = Round(Text6.Text * Text7.Text, 2)
End Sub
Private Sub Text9_GotFocus()
Text6.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -