📄 formpf.frm
字号:
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 = "EName"
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 = "Estandard"
Caption = "元器件规格"
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 = "EType"
Caption = "元器件型号"
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 = "EStock"
Caption = "库存量"
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 = "Xy"
Caption = "需求量"
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 = "cl"
Caption = "差量"
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 = "baojin"
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
ColumnWidth = 1275.024
EndProperty
BeginProperty Column01
Object.Visible = 0 'False
ColumnWidth = 1124.787
EndProperty
BeginProperty Column02
ColumnWidth = 2594.835
EndProperty
BeginProperty Column03
ColumnWidth = 1184.882
EndProperty
BeginProperty Column04
ColumnWidth = 1080
EndProperty
BeginProperty Column05
EndProperty
BeginProperty Column06
EndProperty
EndProperty
End
End
Attribute VB_Name = "Formpf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Flg As Boolean
Private Sub DataGrid1_AfterColEdit(ByVal ColIndex As Integer)
rd.Requery
End Sub
Private Sub DataGrid1_Click()
sqlstr = "Select * From ProStock where pname='" & Trim(DataGrid1.Columns(0).Text) & "' "
End Sub
'Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
'' If DataGrid1.Columns(0).Text <> "" Then
' SqlStr = "Select * From ProStock where pname='" & Trim(DataGrid1.Columns(0).Text) & "' "
''End If
'End Sub
Private Sub Form_Load()
Formpf.Top = 0
Formpf.Left = 0
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open App.Path + "\Data\Jxcdb.Mdb", "Admin"
cn.CursorLocation = adUseClient
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set rd = Nothing
End Sub
Private Sub Tbar_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo gl
Select Case Trim(Button.Key)
Case "new"
Frm.Visible = True
Tbar.Buttons(4).Enabled = False
sqlstr = "Select * From ProStock"
BandDataToDataGrid DataGrid1, rd
Tbar.Buttons(2).Enabled = True
Case "save"
If DataGrid1.row = -1 Then Exit Sub
Screen.MousePointer = 11
DataGrid1_Click
DataGrid2.Caption = DataGrid1.Columns(0).Text
DataGrid2.HeadFont.Bold = True
Frm.Visible = False
Dim Fld As String, Sl() As Integer, i As Integer
Flg = False
BandDataToDataGrid DataGrid1, rd
If rd.RecordCount > 0 Then
i = 0
ReDim Sl(rd.RecordCount) As Integer
rd.MoveFirst
Do While Not rd.EOF
Sl(i) = rd!Tmpnum
Fld = rd!Pcom + ","
i = i + 1
rd.MoveNext
Loop
Fld = Left(Fld, Len(Trim(Fld)) - 1)
Flg = True
End If
If Flg Then
Set rs = New ADODB.Recordset
rs.Source = "Select * From EleStock"
rs.Open , cn, adOpenKeyset, adLockOptimistic
Do While Not rs.EOF
rs!Xy = 0
rs.UpdateBatch adAffectCurrent
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
Dim dd As Integer
Dim rsph As Recordset
Set rsph = New ADODB.Recordset
rsph.Source = "Select " + Fld + ",Xy,id From EleStock where " + Fld + ">0 "
rsph.Open , cn, adOpenKeyset, adLockOptimistic
dd = rsph.RecordCount
Dim Ii As Integer, Ss As Integer
Do While Not rsph.EOF
Ss = 0
For Ii = 0 To rsph.Fields.Count - 3
Ss = Ss + rsph.Fields(Ii).Value * Sl(Ii)
Next Ii
rsph!Xy = Ss
rsph.UpdateBatch adAffectCurrent
rsph.MoveNext
Loop
Set rsph = Nothing
sqlstr = "Select EName,Estandard,Etype,Eunit,Elowstock,Estock,estock-elowstock as baojin, Xy,estock-xy as cl From EleStock Where Xy>0 "
BandDataToDataGrid DataGrid2, rd
End If
Tbar.Buttons(2).Enabled = False
Tbar.Buttons(4).Enabled = True
Tbar.Buttons(1).Enabled = True
' Else
' MsgBox " 请先输入模拟量! ", vbInformation, ginfo
' Exit Sub
'End If
Screen.MousePointer = vbDefault
Case "dele"
Case "edit"
Case "find"
Dim Reback As String
Reback = InputBox("请输入元件名称:", "查找元件信息", , 444, 444)
If Reback <> "" Then
sqlstr = "Select EName,Estandard,Etype,Eunit,Elowstock,Estock,estock-elowstock as baojin, Xy,estock-xy as cl From EleStock Where Xy>0 "
'and ename='" & Reback & "'"
Set rd = New ADODB.Recordset
rd.Source = sqlstr
rd.Open , cn, adOpenStatic, adLockBatchOptimistic
Set DataGrid2.DataSource = rd
rd.Find "ename='" & Reback & "'"
' and etype='" & & "'"
If rd.BOF Or rd.EOF Then
MsgBox " 没有该元件! ", vbInformation, ginfo
rd.MoveFirst
Exit Sub
End If
'rd.Close
'BandDataToDataGrid DataGrid2, rd
End If
Case "exit"
Unload Me
End Select
Exit Sub
gl: MsgBox err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -