Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > กรุณาช่วยหนูด้วยนะค่ะ เกี่ยวกับเงื่อไขที่โค้ด ส้รางเมนูด้วยโคด้


 

[.NET] กรุณาช่วยหนูด้วยนะค่ะ เกี่ยวกับเงื่อไขที่โค้ด ส้รางเมนูด้วยโคด้

 
Topic : 078523

Guest



Code (VB.NET)
001.Imports System.IO
002.Imports System.Collections.Generic
003.Imports CrystalDecisions.CrystalReports.Engine
004.Imports System.Data
005.Imports System.Data.SqlClient
006. 
007. 
008.Public Class Site
009.    Inherits System.Web.UI.MasterPage
010.    Dim PathMSDS As String = "C:\Users\TiP-ToP\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\REPORT"
011.    Dim myDirInfo As DirectoryInfo
012.    Dim myFolderInfo As DirectoryInfo
013.    Dim arrFolderInfo As Array
014.    Dim _dirFile As String
015.    Dim RootMaster = New Menu
016.    Dim RootMenu = New MenuItem
017.    Dim RootTmp = New MenuItem
018.    Dim SubTmp = New MenuItem
019.    Dim arrMenu() As String
020.    Dim tarray As New ArrayList()
021.    Dim SearchPath As String = "C:\MSDS\"
022. 
023.    Sub BuildTree(ByVal s As String)
024. 
025.        Dim strName As String = HttpContext.Current.User.Identity.Name.ToString
026.        Dim rootdir = New DirectoryInfo("C:\Users\TiP-ToP\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\REPORT\" & s)
027.        Dim rootnode = New TreeNode(rootdir.Name, rootdir.FullName)
028.        Dim rootSub = New MenuItem(rootdir.Name, rootdir.FullName)
029.        'DocumentMenu.Items.Add(rootSub)
030. 
031.        NavigationMenu.Items.Add(rootSub)
032.        'RecursiveSearch(rootdir, rootSub)
033.        RecursiveSearch2(rootdir, rootSub)
034.        'TreeView1.Nodes.Add(rootnode)
035.        'traversetree(rootdir, rootnode)
036. 
037.    End Sub
038.    'Private Sub RecursiveSearch(ByRef CurrentMenu, ByRef CurrentSubMenu)
039.    '    Dim dir As DirectoryInfo
040.    '    For Each dir In CurrentMenu.GetDirectories
041.    '        Dim SubMenu As New MenuItem(dir.Name, dir.FullName)
042. 
043. 
044.    '        'Dim LstFiles() As String
045.    '        'LstFiles = Directory.GetFiles("path ")
046.    '        'For i As Int32 = 0 To LstFiles.Length - 1
047.    '        '    nuItem(Days.name, )
048.    '        'Next
049. 
050.    '        CurrentSubMenu.Childitems.add(SubMenu)
051. 
052.    '        RecursiveSearch(dir, SubMenu)
053. 
054.    '    Next
055. 
056. 
057.    '    Dim myFile As FileInfo
058.    '    For Each myFile In CurrentMenu.GetFiles
059.    '        Dim MenuFile As New MenuItem(Mid(myFile.Name, 1, Len(myFile.Name) - 4), myFile.FullName)
060.    '        'MsgBox(Menu1.Items.Count)
061.    '        'MenuFile.NavigateUrl = myFile.FullName
062.    '        CurrentSubMenu.Childitems.Add(MenuFile)
063. 
064.    '    Next
065. 
066.    'End Sub
067. 
068.    Private Sub RecursiveSearch2(ByRef CurrentMenu, ByRef CurrentSubMenu)
069.        'Dim dir As DirectoryInfo
070. 
071.        'For Each dir In CurrentMenu.GetDirectories
072.        '    Dim SubMenu As New MenuItem(dir.Name, dir.FullName)
073.        '    CurrentSubMenu.Childitems.add(SubMenu)
074.        '    RecursiveSearch(dir, SubMenu)
075.        'Next
076. 
077.        Dim myFile As FileInfo
078.        For Each myFile In CurrentMenu.GetFiles
079.            Dim MenuFile As New MenuItem(Mid(myFile.Name, 1, Len(myFile.Name) - 4), myFile.FullName)
080.            'MsgBox(Menu1.Items.Count)
081. 
082.             
083. 
084. 
085. 
086. 
087.            MenuFile.NavigateUrl = "viewreport.aspx"
088. 
089.            CurrentSubMenu.Childitems.Add(MenuFile)
090.        Next
091. 
092.    End Sub
093. 
094.    'Private Sub traversetree(ByRef CurrentDir, ByRef CurrentNode)
095.    '    Dim dir As DirectoryInfo
096.    '    For Each dir In CurrentDir.GetDirectories
097.    '        Dim node As New TreeNode(dir.Name, dir.FullName)
098.    '        CurrentNode.ChildNodes.Add(node)
099.    '        traversetree(dir, node)
100.    '    Next
101. 
102.    '    Dim myFile As FileInfo
103.    '    For Each myFile In CurrentDir.GetFiles
104.    '        Dim newNode As TreeNode = New TreeNode(myFile.Name, myFile.FullName)
105.    '        newNode.NavigateUrl = "viewreport.aspx"
106.    '        'myFile.FullName
107.    '        CurrentNode.ChildNodes.Add(newNode)
108.    '    Next
109.    'End Sub
110. 
111.    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
112.        'Dim objConn As New SqlConnection
113.        'Dim objCmd As New SqlCommand
114.        'Dim dtAdapter As New SqlDataAdapter
115.        'Dim ds As New DataSet
116.        'Dim dt As DataTable
117.        'Dim strConnString, strSQL As String
118.        'strConnString = "Server=LAPTOP-IT\SQLEXPRESS;UID=sa;PASSWORD=apcbkk2000;database=APC;Max Pool Size=400;Connect Timeout=600;"
119.        'strSQL = "SELECT * FROM APC  "
120.        'objConn.ConnectionString = strConnString
121.        'With (objCmd)
122.        '    .Connection = objConn
123.        '    .CommandText = strSQL
124.        '    .CommandType = CommandType.Text
125.        'End With 
126.        'dtAdapter.SelectCommand = objCmd
127.        'dtAdapter.Fill(ds, "APCSaleCode")
128.        'dt = ds.Tables(0)
129.        'dtAdapter = Nothing
130.        'objConn.Close()
131.        'objConn = Nothing
132.        'Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
133.        'rpt.Load(Server.MapPath("/report/Marketing/M05-D5005-2-Sale Order Report By Product.rpt"))
134.        'CrystalReportViewer1.ReportSource = rpt
135.        'CrystalReportViewer1.RefreshReport()
136.        'Dim crp = New CrystalReport1()
137. 
138. 
139. 
140. 
141. 
142. 
143. 
144.    End Sub
145.    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
146.        If IsPostBack = False Then
147.            BuildTree("Account")
148.            BuildTree("Bill Collector")
149.            BuildTree("Finance")
150.            BuildTree("IT")
151.            BuildTree("Marketing")
152.            BuildTree("Purchase")
153.            BuildTree("Terminal")
154. 
155.        End If
156. 
157.        'Dim Fd1 As String
158.        'Dim Fd2 As String
159.        'Dim Fd3 As String
160. 
161. 
162.        'Dim TmpFile As String
163.        'Dim DS1, DS2 As String
164.        'Dim S1, S2 As String
165.        'Dim P1, P2 As String
166.        'Dim a1 As String
167.        'Dim ArrFile As Array
168.        'Dim MIndex As String
169. 
170.        'Dim file1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument
171.        'Dim myDirInfo As DirectoryInfo
172.        'file1.Load(Server.MapPath("/report/Marketing/*.rpt", myDirInfo))
173. 
174.        'ReDim ArrFile(1 To 50) As Dat
175.        'Dim i As Integer
176.        'i = 1
177.        'Do While file1 <> ""
178.        '    If file1 <> "." And file1 <> ".." Then
179.        '        ArrFile(i).Fd1 = Mid(file1, 1, Len(file1) - 4)
180.        '        ArrFile(i).Fd2 = Mid(file1, 5, 1)
181.        '        ArrFile(i).Fd3 = Mid(file1, 11, 1)
182.        '        i = i + 1
183.        '    End If
184.        '    file1 = Dir()   ' Get next entry.
185.        'Loop
186.        ''ReDim ArrFile(1 To vbDirectory - 1) As Dat
187.        ''For i = 1 To File1.ListCount  ' Add 3 new items to the menu
188.        ''    ArrFile(i).Fd1 = Mid(File1.List(i - 1), 1, Len(File1.List(i - 1)) - 4)
189.        ''    ArrFile(i).Fd2 = Mid(File1.List(i - 1), 5, 1)
190.        ''    ArrFile(i).Fd3 = Mid(File1.List(i - 1), 11, 1)
191.        ''Next i
192.        'i = 1
193.        'D = 1
194.        'M = 1
195.        'w = 1
196.        'Do
197.        '    If ArrFile(i).Fd2 = "D" Then
198.        '        If ArrFile(i).Fd3 >= User(0).Fd2 Then
199.        '            Load(RptAccD(D))  ' Load new menu item
200.        '            RptAccD(D).Caption = ArrFile(i).Fd1
201.        '            D = D + 1
202.        '        End If
203.        '    ElseIf ArrFile(i).Fd2 = "W" Then
204.        '        If ArrFile(i).Fd3 >= User(0).Fd2 Then
205.        '            Load(RptAccW(w))  ' Load new menu item
206.        '            RptAccW(w).Caption = ArrFile(i).Fd1
207.        '            w = w + 1
208.        '        End If
209.        '    ElseIf ArrFile(i).Fd2 = "M" Then
210.        '        If ArrFile(i).Fd3 >= User(0).Fd2 Then
211.        '            Load(RptAccM(M))  ' Load new menu item
212.        '            RptAccM(M).Caption = ArrFile(i).Fd1
213.        '            M = M + 1
214.        '        End If
215.        '    End If
216.        '    i = i + 1
217.        'Loop Until ArrFile(i).Fd1 = ""
218.        'RptAccD(0).Visible = False
219.        'RptAccM(0).Visible = False
220.        'RptAccW(0).Visible = False
221. 
222.  End Sub
223. 
224.    Private Sub DocumentMenu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs)
225.        MsgBox(sender.ToString & "  " & e.Item.Value)
226.        'Select Case UCase(Right(e.Item.Value, 4))
227.        '    Case ".PDF"
228.        '        Response.ContentType = "Application/pdf"
229.        '    Case ".DOC"
230.        '    Case Else
231.        'End Select
232.        'frame1.Attributes.Add("src", e.Item.Value)
233.        'Me.frame1.InnerHtml = e.Item.Value
234.    End Sub
235. 
236. 
237.    'Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick
238.    '    'If UCase(Right(e.Item.Value)) = ".PDF" Then
239.    '    '    MultiView1.ActiveViewIndex = 1
240.    '    '    frame1.Attributes.Add("src", e.Item.Value)
241.    '    'Else
242.    '    '     "")
243.    '    'End If
244.    '    'frame1.Attributes.Add("src", ViewReport)
245.    'End Sub
246. 
247.    'Protected Sub lkButtonBack_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lkButtonBack.Click
248.    '    'MultiView1.ActiveViewIndex = 0
249.    'End Sub
250. 
251.    Protected Sub NavigationMenu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles NavigationMenu.MenuItemClick
252. 
253.    End Sub
254.End Class


จากโค้ดอยากเพิ่มเงื่อนไขโดยไฟลล์ตามพาธถ้า ไฟล์คริสตัลรีพอตในพาธ มี D ถ้าชื่อมีd แล้ว เมนูจะส้รางเพื่อแยกประเภทเป็น day ให้เมนูสร้างโฟลล์เดอร์เพิ่มขึ้นมาแล้วแยกประเภทด้วย จะมี day week month ดป็นโฟลล์เดอร์ที่ต้องการสร้างต่าจากเมนูหลักก่อนที่จะคลิกแล้วโชว์คริสตัลรีพอต สอนวิธีการโชว์คริสตัลรีพอตด้วยนะค่ะ เมื่อคลิกที่เมนู เมนูส้รางมาจาก code นะค่ะ ไม่ใช่tool
อยากได้ตามรูปเลยค่ะ และเมื่อคลิกcrsytal repot show จะดีมากค่ะ
อยากได้ตามนี้ค่ะ

lkjh



Tag : .NET, Web (ASP.NET), Win (Windows App)

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-05-17 13:29:29 By : belletempo View : 1154 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ใช้พวก IF เข้าช่วยไม่ได้เหรอครับ แนะนำว่าในแต่ล่ะ Report ควรสร้างเป็น Sub ใคร Sub มันครับ และใน Page_Load ก็ตรวจสอบว่ามันควรจะเข้า Sub ไหน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-17 14:31:11 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : กรุณาช่วยหนูด้วยนะค่ะ เกี่ยวกับเงื่อไขที่โค้ด ส้รางเมนูด้วยโคด้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่