以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  筛选更新学生和筛选新增学生代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=128841)

--  作者:Liangcai
--  发布时间:2018/12/16 13:05:00
--  筛选更新学生和筛选新增学生代码

请老师指教,筛选更新学生和筛选新增学生,代码该怎么写?谢谢!

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目20.zip

[此贴子已经被作者于2018/12/16 13:34:30编辑过]

--  作者:y2287958
--  发布时间:2018/12/16 13:19:00
--  
表中没有“更新”与“新增”的信息
--  作者:Liangcai
--  发布时间:2018/12/16 13:34:00
--  
怎么改,请指教,谢谢
--  作者:y2287958
--  发布时间:2018/12/16 13:40:00
--  
增加一列,记录相关内容
--  作者:Liangcai
--  发布时间:2018/12/16 15:46:00
--  

老师,我加了编号列,新增行为1,更新行为2,新增行可以,更新行不行,请老师指教。

Dim t As Table = e.Form.controls("Table1").Table
Dim r As DataRow
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        r = t.DataTable.SQLFind("身份证号 = \'" & sheet(n, 1).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            Dim max As String = DataTables("学生基本信息").SQLCompute("Max(学生编号)","学生编号 Like \'201809%\'")
            If max = "" Then
                r("学生编号") = "201809" & "001"
            Else
                Dim v As Integer = max.SubString(6,3)
                r("学生编号") = "201809" & format(v +1,"000")
            End If
            newcount += 1
            r("编号") = "1"
        Else
            r("编号") = "2"
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                r(cname) = sheet(n, i).Text
            End If
        Next
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
    t.save
End If
t.SetColVisibleWidth("学生编号|90|学生姓名|120|身份证号|120|民族|60|编号|40|")
t.Filter = "编号 = \'1\' Or  编号 = \'2\'"

[此贴子已经被作者于2018/12/16 15:56:13编辑过]

--  作者:有点甜
--  发布时间:2018/12/16 20:28:00
--  

参考

 

Dim t As Table = Tables("学生基本信息") \'e.Form.controls("Table1").Table
Dim r As DataRow
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        r = t.DataTable.SQLFind("身份证号 = \'" & sheet(n, 2).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            Dim max As String = DataTables("学生基本信息").SQLCompute("Max(学生编号)","学生编号 Like \'201809%\'")
            If max = "" Then
                r("学生编号") = "201809" & "001"
            Else
                Dim v As Integer = max.SubString(6,3)
                r("学生编号") = "201809" & format(v +1,"000")
            End If
            newcount += 1
            r("编号") = "1"
        Else
            r("编号") = "2"
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                r(cname) = sheet(n, i).Text
            End If
        Next
        r.save
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
End If
t.SetColVisibleWidth("学生编号|90|学生姓名|120|身份证号|120|民族|60|编号|40|")
t.DataTable.load
t.Filter = "编号 = \'1\' Or  编号 = \'2\'"

 


--  作者:Liangcai
--  发布时间:2018/12/17 11:00:00
--  
谢谢
--  作者:Liangcai
--  发布时间:2018/12/18 9:56:00
--  

老师我这样怎么保存不了,多了学期条件,请老师指点,谢谢!

Dim ary() As String = Functions.Execute("Xueqi")

Dim t As Table = e.Form.controls("Table1").Table
If e.Form.controls("导入文件").text = "缴学费信息" Then
    Dim nms() As String = {"学期","班级","学生编号","缴费日期","缴费金额","收款人"}
    For n As Integer = 1 To t.Rows.Count -1
        dr = DataTables("缴学费").SQLFind("学期 = \'"& ary(1) &"\' And 学生编号 = \'" & t.Rows(n)("学生编号") & "\'")
        If dr Is Nothing Then  \'如果不存在同编号的订单
            dr =  DataTables("缴学费").AddNew()
        End If
        For Each c As String In nms
            dr(c) = t.Rows(n)(c)
        Next
        dr.save
    Next
End If

[此贴子已经被作者于2018/12/18 9:57:07编辑过]

--  作者:有点甜
--  发布时间:2018/12/18 10:04:00
--  

1、msgbox(ary(1)) 看看值是否正确;弹出什么?

 

2、你学期列如果不是字符列(是数值列的话),就不要加单引号。

 

3、你去后台数据表那里查看,是否修改保存了,有可能你没刷新数据看不到后台效果。


--  作者:Liangcai
--  发布时间:2018/12/18 10:17:00
--  
学期是字符列,后台没有数据。