更重要的是,这个web服务器可以和你的管理系统完全整合起来。
假定有下图所示的一个表:
此主题相关图片如下:0093.png
希望设计一个手机录入界面:
此主题相关图片如下:0090.png
录入OK能提示:
此主题相关图片如下:0092.png
缺少关键内容能提示:
此主题相关图片如下:0091.png
从服务器的建立,三个网页的生成,到数据的接收,所有的代码,都在下面:
Dim fl As String = "d:\web\" & e.path
If filesys.FileExists(fl)
Dim idx As Integer = fl.LastIndexOf(".")
Dim ext As String = fl.SubString(idx)
Select Case ext
Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
e.WriteFile(fl)
Return '这里必须返回
End Select
End If
Dim wb As New weui
Select Case e.Path
Case "addnew.htm"
If e.Values.Count = 0 Then
wb.AddForm("","form1","addnew.htm")
With wb.AddInputGroup("form1","ipg1","客户资料")
.AddInput("姓名","姓名","Text") '前一个"姓名"是ID,后一个"姓名"是标题
.AddInput("年龄","年龄","number")
.AddInput("日期","日期","date")
.AddSelect("级别","级别","普通会员|高级会员|VIP会员")
.AddSwitch("停权","停权").Value = "True"
End With
With wb.AddRadioGroup("form1","学历","最高学历")
.Add("本科","本科")
.Add("硕士","硕士")
.Add("博士","博士")
End With
With wb.AddCheckGroup("form1","偏好","品牌偏好")
.Add("苹果","苹果")
.Add("华为","华为")
.Add("三星","三星")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "确定", "submit")
End With
e.WriteString(wb.Build)
Else
Dim nms() As String = {"姓名","年龄","日期","级别"} '不能为空的列名数组
For Each nm As String In nms
If e.Values.ContainsKey(nm) = False Then '生成错误提示页
With wb.addmsgpage("","msgpage","增加失败", nm & "列不能为空!")
.icon = "Warn" '改变图标
.AddButton("btn1","返回").Attribute = ""
End With
e.WriteString(wb.Build)
Return '必须返回
End If
Next
nms = New String() {"姓名","年龄","日期","级别","停权","学历"} '重新定义了nms数组,增加了两列.
Dim dr As DataRow = DataTables("客户").AddNew()
For Each nm As String In nms
If e.Values.ContainsKey(nm) Then
dr(nm) = e.values(nm)
End If
Next
'以下代码处理品牌复选列表项
Dim pp As String
nms = New String() {"苹果","华为","三星"} '将nms重新定义为品牌数组
For Each nm As String In nms
If e.Values.ContainsKey(nm) AndAlso e.Values(nm).Trim() = "on" Then '不能省略Trim
pp = pp & nm & ","
End If
Next
If pp > "" Then
dr("偏好") = pp.Trim(",")
End If
'保存并生成增加成功提示页面
dr.save()
With wb.addmsgpage("","msgpage","增加成功", "好好学习,天天向上") '生成成功提示页
.AddButton("btn1","继续增加","addnew.htm")
End With
e.WriteString(wb.Build)
End If
End Select
[此贴子已经被作者于2016/10/13 11:20:32编辑过]