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

📄 选课界面的代码.txt

📁 数据库实习学生选课系统
💻 TXT
字号:
string ts_select

dw_2.settransobject(sqlca)


if ddplb_1.text="课程类别" then
	if sle_2.text<>"" then
		sle_2.text=trim(sle_2.text)
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制  from 课程表 where 课程表.类别='"+sle_2.text+"'"	
 else 
	messagebox("提示!", "课程类型不能为空!") 
 end if
end if 

if ddplb_1.text="教师" then
 if sle_2.text<>"" then
	sle_2.text=trim(sle_2.text)
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制  from 课程表 where 课程表.教师姓名='"+sle_2.text+"'"	
 else 
	messagebox("提示!", "教师姓名不能为空!") 
 end if
end if 

if ddplb_1.text="教室" then
 if sle_2.text<>"" then
	sle_2.text=trim(sle_2.text)
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制  from 课程表 where 课程表.教室='"+sle_2.text+"'"	
 else 
	messagebox("提示!", "教室不能为空!") 
 end if
end if 
if ddplb_1.text="时间" then
 if sle_2.text<>"" then
	sle_2.text=trim(sle_2.text)
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制  from 课程表 where 课程表.时间='"+sle_2.text+"'"	
 else 
	messagebox("提示!", "时间不能为空!") 
 end if
end if 


//SQL语
dw_2.setsqlselect(ts_select)
dw_2.retrieve()
 
if dw_2.RowCount()=0 then
  messagebox("提示!", "没有相关信息!")  //若查询结果为空,则提示
end if

string ts_select

dw_2.settransobject(sqlca)


if ddplb_1.text="课程类型" then
	if sle_2.text<>"" then
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制 from 课程表 where 类别 like '%"+sle_2.text+"%'"	
 else 
	messagebox("提示!", "课程类型不能为空!") 
 end if
end if 

if ddplb_1.text="教师" then
 if sle_2.text<>"" then
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制 from 课程表 where 教师姓名 like '%"+sle_2.text+"%'"	
 else 
	messagebox("提示!", "教师姓名不能为空!") 
 end if
end if 

if ddplb_1.text="教室" then
 if sle_2.text<>"" then
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制 from 课程表 where 教室 like '%"+sle_2.text+"%'"	
 else 
	messagebox("提示!", "教室不能为空!") 
 end if
end if 
if ddplb_1.text="时间" then
 if sle_2.text<>"" then
   ts_select="select 课程编号, 课程名称, 教师姓名, 教师编号, 类别, 教室, 时间,已报人数,限制 from 课程表 where 时间 like '%"+sle_2.text+"%'"	
 else 
	messagebox("提示!", "时间不能为空!") 
 end if
end if 


//SQL语
dw_2.setsqlselect(ts_select)
dw_2.retrieve()
 
if dw_2.RowCount()=0 then
  messagebox("提示!", "没有相关成绩信息!")  //若查询结果为空,则提示
end if

string input_cno,input_tno,input_sno
string output_cno,output_tno,output_sno


input_cno=sle_1.text
input_tno=sle_3.text
input_sno=s_sn



if input_cno=""  then
	messagebox("提示","请输入想选择的课程号!")
else 
			select 课程表.课程编号,课程表.教师编号 into :output_cno,:output_tno from 课程表
         where 课程表.课程编号=:input_cno and 课程表.教师编号=:input_tno;
         if input_cno<>output_cno and input_tno<>output_tno or sqlca.sqlcode<>0 then
				messagebox("输入错误","请正确输入!")
	             sle_1.setfocus() 
					 return
         else
	       //将选课信息(学号\课号)加入选课表  将该课的已选人数加1              
             
			select 成绩表.学号,成绩表.教师编号 into :output_sno,:output_tno from 成绩表
         where 成绩表.课程编号=:input_cno;
			   if output_sno=input_sno and output_tno=input_tno then
					messagebox("提示","此门课已选过!")
					return
				end if
			   if	output_sno=input_sno and output_tno<>input_tno then
					messagebox("提示","你已选择了另一位老师的同门课程!")
					return
				  else
		
					update 课程表
                   set 课程表.已报人数=课程表.已报人数+1
                   where 课程表.课程编号=:input_cno and 课程表.教师编号=:input_tno;
						 if sqlca.sqlcode=0 then
	                    commit ;

                          else
	                          rollback;
						end if			
                  insert into 成绩表(课程编号,教师编号,学号,成绩)
                  values(:input_cno,:input_tno,:input_sno,0);
						if sqlca.sqlcode=0 then
							  messagebox("提示","选课成功!")
	                               commit ;

                     else 
	                    rollback;
					   end if		
					end if
				end if
	
		END IF
       

⌨️ 快捷键说明

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