1、向DataWindow窗口dw_1和dw_2载入页面(FreeForm类型和Grid类型的)
int row_cnt dw_2.dataobject ='freeform_name' dw_1.dataobject ='grid_name' dw_1.settransobject(sqlca) dw_2.settransobject(sqlca) dw_2.sharedata(dw_1) row_cnt =dw_1.Retrieve() dw_1.setsort("system_idasc, domain_code asc") dw_1.sort() dw_1.SetRow(row_cnt) dw_1.ScrollToRow(row_cnt) dw_1.setfocus()
2、设置DataWindow的可编辑性和背景色(modify()方法)
dw_2.modify("datawindow.color= 16777215") dw_2.modify("DataWindow.ReadOnly=yes") dw_2.modify ("question_picture_status.TabSequence=0") dw_2.modify ("data_status.TabSequence=0")
3、
button_name.visible= true/false dropdownlistbox_name.enabled= true/false
4、
ddlb_name.reset() stringv_policecode declarepolicecodecur cursor for select policecode from biz_ code; openpolicecodecur; fetchpolicecodecur into :v_policecode; if sqlca.sqlcode=-1 then Messagebox("","获取列表失败") end if DO WHILE(sqlca.sqlcode=0 ) ddlb_name.additem(v_policecode) fetch policecodecur into :v_policecode; LOOP closepolicecodecur;
5、保存按钮功能的实现代码
long ll_row dwItemStatus l_mod dw_2.accepttext() ll_row =dw_2.getrow() dw_2.object.update_time[ll_row]= string(now(), 'yyyy-MM-dd hh:mm:ss') if ll_row <= 0then return l_mod =dw_2.GetItemStatus (ll_row, 0, primary!) if l_mod =DataModified! or l_mod = NewModified! then if (dw_2.Update(true) = 1) then commit; //获取编辑页面的区域编码等信息 v_ code = dw_2.object.d_code[ll_row] v_ time = string(now(),'yyyy-MM-dd hh:mm:ss') delete biz_d_domain_class_r wheredomain_code = :v_domain_code; commit; //判断区域分类选项的选中状态,并向区域分类关系表插入有效数据 for v_cnt = 1 todw_domain_class_name.rowcount() step 1 v_check_flag = dw_name.getitemnumber(v_cnt,"check_flag") if v_check_flag = 1 then v_class_code = dw_name.getitemstring(v_cnt,"class_code") insert into tname(d_code,cr_time) values(:v_ code,:v_ time); commit; end if next messagebox("","保存成功") else rollback; end if end if dw_1.setrow(ll_row) dw_1.scrolltorow(ll_row)
6、两个数据窗口同步数据(写在dw_1的rbuttondown事件中)
dw_1.selectrow(0,false) dw_1.selectrow(row,true) dw_2.scrolltorow(row)
7、创建动态DataWindow
string str_err_sql,str_err_create,str_sql,str_syntax,str_style str_sql="select name,class from biz_class where id = " + gv_id; str_style= "style(type = Grid)" //生成SELECT语句对应的自由风格的数据窗口语法 str_syntax=sqlca.SyntaxFromSQL(str_sql,str_style,str_err_sql) messagebox("str_sql",str_sql) messagebox("str_syntax",str_syntax) if len(str_err_sql)>0 then messagebox("错误","取得SQL语法时出错" + str_err_sql) return else dw_1.create(str_syntax,str_err_create) if len(str_err_create)>0 then messagebox("错误","创建数据窗口时出错!") return end if end if dw_1.settransobject(sqlca) dw_1.retrieve()
注意:以上是通过网上找的代码,跟自己实现了功能对应的代码,觉得别人总结的好,我就参照了。