F_LaoBaoFaFangMingDan.frm
资源名称:dbbase.rar [点击查看]
上传用户:xiao_xia32
上传日期:2022-07-21
资源大小:1174k
文件大小:28k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
- Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
- Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
- Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "THREED32.OCX"
- Begin VB.Form F_LaoBaoFaFangMingDan
- BorderStyle = 3 'Fixed Dialog
- Caption = "劳保发放通知"
- ClientHeight = 7020
- ClientLeft = 1095
- ClientTop = 330
- ClientWidth = 10395
- ControlBox = 0 'False
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- LockControls = -1 'True
- MaxButton = 0 'False
- MinButton = 0 'False
- Moveable = 0 'False
- ScaleHeight = 7020
- ScaleWidth = 10395
- StartUpPosition = 2 '屏幕中心
- Begin VB.Frame Frame1
- Height = 6735
- Left = 120
- TabIndex = 11
- Top = 120
- Width = 10095
- Begin TabDlg.SSTab SSTab1
- Height = 6135
- Left = 240
- TabIndex = 12
- Top = 360
- Width = 9615
- _ExtentX = 16960
- _ExtentY = 10821
- _Version = 393216
- Tabs = 2
- TabHeight = 520
- TabCaption(0) = "编 辑"
- TabPicture(0) = "F_LaoBaoFaFangMingDan.frx":0000
- Tab(0).ControlEnabled= -1 'True
- Tab(0).Control(0)= "Frame2"
- Tab(0).Control(0).Enabled= 0 'False
- Tab(0).Control(1)= "Picture1"
- Tab(0).Control(1).Enabled= 0 'False
- Tab(0).ControlCount= 2
- TabCaption(1) = "列 表"
- TabPicture(1) = "F_LaoBaoFaFangMingDan.frx":001C
- Tab(1).ControlEnabled= 0 'False
- Tab(1).Control(0)= "Frame3"
- Tab(1).ControlCount= 1
- Begin VB.PictureBox Picture1
- Appearance = 0 'Flat
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 420
- Left = 2280
- ScaleHeight = 420
- ScaleWidth = 6720
- TabIndex = 23
- Top = 5520
- Width = 6720
- Begin Threed.SSCommand cmdClose
- Height = 330
- Left = 5520
- TabIndex = 24
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&Q.关 闭"
- Font3D = 1
- End
- Begin Threed.SSCommand CmdAdd
- Height = 330
- Left = 720
- TabIndex = 6
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&A.增 加"
- Font3D = 1
- End
- Begin Threed.SSCommand cmdEdit
- Height = 330
- Left = 1920
- TabIndex = 7
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&E.编 辑"
- Font3D = 1
- End
- Begin Threed.SSCommand CmdDelete
- Height = 330
- Left = 3120
- TabIndex = 8
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&D.删 除"
- Font3D = 1
- End
- Begin Threed.SSCommand cmdUpdate
- Height = 330
- Left = 4320
- TabIndex = 25
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&Y.保 存"
- Font3D = 1
- End
- Begin Threed.SSCommand cmdRefresh
- Height = 330
- Left = 4320
- TabIndex = 9
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&R.刷新"
- Font3D = 1
- End
- Begin Threed.SSCommand cmdCancel
- Height = 330
- Left = 5520
- TabIndex = 10
- Top = 0
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 573
- _StockProps = 78
- Caption = "&C.取消"
- Font3D = 1
- End
- End
- Begin VB.Frame Frame3
- Height = 5415
- Left = -74760
- TabIndex = 19
- Top = 480
- Width = 9135
- Begin MSDataGridLib.DataGrid DataGrid1
- Height = 4815
- Left = 240
- TabIndex = 20
- Top = 360
- Width = 8655
- _ExtentX = 15266
- _ExtentY = 8493
- _Version = 393216
- AllowUpdate = 0 'False
- HeadLines = 1
- RowHeight = 14
- BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- 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
- Begin VB.Frame Frame2
- Height = 4935
- Left = 240
- TabIndex = 13
- Top = 480
- Width = 9135
- Begin VB.TextBox txtFields
- Appearance = 0 'Flat
- DataField = "通知单编号"
- Height = 285
- Index = 4
- Left = 1320
- TabIndex = 0
- Top = 480
- Width = 1815
- End
- Begin MSDataGridLib.DataGrid grdDataGrid
- Height = 3135
- Left = 240
- TabIndex = 21
- Top = 1560
- Width = 8655
- _ExtentX = 15266
- _ExtentY = 5530
- _Version = 393216
- HeadLines = 1
- RowHeight = 14
- FormatLocked = -1 'True
- BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- 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 = 6
- 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
- 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 = "使用年限"
- 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 = "更换时间"
- 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 = 1814.74
- EndProperty
- BeginProperty Column01
- ColumnWidth = 1035.213
- EndProperty
- BeginProperty Column02
- ColumnWidth = 1035.213
- EndProperty
- BeginProperty Column03
- ColumnWidth = 1214.929
- EndProperty
- BeginProperty Column04
- EndProperty
- BeginProperty Column05
- ColumnWidth = 1679.811
- EndProperty
- EndProperty
- End
- Begin MSComCtl2.DTPicker DTPicker1
- DataField = "领用时间"
- Height = 300
- Left = 7080
- TabIndex = 5
- Top = 960
- Width = 1815
- _ExtentX = 3201
- _ExtentY = 529
- _Version = 393216
- CheckBox = -1 'True
- DateIsNull = -1 'True
- Format = 127795201
- CurrentDate = 36189
- End
- Begin VB.TextBox txtFields
- Appearance = 0 'Flat
- DataField = "员工号"
- Height = 285
- Index = 0
- Left = 4200
- TabIndex = 1
- Top = 480
- Width = 1815
- End
- Begin VB.TextBox txtFields
- Appearance = 0 'Flat
- DataField = "姓名"
- Height = 285
- Index = 1
- Left = 7080
- TabIndex = 2
- Top = 480
- Width = 1815
- End
- Begin VB.TextBox txtFields
- Appearance = 0 'Flat
- DataField = "部门"
- Height = 285
- Index = 2
- Left = 1320
- TabIndex = 3
- Top = 960
- Width = 1815
- End
- Begin VB.TextBox txtFields
- Appearance = 0 'Flat
- DataField = "岗位"
- Height = 285
- Index = 3
- Left = 4200
- TabIndex = 4
- Top = 960
- Width = 1815
- End
- Begin VB.Label lblLabels
- Caption = "通知单编号"
- Height = 255
- Index = 5
- Left = 240
- TabIndex = 22
- Top = 480
- Width = 975
- End
- Begin VB.Label lblLabels
- Caption = "员工号"
- Height = 255
- Index = 0
- Left = 3360
- TabIndex = 18
- Top = 480
- Width = 735
- End
- Begin VB.Label lblLabels
- Caption = "姓 名"
- Height = 255
- Index = 1
- Left = 6240
- TabIndex = 17
- Top = 480
- Width = 735
- End
- Begin VB.Label lblLabels
- Caption = "部 门"
- Height = 255
- Index = 2
- Left = 240
- TabIndex = 16
- Top = 960
- Width = 1095
- End
- Begin VB.Label lblLabels
- Caption = "岗 位"
- Height = 255
- Index = 3
- Left = 3360
- TabIndex = 15
- Top = 960
- Width = 735
- End
- Begin VB.Label lblLabels
- Caption = "领用时间"
- Height = 255
- Index = 4
- Left = 6240
- TabIndex = 14
- Top = 960
- Width = 735
- End
- End
- End
- End
- End
- Attribute VB_Name = "F_LaoBaoFaFangMingDan"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim WithEvents adoPrimaryRS As Recordset
- Attribute adoPrimaryRS.VB_VarHelpID = -1
- Dim mvBookMark As Variant
- Dim mbEditFlag As Boolean
- Dim mbAddNewFlag As Boolean
- Private Function UpdateData() As Boolean
- Dim strTemp As String
- Dim adochild As ADODB.Recordset
- On Error GoTo UpdateErr
- '更新父表
- adoPrimaryRS.UpdateBatch adAffectCurrent
- '检查子表的有效性
- Set adochild = New Recordset
- Set adochild = adoPrimaryRS("ChildCMD").UnderlyingValue
- If Not adochild.BOF And Not adochild.EOF Then
- adochild.MoveFirst
- End If
- 'While Not adochild.EOF
- ' If Trim(adochild.Fields("单价")) = "" Or IsNull(adochild.Fields("单价")) Or Not IsNumeric(adochild.Fields("单价")) Then
- ' MsgBox "请在单价中输入数字!", vbExclamation + vbOKOnly, "警告"
- ' adochild.Close
- ' Set adochild = Nothing
- 'Exit Function
- 'End If
- 'If Trim(adochild.Fields("数量")) = "" Or IsNull(adochild.Fields("数量")) Or Not IsNumeric(adochild.Fields("单价")) Then
- ' MsgBox "请在数量中输入数字!", vbExclamation + vbOKOnly, "警告"
- ' adochild.Close
- ' Set adochild = Nothing
- 'Exit Function
- ' End If
- ' adochild.MoveNext
- ' Wend
- '更新子表
- adochild.UpdateBatch adAffectAllChapters
- adochild.Close
- Set adochild = Nothing
- ' strTemp = txtFields(0).Text
- ' Set grdDataGrid.DataSource = Nothing
- 'adoPrimaryRS.Requery
- 'adoPrimaryRS.Find "目的港='" & strTemp & "'", 0, adSearchForward
- 'Set grdDataGrid.DataSource = adoPrimaryRS("ChildCMD").UnderlyingValue
- UpdateData = True
- If mbAddNewFlag Then
- adoPrimaryRS.MoveLast 'move to the new record
- End If
- mbEditFlag = False
- mbAddNewFlag = False
- SetButtons True
- Exit Function
- UpdateErr:
- UpdateData = False
- End Function
- Private Sub DTPicker1_KeyPress(KeyAscii As Integer)
- If KeyAscii = vbKeyReturn Then
- SendKeys "{TAB}"
- End If
- End Sub
- Private Sub Form_Load()
- On Error Resume Next
- For Each TextBox In Me.Controls
- TextBox.Font.Name = "宋体"
- TextBox.Font.Size = 9
- Next
- SetButtons True
- 'Set adoPrimaryRS = New Recordset
- ' adoPrimaryRS.Open "SHAPE {通知单编号,员工号,姓名,部门,岗位,领用时间 from 劳保发放名单} AS ParentCMD APPEND ({劳保发放通知单编号,劳保物品名称,数量,单价,金额,使用年限,更换时间 from 劳保发放明细 } AS ChildCMD RELATE 通知单编号 TO 劳保发放通知单编号) AS ChildCMD", db1, adOpenStatic, adLockBatchOptimistic
- Set adoPrimaryRS = New Recordset
- adoPrimaryRS.Open "SHAPE {select 通知单编号,员工号,姓名,部门,岗位,领用时间 from 劳保发放名单} AS ParentCMD APPEND ({select 劳保发放通知单编号,劳保物品名称,数量,单价,金额,使用年限,更换时间 from 劳保发放明细 } AS ChildCMD RELATE 通知单编号 TO 劳保发放通知单编号) AS ChildCMD", db1, adOpenStatic, adLockBatchOptimistic
- Dim oText As TextBox
- 'Bind the text boxes to the data provider
- For Each oText In Me.txtFields
- Set oText.DataSource = adoPrimaryRS
- Next
- Set DTPicker1.DataSource = adoPrimaryRS
- If adoPrimaryRS.RecordCount <> 0 Then
- Set grdDataGrid.DataSource = adoPrimaryRS("ChildCMD").UnderlyingValue
- End If
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Screen.MousePointer = vbDefault
- End Sub
- Private Sub cmdAdd_Click()
- On Error GoTo AddErr
- With adoPrimaryRS
- If Not (.BOF And .EOF) Then
- mvBookMark = .Bookmark
- End If
- .AddNew
- mbAddNewFlag = True
- SetButtons False
- End With
- Exit Sub
- AddErr:
- MsgBox "增加操作失败", vbExclamation + vbOKOnly, pTitle
- End Sub
- Private Sub cmdDelete_Click()
- Dim adochild As ADODB.Recordset
- On Error GoTo DeleteErr
- RESULT = MsgBox("此操作将删除此记录所有信息,你真的要删除吗?", vbExclamation + vbYesNo + vbDefaultButton2, "提示")
- If RESULT = 6 Then '选择YES
- '删除子表记录
- Set adochild = New Recordset
- Set adochild = adoPrimaryRS("ChildCMD").UnderlyingValue
- While Not adochild.EOF
- adochild.Delete
- adochild.MoveNext
- Wend
- adochild.UpdateBatch adAffectAll
- adochild.Close
- Set adochild = Nothing
- '删除父表的当前记录
- With adoPrimaryRS
- .Delete
- .UpdateBatch adAffectCurrent
- .MoveNext
- If .EOF Then .MoveLast
- End With
- End If
- Exit Sub
- DeleteErr:
- MsgBox "删除数据失败!", vbExclamation + vbOKOnly, "Ptitle"
- End Sub
- Private Sub cmdRefresh_Click()
- 'This is only needed for multi user apps
- On Error GoTo RefreshErr
- adoPrimaryRS.Requery
- Exit Sub
- RefreshErr:
- MsgBox "刷新操作失败", vbExclamation + vbOKOnly, pTitle
- End Sub
- Private Sub cmdEdit_Click()
- On Error GoTo EditErr
- mbEditFlag = True
- SetButtons False
- Exit Sub
- EditErr:
- MsgBox "保存操作失败", vbExclamation + vbOKOnly, pTitle
- End Sub
- Private Sub cmdCancel_Click()
- ' On Error Resume Next
- On Error GoTo CancelErr
- mbEditFlag = False
- mbAddNewFlag = False
- adoPrimaryRS.CancelUpdate
- SetButtons True
- Exit Sub
- CancelErr:
- MsgBox "取消操作", vbExclamation + vbOKOnly, pTitle
- End Sub
- Private Sub cmdUpdate_Click()
- Dim blnUpdateFlag As Boolean
- blnUpdateFlag = UpdateData
- If blnUpdateFlag = True Then
- MsgBox "数据保存成功!", vbInformation + vbOKOnly, "提示"
- Else
- MsgBox "数据保存失败!", vbExclamation + vbOKOnly, "警告"
- End If
- End Sub
- Private Sub cmdClose_Click()
- RSGL.Enabled = True
- Unload Me
- End Sub
- Private Sub grdDataGrid_Error(ByVal DataError As Integer, Response As Integer)
- Response = 0
- MsgBox "输入数据不合法,请输入合法数据!", vbExclamation + vbOKOnly, pTitle
- End Sub
- Private Sub SetButtons(bVal As Boolean)
- Dim oText As TextBox
- CmdAdd.Visible = bVal
- cmdEdit.Visible = bVal
- cmdUpdate.Visible = Not bVal
- cmdCancel.Visible = Not bVal
- cmdDelete.Visible = bVal
- cmdClose.Visible = bVal
- cmdRefresh.Visible = bVal
- For Each oText In Me.txtFields
- oText.Enabled = Not bVal
- Next
- If Not bVal Then
- If mbEditFlag Then
- grdDataGrid.AllowAddNew = True
- grdDataGrid.AllowDelete = True
- grdDataGrid.AllowUpdate = True
- End If
- Else
- grdDataGrid.AllowAddNew = False
- grdDataGrid.AllowDelete = False
- grdDataGrid.AllowUpdate = False
- End If
- If bVal Then
- Set DataGrid1.DataSource = adoPrimaryRS
- Else
- Set DataGrid1.DataSource = Nothing
- End If
- DTPicker1.Enabled = Not bVal
- DTPicker1.Enabled = Not bVal
- End Sub
- Private Sub txtFields_KeyPress(Index As Integer, KeyAscii As Integer)
- If KeyAscii = vbKeyReturn Then
- SendKeys "{TAB}"
- End If
- End Sub
- Private Sub txtFields_LostFocus(Index As Integer)
- If Not IsNull(Trim(txtFields(4).Text)) And Index = 4 Then
- txtFields(4).Locked = True
- End If
- If Index = 0 Then
- Dim Sql3 As String
- Sql3 = "select distinct 部门 ,姓名 ,岗位 from 员工基本信息 where 员工号 = '" & txtFields(0).Text & "'"
- Set rs3 = db.Execute(Sql3)
- If Not rs3.EOF Then
- If Not IsNull(rs3("部门")) Then
- txtFields(2).Text = Trim(rs3("部门"))
- End If
- If Not IsNull(rs3("姓名")) Then
- txtFields(1).Text = Trim(rs3("姓名"))
- End If
- If Not IsNull(rs3("岗位")) Then
- txtFields(3).Text = Trim(rs3("岗位"))
- End If
- End If
- End If
- 'If Not IsNumeric(txtFields(6).Text) And (txtFields(6).Text <> "") Then
- ' MsgBox "请在“使用年限”中输入数字", vbExclamation + vbOKOnly, Ptitle
- ' txtFields(6).SetFocus
- ' txtFields(6).SelLength = Len(txtFields(6))
- ' txtFields(6).SelStart = 0
- 'End If
- 'If Not IsNumeric(txtFields(8).Text) And (txtFields(8).Text <> "") Then
- ' MsgBox "请在“数量”中输入数字", vbExclamation + vbOKOnly, Ptitle
- ' txtFields(8).SetFocus
- ' txtFields(8).SelLength = Len(txtFields(8))
- ' txtFields(8).SelStart = 0
- 'End If
- 'If Not IsNumeric(txtFields(9).Text) And (txtFields(9).Text <> "") Then
- ' MsgBox "请在“单价”中输入数字", vbExclamation + vbOKOnly, Ptitle
- ' txtFields(9).SetFocus
- ' txtFields(9).SelLength = Len(txtFields(9))
- 'txtFields(9).SelStart = 0
- 'End If
- End Sub