?? productlist.ascx.vb
字號:
Imports OrderDll
Partial Class ProductList
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TableInit()
End Sub
Protected Sub Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim id As String
Dim cp As New ClassProduct
id = DirectCast(sender, Button).ID.Substring(3)
If cp.Delete(id) = False Then
TableClear(TableProduct)
TableInit()
Else
End If
End Sub
Private Sub TableInit()
Dim dsProduct As Data.DataSet
Dim cp As New ClassProduct
Dim count As Integer
dsProduct = New Data.DataSet
If cp.List(dsProduct) = False Then
With dsProduct.Tables(0)
For count = 0 To .Rows.Count - 1
TableProduct.Controls.Add(GenrateRow( _
.Rows(count).Item(0).ToString(), _
.Rows(count).Item(1).ToString(), _
.Rows(count).Item(2).ToString(), _
.Rows(count).Item(3), _
.Rows(count).Item(4), _
.Rows(count).Item(5), _
.Rows(count).Item(6)) _
)
Next
End With
Else
End If
End Sub
Private Function GenrateRow(ByVal id As String, ByVal name As String, ByVal unit As String, ByVal storage As Integer, ByVal sellrate As Double, ByVal cost As Double, ByVal total As Integer) As TableRow
Dim tr As New TableRow
Dim tc As TableCell
Dim btnDel As Button
Dim btn As HtmlInputButton
tc = New TableCell
tc.Text = id
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = name
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = unit
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = storage.ToString()
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = sellrate.ToString()
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = cost.ToString()
tr.Controls.Add(tc)
tc = New TableCell
tc.Text = total.ToString()
tr.Controls.Add(tc)
tc = New TableCell
btn = New HtmlInputButton
btn.Attributes("value") = "修改"
btn.Attributes("OnClick") = "javascript:self.location='ProductEdit.aspx?PID=" & id & "';"
tc.Controls.Add(btn)
btnDel = New Button
btnDel.Text = "刪除"
btnDel.ID = "Del" & id
AddHandler btnDel.Click, AddressOf Me.Btn_Click
tc.Controls.Add(btnDel)
tr.Controls.Add(tc)
tc = New TableCell
btn = New HtmlInputButton
btn.Attributes("value") = "添加"
btn.Attributes("OnClick") = "javascript:self.location='Producing.aspx?PID=" & id & "';"
tc.Controls.Add(btn)
btn = New HtmlInputButton
btn.Attributes("value") = "察看"
btn.Attributes("OnClick") = "javascript:self.location='ProducingView.aspx?PID=" & id & "';"
tc.Controls.Add(btn)
tr.Controls.Add(tc)
Return tr
End Function
Protected Sub TableClear(ByVal tbl As Table)
Dim temp As TableRow
temp = tbl.Controls(0)
tbl.Controls.Clear()
tbl.Controls.Add(temp)
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -