-- 作者:xywl
-- 发布时间:2017/7/3 10:18:00
-- 计划有时候能实行,有时候没反应,间隔5350000
我有个夜间12点自动备份两张表数据的计划,这个客户端一直在服务器那里运行着,实行间隔是5350000
但是现在有这么个问题,这个计划不是每天都会实行,有时候隔一天,有时候隔两天都不实行,上一次实行是7月1日,就没有实行了,但是服务器那边一直在运行着。
起初我想没必要间隔时间太短让它一直在后台进行时间对比,那样还得加个判断是否当天已经实行过备份,所以我就让间隔是53.5分钟实行一次,代码还是我请教版主帮忙才做的计划。不知道我哪里搞错了,出现这种状况!
static d11 As Date = Date.today.AddDays(-1) If d11 <> Date.today AndAlso Date.Now.Hour=0 Then d11 = Date.today DataTables("商品库存").Load() DataTables("商品库存明细").Load() For Each r As Row In Tables("商品库存").Rows Dim d1 As Row = Tables("备份商品库存").AddNew() d1("Item") = r("Item") d1("ChineseBrand") = r("ChineseBrand") d1("ChineseDescription") = r("ChineseDescription") d1("EnglishBrand") = r("EnglishBrand") d1("EnglishDescription") = r("EnglishDescription") d1("ItemCategory") = r("ItemCategory") d1("PackSize") = r("PackSize") d1("ItemCategory2") = r("ItemCategory2") d1("Barcode") = r("Barcode") d1("实时库存") = r("实时库存") d1("可用库存") = r("可用库存") d1("待发库存") = r("待发库存") d1("冻结库存") = r("冻结库存") d1("报损库存") = r("报损库存") d1("报损原因") = r("报损原因") d1("报损明细") = r("报损明细") d1("商品状态") = r("商品状态") d1("备份时间") = d11 d1.save() Next For Each r1 As Row In Tables("商品库存明细").Rows Dim d As Row = Tables("备份商品库存明细").AddNew() d("货品编号") = r1("货品编号") d("货品名称") = r1("货品名称") d("类型") = r1("类型") d("条码") = r1("条码") d("货格") = r1("货格") d("箱含量") = r1("箱含量") d("箱") = r1("箱") d("瓶") = r1("瓶") d("实时库存") = r1("实时库存") d("可用库存") = r1("可用库存") d("待发库存") = r1("待发库存") d("冻结库存") = r1("冻结库存") d("报损库存") = r1("报损库存") d("报损原因") = r1("报损原因") d("报损明细") = r1("报损明细") \'d1("商品状态") = r("商品状态") d("入库日期") = r1("入库日期") d("经手人") = r1("经手人") d("生产日期") = r1("生产日期") d("到期日期") = r1("到期日期") d("批次") = r1("批次") d("待入库") = r1("待入库") d("条码类型") = r1("条码类型") d("入库单号") = r1("入库单号") d("冻结") = r1("冻结") d("备份时间") = d11 d.save() Next
End If
|
-- 作者:xywl
-- 发布时间:2017/7/3 14:00:00
--
对了还有一个问题,同样的代码和类似的模板,导出时,焦点在哪一行只导出哪一行是什么原因?
这是导出的代码:
ElseIf ts = "盘点表统计" Then If FileSys.FileExists(ProjectPath & "模板\\盘点表.xls") = False Then Messagebox.Show("盘点表Excel模板不存在或已经被删除,导出失败!","错误提示",MessageBoxButtons.OK, MessageBoxIcon.Warning) Return End If Dim fl As String = ProjectPath & "excel\\盘点表.xls" If FileIsOpened(fl)= True Then MessageBox.Show("""盘点表.xls""文件正在打开中,请先关闭再执行导出操作!") Return End If e.Form.Controls("打印预览").Enabled = True e.Form.Controls("直接打印").Enabled = True Dim Book As New XLS.Book(ProjectPath & "模板\\盘点表.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) With Sheet.PrintSetting .PaperKind = 9 .MarginLeft = 15 .MarginRight = 5 .MarginTop = 5 .MarginBottom = 5 .LandScape = True End With Dim lbl As WinForm.DateTimePicker lbl = e.Form.Controls("DateTimePicker3") Sheet(0,1).Value = lbl.value & "红酒盘点表" Sheet(2,0).Value = "<报表统计_Table1>" Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 e.Form.Controls("打印预览").Enabled = True e.Form.Controls("直接打印").Enabled = True If MessageBox.Show("导出完成,是否打开盘点表?", "完成提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = 1 Then Dim Proc As New Process \'打开工作簿 Proc.File = fl Proc.Start() End If
生成报表的代码:
e.Form.Controls("打印预览").Enabled = False e.Form.Controls("直接打印").Enabled = False Dim lbl3,lbl4 As WinForm.DateTimePicker lbl3 = e.Form.Controls("DateTimePicker3") lbl4 = e.Form.Controls("DateTimePicker4") Dim g As New GroupTableBuilder("出库日报", DataTables("商品库存明细")) g.Groups.AddDef("货品编号", "商品型号") g.Groups.AddDef("货品名称", "商品名") g.Groups.AddDef("货格", "库位") g.Groups.AddDef("批次") g.Groups.AddDef("实时库存","系统数量") g.Build() e.Form.Controls("提示").text = "盘点表统计" Tables("报表统计_Table1").DataSource = g.BuildDataSource()
|
-- 作者:xywl
-- 发布时间:2017/7/3 17:47:00
--
你说的都检查了,没错,与<end>同一列 与细节区同一行。这个可以先不管,商品库存明细同一个库位有若干行,几个批次就几行,我做了个报表统计
在生成细节区之前我做了一次统计:
Select Case e.Book.TempLate Case "库存明细" Dim str2 As String = ""
If e.DataRow IsNot Nothing AndAlso e.Region = "货品编号" Then Dim Filter1 As String = "货品编号 = \'" & e.DataRow("货品编号") & "\' And 货格 = \'" & e.DataRow("货格") & "\'" e.Book.Marks("实时库存") = DataTables("商品库存明细").Compute("Sum(实时库存)",Filter1) e.Book.Marks("可用库存") = DataTables("商品库存明细").Compute("Sum(可用库存)",Filter1) e.Book.Marks("待发库存") = DataTables("商品库存明细").Compute("Sum(待发库存)",Filter1) e.Book.Marks("冻结库存") = DataTables("商品库存明细").Compute("Sum(冻结库存)",Filter1) e.Book.Marks("报损库存") = DataTables("商品库存明细").Compute("Sum(报损库存)",Filter1) For Each dr As String In e.DataRow.DataTable.GetValues("货格", Filter1) str2 &= dr & "," Next e.Book.Marks("货格") = str2.trim(",") End If End Select
然后呢在模板里我这么设置,但是没见效果,就是所有makes 都没数据
应该是还要加个统计对原表进行一次统计才输出才行,本来有769行,导出时不应该有这么多行的
|