📄 frm_tysq.frm
字号:
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim c
Private Sub Cbx_bm_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(20).SetFocus
End If
End Sub
Private Sub Cmd_Select_Click()
frm_T_Khxx.Left = 2550
frm_T_Khxx.Top = 3150
frm_T_Khxx.Show 1 '设置窗体显示为有模式的状态
End Sub
Private Sub Command1_Click()
frm_T_Clxx.Show 1
End Sub
Private Sub DT1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(3).SetFocus
End If
End Sub
Private Sub DT2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(5).SetFocus
End If
End Sub
Private Sub Form_Activate()
AdoRs.Open "select bmxx_mc from tb_bmxx order by bmxx_id", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Cbx_bm.Clear
AdoRs.MoveFirst
For i = 0 To AdoRs.RecordCount - 1
Cbx_bm.AddItem AdoRs.Fields("bmxx_mc")
AdoRs.MoveNext
Next i
End If
AdoRs.Close
End Sub
Private Sub Form_Load()
Call LoadFile '在窗体加载的时候显示数据信息
For i = 1 To 20
Text1(i).Locked = True '锁定文本框,禁止输入字符信息
Next i
Adodc1.ConnectionString = PublicStr '通过代码连接到数据库
Adodc1.RecordSource = "select * from tb_Goods_sqd order by sqd_lszh"
Adodc1.Refresh
DT1.Value = Date
Call Tbr_cortrol(Tbr_xxcz, True)
End Sub
Private Sub Tbr_xxcz_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
Call Tbr_cortrol(Tbr_xxcz, False)
For i = 0 To 20
Text1(i).Locked = False
Text1(i).Text = ""
Next i
Text1(0).SetFocus
'根据日期产生流水账号
AdoRs.Open "select * from tb_Goods_sqd where sqd_lszh like '%" + Format(Date, "yyyymmdd") + "%' order by sqd_lszh", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
AdoRs.MoveLast
Txt_id.Text = Val(AdoRs.Fields("sqd_lszh")) + 1
Else
Txt_id.Text = Format(Date, "yyyymmdd") & "0000001"
End If
AdoRs.Close
Case 2 '删除信息
Call Deletes
Case 3 '修改信息
Call Edits
Case 4 '保存信息
Call Saves
Case 5
Call Tbr_cortrol(Tbr_xxcz, True)
For i = 1 To 20
Text1(i).Text = ""
Text1(1).SetFocus
Next i
Case 6 '打印信息
Unload Me
End Select
End Sub
Private Sub Text1_Change(Index As Integer)
If Index = 7 Then
Text1(15).Text = Val(Text1(7).Text) + Val(Text1(11).Text)
ElseIf Index = 11 Then
Text1(15).Text = Val(Text1(7).Text) + Val(Text1(11).Text)
ElseIf Index = 15 Then
Text1(15).Text = Val(Text1(7).Text) + Val(Text1(11).Text)
End If
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
If Index = 12 Then
Call Command1_Click
Exit Sub
End If
If Index = 1 Then
Call Cmd_Select_Click
Exit Sub
End If
If Index = 19 Then
Cbx_bm.SetFocus
Exit Sub
End If
If Index = 20 Then
Call Saves
Exit Sub
End If
End If
If Tbr_xxcz.Buttons(1).Enabled = True Then
If Index = 0 Then
AdoRs.Open "select * from tb_Goods_sqd where sqd_sqdh='" + Text1(0).Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Txt_id.Text = AdoRs.Fields(0)
Text1(0).Text = AdoRs.Fields(1)
Text1(1).Text = AdoRs.Fields(2)
Text1(2).Text = AdoRs.Fields(3)
DT1.Value = AdoRs.Fields(4)
Text1(3).Text = AdoRs.Fields(5)
Text1(4).Text = AdoRs.Fields(6)
DT2.Value = AdoRs.Fields(7)
Text1(5).Text = AdoRs.Fields(8)
Text1(6).Text = AdoRs.Fields(9)
Text1(7).Text = AdoRs.Fields(10)
Text1(8).Text = AdoRs.Fields(11)
Text1(9).Text = AdoRs.Fields(12)
Text1(10).Text = AdoRs.Fields(13)
Text1(11).Text = AdoRs.Fields(14)
Text1(12).Text = AdoRs.Fields(15)
Text1(13).Text = AdoRs.Fields(16)
Text1(14).Text = AdoRs.Fields(17)
Text1(15).Text = AdoRs.Fields(18)
Text1(16).Text = AdoRs.Fields(19)
Text1(17).Text = AdoRs.Fields(20)
Text1(18).Text = AdoRs.Fields(21)
Text1(19).Text = AdoRs.Fields(22)
Cbx_bm.Text = AdoRs.Fields(23)
Text1(20).Text = AdoRs.Fields(24)
End If
For i = 0 To 20
Text1(i).Locked = False
Next i
AdoRs.Close
Exit Sub
End If
Else
End If
If KeyCode = 13 Or KeyCode = 40 Then
If Index = 2 Then
DT1.SetFocus
Exit Sub
ElseIf Index = 4 Then
DT2.SetFocus
Exit Sub
End If
End If
If Index = 4 Then
If KeyCode = 38 Then
DT1.SetFocus
Exit Sub
End If
End If
If Index < 20 And KeyCode = 38 Then Text1(Index - 1).SetFocus
If Index >= 0 And KeyCode = 40 Then Text1(Index + 1).SetFocus
If Index >= 0 And KeyCode = 13 Then Text1(Index + 1).SetFocus
End Sub
Private Sub Saves() '保存信息的事件过程
If Text1(0).Text = "" Or Text1(3).Text = "" Or Text1(1).Text = "" Or Text1(5).Text = "" Then
MsgBox "重要信息不能为空值", 48, "提示信息"
Else
AdoRs.Open "select * from tb_Goods_sqd where sqd_sqdh='" + Text1(0).Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
MsgBox "该信息已经存在", 48, "提示信息"
AdoRs.Close
Else
AdoRs.Close
c = MsgBox("确认保存信息吗", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("insert into tb_Goods_sqd values('" & Txt_id & "','" & Text1(0) _
& "','" & Text1(1) & "','" & Text1(2) & "','" & STR(DT1.Value) & "','" & Text1(3) & "'," _
& Text1(4) & ",'" & STR(DT2.Value) & "','" & Text1(5) & "'," & Text1(6) & "," & Text1(7) _
& ",'" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "'," & Text1(11) & ",'" & Text1(12) _
& "','" & Text1(13) & "'," & Text1(14) & "," & Text1(15) & ",'" & Text1(16) & "'," & Text1(17) _
& "," & Text1(18) & ",'" & Text1(19) & "','" & Cbx_bm.Text & "','" & Text1(20) & "')")
MsgBox "数据保存成功", 64, "提示信息"
Else
End If
End If
Call Tbr_cortrol(Tbr_xxcz, True)
End If
End Sub
Private Sub Edits() '修改信息的事件过程
c = MsgBox("确认修改信息吗", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("UPDATE tb_Goods_sqd SET sqd_lszh='" + Txt_id + "',sqd_sqdh='" + Text1(0) + "',sqd_khbh='" + Text1(1) + "',sqd_khmc='" + Text1(2) + "',sqd_chrq='" _
+ STR(DT1.Value) + "',sqd_zjmc='" + Text1(3) + "',sqd_tj='" + Text1(4) + "',sqd_kprq='" + STR(DT2.Value) + "',sqd_ddbh='" + Text1(5) + "',sqd_zjsl='" + Text1(6) + "',sqd_yf=" _
+ Text1(7) + ",sqd_htbh='" + Text1(8) + "',sqd_cfdd='" + Text1(9) + "',sqd_fdmc='" + Text1(10) + "',sqd_fsfy=" + Text1(11) + ",sqd_clbh='" + Text1(12) + "',sqd_mddd='" + Text1(13) _
+ "',sqd_fjsl='" + Text1(14) + "',sqd_hjje=" + Text1(15) + ",sqd_cphm='" + Text1(16) + "',sqd_jl=" + Text1(17) + ",sqd_dw=" + Text1(18) + ",sqd_fqhm='" + Text1(19) + "',sqd_ssbm='" + Cbx_bm + "',sqd_bz='" + Text1(20) + "' where sqd_lszh='" + Txt_id.Text + "'")
MsgBox "数据修改成功", 64, "提示信息"
StrId = Text1(0).Text
StrTitle = Text1(2).Text
Call joinRZ
Else
' AdoRs.Close
End If
End Sub
Private Sub LoadFile()
AdoRs.Open "select * from tb_Goods_sqd", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Txt_id.Text = AdoRs.Fields(0)
Text1(0).Text = AdoRs.Fields(1)
Text1(1).Text = AdoRs.Fields(2)
Text1(2).Text = AdoRs.Fields(3)
DT1.Value = AdoRs.Fields(4)
Text1(3).Text = AdoRs.Fields(5)
Text1(4).Text = AdoRs.Fields(6)
DT2.Value = AdoRs.Fields(7)
Text1(5).Text = AdoRs.Fields(8)
Text1(6).Text = AdoRs.Fields(9)
Text1(7).Text = AdoRs.Fields(10)
Text1(8).Text = AdoRs.Fields(11)
Text1(9).Text = AdoRs.Fields(12)
Text1(10).Text = AdoRs.Fields(13)
Text1(11).Text = AdoRs.Fields(14)
Text1(12).Text = AdoRs.Fields(15)
Text1(13).Text = AdoRs.Fields(16)
Text1(14).Text = AdoRs.Fields(17)
Text1(15).Text = AdoRs.Fields(18)
Text1(16).Text = AdoRs.Fields(19)
Text1(17).Text = AdoRs.Fields(20)
Text1(18).Text = AdoRs.Fields(21)
Text1(19).Text = AdoRs.Fields(22)
Cbx_bm.Text = AdoRs.Fields(23)
Text1(20).Text = AdoRs.Fields(24)
End If
AdoRs.Close
End Sub
Private Sub Deletes() '删除信息
c = MsgBox("确认删除该信息吗", 17, "提示信息")
If c = vbOK Then
On Error Resume Next
Set AdoRs = Cnn.Execute("Delete tb_Goods_sqd from tb_Goods_sqd where sqd_lszh='" + Txt_id.Text + "'")
End If
For i = 0 To 20
Text1(i).Text = ""
Next i
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Lbl_Num.Caption = "当前数据表中共有 " & Adodc1.Recordset.RecordCount & " 条记录"
End Sub
Private Sub Txt_id_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '判断按下的是否是回车键
AdoRs.Open "select * from tb_Goods_sqd where sqd_sqdh='" + Text1(0).Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Txt_id.Text = AdoRs.Fields(0)
Text1(0).Text = AdoRs.Fields(1)
Text1(1).Text = AdoRs.Fields(3)
Text1(2).Text = AdoRs.Fields(4)
DT1.Value = AdoRs.Fields(4)
Text1(3).Text = AdoRs.Fields(5)
Text1(4).Text = AdoRs.Fields(6)
DT2.Value = AdoRs.Fields(7)
Text1(5).Text = AdoRs.Fields(8)
Text1(6).Text = AdoRs.Fields(9)
Text1(7).Text = AdoRs.Fields(10)
Text1(8).Text = AdoRs.Fields(11)
Text1(9).Text = AdoRs.Fields(12)
Text1(10).Text = AdoRs.Fields(13)
Text1(11).Text = AdoRs.Fields(14)
Text1(12).Text = AdoRs.Fields(15)
Text1(13).Text = AdoRs.Fields(16)
Text1(14).Text = AdoRs.Fields(17)
Text1(15).Text = AdoRs.Fields(18)
Text1(16).Text = AdoRs.Fields(19)
Text1(17).Text = AdoRs.Fields(20)
Text1(18).Text = AdoRs.Fields(21)
Text1(19).Text = AdoRs.Fields(22)
Cbx_bm.Text = AdoRs.Fields(23)
Text1(20).Text = AdoRs.Fields(24)
End If
AdoRs.Close '关闭记录集对象
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -