Dim e As RequestEventArgs = args(0) Dim wb As new weui If e.postvalues.count = 0 Then wb.addform("","form1","xxsc.htm") With wb.AddRadioGroup("form1","xxgxfl","供需分类") .Add("供给","供给") ',True) .Add("需求","需求") End With With wb.AddCheckGroup("form1","xxnrfl","内容分类") .Add("劳务供需","劳务供需") ', True) '默认勾选 .Add("不动产供需","不动产供需") .Add("二手供需","二手供需") .Add("社区公益","社区公益") '.Enabled = False '此项不可选 .add("生活消费品供需","生活消费品供需") .add("商家促销活动","商家促销活动") .add("其他","其他") End With With wb.AddInputGroup("form1","ipg1","你的新信息") .AddTextArea("xxinfo",10).Placeholder = "请输入200字以内的文字信息" .AddInput("xxtimeout","有效时限截止:","date") With .AddUploader("up2","添加图片",True) 'True表示允许一次上传多个文件 .TextPosition = 0 '标题靠左 .Accept = "image/*" '允许使用相册和相机 .AllowDelete = True '允许用户删除图片 .Incremental = True '允许重复选择文件或连续拍照 End With End With With wb.AddButtonGroup("form1","btg1",False) .Add("btn1", "确定", "button").Attribute= "" '调用js函数上传 ' .add ("btn1", "确定", "submit") End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功,待审核",0) wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src='./lib/ajaxform.js'></script>") '引入脚本文件 e.WriteString(wb.Build) Else Dim nms() As String = {"xxgxfl","xxinfo","xxtimeout"} '不能为空的列名数组 For Each nm As String In nms If e.PostValues.ContainsKey(nm) = False Then '生成错误提示页 With wb.AddMsgPage("","msgpage","您的信息上传未成功", "供需分类|信息内容|有效时限均不能为空!") .icon = "Warn" '改变图标 ' .AddButton("btn1","返回","reset").Attribute = "" .AddButton("btn1","返回").Attribute = "" End With e.WriteString(wb.Build) Return "" '必须返回 End If Next Dim nms5 = New String() {"劳务供需","不动产供需","二手供需","社区公益","生活消费品供需","商家促销活动","其他"} Dim hasxxnrfl As Boolean For Each nm As String In nms5 If e.PostValues.ContainsKey(nm) Then '生成错误提示页 hasxxnrfl = True Exit For End If Next If hasxxnrfl = False With wb.AddMsgPage("","msgpage","您的信息上传未成功", "内容分类不能为空!") .icon = "Warn" '改变图标 .AddButton("btn1","返回").Attribute = "" End With e.WriteString(wb.Build) Return "" '必须返回 End If nms = New String() {"xxgxfl","xxinfo","xxtimeout"} Dim dr As DataRow = DataTables("gxxxtbl").AddNew() '以下代码上传保存图片 For Each key As String In e.Files.Keys Dim pctn As String If key = "up2" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "web\pict\" & fln) ' pctn = pctn & fln &"," Next ' If pctn > "" Then dr.lines("xxinfopct") = e.files(key) ' End If End If Next dr("cxinfodate") = Date.Today '给信息表新增行的"发布日期"单元格赋值 dr("xxfbz") = e.Cookies("userid") '给信息表新增行的"发布者"单元格赋值 For Each nm As String In nms If e.PostValues.ContainsKey(nm) Then dr(nm) = e.PostValues(nm) End If Next '编码生成信息id Dim d As Date = Date.Now Dim bms As String = cstr(d) bms = bms.Replace("-","") bms = bms.Replace(" ","") bms = bms.Replace(":","") dr("cxinfoid") = bms & "d" & e.Cookies("userid") '自动生成信息id,赋值给信息表新增行的"信息编码"单元格 '以下代码处理信息内容分类复选列表项 Dim nrfl As String Dim nrs As List (of String) nrs = DataTables("xxnrtbl").GetValues("xxnrfl") For Each nr As String In nrs If e.PostValues.ContainsKey(nr) AndAlso e.PostValues(nr).Trim() = "on" Then '不能省略Trim nrfl = nrfl & nr & "," End If Next If nrfl > "" Then dr("xxnrfl") = nrfl.Trim(",") '赋值给信息表的新增行的"内容分类"单元格 End If '保存并生成增加成功提示页面 dr.save() With wb.AddMsgPage("","msgpage","上传成功,等待审核!", "") '生成成功提示页 .AddButton("btn1","返回","yh.htm") End With e.WriteString(wb.Build) End If
|