$PBExportHeader$w_department_ch.srw forward global type w_department_ch from w_publ_base end type type cb_refresh from uo_imflatbutton within w_department_ch end type type cb_add from uo_imflatbutton within w_department_ch end type type cb_add_next from uo_imflatbutton within w_department_ch end type type cb_mod from uo_imflatbutton within w_department_ch end type type cb_del from uo_imflatbutton within w_department_ch end type type tv_1 from uo_tv_deptype within w_department_ch end type type cb_help from uo_imflatbutton within w_department_ch end type type cb_ch from uo_imflatbutton within w_department_ch end type type ln_bar from line within w_department_ch end type type ln_bar2 from line within w_department_ch end type type r_bar from rectangle within w_department_ch end type end forward global type w_department_ch from w_publ_base integer width = 2437 integer height = 1724 string title = "部门选择" boolean minbox = false windowtype windowtype = response! event ue_help ( ) 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 cb_ch cb_ch ln_bar ln_bar ln_bar2 ln_bar2 r_bar r_bar end type global w_department_ch w_department_ch type variables long il_hand s_deptype s_dep_rst end variables forward prototypes public function integer wf_cnt_dot (string arg_mtrltype) end prototypes event ue_help();Int i i = htmlhelpA(Handle(THIS), sys_help_chm, 0, THIS.Title+".htm") end event 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_ch.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.cb_ch=create cb_ch this.ln_bar=create ln_bar this.ln_bar2=create ln_bar2 this.r_bar=create r_bar 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.cb_ch this.Control[iCurrent+9]=this.ln_bar this.Control[iCurrent+10]=this.ln_bar2 this.Control[iCurrent+11]=this.r_bar end on on w_department_ch.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.cb_ch) destroy(this.ln_bar) destroy(this.ln_bar2) destroy(this.r_bar) end on event resize;call super::resize;ln_bar.EndX = THIS.Width ln_bar2.EndX = THIS.Width r_bar.Width = THIS.Width end event event key;call super::key;IF KeyDown(KeyF1!) THEN THIS.TriggerEvent('ue_help') end if end event event close;call super::close;closewithreturn(this,s_dep_rst) end event type cb_func from w_publ_base`cb_func within w_department_ch boolean visible = false integer x = 119 integer y = 484 end type type cb_exit from w_publ_base`cb_exit within w_department_ch integer x = 1202 integer width = 174 integer height = 164 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_ch integer width = 174 integer height = 164 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_ch integer x = 174 integer width = 192 integer height = 164 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,sys_msg_pow) THEN MessageBox(publ_operator,sys_msg_pow) RETURN END IF IF tv_1.uo_cur_info.departmentid = 0 THEN MessageBox("系统提示",'不能建立部门') 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('系统提示','查询上级部门资料失败') 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,id_sqlca) IF ll_departmentid <= 0 THEN MessageBox(publ_operator,arg_msg) 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+'"失败,可能是编号或名称已经存在或网络故障!') RETURN END IF UPDATE cw_department SET sonflag = 0 Where cw_department.departmentid = :ll_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('失败','新建部门"'+ls_departmentname+'"失败,可能是名称已经存在或网络故障!') RETURN END IF COMMIT; MessageBox('成功','新建部门操作成功!') Long ll_hand,ll_handl TreeViewItem l_tvi ll_hand = tv_1.FindItem(parenttreeitem!,il_hand) ll_handl = tv_1.InsertItemSort(ll_hand,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_ch integer x = 366 integer width = 192 integer height = 164 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,sys_msg_pow) THEN MessageBox(publ_operator,sys_msg_pow) 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,id_sqlca) IF ll_departmentid <= 0 THEN MessageBox(publ_operator,arg_msg) 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+'"失败,可能是编号或名称已经存在或网络故障!') RETURN END IF UPDATE cw_department SET sonflag = 0 Where cw_department.departmentid = :ll_parentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('失败','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!') RETURN END IF COMMIT; MessageBox('成功','新建部门操作成功!') Long ll_handl TreeViewItem l_tvi ll_handl = tv_1.InsertItemSort(il_hand,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_ch integer x = 558 integer width = 174 integer height = 164 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,sys_msg_pow) THEN MessageBox(publ_operator,sys_msg_pow) RETURN END IF IF tv_1.uo_cur_info.departmentid = 0 THEN MessageBox(publ_operator,'请选择要修改当前部门!') 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('失败','修改名称操作失败,可能是新名称已经存在或网络故障!') 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('失败','修改部门资料操作失败,可能是新名称已经存在或网络故障!') RETURN END IF UPDATE u_rs_empinfo SET deptype = :ls_new_departmentname Where deptid = :ll_departmentid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('失败','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!') 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('失败','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!') 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+'"上级部门失败') 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('失败','查询上级部门是否还存在下级部门失败') 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('失败','更新上级部门资料失败') RETURN END IF END IF END IF COMMIT; MessageBox('成功','部门修改成功!') 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_ch integer x = 731 integer width = 174 integer height = 164 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,sys_msg_pow) THEN MessageBox(publ_operator,sys_msg_pow) RETURN END IF if MessageBox(publ_operator,'是否要确定删除当前部门', Exclamation!, YesNo!, 2)=2 then return end if if tv_1.uo_cur_info.sonflag = 0 then messagebox(publ_operator,'不是明细部门,不能删除') 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(publ_operator,'查询部门是否已用失败,不能删除') return end if if cnt > 0 then messagebox(publ_operator,'部门已用于员工信息管理,不能删除') 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(publ_operator,'查询部门资料失败,不能删除') 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(publ_operator,'更新上级部门资料失败,不能删除') rollback; return end if end if delete from cw_department where departmentid = :tv_1.uo_cur_info.departmentid; if sqlca.sqlcode <> 0 then messagebox(publ_operator,'删除部门失败>>'+sqlca.sqlerrtext) rollback; return end if commit; messagebox(publ_operator,'删除部门成功') tv_1.f_maketree() end event type tv_1 from uo_tv_deptype within w_department_ch integer y = 180 integer width = 2359 integer height = 1396 integer taborder = 30 boolean bringtotop = true integer textsize = -9 fontcharset fontcharset = gb2312charset! fontfamily fontfamily = anyfont! string facename = "宋体" end type event selectionchanged;call super::selectionchanged;il_hand = newhandle end event event doubleclicked;call super::doubleclicked;cb_ch.TriggerEvent(Clicked!) end event type cb_help from uo_imflatbutton within w_department_ch integer x = 1051 integer width = 151 integer height = 164 integer taborder = 20 boolean bringtotop = true string text = "帮助" string normalpicname = "help.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;PARENT.TriggerEvent('ue_help') end event type cb_ch from uo_imflatbutton within w_department_ch integer x = 901 integer width = 151 integer height = 164 integer taborder = 110 boolean bringtotop = true string text = "选定" string normalpicname = "ok.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;IF tv_1.uo_cur_info.departmentid = 0 THEN MessageBox('提示','请选择部门!') RETURN END IF s_dep_rst.departmentid = tv_1.uo_cur_info.departmentid s_dep_rst.departmentname = tv_1.uo_cur_info.departmentname s_dep_rst.handtype = tv_1.uo_cur_info.handtype Close(PARENT) end event type ln_bar from line within w_department_ch long linecolor = 268435456 integer linethickness = 4 integer beginy = 172 integer endx = 2007 integer endy = 172 end type type ln_bar2 from line within w_department_ch long linecolor = 16777215 integer linethickness = 4 integer beginy = 176 integer endx = 2039 integer endy = 176 end type type r_bar from rectangle within w_department_ch long linecolor = 16777215 integer linethickness = 4 long fillcolor = 1073741824 integer x = 1833 integer width = 146 integer height = 68 end type event constructor;this.fillcolor = 14215660 this.linecolor = 14215660 this.x = -1 this.y = -1 this.height = ln_bar.beginy - 5 end event