$PBExportHeader$w_fx_refuse_reason.srw
forward
global type w_fx_refuse_reason from w_publ_edit_index
end type
end forward

global type w_fx_refuse_reason from w_publ_edit_index
integer y = 388
string title = "订单拒绝原因设定"
boolean minbox = true
windowtype windowtype = popup!
end type
global w_fx_refuse_reason w_fx_refuse_reason

on w_fx_refuse_reason.create
call super::create
end on

on w_fx_refuse_reason.destroy
call super::destroy
end on

event resize;call super::resize;dw_index.width = this.workspacewidth() - dw_index.X
dw_index.height = this.workspaceheight() - dw_index.Y

end event

event open;cb_retrieve.triggerEvent(clicked!)
end event

type cb_func from w_publ_edit_index`cb_func within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_exit from w_publ_edit_index`cb_exit within w_fx_refuse_reason
integer x = 1053
end type

type sle_usual_query from w_publ_edit_index`sle_usual_query within w_fx_refuse_reason
boolean visible = false
end type

type cb_nextpage from w_publ_edit_index`cb_nextpage within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_priorpage from w_publ_edit_index`cb_priorpage within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_firstpage from w_publ_edit_index`cb_firstpage within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_retrieveall from w_publ_edit_index`cb_retrieveall within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type em_pagerowno from w_publ_edit_index`em_pagerowno within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type st_pagerowno from w_publ_edit_index`st_pagerowno within w_fx_refuse_reason
end type

type st_1 from w_publ_edit_index`st_1 within w_fx_refuse_reason
boolean visible = false
end type

type cb_add from w_publ_edit_index`cb_add within w_fx_refuse_reason
integer x = 150
end type

event cb_add::clicked;String arg_msg
OpenWithParm(w_fx_refuse_reason_edit, arg_msg)

s_open_packet s_ret
s_ret = Message.PowerObjectParm
if (s_ret.returnflag = 0) then
    RETURN
end if


String reason
reason = s_ret.postscript
if IsNull(reason) OR reason = '' then
    MessageBox('','拒绝原因不能为空')
    RETURN
end if


arg_msg = ''
oleobject request,response

request  = FXAppCom.CreatePbDictionary()
request.SetString('token',app_token_fx)
request.SetString("reason",reason)
response = FXAppCom.DoExecute("SaveRefuseReason",request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
    MessageBox('',arg_msg)
ELSE
    MessageBox('','新建成功')
    cb_retrieve.triggerEvent(clicked!)
end if
end event

type cb_edit from w_publ_edit_index`cb_edit within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_delet from w_publ_edit_index`cb_delet within w_fx_refuse_reason
integer x = 344
end type

event cb_delet::clicked;Long row
row = dw_index.GetRow()
IF row <= 0 THEN
	MessageBox('','请先选择需要删除的记录')
    RETURN
END IF


String reason
reason = dw_index.Object.reason[row]
if (MessageBox('提示', '确定要删除拒绝原因为['+reason+']的记录?', Question!, YesNoCancel!) <> 1) then return

Long reasonid
reasonid = dw_index.Object.reasonid[row]
string arg_msg
arg_msg = ''
oleobject request,response

request  = FXAppCom.CreatePbDictionary()
request.SetString('token',app_token_fx)
request.SetString("reasonid",reasonid)
response = FXAppCom.DoExecute("DeleteRefuseReason",request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
    MessageBox('',arg_msg)
ELSE
    MessageBox('','删除成功')
    cb_retrieve.triggerEvent(clicked!)
end if
end event

type cb_choice from w_publ_edit_index`cb_choice within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type cb_cancel from w_publ_edit_index`cb_cancel within w_fx_refuse_reason
end type

type cbx_mlselect from w_publ_edit_index`cbx_mlselect within w_fx_refuse_reason
boolean visible = false
end type

type cbx_allselect from w_publ_edit_index`cbx_allselect within w_fx_refuse_reason
boolean visible = false
end type

type cb_mode_itfchg_b from w_publ_edit_index`cb_mode_itfchg_b within w_fx_refuse_reason
end type

type cb_mode_itfchg from w_publ_edit_index`cb_mode_itfchg within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type gb_1 from w_publ_edit_index`gb_1 within w_fx_refuse_reason
end type

type dw_uc from w_publ_edit_index`dw_uc within w_fx_refuse_reason
boolean visible = false
end type

type cb_retrieve from w_publ_edit_index`cb_retrieve within w_fx_refuse_reason
integer x = 0
end type

event cb_retrieve::clicked;dw_index.Reset()
String arg_msg
oleobject request,response,refuseReasonList
Long cnt
cnt = 0

request  = FXAppCom.CreatePbDictionary()
request.SetString('token',app_token_fx)
response = FXAppCom.DoExecute("GetRefuseReasonList",request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
    MessageBox('',arg_msg)
    RETURN
end if
refuseReasonList = response.GetPBArray("refuseReasonList")
IF IsValid(refuseReasonList) THEN
    cnt = refuseReasonList.Count
END IF
IF cnt <= 0 THEN
    RETURN
END IF
Long row, i
oleobject item
FOR i = 1 TO cnt
    item = refuseReasonList.GetPBDictionary(i - 1)
    row = dw_index.InsertRow(0)
    dw_index.SetItem(row,"reasonid",item.GetInt("reasonid"))
    dw_index.SetItem(row,"comid",item.GetInt("comid"))
    dw_index.SetItem(row,"Reason",item.GetString("Reason"))
NEXT
end event

type cb_print from w_publ_edit_index`cb_print within w_fx_refuse_reason
boolean visible = false
boolean enabled = false
end type

type ln_bar from w_publ_edit_index`ln_bar within w_fx_refuse_reason
end type

type ln_bar2 from w_publ_edit_index`ln_bar2 within w_fx_refuse_reason
end type

type r_bar from w_publ_edit_index`r_bar within w_fx_refuse_reason
end type

type ln_1 from w_publ_edit_index`ln_1 within w_fx_refuse_reason
end type

type ln_2 from w_publ_edit_index`ln_2 within w_fx_refuse_reason
end type

type dw_index from w_publ_edit_index`dw_index within w_fx_refuse_reason
integer width = 2571
string dataobject = "dw_fx_refuseReason"
boolean rbutton_filter_use = true
end type

