无法获得Primarykey可以给看一下吗?
现在因为无法获取Primarykey,所以无法从搜索的表格中选择数据以后加到另外一个表中。
Dim e As RequestEventArgs = args(0)
Dim UserCompany As String = e.Cookies("usercompany") '从cookie中获取
Dim gjs As List(of String) = DataTables("SalesPriceCalculation").SQLGetValues("GroupName")
Dim Page As Integer
If e.GetValues.ContainsKey("page") Then
Integer.TryParse(e.GetValues("page"), page)
End If
Dim wb As New weui
wb.AddForm("","form1","")
Dim pgs As String = e.Cookies("page")
Dim odn As String = e.Cookies("orderno")
Dim p As String = "order_edit.htm?page=" & pgs & "&oid=" & odn '返回的页面
For Each r As String In e.PostValues.Keys
msgbox(r)
Next
For Each rr As String In e.GetValues.Keys '现在接受不到这个
msgbox("get:" & rr)
Next
'增加基本页面
With wb.AddInputGroup("form1","ipg1","搜索")
.AddInput("stocklist_orderno","定单编号","text").Value = odn
.AddSelect("stocklist_group","产品组","|" & String.Join("|",gjs.ToArray)).Attribute = "" '调用js函数.
.AddInput("stocklist_product","产品名称","text")
End With
With wb.AddButtonGroup("form1","btg2",False)
.Add("btn22", "搜索", "submit")
.Add("btn11", "返回","",p)
End With
If e.PostValues.Count > 0 Then
Dim group As String
Dim pnm As String
Dim ftl As String
For Each key As String In e.PostValues.Keys
If key = "stocklist_group" Then
group = e.PostValues(Key)
ElseIf key = "stocklist_product" Then
pnm = e.PostValues(Key)
End If
Next
If pnm > "" Then
Dim Names() As String = pnm.Split(" ")
For Each name As String In Names
If name > "" Then
ftl = ftl & "pname_1 Like N'%" & name & "%' or pname_2 Like N'%" & name & "%' and "
End If
Next
ftl = ftl.SubString(0,ftl.Length - 4) '获取关键字
End If
If group > "" Then
If ftl > "" Then
ftl = ftl & " and "
End If
ftl = "GroupName Like N'%" & group & "%'"
End If
Dim ug As String = e.Cookies("usercompany") '从cookie中获取
With wb.AddTable("form1","table2")
Dim nms() As String = {"ID","产品编号","产品名称","采购单价","建议售价"}
.Head.AddRow(nms)
.Highlight = 1 '仅高亮显示行
.PageNumber = 0 '设置页码
If ftl > "" Then
For Each r As DataRow In DataTables("SalesPriceCalculation").SQLSelect(ftl)
With .Body.AddRow(r("pid"),r("pno"),r("pname_2"))
.Primarykey = r("pid") '设置主键
Dim amt As Double = 0
amt = Functions.Execute("计算客户价格网页用",e,r("pid"),ug)
.AddCell(Format (amt,"#,###"))
.AddCell(r("RetailPrice"))
End With
Next
End If
End With
End If
'主键传递
Dim idx As String
If e.GetValues.ContainsKey("ospa") Then '如果含产品id,增加详情
'如果含主键就增加数据到详情页
idx = e.GetValues("ospa")
Dim pr As DataRow = DataTables("order_add_dtail").SQLAddNew()
Dim dr1 As DataRow = DataTables("SalesPriceCalculation").SQLFind("pid = '" & idx & "'")
If dr1 IsNot Nothing Then
pr("OrderNo") = odn
pr("pid") = dr1("pid")
pr("pno") = dr1("pno")
pr("pname") = dr1("pname_2")
pr.save
End If
End If
With wb.AddButtonGroup("form1","btg31",False)
.Add("btnAdd", "增加产品").Attribute = ""
End With
'显示定单明细
If odn > "" Then
Dim srs As List(of DataRow) '订单明细集合
srs = DataTables("order_add_dtail").SQLSelect("OrderNo='" & odn & "'") '获取订单明细
With wb.AddTable("form1","listtable")
.head.AddRow("产品","单价")
.Highlight = 1 '高亮显示行
For Each sr As DataRow In srs
With .Body.AddRow(sr("pname"),sr("price"))
.Primarykey = sr("_Identify") '为此行指定主键值
End With
Next
End With
End If
wb.AppendHTML("<script src='./lib/order.js'></script>") '引入脚本文件
wb.AppendHTML("<script src='./lib/product_group.js'></script>") '引入脚本文件
e.WriteString(wb.Build) '生成网页
js的名称为order.js
代码为
function ospAdd(){
location="order_search_product.htm?page=" + table2.pagenumber + "&ospa=" + table2.primarykey;
}