Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Partial Public Class Show_Container
Inherits System.Web.UI.Page
Dim connstr As String = "server=(local);database=db_CMS;uid=AdminCMS;password=qaz123"
Dim Conn As New SqlConnection(connstr)
Dim Sql As String
Dim ad As SqlDataAdapter
Dim Cmd As SqlCommand
Dim Dview As DataView
Dim Ds As New DataSet
Dim Service As New Service1
Sub showdata()
Dim DView As DataView
Dim Ds As New DataSet
Dim conpic As String
Dim idx As String = Request.QueryString("id")
Sql = "SELECT Tl_Container.*, Tl_Customer.cus_name AS Cus_name, Tl_ContainerType.Cont_name AS Cont_name, 'background-color:#' + Tl_Container.Con_color AS color FROM Tl_Container INNER JOIN Tl_Customer ON Tl_Container.Cus_id = Tl_Customer.cus_id INNER JOIN Tl_ContainerType ON Tl_Container.Cont_id = Tl_ContainerType.Cont_id WHERE Tl_Container.Con_id=" + "'" + idx + "'" + " "
'//กำหนด Sqlสำหรับอ่านข้อมูล
ad = New SqlDataAdapter(Sql, Conn) '///ประมวลผลคำสั่งอ่านข้อมูล
ad.Fill(Ds, "Con") '///นำข้อมูลที่อ่านข้อมูลได้ไปให้กับDsแบบดาต้าเซต
DView = Ds.Tables("Con").DefaultView '///นำข้อมูลในDsแบบดาต้าเซตไปให้ดาต้าวิว
If DView.Count > 0 Then '////ถ้า DView.Count มีค่ามากกว่า 0 แสดงว่ามีข้อมูลรหัสนั้นๆ แล้ว
Dim DRowView As DataRowView '////กำหนดตัวแปรแบบบ DataRowview เพื่ออ่านข้อมูลที่ละรายการ
For Each DRowView In DView '////วนรอบอ่านข้อมูลจาก Dview ทีละรายการไปให้ DataRowview ถ้าอ่านไม่ได้ออกจากลูป
TxtConid.Text = idx
Txtsize.Text = DRowView.Item("Con_size")
TxtCusname.Text = DRowView.Item("cus_name")
TxtType.Text = DRowView.Item("cont_name")
TxtConweigth.Text = DRowView.Item("con_weight")
TxtConweihig.Text = DRowView.Item("con_whold")
TxtConyear.Text = DRowView.Item("con_year")
TxtDetail.Text = DRowView.Item("con_detail")
conpic = DRowView.Item("Con_Picture")
Dim filepic As String = "D" & idx & "." & conpic
'Response.Write(filepic)
Image1.ImageUrl = filepic
Next
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
showdata()
End If
'If Not (Service.TestSession()) Then
' Response.Redirect("Login.aspx")
'End If
End Sub
Private Sub Btncancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btncancel.Click
Response.Redirect("Display_Container.aspx")
End Sub
Private Sub BtnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
Response.Redirect("Edit_Container.aspx?id=" & TxtConid.Text)
End Sub
End Class