📄 frmunitconsolidation.frm
字号:
End Sub
Private Sub Command4Merge_Click()
Dim i As Long
If VSFlexGrid4Source.Cell(flexcpData, Me.VSFlexGrid4Source.Row, 0) = Me.VSFlexGrid4Destinition.Cell(flexcpData, Me.VSFlexGrid4Destinition.Row, 0) Then MsgBox "同机构内不能调整", vbOKOnly, "提示": Exit Sub
With Me.VSFlexGrid4EmpSource
For i = 1 To .Rows - 1
If .TextMatrix(i, 0) = "True" Then Exit For
Next
If i >= .Rows Then
MsgBox "请选择至少一个人员!", vbOKOnly, "提示"
Exit Sub
End If
If MsgBox("你确定将所选人员加入" & VSFlexGrid4Destinition.TextMatrix(VSFlexGrid4Destinition.Row, 0) & "吗?", vbYesNo, "提示") = vbNo Then MousePointer = 1: Exit Sub
MousePointer = 11
ExcuteSQL "begin transaction"
For i = 1 To .Rows - 1
If .TextMatrix(i, 0) = "True" Then
If GetRecordEmpInfo(VSFlexGrid4Source.Cell(flexcpData, VSFlexGrid4Source.Row), .TextMatrix(i, 5), VSFlexGrid4Destinition.Cell(flexcpData, VSFlexGrid4Destinition.Row)) = False Then
MousePointer = 1
ExcuteSQL "rollback transaction"
Exit Sub
End If
End If
Next
End With
ExcuteSQL "commit transaction"
FillEmp VSFlexGrid4Source, VSFlexGrid4Source.Row, VSFlexGrid4EmpSource, True
FillEmp VSFlexGrid4Destinition, VSFlexGrid4Destinition.Row, VSFlexGrid4EmpDestinition, False
MsgBox "调整完毕!", vbOKOnly, "完成"
End Sub
Private Sub Form_Load()
Me.Height = 5460
Me.Width = 9540
Me.Command4Close.Enabled = False
VSFlexGrid4EmpSource.ColHidden(5) = True
VSFlexGrid4EmpDestinition.ColHidden(5) = True
VSFlexGrid4Source.ColHidden(1) = True
VSFlexGrid4Destinition.ColHidden(1) = True
VSFlexGrid4EmpSource.AllowUserResizing = flexResizeColumns
VSFlexGrid4EmpDestinition.AllowUserResizing = flexResizeColumns
LoadData VSFlexGrid4Source, True
LoadData VSFlexGrid4Destinition, False
With VSFlexGrid4EmpSource
.Rows = 1
.Cols = 6
.FixedCols = 0
.ColDataType(0) = flexDTBoolean
.ColDataType(3) = flexDTDate
.ColFormat(3) = "yyyy-mm-dd"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "身份证号"
.TextMatrix(0, 3) = "出生日期"
.TextMatrix(0, 4) = "籍贯"
.AutoSize 0, 4
.ColWidth(0) = .RowHeight(0)
VSFlexGrid4EmpSource.ColHidden(5) = True
.ExtendLastCol = True
End With
Me.Command4Close.Enabled = True
FillEmp VSFlexGrid4Source, 0, VSFlexGrid4EmpSource, True
FillEmp VSFlexGrid4Destinition, 0, VSFlexGrid4EmpDestinition, False
Unload frmSplash
End Sub
Private Function FillOrgan(paraNode As VSFlexNode, ByVal StartData As String, ByVal iLevel As Integer, ByVal Vsf As VSFlexGrid, ByVal bIsAll As Boolean) As Boolean
Dim strSQL As String
Dim TmpBoolean As Boolean
Dim tmpNode As VSFlexNode
Dim TmpRst As New ADODB.Recordset
If iLevel > 4 Then Exit Function
Select Case g_str4LoginUnitLevel
Case C_BUREAUE_LEVEL
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3
Case C_FACTORY_LEVEL
If Len(StartData) = C_FACTORY_LENGTH Then
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3
Else
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3 & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_COMPANY_LEVEL
If Len(StartData) = C_COMPANY_LENGTH Then
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3
Else
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3 & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_LARGE_LEVEL
If Len(StartData) = C_LARGE_LENGTH Then
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3
Else
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3 & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_SMALL_LEVEL
If Len(StartData) = C_SMALL_LENGTH Then
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3
Else
strSQL = "Select * from t_organ where (organ_no between " & "'" & StartData & String(3, "0") & "'" & " AND '" & StartData & String(3, "9") & "') AND LEN(organ_no)=" & Len(StartData) + 3 & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
End Select
If bIsAll = False Then
strSQL = strSQL & HaveOrganMark
Else
strSQL = strSQL & " and ( ORGAN_DELETE_MARK=" & C_Organ_Have & " or ORGAN_DELETE_MARK =" & C_Organ_Delete_Have_Used_Unit & ")"
End If
TmpRst.CursorType = adOpenKeyset
TmpRst.CursorLocation = adUseClient
TmpRst.Open strSQL, g_oConnection4This
If TmpRst.BOF = True Then
TmpRst.Close
Set TmpRst = Nothing
Exit Function
Else
TmpRst.MoveFirst
While TmpRst.EOF = False
Set tmpNode = paraNode.AddNode(6, TmpRst.Fields("organ_Name").Value)
Vsf.Cell(flexcpData, Vsf.Rows - 1) = TmpRst.Fields("organ_no").Value
Vsf.IsSubtotal(Vsf.Rows - 1) = True
If Len(TmpRst.Fields("organ_no").Value) = 15 Then
Vsf.RowOutlineLevel(Vsf.Rows - 1) = iLevel + 1
Else
Vsf.RowOutlineLevel(Vsf.Rows - 1) = iLevel
End If
TmpBoolean = FillOrgan(tmpNode, TmpRst.Fields("organ_no").Value, iLevel + 1, Vsf, bIsAll)
tmpNode.Expanded = False
TmpRst.MoveNext
Wend
End If
TmpRst.Close
Set TmpRst = Nothing
End Function
Private Sub LoadData(ByVal VSFlexGrid4This As VSFlexGrid, ByVal bIsAll As Boolean)
Dim tmpNode As VSFlexNode
Dim oRs4This As New ADODB.Recordset
Dim strSQL As String
With VSFlexGrid4This
.SelectionMode = flexSelectionByRow
.FixedCols = 0
.FixedRows = 0
.Rows = 0
.Cols = 1
.ColAlignment(0) = flexAlignLeftTop
.OutlineCol = 0
.OutlineBar = flexOutlineBarSimpleLeaf
.MergeCells = flexMergeOutline
.ExtendLastCol = True
.AllowUserResizing = flexResizeColumns
.AllowSelection = False
.GridLines = flexGridFlatVert
strSQL = "select organ_no,organ_name from t_organ where organ_no='" & g_str4LoginUnit & "'"
If oRs4This.State = adStateOpen Then oRs4This.Close
oRs4This.CursorLocation = adUseClient
oRs4This.Open strSQL, g_oConnection4This, adOpenKeyset, adLockOptimistic
.AddItem oRs4This.Fields("organ_name").Value
.Row = .Rows - 1
.Cell(flexcpData, .Rows - 1, 0) = oRs4This.Fields("organ_no").Value
.IsSubtotal(.Row) = True
.RowOutlineLevel(.Row) = 0
Set tmpNode = .GetNode(.Row)
FillOrgan tmpNode, oRs4This.Fields("organ_no").Value, 4 - g_str4LoginUnitLevel + 1, VSFlexGrid4This, bIsAll
tmpNode.Expanded = False
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
MDIfrmMain.SSActiveToolBarsMain.Tools("ID_机构调整").Enabled = True
End Sub
Private Sub VSFlexGrid4Destinition_AfterRowColChange(ByVal OldRow As Long, ByVal OldCol As Long, ByVal NewRow As Long, ByVal NewCol As Long)
If NewRow = OldRow Then Exit Sub
If Me.Command4Close.Enabled = False Then Exit Sub
FillEmp VSFlexGrid4Destinition, NewRow, VSFlexGrid4EmpDestinition, False
End Sub
Private Sub VSFlexGrid4EmpDestinition_AfterDataRefresh()
With VSFlexGrid4EmpDestinition
.ColDataType(3) = flexDTDate
.ColFormat(3) = "yyyy-mm-dd"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "身份证号"
.TextMatrix(0, 3) = "出生日期"
.TextMatrix(0, 4) = "籍贯"
.AutoSize 0, 4
.ColWidth(0) = .RowHeight(0)
VSFlexGrid4EmpDestinition.ColHidden(5) = True
.ExtendLastCol = True
End With
End Sub
Private Sub VSFlexGrid4EmpSource_AfterDataRefresh()
Dim i As Long
With VSFlexGrid4EmpSource
.FixedCols = 0
.ColDataType(0) = flexDTBoolean
.ColDataType(3) = flexDTDate
.ColFormat(3) = "yyyy-mm-dd"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "身份证号"
.TextMatrix(0, 3) = "出生日期"
.TextMatrix(0, 4) = "籍贯"
For i = 1 To .Rows - 1
.TextMatrix(i, 0) = False
Next
.AutoSize 0, 4
.ColWidth(0) = .RowHeight(0)
VSFlexGrid4EmpSource.ColHidden(5) = True
.ExtendLastCol = True
End With
End Sub
Private Sub VSFlexGrid4EmpSource_Click()
With VSFlexGrid4EmpSource
If .Row = 0 Then Exit Sub
If .TextMatrix(.Row, 0) = "True" Then
.TextMatrix(.Row, 0) = False
Else
.TextMatrix(.Row, 0) = True
End If
End With
End Sub
Private Sub VSFlexGrid4Source_AfterRowColChange(ByVal OldRow As Long, ByVal OldCol As Long, ByVal NewRow As Long, ByVal NewCol As Long)
If NewRow = OldRow Then Exit Sub
If Me.Command4Close.Enabled = False Then Exit Sub
FillEmp VSFlexGrid4Source, NewRow, VSFlexGrid4EmpSource, True
End Sub
Private Sub FillEmp(ByVal VSFlexGrid4This As VSFlexGrid, ByVal Row As Long, ByVal VSFlexGrid4That As VSFlexGrid, ByVal bIsAll As Boolean)
Dim strSQL As String
Dim oRs4This As New ADODB.Recordset
MousePointer = 11
VSFlexGrid4That.FixedCols = 1
strSQL = "select emp_name,id_code," _
& " (cast(BIRTHDAY/10000 as varchar(4))+'年'+cast(BIRTHDAY%10000/100 as varchar(2))+'月'+cast(BIRTHDAY%100 as varchar(2))+'日') as BIRTHDAY," _
& " born_place,emp_no from t_emp_basic where organ_no='" & VSFlexGrid4This.Cell(flexcpData, Row) & "'"
If bIsAll = False Then
strSQL = strSQL & HaveEmpMark
Else
strSQL = strSQL & " and (DELETE_MARK=" & C_Emp_Have & " or DELETE_MARK=" & C_Emp_Delete_Have_Used_Unit & ")"
End If
If oRs4This.State = adStateOpen Then oRs4This.Close
oRs4This.CursorLocation = adUseClient
oRs4This.Open strSQL, g_oConnection4This, adOpenKeyset, adLockOptimistic
Set VSFlexGrid4That.DataSource = oRs4This
Set oRs4This = Nothing
MousePointer = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -