以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 新增订单时会把已保存过的订单明细带上来 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=173798) |
-- 作者:whx007 -- 发布时间:2021/12/16 17:12:00 -- 新增订单时会把已保存过的订单明细带上来 如题,有ABCD四台电脑,数据库存放在A电脑,BCD三台电脑通过数据库共享接入A。新增订单时B电脑时常把已经保存过订单的订单明细带到新订单的明细里面,CD两台电脑都没有这种情况,请问是什么原因导致?B电脑重新装系统也一样。 如上图,红圈里面是其他已经保存过的订单的订单明细。 |
-- 作者:有点蓝 -- 发布时间:2021/12/16 17:33:00 -- 程序/项目文件不要放到共享里使用。把CD电脑的程序或者项目文件复制到B电脑使用有没有问题? |
-- 作者:whx007 -- 发布时间:2021/12/16 17:44:00 -- 我A电脑的程序在共享文件里面,我取消试试。 CD电脑和B电脑用的是同一个版本的程序
|
-- 作者:有点蓝 -- 发布时间:2021/12/16 20:10:00 -- 程序/项目文件不要放到共享里使用。要共享也应该共享数据库,而不是共享程序。应该把程序安装到每台电脑使用 |
-- 作者:whx007 -- 发布时间:2021/12/21 18:09:00 -- 以下是引用有点蓝在2021/12/16 20:10:00的发言: 程序/项目文件不要放到共享里使用。要共享也应该共享数据库,而不是共享程序。应该把程序安装到每台电脑使用 程序都是每个电脑安装的,之前只是A电脑的程序/项目文件也在共享文件夹里。改了以后现在只有数据库是共享的。改了以后用了几天后,B电脑暂时没有出现,但今天C电脑出现了相同情况。 [此贴子已经被作者于2021/12/23 4:31:37编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/12/21 20:05:00 -- 如果排除了共享的问题。应该就是代码逻辑有问题了。具体要提供实例测试过才能确定问题了 [此贴子已经被作者于2021/12/21 20:05:06编辑过]
|
-- 作者:whx007 -- 发布时间:2021/12/25 18:28:00 -- 开单流程: 第一步,新增订单,按钮代码: Dim id As Integer = DataTables("报价单").Compute("Max(_Identify)") Dim Filter As String = "[_Identify] > " & id DataTables("报价单").AppendLoad(Filter, False) With Tables("报价单") If .Current Is Nothing OrElse .Current.DataRow.RowState = DataRowState.Unchanged Then \'如果当前行未曾修改 Tables("报价单").AllowEdit = True Dim dr As Row = Tables("报价单").AddNew dr("日期") = Date.Today End If End With Dim xzcp As WinForm.Button = e.Form.Controls("新增产品") xzcp.Enabled = True Dim bc As WinForm.Button = e.Form.Controls("保存") bc.Enabled = True 第二步,增加订单明细,按钮代码: Dim sts() As String = {"dropbox2","DropBox4","DropBox1","NumericComboBox2"} For Each st As String In sts If e.Form.Controls(st).value Is Nothing Then MessageBox.show("Please enter the name,phone number,Model and quantity !","Remind") Return End If Next Dim tbl As Table = Tables("报价明细表") Dim r As Row = tbl.AddNew() r("订单号") = e.Form.Controls("TextBox2").Text r("客户名称") = e.Form.Controls("DropBox4").Text r("客户电话") = e.Form.Controls("DropBox2").Text r("日期") = e.Form.Controls("DateTimePicker1").Text r("产品型号") = e.Form.Controls("dropbox1").Text r("产品类别") = e.Form.Controls("产品类别").Text r("单价成本") = e.Form.Controls("单价成本").Text r("销售单价") = e.Form.Controls("TextBox5").Text r("数量") = e.Form.Controls("NumericComboBox2").Text r("已提数量") = e.Form.Controls("NumericComboBox1").Text \'r.save e.Form.Controls("DropBox1").Text = "" e.Form.Controls("textbox5").Text = "" e.Form.Controls("NumericComboBox2").Value = Nothing e.Form.Controls("未提数量").Text = "未知" 第三步,保存,按钮代码: If e.Form.Controls("CheckBox1").Checked = False AndAlso e.Form.Controls("CheckBox2").Checked = False Then MessageBox.Show("Please Choose Whether To Convert To An Order!", "Error") Return End If If Tables("报价单").Current.DataRow.RowState = DataRowState.Added AndAlso Tables("报价单").Current IsNot Nothing Then If Tables("报价明细表").Current Is Nothing Then MessageBox.Show("No details cannot be saved 无订单明细,无法保存!", "Error 错误提示") Tables("报价单").Current.Delete Else Tables("报价单").Current("客户名称") = e.Form.Controls("DropBox4").Text Tables("报价单").Current("客户电话") = e.Form.Controls("DropBox2").Text Tables("报价单").Current("折扣") = e.Form.Controls("TextBox3").Text Tables("报价单").Current("备注") = Tables("报价单").Current("备注") & e.Form.Controls("TextBox4").Text \'Tables("报价单").Current("已付款") = e.Form.Controls("TextBox9").Text If Tables("报价单").Current IsNot Nothing Then Tables("报价单").Current.Save Tables("报价单").AllowEdit = False End If Tables("报价明细表").Save End If End If Dim khmc As WinForm.DropDownBox = e.Form.Controls("DropBox4") Dim khdh As WinForm.DropDownBox = e.Form.Controls("DropBox2") If e.Form.Controls("DropBox4").value IsNot Nothing Or e.Form.Controls("DropBox2").value IsNot Nothing Then \'添加客户信息 Dim tbl As Table = Tables("客户信息表") Dim drn As DataRow = DataTables("客户信息表").SQLFind("客户名称 = \'" & khmc.Text & "\'") Dim drp As DataRow = DataTables("客户信息表").SQLFind("客户电话 = \'" & khdh.Text & "\'") If drn Is Nothing AndAlso drp Is Nothing Then Dim n As Row = tbl.AddNew() n("客户名称") = e.Form.Controls("DropBox4").Text n("客户电话") = e.Form.Controls("DropBox2").Text tbl.Current.Save() Else If drn Is Nothing AndAlso drp IsNot Nothing Then tbl.current("客户名称") = e.Form.Controls("DropBox4").Text tbl.Current.Save() Else If drn IsNot Nothing AndAlso drp Is Nothing Then Dim n2 As Row = tbl.AddNew() n2("客户名称") = e.Form.Controls("DropBox4").Text n2("客户电话") = e.Form.Controls("DropBox2").Text tbl.Current.Save() End If End If Dim zk As WinForm.TextBox = e.Form.Controls("textbox3") Dim cpxh As WinForm.DropDownBox = e.Form.Controls("DropBox1") Dim sl As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox2") Dim dj As WinForm.TextBox = e.Form.Controls("textbox5") Dim sfje As WinForm.TextBox = e.Form.Controls("textbox9") Dim ytsl As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox1") Dim bz As WinForm.TextBox = e.Form.Controls("textbox4") Dim zffs As WinForm.ComboBox = e.Form.Controls("ComboBox1") khmc.Text = "" khdh.Text = "" cpxh.Text = "" sl.Value = Nothing dj.Text = "" sfje.Text = "" zk.Text = "0" ytsl.Value = Nothing bz.Text = "" zffs.Text = "Cash" Dim t As Table = Tables("Quotation_Table2") With Tables("报价单") If .Current Is Nothing Then t.Filter = "False" Else t.Filter = "订单号 = \'" & .Current("订单号") & "\'" End If End With With Tables("报价明细表") Tables("报价明细表").Filter = "1=2" .Cols("数量").GrandTotal = True .Cols("金额").GrandTotal = True .GrandTotal = False End With Dim xzcp As WinForm.Button = e.Form.Controls("新增产品") xzcp.Enabled = False Dim bc As WinForm.Button = e.Form.Controls("保存") bc.Enabled = False If e.Form.Controls("CheckBox1").Checked = True Then If MessageBox.Show("Are You Sure To Convert This Quotation To An Order?","Confirm",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then Dim dr1 As Row = Tables("报价单").Current Dim Cols1() As String = {"日期","订单号","客户名称","客户电话","折扣","编辑者","备注"} Dim Cols2() As String = {"日期","订单号","客户名称","客户电话","折扣","编辑者","备注"} Dim Cols3() As String = {"日期","订单号","客户名称","客户电话","产品型号","产品类别","数量","销售单价","备注","单价成本"} Dim Cols4() As String = {"日期","订单号","客户名称","客户电话","产品型号","产品类别","数量","销售单价","备注","单价成本"} Dim dr2 As DataRow = DataTables("销售订单").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next For Each dr3 As DataRow In dr1.DataRow.GetChildRows("报价明细表") Dim dr4 As DataRow = DataTables("销售明细表").AddNew() For i As Integer = 0 To Cols3.Length -1 dr4(Cols4(i)) = dr3(Cols3(i)) Next Next Tables("报价单").Current.delete DataTables("报价单").Save() DataTables("销售订单").Save() DataTables("销售明细表").Save() End If End If 帮我看看是不是代码或者逻辑有问题。 [此贴子已经被作者于2021/12/25 18:38:17编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/12/26 20:12:00 -- 从代码看,窗口控件应该都没有使用绑定,直接赋值的。这种情况容易串行,特别是报价单新增了多行还没有保存的情况下。 建议控制一下每次只能新增一个单号的报价单,没有之前不能新增第二个。其实在foxtable里使用绑定和关联表录入明细是最合适的,基本不需要担心串行,也不需要写这么多的代码复制和控制
|
-- 作者:whx007 -- 发布时间:2021/12/26 21:57:00 -- 只绑定了两个字段 如果每次只能新增一个单,效率就很低了。 [此贴子已经被作者于2021/12/27 0:40:51编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/12/26 22:12:00 -- 代码里尽量不要使用Tables("xxx").Current这种用法,比如用户编辑第一行,那么Tables("报价单").Current表示的就是第一行,这时用户点击了第二行,那么Tables("报价单").Current就表示第二行,但是Tables("报价明细表").Current可能是和"报价单"第一行有关的数据,所以就很容易串行了 |