【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,cjdytempunit.pas,希望对大家有所帮助!
unit cjdytempunit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, ExtCtrls,datadomule, DB, DBTables;
type
Tcjdytemp = class(TForm)
Panel1: TPanel;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
Label4: TLabel;
MaskEdit1: TMaskEdit;
Button1: TButton;
qry: TQuery;
DataSource1: TDataSource;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Exit(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
cjdytemp: Tcjdytemp;
implementation
uses cjdyunit, bjcjdyunit;
{$R *.dfm}
procedure Tcjdytemp.RadioButton1Click(Sender: TObject);
begin
label1.Visible:=true;
label2.Visible:=true;
label3.Visible:=false;
combobox1.Visible:=true;
combobox2.Visible:=true;
edit1.Visible:=false;
end;
procedure Tcjdytemp.RadioButton2Click(Sender: TObject);
begin
label1.Visible:=false;
label2.Visible:=false;
label3.Visible:=true;
combobox1.Visible:=false;
combobox2.Visible:=false;
edit1.Visible:=true;
end;
procedure Tcjdytemp.FormCreate(Sender: TObject);
begin
combobox1.Items.clear;
with datamodule1.qry_bycp do
begin
close;
sql.clear;
sql.add('select * from zyb0') ;
open;
first;
if recordcount>0 then
// combobox1.text:=Fields[1].asstring;
repeat
combobox1.items.add(fields[1].asstring);
until findnext=false;
end;
end;
procedure Tcjdytemp.ComboBox1Exit(Sender: TObject);
begin
combobox2.Items.Clear;
with datamodule1.qry_bycp do
begin
close;
sql.Clear;
sql.add('select * from bjb0 where zymc=:name');
parambyname('name').asstring:=combobox1.text;
open;
if recordcount>0 then
combobox2.text:=Fields[0].asstring;
repeat
combobox2.items.add(fields[0].asstring);
until findnext=false;
end;
end;
procedure Tcjdytemp.Button1Click(Sender: TObject);
var i:integer ;
var a:array[1..30] of string;
begin
if radiobutton1.Checked then //按班级打印
begin
with qry do
begin
close;
sql.Clear ;
sql.add('delete from cjbdy');
execsql; //添加 和
sql.Clear ;
sql.Add('insert into cjbdy(xsxh_id,xm00) select xsxh_id,xm00 from xsmc where bjh0=:name');
parambyname('name').asstring:=combobox2.text;
execsql;
sql.Clear ;
sql.Add('select * from cjbdy');
execsql;
open;
datamodule1.qry_cjdy1.close;
datamodule1.qry_cjdy1.sql.Clear ;
datamodule1.qry_cjdy1.sql.Add('select * from cjbdy');
datamodule1.qry_cjdy1.execsql;
datamodule1.qry_cjdy1.open;
while not qry.Eof do //qry 指向每一个班级成员
begin
with datamodule1.qry_cjdy do
begin
close;
sql.Clear ;
sql.add('select * from cjb0 where bjh0=:name and kkxq=:id and xsxh_id=:aa');
parambyname('name').asstring:=combobox2.text;
parambyname('id').asstring:=maskedit1.Text;
parambyname('aa').AsString:=qry.Fields[0].asstring;
open; //选出个人的成绩
//datamodule1.qry_cjdy1.sql.Clear ;
//datamodule1.qry_cjdy1.sql.Add('delete from cjbdy');
//datamodule1.qry_cjdy1.execsql;
datamodule1.qry_cjdy1.edit; //让表cjbdy处编辑状态
for i:=low(a) to high(a) do
a[i]:='';
for i:=1 to 15 do //储存课程名
if not eof then
begin
a[i]:=datamodule1.qry_cjdy.Fields[5].AsString;
next;
end;
for i:=1 to 15 do
datamodule1.qry_cjdy1.Fields[i+1].asstring:=a[i];
//datamodule1.qry_cjdy1.post;
datamodule1.qry_cjdy.First;
for i:=16 to 30 do //保存成绩
if not eof then
begin
a[i]:=datamodule1.qry_cjdy.Fields[10].AsString;
next;
end;
for i