Foxtable(狐表)用户栏目专家坐堂 → 录入多行重复材料资料,如何出现警告


  共有2556人关注过本帖树形打印复制链接

主题:录入多行重复材料资料,如何出现警告

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/26 11:35:00 [显示全部帖子]

If e.Form.Controls("ComboBox1").Value = Nothing Then
    MessageBox.Show("请选择供应商")
    Return
End If

For Each r As Row In Tables("临时材料表").rows
    For Each c As Col In Tables("临时材料表").cols
        If r.IsNull(c.name) Then
            MessageBox.Show(r.index+1 & "行 " & c.name & " 列为空")
            Return
        End If
    Next
Next

Dim Cols1() As  String = {"产品名称","型号规格","单位","单价"}
Dim Cols2() As  String = {"产品名称","型号规格","单位","单价"}
Dim idxs As String = "-1,"
For Each dr1 As DataRow In DataTables("临时材料表").Select("")
    Dim dr2 As DataRow = DataTables("材料表").find("供应商 = '" & e.Form.Controls("ComboBox1").text & "' and 产品名称 = '" & dr1("产品名称") & "' and 型号规格 = '" & dr1("型号规格") & "'")
    If dr2 Is Nothing Then
        dr2 = DataTables("材料表").AddNew()
        dr2("供应商")=e.Form.Controls("ComboBox1").text
        For i As Integer = 0 To Cols1.Length-1
            dr2(Cols2(i))=dr1(Cols1(i))
        Next
        idxs &= dr1("_Identify") & ","
    End If
Next
DataTables("临时材料表").DeleteFor("_Identify in (" & idxs.trim(",") & ")")


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/27 20:06:00 [显示全部帖子]

If e.Form.Controls("ComboBox1").Value = Nothing Then
    MessageBox.Show("请选择供应商")
    Return
End If
Dim t As Table = e.Form.controls("table1").Table
For Each r As Row In t.rows
    For Each c As Col In t.cols
        If r.IsNull(c.name) Then
            MessageBox.Show(r.index+1 & "行 " & c.name & " 列为空")
            Return
        End If
    Next
Next

Dim Cols1() As  String = {"产品名称","型号规格","单位","单价"}
Dim Cols2() As  String = {"产品名称","型号规格","单位","单价"}
Dim idxs As String = "-1,"
Dim ls_add As new List(Of Row)
Dim dic As new Dictionary(of Row, DataRow)
For i As Integer = 0 To t.Rows.count-1
    Dim dr1 As Row = t.Rows(i)
    Dim dr2 As DataRow = DataTables("材料表").find("供应商 = '" & e.Form.Controls("ComboBox1").text & "' and 产品名称 = '" & dr1("产品名称") & "' and 型号规格 = '" & dr1("型号规格") & "'")
   
    If dr2 Is Nothing Then
        ls_add.add(dr1)
    Else
        dic.Add(dr1, dr2)
    End If
Next
If dic.count > 0 Then
    Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1")
    cs1.backcolor = Color.red
    cs1.Forecolor = Color.white
    For Each key As Row In dic.Keys
        t.Grid.SetCellStyle(key.Index+1, 4, cs1)
    Next
    Dim Result As DialogResult
    Result = MessageBox.Show("是否替换", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
       
        For Each key As Row In dic.Keys
            Dim dr2 = dic(key)
            dr2("供应商")=e.Form.Controls("ComboBox1").text
            For i As Integer = 0 To Cols1.Length-1
                dr2(Cols2(i))=key(Cols1(i))
            Next
            Dim c = t.Grid.GetCellRange(key.Index+1, 4)
            c.Style = Nothing
        Next
       
        For Each r As Row In ls_add
            Dim dr2 = DataTables("材料表").AddNew()
            dr2("供应商")=e.Form.Controls("ComboBox1").text
            For i As Integer = 0 To Cols1.Length-1
                dr2(Cols2(i))=r(Cols1(i))
            Next
        Next
    End If
    t.DataTable.DataRows.Clear
Else
    For Each r As Row In ls_add
        Dim dr2 = DataTables("材料表").AddNew()
        dr2("供应商")=e.Form.Controls("ComboBox1").text
        For i As Integer = 0 To Cols1.Length-1
            dr2(Cols2(i))=r(Cols1(i))
        Next
    Next
    t.DataTable.DataRows.Clear
End If


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/31 15:37:00 [显示全部帖子]

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:cai4.table


 回到顶部