⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w_main.srw

📁 pb所需编程技巧和事例
💻 SRW
📖 第 1 页 / 共 2 页
字号:
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type cb_refresh from commandbutton within w_main
end type
type tv_1 from treeview within w_main
end type
type tab_1 from tab within w_main
end type
type tabpage_1 from userobject within tab_1
end type
type lb_vice from listbox within tabpage_1
end type
type lb_regular from listbox within tabpage_1
end type
type sle_officeaddr from singlelineedit within tabpage_1
end type
type st_17 from statictext within tabpage_1
end type
type cb_modify from commandbutton within tabpage_1
end type
type sle_officetel from singlelineedit within tabpage_1
end type
type st_16 from statictext within tabpage_1
end type
type st_15 from statictext within tabpage_1
end type
type st_14 from statictext within tabpage_1
end type
type sle_director from singlelineedit within tabpage_1
end type
type st_13 from statictext within tabpage_1
end type
type tabpage_1 from userobject within tab_1
lb_vice lb_vice
lb_regular lb_regular
sle_officeaddr sle_officeaddr
st_17 st_17
cb_modify cb_modify
sle_officetel sle_officetel
st_16 st_16
st_15 st_15
st_14 st_14
sle_director sle_director
st_13 st_13
end type
type tabpage_2 from userobject within tab_1
end type
type cb_modipersonel from commandbutton within tabpage_2
end type
type mle_resume from multilineedit within tabpage_2
end type
type sle_email from singlelineedit within tabpage_2
end type
type st_11 from statictext within tabpage_2
end type
type sle_mobile from singlelineedit within tabpage_2
end type
type st_10 from statictext within tabpage_2
end type
type sle_position from singlelineedit within tabpage_2
end type
type st_9 from statictext within tabpage_2
end type
type st_8 from statictext within tabpage_2
end type
type st_7 from statictext within tabpage_2
end type
type st_6 from statictext within tabpage_2
end type
type sle_degree from singlelineedit within tabpage_2
end type
type sle_tel from singlelineedit within tabpage_2
end type
type sle_department from singlelineedit within tabpage_2
end type
type sle_birthday from singlelineedit within tabpage_2
end type
type st_5 from statictext within tabpage_2
end type
type st_4 from statictext within tabpage_2
end type
type st_3 from statictext within tabpage_2
end type
type st_2 from statictext within tabpage_2
end type
type sle_politicalstatus from singlelineedit within tabpage_2
end type
type sle_native from singlelineedit within tabpage_2
end type
type sle_gender from singlelineedit within tabpage_2
end type
type sle_name from singlelineedit within tabpage_2
end type
type st_1 from statictext within tabpage_2
end type
type tabpage_2 from userobject within tab_1
cb_modipersonel cb_modipersonel
mle_resume mle_resume
sle_email sle_email
st_11 st_11
sle_mobile sle_mobile
st_10 st_10
sle_position sle_position
st_9 st_9
st_8 st_8
st_7 st_7
st_6 st_6
sle_degree sle_degree
sle_tel sle_tel
sle_department sle_department
sle_birthday sle_birthday
st_5 st_5
st_4 st_4
st_3 st_3
st_2 st_2
sle_politicalstatus sle_politicalstatus
sle_native sle_native
sle_gender sle_gender
sle_name sle_name
st_1 st_1
end type
type tab_1 from tab within w_main
tabpage_1 tabpage_1
tabpage_2 tabpage_2
end type
end forward

global type w_main from window
integer width = 2715
integer height = 1988
boolean titlebar = true
string title = "干部档案管理系统"
boolean controlmenu = true
boolean minbox = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_refresh cb_refresh
tv_1 tv_1
tab_1 tab_1
end type
global w_main w_main

type variables
DataStore ds
int lc1 //listbox lb_vice的个数
int lc2 //listbox lb_regular的个数
end variables
on w_main.create
this.cb_refresh=create cb_refresh
this.tv_1=create tv_1
this.tab_1=create tab_1
this.Control[]={this.cb_refresh,&
this.tv_1,&
this.tab_1}
end on

on w_main.destroy
destroy(this.cb_refresh)
destroy(this.tv_1)
destroy(this.tab_1)
end on

event open;TreeViewItem itvi_item,itvi_Emp
int i
int li_Rows

ds=Create datastore
ds.DataObject="d_deptname"
ds.SetTransObject(SQLCA)

itvi_item.children=true
itvi_item.bold=false

li_Rows=ds.Retrieve(Integer(itvi_item.data))
For i=1 to li_Rows
	itvi_item.label=ds.object.deptname[i]
	itvi_item.data='100'
	tv_1.InsertItemLast(0,itvi_item)	
next 
end event
type cb_refresh from commandbutton within w_main
integer x = 137
integer y = 1704
integer width = 457
integer height = 128
integer taborder = 80
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "刷新"
end type

event clicked;TreeViewItem itvi_item
int i,li_Rows
long tvi_hdl = 0
//This example deletes all items from a TreeView control 
//when there are several items at the first level:
DO UNTIL tv_1.FindItem(RootTreeItem!, 0) = -1
    tv_1.DeleteItem(tvi_hdl)
LOOP

ds=Create datastore
ds.DataObject="d_deptname"
ds.SetTransObject(SQLCA)

itvi_item.children=true
itvi_item.bold=false

li_Rows=ds.Retrieve(Integer(itvi_item.data))
For i=1 to li_Rows
	itvi_item.label=ds.object.deptname[i]
	itvi_item.data='100'
	tv_1.InsertItemLast(0,itvi_item)	
next 
end event
type tv_1 from treeview within w_main
integer x = 27
integer y = 80
integer width = 754
integer height = 1592
integer taborder = 50
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean border = false
borderstyle borderstyle = StyleBox!
boolean haslines = false
boolean linesatroot = true
boolean tooltips = false
string picturename[] = {"Custom026!","Custom027!","Custom028!"}
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type

event itempopulate;TreeViewItem itvi_Dept,itvi_emp
//为根(部门)生成项(员工)
DataStore ds1
int i,li_rows

ds1=create DataStore
ds1.DataObject="d_name"
ds1.SetTransObject(SQLCA)
ds1.Reset()

itvi_emp.children=false
itvi_emp.bold=false

tv_1.GetItem(handle,itvi_emp)

ds1.setFilter( "department='" + itvi_emp.label+ "'");
ds1.filter();
ds1.retrieve()
li_rows=ds1.rowcount()

choose case itvi_emp.data
	case '100' 
		tab_1.selectedtab=1
	case '200'
		tab_1.selectedtab=2	
end choose

for i=1 to li_rows
	itvi_emp.label=ds1.object.name[i]
	itvi_emp.data='200'
	InsertItemLast(handle,itvi_emp)
next
end event
event clicked;TreeViewItem itvi_emp
tv_1.GetItem(handle,itvi_emp)
string leader,officetel,officeaddr
string name,gender,native,politicalstatus
date birthday
string department,position,degree,tel
string mobile,email,resume
string vicename,regular
int i,rc

choose case string(itvi_emp.data)
	case '100'
		
		tab_1.selectedtab=1
		
		select leader,depttel,officeaddr
		into  :leader,:officetel,:officeaddr
		from	department
		where deptname=:itvi_emp.label
		using sqlca;
		
		if itvi_emp.label="书记会" then
			tab_1.tabpage_1.st_13.text="书记"
			tab_1.tabpage_1.st_14.text="副书记"
			tab_1.tabpage_1.st_15.visible=false
			tab_1.tabpage_1.lb_regular.visible=false		
		else	
			tab_1.tabpage_1.st_13.text="主任/部长"
			tab_1.tabpage_1.st_14.text="副(主任/部长)"
			tab_1.tabpage_1.st_15.visible=true
			tab_1.tabpage_1.lb_regular.visible=true
		end if	
		
		tab_1.tabpage_1.sle_director.text=leader
		tab_1.tabpage_1.sle_officetel.text=officetel
		tab_1.tabpage_1.sle_officeaddr.text=officeaddr		
		
		//==============================	
		SELECT count(id)
		into :rc
		FROM personel
		WHERE (position = '副主任' or
				position = '副部长' or
				position = '副书记') and 
				department=:itvi_emp.label
		using sqlca;
		
		if lc1=0 then
			lc1=rc
		else
			for i=1 to lc1
				tab_1.tabpage_1.lb_vice.DeleteItem(1)		
			next	
			lc1=rc
		end if
		
		//===================//
		DECLARE curs1 CURSOR FOR
		
		SELECT name FROM personel
		WHERE (position = '副主任' or
				position = '副部长' or
				position = '副书记') and 
				department=:itvi_emp.label
		using sqlca;
		
		OPEN curs1;
		
		if rc>0 then
			for i=1 to rc
				FETCH curs1 INTO :vicename;
				tab_1.tabpage_1.lb_vice.additem(vicename)
			next
		end if
		
		close curs1;
		//==================//
		
		//==============================	
		
		SELECT count(id)
		into :rc
		FROM personel
		WHERE (position = '干事' or
				position = '科员') and 
				department=:itvi_emp.label
		using sqlca;
		
		if lc2=0 then
			lc2=rc
		else
			for i=1 to lc2
				tab_1.tabpage_1.lb_regular.DeleteItem(1)		
			next	
			lc2=rc
		end if	
		
		DECLARE curs2 CURSOR FOR
		
		SELECT name FROM personel
		WHERE (position = '干事' or
				position = '科员') and 
				department=:itvi_emp.label
		using sqlca;
		
		OPEN curs2;		
		if rc>0 then
			For i=1 to rc
				FETCH curs2 INTO :regular;
				tab_1.tabpage_1.lb_regular.additem(regular)
			next
		end if
		
		close curs2;	
		
	case '200'
		
		tab_1.selectedtab=2	
		
		SELECT "personel"."name",   
				"personel"."gender",   
				"personel"."native",   
				"personel"."politicalstatus",   
				"personel"."birthday",   
				"personel"."department",   
				"personel"."position",   
				"personel"."degree",   
				"personel"."tel",   
				"personel"."mobile",   
				"personel"."email",   
				"personel"."resume"  
		 INTO :name,   
				:gender,   
				:native,   
				:politicalstatus,   
				:birthday,   
				:department,   
				:position,   
				:degree,   
				:tel,   
				:mobile,   
				:email,   
				:resume  
		 FROM "personel" 
		 where name=:itvi_emp.label;
	
		tab_1.tabpage_2.sle_name.text=name
		tab_1.tabpage_2.sle_gender.text=gender
		tab_1.tabpage_2.sle_native.text=native
		tab_1.tabpage_2.sle_politicalstatus.text=politicalstatus
		tab_1.tabpage_2.sle_birthday.text=string(birthday,"yyyy/mm/dd")
		tab_1.tabpage_2.sle_department.text=department
		tab_1.tabpage_2.sle_position.text=position
		tab_1.tabpage_2.sle_degree.text=degree
		tab_1.tabpage_2.sle_tel.text=tel
		tab_1.tabpage_2.sle_mobile.text=mobile
		tab_1.tabpage_2.sle_email.text=email
		tab_1.tabpage_2.mle_resume.text=resume
	case else
		
end choose
end event
type tab_1 from tab within w_main
integer x = 823
integer y = 44
integer width = 1815
integer height = 1812
integer taborder = 20
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long backcolor = 67108864
boolean multiline = true
boolean raggedright = true
boolean focusonbuttondown = true
integer selectedtab = 1
tabpage_1 tabpage_1
tabpage_2 tabpage_2
end type

on tab_1.create
this.tabpage_1=create tabpage_1
this.tabpage_2=create tabpage_2
this.Control[]={this.tabpage_1,&
this.tabpage_2}
end on

on tab_1.destroy
destroy(this.tabpage_1)
destroy(this.tabpage_2)
end on

event selectionchanged;choose case tab_1.selectedTab
	case 1
//		messagebox( "","1")
	case 2
//		messagebox( "","2")
end choose
end event

type tabpage_1 from userobject within tab_1
integer x = 18
integer y = 120
integer width = 1778
integer height = 1676
long backcolor = 67108864
string text = "部门信息"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
lb_vice lb_vice
lb_regular lb_regular
sle_officeaddr sle_officeaddr
st_17 st_17
cb_modify cb_modify
sle_officetel sle_officetel
st_16 st_16
st_15 st_15
st_14 st_14
sle_director sle_director
st_13 st_13
end type

on tabpage_1.create
this.lb_vice=create lb_vice
this.lb_regular=create lb_regular
this.sle_officeaddr=create sle_officeaddr
this.st_17=create st_17
this.cb_modify=create cb_modify
this.sle_officetel=create sle_officetel
this.st_16=create st_16
this.st_15=create st_15
this.st_14=create st_14
this.sle_director=create sle_director
this.st_13=create st_13
this.Control[]={this.lb_vice,&
this.lb_regular,&
this.sle_officeaddr,&
this.st_17,&
this.cb_modify,&
this.sle_officetel,&
this.st_16,&
this.st_15,&
this.st_14,&
this.sle_director,&
this.st_13}
end on

on tabpage_1.destroy
destroy(this.lb_vice)
destroy(this.lb_regular)
destroy(this.sle_officeaddr)
destroy(this.st_17)
destroy(this.cb_modify)
destroy(this.sle_officetel)
destroy(this.st_16)
destroy(this.st_15)
destroy(this.st_14)
destroy(this.sle_director)
destroy(this.st_13)
end on

type lb_vice from listbox within tabpage_1
integer x = 658
integer y = 340
integer width = 517
integer height = 336
integer taborder = 70
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean vscrollbar = true
boolean sorted = false
borderstyle borderstyle = stylelowered!
end type

type lb_regular from listbox within tabpage_1
integer x = 654
integer y = 708
integer width = 517
integer height = 452
integer taborder = 90
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean vscrollbar = true
boolean sorted = false
borderstyle borderstyle = stylelowered!
end type

type sle_officeaddr from singlelineedit within tabpage_1
integer x = 654
integer y = 1348
integer width = 901
integer height = 96
integer taborder = 70
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type st_17 from statictext within tabpage_1
integer x = 187
integer y = 1364
integer width = 379
integer height = 72
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "办公室电话"
boolean focusrectangle = false
end type

type cb_modify from commandbutton within tabpage_1
integer x = 795
integer y = 1472
integer width = 503
integer height = 128
integer taborder = 70
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "部门信息维护"
end type

event clicked;open(w_dept)
end event

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -