Private Sub PopulateRootLevel()
treeClient.Nodes.Clear()
Dim stBuild As New StringBuilder()
stBuild.Append("select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client ")
stBuild.Append(" WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=0")
selectQry = stBuild.ToString()
'selectQry = "select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client " &
' " WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=0"
'Dim cmm As SqlCommand = New SqlCommand(selectQry)
'Dim result As Object
Dim dtTree = New DataTable
dtTree = DataConnect.GetInstance.GetDt(selectQry)
Dim dtTreeLang As New DataTable
'If hdnLang.Value.ToString() <> "en" Then
' dtTreeLang = lt.changeLanguage(dtTree, hdnLang.Value.ToString())
'Else
dtTreeLang = dtTree
'End If
PopulateNodes(dtTreeLang, treeClient.Nodes)
End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)
For Each dr As DataRow In dt.Rows
Dim tn As New TreeNode()
tn.Text = dr("client_name").ToString() ' + "<asp:ImageButton runat='server' ImageUrl='~/Images/plus.gif' onClick='clickPlus()'>"
tn.Value = dr("client_id").ToString()
If dr("o_or_p").ToString().Trim() = "p" Then
'If dr("active_yn").ToString().Trim() = "y" Then
Dim strb = New StringBuilder()
strb.Append("<u><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/>")
strb.Append(tn.Text)
strb.Append("</u><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/>")
strb.Append("<img src='Images/1x1.gif'/><img src='Images/1x1.gif'/><img src='Images/BlueStar.png'/>")
tn.Text = strb.ToString()
'tn.Text = "<u><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/>" &
' tn.Text &
' "</u><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/>" &
' "<img src='Images/1x1.gif'/><img src='Images/1x1.gif'/><img src='Images/BlueStar.png'/>"
'Else
' tn.Text = "<u><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/><img src='Images/1x1.gif'/>" +
' tn.Text +
' "</u>"
'End If
Else
Dim style As String
style = "<style type='text/css'>" +
".onClass{color:Black;}" +
".onClass:hover{color:Blue;text-decoration:underline;}" +
"</style>"
tn.Text = style + "<span class='onClass'>" + tn.Text + "</span>"
End If
tn.Target = dr("client_name").ToString()
nodes.Add(tn)
'If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
Next
End Sub
Private Sub PopulateSubLevel(ByVal parentid As Integer, ByVal parentNode As TreeNode)
If rdbActive.Checked = True Then
Dim stBuild As New StringBuilder()
stBuild.Append("select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client ")
stBuild.Append(" WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=@parentID and active_yn='y'")
selectQry = stBuild.ToString()
'selectQry = "select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client " &
' " WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=@parentID and active_yn='y'"
ElseIf rdbAll.Checked = True Then
Dim stBuild As New StringBuilder()
stBuild.Append("select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client ")
stBuild.Append(" WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=@parentID")
selectQry = stBuild.ToString()
'selectQry = "select CLIENT_ID,CLIENT_NAME,o_or_p,active_yn,(select count(*) FROM client " &
' " WHERE reports_to_id=sc.CLIENT_ID) childnodecount FROM client sc where reports_to_id=@parentID"
End If
Dim objCommand = New SqlCommand(selectQry)
objCommand.Parameters.Add("@parentID", SqlDbType.Int).Value = parentid
Dim dt = New DataTable
dt = DataConnect.GetInstance.GetDt(objCommand)
Dim dtChild As New DataTable
'If hdnLang.Value.ToString() <> "en" Then
' dtChild = lt.changeLanguage(dt, hdnLang.Value.ToString())
'Else
dtChild = dt
'End If
PopulateNodes(dtChild, parentNode.ChildNodes)
End Sub
Private Sub treeClient_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeClient.SelectedNodeChanged
Try
'btnNewNodeCancel_Click(sender, e)
'ViewState("nodetext") = treeClient.SelectedNode.Text
pnlGlobalMessage1.Visible = False
lblGlobalMessage1.Visible = False
btnAddClient.Text = "Add New Client/Program"
btnOk.Enabled = True
btnCancel.Enabled = True
treeClient.SelectedNodeStyle.BackColor = Drawing.Color.Wheat
selectQry = "select * from client where client_id='" & treeClient.SelectedNode.Value & "'"
dtTable = DataConnect.GetInstance.GetDt(selectQry)
Dim dtLang As New DataTable
'If hdnLang.Value.ToString() <> "en" Then
' dtLang = lt.changeLanguage(dtTable, hdnLang.Value.ToString())
'Else
dtLang = dtTable
'End If
ViewState("clientdetails") = dtLang
For Each dr As DataRow In dtLang.Rows
treelocations.Nodes.Clear()
labelClientID.Text = dr("client_id").ToString()
'PopulateLocRootLevelid(Int32.Parse(labelClientID.Text))
lblO_or_P.Text = dr("o_or_p").ToString()
lblreports_to_id.Text = dr("reports_to_id").ToString()
lblCreationDate.Text = dr("creation_dt").ToString()
lblcreationid.Text = dr("creation_id").ToString()
Dim p As String = "p"
Dim o As String = "o"
'If hdnLang.Value.ToString() <> "en" Then
' p = lt.LangTranslate("p", hdnLang.Value)
' o = lt.LangTranslate("o", hdnLang.Value)
'End If
If dr("o_or_p").ToString().Trim() = p Then
pnlAddOrg.Enabled = False
pnlNewRootClient.Enabled = False
TabContainer1.Tabs(1).Enabled = True
Session("clientid") = labelClientID.Text
Dim reg As New Regex("<[^<>]+>")
'txtProgNm.Text = treeClient.SelectedNode.Text.Replace("", "")
txtProgNm.Text = reg.Replace(treeClient.SelectedNode.Text, "")
If treeClient.SelectedNode.Parent Is Nothing Then
lblpanelTitle.Text = txtProgNm.Text
Else
lblpanelTitle.Text = treeClient.SelectedNode.Parent.Target.ToString() + " / " + txtProgNm.Text
End If
lblLocAddStatus.Visible = False
lblpanelTitle.Font.Bold = True
lblSurgereid.Text = dr("surgere_id").ToString()
txtNotes.Text = dr("notes").ToString()
TabContainer1.ActiveTab = TabContainer1.Tabs(1)
If treeClient.SelectedNode.Parent Is Nothing Then
labelclientPath.Text = txtProgNm.Text
'lblFacLocTitle.Text = labelclientPath.Text
Else
labelclientPath.Text = treeClient.SelectedNode.Parent.Target.ToString() + " : " + txtProgNm.Text
'lblFacLocTitle.Text = labelclientPath.Text
End If
labelclientPath.Visible = True
msgpanel2.Visible = False
'chkAddClient.Enabled = False
btnAddClient.Enabled = False
If dr("active_yn").ToString().Trim() = "n" Then
btndisablepgm.Text = "Enable"
Else
btndisablepgm.Text = "Disable"
End If
'treeClient.SelectedNode.Selected = False
txtSurgereID.Text = ""
txtNodeNotes.Text = ""
txtNodeNm.Text = ""
TabContainer3.Tabs(1).Enabled = False
treelocations.DataSource = Nothing
treelocations.DataBind()
PopulateLocRootLevelid(Session("clientid"))
treelocations.ExpandAll()
ContactControls.UnLoadContactDetails()
ContactControls.LoadContactDetails()
Packaging1.UnloadControls()
Packaging1.getcontainerList()
POs1.unloadControl()
POs1.controlLoaded()
SupplierDetails.UnloadSuppliers()
SupplierDetails.LoadSupplier("")
Production1.controlUnloaded()
Production1.controlLoaded()
usrDunnage1.controlUnloaded()
usrDunnage1.controlLoaded()
customerControl1.conltrolLoaded()
' PopulateLocRootLevelid(treeClient.SelectedNode.Value)
'Packaging1.UnloadControls()
'POs1.unloadControl()
'Production1.controlUnloaded()
'SupplierDetails.LoadSupplier()
'ContactControls.LoadContactDetails()
'Production1.controlLoaded()
'usrDunnage1.controlUnloaded()
'usrDunnage1.controlLoaded()
' Packaging1.getcontainerList()
' POs1.grdPoFill()
treeClient.SelectedNode.Selected = False
TabContainer2.ActiveTab = TabContainer2.Tabs(0)
Else
'Dim reg As New Regex("<[^<>]+>")
'Dim reReg As New Regex("<[^<>]+<")
'txtNodeNm.Text = reReg.Replace(treeClient.SelectedNode.Text, "")
'txtNodeNm.Text = reg.Replace(txtNodeNm.Text, "")
txtNodeNm.Text = treeClient.SelectedNode.Target.ToString()
If treeClient.SelectedNode.Parent Is Nothing Then
lblpanelTitle.Text = txtNodeNm.Text
Else
lblpanelTitle.Text = treeClient.SelectedNode.Parent.Target.ToString() + " / " + txtNodeNm.Text
End If
'lblpanelTitle.Text = treeClient.SelectedNode.Target.ToString()
lblpanelTitle.Font.Bold = True
txtSurgereID.Text = dr("surgere_id").ToString()
txtNodeNotes.Text = dr("notes").ToString()
txtSurgereID.Enabled = True
btnDel.Text = "Delete"
btnDel.Enabled = True
btnAddClient.Enabled = True
'chkAddClient.Visible = True
pnlAddOrg.Visible = True
'chkAddClient.Enabled = True
If treeClient.SelectedNode.ChildNodes.Count <> 0 Then
btnDel.Enabled = False
End If
pnlAddOrg.Enabled = True
pnlNewRootClient.Enabled = True
Session.Remove("clientid")
TabContainer1.Tabs(1).Enabled = False
Dim dtclient As New DataTable
dtclient = DataConnect.GetInstance.GetDt("select * from checkclientid('" & treeClient.SelectedNode.Value & "')")
If dtclient.Rows.Count <> 0 Then
btnDel.Enabled = False
Else
btnDel.Enabled = True
End If
End If
Next
'
' TODO --Security
'________________________________________________________________________________________________________________________
''User security-Bigin
''________________________________________________________________________________________________________________________
'Dim dtUser As DataTable = Session("user_session")
'Dim user_security As String = dtUser.Rows(0)("user_security").ToString()
'If user_security = "Basic User" Or user_security = "SPARCS" Then
' btnDel.Enabled = False
' btnAddClient.Enabled = False
' btnOk.Enabled = False
' btnupdatepgm.Enabled = False
' btndisablepgm.Enabled = False
' btnNewLocation.Enabled = False
' btnUpdate.Enabled = False
' cmdSave.Enabled = False
' cmdDel.Enabled = False
'End If
''________________________________________________________________________________________________________________________
''User security-End
''________________________________________________________________________________________________________________________
optOrg1.Enabled = False
optOrg2.Enabled = False
'chkAddClient.Checked = False
Catch ex As Exception
pnlGlobalMessage.Visible = True
lblGlobalMessage.Text = "A technical issue has occurred. A message has been sent to the development team. Sorry for the inconvenience."
If hdnLang.Value.ToString() <> "en" Then
lblGlobalMessage.Text = lt.LangTranslate(lblGlobalMessage.Text, hdnLang.Value)
End If
lblGlobalMessage.Visible = True
dt = Session("user_session")
Worker.HandleError(ex, "Client/ProgramList", Int64.Parse(dt.Rows(0)("user_id")), Request.Browser.Browser.ToString())
End Try
End Sub
Private Sub treeClient_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles treeClient.TreeNodePopulate
PopulateSubLevel(CInt(e.Node.Value), e.Node)
End Sub
No comments:
Post a Comment