Dim dtb As New DataTableBuilder("每周菜谱")
dtb.AddDef("年级组", Gettype(String),20)
dtb.AddDef("日期", Gettype(String), 20)
dtb.AddDef("星期", Gettype(String), 6)
dtb.AddDef("菜名", Gettype(String),20)
dtb.AddDef("餐别", Gettype(String),20)
dtb.Build()
DataTables("每周菜谱").DataCols("日期").SetDateTimeFormat(DatetimeformatEnum.Date)
Dim dt As DataTable = DataTables("每周菜谱")
Dim d1 As Date = Date.Today
InputValue(d1, "日期筛选","请输入开始日期:")
d1 = new Date(year(d1),Month(d1),day(d1))
Dim d2 As Date = Date.Today
InputValue(d2, "日期筛选","请输入结束日期:")
d2 = new Date(year(d2),Month(d2),day(d2))
For Each drs As String In DataTables("菜谱").GetValues("日期","日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#")
For Each nianjz As String In DataTables("菜谱").GetValues("年级组","")
For Each cb As String In DataTables("菜谱").GetValues("餐别","") '日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# and 年级组 = '" & nianjz & "'")
For Each cm As String In DataTables("菜谱").GetValues("菜名","日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# and 餐别='" & cb & "' and 年级组 = '" & nianjz & "'","[_sortkey]")
For Each fs As String In DataTables("菜谱").GetValues("份数","日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# and 餐别='" & cb & "' and 年级组 = '" & nianjz & "'")
Dim d As Date = cdate(drs)
Dim dr As DataRow = dt.AddNew
dr("日期") = d
dr("星期") = "星期" & "日一二三四五六".Chars(d.DayOfWeek)
dr("年级组") = nianjz
dr("菜名") = cm & "(" & fs & "份)"
Dim str As String = ""
Dim s2 As String = DataTables("菜谱").sqlGetComboListString("菜品材料 & 合计 & 单位","日期=#" & d & "# and 餐别='" & cb & "' and 菜名='" & cm & "' and 年级组 = '" & nianjz & "'")',"[_sortkey]")
str = str & vbcrlf & s2.Replace("|",",")
str = str.Trim(vbcr,vblf) '删除其中的换行符(vblf)和回车符(vbcr)
dr(cb) = str
Next
Next
Next
Next
Next
Tables("每周菜谱").AutoSizeCols
Tables("每周菜谱").AutoSizeRows
DataTables("每周菜谱").save()