Dim e As RequestEventArgs = args(0)
Dim wb As New weui
Dim Pagetext As Integer = e.GetValues("page")
Dim PrimaryKey As Integer = e.GetValues("key")
Dim PageURL = "List.htm?page=" & Pagetext
If e.PostValues.Count = 0 Then \'生成编辑页面
Dim dr As DataRow = DataTables("订餐明细表").SQLFind("[_Identify]=" & PrimaryKey)
If dr IsNot Nothing Then
wb.AddForm("","form1","edit.htm?key=" & PrimaryKey & "&page=" & Pagetext)
With wb.AddInputGroup("form1","ipg1","编辑table")
.AddHiddenValue("编号", dr("_Identify"))
.AddInput("xm","姓名","text").Value=dr("姓名")
.AddInput("rq","日期","date").Value=dr("日期")
.AddInput("fs","份数","number").Value=dr("份数")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "确定", "submit")
End With
Else
With wb.AddMsgPage("","msgpage","编辑失败", "此table可能已经被删除!") \'提示用户此table不存在.
.icon= "Warn"
.AddButton("btn1","返回",PageURL) \'生成返回原来页面的按钮
End With
End If
Else \'保存编辑结果
Dim dr As DataRow = DataTables("订餐明细表").SQLFind("[_Identify]=" & PrimaryKey)
If dr IsNot Nothing Then
Dim inms() As String = {"xm","rq","fs"} \'输入框名称数组
Dim cnms() As String = {"姓名","日期","份数"} \'列名数组,注意列名和输入框必须一一对应,位置不能错乱
For i As Integer = 0 To inms.Length -1
dr(cnms(i)) = e.PostValues(Inms(i))
Next
dr.Save()
\'显示完成提示,2秒后自动返回原来的页面
wb.AppendHtml("<meta http-equiv=\'refresh\' c>",True)
wb.AddToast("","t1", "编辑完成",0).Visible = True
Else
With wb.AddMsgPage("","msgpage","保存失败", "此table可能已经被删除!") \'提示用户此table不存在.
.icon= "Warn"
.AddButton("btn1","返回",PageURL) \'生成返回原来页面的按钮
End With
End If
End If
e.WriteString(wb.Build) \'生成网页