以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  家庭信息新增  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=122624)

--  作者:susu312
--  发布时间:2018/7/30 10:19:00
--  家庭信息新增

Dim perName As String = e.Form.Controls("perName").Value
Dim cardId  As String = e.Form.Controls("cardId").Value
Dim famName As String = e.Form.Controls("FamName").Value
Dim famTel As String = e.Form.Controls("FamTeL").Value
Dim guanXi  As String = e.Form.Controls("guanXi").Value
Dim political  As String = e.Form.Controls("FamPolitical").Value
Dim age        As String = e.Form.Controls("FamAge").Value
Dim famJob     As String = e.Form.Controls("FamJob").Value
Dim famAddr    As String = e.Form.Controls("FamAddr").Value

 

\'\'清空控件上的值 (这样貌似没有清空?)

e.Form.Controls("FamName").Value=""
e.Form.Controls("FamTeL").Value=""
e.Form.Controls("guanXi").Value=""
e.Form.Controls("FamPolitical").Value=""
e.Form.Controls("FamAge").Value=""
e.Form.Controls("FamJob").Value=""
e.Form.Controls("FamAddr").Value=""

 

 

Dim cmd As New SQLCommand
cmd.C

If famName= ""  Then
    Messagebox.show("请输入姓名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
If guanXi = ""  Then
    Messagebox.show("请输入关系!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If

 


cmd.CommandText = "Insert Into {family} ([cardId],[huzhu],[name],[guanxi],[age],[political],[tel],[job],[address]) Values (\'"
cmd.CommandText = cmd.CommandText & cardId & "\',\'" & perName & "\',\'"  & famName & "\',\'" & guanXi & "\',\'" & age & "\',\'" & political & "\',\'" & famTel & "\',\'" & famJob & "\',\'" & famAddr & "\')"
If cmd.ExecuteNonQuery = 1 Then \'返回1表示增加成功
       Messagebox.show("添加成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

   

       \'\'只加载当前新增用户的家人信息(这样加载的表格是空的)
       Dim Filter As String
       With e.Form.Controls("cardId")
            If .Value IsNot Nothing Then
                 Filter = "cardId = \'" & .Value & "\'"
            End If
       End With
       If Filter > "" Then
             Tables("family").Filter = Filter
       End If
End If

 

 

 

老师,您帮我看看红色部分那个代码哈,我觉得逻辑是对的,但是没有实现我的功能?


--  作者:有点甜
--  发布时间:2018/7/30 10:22:00
--  

1、你控件绑定列了?绑定列如果你要清空数据,直接给列赋值;

 

2、加载,参考 http://www.foxtable.com/webhelp/scr/1928.htm