//import win.ui; /*DSG{{*/ var frmUserDel = ..win.form(text="刪除用戶";right=376;bottom=320;parent=...) frmUserDel.add( button={cls="button";text="肯定";left=229;top=148;right=319;bottom=179;z=4}; button2={cls="button";text="取消";left=229;top=240;right=319;bottom=271;z=5}; listview={cls="listview";left=19;top=56;right=180;bottom=271;bgcolor=16777215;edge=1;z=6}; password={cls="edit";left=198;top=56;right=341;bottom=88;edge=1;password=1;z=3}; static={cls="static";text="系統現有用戶";left=17;top=20;right=164;bottom=44;transparent=1;z=1}; static2={cls="static";text="請輸入所選用戶的密碼";left=191;top=20;right=355;bottom=47;transparent=1;z=2} ) /*}}*/ var db = frmUserDel.parent.db frmUserDel.listview.insertColumn("用戶編號",70) frmUserDel.listview.insertColumn("用戶名",100) for id,name in db.each("SELECT id,用戶名 from [use] ORDER BY id"){ frmUserDel.listview.addItem({id;name}) } frmUserDel.button.oncommand = function(id,event){//肯定 var id = frmUserDel.listview.getItemText(frmUserDel.listview.selIndex,1) var pass = frmUserDel.password.text var rs = db.stepQuery("SELECT 密碼 FROM [use]",{id = id}) rs ?= rs.密碼 if(rs!=pass){ frmUserDel.msgbox("密碼不符請重輸") frmUserDel.password.text = "" frmUserDel.password.setFocus(0); } elseif(frmUserDel.listview.count=1){ frmUserDel.msgbox("刪除無效,系統必須有一個!") frmUserDel.close() } else{ db.exec("DELETE FROM [use] where id=@id",{id = id}) frmUserDel.msgbox("刪除成功") frmUserDel.listview.delItem(frmUserDel.listview.selIndex) } } frmUserDel.button2.oncommand = function(id,event){ frmUserDel.close() } frmUserDel.listview.onnotify = function(id,code,ptr){ select(code) { case 0xFFFFFFFE/*_NM_CLICK*/{//鼠標點擊用戶編號密碼框置焦點 if(frmUserDel.listview.selIndex){ frmUserDel.password.text = "" frmUserDel.password.setFocus() } } } } frmUserDel.show() win.loopMessage(); return frmUserDel;