📄 货物信息.frm
字号:
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = 14613966
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select 类别名称,备注 from 货物类别"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 11.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "货物信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private m_IsAdd1 As Boolean
Private m_IsAdd2 As Boolean
Private SQL As String
Private startcol As Integer
Private endcol As Integer
Private col, row As Integer
Private rowheight As Integer
Private colwidth(14) As Long
Private order(14) As Boolean
Option Explicit
Private Sub InitDataGrid2()
DataGrid2.Columns(0).Locked = True '编号
DataGrid2.Columns(2).Locked = True '类别编号
DataGrid2.Columns(0).Width = 500
DataGrid2.Columns(1).Width = 1500
DataGrid2.Columns(2).Width = 800
DataGrid2.Columns(3).Width = 1200
DataGrid2.Columns(4).Width = 800
DataGrid2.Columns(5).Width = 800
DataGrid2.Columns(6).Width = 800
DataGrid2.Columns(7).Width = 1200
If Adodc2.Recordset.RecordCount > 0 Then
Adodc2.Recordset.MoveLast
货物编号.Text = Adodc2.Recordset.Fields("编号").Value + 1
Adodc2.Recordset.MoveFirst
Else
货物编号.Text = 1
End If
End Sub
Private Sub SaveInit()
startcol = DataGrid2.SelStartCol
endcol = DataGrid2.SelEndCol
col = DataGrid2.LeftCol
row = DataGrid2.row
rowheight = DataGrid2.rowheight
Dim i As Integer
For i = 0 To DataGrid2.Columns.count - 1
colwidth(i) = DataGrid2.Columns(i).Width
Next
End Sub
Private Sub ResumeInit()
DataGrid2.SelStartCol = startcol
DataGrid2.SelEndCol = endcol
DataGrid2.Scroll col, row
DataGrid2.rowheight = rowheight
Dim i As Integer
For i = 0 To DataGrid2.Columns.count - 1
DataGrid2.Columns(i).Width = colwidth(i)
Next
End Sub
Private Sub initdatagrid1()
DataGrid1.Columns(0).Locked = True
DataGrid1.Columns(0).Width = 1200
DataGrid1.Columns(1).Width = 1000
DataGrid1.AllowRowSizing = False
DataGrid1.Columns(0).AllowSizing = False
DataGrid1.Columns(1).AllowSizing = False
End Sub
Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error Resume Next
Adodc1.caption = Adodc1.Recordset.Fields("类别名称").Value
End Sub
Private Sub Adodc2_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error Resume Next
Adodc2.caption = Adodc2.Recordset.Fields("货物名称").Value
End Sub
Private Sub DataGrid1_AfterDelete()
'写入系统日志
fMainForm.WriteLog ("删除货物类别")
End Sub
Private Sub DataGrid1_AfterInsert()
'写入系统日志
fMainForm.WriteLog ("增加货物类别")
End Sub
Private Sub DataGrid1_AfterUpdate()
'写入系统日志
fMainForm.WriteLog ("更新货物类别")
End Sub
Private Sub DataGrid1_BeforeDelete(Cancel As Integer)
On Error Resume Next
'判断是否其它表单用了待删除的货物类别
Dim name As String
Dim rs As String
name = DataGrid1.Columns(0).Text
rs = "select 货物信息.编号 from 货物信息,货物类别"
rs = rs + " Where 货物信息.货物类别='": rs = rs + name: rs = rs + "'"
fMainForm.m_checkado.RecordSource = rs
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
MsgBox "其它表单用了此货物类别信息,不能删除!", vbExclamation
Cancel = True
End If
End Sub
Private Sub DataGrid1_OnAddNew()
DataGrid1.Columns(0).Locked = False
m_IsAdd1 = True
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If m_IsAdd1 = False Then
DataGrid1.Columns(0).Locked = True
Else
m_IsAdd1 = False
End If
End Sub
Private Sub DataGrid2_AfterColUpdate(ByVal ColIndex As Integer)
If ColIndex = 0 Then DataGrid2.Columns(2).Value = 货物类别.Text
End Sub
Private Sub DataGrid2_AfterDelete()
'写入系统日志
fMainForm.WriteLog ("删除货物")
End Sub
Private Sub DataGrid2_AfterUpdate()
'写入系统日志
fMainForm.WriteLog ("更新货物")
End Sub
Private Sub DataGrid2_BeforeDelete(Cancel As Integer)
On Error Resume Next
'判断是否其它表单用了待删除的货物编号
Dim code As String
Dim rs As String
code = DataGrid2.Columns(0).Text
rs = ""
rs = rs + "select 货物编号 from 入库单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 出库单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 借入单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 借出单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 调拔单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 报损单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 库存状况 where 货物编号=" + Str(code)
fMainForm.m_checkado.RecordSource = rs
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
MsgBox "其它表单用了此货物信息,不能删除!", vbExclamation
Cancel = True
End If
End Sub
Private Sub DataGrid2_HeadClick(ByVal ColIndex As Integer)
On Error Resume Next
Dim caption As String
caption = DataGrid2.Columns(ColIndex).caption
If caption = "存放仓库" Then caption = "仓库名称"
Adodc2.RecordSource = SQL + " order by " + caption
order(ColIndex) = True - order(ColIndex)
If order(ColIndex) = True Then
Adodc2.RecordSource = Adodc2.RecordSource + " ASC"
Else
Adodc2.RecordSource = Adodc2.RecordSource + " DESC"
End If
SaveInit
Adodc2.Refresh
ResumeInit
End Sub
Private Sub DataGrid2_OnAddNew()
DataGrid2.Columns(0).Locked = False
m_IsAdd2 = True
End Sub
Private Sub DataGrid2_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If m_IsAdd2 = False Then
DataGrid2.Columns(0).Locked = True
Else
m_IsAdd2 = False
End If
End Sub
Private Sub Form_Load()
'初始化货物类别
Adodc1.ConnectionString = DataConnectString
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
'Adodc1.Visible = False
initdatagrid1
'初始化货物信息
Adodc2.ConnectionString = DataConnectString
SQL = Adodc2.RecordSource
Set DataGrid2.DataSource = Adodc2
Adodc2.Refresh
'Adodc2.Visible = False
'设置DataGrid2属性
InitDataGrid2
'增加新货物控件
Set 货物类别.DataSource = Adodc1
货物类别.DataField = "类别名称"
End Sub
Private Sub 更换类别_Click()
DataGrid2.Columns(2).Value = 货物类别.Text
'写入系统日志
fMainForm.WriteLog ("更新货物类别")
End Sub
Private Sub 货物类别_GotFocus()
货物类别.Enabled = False
End Sub
Private Sub 货物类别_LostFocus()
货物类别.Enabled = True
End Sub
Private Sub 删除货物_Click()
On Error Resume Next
'判断是否其它表单用了待删除的货物编号
Dim code As String
Dim rs As String
code = DataGrid2.Columns(0).Text
rs = ""
rs = rs + "select 货物编号 from 入库单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 出库单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 借入单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 借出单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 调拔单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 报损单 where 货物编号=" + Str(code): rs = rs + " union "
rs = rs + "select 货物编号 from 库存状况 where 货物编号=" + Str(code)
fMainForm.m_checkado.RecordSource = rs
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
MsgBox "其它表单用了此货物信息,不能删除!", vbExclamation
Else
fMainForm.m_checkado.RecordSource = "select * from 货物信息 where 编号=" + DataGrid2.Columns(0).Text
fMainForm.m_checkado.Refresh
fMainForm.m_checkado.Recordset.Delete
SaveInit
Adodc2.Refresh
ResumeInit
'写入系统日志
fMainForm.WriteLog ("删除货物")
End If
End Sub
Private Sub 增加新货物_Click()
If 货物编号.Text = "" Then MsgBox "请填写货物编号!", vbQuestion: Exit Sub
If 货物名称.Text = "" Then MsgBox "请填写货物名称!", vbQuestion: Exit Sub
If 最低限量.Text = "" Then MsgBox "请填写最低限量!", vbQuestion: Exit Sub
If 最高限量.Text = "" Then MsgBox "请填写最高限量!", vbQuestion: Exit Sub
If 计量单位.Text = "" Then MsgBox "请填写计量单位!", vbQuestion: Exit Sub
On Error Resume Next
SaveInit
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("编号") = 货物编号.Text
Adodc2.Recordset.Fields("货物名称") = 货物名称.Text
Adodc2.Recordset.Fields("货物类别") = DataGrid1.Columns(0).Text
Adodc2.Recordset.Fields("货物规格") = 货物规格.Text
Adodc2.Recordset.Fields("计量单位") = 计量单位.Text
Adodc2.Recordset.Fields("最低限量") = 最低限量.Text
Adodc2.Recordset.Fields("最高限量") = 最高限量.Text
Adodc2.Recordset.Fields("备注") = 备注.Text
Adodc2.Recordset.update
Adodc2.Recordset.Requery
Adodc2.Refresh
ResumeInit
货物编号.Text = 货物编号.Text + 1
'写入系统日志
fMainForm.WriteLog ("增加新货物")
End Sub
'此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
'╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
'╭⌒╭⌒╮╭⌒╮~╭⌒╮ ︶ ,︶︶
',︶︶︶︶,''︶~~ ,''~︶︶ ,''
'╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
'╬ ︱田︱田 田 ︱ ╬
'╬ http://www.5ivb.net ╬
'╬ ╭○╮● ╬
'╬ /■\/■\ ╬
'╬ <| || 有希望,就有成功! ╬
'╬ ╬
'╚╬╬╬╬╬╬╬╬╬╬╗ ╔╬╬╬╬╝
'
'说明:
'专业提供VB、.NET、Delphi、ASP、PB源码下载
'包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -