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

📄 w_main.srw

📁 pb所需编程技巧和事例
💻 SRW
字号:
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type mdi_1 from mdiclient within w_main
end type
type cb_4 from commandbutton within w_main
end type
type cb_3 from commandbutton within w_main
end type
type cb_2 from commandbutton within w_main
end type
type cb_1 from commandbutton within w_main
end type
type dw_2 from datawindow within w_main
end type
type dw_1 from datawindow within w_main
end type
type tv_1 from treeview within w_main
end type
type ln_1 from line within w_main
end type
type ln_2 from line within w_main
end type
type struct_tv_data from structure within w_main
end type
end forward

type struct_tv_data from structure
	string		e_table_name
	string		e_column_name
	string		c_column_name
	integer		column_count
	integer		note
end type

global type w_main from window
integer width = 3776
integer height = 2716
boolean titlebar = true
string title = "数据库维护系统(Alpha版 )            ★ 比较购物输入界面 ★"
string menuname = "m_main"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
windowtype windowtype = mdihelp!
windowstate windowstate = maximized!
long backcolor = 79741120
mdi_1 mdi_1
cb_4 cb_4
cb_3 cb_3
cb_2 cb_2
cb_1 cb_1
dw_2 dw_2
dw_1 dw_1
tv_1 tv_1
ln_1 ln_1
ln_2 ln_2
end type
global w_main w_main

type variables
//

end variables

on w_main.create
if this.MenuName = "m_main" then this.MenuID = create m_main
this.mdi_1=create mdi_1
this.cb_4=create cb_4
this.cb_3=create cb_3
this.cb_2=create cb_2
this.cb_1=create cb_1
this.dw_2=create dw_2
this.dw_1=create dw_1
this.tv_1=create tv_1
this.ln_1=create ln_1
this.ln_2=create ln_2
this.Control[]={this.mdi_1,&
this.cb_4,&
this.cb_3,&
this.cb_2,&
this.cb_1,&
this.dw_2,&
this.dw_1,&
this.tv_1,&
this.ln_1,&
this.ln_2}
end on

on w_main.destroy
if IsValid(MenuID) then destroy(MenuID)
destroy(this.mdi_1)
destroy(this.cb_4)
destroy(this.cb_3)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.dw_2)
destroy(this.dw_1)
destroy(this.tv_1)
destroy(this.ln_1)
destroy(this.ln_2)
end on

event closequery;integer li_rc
// Accept the last data entered into the datawindow
dw_1.AcceptText()
//Check to see if any data has changed
IF dw_1.DeletedCount()+dw_1.ModifiedCount() > 0 THEN
		li_rc = MessageBox("警告:将要关闭!", "保存更改吗?", Question!, YesNoCancel!, 3)
      //如果选择保存后关闭
		IF li_rc = 1 THEN
			connect;
		   If dw_1.Update() = 1 then
				commit;
		   else 
				rollback using sqlca;
		   End if
		//用户选择关闭窗口但不更改
		ELSEIF li_rc = 2 THEN
			RETURN 0
     //用户选择放弃关闭窗口
		ELSE
			RETURN 1
		END IF
ELSE
		// 数据没有变化,仅关闭窗口
		RETURN 0
END IF

end event

event open;TreeViewItem itvi_item
setpointer(hourglass!)
//为tv_1创立数据对象
datastore TvItemData
TvItemData=Create datastore
TvItemData.DataObject="d_shuruguanli"
TvItemData.setTrans(sqlca)
//为控件tv_1添加项目
int rows,i
rows=TvItemData.retrieve()
for i=1 to rows
	itvi_item.label = TvItemData.Object.cname[i]
	itvi_item.data  = TvItemData.Object.ename[i]
	//设置TreeViewItem对象属性
   itvi_item.children=false
   if itvi_item.data='' then
     itvi_item.bold=true
     itvi_item.pictureindex=0
     itvi_item.selectedpictureindex=0
	else
	  itvi_item.bold=false
	  itvi_item.pictureindex=1
     itvi_item.selectedpictureindex=2
	end if 
   tv_1.insertitemlast(0,itvi_item)
next

dw_2.visible=false
cb_1.visible=false
cb_2.visible=false
cb_3.visible=false
cb_4.visible=false

dw_2.setTransobject(sqlca)
dw_2.retrieve()
end event

type mdi_1 from mdiclient within w_main
long BackColor=276856960
end type

type cb_4 from commandbutton within w_main
integer x = 782
integer y = 2372
integer width = 229
integer height = 112
integer taborder = 60
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "关闭"
end type

event clicked;dw_2.visible=false
cb_1.visible=false
cb_2.visible=false
cb_3.visible=false
cb_4.visible=false
end event

type cb_3 from commandbutton within w_main
integer x = 526
integer y = 2372
integer width = 229
integer height = 112
integer taborder = 50
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "保存"
end type

event clicked;dw_2.update()
end event

type cb_2 from commandbutton within w_main
integer x = 283
integer y = 2372
integer width = 215
integer height = 112
integer taborder = 40
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "删除"
end type

event clicked;dw_2.deleterow(0)
end event

type cb_1 from commandbutton within w_main
integer y = 2372
integer width = 251
integer height = 112
integer taborder = 30
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "添加"
end type

event clicked;dw_2.insertrow(0)
end event

type dw_2 from datawindow within w_main
integer y = 1664
integer width = 1216
integer height = 628
integer taborder = 20
string title = "总控"
string dataobject = "d_shuruguanli"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

type dw_1 from datawindow within w_main
event ue_downenter pbm_dwnprocessenter
integer x = 1230
integer y = 164
integer width = 2491
integer height = 2108
integer taborder = 20
boolean titlebar = true
string title = "数据内容:"
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
string icon = "OleGenReg!"
borderstyle borderstyle = stylelowered!
end type

event ue_downenter;
IF This.AcceptText()<0 then
     //this.setactioncode(1)
	  return 1
     end if
if this.getcolumn()=Long(This.Describe("datawindow.column.count")) then
        if this.getrow()=This.RowCount() then
           this.insertrow(0)
           this.scrolltorow(this.getrow()+1)
		//添加缺剩值
		if 	Long(This.Describe("datawindow.column.count"))>1 then		
				Int i
				String ls_temp
				String ls_num
				For i = 2 To Long(This.Describe("datawindow.column.count"))
					if i<10 then
						ls_num = "#"+Char(i+48)+".Coltype"
					else
						ls_num = "#"+Char(49)+Char(i/10+48)+".Coltype"
					end if
					ls_temp = this.Describe(ls_num) 
					If Pos(ls_temp,'char')=0 Then
						This.SetItem(This.RowCount(),i,This.GetItemNumber(This.RowCount() - 1,i) )
					Else
							This.SetItem(This.RowCount(),i,This.GetItemString(This.RowCount() - 1,i) )
					End If

			Next
		End If
           this.setcolumn(2)
			  This.object.datawindow.verticalscrollposition= This.object.datawindow.VerticalScrollMaximum
			  This.object.DataWindow.HorizontalScrollPosition = 0
			  this.SetFocus()
             return	1
       end if
   end if
   send(handle(this),256,9,long(0,0))
   return 1

end event

event clicked;datetime updatetime
string ls_name,upd
ls_name = dwo.Name
if ls_name='update_time' then //and insertflag=1 then 
  updatetime=datetime(today())
  upd=mid(string(updatetime),1,8)
  dw_1.setitem(row,"update_time",updatetime) 
end if
end event

event resize;
dw_1.width=parent.width - dw_1.x - 100
dw_1.height=parent.height - dw_1.y - 300
end event

type tv_1 from treeview within w_main
event setall ( )
integer x = 105
integer y = 188
integer width = 1006
integer height = 1420
integer taborder = 10
integer textsize = -12
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontfamily fontfamily = modern!
string facename = "Arial"
long textcolor = 134217734
long backcolor = 15793151
borderstyle borderstyle = stylelowered!
boolean hasbuttons = false
boolean linesatroot = true
string picturename[] = {"Custom039!","Custom050!"}
long picturemaskcolor = 553648127
string statepicturename[] = {"ScriptNo!","ScriptYes!","Custom039!","Custom050!"}
long statepicturemaskcolor = 553648127
end type

event selectionchanged;
TreeViewItem ltvi_new,ltvi_old

tv_1.getitem(newhandle,ltvi_new)
dataname=trim(string(ltvi_new.data))
string datanamelist
datanamelist='#admininfo#'+'#lieguanli#'+'#product_type#'+'#merchant#';
if dataname='*' then
	dw_1.title=trim(ltvi_new.label)
	dw_1.visible=false
	dw_2.visible=true
	cb_1.visible=true
	cb_2.visible=true
	cb_3.visible=true
	cb_4.visible=true
else	
	if pos('#'+datanamelist+'#',dataname)>0 then
		dw_1.visible=true
		dw_1.title='数据表 '+dataname+'('+trim(ltvi_new.label)+')'+'  内容:';
		dw_1.dataobject='d_'+dataname
		dw_1.modify("DataWindow.Vertical_Size = 300")
		dw_1.Object.#1.Key = "yes"
		dw_1.settransobject(sqlca)
		dw_1.retrieve()
		
		if dw_1.rowcount()>0 then
			dw_1.scrolltorow(1)
		end if
	else 
		dw_1.visible=false
		OpenWithParm(w_add,dataname,w_main)
		w_add.sle_product_type.text=ltvi_new.label
	end if
end if
	
end event
event selectionchanging;TreeViewItem ltvi_new, ltvi_old
This.GetItem(oldhandle, ltvi_old)
This.GetItem(newhandle, ltvi_new)
dw_1.accepttext()
int li_net
If Trim(ltvi_old.label)<>'' And (dw_1.ModifiedCount()+dw_1.DeletedCount()>0)	Then
	li_net = MessageBox("提示","    所做的修改还没有保存,~n~r	 需要保存吗?",Question!, &
		YesNoCancel!)
	If li_net = 1 Then
		If dw_1.Update() = 1 Then
			commit;
		End if
	Elseif li_net = 3 Then
		Return 1
	End if
End if
end event

type ln_1 from line within w_main
long linecolor = 33554431
integer linethickness = 4
integer beginy = 116
integer endx = 12000
integer endy = 116
end type

type ln_2 from line within w_main
long linecolor = 33554431
integer linethickness = 1
integer beginy = 112
integer endx = 12000
integer endy = 112
end type

⌨️ 快捷键说明

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