以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助关于控制新增的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=52887)

--  作者:188802386
--  发布时间:2014/6/25 10:50:00
--  求助关于控制新增的问题
我有个成交录入表,里面有个合同编号列,窗口中有个模糊查询本文输入框 我在文本输入框输入编号后,下面自动搜索该编号,

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140625103009.png
图片点击可在新窗口打开查看
我想实现,如果搜索到改编号,那么窗口中新增按钮就不能点击,请问新增按钮的控件如何设置
主要是我要实现合同编号唯一

--  作者:有点甜
--  发布时间:2014/6/25 10:55:00
--  

 新增按钮加入代码

 

If Datatables("表A").Find("合同编号 = \'" & e.Form.Controls("TextBox1").Text & "\'") is Nothing Then

     Datatables("表A").AddNew

Else

     msgbox("编号存在")

End If


--  作者:188802386
--  发布时间:2014/6/25 11:06:00
--  
新增按钮原来代码
Dim htbh As WinForm.TextBox = e.Form.Controls("TextBox1")
If e.Form.Controls("TextBox1").text> "" Then
\'e.Form.controls("Button5").enabled = False
With Tables("成交录入")
    If .Current Is Nothing OrElse .Current.DataRow.RowState = DataRowState.Unchanged Then \'如果当前行未曾修改
       Dim r As Row =  Tables("成交录入").AddNew()
r("合同编号")=e.form.controls("TextBox1").text
    End If
End With
Forms("成交录入").open
Else
    Msgbox("在新增前请在模糊查询里输入你要录入的合同编号!")
End If
我加在前后就可以了吗
If Datatables("成交录入").Find("合同编号 = \'" & e.Form.Controls("TextBox1").Text & "\'") is Nothing Then
Dim htbh As WinForm.TextBox = e.Form.Controls("TextBox1")
If e.Form.Controls("TextBox1").text> "" Then
\'e.Form.controls("Button5").enabled = False
With Tables("成交录入")
    If .Current Is Nothing OrElse .Current.DataRow.RowState = DataRowState.Unchanged Then \'如果当前行未曾修改
       Dim r As Row =  Tables("成交录入").AddNew()
r("合同编号")=e.form.controls("TextBox1").text
    End If
End With
Forms("成交录入").open
Else
    Msgbox("在新增前请在模糊查询里输入你要录入的合同编号!")
End If

Else

     msgbox("编号存在")

End If


--  作者:有点甜
--  发布时间:2014/6/25 11:09:00
--  
 可以。
--  作者:188802386
--  发布时间:2014/7/3 15:55:00
--  
我合同编号是7位数 请问我如何控制“TextBox1”  等于7位数才新增呢
If DataTables("成交录入").Find("合同编号 = \'" & e.Form.Controls("TextBox1").Text & "\'") Is Nothing Then
Dim htbh As WinForm.TextBox = e.Form.Controls("TextBox1")
If e.Form.Controls("TextBox1").text> "" Then
\'e.Form.controls("Button5").enabled = False
With Tables("成交录入")
    If .Current Is Nothing OrElse .Current.DataRow.RowState = DataRowState.Unchanged Then \'如果当前行未曾修改
       Dim r As Row =  Tables("成交录入").AddNew()
r("合同编号")=e.form.controls("TextBox1").text
    End If
End With
Forms("成交录入").open
Else
    Msgbox("在新增前请在模糊查询里输入你要录入的合同编号!")
End If
Else
     msgbox("该合同编号已存在,请不要重复新增!")
End If

--  作者:Bin
--  发布时间:2014/7/3 15:58:00
--  
If e.Form.Controls("TextBox1").text.length = 7 Then
--  作者:188802386
--  发布时间:2014/7/3 16:14:00
--  
如何让汉字为两个字符串呢 我合同编号有两种一种纯数字0000000   一种 云华000   红雨000  的 
--  作者:Bin
--  发布时间:2014/7/3 16:17:00
--  
Dim str As String ="云华000"
Dim i As Integer
For Each s As String In str
    If IsNumeric(s) Then
        i=i+1
    Else
        i=i+2
    End If
Next
if i = 7 then

--  作者:有点甜
--  发布时间:2014/7/3 16:19:00
--  

 这样做。

 

Dim str As String = "云华3"
Dim length As Integer = System.Text.Encoding.default.GetBytes(str).length
msgbox(length)


--  作者:188802386
--  发布时间:2014/7/3 16:35:00
--  
请问如何与这段整合起来呢
If DataTables("成交录入").Find("合同编号 = \'" & e.Form.Controls("TextBox1").Text & "\'") Is Nothing Then
Dim htbh As WinForm.TextBox = e.Form.Controls("TextBox1")
If e.Form.Controls("TextBox1").text.length = 7 Then
With Tables("成交录入")
    If .Current Is Nothing OrElse .Current.DataRow.RowState = DataRowState.Unchanged Then \'如果当前行未曾修改
       Dim r As Row =  Tables("成交录入").AddNew()
r("合同编号")=e.form.controls("TextBox1").text
    End If
End With
Forms("成交录入").open
Else
    Msgbox("在新增前请在模糊查询里输入你要录入的合同编号!")
End If
Else
     msgbox("该合同编号已存在,请不要重复新增!")
End If