以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]保存问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=176572)

--  作者:cd_tdh
--  发布时间:2022/4/18 17:31:00
--  [求助]保存问题

老师我网页逻辑如下:

先生成列表,生成下面页面:


图片点击可在新窗口打开查看此主题相关图片如下:11.jpg
图片点击可在新窗口打开查看

点击出场登记,生成下面页面:


图片点击可在新窗口打开查看此主题相关图片如下:22.jpg
图片点击可在新窗口打开查看

然后修改出场日期,点击保存不了,哪儿问题呢,代码如下:

Dim e As object = args(0)
\'Dim e As RequestEventArgs = args(0)
Dim wb As New weui
Dim dr As DataRow = DataTables("实名制管理").SQLFind("项目名称 = \'" & _Userxmmc & "\' and 姓名 = \'" & e.getvalues("name") & "\'")
If dr IsNot Nothing Then
    If e.PostValues.Count = 0 Then
        wb.AddForm("","form1","ReNamejccx_name.htm")
        With wb.AddInputGroup("form1","工人信息","工人信息")
            With .AddInput("姓名","姓  名","Text")
                .Value = dr("姓名")
                .Readonly= True
            End With
            With .AddInput("身份证号码","身份证号","number")
                .Value = dr("身份证号码")
                .Readonly= True
            End With
            With .AddInput("家庭地址","家庭地址","Text")
                .Value = dr("家庭地址")
                .Readonly= True
            End With
            With .AddInput("进场日期","进场日期","date")
                .Value = dr("进场日期")
                .Readonly= True
            End With
            .AddInput("退场日期","退场日期","date")
            .AddInput("退场登记人","退场登记人","Text")
            .AddInput("退场登记日期","退场登记日期","date")
        End With
        With wb.AddButtonGroup("form1","btg2", True)
            .Add("btn1", "重新查询", "", "ReNamejccx.htm")
            .Add("btn2", "保  存", "submit")
        End With
        e.WriteString(wb.Build)
    Else
        Dim nms() As String = {"退场日期","退场登记人","退场登记日期"} \'不能为空的列名数组
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) = False Then \'生成错误提示页
                With wb.AddMsgPage("","msgpage","保存失败", nm & "列不能为空!")
                    .icon = "Warn" \'改变图标
                    .AddButton("btn1","返回").Attribute = ""
                End With
                e.WriteString(wb.Build)
                Return Nothing \'必须返回
            End If
        Next
        nms = New String() {"退场日期","退场登记人","退场登记日期"}  \'重新定义了nms数组,增加了两列.
        Dim ds As DataRow = DataTables("实名制管理").SQLFind("项目名称 = \'" & _Userxmmc & "\' and 姓名 = \'" & e.getvalues("name") & "\'")
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                ds(nm) = e.PostValues(nm)
            End If
        Next
        ds.save()
        \'保存并生成增加成功提示页面
        With wb.AddMsgPage("","msgpage","保存成功", "你是否继续修改其他人员退场信息") \'生成成功提示页
            .AddButton("btn2","返回首页","default.htm")
            .AddButton("btn1","继续修改","ReNamejccx.htm")
        End With
        e.WriteString(wb.Build)
    End If
End If


 


--  作者:有点蓝
--  发布时间:2022/4/18 17:38:00
--  
调试看哪些代码执行了,哪些没有执行?
--  作者:cd_tdh
--  发布时间:2022/4/18 19:16:00
--  
保存按钮后的代码都没执行,点击保存,弹出的是上个页面查询没有数据的提示页面
--  作者:有点蓝
--  发布时间:2022/4/18 20:08:00
--  
很多人基本都不会做调试,或者是懒得写调试代码

Dim e As object = args(0)
\'Dim e As RequestEventArgs = args(0)
Dim wb As New weui
msgbox(name=” & e.getvalues("name"))
Dim dr As DataRow = DataTables("实名制管理").SQLFind("项目名称 = \'" & _Userxmmc & "\' and 姓名 = \'" & e.getvalues("name") & "\'")
msgbox(dr IsNot Nothing)
If dr IsNot Nothing Then
msgbox(e.PostValues.Count=” & e.PostValues.Count)
    If e.PostValues.Count = 0 Then
msgbox(1)
        wb.AddForm("","form1","ReNamejccx_name.htm")
        With wb.AddInputGroup("form1","工人信息","工人信息")
            With .AddInput("姓名","姓  名","Text")
                .Value = dr("姓名")
                .Readonly= True
            End With
            With .AddInput("身份证号码","身份证号","number")
                .Value = dr("身份证号码")
                .Readonly= True
            End With
            With .AddInput("家庭地址","家庭地址","Text")
                .Value = dr("家庭地址")
                .Readonly= True
            End With
            With .AddInput("进场日期","进场日期","date")
                .Value = dr("进场日期")
                .Readonly= True
            End With
            .AddInput("退场日期","退场日期","date")
            .AddInput("退场登记人","退场登记人","Text")
            .AddInput("退场登记日期","退场登记日期","date")
        End With
        With wb.AddButtonGroup("form1","btg2", True)
            .Add("btn1", "重新查询", "", "ReNamejccx.htm")
            .Add("btn2", "保  存", "submit")
        End With
        e.WriteString(wb.Build)
    Else
msgbox(2)
        Dim nms() As String = {"退场日期","退场登记人","退场登记日期"} \'不能为空的列名数组
        For Each nm As String In nms
msgbox("nm=" & nm)
            If e.PostValues.ContainsKey(nm) = False Then \'生成错误提示页
msgbox("错误")
                With wb.AddMsgPage("","msgpage","保存失败", nm & "列不能为空!")
                    .icon = "Warn" \'改变图标
                    .AddButton("btn1","返回").Attribute = ""
                End With
                e.WriteString(wb.Build)
                Return Nothing \'必须返回
            End If
        Next
        nms = New String() {"退场日期","退场登记人","退场登记日期"}  \'重新定义了nms数组,增加了两列.
        Dim ds As DataRow = DataTables("实名制管理").SQLFind("项目名称 = \'" & _Userxmmc & "\' and 姓名 = \'" & e.getvalues("name") & "\'")
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                ds(nm) = e.PostValues(nm)
            End If
        Next
        ds.save()
        \'保存并生成增加成功提示页面
        With wb.AddMsgPage("","msgpage","保存成功", "你是否继续修改其他人员退场信息") \'生成成功提示页
            .AddButton("btn2","返回首页","default.htm")
            .AddButton("btn1","继续修改","ReNamejccx.htm")
        End With
        e.WriteString(wb.Build)
    End If
End If

这段代码是哪个页面的?"ReNamejccx_name.htm"?还是"ReNamejccx.htm"?

--  作者:cd_tdh
--  发布时间:2022/4/19 8:25:00
--  

这段代码是ReNamejccx_name.htm页面的,生成页面的时候弹出的都是正确的值,保存的时候弹出name=  ,msgbox(dr IsNot Nothing)为False,后面代码都没执行了

如果不要这一句:If dr IsNot Nothing Then,后面代码都执行了,但是最后报错:

   


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20220419083421.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2022/4/19 8:35:47编辑过]

--  作者:有点蓝
--  发布时间:2022/4/19 8:46:00
--  
不但不会调试,连怎么看调试结果也不会。

弹出name=  说明【e.getvalues("name")】没有值,也就是提交再次进入这个页面的时候没有添加get参数

wb.AddForm("","form1","ReNamejccx_name.htm?name=" & e.getvalues("name"))

--  作者:cd_tdh
--  发布时间:2022/4/19 8:53:00
--  

老师,生成ReNamejccx.htm页面时,出场日期为空时,显示的是00:00:00,怎么让它不显示00:00:00

            txt = txt & "<p>进场日期:" & dr("进场日期") & "&ensp; &ensp; &ensp;退场日期:" & dr("退场日期") & "</p>"

[此贴子已经被作者于2022/4/19 8:58:26编辑过]

--  作者:有点蓝
--  发布时间:2022/4/19 9:42:00
--  
帮助搜“格式化日期和时间”
--  作者:cd_tdh
--  发布时间:2022/4/19 10:37:00
--  
格式化显示出来是:0001-01-01啊
--  作者:有点蓝
--  发布时间:2022/4/19 10:40:00
--  
帮助搜“空值”,学会处理空值