点击TreeView控件不同层次节点生成各自不同的文件(对“TreeView控件不同层次节点的设计与运用”的修改与完善)一、功能:1、点击T reeView控件中的“四年级”节点生成四年级成绩统计表;2、点击TreeView控件中的“四年级”节点下的“(1)班”节点生成四 年级(1)班成绩统计表;3、点击TreeView控件中的“四年级”节点下的“(1)班”“男”节点生成四年级(1)班男生成绩统计表 4、其他年级类推。二、说明:1、主要对thisform.OleControl1.NodeClick事件代码进行修改。2、根据“修改 思路”进行修改。三、修改思路:IFISNULL(This.SelectedItem.Parent)&&年级cNj=This. Nodes(This.SelectedItem.Key).TextELSEIFISNULL(This.SelectedIte m.Parent.Parent)&&班级?cNj=This.Nodes(This.SelectedItem.Parent.Key) .Text?cBj=This.Nodes(This.SelectedItem.Key).TextELSE&&性别?cNj=Thi s.Nodes(This.SelectedItem.Parent.Parent.Key).Text?cBj=This.Nodes( This.SelectedItem.Parent.Key).Text?cXb=This.Nodes(This.SelectedIt em.Key).TextENDIFENDIF四、运行界面:五、Form1.OleControl1.NodeClick事件代码DO CASECASEthisform.Optiongroup1.Value=1点击节点XX年级生成XX年级 成绩统计表IFISNULL(This.SelectedItem.Parent)wjm=DataPath+"cjtjmb1.do c"PUBLICcnj,i,s,k,lloWord=CREATEOBJECT("word.application") oWord.VISIBLE=.T.SELECTcjhzbLocateFORALLTRIM(cjhzb.年级)=ALLT RIM(this.Nodes(this.Selecteditem.key).text)IFFOUND()cnj=ALLTRIM (this.Nodes(this.Selecteditem.key).text)WAITWINDOW''正在生成"''+c nj+''"的成绩统计表……''NOWAITSELECTFROMcjhzbWHERE年级=cnjIN TOCURSORtemp3SELECTtemp3oTab=oWord.APPLICATION.Documents.O PEN(wjm)oWord.SELECTIONoWord.SELECTION.insertafter(ALLTRIM("&cnj" ))SELECTtemp3s=RECCOUNT()-2ll=IIF(MOD(s,2)<>0,INT(s/2+1),s/2)oW ord.ActiveDocument.Tables(1).cell(2,1).selectoWord.Selection.Inse rtRowsBelow(ll)FORi=1TORECCOUNT()GOik=INT((i+1)/2+1)IFMO D(i,2)=0oTab.Tables(1).Cell(k,5).Range.InsertAfter(temp3.姓名)oTab .Tables(1).Cell(k,6).Range.InsertAfter(temp3.语文)oTab.Tables(1).Ce ll(k,7).Range.InsertAfter(temp3.数学)oTab.Tables(1).Cell(k,8).Range .InsertAfter(temp3.英语)ELSEoTab.Tables(1).Cell(k,1).Range.InsertAf ter(temp3.姓名)oTab.Tables(1).Cell(k,2).Range.InsertAfter(temp3.语文) oTab.Tables(1).Cell(k,3).Range.InsertAfter(temp3.数学)oTab.Tables(1 ).Cell(k,4).Range.InsertAfter(temp3.英语)ENDIFENDFORSELECTtemp3US ESELECTcjhzbWAITCLEARFileName=TempPath+cnj+"成绩统计表.doc"oWord.D ocuments(1).SAVEAS(Filename)oWord.ActiveDocument.CLOSEoWord.QUIT( )MESSAGEBOX("成绩统计表WORD文档生成完毕!",64,"提示")ENDIFThisform.RefreshELSE 点击节点“XX班”生成XX年级XX班成绩统计表IFISNULL(This.SelectedItem.Pare nt.Parent)wjm=DataPath+"cjtjmb.doc"PUBLICcnj,cbj,ioWord=CRE ATEOBJECT("word.application")oWord.VISIBLE=.T.SELECTcjhzbLocate FORALLTRIM(cjhzb.年级)=ALLTRIM(this.nodes(this.Selecteditem.par ent.key).Text)ANDALLTRIM(cjhzb.班级)=ALLTRIM(this.nodes(this.Sel ecteditem.key).Text)IFFOUND()cnj=ALLTRIM(this.nodes(this.Select editem.parent.key).Text)cbj=ALLTRIM(this.nodes(this.Selecteditem. key).Text)WAITWINDOW''正在生成"''+cnj+cbj+''"的成绩统计表……''NOWAITS ELECTFROMcjhzbWHERE年级=cnjAND班级=cbjINTOCURSORte mp3SELECTtemp3oTab=oWord.APPLICATION.Documents.OPEN(wjm)oWord. SELECTIONoWord.SELECTION.insertafter(ALLTRIM("&cnj&cbj"))SELECT temp3FORi=1TORECCOUNT()GOiIFi>30oTab.Tables(1).Cell(i+ 1-30,5).Range.InsertAfter(temp3.姓名)oTab.Tables(1).Cell(i+1-30,6) .Range.InsertAfter(temp3.语文)oTab.Tables(1).Cell(i+1-30,7).Range. InsertAfter(temp3.数学)oTab.Tables(1).Cell(i+1-30,8).Range.InsertA fter(temp3.英语)ELSEoTab.Tables(1).Cell(i+1,1).Range.InsertAfter(te mp3.姓名)oTab.Tables(1).Cell(i+1,2).Range.InsertAfter(temp3.语文)oTab .Tables(1).Cell(i+1,3).Range.InsertAfter(temp3.数学)oTab.Tables(1). Cell(i+1,4).Range.InsertAfter(temp3.英语)ENDIFENDFORSELECTtemp3US ESELECTcjhzbWAITCLEARFileName=TempPath+cnj+cbj+"成绩统计表.doc"oWo rd.Documents(1).SAVEAS(Filename)oWord.ActiveDocument.CLOSEoWord.Q UIT()MESSAGEBOX("成绩统计表WORD文档生成完毕!",64,"提示")ENDIFthisform.Refresh 点击节点“男(或女)”生成XX年级XX班男(或女)生成绩统计表ELSEwjm=DataPath+"cjtjmb. doc"PUBLICcnj,cbj,cxb,ioWord=CREATEOBJECT("word.application ")oWord.VISIBLE=.T.SELECTcjhzbLocateFORALLTRIM(cjhzb.年级)=ALL TRIM(this.nodes(this.Selecteditem.parent.Parent.key).Text)ANDA LLTRIM(cjhzb.班级)=ALLTRIM(this.nodes(this.Selecteditem.Parent.key) .Text);ANDALLTRIM(cjhzb.性别)=ALLTRIM(this.nodes(this.Selectedit em.key).Text)IFFOUND()cnj=ALLTRIM(this.nodes(this.Selecteditem. parent.Parent.key).Text)cbj=ALLTRIM(this.nodes(this.Selecteditem. Parent.key).Text)cxb=ALLTRIM(this.nodes(this.Selecteditem.key).Te xt)WAITWINDOW''正在生成"''+cnj+cbj+cxb+''"生的成绩统计表……''NOWAITSELE CTFROMcjhzbWHERE年级=cnjAND班级=cbjAND性别=cxbINTOC URSORtemp3SELECTtemp3oTab=oWord.APPLICATION.Documents.OPEN(w jm)oWord.SELECTIONoWord.SELECTION.insertafter(ALLTRIM("&cnj&cbj&c xb")+"生")SELECTtemp3FORi=1TORECCOUNT()GOiIFi>30oTab. Tables(1).Cell(i+1-30,5).Range.InsertAfter(temp3.姓名)oTab.Tables( 1).Cell(i+1-30,6).Range.InsertAfter(temp3.语文)oTab.Tables(1).Cell (i+1-30,7).Range.InsertAfter(temp3.数学)oTab.Tables(1).Cell(i+1-30 ,8).Range.InsertAfter(temp3.英语)ELSEoTab.Tables(1).Cell(i+1,1).Ran ge.InsertAfter(temp3.姓名)oTab.Tables(1).Cell(i+1,2).Range.InsertAf ter(temp3.语文)oTab.Tables(1).Cell(i+1,3).Range.InsertAfter(temp3.数 学)oTab.Tables(1).Cell(i+1,4).Range.InsertAfter(temp3.英语)ENDIFENDF ORSELECTtemp3USESELECTcjhzbWAITCLEARFileName=TempPath+cnj+c bj+cxb+"生成绩统计表.doc"oWord.Documents(1).SAVEAS(Filename)oWord.ActiveDocument.CLOSEoWord.QUIT()MESSAGEBOX("成绩统计表WORD文档生成完毕!",64,"提示")ENDIFENDIFENDIFthisform.RefreshCASEthisform.Optiongroup1.Value=2…….……CASEthisform.Optiongroup1.Value=3…….……ENDCASE六、附件1、模板文件(cjtjmb1.doc)成绩统计表姓名语文数学英语姓名语文数学英语2、模板文件(cjtjmb.doc)8列31行(空行30行,60条记录)成绩统计表姓名语文数学英语姓名语文数学英语-3- |
|