以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  数据 保存时做选择  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=138123)

--  作者:yifan3429
--  发布时间:2019/7/23 12:22:00
--  数据 保存时做选择
Dim str As String = e.form.Name
If InputValue(str, "保存", "请输入窗体名字") Then
    Dim t As Table = Tables("窗体设置")
    Dim t1 As Table = e.Form.controls("table1").Table
    Dim nr As Row = t.AddNew
    nr("窗体名称") = str
    nr("数据源") = e.Form.Controls("ComboBox数据源").Text
    nr("表名") = e.Form.Controls("ComboBox表").Text
    nr("数据列") = e.Form.Controls("CheckedComboBox数据列").Text
    nr("用户") = User.Name
    nr("日期") = Date.Today()
    nr("目录树") = e.Form.Controls("CheckedComboBox数据列").Text.replace(",","|")
    Dim s As String = e.Form.Controls("CheckedComboBox数据列").Text
    Dim i As Integer = s.IndexOf(",")
    If i = -2 Then
        s = s & " desc"
    Else
        s = s.Insert(i ," desc")
    End If
    nr("筛选条件") = s
    \'Output.Show(s)
End If
DataTables("窗体设置").Save()



上面的代码我想在保存时做选择  
根据 nr("表名") = e.Form.Controls("ComboBox表").Text  判断

如果表名存在  选择覆盖还是放弃




--  作者:有点蓝
--  发布时间:2019/7/23 14:04:00
--  
dim dr as datarow = dataTables("窗体设置").find("表名=\'" & e.Form.Controls("ComboBox表").Text & "\'")
if dr isnot nothing then
msgbox("存在")
end if

--  作者:yifan3429
--  发布时间:2019/7/29 16:56:00
--  
如果存在 覆盖怎么写呢

Dim dr As DataRow = DataTables("窗体设置").find("表名=\'" & e.Form.Controls("ComboBox表").Text & "\'")
If dr IsNot Nothing Then
    msgbox("设置以存在,是否覆盖")
Else
    Dim str As String = e.form.Name
    If InputValue(str, "保存", "请输入窗体名字") Then
        Dim t As Table = Tables("窗体设置")
        Dim t1 As Table = e.Form.controls("table1").Table
        Dim nr As Row = t.AddNew
        nr("窗体名称") = str
        nr("数据源") = e.Form.Controls("ComboBox数据源").Text
        nr("表名") = e.Form.Controls("ComboBox表").Text
        nr("数据列") = e.Form.Controls("CheckedComboBox数据列").Text
        nr("用户") = User.Name
        nr("日期") = Date.Today()
        nr("目录树") = e.Form.Controls("CheckedComboBox数据列").Text.replace(",","|")
        
        Dim s As String = e.Form.Controls("CheckedComboBox数据列").Text
        Dim i As Integer = s.IndexOf(",")
        If i = -2 Then
            s = s & " desc"
        Else
            s = s.Insert(i ," desc")
        End If
        nr("筛选条件") = s
        \'Output.Show(s)
    End If
    DataTables("窗体设置").Save()
End If
[此贴子已经被作者于2019/7/29 16:59:49编辑过]

--  作者:有点蓝
--  发布时间:2019/7/29 17:15:00
--  
参考:http://www.foxtable.com/webhelp/topics/0326.htm
--  作者:yifan3429
--  发布时间:2019/7/29 17:26:00
--  
如果存在覆盖  保证唯一值
我要覆盖筛选的行的数据


[此贴子已经被作者于2019/7/29 17:26:58编辑过]

--  作者:有点蓝
--  发布时间:2019/7/29 17:39:00
--  
不需要addnew,直接对dr各列赋值即可