我要使用System.Data.DataTable(不使用datagridview)
目的为管理每一个人员的下单情况
黄色和蓝色业绩的栏位,为已经载入的数据
我要计算出
1、连续不下单月份数
2、连续3/6个月不下单
3、连续下单月份数
4、连续3/6个月下单
把这些带有数值的文字塞到灰色及红色的栏位
请问要怎么做呢,这些数据的处理已经和用SQL是没有关系的,直接在ystem.Data.DataTable来计算
谢谢
业绩的部分,是用动态产生的,其整个代码如下
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim cn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\data.mdb;Persist Security Info=True"
cn = New OleDbConnection(cnStr)
Dim sql As String = "select * from mytable"
da = New OleDbDataAdapter(sql, cn)
ds = New DataSet
da.Fill(ds, "Server")
DataGridView1.DataSource = ds.Tables("Server")
cn.Close()
cn.Dispose()
ds.Dispose()
da.Dispose()
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim C_list As String = "2018/9,2018/10,2018/11,2018/12,2019/1,2019/2"
Dim insert_index As Integer = 5
Dim tmp_table As New DataTable
tmp_table = DataGridView1.DataSource
DataGridView1.DataSource = Nothing '必须要释放,不然位置不准确
DataGridView1.DataSource = Insert_Columns(C_list, tmp_table, 5)
End Sub
Function Insert_Columns(ByVal items As String, ByVal DT As DataTable, ByVal index As Integer) As DataTable
Dim New_table As New DataTable
New_table = DT
Dim a() As String
a = Split(items, ",")
For i = 0 To UBound(a)
New_table.Columns.Add(a(i)).SetOrdinal(index + i)
Next
Return New_table
End Function
End Class
其数据库及form为