
Code AardioLine:103复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.import
godking.vlistEx;import
fonts.fontAwesomeimport
win
.ui;- mainForm =
win
.form(text="客户信息管理"
;right=967
;bottom=556
;border="none"
) - mainForm.add(
- addData={cls=
"plus"
;text='\uF067 新增'
;left=8
;top=80
;right=77
;bottom=110
;bgcolor=15780518
;dl=1
;dt=1
;font=LOGFONT(h=-16
;name='FontAwesome'
);notify=1
;z=4
}; - bkplus={cls=
"bkplus"
;left=-3
;top=-2
;right=972
;bottom=76
;aw=1
;bgcolor=32768
;z=1
}; - delData={cls=
"plus"
;text='\uF068 删除'
;left=80
;top=80
;right=149
;bottom=110
;bgcolor=15780518
;dl=1
;dt=1
;font=LOGFONT(h=-16
;name='FontAwesome'
);notify=1
;z=5
}; - edit={cls=
"edit"
;left=752
;top=80
;right=960
;bottom=112
;edge=1
;z=8
}; - plus={cls=
"plus"
;left=12
;top=8
;right=81
;bottom=66
;background="\google-play-books.ico"
;dl=1
;dt=1
;z=2
}; - static={cls=
"static"
;text="客户信息管理"
;left=89
;top=10
;right=313
;bottom=59
;color=65535
;dl=1
;dt=1
;font=LOGFONT(h=-35
);transparent=1
;z=3
}; - static2={cls=
"static"
;text="客户名称查询"
;left=630
;top=84
;right=739
;bottom=109
;align="right"
;color=16711680
;dr=1
;dt=1
;font=LOGFONT(h=-16
);transparent=1
;z=6
}; - vlist={cls=
"vlistEx"
;left=6
;top=116
;right=965
;bottom=554
;ah=1
;aw=1
;dl=1
;dt=1
;edge=1
;z=7
} - )
import
win
.ui.simpleWindow;win
.ui.simpleWindow(mainForm);- mainForm.vlist.headerFont = ::LOGFONT(name=
"黑体"
;h=17
;color=0xFFFFFF ); - mainForm.vlist.headerAlign =
1
; - mainForm.vlist.headerBkcolor = 0xFF901E;
- mainForm.vlist.bkColor2 = 0x98FB98;
import
godking.connvar
db = godking.conn.openAccess("/Database.accdb"
,)var
sql = "select id,pname as 姓名,iif(sex,'男','女') as 性别,age as 年龄,addr as 地址 from [人员名单] order by id"
var
t = db.getTable( sql,false,,, );- mainForm.vlist.setTable(t,,,1,,,)
- mainForm.addData.oncommand =
function
(id,event){ -
var
rs = db.rs("[人员名单]"
); - rs.AddNew();
- rs.setValue(
"sex"
,1
); - rs.UpDate();
-
var
id = rs.getValue("ID"
); - rs.close()
- mainForm.vlist.addRow({id=id,性别=
"男"
,年龄=0
}); - }
- mainForm.delData.oncommand =
function
(id,event){ -
var
rows,ids = mainForm.vlist.getSelected(,1); -
if
-
var
idstr = ..string
.join(ids,","
) -
var
sql = "DELETE from [人员名单] WHERE id in ("
++idstr++")"
; -
if
!db.exec(sql) { - ..
win
.msgbox("删除数据失败!"
); - }
else
{ -
for
(i= - mainForm.vlist.delRow(rows[i]);
- }
- }
- }
- }
- mainForm.vlist.onEditEnd =
function
(row,col,text,endType){ -
if
row and
col { -
var
id = owner
.getCellText(row,1
); -
if
id { -
var
field = ({"pname"
,"sex"
,"age"
,"addr"
})[col-1
]; -
var
value = text; -
if
col==2
or
col==5
{ - value ='
"'++text++'"
'; - }
elseif
col==3
{ - value = text===
"男"
?1
:0
; - }
elseif
col==4
{ - value =
tonumber
(text,10
):0
; - }
-
var
sql = "UPDATE [人员名单] SET "
++field++"="
++value++" WHERE id="
++id; -
if
!db.exec(sql) { - ..
win
.msgbox("数据更新失败"
); -
return
false
; - }
- }
- }
- }
- mainForm.edit.oncommand =
function
(id,event){ -
if
mainForm.edit.text = ""
{ - mainForm.vlist.filter()
- }
else
{ - mainForm.vlist.filter(mainForm.edit.text,
"姓名"
,true); - mainForm.vlist.update()
-
- }
- }
- mainForm.vlist.onEditBegin = {
false
,1
}; - mainForm.vlist.setColumnType(3,1,true,0xAAAAAA );
- mainForm.vlist.getComboBox().items={
"男"
,"女"
} - mainForm.show();
return
win
.loopMessage();
exec函数的格式化参数用法:
Code AardioLine:103复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.import
godking.vlistEx;import
fonts.fontAwesomeimport
win
.ui;- mainForm =
win
.form(text="客户信息管理"
;right=967
;bottom=556
;border="none"
) - mainForm.add(
- addData={cls=
"plus"
;text='\uF067 新增'
;left=8
;top=80
;right=77
;bottom=110
;bgcolor=15780518
;dl=1
;dt=1
;font=LOGFONT(h=-16
;name='FontAwesome'
);notify=1
;z=4
}; - bkplus={cls=
"bkplus"
;left=-3
;top=-2
;right=972
;bottom=76
;aw=1
;bgcolor=32768
;z=1
}; - delData={cls=
"plus"
;text='\uF068 删除'
;left=80
;top=80
;right=149
;bottom=110
;bgcolor=15780518
;dl=1
;dt=1
;font=LOGFONT(h=-16
;name='FontAwesome'
);notify=1
;z=5
}; - edit={cls=
"edit"
;left=752
;top=80
;right=960
;bottom=112
;edge=1
;z=8
}; - plus={cls=
"plus"
;left=12
;top=8
;right=81
;bottom=66
;background="\google-play-books.ico"
;dl=1
;dt=1
;z=2
}; - static={cls=
"static"
;text="客户信息管理"
;left=89
;top=10
;right=313
;bottom=59
;color=65535
;dl=1
;dt=1
;font=LOGFONT(h=-35
);transparent=1
;z=3
}; - static2={cls=
"static"
;text="客户名称查询"
;left=630
;top=84
;right=739
;bottom=109
;align="right"
;color=16711680
;dr=1
;dt=1
;font=LOGFONT(h=-16
);transparent=1
;z=6
}; - vlist={cls=
"vlistEx"
;left=6
;top=116
;right=965
;bottom=554
;ah=1
;aw=1
;dl=1
;dt=1
;edge=1
;z=7
} - )
import
win
.ui.simpleWindow;win
.ui.simpleWindow(mainForm);- mainForm.vlist.headerFont = ::LOGFONT(name=
"黑体"
;h=17
;color=0xFFFFFF ); - mainForm.vlist.headerAlign =
1
; - mainForm.vlist.headerBkcolor = 0xFF901E;
- mainForm.vlist.bkColor2 = 0x98FB98;
import
godking.connvar
db = godking.conn.openAccess("/Database.accdb"
,);if
!db error
("数据库连接失败"
);var
sql = "select id,pname as 姓名,iif(sex,'男','女') as 性别,age as 年龄,addr as 地址 from [人员名单] order by id"
var
t = db.getTable( sql,false,,, );- mainForm.vlist.setTable(t,,,1,,,);
- mainForm.addData.oncommand =
function
(id,event){ -
var
rs = db.rs("[人员名单]"
); - rs.AddNew();
- rs.setValue(
"sex"
,1
); - rs.UpDate();
-
var
id = rs.getValue("ID"
); - rs.close()
- mainForm.vlist.addRow({id=id,性别=
"男"
,年龄=0
}); - }
- mainForm.delData.oncommand =
function
(id,event){ -
var
rows,ids = mainForm.vlist.getSelected(,1); -
if
-
var
sql = "DELETE from [人员名单] WHERE id in (?)"
; -
if
!db.exec(sql,ids) { - ..
win
.msgbox("删除数据失败!"
); - }
else
{ - mainForm.vlist.delRow(rows);
- }
- }
- }
- mainForm.vlist.onEditEnd =
function
(row,col,text,endType){ -
if
row and
col { -
var
id = tonumber
(owner
.getCellText(row,1
)); -
if
id { -
var
field = ({"pname"
,"sex"
,"age"
,"addr"
})[col-1
]; -
var
value = text; -
if
col==3
{ - value = text===
"男"
; - }
elseif
col==4
{ - value =
tonumber
(text,10
):0
; -
if
value<=0
or
value>500
return
false
; - text =
tostring
(value); - }
-
var
sql = "UPDATE [人员名单] SET ??=? WHERE id=?"
; -
if
!db.exec(sql,field,value,id) { - ..
win
.msgbox("数据更新失败"
); -
return
false
; - }
-
return
text; - }
- }
- }
- mainForm.edit.oncommand =
function
(id,event){ -
if
mainForm.edit.text = ""
{ - mainForm.vlist.filter();
- }
else
{ - mainForm.vlist.filter(mainForm.edit.text,
"姓名"
,true); - }
- }
- mainForm.vlist.onEditBegin = {
false
,1
}; - mainForm.vlist.setColumnType(3,1,true,0xAAAAAA );
- mainForm.vlist.getComboBox().items={
"男"
,"女"
}; - mainForm.onClose =
function
(hwnd,message,wParam,lParam){ - db.close();
- }
- mainForm.show();
return
win
.loopMessage();