PB的小技巧.doc
文本预览下载声明
PB的小技巧
1.如何使DataWindow中的数据只能追加新记录而不能修改。
利用 Column 的 Protect 属性可以很方便的做到这一点,方法如下:
将每一列的 Protect 属性设置为:
If( IsRowNew(), 0, 1) )
在 PowerScript 中可以动态修改 Protect 属性:
dw_1.Modify(column_name_here.Protect=1~tIf(IsRowNew(),0,1))
2. 允许从空的非字符字段跳离
string s
s = this.dwDescribe(this.GetColumnName()+.coltype)
//s = this.dwDescribe(#+String(this.GetColumn())+.coltype)
CHOOSE CASE s
CASE number
IF Trim(this.GetText()) = THEN
int null_num
SetNull(null_num)
this.SetItem(this.GetRow(),this.GetColumn(),null_num)
this.SetActionCode(3)
END IF
CASE date
IF Trim(this.GetText()) = THEN
date null_date
SetNull(null_date)
this.SetItem(this.GetRow(),this.GetColumn(),null_date)
this.SetActionCode(3)
END IF
CASE time
IF Trim(this.GetText()) = THEN
time null_time
SetNull(null_time)
this.SetItem(this.GetRow(),this.GetColumn(),null_time)
this.SetActionCode(3)
END IF
CASE datetime
IF Trim(this.GetText()) = THEN
date null_datetime
SetNull(null_datetime)
this.SetItem(this.GetRow(),this.GetColumn(),null_datetime)
this.SetActionCode(3)
END IF
END CHOOSE
3. 当我们为Datawindow的每一行显示行号时
可以简单的放一个表达式为GetRow() -- 计算列。
但是对于分组的Datawindow,要分别显示各组的行号,则应使用表达式为
GetRow() - First(GetRow() for Group 1) + 1的计算列。
4.多 用 户 安 全 访 问 数 据 库 的 实 现
数 据 窗 口 的 并 发 性 控 制 可 以 用“rows” 菜 单 的“Update Properties” 项 进 行 设 定。
1.Allow Updates: 如 果 选 中, 则 整 个 数 据 窗 口 允 许 修 改, 否 则 不 允 许;
2.Table to Update: 在 多 表 查 询 时, 用 该 项 选 择 要 设 置 的 表 名;
3.Where Clause for Update/Delete: 这 项 设 置 是 对 数 据 库 并 发 控 制 最 重 要 的 一 项, 要 仔 细 设 置。
当 调 用 数 据 窗 口 的Update 方 法 时,数据窗 口 使 用SQL 语 句 将 数 据 结 果 传 递 到 数 据 库 系 统, 这 项 设 置 决 定 在SQL 语 句 的where 子 句 中 使 用 哪 些 列 作 为 整 条 记 录 的 标 志。
(a)Key Columns: 仅 仅 使 用 关 键 字 作 为 整 条 记 录 的 标 志。 在 网 络 环 境 下 不 推 荐 使 用 此 选 项。 如 果 两 个 用 户 同 时 修 改 了 同 一 条 记 录, 后 进 行 保 存 操 作 的 人 会 把 先 保 存 的 人 所 做 的 修 改“ 抹 掉” 而 毫 无 察 觉。
(b)Key and Updatable Columns: 使 用 关 键 字 和 所
显示全部