以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代替人工,点选列项目首项  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=106201)

--  作者:zhangning
--  发布时间:2017/9/4 15:45:00
--  代替人工,点选列项目首项
老师,您好!
我已经设置好了“调度设备”列的列项目,
需要选择列项目的第一个,现在是人工选,月初排计划时,工作量很大,
有没有什么方法,可以自动选?

请参考附图
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:截图.xls



--  作者:有点蓝
--  发布时间:2017/9/4 17:12:00
--  
默认选中第一个?

DataRowAdded事件

e.DataRow("调度设备")  = Tables(e.DataTable.Name).Cols("调度设备").ComboList.Split("|")(0)

--  作者:zhangning
--  发布时间:2017/9/5 15:14:00
--  
老师,事先已经将列表项目进行了如下设定:
在prepareedit事件里
If e.Col.name Like "*调度设备*" Then
    Dim str As String = ""
    Dim filter As String = "部品ID = \'" & e.Row("部品ID") & "\'"
    Dim idx As String = e.Col.Name.Replace("第", "").Replace("序_调度设备", "")
    Dim fdr As DataRow = DataTables("工程和工时").Find(filter & " and 工序序号 = \'" & idx & "\'")
    If fdr IsNot Nothing Then
        For Each dc As DataCol In DataTables("工程和工时").DataCols
            If dc.name.StartsWith("使用机器") AndAlso fdr.IsNull(dc.name) = False Then
                str &= fdr(dc.name) & "|"
            End If
        Next
    End If
    e.Col.ComboList = str
End If
If e.Col.name Like "*调度设备*" Then
    Dim str As String = ""
    Dim filter As String = "部品ID = \'" & e.Row("部品ID") & "\'"
    Dim idx As String = e.Col.Name.Replace("第", "").Replace("序_调度设备", "")
    Dim fdr As DataRow = DataTables("工程和工时").Find(filter & " and 工序序号 = \'" & idx & "\'")
    If fdr IsNot Nothing Then
        For Each dc As DataCol In DataTables("工程和工时").DataCols
            If dc.name.StartsWith("使用机器") AndAlso fdr.IsNull(dc.name) = False Then
                Dim flag As Boolean = True
                For Each c As Col In e.Table.Cols
                    If c.name Like "*调度设备*" Then
                        Dim i As Integer = c.Name.Replace("第", "").Replace("序_调度设备", "")
                        For Each dr As DataRow In e.Table.DataTable.Select(c.name & " = \'" & fdr(dc.name) & "\'")
                            If dr("第" & i & "序_开始日") < e.Row("第" & i & "序_开始日") Then
                                If dr("第" & i & "序_结束日") >= e.Row("第" & i & "序_开始日") Then
                                    flag = False
                                End If
                            ElseIf dr("第" & i & "序_开始日") >= e.Row("第" & i & "序_开始日") Then
                                If dr("第" & i & "序_开始日") <= e.Row("第" & i & "序_结束日") Then
                                    flag = False
                                End If
                            End If
                        Next
                        If flag = False Then Exit For
                    End If
                Next
                If flag = True Then
                    str &= fdr(dc.name) & "|"
                End If
            End If
        Next
    End If
    e.Col.ComboList = str
End If


现在需要将点击列箭头,显示在最上面的自动填充到单元格里,
具体表的信息如图:


--  作者:zhangning
--  发布时间:2017/9/5 15:15:00
--  

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

我写的代码是:
If e.DataRow("类别") = "计划"  Then
    e.DataRow("*序_调度设备*")  = Tables("加工排产").Cols("*序_调度设备*").ComboList.Split("|")(0)
End If



没有反应,请老师帮斧正,谢谢!

--  作者:有点甜
--  发布时间:2017/9/5 15:55:00
--  

做个按钮

 

Dim t As Table = Tables("加工排产")
For Each rr As Row In t.Rows
    For Each cc As Col In t.Cols
        If cc.name Like "*调度设备*" Then
            Dim str As String = ""
            Dim filter As String = "部品ID = \'" & rr("部品ID") & "\'"
            Dim idx As String = cc.Name.Replace("第", "").Replace("序_调度设备", "")
            Dim fdr As DataRow = DataTables("工程和工时").Find(filter & " and 工序序号 = \'" & idx & "\'")
            If fdr IsNot Nothing Then
                For Each dc As DataCol In DataTables("工程和工时").DataCols
                    If dc.name.StartsWith("使用机器") AndAlso fdr.IsNull(dc.name) = False Then
                        str &= fdr(dc.name) & "|"
                    End If
                Next
            End If
            cc.ComboList = str
            Dim ary = str.split("|")
            If ary.length > 0 Then
                rr(cc.name) = ary(0)
            End If
        End If
        If cc.name Like "*调度设备*" Then
            Dim str As String = ""
            Dim filter As String = "部品ID = \'" & rr("部品ID") & "\'"
            Dim idx As String = cc.Name.Replace("第", "").Replace("序_调度设备", "")
            Dim fdr As DataRow = DataTables("工程和工时").Find(filter & " and 工序序号 = \'" & idx & "\'")
            If fdr IsNot Nothing Then
                For Each dc As DataCol In DataTables("工程和工时").DataCols
                    If dc.name.StartsWith("使用机器") AndAlso fdr.IsNull(dc.name) = False Then
                        Dim flag As Boolean = True
                        For Each c As Col In t.Cols
                            If c.name Like "*调度设备*" Then
                                Dim i As Integer = c.Name.Replace("第", "").Replace("序_调度设备", "")
                                For Each dr As DataRow In t.DataTable.Select(c.name & " = \'" & fdr(dc.name) & "\'")
                                    If dr("第" & i & "序_开始日") < rr("第" & i & "序_开始日") Then
                                        If dr("第" & i & "序_结束日") >= rr("第" & i & "序_开始日") Then
                                            flag = False
                                        End If
                                    ElseIf dr("第" & i & "序_开始日") >= rr("第" & i & "序_开始日") Then
                                        If dr("第" & i & "序_开始日") <= rr("第" & i & "序_结束日") Then
                                            flag = False
                                        End If
                                    End If
                                Next
                                If flag = False Then Exit For
                            End If
                        Next
                        If flag = True Then
                            str &= fdr(dc.name) & "|"
                        End If
                    End If
                Next
            End If
            cc.ComboList = str
            Dim ary = str.split("|")
            If ary.length > 0 Then
                rr(cc.name) = ary(0)
            End If
        End If
    Next
Next


--  作者:恒隆君
--  发布时间:2017/9/5 16:36:00
--  
正好可以用到。
--  作者:zhangning
--  发布时间:2017/9/6 8:36:00
--  
老师,您好!
谢谢您帮我写代码,我运行了一下,有几个问题:
1.不是所有的都自动添加了。
2.已经添加的,也不是按照,先使用机器1,如机器1被占用,就选机器2,以此类推

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:精益制造改.rar


麻烦老师,帮看看,谢谢!

--  作者:zhangning
--  发布时间:2017/9/6 8:36:00
--  
密码:qdkf
开发者

--  作者:有点甜
--  发布时间:2017/9/6 8:39:00
--  

判断值,为空的再添加。

 

Dim t As Table = Tables("加工排产")
For Each rr As Row In t.Rows
    For Each cc As Col In t.Cols
        If cc.name Like "*调度设备*" AndAlso rr.isNull(cc.name) Then


--  作者:zhangning
--  发布时间:2017/9/6 8:46:00
--  
3.只是想在“类别”列内容是“计划”时才排设备