-- 作者:xywl
-- 发布时间:2017/3/8 18:37:00
-- 选择不同行后实行
有窗口商品上架资料补充,表afterload 代码
Dim lbl,lbl2,lbl3,lbl4 As WinForm.DateTimePicker lbl = e.Form.Controls("DateTimePicker1") lbl2 = e.Form.Controls("DateTimePicker2") lbl3 = e.Form.Controls("DateTimePicker3") lbl4 = e.Form.Controls("DateTimePicker4") \'e.Form.Controls("提示").text = "商品入库明细记录" Dim d As Date = Date.Today Dim y As Integer = d.Year Dim m As Integer = d.Month Dim Days As Integer = Date.DaysInMonth(y,m) Dim fd As Date = New Date(y,m,1) \'获得该月的第一天 Dim ld As Date = New Date(y,m,Days) \'获得该月的最后一天 lbl.Value = fd lbl2.Value = Date.Today lbl3.Value = fd lbl4.Value = Date.Today Tables("商品上架资料补充_Table1").ExtendLastCol = True Tables("商品上架资料补充_table2").ExtendLastCol = True Dim filter As String filter = "待入库 <> \' 0 \'" Tables("商品上架资料补充_Table1").Filter = filter Dim zts As Integer = Tables("商品上架资料补充_Table1").Rows.Count e.Form.Controls("入库总记录数").text = "入库记录数: " & zts & " 条" Dim zsl As Double = Tables("商品上架资料补充_Table1").Compute("Sum(待入库)") e.Form.Controls("待入库总数量").text = "入库总数量: " & zsl If zts > 0 Then Tables("商品上架资料补充_Table2").Filter = "[货品编号] = \'" & Tables("商品上架资料补充_table1").Current("Item") & "\'" End If
副本表一
CurrentChanged事件
Dim zts As Integer = Tables("商品上架资料补充_table1").Rows.Count If zts > 0 Then Tables("商品上架资料补充_Table2").Filter = "[货品编号] = \'" & Tables("商品上架资料补充_table1").Current("Item") & "\'And [待入库] = \'" & Tables("商品上架资料补充_table1").Current("待入库") & " \'" End If
窗口《商品上架资料修改》 afterload事件
If Forms("商品上架资料补充").opened Then e.Form.Controls("商品编号").value = Tables("商品上架资料补充_table2").Current("货品编号") e.Form.Controls("商品名称").value = Tables("商品上架资料补充_table2").Current("货品名称") e.Form.Controls("商品类别").value = Tables("商品上架资料补充_table2").Current("类型") e.Form.Controls("规格").value = Tables("商品上架资料补充_table2").Current("箱含量") e.Form.Controls("库位").value = Tables("商品上架资料补充_table2").Current("货格") e.Form.Controls("条码").value = Tables("商品上架资料补充_table2").Current("条码") e.Form.Controls("条码类型").value = Tables("商品上架资料补充_table2").Current("条码类型") e.Form.Controls("数量").value = Tables("商品上架资料补充_table2").Current("待入库") e.Form.Controls("实时库存").value = Tables("商品上架资料补充_table2").Current("实时库存")+ Tables("商品上架资料补充_table2").Current("待入库")
If Tables("商品上架资料补充_table2").Current("生产日期") = Nothing Then e.Form.Controls("生产日期").value = Nothing Else e.Form.Controls("生产日期").value = Tables("商品上架资料补充_table2").Current("生产日期") End If If Tables("商品上架资料补充_table2").Current("到期日期") = Nothing Then e.Form.Controls("有效期至").value = Nothing Else e.Form.Controls("有效期至").value = Tables("商品上架资料补充_table2").Current("到期日期") End If End If
该窗口的修改按钮事件:
ElseIf yxqz.value = Nothing Then MessageBox.Show("请输入商品的有效期,不能为空!", "错误提示!",MessageBoxButtons.OK,MessageBoxIcon.Warning) e.Form.Controls("有效期至").Select() Return End If Dim spbh As String = e.Form.Controls("商品编号").value Dim spmc As String = e.Form.Controls("商品名称").value Dim splb As String = e.Form.Controls("商品类别").value Dim gg As String = e.Form.Controls("规格").value Dim ly As String = e.Form.Controls("库位").value Dim jz As String = e.Form.Controls("条码").value Dim dw As String = e.Form.Controls("条码类型").value Dim sl As Double = e.Form.Controls("实时库存").value Dim cgj As String = e.Form.Controls("批次").value Dim dr1 As DataRow = DataTables("商品库存明细").Find("货品编号 = \'" & spbh & "\'And 待入库 = \'" & sl & "\'") If dr1 IsNot Nothing Then dr1("实时库存") = sl + dr1("实时库存") dr1("可用库存") = sl + dr1("可用库存") dr1("类型") = splb dr1("生产日期") = scrq.value dr1("到期日期") = yxqz.value dr1("箱含量") = gg dr1("货格") = ly dr1("条码") = jz dr1("条码类型") = dw dr1("批次") = cgj dr1("待入库") = "0" dr1.Save() End If Dim pr As DataRow Dim filter As String filter = "Item = \'" & spbh & "\'" pr = DataTables("商品库存").Find(filter) If pr IsNot Nothing Then pr("实时库存") = sl + pr("实时库存") pr("可用库存") = sl + pr("可用库存") pr("待入库") = "0" pr.Save() End If
MessageBox.Show("商品上架成功!", "成功提示!") e.Form.Controls("商品编号").value = Nothing e.Form.Controls("商品编号").Select()
问题一,点击副本表一的不同行,副本表二没反应(但设计预览时可用),只在点击第一行时有效果
问题二:修改按钮的事件在处理完一次修改后,怎样刷新重新定位“商品编号”到副本表一的当前行的商品编号,也就是重置一次窗口的afterload事件代码,直到副本表一没有可选行,直接关闭。
问题三:曾经提示过一次键值约束,但是现在试了很多次又不见提示了
|