1: Imports System
2: Imports System.ComponentModel
3: Imports System.Collections.Generic
4: Imports System.Diagnostics
5: Imports System.Text
6:
7: Imports DevExpress.ExpressApp
8: Imports DevExpress.ExpressApp.Actions
9: Imports DevExpress.Persistent.Base
10: Imports DevExpress.ExpressApp.Web.Editors.ASPx
11: Imports DevExpress.Web.ASPxEditors
12: Imports DevExpress.Persistent.BaseImpl
13: Imports DevExpress.Xpo
14: Imports DevExpress.Data.Filtering
15: Imports BillingSystem.Module.Devices
16:
17: Public Class PredefinedValuesController
18: Inherits DevExpress.ExpressApp.ViewController(Of DetailView)
19:
20: Public Sub New()
21: MyBase.New()
22:
23: 'This call is required by the Component Designer.
24: InitializeComponent()
25: RegisterActions(components)
26:
27: End Sub
28:
29:
30:
31: Protected Overrides Sub OnActivated()
32: MyBase.OnActivated()
33: ' to add for more values we
34: If TypeOf View.CurrentObject Is MobileDevice Then
35: SetPreDefinedValues("MobileDevice", "IMEI")
36:
37: End If
38:
39: End Sub
40:
41: Private Sub SetPreDefinedValues(ByVal tableName As String, ByVal columnName As String)
42: Dim editor As ASPxStringPropertyEditor = TryCast(View.FindItem(columnName), ASPxStringPropertyEditor)
43: If editor IsNot Nothing AndAlso View.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit Then
44: If editor.Control IsNot Nothing Then
45: Customize(editor.Editor, tableName, columnName)
46: Else
47: AddHandler editor.ControlCreated, Sub(s, e) Customize(editor.Editor, tableName, columnName)
48: End If
49: End If
50: End Sub
51:
52: Private Sub Customize(ByVal p As Object, ByVal tableName As String, ByVal columnName As String)
53: Dim control As ASPxComboBox = TryCast(p, ASPxComboBox)
54: If control IsNot Nothing Then
55: AddHandler control.Load, Sub(s, e)
56: control.Items.Clear()
57: For Each item As String In GetPredefinedValuesFromTableColumn(tableName, columnName)
58: control.Items.Add(item)
59: Next
60: End Sub
61: End If
62: End Sub
63: Private Function GetPredefinedValuesFromTableColumn(ByVal tableName As String, ByVal columnName As String) As List(Of String)
64: Dim paramsOperand As New List(Of OperandValue)
65: paramsOperand.AddRange(New OperandValue() {tableName, columnName})
66: Dim session As Session = CType(SecuritySystem.CurrentUser, User).Session
67: Dim res As DB.SelectedData = session.ExecuteSproc("GetPredefinedValues", paramsOperand.ToArray)
68: Dim result As New List(Of String)
69: For Each row As DB.SelectStatementResultRow In res.ResultSet(0).Rows
70: result.Add(row.Values(0).ToString())
71: Next
72: Return result
73:
74: End Function
75:
76:
77: End Class
No comments:
Post a Comment