Foxtable(狐表)用户栏目专家坐堂 → e.GetValues的问题


  共有2521人关注过本帖树形打印复制链接

主题:e.GetValues的问题

帅哥哟,离线,有人找我吗?
zenbu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
e.GetValues的问题  发帖心情 Post By:2019/5/6 14:51:00 [显示全部帖子]

无法获得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; 
}

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 15:01:00 [显示全部帖子]

弹出的还是123

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 15:08:00 [显示全部帖子]

PostValues是正常,所以需要搜索的产品也好产品组也好都正常,但是GetValues的参数无法获得

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 15:30:00 [显示全部帖子]

是的,是ospAdd 函数没有被执行
是需要搜索到产品以后产生一个表格,选择这个表格中的数据以后按增加产品以后再执行ospAdd函数
目的是把找到的产品数据加入到另外一个表中

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 16:01:00 [显示全部帖子]

重新式了一下JS中代码弹出正确,有主键
order_search_product.htm?page=0&ospa=PID-19041500521

但是再代码中无法接受
For Each tt As String In e.GetValues.Keys
msgbox(tt)
Next

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 16:21:00 [显示全部帖子]

现在的页面是http://127.0.0.1/order_search_product.htm
要返回的页面是http://127.0.0.1/order_search_product.htm?page=0&ospa=PID-19041500521

是因为这个原因无法获得primarykey吗?

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 16:29:00 [显示全部帖子]

msgbox(123) 1次
msgbox(e.values.count)  搜索时2,按下增加产品后1次
msgbox(e.values("ospa"))  始终是空

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 17:12:00 [显示全部帖子]

无法添加附件
代码抄一下吧
内部函数部分


'''
Dim e As RequestEventArgs = args(0)
msgbox(123)
msgbox(e.values.count)
msgbox(e.values("ospa"))

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 rr As String In e.GetValues.Keys  '现在接受不到这个
    msgbox("get:" & rr)
Next
'增加基本页面
With wb.AddInputGroup("form1","ipg1","搜索产品")
    .AddInput("stocklist_orderno","定单编号","text").Value = odn  '从Cookies引用
    .AddSelect("stocklist_group","选择组","|" & String.Join("|",gjs.ToArray)).Attribute = ""  '调用js函数.
    .AddInput("stocklist_product","产品名称","text")
End With

With wb.AddButtonGroup("form1","btg1",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","osptable")
        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","btg2",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) '生成网页

 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 17:12:00 [显示全部帖子]

JS部分,JS文件名是order.js

function edit(){
   location="order_edit.htm?page=" + table1.pagenumber + "&oid=" + table1.primarykey; 
}

function del(){
   location="order_ls_list.htm?page=" + table1.pagenumber + "&deloid=" + table1.primarykey; 
}

function pno(){
   location="order_edit.htm?page=" + table1.pagenumber + "&newpno=" + table1.primarykey; 
}

function addnew(){
   location="order_edit.htm?page=" + table1.pagenumber;
}

function addDetail(){
   location=form1.action + "&addnext=true";
}

function editDetail(){
   location = form1.action + "&did=" + detailtable.primarykey;
}

function delDetail() {
   location = form1.action + "&deldid=" + detailtable.primarykey;
}

function calc(){
   document.getElementById("vat").value = document.getElementById("qty").value * document.getElementById("price").value *0.1;
document.getElementById("amount").value = document.getElementById("qty").value * document.getElementById("price").value + (document.getElementById("vat").value - document.getElementById("sale").value);
document.getElementById("lr").value = document.getElementById("amount").value - document.getElementById("yj").value * document.getElementById("qty").value;
}

function ospAdd(){
   alert("order_search_product.htm?page=" + osptable.pagenumber + "&ospa=" + osptable.primarykey);
   location="order_search_product.htm?page=" + osptable.pagenumber + "&ospa=" + osptable.primarykey; 
}


 回到顶部
帅哥哟,离线,有人找我吗?
zenbu
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:166 积分:1946 威望:0 精华:0 注册:2012/12/26 15:47:00
  发帖心情 Post By:2019/5/6 17:14:00 [显示全部帖子]

HttpRequest部分

    Case "order_edit.htm"
        If e.PostValues.Count > 0 Then
            Functions.Execute("order_ls_save",e)
        End If
        Functions.Execute("order_edit",e)    
    Case "order_search_product.htm"
        Functions.Execute("order_search_product",e)
    Case "order_ls_list.htm"
        Functions.Execute("order_ls_list",e)

 回到顶部
总数 14 1 2 下一页