📄 frmscrw.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmScrw
Caption = "生产任务管理"
ClientHeight = 7020
ClientLeft = 60
ClientTop = 345
ClientWidth = 11880
LinkTopic = "Form1"
ScaleHeight = 7020
ScaleWidth = 11880
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdimportdata
Caption = "数据导入"
Height = 375
Left = 4320
TabIndex = 5
Top = 6360
Width = 1125
End
Begin VB.CommandButton cmdsch
Caption = "查找"
Height = 375
Left = 5595
TabIndex = 4
Top = 6360
Width = 1125
End
Begin MSAdodcLib.Adodc Adoscrw
Height = 330
Left = 240
Top = 6360
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSComDlg.CommonDialog cdimport
Left = 8700
Top = 6360
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 375
Left = 6870
TabIndex = 3
Top = 6360
Width = 1125
End
Begin VB.CommandButton cmdimport
Caption = "数据导入"
Height = 375
Left = 9630
TabIndex = 2
Top = 6540
Visible = 0 'False
Width = 1125
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "frmScrw.frx":0000
Height = 5385
Left = 120
TabIndex = 1
Top = 780
Width = 11745
_ExtentX = 20717
_ExtentY = 9499
_Version = 393216
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
AllowAddNew = -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 = 5
BeginProperty Column00
DataField = "ID"
Caption = "ID"
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
BeginProperty Column02
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 Column03
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 Column04
DataField = "备注2"
Caption = "备注2"
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
Object.Visible = 0 'False
ColumnWidth = 2085.166
EndProperty
BeginProperty Column01
ColumnWidth = 2099.906
EndProperty
BeginProperty Column02
ColumnWidth = 4004.788
EndProperty
BeginProperty Column03
ColumnWidth = 1005.165
EndProperty
BeginProperty Column04
ColumnWidth = 4004.788
EndProperty
EndProperty
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "生产任务数据导入"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 4320
TabIndex = 0
Top = 150
Width = 3225
End
End
Attribute VB_Name = "frmScrw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rstemp As ADODB.Recordset
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdimport_Click()
Dim vbExcel As Object
Dim sFile As String
Dim rectotal, i As Integer
Dim tablename As String
On Error Resume Next
tablename = "生产任务表"
Call Delrecord(tablename)
With cdimport
.DialogTitle = "打开"
.CancelError = False
'ToDo: 设置 common dialog 控件的标志和属性
.Filter = "EXCEL文件 (*.xls)|*.xls"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
Else
sFile = .FileName
End If
End With
'创建Excel对象
Set vbExcel = GetObject(, "Excel.Application")
If Err.Number <> 0 Then '表示Excel没有运行
Set vbExcel = CreateObject("Excel.Application")
End If
Err.Clear
rectotal = 30000 '导入的数据记录数
With vbExcel
.Visible = False
.ScreenUpdating = True
.Workbooks.Open sFile
With .Sheets(1) '填写数据
For i = 2 To rectotal
If Trim(.cells(i, 1)) <> "" Then
' Set rsTemp = New ADODB.Recordset '初始化数据库
' rsTemp.CursorType = adOpenKeyset
' rsTemp.CursorLocation = adUseClient
' rsTemp.LockType = adLockOptimistic
' rsTemp.Open "select * from 生产任务表 where 任务号='" & Trim(.cells(i, 9)) & "'", cnSys
' If rsTemp.RecordCount > 0 Then
' MsgBox "该任务号相关记录已存在,请认真检查!", 0 + 16, "提示窗"
' Exit Sub
' End If
Adoscrw.Recordset.AddNew
Adoscrw.Recordset("任务号") = Trim(.cells(i, 9))
Adoscrw.Recordset("型号规格") = Trim(.cells(i, 10))
If Trim(.cells(i, 12)) <> "" Then
Adoscrw.Recordset("数量") = Val(Trim(.cells(i, 12)))
Else
Adoscrw.Recordset("数量") = 0
End If
Adoscrw.Recordset("备注2") = Trim(.cells(i, 20))
Adoscrw.Recordset.Update
Else
Set vbExcel = Nothing
MsgBox "数据导入完毕!", 0 + 16, "提示窗"
Exit Sub
End If
Next
End With
End With
Set vbExcel = Nothing 'Release Excel Object variable
MsgBox "数据导入完毕!", 0 + 16, "提示窗"
End Sub
Private Sub cmdimportdata_Click()
Dim tablename As String
tablename = "生产任务表"
Call Delrecord(tablename)
rstemp.Close
rstemp.Open "select * from 订单订单分析", cnSysscrw
rstemp.MoveFirst
Do While Not rstemp.EOF
Adoscrw.Recordset.AddNew
Adoscrw.Recordset("任务号") = Trim(rstemp("任务号"))
Adoscrw.Recordset("型号规格") = Trim(rstemp("型号/规格"))
If Trim(rstemp("数量")) <> "" Then
Adoscrw.Recordset("数量") = Val(Trim(rstemp("数量")))
Else
Adoscrw.Recordset("数量") = 0
End If
Adoscrw.Recordset("备注2") = Trim(rstemp("备注2"))
Adoscrw.Recordset.Update
rstemp.MoveNext
Loop
MsgBox "数据导入完毕!", 0 + 16, "提示窗"
End Sub
Private Sub cmdsch_Click()
On Error Resume Next
tabname = "生产任务表"
If cmdsch.Caption = "查找" Then
frmSearch.Show vbModal
If strQuery <> "" Then
Adoscrw.RecordSource = strQuery
Adoscrw.Refresh
cmdsch.Caption = "重置"
End If
Else
strQuery = "Select * From " & tabname
Adoscrw.RecordSource = strQuery
Adoscrw.Refresh
cmdsch.Caption = "查找"
End If
End Sub
Private Sub Form_Load()
Dim scrwtemp As String
On Error Resume Next
scrwtemp = "无"
Set rstemp = New ADODB.Recordset '初始化数据库
rstemp.CursorType = adOpenKeyset
rstemp.CursorLocation = adUseClient
rstemp.LockType = adLockOptimistic
rstemp.Open "select * from 订单订单分析 where 任务号='" & scrwtemp & "'", cnSysscrw
Adoscrw.ConnectionString = strConn
Adoscrw.RecordSource = "Select * From 生产任务表"
Adoscrw.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -