此主题相关图片如下:qq图片20150809181554.png

图中为我设计的一个表 绑定的窗口,
我现在命令如下,在没有添加分类选项之前 运行已经没问题了,加上分类和第一组命令以后,下一步有点懵
窗口afterload:
Tables("培训课时统计表").AddNew
Dim cmb As WinForm.ComboBox = e.form.Controls("ComboBox3")
cmb.ComboList = DataTables("课类分类表").GetComboListString("分类")
学生姓名后面的combox2控件enter:
Dim cmb As WinForm.ComboBox = e.Sender
Dim str As String = e.Form.Controls("ComboBox1").Value
cmb.ComboList = DataTables("学员一览表").GetComboListString("姓名", "辅导老师 = '" & str & "'")
签到按钮Click:
Dim mr As Row =Tables("培训课时统计表").Current
Dim Result As DialogResult
Result = MessageBox.Show(mr("教师姓名") &" 是否确认签到?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
'找到对应的学员这一行,改怎么减就怎么减
Dim dr1 As DataRow = DataTables("学员一览表").Find("辅导老师 = '" & mr("教师姓名") & "' And 课程 = '" & mr("授课内容") & "' and 姓名 = '" & mr("学员姓名") & "'")
Dim dr2 As DataRow = DataTables("课类分类表").Find("科目 = '" & mr("授课内容") & "'")
If dr1 Is Nothing OrElse dr2 Is Nothing Then
messagebox.show("错误,请核对授课内容.")
End If
If mr("分类") = "主课" Then
dr1("学费余额") = dr1("学费余额") - dr2("课时费")
dr1("剩余课时") = dr1("剩余课时") - 1
Else If mr("分类") = "附加"
dr1("乐理学费余额") = dr1("乐理学费余额") - dr2("课时费")
dr1("乐理课时") = dr1("乐理课时") - 1
Else If mr("分类") = "陪练"
dr1("陪练费余额") = dr1("陪练费余额") - dr2("课时费")
dr1("陪练课时") = dr1("陪练课时") - 1
Else If mr("分类") = "听力"
dr1("听力余额") = dr1("听力余额") - dr2("课时费")
dr1("听力课时") = dr1("听力课时") - 1
End If
MessageBox.Show(mr("教师姓名") &" 签到成功","提示")
mr.Save
End If
Dim nma()As String = {"学员姓名","授课内容","签到时间","签到次数"} 'A表数据来源列
Dim nmb()As String = {"学员姓名","上课内容","上课时间","节数"} 'B表数据接收列
Dim dr3 As Row = Tables("培训课时统计表").Current
Dim dr4 As Row = Tables("学员上课记录表").AddNew
For i As Integer = 0 To nma.Length - 1
dr4(nmb(i)) = dr3(nma(i))
Next
Dim nmd()As String = {"教师姓名","授课内容","学员姓名","签到时间","签到次数"} 'A表数据来源列
Dim nmc()As String = {"教师姓名","授课内容","学员姓名","签到时间","签到次数"} 'B表数据接收列
Dim dr6 As Row = Tables("培训课时统计表").Current
Dim dr5 As Row = Tables("教师签到记录").AddNew
For i As Integer = 0 To nmd.Length - 1
dr5(nmc(i)) = dr6(nmc(i))
Next
forms("签到").close
绑定表表事件:
If e.DataCol.Name = "学员姓名" Then
If e.NewValue Is Nothing Then
e.DataRow("授课内容") = Nothing
Else
Dim dr3 As DataRow
dr3 = DataTables("学员一览表").Find("姓名 = '" & e.DataRow("学员姓名") & "'")
If dr3 IsNot Nothing Then
e.DataRow("授课内容") = dr3("课程")
End If
End If
End If
If e.DataCol.Name = "授课内容" OrElse e.DataCol.Name = "分类" Then
If e.NewValue Is Nothing Then
e.DataRow("培训科目") = Nothing
Else
Dim dr1 As DataRow
dr1 = DataTables("课类分类表").Find("科目 = '" & e.DataRow("授课内容") & "' and 分类 = '" & e.DataRow("分类") & "'")
If dr1 IsNot Nothing Then
e.DataRow("培训科目") = dr1("培训科目")
e.DataRow("签到时间") = Date.Today
e.DataRow("签到次数") = 1
End If
End If
End If
抛开我前面自己编写的命令~因为我即编写了 表事件命令又编写了窗口命令 也许才会搞混乱
现在如果我想实现的是:
1、进入签到窗口以后,先选择签到的“分类”:主课、附加、陪练
2、然后选择“教师姓名”,选择“学员姓名”
3、"TextBox1"自动代入"授课内容"(由于教师和学生之间,同时拥有:主课、附加、陪练这三种分类的课程。所以需根据条件1"分类"来判断代入内容)
自动代入 “授课内容”
4、在“签到统计表中”根据"授课内容"自动代入“培训科目”“签到次数”“日期”
该如何编写命令?在表事件中还是窗口事件?
下图为 主课、附加、陪练 三种分类的来由

此主题相关图片如下:qq图片20150809193017.png