If e.Form.Controls("TextBox2").value = "" Then
messagebox.show("客户编号不能为空","提示!")
e.Form.Controls("textbox3").Select()
Return
End If
If e.Form.Controls("增 加").Enabled = True Then
Dim dr As DataRow
If dr.RowState <> DataRowState.Added Then '如果不是新增行
Return '那么返回
End If
Dim cmd1 As New SQLCommand
Dim cmd2 As New SQLCommand
Dim Key As Integer
cmd1.C '设置数据源名称
cmd2.C
cmd1.commandText = "Select Count(*) F rom [单据编号] Where 单据前缀 = 'KHGL-'"
If cmd1.ExecuteScalar = 0 Then '如果编号表不存在前缀的行,那么增加一行
cmd1.commandtext = "Ins ert Into 单据编号 (单据前缀,顺序号) Values('KHGL-',1)"
cmd1.ExecuteNonQuery
End If
cmd1.commandText = "Select [顺序号] F rom [单据编号] Where 单据前缀 = 'KHGL-'"
Key = cmd1.ExecuteScalar() '从后台获得顺序号
cmd2.commandText = "Up date [单据编号] Set [顺序号] = " & (Key + 1) & " Where [顺序号] = " & Key & " And [单据前缀] = 'KHGL-'"
If cmd2.ExecuteNonQuery() = 0 Then
MessageBox.Show("客户编号重复!请重新输入!","提示")
e.Form.Controls("textbox3").Select()
Return
Else
Dim r As Row = Tables("客户管理").addnew()
r("客户管理系统编号") = "KHGL-" & Format(Key,"00000")
r("单据前缀")= e.Form.Controls("TextBox8").value
r("客户编号")= e.Form.Controls("TextBox2").value
r("客户名称")= e.Form.Controls("TextBox3").value
r("内部编号")= e.Form.Controls("TextBox4").value
r("联系人")= e.Form.Controls("TextBox5").value
r("联系电话")= e.Form.Controls("TextBox6").value
r("联系手机")= e.Form.Controls("TextBox7").value
r("联系地址")= e.Form.Controls("TextBox12").value
r("备注一")= e.Form.Controls("TextBox13").value
r("客户类别")= e.Form.Controls("ComboBox1").value
r("货运名称")= e.Form.Controls("ComboBox2").value
r("结算方式")= e.Form.Controls("ComboBox3").value
r("客户区域")= e.Form.Controls("ComboBox4").value
Tables("客户管理").current.save()
e.Form.Controls("TextBox2").value = ""
e.Form.Controls("TextBox3").value = ""
e.Form.Controls("TextBox4").value = ""
e.Form.Controls("TextBox5").value = ""
e.Form.Controls("TextBox6").value = ""
e.Form.Controls("TextBox7").value = ""
e.Form.Controls("TextBox8").value = ""
e.Form.Controls("TextBox12").value = ""
e.Form.Controls("TextBox13").value = ""
e.Form.Controls("ComboBox1").value = ""
e.Form.Controls("ComboBox2").value = ""
e.Form.Controls("ComboBox3").value = ""
e.Form.Controls("ComboBox4").value = ""
End If
End If
这是完整的代码呀,就是提示 未将对象引用设置到对象的实例呀,我是用做保存按钮click ,事件呀