//import win.ui; 做爲子窗口,能夠引用父窗口的導入庫 /*DSG{{*/ var frmUserUpdate = ..win.form(text="修改密碼";right=372;bottom=319;parent=...) frmUserUpdate.add( button={cls="button";text="肯定";left=60;top=270;right=150;bottom=301;z=4}; button2={cls="button";text="取消";left=236;top=266;right=326;bottom=297;z=5}; listview={cls="listview";left=22;top=52;right=183;bottom=241;bgcolor=16777215;edge=1;z=10}; newpass={cls="edit";left=208;top=130;right=351;bottom=162;edge=1;password=1;z=6}; oldpass={cls="edit";left=208;top=53;right=351;bottom=85;edge=1;password=1;z=3}; pass2={cls="edit";left=208;top=206;right=351;bottom=238;edge=1;password=1;z=7}; static={cls="static";text="請鼠標選擇須要修改密碼的用戶編號";left=16;top=20;right=213;bottom=40;transparent=1;z=1}; static2={cls="static";text="請輸入舊密碼";left=230;top=19;right=327;bottom=33;transparent=1;z=2}; static3={cls="static";text="請輸入新密碼";left=230;top=97;right=327;bottom=111;transparent=1;z=8}; static4={cls="static";text="請確認新密碼";left=230;top=175;right=327;bottom=195;transparent=1;z=9} ) /*}}*/ var db = frmUserUpdate.parent.db frmUserUpdate.listview.insertColumn("用戶編號",70) frmUserUpdate.listview.insertColumn("用戶名",100) for id,name in db.each("SELECT id,用戶名 from [use] ORDER BY id ") { frmUserUpdate.listview.addItem({id;name}) } frmUserUpdate.button2.oncommand = function(id,event){ frmUserUpdate.close() } frmUserUpdate.button.oncommand = function(id,event){ //肯定; var id = frmUserUpdate.listview.getItemText(frmUserUpdate.listview.selIndex,1) var pass = frmUserUpdate.oldpass.text var pass2 = frmUserUpdate.newpass.text var pass3 = frmUserUpdate.pass2.text var rs = db.stepQuery("SELECT 密碼 FROM [use]",{id = id}) rs ?= rs.密碼 if(rs!=pass){ frmUserUpdate.msgbox("舊密碼不符請重輸") frmUserUpdate.oldpass.text = "" frmUserUpdate.oldpass.setFocus(0); } elseif(!#pass2){ frmUserUpdate.msgbox("新密碼不能爲空") frmUserUpdate.newpass.setFont() } elseif(pass3!=pass2){ frmUserUpdate.msgbox("二次輸入密碼不符請重輸") frmUserUpdate.pass2.text = "" frmUserUpdate.pass2.setFocus() } else{ if(db)db.exec("update [use] set 密碼 = @p where id = @id;",{p=pass2;id=id}) frmUserUpdate.msgbox("修改密碼成功") } } frmUserUpdate.listview.onnotify = function(id,code,ptr){ select(code) { case 0xFFFFFFFE/*_NM_CLICK*/{//鼠標點擊用戶編號密碼框置焦點 if(frmUserUpdate.listview.selIndex){ frmUserUpdate.oldpass.text="" frmUserUpdate.oldpass.setFocus() } } } } frmUserUpdate.show() win.loopMessage(); return frmUserUpdate;