 |
|
ใช้ตัว Repeater แล้วทำเป็นปุ่มกด อยากให้ไปทำงาน Sub ย่อยทำยังไงครับ |
|
 |
|
|
 |
 |
|
คือผมได้ทำการสร้าง Repeater ขึ้นมาแล้วสร้างปุ่มกดใน Repeater แล้วอยากให้กดปุ่มแล้วไปทำงานอีก Sub นึงทำยังไงครับ
ผมทำแล้วไม่
Code (VB.NET)
Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
'*** Hyperlink ***'
Dim hplSelect As HyperLink = CType(e.Item.FindControl("hplSelect"), HyperLink)
If Not IsNothing(hplSelect) Then
hplSelect.Text = "Select"
hplSelect.NavigateUrl = "Show_Data_CMS.aspx?Fiscal=" & e.Item.DataItem("F_Fiscal_Year") & "&Acc=" & e.Item.DataItem("F_Acc_Code") & "&Cr=" & e.Item.DataItem("F_CR_Tech") & "&Dept=" & e.Item.DataItem("F_Department_Code") & "&Sub=" & e.Item.DataItem("F_Subject") & "&Loc=" & e.Item.DataItem("F_Locat_ID")
End If
'*** CustomerID ***'
Dim lblFiscal1 As Label = CType(e.Item.FindControl("lblFiscal1"), Label)
If Not IsNothing(lblFiscal1) Then
lblFiscal1.Text = e.Item.DataItem("F_Fiscal_Year")
End If
'*** Button ***'
Dim hplEdit As Button = CType(e.Item.FindControl("hplEdit"), Button)
If Not IsNothing(hplEdit) Then
hplEdit.Text = "Activity"
printpic()
End If
End Sub
Private Sub printpic()
Dim TimePrint As String
Dim SWhere As String
'SWhere = "{T_MS_Project.F_Use} = 'U' "
TimePrint = Format(Now, "ddMMyyyy") & Format(Microsoft.VisualBasic.DateAndTime.TimeOfDay, "HHmmss")
Dim user As String = Session("User")
Dim DSreport As New DataSet
Dim SqlReader As SqlClient.SqlDataReader
Dim Conn As New SqlClient.SqlConnection
Dim sql As String = "select F_Fiscal_Year,F_Acc_Code,F_CR_Tech,F_Subject,F_Department_Code,F_File from T_Entry_CMS where F_Fiscal_Year = '" & Session("Fiscal") & "' " & _
"and F_Acc_Code = '" & Session("AC") & "' and F_CR_Tech = '" & Session("CR") & "' " & _
"and F_Department_Code = '" & Session("Deptcd") & "' and F_Subject = '" & Session("Subject") & "' "
Dim strConn As String = "Server=HMMT-WIS;uid=sa;pwd=SPD777;database=WISDB;"
Conn.ConnectionString = strConn
Conn.Open()
Dim DT As New DataTable("element1")
DT.Columns.Add("Year", GetType(String))
DT.Columns.Add("Acc", GetType(String))
DT.Columns.Add("Cr", GetType(String))
DT.Columns.Add("dept", GetType(String))
DT.Columns.Add("subject", GetType(String))
DT.Columns.Add("Pic", GetType(System.Byte()))
DSreport.Tables.Add(DT)
Dim SqlAdapter As New SqlClient.SqlDataAdapter(sql, Conn)
SqlReader = SqlAdapter.SelectCommand.ExecuteReader
If SqlReader.HasRows Then
While SqlReader.Read
Dim path As String = SqlReader.Item("F_File").ToString()
Dim FilStr As New FileStream(path, FileMode.Open) ' เปิด file แบบ Stream เพื่ออ่านเป็น Binary
Dim BinRead As New BinaryReader(FilStr)
Dim DR As DataRow = DSreport.Tables("element1").NewRow
' Add ข้อมูลที่อ่านจาก SQL Base ใส่เข้าไปแต่ละ Rows ของ Temp Table
DR.Item("Year") = SqlReader.Item("F_Fiscal_Year")
DR.Item("Acc") = SqlReader.Item("F_Acc_code")
DR.Item("Cr") = SqlReader.Item("F_Cr_Tech")
DR.Item("dept") = SqlReader.Item("F_Department_code")
DR.Item("subject") = SqlReader.Item("F_Subject")
' Column Photo ใส่ข้อมูล Binary
DR.Item("Pic") = BinRead.ReadBytes(BinRead.BaseStream.Length)
DSreport.Tables("element1").Rows.Add(DR) 'Add Row เข้าไปใน Temp Table
FilStr.Close() '//ปิด FileStream
BinRead.Close()
Session("M_DV") = DSreport.Tables("element1")
End While
SqlReader.Close()
Conn.Close()
Call GenReport("CMS_Activity_Sheet_RPT", CType(Session("M_DV"), DataTable), TimePrint, user)
Response.Write("<script>")
Response.Write("window.open('/WISNET/Report_CMS/CMS_Activity_Sheet_RPT_" & user & "_" & TimePrint & ".pdf','_blank')")
Response.Write("</script>")
End If
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET, VS 2003 (.NET 1.1)
|
|
 |
 |
 |
 |
Date :
2010-08-19 09:39:00 |
By :
juka |
View :
1316 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพิ่มเติมครับ ผมทำตรง Report แล้วตรง
rpt.FilePath("C:\Inetpub\wwwroot\Help_Desk\" & RepName & ".rpt") 'Server.MapPath 'My.Request.PhysicalApplicationPath & RepName & ".rpt"
ใช้ไม่ได้ครับ ผมต้องทำยังไงถึงจะออก Report ได้ครับ ช่วยทีครับ
Code (VB.NET)
Private Sub GenReport(ByVal RepName As String, ByVal DV As DataTable, ByVal TimePrint As String, ByVal user As String)
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim oExportOptions As CrystalDecisions.Shared.ExportOptions
Dim oDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
Try
rpt.FilePath("C:\Inetpub\wwwroot\Help_Desk\" & RepName & ".rpt") 'Server.MapPath 'My.Request.PhysicalApplicationPath & RepName & ".rpt"
rpt.SetDataSource(DV)
'If Param <> "" Then
' rpt.DataDefinition.FormulaFields.Item("F_Dept").Text = """DEPT " & Param & """"
'End If
'===========================
oDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
oExportOptions = rpt.ExportOptions
Dim PDFpath As String = "C:\Inetpub\wwwroot\WISNET\Report_CMS\" & RepName & "_" & user & "_" & TimePrint & ".pdf"
oDiskFileDestinationOptions.DiskFileName = PDFpath
With oExportOptions
.DestinationOptions = oDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With
rpt.Export()
'Response.Redirect(RepName & "_" & TimePrint & ".pdf")
'============================
'rpt.ExportToDisk(ExportFormatType.PortableDocFormat, paths & "\PrintPDF\" & RepName & "_" & TimePrint & ".pdf")
Catch ex As Exception
'Response.Write(ex.Message)
End Try
End Sub
|
ประวัติการแก้ไข 2010-08-19 09:49:23 2010-08-19 09:49:27
 |
 |
 |
 |
Date :
2010-08-19 09:48:45 |
By :
juka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
dynamic event handle เป็นป่ะ และควรใช้ oncommand แทนเพราะจะได้ส่ง parameter ไปด้วยได้
|
 |
 |
 |
 |
Date :
2010-08-19 11:58:15 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำยังไงหรือครับ คุณ Tungman
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2010-08-19 13:12:57 |
By :
juka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอความช่วยเหลือด้วยครับ
|
 |
 |
 |
 |
Date :
2010-08-19 14:28:23 |
By :
juka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|