📄 unit2.pas
字号:
begin
ADOCommand1.CommandText:='delete from 学生 where 学号='''+edit8.text+''' ';
ADOCommand1.Execute;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 学生 order by 学号 ');
ADOQuery1.Close;
ADOQuery1.Open;
showmessage('删除成功');
end;
procedure TForm2.ComboBox1Change(Sender: TObject);
begin
Edit1.Text:='';
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单');
ADOQuery2.Close;
ADOQuery2.Open;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
ADOCommand1.CommandText:='insert into 选课 values('''+ComboBox2.Text+''','''+ComboBox3.Text+''','''+edit4.Text+''','''+edit9.Text+''','''+edit10.Text+''') ';
ADOCommand1.Execute;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox2.Text+''' and 学期='''+ComboBox3.Text+''' and 课程号='''+edit4.Text+''' and 学号='''+edit9.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
end;
procedure TForm2.Button3Click(Sender: TObject);
var
name:string;
course:string;
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Text:='select 姓名,课程名 from 成绩单 where 学年='''+ComboBox2.Text+''' and 学期='''+ComboBox3.Text+''' and 课程号='''+edit4.Text+''' and 学号='''+edit9.Text+'''';
ADOQuery2.Close;
ADOQuery2.Open;
name:=ADOQuery2.Fieldbyname('姓名').AsString;
course:=ADOQuery2.Fieldbyname('课程名').AsString;
ADOCommand1.CommandText:='delete from 选课 where 学年='''+ComboBox2.Text+''' and 学期='''+ComboBox3.Text+''' and 课程号='''+edit4.Text+''' and 学号='''+edit9.Text+''' ';
ADOCommand1.Execute;
showmessage(' '+name+' 的 '+course+' 课程被删除');
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
if(CheckBox1.Checked)then
begin
if(combobox8.Text='个人')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='班级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='年级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
end
else
begin
if(combobox8.Text='个人')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='班级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='年级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select count(distinct 姓名) as num from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery2.Close;
ADOQuery2.Open;
label2.Caption:='共 '+ADOQuery2.Fieldbyname('num').AsString+' 人';
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery2.Close;
ADOQuery2.Open;
end
end
end;
procedure TForm2.TabSheet1Show(Sender: TObject);
begin
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 学生 order by 学号');
ADOQuery1.Close;
ADOQuery1.Open;
end;
procedure TForm2.TabSheet2Show(Sender: TObject);
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 成绩单');
ADOQuery2.Close;
ADOQuery2.Open;
ADOQuery3.SQL.Clear;
ADOQuery3.SQL.Add('select * from 课程');
ADOQuery3.Close;
ADOQuery3.Open;
end;
procedure TForm2.ComboBox8Change(Sender: TObject);
begin
if(ComboBox8.Text='个人')then
begin
label1.Caption:='学号';
button4.Enabled:=true;
button5.Enabled:=true;
button6.Enabled:=false;
button7.Enabled:=false;
end
else if(ComboBox8.Text='班级')then
begin
label1.Caption:='班级';
button4.Enabled:=true;
button5.Enabled:=true;
button6.Enabled:=true;
button7.Enabled:=false;
end
else
begin
label1.Caption:='年级';
button4.Enabled:=true;
button5.Enabled:=true;
button6.Enabled:=true;
button7.Enabled:=true;
end
end;
procedure TForm2.CheckBox1Click(Sender: TObject);
begin
if(CheckBox1.Checked)then
begin
DBLookupComboBox1.Enabled:=false;
end
else
begin
DBLookupComboBox1.Enabled:=true;
end
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
if(CheckBox1.Checked)then
begin
if(combobox8.Text='个人')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
else if(combobox8.Text='班级')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
else if(combobox8.Text='年级')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
end
else
begin
if(combobox8.Text='个人')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
else if(combobox8.Text='班级')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
else if(combobox8.Text='年级')then
begin
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select sum(成绩*学分数)/sum(学分数) as score from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' and 班级 like '''+edit13.Text+'______'' ');
ADOQuery4.Close;
ADOQuery4.Open;
label3.Caption:=ADOQuery4.Fieldbyname('score').AsString;
end
end
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
if(CheckBox1.Checked)then
begin
if(combobox8.Text='个人')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='班级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='年级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级 like '''+edit13.Text+'______'' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
end
else
begin
if(combobox8.Text='个人')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 学号='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='班级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级='''+edit13.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
else if(combobox8.Text='年级')then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 学号,姓名,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' and 班级 like '''+edit13.Text+'______'' group by 学号,姓名 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
end
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
if(CheckBox1.Checked)then
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 班级,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 班级 like '''+edit13.Text+'______'' group by 班级 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
else
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select 班级,sum(成绩*学分数)/sum(学分数) as 平均分 from 成绩单 where 学年='''+ComboBox6.Text+''' and 学期='''+ComboBox7.Text+''' and 课程名='''+DBLookupComboBox1.Text+''' and 班级 like '''+edit13.Text+'______'' group by 班级 order by 平均分 desc');
ADOQuery2.Close;
ADOQuery2.Open;
end
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
ADOQuery5.SQL.Clear;
ADOQuery5.SQL.Add('select 学年,学期,班级,学生.学号,姓名,日常得分,活动得分 from 课外考评,学生 where 学生.学号=课外考评.学号');
ADOQuery5.Close;
ADOQuery5.Open;
end;
procedure TForm2.TabSheet5Show(Sender: TObject);
begin
ADOQuery5.SQL.Clear;
ADOQuery5.SQL.Add('select 学年,学期,班级,学生.学号,姓名,日常得分,活动得分 from 课外考评,学生 where 学生.学号=课外考评.学号');
ADOQuery5.Close;
ADOQuery5.Open;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -