以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  weui代码错误,请老师帮把把脉!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=149532)

--  作者:foxtablefanse
--  发布时间:2020/5/5 14:26:00
--  weui代码错误,请老师帮把把脉!
编译错误:function、get或operator中的retun语句 必须返回值

Dim e As RequestEventArgs = args(0)
Select Case e.Path
    Case "addludan.htm"
        Dim wb As New weui
        Dim chp As List(of String) = DataTables("ZL_车辆信息").SQLGetValues("牌照号")
        Dim zhucao As List(of String) = DataTables("RL_员工档案").SQLGetValues("姓名","当前_岗位 in (\'010105\',\'010106\')","姓名 Desc")
        Dim zhihui As List(of String) = DataTables("RL_员工档案").SQLGetValues("姓名","当前_岗位 in (\'010105\',\'010106,010107\')","姓名 Desc")
        
        wb.AddForm("","form1","handle.htm") \'指定接收表单数据的的页面为handle.htm
        With wb.AddInputGroup("form1","ipg1","新增路单")
            .AddInput("LdName","姓  名:","text").Value=e.Cookies("uname")
            .AddSelect("MonthOrDay","用车形式:","台班|包月")
            .AddSelect("VehicleSource","车辆来源:","自有|外协")
            .AddSelect("PlateNumber","牌 照 号:","|" & String.Join("|",chp.ToArray))
            .AddInput("WorkUnit","用车单位:","text")
            .AddInput("WorkUnit2","二级单位:","text")
            .AddInput("WorkSite","用车地点:","text")
            .AddInput("WorkContent","作业内容:","text")
            .AddInput("BeganDate","开始时间:","datetime-local")
            .AddInput("EndDate","结束时间:","datetime-local")
            .AddSelect("FirstOperator","主  操:","|" & String.Join("|",zhucao.ToArray))
            .AddSelect("DeputyOperator","副  操:","|" & String.Join("|",zhucao.ToArray))
            .AddSelect("FirstCommander","主  指  挥:","|" & String.Join("|",zhihui.ToArray))
            .AddSelect("DeputyCommander","副  指  挥:","|" & String.Join("|",zhihui.ToArray))
            .AddSelect("SettlementModes","结账方式:","签单|现金")
            .AddInput("CashAmount","现金金额:","number").Step = "0.01"
            .AddInput("SigningHours","签单时长:","number").Step = "0.1"
            .AddSelect("ChargVehicle","计费车型:","8|16|20|25|35|50|75|100|130|160|200|220|260|300|350")
            With wb.AddInputGroup("form1","ipg2","备 注:")
                .AddTextArea("Remarks",5).Placeholder = "请输入200字以内的备注"
            End With
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1", "确定", "button").Attribute= ""
        End With
        With wb.AddDialog("","dlg1", "提示","增加路单成功,是否继续增加?") \'增加订单成功提示框
            .AddButton("btnYes","是").Attribute = ""
            .AddButton("btnNo","否","http://www.anqy.work/index.htm").Kind = 1
        End With
        With wb.AddDialog("","dlg2", "错误","") \'增加订单失败提示框
            .AddButton("btnOK","确定")
        End With
        wb.AppendHTML("<script src=\'./lib/ldadd_ajaxform.js\'></script>") \'引入脚本文件
        e.WriteString(wb.Build)
    Case "handle.htm"
        Dim nms() As String = {"LdName","MonthOrDay","VehicleSource","PlateNumber","WorkUnit","WorkUnit2","WorkSite","WorkContent","BeganDate","EndDate","FirstOperator","DeputyOperator","DeputyOperator","FirstCommander","DeputyCommander","SettlementModes","CashAmount","SigningHours","ChargVehicle","Remarks"}
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) = False Then
                e.WriteString("请输入" & nm & "!") \'返回错误消息
                Return \'必须返回
            End If
        Next
        Dim dr As DataRow = DataTables("yw_ld").AddNew()
        For Each nm As String In nms
            dr(nm) = e.PostValues(nm)
        Next
        dr.Save()
        e.WriteString("OK") \'返回增加成功消息
End Select



[此贴子已经被作者于2020/5/5 14:41:49编辑过]

--  作者:有点蓝
--  发布时间:2020/5/5 14:30:00
--  
什么错误?什么问题?http://www.foxtable.com/webhelp/topics/1485.htm
--  作者:foxtablefanse
--  发布时间:2020/5/5 15:09:00
--  
编译错误:function、get或operator中的Return 语句 必须返回值
 Return 后面应返回什么值?
改 Return 0 后,点提交提示找不到handle.htm网页,
我是照http://www.foxtable.com/mobilehelp/index.htm?page=0257.htm例子写的
[此贴子已经被作者于2020/5/5 15:11:30编辑过]

--  作者:有点蓝
--  发布时间:2020/5/5 15:31:00
--  
Case "handle.htm"下面整段代码放到httprequest里面,或者httprequest改为

Select Case e.Path
    Case "addludan.htm","handle.htm"
Functions.Execute("1楼代码所在的函数名称",e)

--  作者:foxtablefanse
--  发布时间:2020/5/5 19:08:00
--  
数据添加成功,但是dr.save()没有执行
--  作者:有点蓝
--  发布时间:2020/5/5 20:55:00
--  
学会调试:http://www.foxtable.com/webhelp/topics/1485.htm

msgbox(1)
dr.save()
msgbox(2)
如果2个提示框都能弹出肯定就执行了

--  作者:foxtablefanse
--  发布时间:2020/5/5 21:25:00
--  
正是这样测试的,没有弹框


--  作者:有点蓝
--  发布时间:2020/5/5 21:27:00
--  
js文件内容发上来

.AddButton("btnYes","是").Attribute = ""这里代码补全发上来

--  作者:foxtablefanse
--  发布时间:2020/5/6 8:34:00
--  
 dr.save()前后弹窗了,dr.save()应该执行了,但是数据还是处于新增状态。


With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1", "确定", "button").Attribute= "on  click=\'myfunction()\' "
        End With
        With wb.AddDialog("","dlg1", "提示","增加路单成功,是否继续增加?") \'增加订单成功提示框
            .AddButton("btnYes","是").Attribute = ""
            .AddButton("btnNo","否","http://www.anqy.work/index.htm").Kind = 1
        End With
        With wb.AddDialog("","dlg2", "错误","") \'增加订单失败提示框
            .AddButton("btnOK","确定")
        End With


ldadd_ajaxform.js:

function myfunction(){
    var result = submitAjaxForm(\'form1\',\'\',false);
    if (result ==\'OK\') {show(\'dlg1\')}
    else {showDialog(\'dlg2\',\'错误\',result)}
}
[此贴子已经被作者于2020/5/6 8:54:04编辑过]

--  作者:有点蓝
--  发布时间:2020/5/6 8:54:00
--  
dr.save()如果执行了肯定保存了,除非这个表是临时表或者查询表。到后台数据库看看有数据