📄 firgx.frm
字号:
VERSION 5.00
Object = "{4F29B06F-16D9-4A0C-9C8A-2F0C02F625FE}#1.0#0"; "FlexCell.ocx"
Begin VB.Form firgx
Caption = "工序"
ClientHeight = 7410
ClientLeft = 60
ClientTop = 450
ClientWidth = 7170
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 7410
ScaleWidth = 7170
Begin FlexCell.Grid Grid1
Height = 5475
Left = 90
TabIndex = 7
Top = 690
Width = 6975
_ExtentX = 12303
_ExtentY = 9657
Cols = 5
Rows = 30
End
Begin VB.Frame Frame1
Height = 615
Left = 600
TabIndex = 0
Top = 6660
Width = 5475
Begin VB.CommandButton cmdadd
Caption = "增加"
Height = 255
Left = 120
TabIndex = 4
Top = 240
Width = 795
End
Begin VB.CommandButton cmdsave
Caption = "保存"
Height = 255
Left = 1092
TabIndex = 3
Top = 240
Width = 795
End
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 255
Left = 3180
TabIndex = 2
Top = 240
Width = 795
End
Begin VB.CommandButton cmddelete
Caption = "删行"
Height = 255
Left = 2064
TabIndex = 1
Top = 240
Width = 795
End
End
Begin VB.Label Label2
Caption = "注:编号最长4位,名称最长8位"
Height = 315
Left = 240
TabIndex = 6
Top = 6300
Width = 6555
End
Begin VB.Label Label1
Caption = "生产工序表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 435
Index = 4
Left = 2340
TabIndex = 5
Top = 120
Width = 2055
End
End
Attribute VB_Name = "firgx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'为保证数据库结构的完整性,对工序编号不作更改与删除,只可更改名称等内容,编号为美观最好全部为4位长度,并按车间编号相对直观
Option Explicit
Private Sub Form_Load()
Me.Width = 7300
Me.Height = 7900
Grid1.AutoRedraw = False
Grid1.DisplayFocusRect = False
Grid1.ExtendLastCol = True
Grid1.Cols = 7
Grid1.Rows = 1
Grid1.FixedRows = 1
Grid1.Column(0).Width = 18
Grid1.Column(1).Width = 60
Grid1.Column(2).Width = 100
Grid1.Column(3).Width = 60
Grid1.Column(4).Width = 60
Grid1.Column(5).Width = 2
Grid1.Column(6).Width = 100
Grid1.Column(6).CellType = cellComboBox
dogridfill
Grid1.Column(1).Locked = True '已存在的工序编号不能更改,只可编辑工序名称、显示序号、工序统计
Grid1.Column(5).Locked = True
Grid1.AutoRedraw = True
Grid1.Refresh
cmddelete.Enabled = False '工序不可删
End Sub
Private Sub dogridfill()
Grid1.Cell(0, 1).Text = "工序编号"
Grid1.Cell(0, 2).Text = "工序名称"
Grid1.Cell(0, 3).Text = "显示序号"
Grid1.Cell(0, 4).Text = "工序统计"
Grid1.Cell(0, 5).Text = "车间编号"
Grid1.Cell(0, 6).Text = "所属车间"
szSql = "select * from agx order by gxorder,gxbh"
Set rsTempA = oDb.Execute(szSql)
Do While Not rsTempA.EOF
Grid1.AddItem (rsTempA!gxbh & Chr(9) & rsTempA!gxmc & Chr(9) & rsTempA!gxorder & Chr(9) & rsTempA!gxtj & Chr(9) & rsTempA!gxcjbh & Chr(9) & rsTempA!gxcj)
rsTempA.MoveNext
Loop
Set rsTempC = oDb.Execute("select * from acj order by cjbh")
Do Until rsTempC.EOF
Grid1.ComboBox(6).AddItem rsTempC!cjmc
rsTempC.MoveNext
Loop
End Sub
Private Sub cmddelete_Click()
i = Grid1.ActiveCell.Row
griditem = Grid1.Cell(i, 1).Text
answer = MsgBox("删除此行?" & griditem, vbYesNo, "删除")
If answer = 6 Then
szSql = "delete from agx where gxbh='" & griditem & "'"
oDb.Execute szSql
Grid1.Selection.DeleteByRow
Grid1.Rows = 1
dogridfill
End If
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdadd_Click()
Grid1.Rows = Grid1.Rows + 1
Grid1.Cell(Grid1.Rows - 1, 4).Text = "Y"
Grid1.Column(1).Locked = False
End Sub
Private Sub cmdsave_Click()
'填入所属车间名称
For i = 1 To Grid1.Rows - 1
griditem = Trim(Grid1.Cell(i, 6).Text)
If Trim(griditem) <> "" Then
Set rsTempA = oDb.Execute("select * from acj where cjmc='" & griditem & "'")
Grid1.Cell(i, 5).Text = rsTempA!cjbh
End If
Next i
'保存
For i = 1 To Grid1.Rows - 1
griditem = Grid1.Cell(i, 1).Text
Set rsTempA = oDb.Execute("select gxbh from agx where gxbh='" & griditem & "'")
If rsTempA.RecordCount < 1 Then '增加保存
griditem = "'" & Grid1.Cell(i, 1).Text & "'"
If Grid1.Cell(i, 2).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 2).Text & "'" Else griditem = griditem & ",''"
If Grid1.Cell(i, 3).Text <> "" Then griditem = griditem & "," & Grid1.Cell(i, 3).Text & "" Else griditem = griditem & ",0"
If Grid1.Cell(i, 4).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 4).Text & "'" Else griditem = griditem & ",'Y'"
If Grid1.Cell(i, 5).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 5).Text & "'" Else griditem = griditem & ",''"
If Grid1.Cell(i, 6).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 6).Text & "'" Else griditem = griditem & ",''"
szSql = "insert agx (gxbh,gxmc,gxorder,gxtj,gxcjbh,gxcj) values (" & griditem & ")"
oDb.Execute szSql
Else
szSql = "UPDATE agx SET gxmc='" & Grid1.Cell(i, 2).Text & "',gxorder='" & Grid1.Cell(i, 3).Text & "',gxtj='" & Grid1.Cell(i, 4).Text & "',gxcjbh='" & Grid1.Cell(i, 5).Text & "',gxcj='" & Grid1.Cell(i, 6).Text & "' where gxbh='" & Grid1.Cell(i, 1).Text & "'"
oDb.Execute szSql
End If
Next i
Grid1.Column(1).Locked = True
MsgBox "成功保存", vbOKOnly, "保存"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -