Public Class IC_MainMenu_V1001
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'
' Fixed future 2016-02-22 User control very slow to loaded on first open
'
If Not IsPostBack Then
Dim usrCtrlDyn As UserControl = Nothing
usrCtrlDyn = Page.LoadControl(mnuSelected.Item("_FixedSlow"))
usrCtrlDyn.ID = "_FixedSlow" 'New Random().Next(1, 10) & "_dyn_" & New Random().Next(1, 20)
myPH.Controls.Add(usrCtrlDyn)
End If
End Sub
Private mnuSelected As New Dictionary(Of String, String) From {{"IC_A1_01", "~/IC/usrCtrl_IC_A1_01_.ascx"},
{"IC_A1_02", "~/IC/usrCtrl_IC_A1_02.ascx"},
{"IC_A1_03", "~/IC/usrCtrl_IC_A1_03.ascx"},
{"IC_A1_04", "~/IC/usrCtrl_IC_A1_04.ascx"},
{"IC_A1_05", "~/IC/usrCtrl_IC_A1_05.ascx"},
{"IC_A2_01", "~/IC/usrCtrl_IC_A2_01_.ascx"},
{"IC_A2_02", "~/IC/usrCtrl_IC_A2_02.ascx"},
{"IC_A3_01", "~/IC/usrCtrl_IC_A3_01.ascx"},
{"IC_A3_02", "~/IC/usrCtrl_IC_A3_02.ascx"},
{"IC_A3_03", "~/IC/usrCtrl_IC_A3_03.ascx"},
{"IC_A4_01", "~/IC/usrCtrl_IC_A4_01.ascx"},
{"IC_A4_02", "~/IC/usrCtrl_IC_A4_02.ascx"},
{"IC_A4_03", "~/IC/usrCtrl_IC_A4_03.ascx"},
{"IC_A4_04", "~/IC/usrCtrl_IC_A4_04.ascx"},
{"IC_A5_01", "~/IC/usrCtrl_IC_A5_01.ascx"},
{"IC_A5_02", "~/IC/usrCtrl_IC_A5_02.ascx"},
{"IC_A6_01", "~/IC/usrCtrl_IC_A6_01.ascx"},
{"IC_A6_02", "~/IC/usrCtrl_IC_A6_02.ascx"},
{"IC_A6_03", "~/IC/usrCtrl_IC_A6_03.ascx"},
{"IC_B1_01", "~/IC/usrCtrl_IC_B1_01.ascx"},
{"IC_B2_01", "~/IC/usrCtrl_IC_B2_01.ascx"},
{"IC_B2_02", "~/IC/usrCtrl_IC_B2_02.ascx"},
{"IC_B3_01", "~/IC/usrCtrl_IC_B3_01.ascx"},
{"IC_B4_01", "~/IC/usrCtrl_IC_B4_01.ascx"},
{"IC_B4_02", "~/IC/usrCtrl_IC_B4_02.ascx"},
{"IC_B4_03", "~/IC/usrCtrl_IC_B4_03.ascx"},
{"IC_B4_04", "~/IC/usrCtrl_IC_B4_04.ascx"},
{"IC_C1_01", "~/IC/usrCtrl_IC_C1_01.ascx"},
{"IC_C1_02", "~/IC/usrCtrl_IC_C1_02.ascx"},
{"IC_C1_03", "~/IC/usrCtrl_IC_C1_03.ascx"},
{"_FixedSlow", "~/IC/_FixedSpeed.ascx"}
}
''' <summary>
''' Dynamic load user controls.
''' </summary>
''' <param name="s_key"></param>
''' <remarks></remarks>
Private Sub LoadUserControl(ByVal s_key As String)
Dim usrCtrlDyn As UserControl = Nothing
If myPH.Controls.Count > 0 Then
myPH.Controls.Clear()
End If
If "IC_A1_01, IC_A1_02, IC_A1_03, IC_A4_01, IC_A4_02, IC_A4_03".Contains(s_key) Then
If s_key.Contains("A1") Then 'รับ/จ่าย/ปรับปรุงสินค้าคงคลัง ***** การโอนย้ายยังไม่ได้ทำ (ย้ายประเภท-หมวดหมู่/โอนย้ายระหว่างคลัง/ข้ามฝาย-แผนก/etc...)
Page.Items.Add("IC_A1", {"RC", "IS", "AJ"}(CByte(s_key.Last().ToString()) - 1))
usrCtrlDyn = Page.LoadControl(mnuSelected.Item("IC_A1_01"))
Else ' รายงานตรวจสอบข้อมูล
Page.Items.Add("IC_A4", {"RC", "IS", "AJ"}(CByte(s_key.Last().ToString()) - 1))
usrCtrlDyn = Page.LoadControl(mnuSelected.Item("IC_A4_01"))
End If
Else 'อื่นฯ
usrCtrlDyn = Page.LoadControl(mnuSelected.Item(s_key))
End If
usrCtrlDyn.ID = "dyn" & s_key 'New Random().Next(1, 10) & "_dyn_" & New Random().Next(1, 20)
myPH.Controls.Add(usrCtrlDyn)
End Sub
End Class