以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  不知道为什么会出现错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144897)

--  作者:hongye
--  发布时间:2020/1/2 11:52:00
--  不知道为什么会出现错误

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


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

确定Click事件
Dim Te() As String ={"类别","辅料名称","单位"}
For i As Integer = 0 To te.Length-1
    If e.Form.Controls(te(i)).text = "" Then
        MessageBox.Show( ""& te(i) &" 是空值,请输入 "& te(i) &"!","提醒")
        Return
    End If
Next
Dim r As Row = Tables("添加辅料_Table1").Current
If r.Locked = True Then
   r .Locked = False
End If
Dim cmd As New SQLCommand
Dim ds As DataTable
Dim cmb As WinForm.ComboBox
cmd.C
cmd.CommandText = "SELEC1T * From {辅料信息表}"
ds = cmd.ExecuteReader(True)
r("计量单位") = e.Form.Controls("单位").Value
r("辅料质地") = e.Form.Controls("辅料质地").Value
r("规格") = e.Form.Controls("规格").Value
r("辅料名称") = e.Form.Controls("辅料名称").Value
\'r("辅料类别") = e.Form.Controls("类别").Value
\'r("辅料编号") = e.Form.Controls("编号").text
With Tables("添加辅料_Table1").Current \'引用当前行
    If .IsNull("辅料名称") = False Then \'如果已经输入结账日期
        .Locked = True \'那么锁定此行
        If DataTables("添加辅料_Table1").HasChanges Then
            r.Save
            ds.Save
        End If
    Else
        .Locked = False \'那么锁定此行
        ds.Save
    End If
End With

--  作者:有点蓝
--  发布时间:2020/1/2 12:04:00
--  
Dim Te() As String ={"类别","辅料名称","单位"} ‘确定这些控件名称是正确的?’
For i As Integer = 0 To te.Length-1
    If e.Form.Controls(te(i)).text = "" Then
        MessageBox.Show( ""& te(i) &" 是空值,请输入 "& te(i) &"!","提醒")
        Return
    End If
Next
Dim r As Row = Tables("添加辅料_Table1").Current
if r is nothing then return \'Current必须判断是否为空
If r.Locked = True Then
   r .Locked = False
End If
‘红色的这些代码一点用处都没有’
Dim cmd As New SQLCommand
Dim ds As DataTable
Dim cmb As WinForm.ComboBox
cmd.C
cmd.CommandText = "SELEC1T * From {辅料信息表}"
ds = cmd.ExecuteReader(True)
r("计量单位") = e.Form.Controls("单位").Value
r("辅料质地") = e.Form.Controls("辅料质地").Value
r("规格") = e.Form.Controls("规格").Value
r("辅料名称") = e.Form.Controls("辅料名称").Value
\'r("辅料类别") = e.Form.Controls("类别").Value
\'r("辅料编号") = e.Form.Controls("编号").text
With r \'引用当前行
    If .IsNull("辅料名称") = False Then \'如果已经输入结账日期
        .Locked = True \'那么锁定此行
        If DataTables("添加辅料_Table1").HasChanges Then
            .Save
            ds.Save
        End If
    Else
        .Locked = False \'那么锁定此行
        ds.Save
    End If
End With

--  作者:hongye
--  发布时间:2020/1/2 12:41:00
--  

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

还是出现这个问题哦

--  作者:hongye
--  发布时间:2020/1/2 12:46:00
--  
几个方面当辅料查询时,点击辅料成分选择要选的项目后,如果出现2条以上的内容,然后修改按确定,不出现错误,但是会保存,如果出现内容只有一条,那就会出现如上错误
--  作者:有点蓝
--  发布时间:2020/1/2 13:43:00
--  
提示currentchanged事件代码有问题,上面代码是currentchanged事件的吗?

调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看哪一句代码有问题

--  作者:hongye
--  发布时间:2020/1/2 14:37:00
--  
不是,上面的代码是“确定”Click事件
currentchanged的事件代码如下
Dim sj1 As WinForm.TextBox = e.Form.Controls("单位")
Dim sj2 As WinForm.TextBox = e.Form.Controls("辅料质地")
Dim sj3 As WinForm.TextBox = e.Form.Controls("规格")
Dim sj4 As WinForm.TextBox = e.Form.Controls("辅料名称")
Dim sj5 As WinForm.ComboBox = e.Form.Controls("类别")
Dim sj6 As WinForm.Label = e.Form.Controls("编号")
Dim r As Row = Tables("添加辅料_Table1").Current
sj1.Value = r("计量单位")
sj2.Value = r("辅料质地")
sj3.Value = r("规格")
sj4.Value = r("辅料名称")
sj5.Value = r("辅料类别")
sj6.text = r("辅料编号")

窗口中的表是SQLTABLE
[此贴子已经被作者于2020/1/2 14:37:51编辑过]

--  作者:有点蓝
--  发布时间:2020/1/2 14:58:00
--  
解决问题的方法在2楼,如果找不到,看看这里的2楼:http://foxtable.com/bbs/dispbbs.asp?boardid=2&Id=144858