<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AdvControls" Namespace="AdvControls" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無題のページ</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="grd" runat="server" CellPadding="3" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px">
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="checkBox" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ShiyouID" HeaderText="ShiyouID" SortExpression="ShiyouID" />
<asp:BoundField DataField="GroupID" HeaderText="GroupID" SortExpression="GroupID" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node1">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:BoundField DataField="StrNull1" HeaderText="StrNull1" SortExpression="StrNull1" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node2">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:BoundField DataField="StrNull2" HeaderText="StrNull2" SortExpression="StrNull2" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node3">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:HyperLinkField DataTextField="StrNull3" HeaderText="StrNull3" NavigateUrl="~/PE003008.aspx"
SortExpression="StrNull3" Target="_blank" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node4">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:BoundField DataField="StrNull4" HeaderText="StrNull4" SortExpression="StrNull4" />
<asp:BoundField DataField="StrNull41" HeaderText="StrNull41" SortExpression="StrNull41" />
<asp:BoundField DataField="StrNull42" HeaderText="StrNull42" SortExpression="StrNull42" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node5">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:BoundField DataField="StrNull5" HeaderText="StrNull5" SortExpression="StrNull5" />
<asp:ButtonField ButtonType="Button" Text="+" CommandName="node6">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:ButtonField>
<asp:BoundField DataField="StrNull6" HeaderText="StrNull6" SortExpression="StrNull6" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetGrdData"
TypeName="DBCommon"></asp:ObjectDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
Imports System.Drawing
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Define
Imports System.Xml
Imports System.Web.UI
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Partial Class _Default
Inherits System.Web.UI.Page
Private objItem As Model 'グリッドデータ用モデル
Private objCom As New DBCommon 'データベースに関しての処理クラス
''' <summary>
''' ページロード
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'初期表示の場合のみ、下記の処理を実行
If Not IsPostBack Then
Me.grd.DataSourceID = Nothing 'データソースを使わなくなる
'ツリー部分のデータを検索する
TreeData = objCom.GetTreeData()
SetGrdInit() 'グリッド初期化
End If
End Sub
''' <summary>
''' グリッド初期化
''' </summary>
''' <remarks></remarks>
Private Sub SetGrdInit()
'ツリー部分以外のデータを検索する
GrdData = objCom.GetGrdData()
grd.DataSource = GrdData 'グリッドにデータを設定する
'ツリーの初期化状態を作ると処理を行う
Dim lstModel As New List(Of Model)
Dim arrlst As ArrayList = GetLstTreeData(0) 'ツリーと第一列のデータを取得する
Dim ii As Integer
For ii = 0 To arrlst.Count - 1
objItem = New Model
objItem.StrNull1 = arrlst(ii)
If GetLstTreeData(1, objItem).Count >= 1 Then
objItem.StrNull1 = "+" & arrlst(ii)
End If
lstModel.Add(objItem)
Next
'ツリーが初期化された状態を保存して置く
TreeView = lstModel
End Sub
''' <summary>
''' ツリー部分のデータソースから列番号によってデータを取得すると処理
''' </summary>
''' <param name="col">列番号</param>
''' <param name="item">ツリー部分、同行中で前のキーを引数として</param>
''' <returns></returns>
''' <remarks></remarks>
Private Function GetLstTreeData(ByVal col As Integer, Optional ByVal item As Model = Nothing) As ArrayList
Dim arrLst As New ArrayList
If Not col < 6 Then Return arrLst '最大の列数が限られる---------------6はツリー部分列数の総計---------【★注意:変更する必要がある★】
If TreeData Is Nothing Then Return arrLst 'データとヌルをチェックする
If TreeData.Columns.Count < 6 Then Return arrLst '-----------------------------【★注意:変更する必要がある★】
Dim hashTbl As Hashtable
Dim strValue As String = String.Empty
'Dim n As Integer
Dim rr As Integer
For rr = 0 To TreeData.Rows.Count - 1
'If col = 0 Then
' arrLst.Add(TreeData.Rows(rr).Item(col))
'Else
' For n = 0 To col
' If n = col Then
' If String.IsNullOrEmpty(TreeData.Rows(rr).Item(col)) Then
' Return arrLst
' Else
' arrLst.Add(TreeData.Rows(rr).Item(col))
' Exit For
' End If
' End If
' Select Case n
' Case 0
' strValue = item.StrNull1
' Case 1
' strValue = item.StrNull2
' Case 2
' strValue = item.StrNull3
' Case 3
' strValue = item.StrNull4
' Case 4
' '無し
' End Select
' If strValue.Equals(TreeData.Rows(rr).Item(n)) Then
' Continue For
' Else
' Exit For
' End If
' Next
'End If
Select Case col
Case 0
arrLst.Add(TreeData.Rows(rr).Item("Node1"))
Case 1
If item.StrNull1.Equals(TreeData.Rows(rr).Item("Node1")) Then
If String.IsNullOrEmpty(TreeData.Rows(rr).Item("Node2")) Then
Return arrLst
Else
arrLst.Add(TreeData.Rows(rr).Item("Node2"))
End If
End If
Case 2
If item.StrNull1.Equals(TreeData.Rows(rr).Item("Node1")) Then
If item.StrNull2.Equals(TreeData.Rows(rr).Item("Node2")) Then
If String.IsNullOrEmpty(TreeData.Rows(rr).Item("Node3")) Then
Return arrLst
Else
arrLst.Add(TreeData.Rows(rr).Item("Node3"))
End If
End If
End If
Case 3
If item.StrNull1.Equals(TreeData.Rows(rr).Item("Node1")) Then
If item.StrNull2.Equals(TreeData.Rows(rr).Item("Node2")) Then
If item.StrNull3.Equals(TreeData.Rows(rr).Item("Node3")) Then
If String.IsNullOrEmpty(TreeData.Rows(rr).Item("Node4")) Then
Return arrLst
Else
hashTbl = New Hashtable
hashTbl.Add("StrNull4", TreeData.Rows(rr).Item("Node4"))
hashTbl.Add("StrNull41", TreeData.Rows(rr).Item("Node41"))
hashTbl.Add("StrNull42", TreeData.Rows(rr).Item("Node42"))
arrLst.Add(hashTbl)
End If
End If
End If
End If
Case 4
If item.StrNull1.Equals(TreeData.Rows(rr).Item("Node1")) Then
If item.StrNull2.Equals(TreeData.Rows(rr).Item("Node2")) Then
If item.StrNull3.Equals(TreeData.Rows(rr).Item("Node3")) Then
If item.StrNull4.Equals(TreeData.Rows(rr).Item("Node4")) Then
If String.IsNullOrEmpty(TreeData.Rows(rr).Item("Node5")) Then
Return arrLst
Else
arrLst.Add(TreeData.Rows(rr).Item("Node5"))
End If
End If
End If
End If
End If
Case 5
If item.StrNull1.Equals(TreeData.Rows(rr).Item("Node1")) Then
If item.StrNull2.Equals(TreeData.Rows(rr).Item("Node2")) Then
If item.StrNull3.Equals(TreeData.Rows(rr).Item("Node3")) Then
If item.StrNull4.Equals(TreeData.Rows(rr).Item("Node4")) Then
If item.StrNull5.Equals(TreeData.Rows(rr).Item("Node5")) Then
If String.IsNullOrEmpty(TreeData.Rows(rr).Item("Node6")) Then
Return arrLst
Else
arrLst.Add(TreeData.Rows(rr).Item("Node6"))
End If
End If
End If
End If
End If
End If
Case Else
Exit For
End Select
Next
Return arrLst
End Function
''' <summary>
''' グリッドが生成している時の処理
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub grd_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grd.RowDataBound
Dim i As Integer
'グリッドのヘーダ複数列を合併する処理
'If e.Row.RowType = DataControlRowType.Header Then
' Dim tcHeader As TableCellCollection = e.Row.Cells
' For i = 3 To grd.Columns.Count - 1'-----------------------------------------【★注意:変更する必要がある★】
' tcHeader.RemoveAt(3) '-----------------------------------------【★注意:変更する必要がある★】
' Next
' For i = 1 To 6 '-----------------------------------------【★注意:変更する必要がある★】
' tcHeader.Add(New TableHeaderCell())
' tcHeader(i + 2).Attributes.Add("colspan", "2")
' tcHeader(i + 2).Text = "1111".Replace("1", i)
' Next
'End If
If TreeView Is Nothing Then Return 'データとヌルをチェックする
If TreeView.Count <= e.Row.RowIndex Then Return
'グリッドボディ部分の処理
If e.Row.RowType = DataControlRowType.DataRow Then
Dim tc As TableCellCollection = e.Row.Cells
'ボタンのサイズを設定する
'For i = 3 To 13 Step 2 '-------------------13はグリッド列数の総計-----------------------【★注意:変更する必要がある★】
' CType(tc.Item(i).Controls.Item(0), Button).Height = 18
' CType(tc.Item(i).Controls.Item(0), Button).Width = 18
'Next
CType(tc.Item(3).Controls.Item(0), Button).Height = 18 '20081020 追加 何
CType(tc.Item(3).Controls.Item(0), Button).Width = 18
CType(tc.Item(5).Controls.Item(0), Button).Height = 18
CType(tc.Item(5).Controls.Item(0), Button).Width = 18
CType(tc.Item(7).Controls.Item(0), Button).Height = 18
CType(tc.Item(7).Controls.Item(0), Button).Width = 18
CType(tc.Item(9).Controls.Item(0), Button).Height = 18
CType(tc.Item(9).Controls.Item(0), Button).Width = 18
CType(tc.Item(13).Controls.Item(0), Button).Height = 18
CType(tc.Item(13).Controls.Item(0), Button).Width = 18
CType(tc.Item(15).Controls.Item(0), Button).Height = 18
CType(tc.Item(15).Controls.Item(0), Button).Width = 18 '20081020 追加 何
Dim strValue As String = String.Empty
objItem = Me.TreeView(e.Row.RowIndex)
i = 3 'グリッド第三列から '--------------------グリッドの第三列から----------------------【★注意:変更する必要がある★】
'ツリーと第一列
If String.IsNullOrEmpty(objItem.StrNull1) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
CType(tc.Item(0).FindControl("checkBox"), CheckBox).Visible = False '追加 20081016 チェックボックスが表示しない
tc.Item(i + 1).Text = String.Empty
Else
strValue = objItem.StrNull1.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
tc.Item(i + 1).Text = objItem.StrNull1.Substring(1)
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = objItem.StrNull1
End If
End If
i += 2
'ツリーと第二列
If String.IsNullOrEmpty(objItem.StrNull2) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = String.Empty
Else
strValue = objItem.StrNull2.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
tc.Item(i + 1).Text = objItem.StrNull2.Substring(1)
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = objItem.StrNull2
End If
End If
i += 2
'ツリーと第三列
If String.IsNullOrEmpty(objItem.StrNull3) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
'Start 20081016 リンクを追加する-----------------------------------------変更
'tc.Item(i + 1).Text = String.Empty
CType(tc.Item(i + 1).Controls.Item(0), HyperLink).Text = String.Empty
' End 20081016 リンクを追加する-----------------------------------------変更
Else
strValue = objItem.StrNull3.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
'Start 20081016 リンクを追加する-----------------------------------------変更
'tc.Item(i + 1).Text = objItem.StrNull3.Substring(1)
CType(tc.Item(i + 1).Controls.Item(0), HyperLink).Text = objItem.StrNull3.Substring(1)
' End 20081016 リンクを追加する-----------------------------------------変更
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
'Start 20081016 リンクを追加する-----------------------------------------変更
'tc.Item(i + 1).Text = objItem.StrNull3
CType(tc.Item(i + 1).Controls.Item(0), HyperLink).Text = objItem.StrNull3
' End 20081016 リンクを追加する-----------------------------------------変更
End If
End If
i += 2
'ツリーと第四列
If String.IsNullOrEmpty(objItem.StrNull4) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = String.Empty
tc.Item(i + 2).Text = String.Empty '20081020 追加 何
tc.Item(i + 3).Text = String.Empty '20081020 追加 何
Else
strValue = objItem.StrNull4.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
tc.Item(i + 1).Text = objItem.StrNull4.Substring(1)
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = objItem.StrNull4
End If
tc.Item(i + 2).Text = objItem.StrNull41 '20081020 追加 何
tc.Item(i + 3).Text = objItem.StrNull42 '20081020 追加 何
End If
i += 2
i += 2 '20081020 追加 何
'ツリーと第五列
If String.IsNullOrEmpty(objItem.StrNull5) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = String.Empty
Else
strValue = objItem.StrNull5.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
tc.Item(i + 1).Text = objItem.StrNull5.Substring(1)
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = objItem.StrNull5
End If
End If
i += 2
'ツリーと第六列
If String.IsNullOrEmpty(objItem.StrNull6) Then
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = String.Empty
Else
strValue = objItem.StrNull6.Substring(0, 1)
If "+".Equals(strValue) Or "-".Equals(strValue) Then
CType(tc.Item(i).Controls.Item(0), Button).Text = strValue
tc.Item(i + 1).Text = objItem.StrNull6.Substring(1)
Else
CType(tc.Item(i).Controls.Item(0), Button).Visible = False
tc.Item(i + 1).Text = objItem.StrNull6
End If
End If
End If
End Sub
''' <summary>
''' グリッド中のボタンイベントを行う
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub grd_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grd.RowCommand
Dim row As Integer = e.CommandArgument '行番号
Dim cmdName As String = e.CommandName 'コマンド名前が列の区別
Dim cellFlg As String = String.Empty
Dim grdModel As List(Of Model) = GrdData 'セッションからツリー以外データを取得する
Dim treeModel As List(Of Model) = TreeView 'セッションからツリー状態を取得する
Dim item As New Model
Dim arrLst As ArrayList
Dim ii As Integer
Dim delRows As Integer
'列区別
Select Case cmdName
'ツリーと第一列
Case "node1"
Dim tc As TableCellCollection = grd.Rows(row).Cells
cellFlg = CType(tc.Item(3).Controls.Item(0), Button).Text 'ボタンの状態を取得する-----------------【★注意:変更する必要がある★】
'記号フラグセッションを追加する-------------------------------Start-----追加-----20081017
If RefreshCheck(cellFlg & row & cmdName) Then Exit Select
'記号フラグセッションを追加する--------------------------------End------追加-----20081017
item = GetParentModel(row, 1) 'ツリー部分で、第一列の値とキーを取得する
'プラス記号を表示しているボタンを押す場合
If "+".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull1 = "-" & treeModel(row).StrNull1.Substring(1)
arrLst = GetLstTreeData(1, item) 'ツリーと第二列のデータリストを取得する
For ii = 0 To arrLst.Count - 1
objItem = New Model
item.StrNull2 = arrLst(ii)
If GetLstTreeData(2, item).Count >= 1 Then
objItem.StrNull2 = "+" & arrLst(ii)
Else
objItem.StrNull2 = arrLst(ii)
End If
'新しい行を追加する処理
treeModel.Insert(row + 1, objItem)
grdModel.Insert(row + 1, New Model)
Next
'マイナス記号を表示しているボタンを押す場合
ElseIf "-".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull1 = "+" & treeModel(row).StrNull1.Substring(1)
delRows = GetNodes(row, 4) '削除する行数を取得する
'行を削除する処理
For ii = 1 To delRows
treeModel.RemoveAt(row + 1)
grdModel.RemoveAt(row + 1)
Next
Else
Exit Sub 'なんでもない場合、退出する
End If
'ツリーと第二列
Case "node2"
Dim tc As TableCellCollection = grd.Rows(row).Cells
cellFlg = CType(tc.Item(5).Controls.Item(0), Button).Text '-----------------【★注意:変更する必要がある★】
'記号フラグセッションを追加する-------------------------------Start-----追加-----20081017
If RefreshCheck(cellFlg & row & cmdName) Then Exit Select
'記号フラグセッションを追加する--------------------------------End------追加-----20081017
item = GetParentModel(row, 2)
If "+".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull2 = "-" & treeModel(row).StrNull2.Substring(1)
arrLst = GetLstTreeData(2, item)
For ii = 0 To arrLst.Count - 1
objItem = New Model
item.StrNull3 = arrLst(ii)
If GetLstTreeData(3, item).Count >= 1 Then
objItem.StrNull3 = "+" & arrLst(ii)
Else
objItem.StrNull3 = arrLst(ii)
End If
treeModel.Insert(row + 1, objItem)
grdModel.Insert(row + 1, New Model)
Next
ElseIf "-".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull2 = "+" & treeModel(row).StrNull2.Substring(1)
delRows = GetNodes(row, 6)
For ii = 1 To delRows
treeModel.RemoveAt(row + 1)
grdModel.RemoveAt(row + 1)
Next
Else
Exit Sub
End If
'ツリーと第三列
Case "node3"
Dim tc As TableCellCollection = grd.Rows(row).Cells
cellFlg = CType(tc.Item(7).Controls.Item(0), Button).Text '-----------------【★注意:変更する必要がある★】
'記号フラグセッションを追加する-------------------------------Start-----追加-----20081017
If RefreshCheck(cellFlg & row & cmdName) Then Exit Select
'記号フラグセッションを追加する--------------------------------End------追加-----20081017
item = GetParentModel(row, 3)
If "+".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull3 = "-" & treeModel(row).StrNull3.Substring(1)
arrLst = GetLstTreeData(3, item)
'20081020 変更 何 Start
'For ii = 0 To arrLst.Count - 1
' objItem = New Model
' item.StrNull4 = arrLst(ii)
' If GetLstTreeData(4, item).Count >= 1 Then
' objItem.StrNull4 = "+" & arrLst(ii)
' Else
' objItem.StrNull4 = arrLst(ii)
' End If
' treeModel.Insert(row + 1, objItem)
' grdModel.Insert(row + 1, New Model)
'Next
Dim hsTbl As Hashtable
For ii = 0 To arrLst.Count - 1
objItem = New Model
hsTbl = arrLst(ii)
item.StrNull4 = hsTbl("StrNull4")
If GetLstTreeData(4, item).Count >= 1 Then
objItem.StrNull4 = "+" & hsTbl("StrNull4")
Else
objItem.StrNull4 = hsTbl("StrNull4")
End If
objItem.StrNull41 = hsTbl("StrNull41")
objItem.StrNull42 = hsTbl("StrNull42")
treeModel.Insert(row + 1, objItem)
grdModel.Insert(row + 1, New Model)
Next
'20081020 変更 何 End
ElseIf "-".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull3 = "+" & treeModel(row).StrNull3.Substring(1)
delRows = GetNodes(row, 8)
For ii = 1 To delRows
treeModel.RemoveAt(row + 1)
grdModel.RemoveAt(row + 1)
Next
Else
Exit Sub
End If
'ツリーと第四列
Case "node4"
Dim tc As TableCellCollection = grd.Rows(row).Cells
cellFlg = CType(tc.Item(9).Controls.Item(0), Button).Text '-----------------【★注意:変更する必要がある★】
'記号フラグセッションを追加する-------------------------------Start-----追加-----20081017
If RefreshCheck(cellFlg & row & cmdName) Then Exit Select
'記号フラグセッションを追加する--------------------------------End------追加-----20081017
item = GetParentModel(row, 4)
If "+".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull4 = "-" & treeModel(row).StrNull4.Substring(1)
arrLst = GetLstTreeData(4, item)
For ii = 0 To arrLst.Count - 1
objItem = New Model
item.StrNull5 = arrLst(ii)
If GetLstTreeData(5, item).Count >= 1 Then
objItem.StrNull5 = "+" & arrLst(ii)
Else
objItem.StrNull5 = arrLst(ii)
End If
treeModel.Insert(row + 1, objItem)
grdModel.Insert(row + 1, New Model)
Next
ElseIf "-".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull4 = "+" & treeModel(row).StrNull4.Substring(1)
delRows = GetNodes(row, 10)
For ii = 1 To delRows
treeModel.RemoveAt(row + 1)
grdModel.RemoveAt(row + 1)
Next
Else
Exit Sub
End If
'ツリーと第五列
Case "node5"
Dim tc As TableCellCollection = grd.Rows(row).Cells
'cellFlg = CType(tc.Item(11).Controls.Item(0), Button).Text '20081020 変更 何
cellFlg = CType(tc.Item(13).Controls.Item(0), Button).Text '20081020 変更 何
'記号フラグセッションを追加する-------------------------------Start-----追加-----20081017
If RefreshCheck(cellFlg & row & cmdName) Then Exit Select
'記号フラグセッションを追加する--------------------------------End------追加-----20081017
item = GetParentModel(row, 5)
If "+".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull5 = "-" & treeModel(row).StrNull5.Substring(1)
arrLst = GetLstTreeData(5, item)
For ii = 0 To arrLst.Count - 1
objItem = New Model
item.StrNull6 = arrLst(ii)
If GetLstTreeData(6, item).Count >= 1 Then
objItem.StrNull6 = "+" & arrLst(ii)
Else
objItem.StrNull6 = arrLst(ii)
End If
treeModel.Insert(row + 1, objItem)
grdModel.Insert(row + 1, New Model)
Next
ElseIf "-".Equals(cellFlg.Trim()) Then
treeModel(row).StrNull5 = "+" & treeModel(row).StrNull5.Substring(1)
'delRows = GetNodes(row, 12)'20081020 変更 何
delRows = GetNodes(row, 14) '20081020 変更 何
For ii = 1 To delRows
treeModel.RemoveAt(row + 1)
grdModel.RemoveAt(row + 1)
Next
Else
Exit Sub
End If
'ツリーと第六列
Case "node6"
'無し
End Select
grd.DataSource = grdModel 'グリッドに最新のデータを設定する
grd.DataBind()
End Sub
''' <summary>
''' ツリー部分で、行、列番号によって同行中で前のキーを取得すると処理
''' </summary>
''' <param name="row"></param>
''' <param name="col"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function GetParentModel(ByVal row As Integer, ByVal col As Integer) As Model
Dim item As New Model
If Me.grd.Rows.Count <= 0 Then Return item
Dim rr As Integer
For rr = row To 0 Step -1
While col <> 0
Select Case col
Case 6
'無し
Case 5
'20081020 変更 何 Start
'If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 7).Text) Then '-----------------【★注意:変更する必要がある★】
' item.StrNull5 = Me.grd.Rows(rr).Cells(col + 7).Text
' col -= 1
'Else
' Exit While
'End If
If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 9).Text) Then '-----------------【★注意:変更する必要がある★】
item.StrNull5 = Me.grd.Rows(rr).Cells(col + 9).Text
col -= 1
Else
Exit While
End If
'20081020 変更 何 End
Case 4
If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 6).Text) Then '-----------------【★注意:変更する必要がある★】
item.StrNull4 = Me.grd.Rows(rr).Cells(col + 6).Text
col -= 1
Else
Exit While
End If
Case 3
'Start 20081016 リンクを追加する-----------------------------------------変更
'If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 5).Text) Then
' item.StrNull3 = Me.grd.Rows(rr).Cells(col + 5).Text
' col -= 1
'Else
' Exit While
'End If '-----------------【★注意:変更する必要がある★】
If Not String.IsNullOrEmpty(CType(Me.grd.Rows(rr).Cells(col + 5).Controls.Item(0), HyperLink).Text) Then
item.StrNull3 = CType(Me.grd.Rows(rr).Cells(col + 5).Controls.Item(0), HyperLink).Text
col -= 1
Else
Exit While
End If
' End 20081016 リンクを追加する-----------------------------------------変更
Case 2 '-----------------【★注意:変更する必要がある★】
If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 4).Text) Then
item.StrNull2 = Me.grd.Rows(rr).Cells(col + 4).Text
col -= 1
Else
Exit While
End If
Case 1 '-----------------【★注意:変更する必要がある★】
If Not String.IsNullOrEmpty(Me.grd.Rows(rr).Cells(col + 3).Text) Then
item.StrNull1 = Me.grd.Rows(rr).Cells(col + 3).Text
col -= 1
Else
Exit While
End If
End Select
End While
Next
Return item
End Function
''' <summary>
''' 削除できる行数を取得すると処理
''' </summary>
''' <param name="row"></param>
''' <param name="col"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function GetNodes(ByVal row As Integer, ByVal col As Integer) As Integer
Dim counts As Integer = 0
If Me.grd.Rows.Count <= 0 Then Return counts
Dim cc As Integer
Dim blnFlg As Boolean = True
While blnFlg
row += 1
If row >= Me.grd.Rows.Count Then Exit While
cc = col
While True
'Start 20081016 リンクを追加する-----------------------------------------変更
'If String.IsNullOrEmpty(Me.grd.Rows(row).Cells(cc).Text) Then
' If cc > 4 Then
' cc -= 2
' Else
' counts += 1
' Exit While
' End If
'Else
' blnFlg = False
' Exit While
'End If
If cc = 8 Then '-------リンク列が第八列----------【★注意:変更する必要がある★】
'リンクである列
If String.IsNullOrEmpty(CType(Me.grd.Rows(row).Cells(cc).Controls.Item(0), HyperLink).Text) Then
If cc > 4 Then '-----------------【★注意:変更する必要がある★】
cc -= 2
Else
counts += 1
Exit While
End If
Else
blnFlg = False
Exit While
End If
Else
If String.IsNullOrEmpty(Me.grd.Rows(row).Cells(cc).Text) Then
If cc > 4 Then '-----------------【★注意:変更する必要がある★】
'20081020 変更 何 Start
'cc -= 2
If cc = 14 Then
cc -= 4
Else
cc -= 2
End If
'20081020 変更 何 End
Else
counts += 1
Exit While
End If
Else
blnFlg = False
Exit While
End If
End If
' End 20081016 リンクを追加する-----------------------------------------変更
End While
End While
Return counts
End Function
''' <summary>
''' F5とキーが押したらグリッドが再描画されるかどうかをチェックすると処理
''' </summary>
''' <param name="strFlg"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function RefreshCheck(ByVal strFlg As String) As Boolean
RefreshCheck = False
If KigouFlg Is Nothing Then
KigouFlg = strFlg
Else
If KigouFlg.Equals(strFlg) Then
RefreshCheck = True
Else
KigouFlg = strFlg
End If
End If
End Function
''' <summary>
''' グリッド中のデータリスト
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Private Property GrdData() As List(Of Model)
Get
Return Session("GRID_DATA")
End Get
Set(ByVal value As List(Of Model))
Session("GRID_DATA") = value
End Set
End Property
''' <summary>
''' ツリー部分のデータリスト
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Private Property TreeData() As DataTable
Get
Return Session("TREE_DATA")
End Get
Set(ByVal value As DataTable)
Session("TREE_DATA") = value
End Set
End Property
''' <summary>
''' ツリー部分の状況を保存するリスト
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Private Property TreeView() As List(Of Model)
Get
Return Session("TREE_VIEW")
End Get
Set(ByVal value As List(Of Model))
Session("TREE_VIEW") = value
End Set
End Property
''' <summary>
''' 記号フラグ
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Private Property KigouFlg() As String
Get
Return Session("記号フラグ")
End Get
Set(ByVal value As String)
Session("記号フラグ") = value
End Set
End Property
End Class
Imports Microsoft.VisualBasic
Imports System.Data
Imports Oracle.DataAccess.Client
Imports System.Collections.Generic
Public Class DBCommon
Private objDb As DbUtil
Public Function GetGrdData() As List(Of Model)
'Dim dataTabl As DataTable = Nothing
Dim strSql As New StringBuilder 'SQL文作成用
Dim OraCommand As OracleCommand = New OracleCommand 'パラメータ設定用
Dim oraDr As OracleDataReader
Dim lstModel As New List(Of Model)
Try
strSql.Append(" SELECT SK_SPEC_ID ShiyouID, ")
'strSql.Append(" SK_SPEC_REV Kaitei, ")
strSql.Append(" SK_SPEC_GRP_ID GroupID")
strSql.Append(" FROM SK_SPEC ")
strSql.Append(" WHERE ROWNUM <= 5")
objDb = New DbUtil
objDb.DbOpen(2, Nothing)
oraDr = objDb.ExecuteReader(strSql.ToString(), OraCommand)
Dim item As Model
While (oraDr.Read())
item = New Model
item.ShiyouID = oraDr("ShiyouID").ToString()
'item.Kaitei = oraDr("Kaitei").ToString()
item.GroupID = oraDr("GroupID").ToString()
lstModel.Add(item)
End While
Catch ex As Exception
Throw ex
Finally
If objDb IsNot Nothing Then
objDb.DbClose()
objDb = Nothing
End If
End Try
Return lstModel
End Function
Public Function GetTreeData() As DataTable
Dim dataTabl As DataTable = Nothing
Dim strSql As New StringBuilder 'SQL文作成用
Dim OraCommand As OracleCommand = New OracleCommand 'パラメータ設定用
Try
strSql.Append(" SELECT YORYOSHO_NO Node1, ")
strSql.Append(" ROW_NO Node2, ")
strSql.Append(" EG_SPEC_ID Node3, ")
strSql.Append(" ROW_NO Node4, ")
'Start 20081020 追加 何
strSql.Append(" ROW_NO Node41, ")
strSql.Append(" ROW_NO Node42, ")
' End 20081020 追加 何
strSql.Append(" ROW_NO Node5, ")
strSql.Append(" ROW_NO Node6 ")
strSql.Append(" FROM YORYOSHO_TO_EG_SPEC ")
strSql.Append(" where rownum <= 5 ")
strSql.Append(" order by YORYOSHO_NO, ROW_NO ")
objDb = New DbUtil
objDb.DbOpen(2, Nothing)
dataTabl = objDb.ExecuteReaderTable(strSql.ToString(), OraCommand)
Catch ex As Exception
Throw ex
Finally
If objDb IsNot Nothing Then
objDb.DbClose()
objDb = Nothing
End If
End Try
Return dataTabl
End Function
End Class
Imports Microsoft.VisualBasic
Public Class Model
Dim _shiyouID As String
Dim _kaitei As String
Dim _groupID As String
Dim _strNull1 As String
Dim _strNull2 As String
Dim _strNull3 As String
Dim _strNull4 As String
Dim _strNull5 As String
Dim _strNull6 As String
'Start 20081020 追加 何
Dim _strNull41 As String
Dim _strNull42 As String
Public Property StrNull41() As String
Get
Return _strNull41
End Get
Set(ByVal value As String)
_strNull41 = value
End Set
End Property
Public Property StrNull42() As String
Get
Return _strNull42
End Get
Set(ByVal value As String)
_strNull42 = value
End Set
End Property
' End 20081020 追加 何
Public Property ShiyouID() As String
Get
Return _shiyouID
End Get
Set(ByVal value As String)
_shiyouID = value
End Set
End Property
Public Property Kaitei() As String
Get
Return _kaitei
End Get
Set(ByVal value As String)
_kaitei = value
End Set
End Property
Public Property GroupID() As String
Get
Return _groupID
End Get
Set(ByVal value As String)
_groupID = value
End Set
End Property
Public Property StrNull1() As String
Get
Return _strNull1
End Get
Set(ByVal value As String)
_strNull1 = value
End Set
End Property
Public Property StrNull2() As String
Get
Return _strNull2
End Get
Set(ByVal value As String)
_strNull2 = value
End Set
End Property
Public Property StrNull3() As String
Get
Return _strNull3
End Get
Set(ByVal value As String)
_strNull3 = value
End Set
End Property
Public Property StrNull4() As String
Get
Return _strNull4
End Get
Set(ByVal value As String)
_strNull4 = value
End Set
End Property
Public Property StrNull5() As String
Get
Return _strNull5
End Get
Set(ByVal value As String)
_strNull5 = value
End Set
End Property
Public Property StrNull6() As String
Get
Return _strNull6
End Get
Set(ByVal value As String)
_strNull6 = value
End Set
End Property
End Class