以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于订单例子增加明细独立页面后,订单主表保存问题?已解决 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=162957) |
-- 作者:YUNSEL -- 发布时间:2021/4/18 16:12:00 -- 关于订单例子增加明细独立页面后,订单主表保存问题?已解决 我把帮助中手机订单的例子,改了一下,把【增加明细】单独成本个独立界面了,并且取消了save函数,现在发现一个问题,主表只有保存了订单号与日期字段,其他的都没有保存下来。下面是edit函数的代码,老师帮忙看下问题在哪儿?谢谢! Dim e As RequestEventArgs = args(0) Dim wb As New weui \'删除订单明细 If e.GetValues.ContainsKey("deldid") Then DataTables("订单明细").SQLDeleteFor("[zid] = " & e.GetValues("deldid")) End If Dim Page As Integer \'页码变量 If e.GetValues.ContainsKey("page") Then \'如果地址中有page参数 Integer.TryParse(e.GetValues("page"), page) \'提取page参数 End If Dim dr As DataRow \'订单 Dim drs As List(of DataRow) \'订单明细集合 If e.GetValues.ContainsKey("oid") = False Then \'如果没有传递订单编号,则新增与一个订单 dr = DataTables("订单").AddNew() \' dr("订单编号") = Functions.Execute("GetOrderID") \'利用自定义函数GetOrderID为新增订单生成编号. dr("日期") = Date.Today() dr.Save Else \'如果传递了订单编号,则找出此订单进行编辑 dr = DataTables("订单").SQLFind("订单编号=\'" & e.GetValues("oid") & "\'") If dr Is Nothing Then \'多用户情况下,必须考虑其他用户删除订单的可能. wb.InSertHtml("此订单已被其他用户删除!") e.WriteString(wb.Build) Return "" \'必须返回 End If drs = DataTables("订单明细").SQLSelect("ID=\'" & dr("ID") & "\'") \'获取订单明细 End If Dim url As String = "edit.htm?page=" & page & "&oid=" & e.GetValues("oid") \'传递页码和订单编号 Dim PageURL = "List.htm?page=" & Page wb.AddForm("","form1",url) With wb.AddInputGroup("form1","ipg1",iif(e.GetValues.ContainsKey("oid"),"编辑订单","新增订单")) With .AddInput("订单编号","编号","text") .Value = dr("订单编号") .Readonly = True End With .AddInput("客户","客户","text").Value = dr("客户") If drs IsNot Nothing Then .AddInput("日期","日期","date").Value = dr("日期") Dim qty As Integer Dim amt As Integer For Each sr As DataRow In drs qty = qty + sr("数量") amt = amt + sr("数量") * sr("单价") Next .AddInput("总数量","总数量","number").value = qty .AddInput("总金额","总金额","number").value = amt Else .AddInput("总数量","总数量","number") .AddInput("总金额","总金额","number") End If End With \'生成订单明细表格 If e.GetValues.ContainsKey("oid") AndAlso drs.count > 0 Then \'如果不是新增订单,且订单明细行数大于0,则生成订单明细表格. With wb.AddTable("form1","detailTable") \'为了区分,明细表的名字设为detailTable .head.AddRow("物料名称","数量","单价","金额") .ActiveSheet = "menu" \'指定菜单 For Each sr As DataRow In drs With .Body.AddRow(sr("物料名称"),sr("数量"),sr("单价")) .AddCell(sr("数量") * sr("单价")) .Primarykey = sr("zid") \'为此行指定主键值 End With Next End With \'设计菜单 With wb.AddActionSheet("","menu") .Add("mnudAdd", "增加明细").Attribute="" \'调用js函数 .Add("mnuEdit", "编辑明细").Attribute ="" .Add("mnuDelete", "删除明细").Attribute =""" .Add("mnuCancel","取消","",True) End With End If With wb.AddDialog("","dlg1", "删除确认","您确定要删除当前明细吗?") .AddButton("btnCancel","取消").Kind = 1 .AddButton("btnOK","确定").Attribute = "" End With With wb.AddButtonGroup("form1","btg1",False) .Add("btn1", "增加明细", "button","adds.htm?oid=" & dr("订单编号") & "&addnext=true&page=" & page) .Add("btn2", "保存", "submit") \'正常提交,保存后进入编辑状态 If e.GetValues.ContainsKey("oid") = False Then \'如过是新增订单 .Add("btn3", "取消", "button","list.htm?page=" & page & "&deloid=" & dr("订单编号")) \'删除新增订单后返回列表 \'ElseIf IsNew OrElse mr IsNot Nothing Then \'如果在给旧订单新增或修改明细,则直接返回编辑状态 \'.Add("btn3", "取消", "button",url) \'返回编辑状态 Else .Add("btn3", "返回", "button","list.htm?page=" & page) \'返回列表 End If End With Dim nms() As String = {"客户","日期"} \'"" If dr IsNot Nothing Then For Each nm As String In nms If e.PostValues.ContainsKey(nm) Then dr(nm)= e.PostValues(nm) End If Next End If dr.Save If e.PostValues.Count > 0 Then \'如果是通过提交按钮访问,则给一个已经保存的提示给用户,时长500毫秒 wb.AddToast("","t1", "已经保存",0).Msec= 500 End If wb.AppendHTML("<script src=\'./lib/order.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 [此贴子已经被作者于2021/4/18 18:34:12编辑过]
|
-- 作者:YUNSEL -- 发布时间:2021/4/18 18:34:00 -- 自己解决了,把界面分两个函数了,一个新增一个编辑。 |