Foxtable(狐表)用户栏目专家坐堂 → 家庭信息新增


  共有1659人关注过本帖树形打印复制链接

主题:家庭信息新增

美女呀,离线,留言给我吧!
susu312
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:997 积分:6752 威望:0 精华:0 注册:2018/6/8 16:17:00
家庭信息新增  发帖心情 Post By: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

 

 

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/30 10:22:00 [只看该作者]

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

 

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

 


 回到顶部