Dim e As RequestEventArgs = args(0)
Dim wb As New weui
Dim PageNumber As Integer = e.GetValues("page")
Dim PrimaryKey As Integer = e.GetValues("key")
Dim PageURL = "List.htm?page=" & PageNumber
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=" & PageNumber)
With wb.AddInputGroup("form1","ipg1","编辑客户信息")
.AddInput("客户编号","客户编号","Text").Value = dr("客户编号")
.AddInput("客户姓名","客户姓名","Text").Value = dr("客户姓名")
.AddInput("出生日期","出生日期","date").Value = dr("出生日期")
.AddInput("年龄","年龄","number").Value = dr("年龄")
.AddSelect("性别","性别","男|女") .Value = dr("性别")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "确定", "submit")
End With
Else
With wb.AddMsgPage("","msgpage","编辑失败", "此订单可能已经被删除!") '提示用户此订单不存在.
.icon= "Warn"
.AddButton("btn1","返回",PageURL) '生成返回原来页面的按钮
End With
End If
Else '保存编辑结果
Dim dr As DataRow = DataTables("客户管理").SQLFind("[_Identify]=" & PrimaryKey)
If dr IsNot Nothing Then
Dim nms() As String = {"客户编号","客户姓名","出生日期","年龄","性别"}
For Each nm As String In nms
dr(nm) = e.PostValues(nm)
Next
dr.Save()
'显示完成提示,2妙手自动返回原来的页面
wb.AppendHtml("<meta http-equiv='refresh' c>",True)
wb.AddToast("","t1", "编辑完成",0).Visible = True
Else
With wb.AddMsgPage("","msgpage","保存失败", "此客户信息可能已经被删除!") '提示用户此订单不存在.
.icon= "Warn"
.AddButton("btn1","返回",PageURL) '生成返回原来页面的按钮
End With
End If
End If
e.WriteString(wb.Build) '生成网页