📄 frmorganedit.frm
字号:
Option4SmallBand.Enabled = True
Option4Inc.Value = True
ElseIf .Cell(flexcpData, .GetNodeRow(.Row, flexNTParent)) = C_COMPANY_LEVEL Then
Option4Bureau.Enabled = False
Option4Factory.Enabled = False
Option4Inc.Enabled = False
Option4BigBand.Enabled = True
Option4SmallBand.Enabled = True
Option4BigBand.Value = True
ElseIf .Cell(flexcpData, .GetNodeRow(.Row, flexNTParent)) = C_LARGE_LEVEL Then
Option4Bureau.Enabled = False
Option4Factory.Enabled = False
Option4Inc.Enabled = False
Option4BigBand.Enabled = False
Option4SmallBand.Enabled = True
Option4SmallBand.Value = True
End If
End With
InitText
End Sub
Private Function GetOrganAddDelete(ByVal No As String) As String
'Dim m_ors4temp As New ADODB.Recordset
m_strSQL = "select organ_no from t_organ where organ_no='" & No & "'"
If m_oRs4Temp.State = adStateOpen Then m_oRs4Temp.Close
m_oRs4Temp.CursorLocation = adUseClient
m_oRs4Temp.Open m_strSQL, g_oConnection4This, adOpenKeyset, adLockPessimistic
If m_oRs4Temp.EOF = True Then
m_strTemp = No
Exit Function
Else
GetOrganAddDelete left(m_oRs4Temp.Fields(0).Value, Len(m_oRs4Temp.Fields(0).Value) - 3) & String(3 - Len(CDec(right(m_oRs4Temp.Fields(0).Value, 3)) + 1), "0") & CDec(right(m_oRs4Temp.Fields(0).Value, 3)) + 1
End If
End Function
Private Sub Command4Delete_Click()
Dim nd As VSFlexNode
Dim lTemp As Long
With Me.VSFlexGrid4Organ
If .Row > -1 Then
If vbYes = MsgBox("确认删除该记录吗?", vbYesNo + vbDefaultButton2, "警告") Then
Set nd = .GetNode(.Row)
If nd.Children = 0 Then
If Me.Text4OrganCode.Tag = C_Update Then
m_strSQL = "select * from t_emp_basic where organ_no='" & nd.Key & "'" & HaveEmpMark
If m_oRs4Temp.State = adStateOpen Then m_oRs4Temp.Close
m_oRs4Temp.CursorLocation = adUseClient
m_oRs4Temp.Open m_strSQL, g_oConnection4This, adOpenKeyset, adLockPessimistic
If m_oRs4Temp.EOF = False Then
MsgBox "请先删除此机构下的人员", vbOKOnly, "警告"
Exit Sub
Else
m_strSQL = "select * from t_emp_basic where organ_no='" & nd.Key & "'"
If m_oRs4Temp.State = adStateOpen Then m_oRs4Temp.Close
m_oRs4Temp.CursorLocation = adUseClient
m_oRs4Temp.Open m_strSQL, g_oConnection4This, adOpenKeyset, adLockPessimistic
If m_oRs4Temp.EOF = False Then
m_strSQL = "update t_organ set organ_delete_mark=" & C_Organ_Delete_NoUsed & " where organ_no='" & nd.Key & "'"
Else
m_strSQL = "delete from t_organ where organ_no='" & nd.Key & "'"
End If
If ExcuteSQL(m_strSQL) <> 0 Then Exit Sub
End If
End If
nd.RemoveNode
If .Row = -1 Then .Row = .Rows - 1
lTemp = .Row
.Row = -1
.Row = lTemp
Else
MsgBox "请先删除此纪录的子纪录后,再删除此记录!", vbOKOnly, "警告"
Exit Sub
End If
End If
Else
MsgBox "请选择需删除的纪录", vbOKOnly, "警告"
Exit Sub
End If
End With
End Sub
Private Sub Command4Close_Click()
Unload Me
End Sub
Private Sub Command4Save_Click()
Dim nd As VSFlexNode
Dim lTemp As Long
If Trim(Text4OrganName.text) = "" Then
MsgBox "请输入单位名称!", vbOKOnly, "警告"
Exit Sub
End If
If Me.Option4BigBand.Value = False And Me.Option4Factory.Value = False And Me.Option4Bureau.Value = False And Me.Option4Inc.Value = False And Me.Option4SmallBand.Value = False Then
MsgBox "请选择单位级别!", vbOKOnly, "警告"
Exit Sub
End If
If Len(g_str4LoginUnit) = C_BUREAUE_LENGTH Then
g_i4ExcuteSql = 1
Else
g_i4ExcuteSql = 2
End If
If Me.Text4OrganCode.Tag = C_Insert Then
m_strSQL = "insert into t_organ( organ_no,organ_name,organ_telephone,ENTERPRISE_PROPERTY_NO,organ_level,organ_description)" _
& " values ('" & Trim(Text4OrganCode.text) & "','" & Trim(Text4OrganName.text) & "','" & Trim(Text4OrganTelephone.text) & "',"
If Trim(Combo4OrganProperty.text) = "" Then
m_strSQL = m_strSQL & "null,"
Else
m_strSQL = m_strSQL & Combo4OrganProperty.ItemData(Combo4OrganProperty.ListIndex) & ","
End If
If Me.Option4Bureau.Value = True Then
m_strSQL = m_strSQL & C_BUREAUE_LEVEL
ElseIf Me.Option4Factory.Value = True Then
m_strSQL = m_strSQL & C_FACTORY_LEVEL
ElseIf Me.Option4Inc.Value = True Then
m_strSQL = m_strSQL & C_COMPANY_LEVEL
ElseIf Me.Option4BigBand.Value = True Then
m_strSQL = m_strSQL & C_LARGE_LEVEL
ElseIf Me.Option4SmallBand.Value = True Then
m_strSQL = m_strSQL & C_SMALL_LEVEL
Else
m_strSQL = m_strSQL & "null"
End If
m_strSQL = m_strSQL & "," & CSQL(Me.Text4OrganNote.text) & ")"
ExcuteSQL m_strSQL
Set nd = Me.VSFlexGrid4Organ.GetNode(Me.VSFlexGrid4Organ.Row)
nd.Key = Text4OrganCode.text
Me.Text4OrganCode.Tag = C_Update
If Len(g_str4LoginUnit) = C_BUREAUE_LENGTH Then
If Len(nd.Key) = 3 Then
Me.Command4AddSame.Enabled = False
Me.Command4AddUnder.Enabled = True
Me.Command4Delete.Enabled = True
Else
Me.Command4AddSame.Enabled = True
Me.Command4AddUnder.Enabled = False
Me.Command4Delete.Enabled = True
End If
Else
If Len(nd.Key) = 6 Then
Me.Command4AddSame.Enabled = False
Me.Command4AddUnder.Enabled = True
Me.Command4Delete.Enabled = True
Else
Me.Command4AddSame.Enabled = True
Me.Command4AddUnder.Enabled = True
Me.Command4Delete.Enabled = True
End If
End If
MsgBox "保存完毕!", vbOKOnly, "成功"
If Me.Option4Bureau.Value = True Then
m_strSQL = C_BUREAUE_LEVEL
ElseIf Me.Option4Factory.Value = True Then
m_strSQL = C_FACTORY_LEVEL
ElseIf Me.Option4Inc.Value = True Then
m_strSQL = C_COMPANY_LEVEL
ElseIf Me.Option4BigBand.Value = True Then
m_strSQL = C_LARGE_LEVEL
ElseIf Me.Option4SmallBand.Value = True Then
m_strSQL = C_SMALL_LEVEL
End If
VSFlexGrid4Organ.Cell(flexcpData, VSFlexGrid4Organ.Row) = m_strSQL
VSFlexGrid4Organ.ShowCell VSFlexGrid4Organ.FindRow(Text4OrganName.text, , 0, , False), 0
If Len(Text4OrganCode.text) < 15 Then
Command4AddUnder.Enabled = True
Else
Command4AddUnder.Enabled = False
End If
Else
m_strSQL = "update t_organ SET organ_name='" & Trim(Text4OrganName.text) & "', organ_telephone=" & CSQL(Me.Text4OrganTelephone) & ","
If Trim(Combo4OrganProperty.text) = "" Then
m_strSQL = m_strSQL & " ENTERPRISE_PROPERTY_NO=null,"
Else
m_strSQL = m_strSQL & " ENTERPRISE_PROPERTY_NO=" & Combo4OrganProperty.ItemData(Combo4OrganProperty.ListIndex) & ","
End If
m_strSQL = m_strSQL & " organ_level="
If Me.Option4Bureau.Value = True Then
m_strSQL = m_strSQL & C_BUREAUE_LEVEL
ElseIf Me.Option4Factory.Value = True Then
m_strSQL = m_strSQL & C_FACTORY_LEVEL
ElseIf Me.Option4Inc.Value = True Then
m_strSQL = m_strSQL & C_COMPANY_LEVEL
ElseIf Me.Option4BigBand.Value = True Then
m_strSQL = m_strSQL & C_LARGE_LEVEL
ElseIf Me.Option4SmallBand.Value = True Then
m_strSQL = m_strSQL & C_SMALL_LEVEL
Else
m_strSQL = m_strSQL & "null"
End If
m_strSQL = m_strSQL & " ,organ_description=" & CSQL(Text4OrganNote.text) & " where organ_no='" & Trim(Text4OrganCode.text) & "'"
ExcuteSQL m_strSQL
Me.Text4OrganCode.Tag = C_Update
Set nd = Me.VSFlexGrid4Organ.GetNode(Me.VSFlexGrid4Organ.Row)
MsgBox "保存完毕!", vbOKOnly, "成功"
End If
bIsChange = True
Set nd = Me.VSFlexGrid4Organ.GetNode(Me.VSFlexGrid4Organ.Row)
If VSFlexGrid4Organ.Cell(flexcpData, VSFlexGrid4Organ.Row) = 0 Then
Command4AddUnder.Enabled = False
Else
Command4AddUnder.Enabled = True
End If
If VSFlexGrid4Organ.Cell(flexcpData, VSFlexGrid4Organ.Row) = 0 Then
Option4Bureau.Enabled = False
Option4Factory.Enabled = False
Option4Inc.Enabled = False
Option4BigBand.Enabled = False
Option4SmallBand.Enabled = True
End If
End Sub
Private Sub Form_Load()
Dim tmpNode As VSFlexNode
Dim nd As VSFlexNode
bIsChange = False
m_str4OptionName(0) = "(小队级)"
m_str4OptionName(1) = "(大队级)"
m_str4OptionName(2) = "(公司级)"
m_str4OptionName(3) = "(厂处级)"
m_str4OptionName(4) = "(局级)"
Me.Text4OrganCode.Locked = True
Me.Command4Close.Enabled = False
Me.Width = 9540
Me.Height = 5460
With Me.VSFlexGrid4Organ
.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
m_strSQL = "select * from t_organ where len(organ_no)=" & C_BUREAUE_LENGTH
If m_oRs4Temp.State = adStateOpen Then m_oRs4Temp.Close
m_oRs4Temp.CursorLocation = adUseClient
m_oRs4Temp.Open m_strSQL, g_oConnection4This
If m_oRs4Temp.EOF = False Then
If Not IsNull(m_oRs4Temp.Fields("organ_level").Value) Then
.AddItem m_oRs4Temp.Fields("organ_name").Value & m_str4OptionName(m_oRs4Temp.Fields("organ_level").Value)
.Cell(flexcpData, .Rows - 1) = m_oRs4Temp.Fields("organ_level").Value
Else
.AddItem m_oRs4Temp.Fields("organ_name").Value
.Cell(flexcpData, .Rows - 1) = m_oRs4Temp.Fields("organ_level").Value
End If
.Row = .Rows - 1
.IsSubtotal(.Row) = True
.RowOutlineLevel(.Row) = 0
Set tmpNode = .GetNode(.Row)
tmpNode.Key = m_oRs4Temp.Fields("organ_no").Value
FillTree tmpNode, tmpNode.Key, 1
tmpNode.Expanded = False
End If
End With
Label4OrganName.ForeColor = g_ForeColor4NotNullFields
Me.vsElastic4This.ForeColor = g_ForeColor4NotNullFields
FillComboBox Combo4OrganProperty, "T_ENTERPRISE_PROPERTY", "ENTERPRISE_PROPERTY_NO", "ENTERPRISE_PROPERTY_NAME", 0
If Len(g_str4LoginUnit) <> C_BUREAUE_LENGTH Then
Me.Command4AddUnder.Enabled = False
Me.Command4Delete.Enabled = False
Me.Command4Save.Enabled = False
End If
Me.Command4AddSame.Enabled = False
Me.Command4Close.Enabled = True
If Me.VSFlexGrid4Organ.Rows > 0 And g_str4LoginUnitLevel <> 4 Then
Call VSFlexGrid4organ_AfterRowColChange(-1, 0, 0, 0)
Else
Call VSFlexGrid4organ_AfterRowColChange(-1, 0, 0, 0)
End If
Unload frmSplash
End Sub
Private Function FillTree(paraNode As VSFlexNode, ByVal StartData As String, ByVal iLevel As Long) As Boolean
Dim TmpBoolean As Boolean
Dim tmpNode As VSFlexNode
Dim TmpRst As New ADODB.Recordset
If iLevel > 4 Then Exit Function
Select Case Len(g_str4LoginUnit)
Case C_BUREAUE_LENGTH
m_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 & HaveOrganMark
Case C_FACTORY_LENGTH
If Len(StartData) = C_FACTORY_LENGTH Then
m_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 & HaveOrganMark
Else
m_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 & HaveOrganMark & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_COMPANY_LENGTH
If Len(StartData) = C_COMPANY_LENGTH Then
m_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 & HaveOrganMark
Else
m_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 & HaveOrganMark & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_LARGE_LENGTH
If Len(StartData) = C_LARGE_LENGTH Then
m_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 & HaveOrganMark
Else
m_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 & HaveOrganMark & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
Case C_SMALL_LENGTH
If Len(StartData) = C_SMALL_LENGTH Then
m_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 & HaveOrganMark
Else
m_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 & HaveOrganMark & " and organ_no like '" & left(g_str4LoginUnit, Len(StartData) + 3) & "%'"
End If
End Select
TmpRst.CursorType = adOpenKeyset
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -