【正文】
MoveFirst()。 } var = GetCollect(failecount)。 //(不及格門數(shù) %d,)。 //AfxMessageBox(strtemp)。 m_fail = 。 } /***查詢平均分 ******/ (select avg(grade) as average from grade\ where sno=%s,m_sno)。 (_bstr_t(sql))。 if (adoEOF) { AfxMessageBox(沒有可查詢的成績(jī) ,請(qǐng)等待老師上傳 !!!)。 ()。 return。 } if (adoBOF) { MoveFirst()。 } var = GetCollect(average)。 m_average = 。 19 /***更新 grid表格 *******/ (select ame as 39。課程 39。,\ grade as 39。分?jǐn)?shù) 39。,tname as 39。任課教師 39。 from student,grade,course,teacher,tcourse\ where = %s and = and = \ and = and = \ and = ,m_sno)。 (sql)。 ()。 thisSetDlgItemText(IDC_BUTTONLOG,已登入 )。 ()。 GetDlgItem(IDC_BUTTONSOLOG)EnableWindow(TRUE)。 UpdateData(false)。 } void StuPage::OnButtonoutlog() { // TODO: Add your control notification handler code here CString sql。 thisSetDlgItemText(IDC_BUTTONLOG,未登入 )。 (select sname as 39。姓名 39。,\ sno as 39。學(xué)號(hào) 39。,sclass as 39。班級(jí) 39。from student)。 (sql)。 (學(xué)生基本情況表 )。 m_sno = _T()。 m_average = 。 m_fail = 0。 m_password = _T()。 ()。 GetDlgItem(IDC_BUTTONSOLOG)EnableWindow(false)。 UpdateData(false)。 } 附錄三 部分 sql 源代碼 /*********************/ /****************************************************************************** * 統(tǒng)計(jì)已上傳成績(jī)班級(jí)成績(jī)狀況 ******************************************************************************/ create proc proc_wel as set nocount on declare @tname char(50) 20 declare @sclass char(7) declare @ame char(50) declare @downs smallint declare @stoe smallint declare @upe smallint declare @o char(6) declare @tno char(11) declare @sno char(11) declare @average real declare @pass real declare @sum real create table temp(sclass char(7),ame char(50), tname char(50),upe smallint, stoe smallint,downs smallint, average real,pass real, primary key(sclass,ame) ) declare @local_cursor cursor set @local_cursor = CURSOR FORWARD_ONLY STATIC for select sclass,tno,o from tcourse where isr=1 open @local_cursor fetch next from @local_cursor into @sclass,@tno,@o WHILE (@@fetch_status = 0) /*0,為 fetch成功, 1為出錯(cuò), 2為不存在 */ begin /*set @sclass= set @tno=Tno set @o=o*/ set @average =0 set @sum = 0。 select @upe = count(),@sum=sum(grade)from student,grade where = and = @o and sclass = @sclass and grade =80 if @sum0 begin set @average=@sum end select @stoe = count(),@sum=sum(grade) from student,grade where = and = @o and sclass = @sclass and grade =60 and grade80 if @sum0 begin set @average=@average+@sum end select @downs = count(),@sum=sum() from student,grade 21 where = and = @o and sclass = @sclass and grade 60 select @ame=ame from course where o = @o select @tname=tname from teacher where tno = @tno if @sum0 begin set @average=@average+@sum end set @pass=convert(real,(@stoe+@upe),1)/(@stoe+@upe+@downs) set @average = @average /(@stoe+@upe+@downs) insert into temp(sclass,ame,tname,upe,stoe,downs,average,pass) values(@sclass,@ame,@tname,@upe,@stoe,@downs,@average,@pass) fetch next from @local_cursor into @sclass,@tno,@o end close @local_cursor deallocate @local_cursor select sclass as 39。班級(jí) 39。,ame as39。課程名 39。,tname as39。任課教師 39。, upe as39。高于 80分人數(shù) 39。,stoe as39。60分到 80分人數(shù) 39。, downs as39。不及格人數(shù) 39。,average as39。平均分 39。, pass*100 as39。及格率 (%)39。from temp drop table temp /*************************/ /************************************************************** * 存儲(chǔ)過程 gradenew * @isr smallint 0還未上傳, 1為已上傳但在修改限制日期 ,2為不可修改 * @tno 教師號(hào), @sclass 班級(jí), @o課程號(hào) ***************************************************************/ create proc gradenew @isr smallint, @tno char(11), @sclass char(7), @o char(6) as set nocount on if @isr=0 begin insert into grade(sno,o,grade) select sno,@o,0 from student where sclass = @sclass end if @isr!=2 begin 22 update tcourse set isr = 1, rdate = getdate() where sclass=@sclass and tno=@tno and o=@o end /*****新成績(jī)默認(rèn)置 0,再反饋給教師修改 *****/ select sname as 39。姓名 39。, as 39。學(xué)號(hào) 39。,grade as 39。成績(jī) 39。 from grade,student where = and sclass = @sclass and o = @o /*****選出該班該門課程的成績(jī)返回給老師 ****