以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  帮我看看哪里错了?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147154)

--  作者:hongye
--  发布时间:2020/3/11 0:56:00
--  帮我看看哪里错了?
Dim cls() As String = {"样衣款号","类别","项目名称","规格","成份或质地","克重","门幅","单位","单耗","单价","金额","供应商"} \'定义列名
Dim lxs() As String = {"String","String","String","String","String","Short","String","String","Double","Double","Double","String"} \'定义Type类型
Dim cds() As String = {"55","55","55","55","55","","16","16","","","","50"}
Dim dtb As New DataTableBuilder("临时核价表")
For i As Integer = 0 To  cls.Length - 1
    dtb.AddDef(cls(i),Gettype(lxs(i)),cds(i))
Next

图片点击可在新窗口打开查看此主题相关图片如下:01.jpg
图片点击可在新窗口打开查看

请问这个该怎么写?


--  作者:程兴刚
--  发布时间:2020/3/11 1:18:00
--  
您定义的是字符型数组,怎么可能用来设置列类型?

参考这个对不同列类型的处理方法!

--  作者:有点蓝
--  发布时间:2020/3/11 8:49:00
--  
Gettype里面需要的是类型,而不是字符串,不能带双引号的。这里无法使用变量或者字符串替代,只能这样处理

if lxs(i) = "String" then
    dtb.AddDef(cls(i),Gettype(String),cds(i))
elseif lxs(i) = "Double" then
    dtb.AddDef(cls(i),Gettype(Double),cds(i))
elseif ......

--  作者:hongye
--  发布时间:2020/3/11 11:52:00
--  
Dim ks As WinForm.Label = e.Form.Controls("款号")
Dim yk As WinForm.Label = e.Form.Controls("样衣款号")
Dim lb As WinForm.Label = e.Form.Controls("类别")
Dim jh As WinForm.Label = e.Form.Controls("计划交期")
Dim bj As WinForm.TextBox = e.Form.Controls("报价金额")
Dim zz As WinForm.TextBox = e.Form.Controls("最终价格")
Dim gps() As  String  = {"面料","辅料","二次加工"} \'定义分组名称
Dim te() As String = {"客户","客户担当","类别","品名","款号","样衣款号","报价数量","计划交期","原料费用","辅料费用","二次加工费用","工缴费用","其他费用","管理费用","核价金额","技术担当"}
Dim cls() As String = {"款号","样衣款号","项目名称","规格","成份或质地","克重","门幅","单位","单耗","单价","金额","供应商","分类"} \'定义列名
Dim lxs() As Object = {"String","String","String","String","String","Short","String","String","Double","Double","Double","String","String"} \'定义Type类型
Dim cds() As String = {"55","55","55","55","55","","16","16","","","","50","40"}
Dim wdh() As String = {140,140,140,135,90,45,45,45,58,65,67,88,85}
Dim dtb As New DataTableBuilder("临时核价表")
For i As Integer = 0 To cls.Length - 1
    If lxs(i) = "String" Then
        dtb.AddDef(cls(i),Gettype(String),cds(i))
    ElseIf lxs(i) = "Double" Then
        dtb.AddDef(cls(i),Gettype(Double),cds(i))
    ElseIf lxs(i) = "Short" Then
        dtb.AddDef(cls(i),Gettype(Short),cds(i))
    End If
Next
dtb.Build()
For i As Integer = 0 To cls.Length - 1
    Tables("临时核价表").Cols(cls(i)).Width  = wdh(i)
Next
For i As Integer = 0 To gps.Length - 1
    Dim dt As DataTable = DataTables(gps(i) &"核价")
    msgbox(dt.name)
    Dim drs = dt.Select("款号 = \'" & ks.Text & "\'and 样衣号 like \'%" & yk.Text & "%\'","_sortkey")
    msgbox(drs.count)
    For Each dr As DataRow In drs
        Dim r As  DataRow = DataTables("临时核价表").AddNew()
        r("款号") = ks.Text
        r("样衣款号") = yk.Text
        r("项目名称") = dr(gps(i) & "名称")
        r("分类") = dt.name
    Next
Next
MainTable = Tables("临时核价表")

这个为什么没有被筛选出来呢?哪里错了?

--  作者:有点蓝
--  发布时间:2020/3/11 12:18:00
--  
说明没有符合条件的数据,或者符合条件的数据没有加载

For i As Integer = 0 To gps.Length - 1
    Dim dt As DataTable = DataTables(gps(i) &"核价")
    msgbox(dt.name)
    msgbox("款号 = \'" & ks.Text & "\' and 样衣号 like \'%" & yk.Text & "%\'") \'这个条件拿到数据库里查询
    Dim drs = dt.Select("款号 = \'" & ks.Text & "\'and 样衣号 like \'%" & yk.Text & "%\'","_sortkey")
    msgbox(drs.count)


--  作者:hongye
--  发布时间:2020/3/11 12:19:00
--  
刚刚漏了窗口名,因为表是窗口里的,但是又出来新问题了

图片点击可在新窗口打开查看此主题相关图片如下:01.jpg
图片点击可在新窗口打开查看
这啥意思?


--  作者:有点蓝
--  发布时间:2020/3/11 13:33:00
--  
For i As Integer = 0 To cls.Length - 1
    If lxs(i) = "String" Then
        dtb.AddDef(cls(i),Gettype(String),cds(i))
    ElseIf lxs(i) = "Double" Then
        dtb.AddDef(cls(i),Gettype(Double))
    ElseIf lxs(i) = "Short" Then
        dtb.AddDef(cls(i),Gettype(Short))
    End If
Next