$PBExportHeader$w_department_add.srw forward global type w_department_add from w_publ_base end type type dw_1 from datawindow within w_department_add end type type cb_1 from uo_imflatbutton within w_department_add end type end forward global type w_department_add from w_publ_base integer width = 1399 integer height = 828 string title = "部门资料修改" boolean minbox = false windowtype windowtype = response! dw_1 dw_1 cb_1 cb_1 end type global w_department_add w_department_add type variables s_deptype s_dept long i_parentid string i_parent_handtype end variables forward prototypes public function integer wf_checkrand (long arg_deptid) end prototypes public function integer wf_checkrand (long arg_deptid);Long ll_parentid Long ll_deptid_arr[],ll_deptid Long rt_b,rt_s,count,ls_i dw_1.accepttext() ll_parentid = dw_1.object.parentid[dw_1.getrow()] IF ll_parentid = arg_deptid THEN RETURN 1 DECLARE area_cur CURSOR FOR SELECT cw_department.departmentid FROM cw_department Where ( cw_department.parentid = :arg_deptid ); OPEN area_cur; FETCH area_cur INTO :ll_deptid; DO WHILE sqlca.SQLCode = 0 count++ ll_deptid_arr[count] = ll_deptid FETCH area_cur INTO :ll_deptid; LOOP CLOSE area_cur; FOR ls_i = 1 TO count rt_b = wf_checkrand(ll_deptid_arr[ls_i]) IF rt_b <> 0 THEN RETURN rt_b NEXT RETURN 0 end function on w_department_add.create int iCurrent call super::create this.dw_1=create dw_1 this.cb_1=create cb_1 iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.dw_1 this.Control[iCurrent+2]=this.cb_1 end on on w_department_add.destroy call super::destroy destroy(this.dw_1) destroy(this.cb_1) end on event open;call super::open;dw_1.settransobject(sqlca) long ll_row s_dept = message.powerobjectparm if s_dept.departmentid = 0 then ll_row = dw_1.insertrow(0) dw_1.object.departmentid[ll_row] = s_dept.departmentid dw_1.object.sonflag[ll_row] = s_dept.sonflag dw_1.object.parentid[ll_row] = s_dept.parentid else dw_1.retrieve(s_dept.departmentid) end if dw_1.SetFocus() dw_1.SetColumn('parentid') i_parent_handtype =s_dept.parenthandtype s_dept.departmentid = -1 end event event close;call super::close;closewithreturn(this,s_dept) end event type cb_func from w_publ_base`cb_func within w_department_add integer x = 576 integer y = 548 integer width = 311 integer height = 96 string text = "确定" toolbaralignment pic_align = alignatleft! boolean border = true end type event cb_func::clicked;Long ll_row Long ll_deptid,ll_parentid Int ls_cr_rsl String ls_parent_handtype dw_1.AcceptText() ll_row = dw_1.GetRow() IF ll_row <= 0 THEN MessageBox('提示','请选择资料',information!,OK!) RETURN END IF dw_1.Object.deptcode[ll_row] = Trim(dw_1.Object.deptcode[ll_row]) dw_1.Object.departmentname[ll_row] = Trim(dw_1.Object.departmentname[ll_row]) IF dw_1.Object.deptcode[ll_row] = '' THEN MessageBox('提示','请输入部门编号!',information!,OK!) dw_1.setfocus() dw_1.setcolumn('deptcode') RETURN END IF IF dw_1.Object.departmentname[ll_row] = '' THEN MessageBox('提示','请输入部门名称!',information!,OK!) dw_1.setcolumn('departmentname') dw_1.setfocus() RETURN END IF IF pos(dw_1.Object.departmentname[ll_row],'>') > 0 THEN MessageBox('提示','部门名称不能包含>!',information!,OK!) dw_1.SetColumn('departmentname') dw_1.SetFocus() RETURN END IF //检查闭环 ll_deptid = dw_1.Object.departmentid[dw_1.GetRow()] ll_parentid = dw_1.Object.parentid[dw_1.GetRow()] IF ll_deptid > 0 THEN IF ll_parentid <> i_parentid THEN ls_cr_rsl = wf_checkrand(ll_deptid) IF ls_cr_rsl = 1 THEN MessageBox('提示',String(dw_1.Object.departmentname[dw_1.GetRow()])+' 发现环,请核对!',information!,OK!) RETURN ELSEIF ls_cr_rsl < 0 THEN MessageBox('错误','因为网络或其他原因导致查环操作失败!['+String(dw_1.Object.departmentname[dw_1.GetRow()])+']',stopsign!,OK!) RETURN END IF END IF END IF // s_dept.departmentid = dw_1.Object.departmentid[ll_row] s_dept.deptcode = dw_1.Object.deptcode[ll_row] s_dept.departmentname = dw_1.Object.departmentname[ll_row] s_dept.sonflag = dw_1.Object.sonflag[ll_row] s_dept.parentid = dw_1.Object.parentid[ll_row] IF ll_parentid <> i_parentid THEN IF ll_parentid = 0 THEN ls_parent_handtype = '' ELSE SELECT handtype INTO :ls_parent_handtype FROM cw_department Where departmentid = :ll_parentid; IF sqlca.SQLCode <> 0 THEN MessageBox('错误','查询上级部门资料失败',stopsign!,OK!) RETURN END IF END IF ELSE ls_parent_handtype = i_parent_handtype END IF s_dept.handtype =ls_parent_handtype + dw_1.Object.departmentname[ll_row] + '>>' close(parent) end event type cb_exit from w_publ_base`cb_exit within w_department_add integer x = 1015 integer y = 548 integer taborder = 30 end type event cb_exit::clicked;s_dept.departmentid = -1 close(parent) end event type dw_1 from datawindow within w_department_add integer x = 114 integer y = 60 integer width = 1179 integer height = 400 integer taborder = 10 boolean bringtotop = true string title = "none" string dataobject = "dw_department_add" boolean border = false boolean livescroll = true end type type cb_1 from uo_imflatbutton within w_department_add integer x = 137 integer y = 548 integer width = 311 integer height = 96 integer taborder = 40 boolean bringtotop = true string text = "查闭环" end type event clicked;call super::clicked;//检查有否环// Long ll_deptid,ll_parentid Int ls_cr_rsl dw_1.accepttext() IF dw_1.GetRow() <= 0 THEN RETURN ll_deptid = dw_1.Object.departmentid[dw_1.GetRow()] ll_parentid = dw_1.Object.parentid[dw_1.GetRow()] IF ll_deptid <= 0 THEN RETURN IF ll_parentid = i_parentid THEN RETURN ls_cr_rsl = wf_checkrand(ll_deptid) IF ls_cr_rsl = 1 THEN MessageBox('提示',string(dw_1.Object.departmentname[dw_1.GetRow()])+' 发现环,请核对!',information!,OK!) RETURN ELSEIF ls_cr_rsl < 0 THEN MessageBox('错误','因为网络或其他原因导致查环操作失败!['+string(dw_1.Object.cusareaname[dw_1.GetRow()])+']',stopsign!,OK!) RETURN END IF MessageBox('提示','没有发现闭环!',information!,OK!) end event