📄 frmbookin.frm
字号:
End
Begin VB.Label Label4
Caption = "书 名:"
Height = 255
Left = 720
TabIndex = 9
Top = 1320
Width = 1095
End
Begin VB.Label Label3
Caption = "书 号:"
Height = 255
Left = 720
TabIndex = 7
Top = 960
Width = 1095
End
Begin VB.Label Label2
Caption = "操作员帐号:"
Height = 255
Left = 720
TabIndex = 5
Top = 600
Width = 1095
End
Begin VB.Label Label1
Caption = "流 水 号:"
Height = 255
Left = 720
TabIndex = 3
Top = 240
Width = 1095
End
End
Begin MSDataGridLib.DataGrid dginrecord
Height = 3015
Left = 0
TabIndex = 0
Top = 0
Width = 9495
_ExtentX = 16748
_ExtentY = 5318
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmBookIn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer '定义模块变量
Sub txtFill() '填充数据到文本框
On Error Resume Next '避免无数据填充到文本框出错
For i = 0 To adoInRecord.Recordset.Fields.Count - 2
txtinrecord(i).Text = adoInRecord.Recordset.Fields(i).Value
Next
dtime.Value = adoInRecord.Recordset("InDate").Value
End Sub
Sub txtclear() '清除文本框内容
For i = 2 To 6
txtinrecord(i).Text = ""
Next
End Sub
Private Sub cmdadd_Click()
txtinrecord(1).Text = username '自动插入当前的帐号
txtinrecord(2).SetFocus
txtclear '清除文本框内容
End Sub
Private Sub cmdcancel_Click()
For i = 1 To 6
txtinrecord(i).Text = ""
Next
dtime.Value = Date
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdfind_Click()
Dim str1 As String
str1 = InputBox("请输入书号:", "模糊查找书名")
If str1 <> "" Then
adoInRecord.RecordSource = "select * from InRecord where BookNo like '" & str1 & "%'"
adoInRecord.Refresh
txtFill
End If
End Sub
Private Sub cmdfirst_Click()
On Error Resume Next '避免没有记录的情况
If adoInRecord.Recordset.AbsolutePosition <> 1 Then adoInRecord.Recordset.MoveFirst '如果当前记录不是第一条,移动到第一条
txtFill '填充数据到文本框
End Sub
Private Sub cmdlast_Click()
On Error Resume Next '避免没有记录的情况
If adoInRecord.Recordset.AbsolutePosition <> adoInRecord.Recordset.RecordCount Then '如果当前记录不是最后一条
adoInRecord.Recordset.MoveLast
txtFill '填充数据到文本框
End If
End Sub
Private Sub cmdnext_Click()
On Error Resume Next '避免没有记录的情况
If adoInRecord.Recordset.AbsolutePosition <> adoInRecord.Recordset.RecordCount Then '如果当前记录不是最后一条
adoInRecord.Recordset.MoveNext
txtFill '填充数据到文本框
Else
MsgBox "已经到达最后一条记录", 48
End If
End Sub
Private Sub cmdpre_Click()
On Error Resume Next '避免没有记录的情况
If adoInRecord.Recordset.AbsolutePosition <> 1 Then '如果当前记录不是第一条
adoInRecord.Recordset.MovePrevious
txtFill
Else
MsgBox "已经到达最前一条记录", 48
End If
End Sub
Private Sub cmdrefresh_Click()
adoInRecord.RecordSource = "select * from InRecord"
adoInRecord.Refresh
'改变dginrecord列的名称
With dginrecord
.Columns(0).Caption = "流水号"
.Columns(1).Caption = "操作员"
.Columns(2).Caption = "书号"
.Columns(3).Caption = "书名"
.Columns(4).Caption = "数量"
.Columns(5).Caption = "入库价"
.Columns(6).Caption = "销售价"
.Columns(7).Caption = "入库时间"
End With
End Sub
Private Sub cmdsave_Click()
Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=图书销售系统;Data Source=1062781987F44B5"
Set rs = New ADODB.Recordset
rs.Open "select * from BookRecord where BookNo='" & Trim(txtinrecord(2)) & "'", con
If rs.EOF = False Then '如果是旧书
'更新图书基本资料的库存数量
con.Execute "update BookRecord set Quantity=Quantity + " & Val(txtinrecord(4)) & " where BookNo='" & txtinrecord(2).Text & "'"
MsgBox "该书在库存中已经存在,修改数量成功"
Else '新书
MsgBox "该书是新书,请先在基本资料填入信息!,然后再保存一次", , "图书入库"
With frmBookRecord
.AdoBookRecord.Recordset.AddNew
.txtBook.Text = txtinrecord(2).Text '填充书号到基本资料窗体书号文本框
.txtBook1.Text = txtinrecord(3).Text '填充书名到基本资料窗体的书名文本框
.txtBook4.Text = txtinrecord(6).Text '填充单价到文本框
.txtBook5.Text = txtinrecord(4).Text '填充数量到文本框
.Show
End With
rs.Close '关闭记录集
Exit Sub
End If
adoInRecord.Recordset.AddNew
For i = 0 To 6
If txtinrecord(i).Text <> "" Then adoInRecord.Recordset.Fields(i).Value = Trim(txtinrecord(i).Text)
Next i
adoInRecord.Recordset.Fields("InDate").Value = dtime.Value
adoInRecord.Recordset.Update
rs.Close
con.Close
End Sub
Private Sub dginrecord_Click() '单击dginrecord时
txtFill
End Sub
Private Sub Form_Load()
adoInRecord.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=图书销售系统;Data Source=1062781987F44B5"
adoInRecord.CommandType = adCmdText
adoInRecord.RecordSource = "select * from InRecord"
adoInRecord.Refresh
Set dginrecord.DataSource = adoInRecord
'改变dginrecord列的名称
With dginrecord
.Columns(0).Caption = "流水号"
.Columns(1).Caption = "操作员"
.Columns(2).Caption = "书号"
.Columns(3).Caption = "书名"
.Columns(4).Caption = "数量"
.Columns(5).Caption = "入库价"
.Columns(6).Caption = "销售价"
.Columns(7).Caption = "入库时间"
End With
dtime.Value = Date '使得日期控件的日期为当前日期
txtinrecord(1).Text = username
If adoInRecord.Recordset.RecordCount = 0 Then
txtinrecord(0).Text = "1"
Else
adoInRecord.Recordset.MoveLast
txtinrecord(0).Text = Trim(Str(adoInRecord.Recordset.Fields(0).Value + 1))
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -