Dim Result As DialogResult
Result = MessageBox.Show("您确定添加吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
If e.Form.Controls("类型2").text = "" Or e.Form.Controls("收入者2").text = "" Or e.Form.Controls("存储方式2").text = "" Or e.Form.Controls("持有人2").text = "" Or e.Form.Controls("金额").text ="" Or e.Form.Controls("日期").text="" Then
MessageBox.Show("必填项不能为空!!!")
Else
Dim nr As Row = Tables("收入表窗口_Table1").AddNew
Dim zc As DataRow
If e.Form.Controls("类型2").text <> "" Then
nr("收入类型表编号") = CInt(e.Form.Controls("类型2").text)
Dim lx As DataRow = DataTables("收入类型表").find("del = 1 and 编号='"& nr("收入类型表编号") &"'")
If lx IsNot Nothing Then
nr("收入类型") =lx("类型")
End If
End If
If e.Form.Controls("金额").text <> "" Then
nr("金额") = CInt(e.Form.Controls("金额").text )
Dim ccfs As DataRow = DataTables("存支方式").find("del=1 and 编号 = '" & nr("存支方式编号") & "'")
If ccfs IsNot Nothing Then
nr("收入汇总") = Tables("收入表窗口_Table1").Compute("Sum(金额)","账号卡号 = '" & ccfs("卡号") & "'")
End If
End If
If e.Form.Controls("日期").text <> "" Then
nr("日期") = CDate(e.Form.Controls("日期").text )
End If
If e.Form.Controls("收入者2").text <> "" Then
nr("收入者编号") = CInt(e.Form.Controls("收入者2").text )
Dim fdr As DataRow = DataTables("家庭成员表").Find("del=1 and 编号 = '" & nr("收入者编号") & "'")
If fdr IsNot Nothing Then
nr("收入者姓名") = fdr("姓名")
End If
End If
If e.Form.Controls("存储方式2").text <> "" Then
nr("存支类型表编号") = CInt(e.Form.Controls("存储方式2").text)
Dim sd As DataRow = DataTables("存支类型表").find("del=1 and 编号 = '"& nr("存支类型表编号") & "'")
If sd IsNot Nothing Then
nr("储存方式") = sd("存支类型")
End If
End If
If e.Form.Controls("卡号类型2").text <> "" Then
nr("银行表编号") = CInt(e.Form.Controls("卡号类型2").text )
Dim zh As DataRow = DataTables("银行表").find("del=1 and 编号 = '"& nr("银行表编号")&"'" )
If zh IsNot Nothing Then
nr("账号卡号类型") = zh("名称")
End If
End If
If e.Form.Controls("银行卡号2").text <> "" Then
nr("存支方式编号") = CInt(e.Form.Controls("银行卡号2").text )
Dim yh As DataRow = DataTables("存支方式").find("del=1 and 编号 = '"& nr("存支方式编号")&"'" )
If yh IsNot Nothing Then
nr("账号卡号") = yh("卡号")
End If
End If
If e.Form.Controls("持有人2").text <> "" Then
nr("持有人") = CInt(e.Form.Controls("持有人2").text )
Dim cy As DataRow = DataTables("家庭成员表").find("del =1 and 编号 = '"& nr("持有人")&"'")
If cy IsNot Nothing Then
nr("持有人姓名") = cy("姓名")
End If
End If
MessageBox.Show("数据添加成功!")
e.Form.close()
nr.Save
End If
End If