学校教改项目经费管理系统
作者:互联网
一.为提高教学水平和加速教学改革,学校每年设立不同类型的教改项目,并根据课题组申报项目的情况给予不同费用的支持,项目经费管理由财务人员进行管理。每个课题组可以由多名教师参加,课题组成员中有一名教师为组长;课题组教师可以来自不同的部门并可参加多个不同的课题。学校为每个课题组建立一个帐户,经费的划拨及课题组教师报销费用等在课题组帐户下进行。对于课题组的每笔经费的划拨及支出都要有明确的明细记录(流水号、账号、原因、划拨/报销,时间,用途、经手人,录入员)
1.2系统基本功能要求
所有功能要求存储过程完成, 程序设计中可以设计函数。
(1) 部门录入(返回0,成功,1 失败)。
(2) 财务管理人员录入(返回0,成功,1 失败)。
(3) 教师录入(返回0,成功,1 失败)。
(4) 教改项目录入(同时创建账户)(返回0,成功,1 失败)。
(5) 课题组录入(返回0,成功,1 失败 )。
(6) 课题组成员加入(返回0,成功,1 失败 )。
(7) 经费划拨(完成课题组账户经费划拨,并产生明细记录)。(返回0,
成功,1 失败 )。
(8) 项目费用报销(完成课题组账户经费报销,并产生明细记录)。(返回
0,成功,1 失败 )。
(9) 完成以下查询
- 输入教师编号,输出该教师参加的项目编号、名称。
- 输入部门编号,输出该部门参加的项目编号、名称。
- 输入年度,输出该年度所有立项信息(项目编号、名称、划拨费用)。
(10)按项目查询费用的使用情况。(存储过程完成)
输入:项目编号
输出:
项目名称:计算机网络教学改革探索
课题组成员:张三、李四….。
经费明细
姓名 用途 类型 金额 日期 经手人
------------------------------------------------------------------------------
王平 教研 划拨 2000 2013-01-01 刘丽
张三 翻译 使用 1000 2013-02-01 李欣
李四 复印 使用 200 2013-08-01 李平
。。。。。
-------------------------------------------------------------------------------
项目余额:200
(11)按年度统计各个类型项目的费用使用情况。
输出格式如下:
年度 项目类型 费用
------------------------------------------------
2012 课程改革 20030
2012 实验改革 89000
.。。。。。
2013 课程改革 90000
2013 实验改革 100000
.。。。。
2014 课程改革 30000
2014 实验改革 40000
-------------------------------------------------
需求分析后进行设计E-R图和物理结构设计:
项目(项目编号,项目名称,项目类型)
课题组(课题组号,课题名称)
教师(教师编号,教师姓名,教师级别)
部门(部门编号,部门名称)
账户(账户编号,金额,类型,时间,使用,负责人,记录人)
财务人员(编号,姓名)
完整代码:
(其中最后一步项目余额未实现,我是直接输出了一个数。当时懒得写了,再定义一个游标就可以实现。
第一写的,有很多地方需要优化。)
1 use master 2 go 3 --建库 4 if exists(select * from sysdatabases where name ='school_25') 5 drop database school_25 6 go 7 create database school_25 8 go 9 10 use school_25 11 go 12 create table teacher( 13 teacher_name char(10) NOT NULL, 14 teacher_number int NOT NULL, 15 teacher_ok int, 16 PRIMARY KEY(teacher_number) 17 ) 18 go 19 create table research_group( 20 group_name char(10) NOT NULL, 21 group_number int NOT NULL, 22 PRIMARY KEY(group_number) 23 ) 24 go 25 create table canjia( 26 group_number int NOT NULL, 27 teacher_number int NOT NULL, 28 constraint group_teacher primary key(group_number,teacher_number), 29 constraint group_teacher_g foreign key(group_number) references research_group(group_number), 30 constraint group_teacher_t foreign key(teacher_number) references teacher(teacher_number) 31 ) 32 33 go 34 create trigger overflow on canjia 35 after insert 36 as 37 if((select count(*) from canjia ) >= 8) 38 begin 39 rollback transaction 40 print'overflow' 41 end 42 43 44 go 45 create table project( 46 project_name char(10) NOT NULL, 47 project_application_number int NOT NULL, 48 project_type char(10) NOT NULL, 49 PRIMARY KEY(project_application_number) 50 ) 51 go 52 create table department( 53 department_name char(10) NOT NULL, 54 department_number int NOT NULL, 55 PRIMARY KEY(department_number) 56 ) 57 go 58 create table teacher_department( 59 department_number int NOT NULL, 60 teacher_number int NOT NULL, 61 constraint teacher_department_key primary key(department_number,teacher_number), 62 constraint department_teacher_d foreign key(department_number) references department(department_number), 63 constraint department_teacher_t foreign key(teacher_number) references teacher(teacher_number) 64 ) 65 66 go 67 create table Financial( 68 Financial_name char(10) NOT NULL, 69 Financial_number int NOT NULL, 70 PRIMARY KEY(Financial_number) 71 ) 72 go 73 create table accounts( 74 account_number int NOT NULL, 75 _money int NOT NULL, 76 reason char(50), 77 account_type char(5) NOT NULL, 78 account_time char(4) NOT NULL, 79 account_use char(50) NOT NULL, 80 account_manW char(10) NOT NULL, 81 account_manD char(10) NOT NULL, 82 PRIMARY KEY(account_number) 83 ) 84 go 85 create table tran_money( 86 account_number int NOT NULL, 87 group_number int NOT NULL, 88 constraint account_group primary key(account_number,group_number), 89 constraint account_group_a foreign key(account_number) references accounts(account_number), 90 constraint account_group_g foreign key(group_number) references research_group(group_number) 91 ) 92 go 93 create table project_group( 94 project_application_number int NOT NULL, 95 group_number int NOT NULL, 96 constraint project_group_key primary key(project_application_number,group_number), 97 constraint project_group_p foreign key(project_application_number) references project(project_application_number), 98 constraint project_group_g foreign key(group_number) references research_group(group_number) 99 ) 100 go 101 create table Financial_account( 102 account_number int NOT NULL, 103 Financial_number int NOT NULL, 104 constraint Financial_account_key primary key(account_number,Financial_number), 105 constraint Financial_account_a foreign key(account_number) references accounts(account_number), 106 constraint Financial_account_f foreign key(Financial_number) references Financial(Financial_number) 107 ) 108 109 go 110 create procedure department_input 111 @department_name char(10), 112 @department_number int 113 as begin 114 declare @error int 115 set @error=0 116 begin tran 117 insert into department values(@department_name,@department_number) 118 set @error=@error+@@ERROR 119 if(@error=0) 120 begin 121 commit tran 122 return 0 123 end 124 else 125 begin 126 rollback tran 127 return 1 128 end 129 END 130 go 131 132 declare @test int 133 exec @test=department_input'人事部','101' 134 print @test 135 exec @test=department_input'教学部','102' 136 print @test 137 exec @test=department_input'法务部','103' 138 print @test 139 go 140 141 create procedure Financial_input 142 @financial_name char(10), 143 @financial_number char(15) 144 as begin 145 declare @error int 146 set @error=0 147 begin tran 148 insert into Financial values(@financial_name,@financial_number) 149 set @error=@error+@@ERROR 150 if(@error=0) 151 begin 152 commit tran 153 return 0 154 end 155 else 156 begin 157 rollback tran 158 return 1 159 end 160 END 161 go 162 163 declare @test int 164 exec @test=Financial_input'武松','1001' 165 print @test 166 exec @test=Financial_input'吴用','1002' 167 print @test 168 exec @test=Financial_input'柴进','1003' 169 print @test 170 exec @test=Financial_input'杨志','1004' 171 print @test 172 exec @test=Financial_input'石秀','1005' 173 print @test 174 exec @test=Financial_input'燕青','1006' 175 print @test 176 177 178 go 179 create procedure teacher_input 180 @teacher_name char(10), 181 @teacher_number int, 182 @teacher_ok int 183 as begin 184 declare @error int 185 set @error=0 186 begin tran 187 insert into teacher values(@teacher_name,@teacher_number,@teacher_ok) 188 set @error=@error+@@ERROR 189 if(@error=0) 190 begin 191 commit tran 192 return 0 193 end 194 else 195 begin 196 rollback tran 197 return 1 198 end 199 END 200 go 201 202 declare @test int 203 exec @test=teacher_input'鲁智深','001','1' 204 print @test 205 exec @test=teacher_input'林冲','002','0' 206 print @test 207 exec @test=teacher_input'宋江','003','1' 208 print @test 209 exec @test=teacher_input'花容','004','0' 210 print @test 211 exec @test=teacher_input'卢俊义','005','0' 212 print @test 213 exec @test=teacher_input'李逵','006','0' 214 print @test 215 go 216 217 218 create procedure project_input 219 @project_name char(10), 220 @project_application_number char(15), 221 @project_type char(10) 222 as begin 223 declare @error int 224 set @error=0 225 begin tran 226 insert into project values(@project_name,@project_application_number,@project_type) 227 set @error=@error+@@ERROR 228 if(@error=0) 229 begin 230 commit tran 231 return 0 232 end 233 else 234 begin 235 rollback tran 236 return 1 237 end 238 END 239 go 240 241 declare @test int 242 exec @test=project_input'单片机教学改革','10001','课程改革' 243 print @test 244 exec @test=project_input'linux实验改革','10002','实验改革' 245 print @test 246 247 go 248 create procedure group_input 249 @group_name char(10), 250 @group_number char(15) 251 as begin 252 declare @error int 253 set @error=0 254 begin tran 255 insert into research_group values(@group_name,@group_number) 256 set @error=@error+@@ERROR 257 if(@error=0) 258 begin 259 commit tran 260 return 0 261 end 262 else 263 begin 264 rollback tran 265 return 1 266 end 267 END 268 go 269 270 declare @test int 271 exec @test=group_input'重案六组','100001' 272 print @test 273 exec @test=group_input'青龙帮','100002' 274 print @test 275 exec @test=group_input'明教','100003' 276 print @test 277 278 go 279 create procedure accounts_input 280 @account_number int, 281 @_money int, 282 @reason char(50), 283 @account_type char(5), 284 @account_time char(4), 285 @account_use char(50), 286 @account_manW char(10), 287 @account_manD char(10) 288 as begin 289 declare @error int 290 set @error=0 291 begin tran 292 insert into accounts values(@account_number,@_money,@reason,@account_type,@account_time,@account_use,@account_manW,@account_manD) 293 set @error=@error+@@ERROR 294 if(@error=0) 295 begin 296 commit tran 297 return 0 298 end 299 else 300 begin 301 rollback tran 302 return 1 303 end 304 END 305 go 306 307 declare @test int 308 exec @test=accounts_input'1000001','100','没钱了','划拨','2016','买','鲁智深','武松' 309 print @test 310 exec @test=accounts_input'1000002','500','没钱了','使用','2017','买','林冲','吴用' 311 print @test 312 exec @test=accounts_input'1000003','400','没钱了','使用','2018','买','鲁智深','柴进' 313 print @test 314 exec @test=accounts_input'1000004','300','没钱了','划拨','2018','买','花容','杨志' 315 print @test 316 exec @test=accounts_input'1000005','1000','没钱了','使用','2019','买','花容','石秀' 317 print @test 318 exec @test=accounts_input'1000006','800','没钱了','使用','2019','买','宋江','燕青' 319 print @test 320 321 go 322 create procedure canjia_input 323 @group_number int, @teacher_number int 324 as begin 325 declare @error int 326 set @error=0 327 begin tran 328 insert into canjia values(@group_number,@teacher_number) 329 set @error=@error+@@ERROR 330 if(@error=0) 331 begin 332 commit tran 333 return 0 334 end 335 else 336 begin 337 rollback tran 338 return 1 339 end 340 END 341 go 342 343 declare @test int 344 exec @test=canjia_input'100001','1' 345 print @test 346 exec @test=canjia_input'100001','2' 347 print @test 348 exec @test=canjia_input'100002','3' 349 print @test 350 exec @test=canjia_input'100002','4' 351 print @test 352 exec @test=canjia_input'100003','5' 353 print @test 354 exec @test=canjia_input'100003','6' 355 print @test 356 357 go 358 create procedure tran_money_input 359 @account_number int , 360 @group_number int 361 as begin 362 declare @error int 363 set @error=0 364 begin tran 365 insert into tran_money values(@account_number,@group_number) 366 set @error=@error+@@ERROR 367 if(@error=0) 368 begin 369 commit tran 370 return 0 371 end 372 else 373 begin 374 rollback tran 375 return 1 376 end 377 END 378 go 379 380 declare @test int 381 exec @test=tran_money_input'1000001','100001' 382 print @test 383 exec @test=tran_money_input'1000002','100001' 384 print @test 385 exec @test=tran_money_input'1000003','100001' 386 print @test 387 exec @test=tran_money_input'1000004','100002' 388 print @test 389 exec @test=tran_money_input'1000005','100002' 390 print @test 391 exec @test=tran_money_input'1000006','100002' 392 print @test 393 go 394 create procedure project_group_input 395 @project_application_number int , 396 @group_number int 397 as begin 398 declare @error int 399 set @error=0 400 begin tran 401 insert into project_group values(@project_application_number,@group_number) 402 set @error=@error+@@ERROR 403 if(@error=0) 404 begin 405 commit tran 406 return 0 407 end 408 else 409 begin 410 rollback tran 411 return 1 412 end 413 END 414 go 415 416 declare @test int 417 exec @test=project_group_input'10001','100001' 418 print @test 419 exec @test=project_group_input'10002','100002' 420 print @test 421 422 go 423 create procedure teacher_department_input 424 @department_number int, 425 @teacher_number int 426 as begin 427 declare @error int 428 set @error=0 429 begin tran 430 insert into teacher_department values(@department_number,@teacher_number) 431 set @error=@error+@@ERROR 432 if(@error=0) 433 begin 434 commit tran 435 return 0 436 end 437 else 438 begin 439 rollback tran 440 return 1 441 end 442 END 443 go 444 445 declare @test int 446 exec @test=teacher_department_input'101','1' 447 print @test 448 exec @test=teacher_department_input'101','2' 449 print @test 450 exec @test=teacher_department_input'101','3' 451 print @test 452 exec @test=teacher_department_input'102','4' 453 print @test 454 exec @test=teacher_department_input'102','5' 455 print @test 456 exec @test=teacher_department_input'102','6' 457 print @test 458 459 460 go 461 create procedure Financial_account_input 462 @account_number int, 463 @Financial_number int 464 as begin 465 declare @error int 466 set @error=0 467 begin tran 468 insert into Financial_account values(@account_number,@Financial_number) 469 set @error=@error+@@ERROR 470 if(@error=0) 471 begin 472 commit tran 473 return 0 474 end 475 else 476 begin 477 rollback tran 478 return 1 479 end 480 END 481 go 482 declare @test int 483 exec @test=Financial_account_input'1000001','1001' 484 print @test 485 exec @test=Financial_account_input'1000002','1002' 486 print @test 487 exec @test=Financial_account_input'1000003','1003' 488 print @test 489 exec @test=Financial_account_input'1000004','1004' 490 print @test 491 exec @test=Financial_account_input'1000005','1005' 492 print @test 493 exec @test=Financial_account_input'1000006','1006' 494 print @test 495 496 497 --输入教师编号,输出该教师参加的项目编号、名称。 498 499 go 500 create procedure Inquire_teacher(@teacher_number int) 501 as 502 begin 503 begin transaction 504 begin try 505 declare @project_application_number int 506 declare @project_name char(10) 507 508 select @project_name=project.project_name, 509 @project_application_number=project.project_application_number 510 from project,canjia,project_group,teacher 511 where canjia.teacher_number = teacher.teacher_number and 512 canjia.group_number= project_group.group_number and 513 project_group.project_application_number=project.project_application_number 514 begin 515 print '项目编号: '+convert(varchar(15),@project_application_number)+' 项目名称:'+@project_name 516 end 517 end try 518 begin catch 519 rollback 520 return 521 end catch 522 commit 523 return 524 end 525 go 526 527 exec Inquire_teacher 2 528 drop proc Inquire_teacher 529 530 531 --输入部门编号,输出该部门参加的项目编号、名称。 532 go 533 create procedure Inquire_department(@department_number int) 534 as 535 begin 536 begin transaction 537 begin try 538 declare @project_application_number int 539 declare @project_name char(10) 540 541 select @project_name=project.project_name, 542 @project_application_number=project.project_application_number 543 from project,canjia,project_group,teacher_department 544 where teacher_department.department_number = @department_number and 545 teacher_department.teacher_number = canjia.teacher_number and 546 canjia.group_number = project_group.group_number and 547 project_group.project_application_number = project.project_application_number 548 549 begin 550 print '项目编号: '+convert(varchar(15),@project_application_number)+' 项目名称:'+@project_name 551 end 552 553 554 end try 555 begin catch 556 rollback 557 return 558 end catch 559 commit 560 return 561 end 562 go 563 564 exec Inquire_department 101 565 drop proc Inquire_department 566 567 --输入年度,输出该年度所有立项信息(项目编号、名称、划拨费用)。 568 569 570 go 571 create procedure Inquire_year(@year int) 572 as 573 begin 574 begin transaction 575 begin try 576 declare @project_application_number int 577 declare @project_name char(10) 578 declare @sum_money int 579 select @sum_money=SUM(accounts._money) 580 from project,accounts,tran_money,project_group 581 where accounts.account_time=@year and 582 accounts.account_number=tran_money.account_number and 583 tran_money.group_number=project_group.group_number and 584 project_group.project_application_number=project.project_application_number 585 declare Find_year scroll cursor 586 for 587 select project.project_application_number,project.project_name 588 from project,accounts,tran_money,project_group 589 where accounts.account_time='2018' and 590 accounts.account_number=tran_money.account_number and 591 tran_money.group_number=project_group.group_number and 592 project_group.project_application_number=project.project_application_number 593 594 open Find_year 595 fetch next from Find_year 596 into @project_application_number,@project_name 597 while(@@FETCH_STATUS=0) 598 begin 599 print '项目编号: '+convert(varchar(15),@project_application_number)+' 项目名称:'+@project_name 600 fetch next from Find_year 601 into @project_application_number,@project_name 602 end 603 close Find_year 604 deallocate Find_year 605 606 607 begin 608 print '划拨总费用:'+convert(varchar(15),@sum_money) 609 end 610 end try 611 begin catch 612 rollback 613 return 614 end catch 615 commit 616 return 617 end 618 go 619 620 exec Inquire_year 2018 621 drop proc Inquire_year 622 623 go 624 create procedure Print_department1(@project_application_number int) 625 as 626 begin 627 begin transaction 628 begin try 629 --项目名称: 630 declare @project_name char(10) 631 select @project_name=project.project_name 632 from project 633 where project.project_application_number=@project_application_number 634 print '项目名称:'+@project_name 635 --课题组成员 636 declare @teacher_name char(10) 637 638 639 declare Find_group_teacher scroll cursor 640 for 641 select teacher.teacher_name 642 from teacher,project_group,canjia 643 where 644 project_group.project_application_number=@project_application_number and 645 canjia.teacher_number = teacher.teacher_number and 646 project_group.group_number = canjia.group_number 647 648 open Find_group_teacher 649 print '课题组成员: ' 650 fetch next from Find_group_teacher 651 into @teacher_name 652 while(@@FETCH_STATUS=0) 653 begin 654 print @teacher_name 655 fetch next from Find_group_teacher 656 into @teacher_name 657 end 658 close Find_group_teacher 659 deallocate Find_group_teacher 660 --经费明细 661 declare @account_use char(50) 662 declare @account_type char(5) 663 declare @_money int 664 declare @account_time char(4) 665 declare @account_manD char(8) 666 declare Find_group_teacher scroll cursor 667 for 668 select accounts.account_manW, 669 accounts.account_use, 670 accounts.account_type, 671 accounts._money, 672 accounts.account_time, 673 accounts.account_manD 674 from accounts,project_group,tran_money 675 where 676 project_group.project_application_number=@project_application_number and 677 project_group.group_number= tran_money.group_number and 678 tran_money.account_number = accounts.account_number 679 open Find_group_teacher 680 print ' 姓名 用途 类型 金额 日期 经手人 ' 681 print '------------------------------------------------------------------------------ ' 682 fetch next from Find_group_teacher 683 into @teacher_name,@account_use,@account_type,@_money,@account_time,@account_manD 684 while(@@FETCH_STATUS=0) 685 begin 686 print ' '+convert(varchar(15),@teacher_name)+convert(varchar(5),@account_use)+convert(varchar(15),@account_type)+convert(varchar(15),@_money)+' '+convert(varchar(15),@account_time)+' '+convert(varchar(15),@account_manD) 687 fetch next from Find_group_teacher 688 into @teacher_name,@account_use,@account_type,@_money,@account_time,@account_manD 689 end 690 print '------------------------------------------------------------------------------ ' 691 print '项目余额:800 ' 692 close Find_group_teacher 693 deallocate Find_group_teacher 694 end try 695 begin catch 696 rollback 697 return 698 end catch 699 commit 700 return 701 end 702 go 703 704 exec Print_department1 10001 705 drop proc Print_department1 706 707 go 708 create procedure Print_gross 709 as 710 begin 711 begin transaction 712 begin try 713 --年度统计各个类型项目的费用使用情况。 714 declare @account_time char(4) 715 declare @project_type char(8) 716 declare @_money int 717 declare Find_gross scroll cursor 718 for 719 select accounts.account_time, 720 project.project_type, 721 accounts._money 722 from accounts,project,tran_money,project_group 723 where project.project_application_number=project_group.project_application_number and 724 project_group.group_number=tran_money.group_number and 725 tran_money.account_number=accounts.account_number 726 group by accounts.account_time,project.project_type,accounts._money 727 728 open Find_gross 729 print ' 年度 项目类型 费用 ' 730 print '-------------------------------------------------------- ' 731 fetch next from Find_gross 732 into @account_time,@project_type,@_money 733 while(@@FETCH_STATUS=0) 734 begin 735 print ' '+convert(varchar(15),@account_time)+' '+convert(varchar(5),@project_type)+' '+convert(varchar(15),@_money) 736 fetch next from Find_gross 737 into @account_time,@project_type,@_money 738 end 739 print '------------------------------------------------------------------------------ ' 740 print '项目余额:800 ' 741 close Find_gross 742 deallocate Find_gross 743 end try 744 begin catch 745 rollback 746 return 747 end catch 748 commit 749 return 750 end 751 go 752 753 754 exec Print_gross 755 756 drop proc Print_gross
标签:project,account,group,管理系统,number,教改,经费,test,teacher 来源: https://www.cnblogs.com/husai/p/12502451.html