Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Function LoadTree() As Boolean
- 'On Error GoTo HELL
- Dim Rec As New ADODB.Recordset
- Dim str As String
- Dim i As Integer
- Dim TypeBefore, GroupBefore As String
- str = "select Distinct Type_name from v_materials WHERE Type_Code = 'MT001' or Type_Code = 'MT002' ORDER BY Type_Name" 'cari root
- Set Rec = oConn.ExecuteSQL(str, True)
- With fgStructures
- .Cols = 23: .Rows = 1
- .OutlineCol = 4
- .GridLines = 8
- For i = 0 To 3
- .ColHidden(i) = True
- Next i
- For i = 13 To .Cols - 1
- .ColHidden(i) = True
- Next i
- ' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- .FormatString = "Code|Mat Code|Mat Name|Description| |Usage|Unit|Conv Usage|Conv Unit|Create|Revision No|Ref Number|Draw Number|main Mat|PARENT|FLAG|LEVEL|ID|p_code|MType|MGroup|TypeCode|GroupCode"
- .Cell(flexcpFontBold, 0, 0, 0, .Cols - 1) = True
- While Not Rec.EOF
- str = "" & vbTab & "" & vbTab & "" & vbTab & "" & vbTab & Rec.Fields(0)
- .AddItem str
- .IsSubtotal(.Rows - 1) = True
- .RowOutlineLevel(.Rows - 1) = 1 'Rec!bom_level ' + 1
- .Cell(flexcpFontBold, .Rows - 1, 0, , .Cols - 1) = True
- .Cell(flexcpPicture, .Rows - 1, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- .Cell(flexcpBackColor, .Rows - 1, 0, .Rows - 1, .Cols - 1) = LblTypeColor.BackColor
- .GetNode(.Rows - 1).Key = Rec.Fields(0)
- ' add hidden node (we'll handle this when the user expands it)
- .AddItem ""
- .IsSubtotal(.Rows - 1) = True
- .RowOutlineLevel(.Rows - 1) = .RowOutlineLevel(.Rows - 2) + 1
- Rec.MoveNext
- Wend
- For i = 4 To 12
- .AutoSize i
- Next
- For i = 1 To .Rows - 1
- .IsCollapsed(i) = flexOutlineCollapsed
- Next
- End With
- LoadTree = True
- Set Rec = Nothing
- HELL:
- If Err.Number <> 0 Then
- LoadTree = False
- Set Rec = Nothing
- Call LogActivities(Now(), "", Err.Number, Err.Source, Err.Description, "LoadTree() As Boolean", App.Major & "." & App.Minor & "." & App.Revision, "", vTypeError)
- MsgBox Err.Description, vbCritical, "LoadTreeMenu @ " & App.Title & "." & Me.Caption
- End If
- End Function
- Private Sub ExpandRow(ByVal R&)
- Dim str As String
- Dim sql As String
- Dim encrypt As String
- Dim qty As String
- Dim Rs As New ADODB.Recordset
- With fgStructures
- ' make it fast
- .Redraw = flexRDNone
- MousePointer = 11
- ' get information for new items
- Dim RsTmp As New ADODB.Recordset
- Dim i&, iPos&, iLvl&
- Dim StrNodeCode As String
- iPos = R + 1
- iLvl = .RowOutlineLevel(R) + 1
- 'cari kode node bom, item yang diselect
- If iLvl = 2 Then
- StrNodeCode = fgStructures.TextMatrix(R, 4)
- str = "SELECT DISTINCT Group_Name from v_materials " & _
- "WHERE Type_name = '" & StrNodeCode & "' " & _
- "Order By Group_Name" 'cari root
- Set RsTmp = oConn.ExecuteSQL(str, True)
- While Not RsTmp.EOF
- str = "" & vbTab & "" & vbTab & "" & vbTab & StrNodeCode & vbTab & RsTmp.Fields(0)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblGroupColor.BackColor
- .GetNode(iPos).Key = StrNodeCode & "|" & RsTmp.Fields(0)
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- RsTmp.MoveNext
- iPos = iPos + 1
- Wend
- ElseIf iLvl = 3 Then
- 'cari Root
- StrNodeCode = .GetNode(R).Key
- str = "SELECT * from v_bill_of_materials " & _
- "WHERE parent_code = '0' and priority = 0 and " & _
- "MatType+'|'+Matgroup = '" & StrNodeCode & "' "
- Set RsTmp = oConn.ExecuteSQL(str, True)
- While Not RsTmp.EOF
- encrypt = IsValue(RsTmp!encript)
- If encrypt = "" Then encrypt = False
- If encrypt = True Then
- GroupName = oConn.LookUpTable("t_usermenu", "group_name", "user_name = '" & pubVar_UserName & "'")
- If oConn.LookUpTable("t_param", "ID", "param_name = 'decript' and param_value = '" & GroupName & "'") <> "" Then
- sql = "select dbo.Fn_LoadCript('" & IsValue(RsTmp!qty_usage) & "') as val"
- Set Rs = oConn.ExecuteSQL(sql, True)
- qty = IsValue(Rs("Val"))
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(qty, "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblParentColor.BackColor
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- RsTmp.MoveNext
- iPos = iPos + 1
- Else
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(IsValue(RsTmp!qty_usage), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblParentColor.BackColor
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- RsTmp.MoveNext
- iPos = iPos + 1
- End If
- '--- decript
- Else
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(IsValue(RsTmp!qty_usage), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblParentColor.BackColor
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- RsTmp.MoveNext
- iPos = iPos + 1
- End If
- Wend
- Else
- StrNodeCode = oConn.LookUpTable("v_bill_of_materials", "code", _
- "mat_code='" & fgStructures.TextMatrix(R, 1) & "' " & _
- " and parent_code = '0' and priority = 0 ")
- End If
- str = "select * from v_bill_of_materials " & _
- "WHERE parent_Code = '" & StrNodeCode & "' and priority = 0 " & _
- "ORDER BY Parent_Code, mat_code"
- Set RsTmp = oConn.ExecuteSQL(str, True)
- While Not RsTmp.EOF
- encrypt = IsValue(RsTmp!encript)
- If encrypt = "" Then encrypt = False
- If encrypt = True Then
- GroupName = oConn.LookUpTable("t_usermenu", "group_name", "user_name = '" & pubVar_UserName & "'")
- If oConn.LookUpTable("t_param", "ID", "param_name = 'decript' and param_value = '" & GroupName & "'") <> "" Then
- sql = "select dbo.Fn_LoadCript('" & IsValue(RsTmp!qty_usage) & "') as val"
- Set Rs = oConn.ExecuteSQL(sql, True)
- qty = IsValue(Rs("Val"))
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(qty, "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblChildColor.BackColor
- If RsTmp.Fields("Parent_flag") Then
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- If RsTmp!parent_code = "0" Then
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- Else
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(2).ExtractIcon
- End If
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- Else
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = False
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(4).ExtractIcon
- .GetNode(iPos).Key = "C" & RsTmp!ID
- End If
- iPos = iPos + 1
- RsTmp.MoveNext
- Else
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(IsValue(RsTmp!qty_usage), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblChildColor.BackColor
- If RsTmp.Fields("Parent_flag") Then
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- If RsTmp!parent_code = "0" Then
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- Else
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(2).ExtractIcon
- End If
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- Else
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = False
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(4).ExtractIcon
- .GetNode(iPos).Key = "C" & RsTmp!ID
- End If
- iPos = iPos + 1
- RsTmp.MoveNext
- End If
- Else
- str = RsTmp!code & vbTab & IsValue(RsTmp!mat_code) & vbTab & _
- IsValue(RsTmp!mat_name) & vbTab & _
- IsValue(RsTmp!mat_desc) & vbTab & _
- IsValue(RsTmp!mat_code) & " - " & IsValue(RsTmp!mat_name) & " - " & _
- IsValue(RsTmp!brand) & " - " & IsValue(RsTmp!Model) & " - " & _
- IsValue(RsTmp!mat_desc) & " - " & IsValue(RsTmp!mat_color) & vbTab & _
- Format(IsValue(RsTmp!qty_usage), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_usage_name) & vbTab & _
- Format(IsValue(RsTmp!qty_conv), "###,###,##0.############") & vbTab & _
- IsValue(RsTmp!uom_conv_name) & vbTab & _
- Format(IsValue(RsTmp!define_date), "dd-mmm-yyyy") & vbTab & _
- IsValue(RsTmp!Revision_no) & vbTab
- str = str & _
- IsValue(RsTmp!ref_no) & vbTab & _
- IsValue(RsTmp!draw_no) & vbTab & _
- IsValue(RsTmp!mat_main_code) & vbTab & _
- IsValue(RsTmp!parent_code) & vbTab & _
- IsValue(RsTmp!parent_flag) & vbTab & _
- IsValue(RsTmp!bom_level) & vbTab & _
- IsValue(RsTmp!ID) & vbTab & _
- IsValue(RsTmp!p_code) & vbTab & _
- IsValue(RsTmp!MatType) & vbTab & _
- IsValue(RsTmp!MatGroup) & vbTab & _
- IsValue(RsTmp!Type_Code) & vbTab & _
- IsValue(RsTmp!Group_Code) & vbTab & _
- IsValue(RsTmp!p_code)
- .AddItem str, iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl
- .Cell(flexcpBackColor, iPos, 0, iPos, .Cols - 1) = LblChildColor.BackColor
- If RsTmp.Fields("Parent_flag") Then
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = True
- If RsTmp!parent_code = "0" Then
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(1).ExtractIcon
- Else
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(2).ExtractIcon
- End If
- .GetNode(iPos).Key = "P" & RsTmp!ID
- ' add hidden node (we'll handle this when the user expands it)
- iPos = iPos + 1
- .AddItem "", iPos
- .IsSubtotal(iPos) = True
- .RowOutlineLevel(iPos) = iLvl + 1
- Else
- .Cell(flexcpFontBold, iPos, 0, , .Cols - 1) = False
- .Cell(flexcpPicture, iPos, .OutlineCol) = imgListTree.ListImages.Item(4).ExtractIcon
- .GetNode(iPos).Key = "C" & RsTmp!ID
- End If
- iPos = iPos + 1
- RsTmp.MoveNext
- End If
- Wend
- End If
- 'fgStructures.Tag = str
- RsTmp.Close
- Set RsTmp = Nothing
- ' collapse the items we just added
- For i = R + 1 To iPos - 1
- If .IsSubtotal(i) Then .IsCollapsed(i) = flexOutlineCollapsed
- Next
- For i = 4 To 12
- .AutoSize i
- Next
- If .ColWidth(4) < LblTypeColor.Width Then .ColWidth(4) = LblTypeColor.Width
- ' ready to redraw
- MousePointer = 0
- .Redraw = flexRDBuffered
- .Row = R
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement