📄 ussfp.~pas
字号:
unit USsfp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PrnDbgeh, DB, ADODB, ActnList, Grids, DBGridEh, StdCtrls, Mask,
DBCtrlsEh, ExtCtrls, ComCtrls, ToolWin;
type
TSSVar = record//试室分配时候的变量
ss: array[1..2]of string;//试室名称、分配人数
nj: array[1..2]of string;//包括那两个年级
rs: array[1..2]of string; //每个年级分配的人数
tj: string;//条件:尖或者普
end;
TFSsfp = class(TForm)
Splitter1: TSplitter;
StatusBar: TStatusBar;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
Tool_add: TToolButton;
Tool_modify: TToolButton;
Tool_save: TToolButton;
Tool_cancel: TToolButton;
Tool_print: TToolButton;
ToolButton7: TToolButton;
Tool_m: TToolButton;
Panel1: TPanel;
Shape1: TShape;
Shape2: TShape;
Panel2: TPanel;
ActionList: TActionList;
A_fpre: TAction;
A_fp: TAction;
A_clear: TAction;
A_cancel: TAction;
A_preview: TAction;
A_refresh: TAction;
A_init: TAction;
ADOQuery: TADOQuery;
DataSource: TDataSource;
PrintDBGridEh: TPrintDBGridEh;
Panel3: TPanel;
DBGridEh: TDBGridEh;
Splitter2: TSplitter;
Panel4: TPanel;
DBGridEh1: TDBGridEh;
Shape3: TShape;
Shape4: TShape;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
Tool_refresh: TToolButton;
ComboBox1: TComboBox;
Shape5: TShape;
Label1: TLabel;
InitDisplay: TLabel;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
ADOQueryID: TAutoIncField;
ADOQueryDSDesigner: TWideStringField;
ADOQueryDSDesigner2: TWideStringField;
ADOQueryDSDesigner3: TSmallintField;
ADOQueryDSDesigner4: TWideStringField;
ADOQueryDSDesigner5: TWideStringField;
ADOQueryDSDesigner6: TWideStringField;
ADOQueryDSDesigner7: TFloatField;
ADOQueryDSDesigner8: TFloatField;
ADOQueryDSDesigner9: TFloatField;
ADOQueryDSDesigner10: TFloatField;
ADOQueryDSDesigner11: TFloatField;
ADOQueryDSDesigner12: TFloatField;
ADOQueryDSDesigner13: TFloatField;
ADOQueryDSDesigner14: TFloatField;
ADOQueryDSDesigner15: TFloatField;
ADOQueryDSDesigner16: TFloatField;
ADOQueryDSDesigner17: TFloatField;
ADOQueryDSDesigner18: TWideStringField;
ADOQueryDSDesigner19: TWideStringField;
ADOQueryDSDesigner20: TWideStringField;
ADOQueryvxh1: TIntegerField;
ADOQuery1vxh: TIntegerField;
GroupBox1: TGroupBox;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
A_auto: TAction;
GroupBox2: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
GroupBox4: TGroupBox;
ListBox1: TListBox;
Panel5: TPanel;
GroupBox3: TGroupBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
GroupBox5: TGroupBox;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Shape6: TShape;
ComboBox2: TComboBox;
Button3: TButton;
ADOQueryDSDesigner21: TWideStringField;
Button4: TButton;
LInfo1: TLabel;
LInfo2: TLabel;
LInfo3: TLabel;
Label4: TLabel;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
Shape10: TShape;
ADOQuery1ID: TAutoIncField;
ADOQuery1ss: TWideStringField;
ADOQuery1rs: TSmallintField;
ADOQuery1nj1: TWideStringField;
ADOQuery1nj2: TWideStringField;
ADOQuery1rs1: TSmallintField;
ADOQuery1rs2: TSmallintField;
Label5: TLabel;
LCL1: TLabel;
LCL2: TLabel;
LCL3: TLabel;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
procedure A_initExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ADOQueryCalcFields(DataSet: TDataSet);
procedure ADOQuery1CalcFields(DataSet: TDataSet);
procedure A_autoExecute(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure ListBox1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure A_refreshExecute(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure ADOQueryAfterOpen(DataSet: TDataSet);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
FFptj: TSSVar;
procedure showinfo; //(显示信息)
procedure updatessnull(ass: string);
public
{ Public declarations }
end;
var
FSsfp: TFSsfp;
implementation
uses UMain, UPublic;
{$R *.dfm}
procedure TFSsfp.A_initExecute(Sender: TObject);
var
i,xh: integer;
begin
if ask('初始化将把所有的已经分好的学生试室、座位号全部删除,请小心使用,要继续吗?','提问',MB_OKCL+MB_WARN)<>1 then exit;
InitDisplay.Visible := true;
InitDisplay.Caption := '正在初始化,请稍候...';
InitDisplay.Refresh;
Screen.Cursor := crHourglass;
with TADOQuery.Create(self) do try
Connection := FMain.ADOConnection;
SQL.Text := 'update STU_info set 试室名称=null,座位号=null';
ExecSQL;
for i := 0 to ComboBox1.Items.Count - 1 do begin
xh := 1;
SQL.Text := 'select ID,序号 from STU_info where 班级='''+ComboBox1.Items[i]+''' and 退学否=''F''';
Open;
while not Eof do begin
Edit;
FieldByName('序号').AsInteger := xh;
Post;
Inc(xh);
Next;
end;
end;
finally
InitDisplay.Visible := False;
Screen.Cursor := crDefault;
free;
end;
ExecuteSQL('update STU_ss set nj1=null,nj2=null,rs1=null,rs2=null');
Tool_refresh.Click;
Ask('初始化成功','信息',MB_INFO);
end;
procedure TFSsfp.FormCreate(Sender: TObject);
var
i: integer;
begin
inherited;
for i := 0 to ComponentCount - 1 do
if (Components[i] is TADOQuery) then
if (TADOQuery(Components[i]).SQL.Text<>'') and (TADOQuery(Components[i]).Tag<>111) then
if not TADOQuery(Components[i]).Active then
try
TADOQuery(Components[i]).Open;
except
end;
InitCode('select distinct bj,id from STU_class order by id',ComboBox1.Items);
InitCode('select distinct ss,id from STU_ss order by id',ComboBox2.Items);
ComboBox2.Items.Insert(0,'全部数据');
with TADOQuery.Create(nil) do try
Connection := FMain.ADOConnection;
SQL.Text := 'select * from STU_SS';
Open;
while not Eof do begin
ListBox1.Items.Add(FieldByname('ss').AsString+'-'+FIeldByName('rs').AsString);
next;
end;
finally
Free;
end;
showinfo;
end;
procedure TFSsfp.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
Release;
end;
procedure TFSsfp.ADOQueryCalcFields(DataSet: TDataSet);
begin
ADOQuery.FieldByName('vxh').AsInteger := abs(ADOQuery.RecNo);
end;
procedure TFSsfp.ADOQuery1CalcFields(DataSet: TDataSet);
begin
ADOQuery1.FieldByName('vxh').AsInteger := abs(ADOQuery1.RecNo);
end;
procedure TFSsfp.A_autoExecute(Sender: TObject);
begin
//
end;
procedure TFSsfp.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then Key := #0;
end;
procedure TFSsfp.ListBox1Click(Sender: TObject);
var
i: integer;
str: string;
begin
for i := 0 to (ListBox1.Items.Count - 1) do
if ListBox1.Selected[i] then begin
str := ListBox1.Items.Strings[i];
Edit1.Text := Copy(str, Pos('-',str)+1,length(str)-Pos('-',str));
end;
Button2.Enabled := False;
end;
procedure TFSsfp.Button1Click(Sender: TObject);
function functionrs: boolean;
var
i: integer;
str: string;
begin
result := False;
if ListBox1.ItemIndex<0 then begin
Ask('试室未选择!','出错',MB_Stop);
exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -