窗口afterload的代码(我觉得大部分没用,有关系的标红了):
DataTables("PurchaseN_Table2").DataCols("采购下单时间").SetDateTimeFormat(Datetimeformatenum.Datelongtime)
DataTables("PurchaseN_Table2").DataCols("付款时间").SetDateTimeFormat(Datetimeformatenum.Datelongtime)
DataTables("PurchaseN_Table2").DataCols("款清时间").SetDateTimeFormat(Datetimeformatenum.Datelongtime)
If ancs = "xzcgd" Then
e.Form.Controls("ad").performclick()
ElseIf ancs Like "C*" Then
DataTables("PurchaseN_Table2").LoadFilter = "采购编号 = '" & ancs & "'"
DataTables("PurchaseN_Table2").load()
DataTables("PurchaseN_Table1").LoadFilter = "采购编号 = '" & ancs & "'"
DataTables("PurchaseN_Table1").load()
e.Form.Controls("add").Enabled = False
End If
Dim tb As Table = e.Form.Controls("Table1").Table
Dim bm As DataRow = lkb.find("表名 = '" & tb.name & "'")
If bm IsNot Nothing Then
tb.setColVisibleWidth(bm("列宽"))
End If
e.Form.Controls("Table2").Visible = False
Dim zh As WinForm.ComboBox = e.Form.Controls("zh")
Dim sql As new SQLCommand
Dim lsb As DataTable
sql.C
sql.CommandText = "sell ect [账户名称] from {收支账户}"
lsb = sql.ExecuteReader
zh.ComboList = lsb.GetComboListString("账户名称")
Dim fwd As WinForm.ComboBox = e.Form.Controls("fwd")
Dim sql1 As new SQLCommand
Dim lsb1 As DataTable
sql1.C
sql1.CommandText = "sell ect [仓库名称] from {仓库代码表}"
lsb1 = sql1.ExecuteReader
fwd.ComboList = lsb1.GetComboListString("仓库名称") & "|直邮客户"
tb.cols("流水号").Visible = False
tb.Cols("基础货号").DropForm = "BPDrop" '科目列和下拉窗口BPdrop绑定
tb.Grid.Cols("采购编号").Style.BackColor = Color.Gainsboro
tb.Grid.Cols("产品基本名称").Style.BackColor = Color.Gainsboro
tb.Grid.Cols("采购总价").Style.BackColor = Color.Gainsboro
tb.cols("报价").TextAlign = TextAlignEnum.Center
tb.cols("折扣").TextAlign = TextAlignEnum.Center
tb.cols("实际采购单价").TextAlign = TextAlignEnum.Center
tb.cols("数量").TextAlign = TextAlignEnum.Center
tb.cols("采购总价").TextAlign = TextAlignEnum.Center
DataTables("PurchaseN_Table2").DataCols("应付货款").RaiseDataColChanged() '为了让总金额label显示
DataTables("PurchaseN_Table2").DataCols("采购单状态").raisedatacolchanged() '判断一下采购单状态,这个状态有可能通过其他流程更改
If Tables("PurchaseN_Table2").Current.IsNull("付款时间") Then
e.Form.Controls("date").Visible = False
Else
e.Form.Controls("date").Visible = True
End If
If Tables("PurchaseN_Table2").Current.IsNull("款清时间") Then
e.Form.Controls("date1").Visible = False
Else
e.Form.Controls("date1").Visible = True
End If
e.Form.Controls("js").Visible = Tables("PurchaseN_Table2").Current.Locked
table2控件的datacolchanged:
Dim cmd As new SQLCommand
Dim rq As Date
cmd.C
cmd.CommandText = "sell ect getdate()" '获取SQL服务器时间
rq = cmd.ExecuteScalar
If e.DataCol.Name = "已支付金额" Then
If e.DataRow("已支付金额") = 0 Then
e.DataRow("付款时间") = Nothing
e.Form.Controls("date").Visible = False
Else
e.DataRow("付款时间") = rq
e.Form.Controls("date").Visible = True
End If
e.DataRow("未支付金额") = e.DataRow("应付货款") + e.DataRow("应付邮费") - e.DataRow("已支付金额")
End If
If e.DataCol.Name = "应付货款" OrElse e.DataCol.Name = "应付邮费" Then
e.DataRow("未支付金额") = e.DataRow("应付货款") + e.DataRow("应付邮费") - e.DataRow("已支付金额")
e.Form.Controls("zje").value = e.DataRow("应付货款") + e.DataRow("应付邮费")
End If
If e.DataCol.Name = "未支付金额" Then
If e.DataRow("未支付金额") = 0 Then
e.DataRow("款清时间") = rq
e.Form.Controls("date1").Visible = True
ElseIf e.DataRow("未支付金额") > 0 Then
e.DataRow("款清时间") = Nothing
e.Form.Controls("date1").Visible = False
Else
e.DataRow("款清时间") = rq
e.Form.Controls("date1").Visible = True
MessageBox.show("未支付金额是负数,请注意是否合理")
End If
End If
If e.DataCol.Name = "供应商名称" Then
If e.NewValue Is Nothing Then
e.DataRow("供应商编码") = ""
Else
Dim sql As new SQLCommand
Dim lsz As String
sql.C
sql.CommandText = "sell ect [供应商编号] from {供应商表} where [供应商名称] = '" & e.newvalue & "'"
lsz = sql.ExecuteScalar
e.DataRow("供应商编号") = lsz
End If
End If
If e.DataCol.Name = "采购单状态" OrElse e.DataCol.Name = "未支付金额" Then
If (e.DataRow("采购单状态") = "直邮签收" OrElse e.DataRow("采购单状态") = "已入库") AndAlso e.DataRow("未支付金额") = 0 Then
MessageBox.show("采购单已完成,该采购单将锁定")
e.DataRow.Locked = True
e.Form.Controls("js").Visible = True
DataTables("PurchaseN_Table1").AllowEdit = False
End If
End If
[此贴子已经被作者于2020/2/26 15:20:33编辑过]