📄 frm_kcgl_scll_cx.frm
字号:
VERSION 5.00
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 Frm_Kcgl_Scll_cx
Caption = "生产领料查询"
ClientHeight = 3570
ClientLeft = 60
ClientTop = 345
ClientWidth = 6585
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 3570
ScaleWidth = 6585
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 180
Top = 2685
Visible = 0 'False
Width = 1800
_ExtentX = 3175
_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 = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_SCGL"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_SCGL"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from tb_SCGL_scll order by scll_id"
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 VB.Frame Frame1
Caption = "查询条件"
Height = 660
Left = 15
TabIndex = 0
Top = 15
Width = 6495
Begin VB.CommandButton Cmd_Exit
Caption = "退出"
Height = 300
Left = 5610
TabIndex = 7
Top = 225
Width = 800
End
Begin VB.CommandButton Cmd_DY
Caption = "打印"
Height = 300
Left = 4830
TabIndex = 6
Top = 225
Width = 800
End
Begin VB.CommandButton Cmd_Ok
Caption = "确定"
Height = 300
Left = 4050
TabIndex = 5
Top = 225
Width = 800
End
Begin VB.TextBox Txt_Key
Height = 300
Left = 2940
TabIndex = 3
Top = 225
Width = 1065
End
Begin VB.ComboBox Cbx_Oper
Height = 300
Left = 1875
TabIndex = 2
Text = "Cbx_Oper"
Top = 225
Width = 1050
End
Begin VB.ComboBox Cbx_Field
Height = 300
Left = 165
TabIndex = 1
Text = "Cbx_Field"
Top = 225
Width = 1695
End
End
Begin MSDataGridLib.DataGrid Dgr_Scll
Bindings = "Frm_Kcgl_Scll_cx.frx":0000
Height = 2805
Left = 15
TabIndex = 4
Top = 705
Width = 6510
_ExtentX = 11483
_ExtentY = 4948
_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 = "Frm_Kcgl_Scll_cx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub Dgr_Title()
Dgr_Scll.Columns(0).Caption = "领料单编号"
Dgr_Scll.Columns(1).Caption = "生产计划单"
Dgr_Scll.Columns(2).Caption = "产品编号"
Dgr_Scll.Columns(3).Caption = "产品名称"
Dgr_Scll.Columns(4).Caption = "产品规格"
Dgr_Scll.Columns(5).Caption = "产品单位"
Dgr_Scll.Columns(6).Caption = "产品数量"
Dgr_Scll.Columns(7).Caption = "物料编号"
Dgr_Scll.Columns(8).Caption = "物料名称"
Dgr_Scll.Columns(9).Caption = "物料规格"
Dgr_Scll.Columns(10).Caption = "物料单位"
Dgr_Scll.Columns(11).Caption = "单位需求量"
Dgr_Scll.Columns(12).Caption = "物料数量"
Dgr_Scll.Columns(13).Caption = "已领数量"
Dgr_Scll.Columns(14).Caption = "领料数量"
Dgr_Scll.Columns(15).Caption = "未领数量"
Dgr_Scll.Columns(16).Caption = "领料日期"
Dgr_Scll.Columns(17).Caption = "备注信息"
End Sub
Private Sub Cbx_Field_GotFocus()
Cbx_Field.BackColor = &HFFFF80
End Sub
Private Sub Cbx_Field_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Cbx_Oper.SetFocus
End Sub
Private Sub Cbx_Field_LostFocus()
Cbx_Field.BackColor = &HFFFFFF
End Sub
Private Sub Cbx_Oper_GotFocus()
Cbx_Oper.BackColor = &HFFFF80
End Sub
Private Sub Cbx_Oper_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Txt_Key.SetFocus
End Sub
Private Sub Cbx_Oper_LostFocus()
Cbx_Oper.BackColor = &HFFFFFF
End Sub
Private Sub Cmd_DY_Click() '打印
Dim i As Integer, j As Integer
Dim ifieldcount As Integer, irecordcount As Integer
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim atable As Word.Table
With Adodc1.Recordset
Adodc1.Recordset.MoveLast
Adodc1.Recordset.MoveFirst
ifieldcount = .Fields.Count
irecordcount = .RecordCount
End With
On Error Resume Next
'创建word应用程序,这一句话打开Word
Set wdapp = CreateObject("Word.Application")
'在word中添加一个新文档
Set wddoc = wdapp.Documents.Add
wddoc.PageSetup.Orientation = wdOrientLandscape
With wdapp
.Visible = True
.Activate
'在word中增加一个表格
Set atable = .ActiveDocument.Tables.Add(.Selection.Range, irecordcount + 1, ifieldcount)
For i = 0 To ifieldcount - 1
atable.Cell(1, i + 1).Range.InsertAfter Dgr_Scll.Columns(i).Caption
Next i
'指定表格内容
For i = 0 To irecordcount - 1
For j = 0 To ifieldcount - 1
Dgr_Scll.Row = i
Dgr_Scll.Col = j
atable.Cell(i + 2, j + 1).Range.InsertAfter Dgr_Scll.Text
Next j
Next i
End With
'清除word对象
Set wdapp = Nothing
Set wddoc = Nothing
End Sub
Private Sub Cmd_Exit_Click() '退出
Unload Me
End Sub
Private Sub Cmd_Ok_Click()
If Cbx_Field.Text = "产品数量" Then If Val(Txt_Key) <= 0 Then Txt_Key = 0
Fld1 = Adodc1.Recordset.Fields.Item(Cbx_Field.ListIndex).Name
Select Case Adodc1.Recordset.Fields(Cbx_Field.ListIndex).Type
Case 200 '字符数据
If Cbx_Oper.Text = "like" Then
sql = "select * from tb_SCGL_scll where " & Fld1 & " like+ '%'+'" + Txt_Key + "'+'%'"
Else
sql = "select * from tb_SCGL_scll where " & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
End If
Case 135 '日期数据
If Cbx_Oper.Text = "like" Then
MsgBox "日期型数据不能选用“Like”作为运算符!", , "提示窗口"
Cbx_Oper.ListIndex = 1
End If
If IsDate(Txt_Key) = False Then
MsgBox "请输入正确的日期!", , "提示窗口"
rs.Close
Exit Sub
End If
sql = "select * from tb_SCGL_scll where " & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
Case 6 '货币数据
If IsNumeric(Txt_Key) = False Then
MsgBox "请输入正确的数据!", , "提示窗口"
rs.Close
Exit Sub
End If
If Cbx_Oper.Text = "like" Then
MsgBox "货币数据不能选用“Like”作为运算符!", , "提示窗口"
Cbx_Oper.ListIndex = 1
End If
sql = "select * from tb_SCGL_scll where " & Fld1 & Txt_Key
Case 131 '数字数据
If Cbx_Oper.Text = "like" Then
MsgBox "数字数据不能选用“Like”作为运算符!", , "提示窗口"
Cbx_Oper.ListIndex = 1
End If
If IsNumeric(Val(Txt_Key)) = False Then
MsgBox "请输入正确的数据!", , "提示窗口"
rs.Close
Exit Sub
End If
sql = "select * from tb_SCGL_scll where " & Fld1 & Cbx_Oper & Txt_Key
Case Else
If Cbx_Oper.Text = "like" Then
sql = "select * from tb_SCGL_scll where " & Fld1 & " like+ '%'+'" + Txt_Key + "'+'%'"
Else
sql = "Select * from tb_SCGL_scll where " & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
End If
End Select
Adodc1.RecordSource = sql & "order by scll_id"
Adodc1.Refresh
Set Dgr_Scll.DataSource = Adodc1
Call Dgr_Title
End Sub
Private Sub Form_Load()
Adodc1.RecordSource = "select * from tb_SCGL_scll "
Adodc1.Refresh
Set Dgr_Scll.DataSource = Adodc1
Call Dgr_Title '调用过程
For i = 0 To Adodc1.Recordset.Fields.Count - 1
'向控件中添加数据项
Cbx_Field.AddItem Dgr_Scll.Columns(i).Caption
Next i
Cbx_Field.ListIndex = 0
'向Cbx_Oper中添加查询条件
Cbx_Oper.AddItem ("like")
Cbx_Oper.AddItem (">")
Cbx_Oper.AddItem ("=")
Cbx_Oper.AddItem (">=")
Cbx_Oper.AddItem ("<")
Cbx_Oper.AddItem ("<=")
Cbx_Oper.AddItem ("<>")
Cbx_Oper.ListIndex = 0
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub
Private Sub Txt_Key_GotFocus()
Txt_Key.BackColor = &HFFFF80
End Sub
Private Sub Txt_Key_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Cmd_Ok.SetFocus
End Sub
Private Sub Txt_Key_LostFocus()
Txt_Key.BackColor = &HFFFFFF
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -