以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  保存问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=106896)

--  作者:刘林
--  发布时间:2017/9/17 20:57:00
--  保存问题
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
If e.PostValues.Count = 0 Then \'分组统计设置
    wb.AddForm("","form1","sjzd.htm")
    With wb.AddInputGroup("form1","ipg1","选择学期")
        .AddSelect("学期","学期","|17秋|18春")
    End With
    With wb.AddButtonGroup("form1","btg1",False)
        .Add("btn1", "确定", "submit")
        .Add("btn1", "返回").Attribute = ""
    End With
Else \'显示统计结果
    Dim dr As DataRow = DataTables("用户").sqlfind("身份证号 = \'" & e.Cookies("username") & "\'")
    Dim pr As DataRow = DataTables("试卷征订").sqlfind("学校名称 =\'" & dr("group") & "\' and 学期 = \'" & e.PostValues("学期") & "\'")
    If pr Is Nothing
        pr = DataTables("试卷征订").AddNew()
        pr("学校名称") = dr("group")
        pr("学期")= e.PostValues("学期")
        pr.save()
    End If
    wb.AppendCookie("sjzdid",pr("_Identify"))
MessageBox.show(e.Cookies("sjzdid"))
    With wb.AddInputGroup("","ipg2","输入各年级试卷数")
        .AddInput("一年级","一年级","number").Value = pr("一年级")
        .AddInput("二年级","二年级","number").Value = pr("二年级")
        .AddInput("三年级","三年级","number").Value = pr("三年级")
        .AddInput("四年级","四年级","number").Value = pr("四年级")
        .AddInput("五年级","五年级","number").Value = pr("五年级")
        .AddInput("六年级","六年级","number").Value = pr("六年级")
        .AddInput("六年级","六年级","number").Value = pr("六年级")
        .AddInput("七年级","七年级","number").Value = pr("七年级")
        .AddInput("八年级","八年级","number").Value = pr("八年级")
        .AddInput("九年级","九年级","number").Value = pr("九年级")
    End With
    With wb.AddButtonGroup("","btg1", False)  \'水平排列
        .Add("btn6", "确定保存","submit","sjzdsave.htm")
        .Add("btn7", "返回列表","button","xlist.htm")
    End With
   End If
e.WriteString(wb.Build)


sjzdsave:

Dim e As RequestEventArgs = args(0)
Dim  wb As New weui
Dim dr As DataRow
dr = DataTables("试卷征订").sqlfind("[_Identify] = \'" & e.Cookies("sjzdid") & "\'")
Dim nms() As String = {"一年级","二年级","三年级","四年级","五年级","六年级","七年级","八年级","九年级"} \'不能为空的列名数组
messagebox.show(e.PostValues("七年级"))
For Each nm As String In nms
    If e.PostValues.ContainsKey(nm) Then
        dr(nm) = e.PostValues(nm)
    End If
Next
dr.Save()
\'wb.AddToast("","t1", "已经保存",0).Msec= 1500
With wb.AddMsgPage("","msgpage","提交申请成功", "教研室已查收")
    .icon = "success" \'改变图标
    .AddButton("btn1","返回").Attribute = ""
End With
e.WriteString(wb.Build)


老师,请问上面代码保存不起一年级,二年级各年级数据呢

--  作者:有点甜
--  发布时间:2017/9/17 21:46:00
--  

跳转到保存的页面了吗?加入msgbox测试是否执行了里面的代码。

 

再有就是,你用的是sqlfind,保存后你要刷新同步表格才能看到最新的记录。

 


--  作者:刘林
--  发布时间:2017/9/18 7:14:00
--  
跳转到了的,保存提示都提示了,另外就是刷新后也没有保存值,
messagebox.show(e.PostValues("七年级"))用这个查show空值呢,实际是录了数据的,请老师帮查一下什么原因

--  作者:有点甜
--  发布时间:2017/9/18 9:21:00
--  
Else \'显示统计结果
    wb.AddForm("","form1","sjzdsave.htm")
    Dim dr As DataRow = DataTables("用户").sqlfind("身份证号 = \'" & e.Cookies("username") & "\'")
    Dim pr As DataRow = DataTables("试卷征订").sqlfind("学校名称 =\'" & dr("group") & "\' and 学期 = \'" & e.PostValues("学期") & "\'")
    If pr Is Nothing
        pr = DataTables("试卷征订").AddNew()
        pr("学校名称") = dr("group")
        pr("学期")= e.PostValues("学期")
        pr.save()
    End If
    wb.AppendCookie("sjzdid",pr("_Identify"))
    With wb.AddInputGroup("form1","ipg2","输入各年级试卷数")
        .AddInput("一年级","一年级","number").Value = pr("一年级")
        .AddInput("二年级","二年级","number").Value = pr("二年级")
        .AddInput("三年级","三年级","number").Value = pr("三年级")
        .AddInput("四年级","四年级","number").Value = pr("四年级")
        .AddInput("五年级","五年级","number").Value = pr("五年级")
        .AddInput("六年级","六年级","number").Value = pr("六年级")
        .AddInput("六年级","六年级","number").Value = pr("六年级")
        .AddInput("七年级","七年级","number").Value = pr("七年级")
        .AddInput("八年级","八年级","number").Value = pr("八年级")
        .AddInput("九年级","九年级","number").Value = pr("九年级")
    End With
    With wb.AddButtonGroup("form1","btg1", False)  \'水平排列
        .Add("btn6", "确定保存","submit")
        .Add("btn7", "返回列表","button","xlist.htm")
    End With