📄 frmdataadm.frm
字号:
mrs_dc.Delete
If mrs_dc.EOF Then
mrs_d.MoveLast
Else
mrs_dc.MoveNext
End If
Call opendeviceclass
End If
If SSTab1.Tab = 1 Then
If DeviceLoadExist(mrs_d("deviceno")) Then
MsgBox "尚有设备负载存在,不能删除该设备", vbOKOnly
Exit Sub
End If
yn = MsgBox("真的要删除该条记录吗?", vbYesNo)
If yn = vbNo Then
Exit Sub
End If
mrs_d.Delete
If mrs_d.EOF Then
mrs_d.MoveLast
Else
mrs_d.MoveNext
End If
Call opendevice
End If
If SSTab1.Tab = 2 Then
yn = MsgBox("真的要删除该条记录吗?", vbYesNo)
If yn = vbNo Then
Exit Sub
End If
mrs_p.Delete
If mrs_p.EOF Then
mrs_d.MoveLast
Else
mrs_p.MoveNext
End If
Call openprocess
End If
If SSTab1.Tab = 3 Then
yn = MsgBox("真的要删除该条记录吗?", vbYesNo)
If yn = vbNo Then
Exit Sub
End If
mrs_bom.Delete
If mrs_bom.EOF Then
mrs_bom.MoveLast
Else
mrs_bom.MoveNext
End If
Call openbom
End If
Exit Sub
ErrMsg:
MsgBox err.Description, vbExclamation, "信息- Delete"
End Sub
Private Sub cmd_ok_Click()
Dim i As Integer
'On Error GoTo ErrMsg
If SSTab1.Tab = 0 Then
mrs_dc.AddNew
For i = 0 To mrs_dc.Fields.Count - 2
mrs_dc.Fields(i) = Trim(dc_txt(i).Text)
Next
mrs_dc.Update
dgd_deviceclass.Enabled = True
Call opendeviceclass
ElseIf SSTab1.Tab = 1 Then
mrs_d.AddNew
For i = 0 To mrs_d.Fields.Count - 2
mrs_d.Fields(i) = Trim(d_txt(i).Text)
Next
mrs_d.Update
dgd_device.Enabled = True
Call opendevice
ElseIf SSTab1.Tab = 2 Then
mrs_p.AddNew
For i = 0 To mrs_p.Fields.Count - 2
If i <> 4 Then
mrs_p.Fields(i) = Trim(pro_txt(i))
End If
Next
mrs_p.Fields(4) = Trim(cbo_dno.Text)
mrs_p.Update
dgd_process.Enabled = True
Call openprocess
ElseIf SSTab1.Tab = 3 Then
mrs_bom.AddNew
For i = 0 To mrs_bom.Fields.Count - 2
mrs_bom.Fields(i) = Trim(bom_txt(i))
Next
mrs_bom.Update
dgd_bom.Enabled = True
Call openbom
ElseIf SSTab1.Tab = 4 Then
End If
cmd_add.Enabled = True
cmd_del.Enabled = True
cmd_ok.Enabled = False
cmd_cancel.Enabled = False
Exit Sub
ErrMsg:
MsgBox err.Description, vbExclamation, " - Update"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call cmd_exit_Click
End Sub
Private Sub SSTab1_Click(Index As Integer)
' On Error Resume Next
cmd_add.Enabled = True
cmd_del.Enabled = True
cmd_ok.Enabled = False
cmd_cancel.Enabled = False
Select Case SSTab1.Tab
Case 0
Set mrs_d = Nothing
Set mrs_dc = Nothing
Set mrs_p = Nothing
Set mrs_bom = Nothing
opendeviceclass
Case 1
Set mrs_d = Nothing
Set mrs_dc = Nothing
Set mrs_p = Nothing
Set mrs_bom = Nothing
Call opendevice
Case 2
Set mrs_d = Nothing
Set mrs_dc = Nothing
Set mrs_p = Nothing
Set mrs_bom = Nothing
Call openprocess
Case 3
Set mrs_d = Nothing
Set mrs_dc = Nothing
Set mrs_p = Nothing
Set mrs_bom = Nothing
Call openbom
End Select
End Sub
Sub dgd_device_Click()
Dim sql As String, i As Integer
For i = 0 To mrs_d.Fields.Count - 2
d_txt(i) = mrs_d.Fields(i)
Next i
End Sub
Sub dgd_deviceclass_Click()
Dim sql As String, i As Integer
For i = 0 To mrs_dc.Fields.Count - 2
dc_txt(i) = mrs_dc.Fields(i)
Next i
End Sub
Sub dgd_process_Click()
Dim sql As String, i As Integer
For i = 0 To mrs_p.Fields.Count - 2
If i <> 4 Then
pro_txt(i) = mrs_p.Fields(i)
End If
Next i
cbo_dno = mrs_p(4)
Call cbo_dno_click
End Sub
Sub dgd_bom_Click()
Dim sql As String, i As Integer
For i = 0 To mrs_bom.Fields.Count - 2
bom_txt(i) = mrs_bom.Fields(i)
Next i
End Sub
Sub opendevice()
Dim sql As String, i As Integer
Set mrs_d = Nothing
sql = "select * from device order by deviceno"
mrs_d.CursorLocation = adUseClient
mrs_d.Open sql, mconn, adOpenKeyset, adLockPessimistic
If mrs_d.RecordCount = 0 Then
Set dgd_device.DataSource = Nothing
dgd_device.Refresh
Else
mrs_d.MoveFirst
Set dgd_device.DataSource = mrs_d
dgd_device.Refresh
dgd_device.Columns.Item(0).Caption = "设备编号"
dgd_device.Columns(0).Width = 0.7 * (dgd_device.Width + 600) / 3
dgd_device.Columns.Item(1).Caption = "设备名称"
dgd_device.Columns(1).Width = 0.7 * (dgd_device.Width + 600) / 3
dgd_device.Columns.Item(2).Caption = "设备类别"
dgd_device.Columns.Item(3).Caption = "设备类型"
dgd_device.Columns(2).Width = 0.7 * (dgd_device.Width + 600) / 6
dgd_device.Columns.Item(4).Caption = "购买日期"
dgd_device.Columns.Item(5).Caption = "设备状态"
dgd_device.Columns.Item(6).Caption = "操作员情况"
dgd_device.Columns.Item(7).Caption = "产品质量状态"
dgd_device.Columns.Item(8).Caption = "所属班组"
dgd_device.Columns.Item(9).Caption = "备注"
For i = 0 To mrs_d.Fields.Count - 2
d_txt(i) = mrs_d.Fields(i)
Next i
'If rs("note") <> Null Then
' txt_note = rs("note")
'End If
End If
End Sub
Sub opendeviceclass()
Dim sql As String, i As Integer
Set mrs_dc = Nothing
sql = "select * from deviceclass order by model"
mrs_dc.CursorLocation = adUseClient
mrs_dc.Open sql, mconn, adOpenKeyset, adLockPessimistic
If mrs_dc.RecordCount = 0 Then
Set dgd_deviceclass.DataSource = Nothing
dgd_deviceclass.Refresh
Else
mrs_dc.MoveFirst
Set dgd_deviceclass.DataSource = mrs_dc
dgd_deviceclass.Refresh
dgd_deviceclass.Columns.Item(0).Caption = "设备类编号"
dgd_deviceclass.Columns(0).Width = 0.7 * (dgd_deviceclass.Width + 600) / 3
dgd_deviceclass.Columns.Item(1).Caption = "设备类名称"
dgd_deviceclass.Columns(1).Width = 0.7 * (dgd_deviceclass.Width + 600) / 3
dgd_deviceclass.Columns.Item(2).Caption = "使用年限"
dgd_deviceclass.Columns(2).Width = 0.7 * (dgd_deviceclass.Width + 600) / 6
dgd_deviceclass.Columns.Item(3).Caption = "数量"
For i = 0 To mrs_dc.Fields.Count - 2
dc_txt(i) = mrs_dc.Fields(i)
Next i
End If
End Sub
Sub openprocess()
Dim sql As String, i As Integer
Set mrs_d = Nothing
Set mrs_dc = Nothing
Set mrs_bom = Nothing
Me.MousePointer = ccHourglass
Set mrs_p = Nothing
sql = "select * from t_subpmreference order by drawingnumber,processnumber"
'sql = "select * from t_machineprocess order by drawingnumber,processnumber"
mrs_p.CursorLocation = adUseClient
mrs_p.Open sql, mconn, adOpenKeyset, adLockPessimistic
If mrs_p.RecordCount = 0 Then
Set dgd_process.DataSource = Nothing
dgd_process.Refresh
Else
mrs_p.MoveFirst
Set dgd_process.DataSource = mrs_p
dgd_process.Refresh
dgd_process.Columns.Item(0).Caption = "产品图号"
dgd_process.Columns.Item(1).Caption = "产品名称"
'dgd_process.Columns(0).Width = 0.7 * (dgd_process.Width + 600) / 3
dgd_process.Columns.Item(2).Caption = "工艺号"
dgd_process.Columns.Item(3).Caption = "工艺名称"
'dgd_process.Columns(1).Width = 0.7 * (dgd_process.Width + 600) / 3
dgd_process.Columns.Item(4).Caption = "加工中心"
'dgd_process.Columns(3).Width = 0.7 * (dgd_process.Width + 600) / 6
dgd_process.Columns.Item(5).Caption = "相关零部件图号"
dgd_process.Columns.Item(6).Caption = "相关零部件名称"
dgd_process.Columns.Item(7).Caption = "占用时间"
dgd_process.Columns.Item(8).Caption = "占用人力"
For i = 0 To mrs_p.Fields.Count - 2
pro_txt(i) = mrs_p.Fields(i)
Next i
End If
Me.MousePointer = ccDefault
End Sub
Sub openbom()
Dim sql As String, i As Integer
Set mrs_bom = Nothing
sql = "select * from t_bom "
'sql = "select * from t_spbillofmaterial "
mrs_bom.CursorLocation = adUseClient
mrs_bom.Open sql, mconn, adOpenKeyset, adLockPessimistic
If mrs_bom.RecordCount = 0 Then
Set dgd_bom.DataSource = Nothing
dgd_bom.Refresh
Else
mrs_bom.MoveFirst
Set dgd_bom.DataSource = mrs_bom
dgd_bom.Refresh
dgd_bom.Columns.Item(0).Caption = "工作号"
dgd_bom.Columns(0).Width = 0.7 * (dgd_bom.Width + 600) / 3
dgd_bom.Columns.Item(1).Caption = "父件图号"
dgd_bom.Columns(1).Width = 0.7 * (dgd_bom.Width + 600) / 3
dgd_bom.Columns.Item(2).Caption = "父件名称"
dgd_bom.Columns(2).Width = 0.7 * (dgd_bom.Width + 600) / 6
dgd_bom.Columns.Item(3).Caption = "子件图号"
dgd_bom.Columns.Item(4).Caption = "子件名称"
dgd_bom.Columns.Item(5).Caption = "台份数量"
dgd_bom.Columns.Item(6).Caption = "材料"
dgd_bom.Columns.Item(7).Caption = "工厂行程"
dgd_bom.Columns.Item(8).Caption = "加工类型"
For i = 0 To mrs_bom.Fields.Count - 2
bom_txt(i) = mrs_bom.Fields(i)
Next i
End If
End Sub
Sub setprocess_additem()
Dim sql As String, rs0 As New ADODB.Recordset
cbo_dno.Clear
'cbo_dname.Clear
sql = "select location from device"
rs0.CursorLocation = adUseClient
rs0.Open sql, mconn, adOpenKeyset, adLockPessimistic
rs0.MoveFirst
While Not rs0.EOF
cbo_dno.AddItem rs0(0)
'cbo_dname.AddItem rs0(1)
rs0.MoveNext
Wend
rs0.Close
End Sub
Function DeviceExist(model As String)
Dim sql As String, rs0 As New ADODB.Recordset
sql = "select * from device where model='" & model & "'"
rs0.CursorLocation = adUseClient
rs0.Open sql, mconn, adOpenKeyset, adLockPessimistic
If rs0.RecordCount <> 0 Then
DeviceExist = 1
Else
DeviceExist = 0
End If
rs0.Close
End Function
Function DeviceLoadExist(dno As String)
Dim sql As String, rs0 As New ADODB.Recordset
sql = "select * from deviceload where deviceno='" & dno & "'"
rs0.CursorLocation = adUseClient
rs0.Open sql, mconn, adOpenKeyset, adLockPessimistic
If rs0.RecordCount <> 0 Then
DeviceExist = 1
Else
DeviceExist = 0
End If
rs0.Close
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -