$PBExportHeader$w_department_edit.srw forward global type w_department_edit from w_publ_base end type type cb_refresh from uo_imflatbutton within w_department_edit end type type cb_add from uo_imflatbutton within w_department_edit end type type cb_add_next from uo_imflatbutton within w_department_edit end type type cb_mod from uo_imflatbutton within w_department_edit end type type cb_del from uo_imflatbutton within w_department_edit end type type tv_1 from uo_tv_deptype within w_department_edit end type type cb_help from uo_imflatbutton within w_department_edit end type type r_bar from rectangle within w_department_edit end type type ln_bar from line within w_department_edit end type type ln_bar2 from line within w_department_edit end type end forward global type w_department_edit from w_publ_base integer width = 2153 integer height = 2380 string title = "部门" cb_refresh cb_refresh cb_add cb_add cb_add_next cb_add_next cb_mod cb_mod cb_del cb_del tv_1 tv_1 cb_help cb_help r_bar r_bar ln_bar ln_bar ln_bar2 ln_bar2 end type global w_department_edit w_department_edit type variables long il_hand end variables forward prototypes public function integer wf_cnt_dot (string arg_mtrltype) end prototypes public function integer wf_cnt_dot (string arg_mtrltype);long rst_cnt string ls_mtrltype long pos_dot ls_mtrltype = arg_mtrltype again: pos_dot = pos(ls_mtrltype,'>>') if pos_dot > 0 then rst_cnt++ ls_mtrltype = mid( ls_mtrltype,pos_dot + 2 ) goto again else goto ext end if ext: return rst_cnt end function on w_department_edit.create int iCurrent call super::create this.cb_refresh=create cb_refresh this.cb_add=create cb_add this.cb_add_next=create cb_add_next this.cb_mod=create cb_mod this.cb_del=create cb_del this.tv_1=create tv_1 this.cb_help=create cb_help this.r_bar=create r_bar this.ln_bar=create ln_bar this.ln_bar2=create ln_bar2 iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.cb_refresh this.Control[iCurrent+2]=this.cb_add this.Control[iCurrent+3]=this.cb_add_next this.Control[iCurrent+4]=this.cb_mod this.Control[iCurrent+5]=this.cb_del this.Control[iCurrent+6]=this.tv_1 this.Control[iCurrent+7]=this.cb_help this.Control[iCurrent+8]=this.r_bar this.Control[iCurrent+9]=this.ln_bar this.Control[iCurrent+10]=this.ln_bar2 end on on w_department_edit.destroy call super::destroy destroy(this.cb_refresh) destroy(this.cb_add) destroy(this.cb_add_next) destroy(this.cb_mod) destroy(this.cb_del) destroy(this.tv_1) destroy(this.cb_help) destroy(this.r_bar) destroy(this.ln_bar) destroy(this.ln_bar2) end on event resize;call super::resize;ln_bar.endx = this.width ln_bar2.endx = this.width r_bar.width = this.width tv_1.height = this.height - tv_1.y - 100 end event type cb_func from w_publ_base`cb_func within w_department_edit boolean visible = false integer x = 1701 integer y = 8 integer width = 219 end type type cb_exit from w_publ_base`cb_exit within w_department_edit integer x = 1024 integer width = 151 integer height = 172 integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event cb_exit::clicked;close(parent) end event type cb_refresh from uo_imflatbutton within w_department_edit integer width = 151 integer height = 172 integer taborder = 80 boolean bringtotop = true string text = "重查" string normalpicname = "refresh.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;tv_1.f_maketree() end event type cb_add from uo_imflatbutton within w_department_edit integer x = 151 integer width = 210 integer height = 172 integer taborder = 80 boolean bringtotop = true string text = "增同级" string normalpicname = "mx1.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;IF NOT f_power_ind(192) THEN MessageBox('提示','你没有使用权限!',information!,OK!) RETURN END IF IF tv_1.uo_cur_info.departmentid = 0 THEN MessageBox("提示",'不能建立部门',information!,OK!) RETURN END IF s_deptype s_dept,s_r_dept Long ll_departmentid,ll_parentid String ls_deptcode,ls_departmentname,ls_handtype Int li_sonflag String arg_msg String ls_parent_handtype s_dept.departmentid = 0 s_dept.deptcode = tv_1.uo_cur_info.deptcode s_dept.departmentname = tv_1.uo_cur_info.departmentname s_dept.sonflag = 1 s_dept.parentid = tv_1.uo_cur_info.parentid IF tv_1.uo_cur_info.parentid = 0 THEN s_dept.parenthandtype = '' ELSE SELECT handtype INTO :ls_parent_handtype FROM cw_department Where departmentid = :tv_1.uo_cur_info.parentid; IF sqlca.SQLCode <> 0 THEN MessageBox('错误','查询上级部门资料失败',stopsign!,OK!) RETURN END IF s_dept.parenthandtype = ls_parent_handtype END IF OpenWithParm(w_department_add,s_dept) s_r_dept = Message.PowerObjectParm IF s_r_dept.departmentid = -1 THEN RETURN ls_deptcode = s_r_dept.deptcode ls_departmentname = s_r_dept.departmentname ls_handtype = s_r_dept.handtype ll_parentid = s_r_dept.parentid li_sonflag = s_r_dept.sonflag ll_departmentid = f_sys_scidentity(0,"cw_department","departmentid",arg_msg,TRUE,sqlca) IF ll_departmentid <= 0 THEN MessageBox('错误',arg_msg,stopsign!,OK!) RETURN END IF INSERT INTO cw_department (departmentid, deptcode, departmentname, handtype, sonflag, parentid) VALUES (:ll_departmentid, :ls_deptcode, :ls_departmentname, :ls_handtype, :li_sonflag, :ll_parentid) ; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE cw_department SET sonflag = 0 Where cw_department.departmentid = :ll_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF COMMIT; MessageBox('提示','新建部门操作成功!',information!,OK!) Long ll_hand,ll_handl TreeViewItem l_tvi ll_hand = tv_1.FindItem(parenttreeitem!,il_hand) ll_handl = tv_1.InsertItemSort(ll_hand,ls_deptcode+'-'+ls_departmentname,2) IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN l_tvi.Label = ls_deptcode+'-'+ls_departmentname l_tvi.Data = ll_departmentid tv_1.SetItem(ll_handl, l_tvi) tv_1.SetFocus() tv_1.SelectItem ( ll_handl ) END IF end event type cb_add_next from uo_imflatbutton within w_department_edit integer x = 361 integer width = 210 integer height = 172 integer taborder = 90 boolean bringtotop = true string text = "增下级" string normalpicname = "mx2.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;if not f_power_ind(192) then messagebox('提示','你没有使用权限!',information!,OK!) return end if s_deptype s_dept,s_r_dept Long ll_departmentid,ll_parentid String ls_deptcode,ls_departmentname,ls_handtype Int li_sonflag String arg_msg s_dept.departmentid = 0 s_dept.deptcode = tv_1.uo_cur_info.deptcode s_dept.departmentname = tv_1.uo_cur_info.departmentname s_dept.sonflag = 1 IF tv_1.uo_cur_info.departmentid = 0 THEN s_dept.parentid = 0 s_dept.parenthandtype = '' ELSE s_dept.parentid = tv_1.uo_cur_info.departmentid s_dept.parenthandtype = tv_1.uo_cur_info.handtype END IF OpenWithParm(w_department_add,s_dept) s_r_dept = Message.PowerObjectParm IF s_r_dept.departmentid = -1 THEN RETURN ls_deptcode = s_r_dept.deptcode ls_departmentname = s_r_dept.departmentname ls_handtype = s_r_dept.handtype ll_parentid = s_r_dept.parentid li_sonflag = s_r_dept.sonflag ll_departmentid = f_sys_scidentity(0,"cw_department","departmentid",arg_msg,TRUE,sqlca) IF ll_departmentid <= 0 THEN MessageBox('提示',arg_msg,stopsign!,OK!) RETURN END IF INSERT INTO cw_department (departmentid, deptcode, departmentname, handtype, sonflag, parentid) Values (:ll_departmentid, :ls_deptcode, :ls_departmentname, :ls_handtype, :li_sonflag, :ll_parentid) ; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE cw_department SET sonflag = 0 Where cw_department.departmentid = :ll_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF COMMIT; MessageBox('提示','新建部门操作成功!',information!,OK!) Long ll_handl TreeViewItem l_tvi ll_handl = tv_1.InsertItemSort(il_hand,ls_deptcode+'-'+ls_departmentname,2) IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN l_tvi.Label = ls_deptcode+'-'+ls_departmentname l_tvi.Data = ll_departmentid tv_1.SetItem(ll_handl, l_tvi) tv_1.SetFocus() tv_1.SelectItem ( ll_handl ) END IF end event type cb_mod from uo_imflatbutton within w_department_edit integer x = 571 integer width = 151 integer height = 172 integer taborder = 90 boolean bringtotop = true string text = "修改" string normalpicname = "open.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;IF NOT f_power_ind(192) THEN MessageBox('提示','你没有使用权限!',information!,OK!) RETURN END IF IF tv_1.uo_cur_info.departmentid = 0 THEN MessageBox('提示','请选择要修改当前部门!',information!,OK!) RETURN END IF s_deptype s_dept,s_r_dept Long cnt Long ll_departmentid Long ll_old_parentid Long ll_new_parentid String ls_deptcode String ls_new_departmentname String ls_old_departmentname String ls_new_handtype String ls_old_handtype String ls_update_handtype Int li_sonflag s_dept.departmentid = tv_1.uo_cur_info.departmentid s_dept.deptcode = tv_1.uo_cur_info.deptcode s_dept.departmentname = tv_1.uo_cur_info.departmentname s_dept.sonflag = tv_1.uo_cur_info.sonflag s_dept.parentid = tv_1.uo_cur_info.parentid s_dept.parenthandtype = tv_1.uo_cur_info.parenthandtype ll_departmentid = tv_1.uo_cur_info.departmentid ll_old_parentid = tv_1.uo_cur_info.parentid ls_old_departmentname = tv_1.uo_cur_info.departmentname ls_old_handtype = tv_1.uo_cur_info.handtype ls_update_handtype = ls_old_handtype + '%' OpenWithParm(w_department_add,s_dept) s_r_dept = Message.PowerObjectParm IF s_r_dept.departmentid = - 1 THEN RETURN ls_deptcode = s_r_dept.deptcode ls_new_departmentname = s_r_dept.departmentname ls_new_handtype = s_r_dept.handtype ll_new_parentid = s_r_dept.parentid li_sonflag = s_r_dept.sonflag UPDATE cw_department SET deptcode = :ls_deptcode, departmentname = :ls_new_departmentname, sonflag = :li_sonflag, parentid = :ll_new_parentid, handtype = :ls_new_handtype Where (departmentid = :ll_departmentid ) ; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','修改名称操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE cw_department SET handtype = replace(handtype,:ls_old_handtype,:ls_new_handtype) Where handtype Like :ls_update_handtype; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','修改部门资料操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE u_rs_empinfo SET deptype = :ls_new_departmentname Where deptid = :ll_departmentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE u_rs_empinfo SET handtype = replace(handtype,:ls_old_handtype,:ls_new_handtype) Where handtype Like :ls_update_handtype; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!) RETURN END IF UPDATE cw_department SET sonflag = 0 Where cw_department.departmentid = :ll_new_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','更新部门"'+ls_new_departmentname+'"上级部门失败',stopsign!,OK!) RETURN END IF IF ll_old_parentid <> ll_new_parentid THEN SELECT count(*) INTO :cnt FROM cw_department Where parentid = :ll_old_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','查询上级部门是否还存在下级部门失败',stopsign!,OK!) RETURN END IF IF cnt = 0 THEN UPDATE cw_department SET sonflag = 1 Where departmentid = :ll_old_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('错误','更新上级部门资料失败',stopsign!,OK!) RETURN END IF END IF END IF COMMIT; MessageBox('提示','部门修改成功!',information!,OK!) TreeViewItem l_tvi IF tv_1.GetItem(il_hand,l_tvi) > 0 THEN l_tvi.Label = ls_deptcode + '-'+ls_new_departmentname l_tvi.Data = ll_departmentid tv_1.SetItem(il_hand, l_tvi) tv_1.SetFocus() tv_1.SelectItem ( il_hand ) END IF end event type cb_del from uo_imflatbutton within w_department_edit integer x = 722 integer width = 151 integer height = 172 integer taborder = 100 boolean bringtotop = true string text = "删除" string normalpicname = "delete.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;long cnt if not f_power_ind(192) then messagebox('提示','你没有使用权限!',information!,OK!) return end if if MessageBox('询问','是否要确定删除当前部门', Exclamation!, YesNo!, 2)=2 then return end if if tv_1.uo_cur_info.sonflag = 0 then messagebox('提示','不是明细部门,不能删除',information!,OK!) return end if cnt = 0 select count(*) into :cnt from u_rs_empinfo where deptid = :tv_1.uo_cur_info.departmentid; if sqlca.sqlcode <> 0 then messagebox('错误','查询部门是否已用失败,不能删除',stopsign!,OK!) return end if if cnt > 0 then messagebox('提示','部门已用于人员信息管理,不能删除',information!,OK!) return end if cnt = 0 select count(*) into :cnt from cw_department where parentid = :tv_1.uo_cur_info.parentid; if sqlca.sqlcode <> 0 then messagebox('错误','查询部门资料失败,不能删除',stopsign!,OK!) return end if if cnt = 1 then update cw_department set sonflag = 1 where departmentid = :tv_1.uo_cur_info.parentid; if sqlca.sqlcode <> 0 then messagebox('错误','更新上级部门资料失败,不能删除',stopsign!,OK!) rollback; return end if end if delete from cw_department where departmentid = :tv_1.uo_cur_info.departmentid; if sqlca.sqlcode <> 0 then messagebox('错误','删除部门失败>>'+sqlca.sqlerrtext,stopsign!,OK!) rollback; return end if commit; messagebox('提示','删除部门成功',information!,OK!) tv_1.f_maketree() end event type tv_1 from uo_tv_deptype within w_department_edit integer y = 188 integer width = 2098 integer height = 1368 integer taborder = 30 integer textsize = -9 fontcharset fontcharset = gb2312charset! fontfamily fontfamily = anyfont! string facename = "宋体" end type event selectionchanged;call super::selectionchanged;il_hand = newhandle end event type cb_help from uo_imflatbutton within w_department_edit string tag = "帮助[F1]" integer x = 873 integer width = 151 integer height = 172 integer taborder = 110 boolean bringtotop = true string text = "帮助" string normalpicname = "help.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type type r_bar from rectangle within w_department_edit long linecolor = 16777215 long fillcolor = 1073741824 integer x = 1929 integer width = 73 integer height = 172 end type event constructor;this.fillcolor = 14215660 this.linecolor = 14215660 this.x = -1 this.y = -1 this.height = ln_bar2.beginy end event type ln_bar from line within w_department_edit long linecolor = 268435456 integer linethickness = 4 integer beginx = -5 integer beginy = 176 integer endx = 2094 integer endy = 176 end type type ln_bar2 from line within w_department_edit long linecolor = 16777215 integer linethickness = 4 integer beginx = -5 integer beginy = 180 integer endx = 2094 integer endy = 180 end type