Dim kmbm As String = e.Form.Controls("kmbm").Value
Dim km1 As String = e.Form.Controls("km1").Value
Dim km2 As String = e.Form.Controls("km2").Value
Dim km3 As String = e.Form.Controls("km3").Value
Dim km4 As String = e.Form.Controls("km4").Value
Dim km5 As String = e.Form.Controls("km5").Value
Dim km6 As String = e.Form.Controls("km6").Value
Dim trV1 As WinForm.TreeView = Forms("会计科目设置").Controls("TreeView1")
Dim lst As WinForm.Table = Forms("会计科目设置").Controls("Table1")
Dim dt As DataTable
Dim cmd As New SQLCommand
cmd.Connectio n N ame = "cwgl"
If km2 = "" OrElse km3 = "" OrElse km4 = "" Then
Messagebox.show("支出性质一级科目,二级科目,经济分类一级科目不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select Count(*) Fro m {会计科目} Where 科目编码 = '" & kmbm & "'"
If cmd.ExecuteScalar > 0 Then
Messagebox.show("增加科目失败,已经能存在相同的科目!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Inser t I n to {会计科目} ([科目编码],[一级科目],[二级科目],[三级科目],[四级科目],[五级科目],[六级科目]) Values ('"
cmd.CommandText = cmd.CommandText & kmbm & "','" & km1 & "','" & km2 & "','" & km3 & "','"& km4 & "','" & km5 & "','" & km6 & "')"
If cmd.ExecuteNonQuery = 1 Then '返回1表示增加成功
If Forms("会计科目设置").Opened Then
cmd.CommandText = "SELECT * Fro m {会计科目}"
dt = cmd.ExecuteReader()
Dim bd1 As New GroupTableBuilder("统计表1",dt)
bd1.Groups.AddDef("科目编码","会计科目编码")
bd1.Groups.AddDef("一级科目","功能类科目名称")
bd1.Groups.AddDef("二级科目","支出性质分类_一级科目")
bd1.Groups.AddDef("三级科目","支出性质分类_二级科目")
bd1.Groups.AddDef("四级科目","经济分类_一级科目")
bd1.Groups.AddDef("五级科目","经济分类_二级科目")
bd1.Groups.AddDef("六级科目","经济分类_三级科目")
Tables("会计科目设置_Table1").DataSource = bd1.BuildDataSource()
Tables("会计科目设置_table1").AutoSizeCols() '设置自动列宽
trv1.BuildTree("会计科目设置_Table1","功能类科目名称|支出性质分类_一级科目|支出性质分类_二级科目|经济分类_一级科目|经济分类_二级科目|经济分类_三级科目")
End If
' Dim dr As DataRow
For Each dr As DataRow In DataTables("会计科目").Select("[科目编码] = '"& lst.Table.Current("会计科目编码") &"'")
dr("一级科目") = lst.Table.Current("功能类科目名称")
dr("二级科目")= lst.Table.Current("支出性质分类_一级科目")
dr("三级科目")= lst.Table.Current("支出性质分类_二级科目")
dr("四级科目")= lst.Table.Current("经济分类_一级科目")
dr("五级科目") = lst.Table.Current("经济分类_二级科目")
dr("六级科目")= lst.Table.Current("经济分类_三级科目")
Next
e.Form.Close()
End If