Dim e As RequestEventArgs = args(0) '注册第1页,注册
Select Case e.Path
Case "register.htm"
Dim wb As New weui
If e.PostValues.Count = 0 Then
wb.AddPageTitle("","pageheader","xxx","xxxxxxxxxxxxxxxxxxx")
wb.AddForm("","form1","register.htm")
With wb.AddInputGroup("form1","ipg1","快速注册")
With .AddInputCell("ic1") '通过InputCell增加输入框(1表示突出显示,2表示红色警示图标)
.AddLabel("lsj","手机",0) '增加标签(0显示在左边)
.AddInput("isj","text",1).PlaceHolder= "请输入手机号" '增加输入框(0靠左显示,1居中显示,2靠右显示)
End With
With .AddInputCell("ic2")
.AddLabel("lyz","验证",0)
.AddInput("iyz","text",1).PlaceHolder= "请输入验证码"
.AddVcodeButton("vyz","获取验证码",2) '0靠左显示,1居中显示,2靠右显示
End With
With .AddInputCell("ic3")
.AddLabel("lmm","密码",0)
.AddInput("imm","text",1).PlaceHolder= "请输入密码"
End With
.AddSelect("sxb","性别","|男|女")
.AddSwitch("fuwuxieyi","同意协议")
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "注册", "submit")
.Add("btn1", "查看服务协议", "","/fillout.htm").Kind = 1
End With
End With
e.WriteString(wb.Build)
Else
Dim nms() As String = {"isj","imm","sxb","fuwuxieyi"} '不能为空的列名数组
Dim nms2() As String = {"手机","密码","性别","同意协议" } '重新定义了nms数组,增加了两列.
For i As Integer = 0 To nms.Length - 1
If i = 0 Then
If e.PostValues.ContainsKey(nms(i)) = False Then '提示手机列不能为空
With wb.AddMsgPage("","msgpage","增加失败", nms2(i) & "列不能为空!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
Dim num As String = e.PostValues("isj")
If num > "" AndAlso num.Length <> 11 Then '提示手机号码必须为11位
With wb.AddMsgPage("","msgpage","增加失败", "手机号码必须为11位!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
If num > "" AndAlso num.Length = 11 Then '提示手机重复,不能注册
Dim dr As DataRow = DataTables("会员资料").Find("手机 = '" & num & "'")
If dr IsNot Nothing Then
With wb.AddMsgPage("","msgpage","增加失败", "手机号码已被注册,请更换手机!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
End If
ElseIf i = 1 Then
If e.PostValues.ContainsKey(nms(i)) = False Then '提示密码列不能为空
With wb.AddMsgPage("","msgpage","增加失败", nms2(i) & "列不能为空!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
Dim psw As String = e.PostValues("imm") '提示密码列长度为6~10位
If psw > "" AndAlso (psw.Length > 10 OrElse psw.Length < 6) Then
With wb.AddMsgPage("","msgpage","增加失败", "密码长度为6~10位!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
ElseIf i = 2 Then
If e.PostValues.ContainsKey(nms(i)) = False Then '提示性别列不能为空
With wb.AddMsgPage("","msgpage","增加失败", nms2(i) & "列不能为空!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
ElseIf i = 3 Then
If e.PostValues.ContainsKey(nms(i)) = False Then '希望这里判断value值是不是on,如果是,才可以注册,不是提示是不是为空,该怎么处理?
With wb.AddMsgPage("","msgpage","增加失败", nms2(i) & "列不能为空!")
.icon = "Warn"
.AddButton("btn1","返回","register.htm") ‘返回后,怎么样才能回到原来填入内容的页面
End With
e.WriteString(wb.Build)
Return ""
End If
End If
Next
Dim dr As DataRow = DataTables("会员资料").AddNew() ’“会员资料”表有编号列,希望为会员设置编号,从1001开始,每次增加+1,怎么样实现?
For i As Integer = 0 To nms.Length - 1
If e.PostValues.ContainsKey(nms(i)) Then
dr(nms2(i)) = e.PostValues(nms(i))
End If
Next
'保存并生成增加成功提示页面
dr.save()
wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转页面
End If
End Select