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

📄 p_st_oper.pas

📁 学员管理的软件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
tempmemo:=Tmemo.Create(nil);
tempmemo.Parent:=st_oper;
tempmemo.Visible:=false;
adotable1.DisableControls;
adotable1.First;
progressbar1.Max:=adotable1.RecordCount;
progressbar1.Position:=0;
screen.Cursor:=crhourglass;
for i:=0 to adotable1.RecordCount do
begin
  for j:=0 to adotable1.FieldCount-1 do
    tempmemo.Lines.Add(adotable1.Fields[j].FieldName+':'+adotable1.Fields[j].AsString);
  tempmemo.Lines.Add('-------------------------------------');
progressbar1.Position:=progressbar1.Position +1;
adotable1.Next;
end;
tempmemo.Lines.SaveToFile(savedialog1.FileName);
tempmemo.Free;
adotable1.EnableControls;
screen.Cursor:=crdefault;
end;

procedure Tst_oper.writeexcel(fname:string);
var
s:string;
excelapp:Texcelapplication;
excelwkbook:Texcelworkbook;
excelwksheet:Texcelworksheet;
i,j:Integer;
begin
case tj.ItemIndex of
1:s:='题目';
2:s:='难度';
3:s:='分值';
4:s:='所属题库';
5:s:='试题号';
end;
adotable1.Close;
adotable1.Filter:=s+'='+edit2.Text;
adotable1.Filtered:=true;
adotable1.Open;
try
 excelapp:=Texcelapplication.Create(application);
 excelwkbook:=Texcelworkbook.Create(application);
 excelwksheet:=Texcelworksheet.Create(application);
 excelapp.Connect;
except
messagedlg('excel没有安装',mtERROR,[mbyes],0);
abort;
end;
excelapp.Workbooks.Add(emptyparam,0);
excelwkbook.ConnectTo(excelapp.Workbooks[1]);
excelwksheet.ConnectTo(excelwkbook.Worksheets[1] as _worksheet);
progressbar1.Max:=adotable1.RecordCount;
progressbar1.Position:=0;
adotable1.First;
adotable1.DisableControls;
for j:=0 to adotable1.Fields.Count-1 do
begin
excelwksheet.Cells.Item[1,j+1]:=adotable1.Fields[j].DisplayLabel;
end;
for i:=2 to adotable1.RecordCount+1 do
begin
  for j:=0 to adotable1.Fields.Count-1 do
  excelwksheet.Cells.Item[i,j+1]:=adotable1.Fields[j].AsString;
progressbar1.Position:=progressbar1.Position+1;
adotable1.Next;
end;
excelwksheet.Columns.AutoFit;
excelwksheet.SaveAs(fname);
adotable1.EnableControls;
excelapp.Disconnect;
excelapp.Quit;
excelapp.Free;
excelwkbook.Free;
excelwksheet.Free;
end;

procedure Tst_oper.writedb(const fname:string);
begin
//adotable1.fielddefs.Add('temp',ftinteger,0,false);
//table1.DatabaseName:=extractfilepath(fname);
//table1.TableName:=extractfilename(fname);
//table1.FieldDefs.Add('temp',ftinteger,0,false);
//table1.CreateTable;
//batchmove1.Execute;
end;
procedure Tst_oper.Check_;
begin
case RadioGroup1.ItemIndex of
0:
begin
savedialog1.Filter:='paradox file(*.db)|*.db';
savedialog1.DefaultExt:='db';
end;
1:
begin
savedialog1.Filter:='foxpro file(*.dbf)|*.dbf';
savedialog1.DefaultExt:='dbf';
end;
2:
begin
savedialog1.Filter:='excel file(*.xls)|*.xls';
savedialog1.DefaultExt:='xls';
end;
3:
begin
savedialog1.Filter:='text file(*.txt)|*.txt';
savedialog1.DefaultExt:='txt';
end;
end;
end;

procedure Tst_oper.BitBtn3Click(Sender: TObject);
begin
if ((edit2.Text = '') and (tj.ItemIndex<>0)) then
begin
showmessage('请设置好条件');
exit;
end;
if not adotable1.Active then
begin
messagedlg('没有数据源',mtError,[mbYes],0);
exit;
end;
check_;
if savedialog1.Execute then
begin
case RadioGroup1.ItemIndex of
0:  begin
//savedialog1.Filter:='paradox file(*.db)|*.db';
//savedialog1.DefaultExt:='db';
//writedb(savedialog1.FileName);
end;
1:
begin
//savedialog1.Filter:='foxpro file(*.dbf)|*.dbf';
//savedialog1.DefaultExt:='dbf';
//writedb(savedialog1.FileName);
end;
2:
begin
//savedialog1.Filter:='excel file(*.xls)|*.xls';
//savedialog1.DefaultExt:='xls';
writeexcel(savedialog1.FileName);
end;
3:begin
//savedialog1.Filter:='text file(*.txt)|*.txt';
//savedialog1.DefaultExt:='txt';
writetxt(savedialog1.FileName);
end;
end;
end;
messagedlg('数据成功导出到'+chr(13)+chr(10)+savedialog1.FileName,mtinformation,[mbyes],0);
end;

procedure Tst_oper.tjClick(Sender: TObject);
var
qq:Tadoquery;
begin
if tj.ItemIndex=4 then
begin
tj.ShowHint:=true;
qq:=Tadoquery.Create(nil);
qq.Connection:=main.DataModule2.ADOConnection1;
qq.Close;
qq.SQL.Clear;
qq.SQL.Add('select * from 题库表');
qq.Open;
tj.Hint:='';
while not qq.Eof do
begin
tj.Hint:=tj.Hint+inttostr(qq.FieldValues['id'])+':'+qq.FieldValues['name']+' ';
qq.Next;
end;
end;
end;

procedure Tst_oper.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if ((tj.ItemIndex=2)or(tj.ItemIndex =3)or(tj.ItemIndex=5)) then
begin
  if key in ['0','1','2','3','4','5','6','7','8','9'] then
  else
  begin
  showmessage('不合法字符');
  exit;
  end;
end;

end;

procedure Tst_oper.BitBtn4Click(Sender: TObject);
begin
close;
end;

procedure Tst_oper.ListView1DblClick(Sender: TObject);
begin
if listview1.Selected=nil  then
exit;
p_st_update.stid:=listview1.Selected.Caption;
p_st_update.sstk:=listview1.Selected.SubItems.Strings[0];
p_st_update.dzsd:=listview1.Selected.SubItems.Strings[1];
p_st_update.xzsd:=listview1.Selected.SubItems.Strings[2];
p_st_update.mylry:=listview1.Selected.SubItems.Strings[10];
p_st_update.st_update.ShowModal;
end;

procedure Tst_oper.BitBtn5Click(Sender: TObject);
var ssql:string;
begin
listview2.Clear;
case RadioGroup2.ItemIndex of
0:
begin
ssql:='SELECT 题型,count(*) as 个数 from 试题表 group by 题型';
with main.DataModule2 do
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(ssql);
aq1.Open;
while not aq1.Eof do
begin
    with listview2.Items.Add do
    begin
       caption:=aq1.FieldValues['题型'];
       subitems.Add(aq1.FieldValues['个数']);
    end;
aq1.Next;
end;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select * from 题型表');
aq1.open;
statusbar1.Panels[0].Text:='';
while not aq1.Eof do
begin
statusbar1.Panels[0].Text:=statusbar1.Panels[0].Text+' '+inttostr(aq1.FieldValues['id'])+':'+aq1.FieldValues['name'];
aq1.Next;
end;
end;

end;
1:
begin
ssql:='SELECT 难度,count(*) as 个数 from 试题表 group by 难度';
with main.DataModule2 do
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(ssql);
aq1.Open;
while not aq1.Eof do
begin
    with listview2.Items.Add do
    begin
       caption:=aq1.FieldValues['难度'];
       subitems.Add(aq1.FieldValues['个数']);
    end;
aq1.Next;
end;
end;
end;
2:
begin
ssql:='SELECT 分值,count(*) as 个数 from 试题表 group by 分值';
with main.DataModule2 do
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(ssql);
aq1.Open;
while not aq1.Eof do
begin
    with listview2.Items.Add do
    begin
       caption:=aq1.FieldValues['分值'];
       subitems.Add(aq1.FieldValues['个数']);
    end;
aq1.Next;
end;
end;
end;
3:
begin
ssql:='SELECT 所属题库,count(*) as 个数 from 试题表 group by 所属题库';
with main.DataModule2 do
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(ssql);
aq1.Open;
while not aq1.Eof do
begin
    with listview2.Items.Add do
    begin
       caption:=aq1.FieldValues['所属题库'];
       subitems.Add(aq1.FieldValues['个数']);
    end;
aq1.Next;
end;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select * from 题库表');
aq1.open;
statusbar1.Panels[0].Text:='';
while not aq1.Eof do
begin
statusbar1.Panels[0].Text:=statusbar1.Panels[0].Text+' '+inttostr(aq1.FieldValues['id'])+':'+aq1.FieldValues['name'];
aq1.Next;
end;
end;
end;
4:
begin
ssql:='SELECT 自动判分,count(*) as 个数 from 试题表 group by 自动判分';
with main.DataModule2 do
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(ssql);
aq1.Open;
while not aq1.Eof do
begin
    with listview2.Items.Add do
    begin
       caption:=aq1.FieldValues['自动判分'];
       subitems.Add(aq1.FieldValues['个数']);
    end;
aq1.Next;
end;
statusbar1.Panels[0].Text:='';
statusbar1.Panels[0].Text:='0:代表手工判分 -1:代表自动判分';
end;
end;
end;
end;







end.

⌨️ 快捷键说明

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