📄 ussfp.~pas
字号:
end;
FFptj.ss[1] := '';
FFptj.ss[2] := '';
for i := 0 to (ListBox1.Items.Count - 1) do
if ListBox1.Selected[i] then begin
str := ListBox1.Items.Strings[i];
FFptj.ss[1] := Copy(str,1, Pos('-',str)-1);
str := Copy(str, Pos('-',str)+1,length(str)-Pos('-',str));
end;
if Edit1.Text='' then Edit1.Text := str
else if strtoint(Edit1.Text)>strtoint(str) then begin
Ask('人数已经超出试室能容纳的最大人数!','出错',MB_Stop);
exit;
end;
result := True;
FFptj.ss[2] := Edit1.Text;
end;
function functionnj: boolean;
var
i: integer;
abool: boolean;
begin
result := False;
abool :=True;
i := 0;
FFptj.nj[1] := '';
FFptj.nj[2] := '';
if CheckBox1.Checked then begin
inc(i);
FFptj.nj[1] := CheckBox1.Caption;
abool := false;
end;
if CheckBox2.Checked then begin
if abool then FFptj.nj[1] := CheckBox2.Caption
else FFptj.nj[2] := CheckBox2.Caption;
inc(i);
end;
if CheckBox3.Checked then begin
FFptj.nj[2] := CheckBox3.Caption;
inc(i);
end;
if i <2 then begin
Ask('年级选择太少,请再选择!','出错',MB_Stop);
exit;
end;
if i >2 then begin
Ask('年级选择太多,请去掉!','出错',MB_Stop);
exit;
end;
result := true;
end;
function functionlx: boolean;
begin
result := False;
FFptj.tj :='';
if Checkbox4.Checked and Checkbox5.Checked then begin
Ask('类型选择太多,请去掉一个或全部!','出错',MB_Stop);
exit;
end;
if Checkbox4.Checked then FFptj.tj := '尖';
if Checkbox5.Checked then FFptj.tj := '普';
result := true;
end;
var
str,aClass,aTj: string;
begin
try
if not functionrs then exit; //检查人数是否正确,成功将返回试室及人数
if not functionnj then exit; //检查年级选择是否正确
if not functionlx then exit;//检查类型条件选择是否正确
except
Ask('检查出错!','出错',MB_Stop);
end;
FFptj.rs[1] := inttostr(strtoint(FFptj.ss[2])-trunc(strtoint(FFptj.ss[2])/2));
FFptj.rs[2] := inttostr(trunc(strtoint(FFptj.ss[2])/2));
if trim(FFptj.tj)<>'' then begin
aClass := FFptj.tj+'班';
aTj := ' and 类型='''+FFptj.tj+''' ';
end;
if GetFieldVar('select count(*) from STU_INFO where 试室名称='''+FFptj.ss[1]+'''')>0 then
LCL1.Caption := '该试室已经被分配了,重新分配将会覆盖以前的数据'
else LCL1.Caption := '该试室还没有被分配';
str := '将把'+FFptj.nj[1]+'级'+aClass+FFptj.rs[1]+'人插入'
+FFptj.ss[1]+'中;'+FFptj.nj[1]+'级'+aClass+'共有'
+inttostr(getfieldVar('select count(*) from STU_INFO where 试室名称 is null and 级别='''+FFptj.nj[1]+''''+aTj))
+'人未分配;';
LCL2.Caption := str;
str := '将把'+FFptj.nj[2]+'级'+aClass+FFptj.rs[2]+'人插入'
+FFptj.ss[1]+'中;'+FFptj.nj[2]+'级'+aClass+'共有'
+inttostr(getfieldVar('select count(*) from STU_INFO where 试室名称 is null and 级别='''+FFptj.nj[2]+''''+aTj))
+'人未分配;';
LCL3.Caption := str;
Button2.Enabled := true;
end;
procedure TFSsfp.Button2Click(Sender: TObject);
var
i, aCount1, aCount2: integer;
str, aTJ,aQT: string;
begin
if Ask(PChar('分配将会覆盖'+FFptj.ss[1]+'以前的数据,是否继续?'),'提示',MB_OKCL)<>1 then exit;
ExecuteSQL('update STU_info set 试室名称=null,座位号=null where 试室名称='''+FFptj.ss[1]+'''');
try
with TADOQuery.Create(self) do try
Connection := FMain.ADOConnection;
if trim(FFptj.tj)<>'' then aTJ := ' and 类型='''+FFptj.tj+'''';
SQL.Text := 'select ID,试室名称, 座位号,流水号 from STU_info where 退学否=''F'' and '
+'(试室名称 is null) and 级别='''+FFptj.nj[1]+''''+aTJ +' order by 序号';
Open;
First;
aCount1 := strtoint(FFptj.rs[1]);
if RecordCount < aCount1 then aCount1 := RecordCount;
for i := 0 to aCount1-1 do begin
Edit;
FieldByName('试室名称').AsString := FFptj.ss[1];
FieldByName('座位号').AsInteger := i+1;
str := inttostr(i+1);
while length(str)<5 do str := '0'+str;
FieldByName('流水号').AsString := str;
Post;
Next;
end;
Close;
SQL.Text := 'select ID,试室名称, 座位号,流水号 from STU_info where 退学否=''F'' and '
+'(试室名称 is null) and 级别='''+FFptj.nj[2]+''''+aTJ +' order by 序号';
Open;
First;
aCount2 := strtoint(FFptj.rs[2]);
if RecordCount < aCount2 then aCount2 := RecordCount;
for i := 0 to aCount2-1 do begin
Edit;
FieldByName('试室名称').AsString := FFptj.ss[1];
FieldByName('座位号').AsInteger := aCount1+i+1;
str := inttostr(aCount1+i+1);
while length(str)<5 do str := '0'+str;
FieldByName('流水号').AsString := str;
Post;
Next;
end;
LCL1.Caption := '分配成功';
if trim(FFptj.tj)<>'' then aQT := FFptj.tj+'班';
str := '已把'+FFptj.nj[1]+'级'+aQT+inttostr(aCount1)+'人插入'
+FFptj.ss[1]+'中;'+FFptj.nj[1]+'级'+aQT+'还有'
+inttostr(getfieldVar('select count(*) from STU_INFO where 试室名称 is null and 级别='''+FFptj.nj[1]+''''+aTj))
+'人未分配;';
LCL2.Caption := str;
str := '把'+FFptj.nj[2]+'级'+aQt+inttostr(aCount2)+'人插入'
+FFptj.ss[1]+'中;'+FFptj.nj[2]+'级'+aQt+'还有'
+inttostr(getfieldVar('select count(*) from STU_INFO where 试室名称 is null and 级别='''+FFptj.nj[2]+''''+aTj))
+'人未分配;';
LCL3.Caption := str;
//
str :='update STU_ss set nj1='''+FFptj.nj[1]+''',nj2='''+FFptj.nj[2]
+''',rs1='+inttostr(aCount1)+',rs2='+inttostr(aCount2)+' where ss='''+FFptj.ss[1]+'''';
ExecuteSQL(str);
Tool_refresh.Click;
ComboBox2.ItemIndex := ComboBox2.Items.IndexOf(FFptj.ss[1]);
Button3.Click;
showinfo;
Ask('分配成功','信息',MB_INFO);
finally
free;
end;
except
Button2.Enabled := false;
Ask('分配失败!','提示',MB_STOP);
end;
Button2.Enabled := false;
end;
procedure TFSsfp.Button3Click(Sender: TObject);
begin
if ComboBox2.ItemIndex <0 then exit;
if ComboBox2.Text = '全部数据' then begin
with ADOQuery do try
if Active then Close;
sql.Text := 'select * from STU_info where 退学否=''F'' and (not(试室名称 is null)) order by 试室名称,流水号';
Open;
except
end;
exit;
end;
with ADOQuery do try
if Active then Close;
sql.Text := 'select * from STU_info where 退学否=''F'' and 试室名称='''+ComboBox2.text+''' order by 试室名称,流水号';
Open;
except
end;
end;
procedure TFSsfp.A_refreshExecute(Sender: TObject);
var
i: integer;
begin
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
begin
if TADOQuery(Components[i]).Active then TADOQuery(Components[i]).Close;
try
TADOQuery(Components[i]).Open;
except
end;
end;
end;
procedure TFSsfp.Button4Click(Sender: TObject);
begin
if ComboBox2.ItemIndex < 1 then exit; //不提供清除全部数据.
if Ask(PChar('将清除'+ComboBox2.Text+'以前的数据,是否继续?'),'提示',MB_OKCL)<>1 then exit;
ExecuteSQL('update STU_info set 试室名称=null,座位号=null where 试室名称='''+ComboBox2.Text+'''');
updatessnull(ComboBox2.Text);//清除试室数据库中的相关数据
tool_refresh.Click;
showinfo;
Ask('清除成功!','提示',MB_INFO);
end;
procedure TFSsfp.ADOQueryAfterOpen(DataSet: TDataSet);
begin
StatusBar.SimpleText :='总共搜索到'+inttostr(ADOQuery.RecordCount)+'条数据';
end;
procedure TFSsfp.showinfo;
var
str,str1: string;
begin
str1 := 'select count(*) from STU_INFO where 试室名称 ';
str := '初一尖班已经分配'+inttostr(getfieldVar(str1 +' <>'''+''' and 级别=''初一'' and 类型=''尖'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初一'' and 类型=''尖'''))
+'人未分配; '
+ '初一普通班已经分配'+inttostr(getfieldVar(str1+' <>'''+''' and 级别=''初一'' and 类型=''普'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初一'' and 类型=''普'''))
+'人未分配。';
LInfo1.Caption := str;
str := '初二尖班已经分配'+inttostr(getfieldVar(str1+' <>'''+''' and 级别=''初二'' and 类型=''尖'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初二'' and 类型=''尖'''))
+'人未分配; '
+ '初二普通班已经分配'+inttostr(getfieldVar(str1+' <>'''+''' and 级别=''初二'' and 类型=''普'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初二'' and 类型=''普'''))
+'人未分配';
LInfo2.Caption := str;
str := '初三尖班已经分配'+inttostr(getfieldVar(str1+' <>'''+''' and 级别=''初三'' and 类型=''尖'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初三'' and 类型=''尖'''))
+'人未分配; '
+ '初三普通班已经分配'+inttostr(getfieldVar(str1+' <>'''+''' and 级别=''初三'' and 类型=''普'''))
+'人,还有'+inttostr(getfieldVar(str1+' is null and 级别=''初三'' and 类型=''普'''))
+'人未分配。';
LInfo3.Caption := str;
end;
procedure TFSsfp.updatessnull(ass: string);
begin
ExecuteSQL('update STU_ss set nj1=null,nj2=null,rs1=null,rs2=null where ss='''+ass+'''');
end;
procedure TFSsfp.CheckBox1Click(Sender: TObject);
begin
Button2.Enabled := False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -