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

📄 cjdytempunit.pas

📁 delphi sqlserver 学生学籍管理系统
💻 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:=16 to 30 do
datamodule1.qry_cjdy1.Fields[i+1].asstring:=a[i];
//datamodule1.qry_cjdy1.post;

datamodule1.qry_cjdy.First;

for i:=31 to 45 do        //保存学分
 if not eof then
 begin
datamodule1.qry_cjdy1.Fields[i+1].asstring:=datamodule1.qry_cjdy.Fields[9].AsString;
 next;
 end;

 datamodule1.qry_cjdy.First;

 for i:=46 to 60 do                 //保持课程类别
 if not eof then
 begin
datamodule1.qry_cjdy1.Fields[i+1].asstring:=datamodule1.qry_cjdy.Fields[6].AsString ;
 next;
 end;
datamodule1.qry_cjdy1.post;

qry.next;        //指向下一个学生
datamodule1.qry_cjdy1.Next ;     //指向下一个学生
end;
end;
end;
bjcjdy:=tbjcjdy.create(self);
bjcjdy.showmodal;
end;

if radiobutton2.Checked then
begin

with qry do
begin
close;
sql.Clear ;
sql.Add('select * from xsmc where xsxh_id=:id');
parambyname('id').asstring:=edit1.text;
open;
if not findfirst then
begin
application.MessageBox('该学号不存在,请核对后再输!','提示',mb_ok+mb_iconinformation);
exit;
end;
end;

with datamodule1.qry_cjdy do
begin
close;
sql.Clear ;
sql.add('select * from cjb0 where xsxh_id=:name and kkxq=:id');
parambyname('name').asstring:=edit1.text;
parambyname('id').asstring:=maskedit1.Text;
open;
cjdy:=tcjdy.create(self);
cjdy.showmodal;
end;
end;


end;

end.

⌨️ 快捷键说明

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