Dim e As RequestEventArgs = args(0)
Dim wb As New weui
Dim page As Integer = 0 '默认page为0,显示第一页
If e.GetValues.ContainsKey("page") Then '如果地址中有page参数
Integer.TryParse(e.GetValues("page"), page) '提取page参数
End If
If e.PostValues.Count = 0 Then '生成增加订单网页
wb.AddForm("", "form1", "wgcpadd.htm")
Dim gjs As List(Of String) = DataTables("wwgcpfl").sqlGetValues("cpfl")
With wb.AddInputGroup("form1", "ipg1", "外购产品添加")
.AddSelect("cpfl", "产品分类", "|" & String.Join("|", gjs.ToArray)).Attribute = "" '调用js函数。
.AddInput("hh", "货号", "text")
.AddInput("pm", "品名", "text")
.AddInput("cpmc", "产品名称", "text").Placeholder = "必须录入"
.AddInput("bz", "备注", "text")
With wb.AddInputGroup("form1", "ipg3", "产品描述(材质, 尺寸)")
.AddTextArea("cpmx", 5)
End With
With wb.AddInputGroup("form1", "ipg2", "产品图片上传")
With .AddUploader("up128", "", False)
.AllowDelete = True '允许删除
.Incremental = True '允许 重复选择文件或连续拍照
' .AllowAdd = True '可以更改上传
.ScaleWidth = 400 '自动压缩图片宽度为400个像素,高度等比例压缩
End With
With .AddUploader("up129", "", False)
.AllowDelete = True '允许删除
.Incremental = True '允许 重复选择文件或连续拍照
' .AllowAdd = True '可以更改上传
.ScaleWidth = 400 '自动压缩图片宽度为400个像素,高度等比例压缩
End With
End With
End With
With wb.AddButtonGroup("form1", "btg1", True)
' .Add("btn1", "确定", "submit")
.Add("btn1", "确定", "button").Attribute = "" '调用js函数上传
' .Add("btn1", "确定", "button").Attribute = "" '调用js函数上传
' .Add("btn1","返回列表","ddgl.htm")
.Add("mnuCancel", "取消", "", "wgcp.htm?page=" & page)
End With
wb.AddToast("", "tst1", "正在上传", 1)
wb.AddToast("", "tst2", "上传成功", 0)
wb.AddToast("", "tst3", "上传失败", 0).Icon = "warn"
wb.AppendHTML("<script src='./lib/wgcptp.js'></script>") '图片上传压缩用引入脚本文件
wb.AppendHTML("<script src='./lib/brands3.js'></script>") '产品类别产生数据 引入脚本文件
Else '保存新增的订单
' MessageBox.Show ("添加新品")
Dim nms2() As String = {"cpfl", "esthh", "cpmc"} '不能为空的列名数组
For Each nm2 As String In nms2
If e.PostValues.ContainsKey(nm2) = False Then '生成错误提示页
' MessageBox.Show ("资料不完整")
If nm2 = "cpfl" Then
nm2 = "产品分类"
ElseIf nm2 = "hh" Then
nm2 = "号"
ElseIf nm2 = "cpmc" Then
nm2 = "产品名称"
End If
With wb.AddMsgPage("", "msgpage", "增加失败", nm2 & "列不能为空!")
.icon = "Warn" '改变图标
.AddButton("btn1", "返回").Attribute = ""
End With
e.WriteString(wb.Build)
Return Nothing '必须返回
End If
Next
Dim dr5 As DataRow
dr5 = DataTables("wwgcp").SQLFind("[esthh] = '" & e.PostValues("esthh") & "' ")
If dr5 IsNot Nothing Then '如果找到的话
' MessageBox.Show ("添加新品已经存在")
With wb.AddMsgPage("", "msgpage", "增加失败", "新号 " & e.PostValues("esthh") & " 已经存在,此号不能重复!")
.icon = "Warn" '改变图标
.AddButton("btn1", "返回").Attribute = ""
End With
e.WriteString(wb.Build)
Return Nothing '必须返回
End If
' MessageBox.Show ("开始增加产品")
Dim nms() As String = {"cpfl", "hh", "thh", "pm", "cpmc", "cpmx", "cpbz", "cpzx", "cpzxcc", "cpmjz", "moq", "nbdj", "txy", "ypf", "bz", "gys1", "gys2" } '重新定义了nms数组,增加了两列.
Dim dr As DataRow = DataTables("wwgcp").AddNew()
For Each nm As String In nms
If e.PostValues.ContainsKey(nm) Then
dr(nm) = e.PostValues(nm)
End If
Next
For Each key As String In e.Files.Keys
If key = "up128" Then
For Each fln As String In e.Files(key)
e.SaveFile(key, fln, ProjectPath & "Attachments\" & fln)
Next
dr.Lines("tpmc1") = e.Files(key)
End If
If key = "up129" Then
For Each fln As String In e.Files(key)
e.SaveFile(key, fln, ProjectPath & "Attachments\" & fln)
Next
dr.Lines("tpmc2") = e.Files(key)
End If
Next
dr.save()
' MessageBox.Show ("添加新品图片 " & wjll & " ")
' If wjll <> "" Then '二进图片上传
Dim wjll As String = ""
Dim wjll2 As String = ""
Dim dr1 As DataRow = DataTables("wwgcp").SQLFind("esthh='" & e.PostValues("esthh") & "'")
If dr1("tpmc1") <> "" Then
wjll = ProjectPath & "Attachments\" & dr1("tpmc1")
dr1.SQLInsertFile("tp1", wjll) '插入文件
End If
If dr1("tpmc2") <> "" Then
wjll2 = ProjectPath & "Attachments\" & dr1("tpmc2")
dr1.SQLInsertFile("tp2", wjll2) '插入文件
End If
With wb.AddMsgPage("", "msgpage", "外购产品增加成功", "是否再增加") '增加订单成功提示信息
.AddButton("btn1", "继续增加", "wgcpadd.htm")
.AddButton("btn1", "返回列表", "wgcp.htm")
End With
End If
e.WriteString(wb.Build) '生成网页