以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  导入  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98535)

--  作者:刘林
--  发布时间:2017/3/31 14:17:00
--  导入

Dim com4 As String =  trim(e.Form.Controls("combobox7").text)
If com4 > ""
    If User.IsRole("业务主管") Then
        Dim dt As Table = Tables("中考报名_table5")
        If dt.Rows.count>0
            Dim dr As DataRow
            dr = DataTables("学校信息").sqlFind("单位全称 = \'" & user.group & "\'and 学段 = \'初中\'" )
            If dr IsNot Nothing
                Dim bydm As String = left(dr("毕业学校代码"),8)
                Dim jm As String = dr("学校班级用简称")
                Dim p As WinForm.ProgressBar
                p = e.Form.Controls("ProgressBar1")
                p.Maximum = dt.Rows.Count \'设置最大值
                p.Minimum = 0 \'设置最小值
                p.Value = 0 \'设置当前值
                Dim dwmc As String = user.group
                If  com4 > ""
                    Dim Cols1() As String = {"学校名称","学生姓名","班级","年级","身份证件号","学籍号","性别","班级"}
                    Dim Cols2() As String = {"学校名称","姓名","班级","年级","身份证号","学籍号","性别","级"}
                    Dim su As Integer = 0
                    Dim dr2 As DataRow
                    Dim p1 As Integer = 0
                    For Each dr1 As Row In dt.Rows
                        If DataTables("生地报名库").sqlFind("身份证号 = \'" & dr1("身份证件号") & "\' and  姓名 = \'" & dr1("学生姓名") & "\'") Is Nothing Then
                            dr2 = DataTables("生地报名库").AddNew()
                            For i As Integer = 0 To Cols1.Length -1
                                Select Case i
                                    Case 0,1,5,4,6,7
                                        dr2(Cols2(i)) = dr1(Cols1(i))
                                    Case 2
                                        Dim c() As Char = {"级", "班"}
                                        Dim str As String = dr1(Cols1(i))
                                        Dim s1() As String = str.Split(c)
                                        dr2(Cols2(i)) = s1(1)
                                    Case 3
                                        Dim year As String = com4.Substring(0,2)
                                        Dim v As Integer = cint(year)
                                        Dim ji As String = com4.Substring(2,1)
                                        Dim j As Integer
                                        If ji = "春"
                                            j = 0
                                        End If
                                        If ji = "秋"
                                            j = 1
                                        End If
                                        dr2(Cols2(i)) = trim(str(v - val(dr1(Cols1(i)).Substring(4,2)) + j +6))
                                        If dr2(Cols2(i)) = "9"
                                            dr2("备注") ="补考"
                                        End If
                                End Select
                                dr2("考试名称") = com4
                           
                        Next

                        P1 =P1+1
                        P.VALUE = P1
                        dr2("毕业中学代码") = bydm \'left(dr("毕业学校代码"),8)
                        dr2("学校班级") = jm & dr2("年级") & "." & dr2("班级")
                        \'End If
                        Dim dr3 As DataRow
                        dr3 = DataTables("师表").Find("学校名称 = \'" & dr2("学校名称") & "\'and 班级 = \'" & dr2("级") & "\'" )
                        If dr3 IsNot Nothing
                            dr2("生物教师")= dr3("生物教师")
                            dr2("地理教师")= dr3("地理教师")
                        End If
                        dr2.save()
                       End If
                    Next
                    p.value=0
                End If
            Else
                messagebox.show("请选择勾选8年级和9年级在校学生","提示",MessageBoxButtons.OK)
            End If
        End If
    End If
Else
    messagebox.show("请选择好报考名称","提示",MessageBoxButtons.OK)
End If
Tables("中考报名_table4").sort = "学校班级,备注"

 

 

老师,上面代码是想查找有不有身份证号和姓名相同的记录有则跳过,无则增加并填充,但做出来结果是都要增加记录,没找到是什么地方错了,请指点,谢谢


--  作者:有点色
--  发布时间:2017/3/31 14:53:00
--  

If DataTables("生地报名库").sqlFind("身份证号 = \'" & dr1("身份证件号") & "\' and  姓名 = \'" & dr1("学生姓名") & "\'") Is Nothing Then

 

改成

 

If DataTables("生地报名库").Find("身份证号 = \'" & dr1("身份证件号") & "\' and  姓名 = \'" & dr1("学生姓名") & "\'") Is Nothing AndAlso DataTables("生地报名库").sqlFind("身份证号 = \'" & dr1("身份证件号") & "\' and  姓名 = \'" & dr1("学生姓名") & "\'") Is Nothing Then


--  作者:刘林
--  发布时间:2017/3/31 14:59:00
--  
效果一样呢
--  作者:有点色
--  发布时间:2017/3/31 15:03:00
--  

msgbox("身份证号 = \'" & dr1("身份证件号") & "\' and  姓名 = \'" & dr1("学生姓名") & "\'")

 

弹出条件看看,看看是否正常。看是否有特殊字符,比如空格之类的。


--  作者:刘林
--  发布时间:2017/3/31 15:58:00
--  

问题如找到了,谢谢,但现在还有一个问题是如果生地库中学生的身份证为空,导入一次又会重复增加记录呢,请问如何解决这种没身份证的问题呢?


--  作者:有点色
--  发布时间:2017/3/31 16:06:00
--  

条件这样生成

 

Dim Filter As String = ""
If dr1.IsNull("身份证件号") Then
    filter &= "身份证号 is Null"
Else
    filter &= "身份证号 = \'" & dr1("身份证件号") & "\'"
End If

If dr1.IsNull("姓名") Then
    filter &= "姓名 is Null"
Else
    filter &= "姓名 = \'" & dr1("学生姓名") & "\'"
End If

msgbox(filter)