📄 frmprice.frm
字号:
TabIndex = 4
Top = 600
Width = 855
End
Begin VB.Label Label1
Caption = "流 水 号:"
Height = 255
Left = 120
TabIndex = 2
Top = 240
Width = 975
End
End
Begin MSDataGridLib.DataGrid dgmantainrecord
Bindings = "frmPrice.frx":0000
Height = 2775
Left = 0
TabIndex = 0
Top = 0
Width = 7935
_ExtentX = 13996
_ExtentY = 4895
_Version = 393216
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
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 = 7
BeginProperty Column00
DataField = "Sn"
Caption = "Sn"
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 = "MantainDate"
Caption = "MantainDate"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "BookNo"
Caption = "BookNo"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "Account"
Caption = "Account"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "Operation"
Caption = "Operation"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column05
DataField = "OriginalData"
Caption = "OriginalData"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column06
DataField = "NewDate"
Caption = "NewDate"
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
ColumnWidth = 1094.74
EndProperty
BeginProperty Column01
ColumnWidth = 2085.166
EndProperty
BeginProperty Column02
ColumnWidth = 2085.166
EndProperty
BeginProperty Column03
ColumnWidth = 1365.165
EndProperty
BeginProperty Column04
ColumnWidth = 1365.165
EndProperty
BeginProperty Column05
ColumnWidth = 2085.166
EndProperty
BeginProperty Column06
ColumnWidth = 2085.166
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmPrice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
DTPicker1.Value = Date '日期控件为当前时间
'清空各文本框
For i = 1 To 5
txtfield(i).Text = ""
Next i
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub cmdExit_Click()
Dim a As Integer
a = MsgBox("确认要退出价格维护吗?", 36)
If a = 6 Then '点击“确定”
Unload Me
End If
End Sub
Private Sub cmdSave_Click()
'如果输入的新数据不符合
If Val(txtfield(5).Text) < 0 Or Val(txtfield(5).Text) > 10 Then
MsgBox "输入的新数据不对!,请重新输入!"
rs.Close '关闭记录集
Exit Sub
End If
'在修改记录表中插入新记录
con.Execute "insert into MantainRecord values(" & txtfield(0).Text & ",'" _
& DTPicker1.Value & "','" & Trim(txtfield(1).Text) & "','" & Trim(txtfield(2).Text) _
& "','" & Trim(txtfield(3).Text) & "'," & Val(txtfield(4).Text) & "," & Val(txtfield(5).Text) & ")"
' 更新基本资料表的折扣数据
con.Execute "update BookRecord set Discount='" & txtfield(5).Text _
& "' where BookNo='" & txtfield(1).Text & "'"
MsgBox "操作成功,OK!", vbOKOnly, "提示框"
AdoMantainRecord.RecordSource = "select * from MantainRecord"
cmdSave.Enabled = False '保存按钮不可
End Sub
Private Sub Command3_Click()
DTPicker1.Value = Date '日期控件为当前时间
'清空各文本框
For i = 1 To 5
txtfield(i).Text = ""
Next i
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
'ado控件连接
AdoMantainRecord.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
& "Persist Security Info=False;Initial Catalog=图书销售系统"
AdoMantainRecord.CommandType = adCmdTable
AdoMantainRecord.RecordSource = "select * from MantainRecord"
' AdoMantainRecord.Refresh
Set dgmantainrecord.DataSource = AdoMantainRecord
'改变表控件的列名
With dgmantainrecord
.Columns(0).Caption = "流水号"
.Columns(1).Caption = " 日期"
.Columns(2).Caption = "书号"
.Columns(3).Caption = "操作员帐号"
.Columns(4).Caption = "操作"
.Columns(5).Caption = "原数据"
.Columns(6).Caption = "修改后数据"
End With
cmdSave.Enabled = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '如果是回车键
If rs.State <> 0 Then rs.Close '如果记录集不是关闭,则关闭'
'打开新的记录
Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=图书销售系统;"
Set rs = New ADODB.Recordset
rs.Open "select * from BookRecord where BookNo='" & Text1.Text & "'", con
If rs.EOF = True Then
MsgBox "基本资料表中没有该书存在"
rs.Close '关闭记录集
Exit Sub
End If
Text2.Text = rs(1).Value '填充书名到"书名"文本框
txtfield(1).Text = Text1.Text '填充书号到"书号"文本框
txtfield(2).Text = username '操作员文本框填入当前操作员帐号
txtfield(3).Text = "修改" '操作文本框
txtfield(4).Text = rs(6).Value '填充原折扣数据到"原数据"文本框
txtfield(5).SetFocus
cmdSave.Enabled = True
Set res = New ADODB.Recordset
res.Open "select * from MantainRecord order by Sn", con, adOpenKeyset
If res.RecordCount > 0 Then
res.MoveLast
txtfield(0).Text = Trim(Str(res.Fields("Sn").Value + 1))
Else
txtfield(0).Text = "1"
End If
res.Close
Set res = Nothing
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -