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

📄 u_stlr.~pas

📁 试卷管理系统
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
unit U_stlr;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ComCtrls, Buttons,
  OleCtnrs, ExtCtrls, Menus, ToolWin, DBCtrls;

type
  Tfrm_stlr = class(TForm)
    GroupBox2: TGroupBox;
    GroupBox5: TGroupBox;
    GroupBox6: TGroupBox;
    Label3: TLabel;
    combo_zy: TComboBox;
    Label2: TLabel;
    combo_gwlb: TComboBox;
    Label4: TLabel;
    combo_gwzl: TComboBox;
    Label5: TLabel;
    combo_khdx: TComboBox;
    combo_sttx: TComboBox;
    Label6: TLabel;
    tbl_khdx: TTable;
    tbl_gwzl: TTable;
    tbl_gwlb: TTable;
    tbl_zy: TTable;
    tbl_sttx: TTable;
    OleContainer1: TOleContainer;
    OleContainer2: TOleContainer;
    tbl_stk: TTable;
    tbl_stkSTXH: TIntegerField;
    tbl_stkZYXH: TSmallintField;
    tbl_stkGWLBXH: TSmallintField;
    tbl_stkGWZLXH: TSmallintField;
    tbl_stkKHDXXH: TSmallintField;
    tbl_stkTXXH: TSmallintField;
    tbl_stkZWCD: TBooleanField;
    RadioGroup1: TRadioGroup;
    Panel1: TPanel;
    Panel2: TPanel;
    GroupBox1: TGroupBox;
    btn_first: TButton;
    btn_priror: TButton;
    btn_next: TButton;
    btn_last: TButton;
    btn_insert: TButton;
    btn_delete: TButton;
    btn_edit: TButton;
    btn_save: TButton;
    btn_cancel: TButton;
    BitBtn2: TBitBtn;
    MainMenu1: TMainMenu;
    BitBtn1: TBitBtn;
    Query1: TQuery;
    OleContainer3: TOleContainer;
    tbl_stkWBTM: TMemoField;
    tbl_stkWBDA: TMemoField;
    tbl_stkTWTM: TBlobField;
    tbl_stkTWDA: TBlobField;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    Memo1: TMemo;
    Memo2: TMemo;
    tbl_stkTMIFWB: TBooleanField;
    tbl_stkDAIFWB: TBooleanField;
    procedure FormCreate(Sender: TObject);
    procedure combo_zyChange(Sender: TObject);
    procedure combo_gwlbChange(Sender: TObject);
    procedure combo_gwzlChange(Sender: TObject);
    procedure combo_khdxChange(Sender: TObject);
    procedure combo_sttxChange(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btn_closeClick(Sender: TObject);
    procedure btn_insertClick(Sender: TObject);
    procedure btn_saveClick(Sender: TObject);
    procedure tbl_stkAfterScroll(DataSet: TDataSet);
    procedure btn_firstClick(Sender: TObject);
    procedure btn_nextClick(Sender: TObject);
    procedure btn_prirorClick(Sender: TObject);
    procedure btn_lastClick(Sender: TObject);
    procedure btn_cancelClick(Sender: TObject);
    procedure btn_editClick(Sender: TObject);
    procedure OleContainerOpen(flag:string);
    procedure btn_deleteClick(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure tbl_stkAfterCancel(DataSet: TDataSet);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure GroupBox6MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure GroupBox5MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
    xh:integer;
    outing:boolean;
    procedure WordQuit(Sender: TObject);
    procedure CopyDirectory(AHandle:THandle;AFromDir,AToDir:String);
  public
    { Public declarations }
  end;

var
  frm_stlr: Tfrm_stlr;

implementation
uses P_RES,Word2000,AutoImpl,ShellAPI, U_progressfrm;
{$R *.dfm}
var
  WordObject:TWordObject;

procedure Tfrm_stlr.FormCreate(Sender: TObject);
begin
  tbl_sttx.First;
  while not tbl_sttx.Eof do
  begin
    combo_sttx.Items.AddObject(tbl_sttx.FieldByName('txmc').AsString,TObject(tbl_sttx.FieldByName('txxh').AsInteger));
    tbl_sttx.Next;
  end;
  combo_sttx.ItemIndex:=0;
  tbl_sttx.Close;

  tbl_zy.First;
  while not tbl_zy.Eof do
  begin
    combo_zy.Items.AddObject(tbl_zy.FieldByName('zymc').AsString,TObject(tbl_zy.FieldByName('zyxh').AsInteger));
    tbl_zy.Next;
  end;

  tbl_zy.Close;

  if combo_zy.Items.Count<>0 then
    combo_zy.ItemIndex:=0;
  combo_zyChange(self);
end;

procedure Tfrm_stlr.combo_zyChange(Sender: TObject);
begin
  combo_gwlb.Clear;
  if combo_zy.Items.Count<>0 then
    tbl_gwlb.Filter:='zyxh='+inttostr(Integer(combo_zy.Items.Objects[combo_zy.ItemIndex]))
  else
    tbl_gwlb.Filter:='zyxh=0';

  tbl_gwlb.First;
  while not tbl_gwlb.Eof do
  begin
    combo_gwlb.Items.AddObject(tbl_gwlb.FieldByName('gwlbmc').AsString,TObject(tbl_gwlb.FieldByName('gwlbxh').AsInteger));
    tbl_gwlb.Next;
  end;

  if combo_gwlb.Items.Count<>0 then
    combo_gwlb.ItemIndex:=0;

  combo_gwlbChange(self);

end;

procedure Tfrm_stlr.combo_gwlbChange(Sender: TObject);
var
  s:string;
begin
  combo_gwzl.Clear;

  if combo_zy.Items.Count<>0 then
    s:='check=true and zyxh='+inttostr(Integer(combo_zy.Items.Objects[combo_zy.ItemIndex]))
  else
    s:='zyxh=0';

  if combo_gwlb.Items.Count<>0 then
    s:=s+' and gwlbxh='+inttostr(Integer(combo_gwlb.Items.Objects[combo_gwlb.ItemIndex]))
  else
    s:=s+' and gwlbxh=0';

  tbl_gwzl.Filter:=s;

  tbl_gwzl.First;
  while not tbl_gwzl.Eof do
  begin
    combo_gwzl.Items.AddObject(tbl_gwzl.FieldByName('gwzlmc').AsString,TObject(tbl_gwzl.FieldByName('gwzlxh').AsInteger));
    tbl_gwzl.Next;
  end;

  if combo_gwzl.Items.Count<>0 then
    combo_gwzl.ItemIndex:=0;

   combo_gwzlChange(self);

end;

procedure Tfrm_stlr.combo_gwzlChange(Sender: TObject);
var
  s:string;
begin
  combo_khdx.Clear;

  if combo_zy.Items.Count<>0 then
    s:='zyxh='+inttostr(Integer(combo_zy.Items.Objects[combo_zy.ItemIndex]))
  else
    s:='zyxh=0';

  if combo_gwlb.Items.Count<>0 then
    s:=s+' and gwlbxh='+inttostr(Integer(combo_gwlb.Items.Objects[combo_gwlb.ItemIndex]))
  else
    s:=s+' and gwlbxh=0';

  if combo_gwzl.Items.Count<>0 then
    s:=s+' and gwzlxh='+inttostr(Integer(combo_gwzl.Items.Objects[combo_gwzl.ItemIndex]))
  else
    s:=s+' and gwzlxh=0';

  tbl_khdx.Filter:=s;

  tbl_khdx.First;
  while not tbl_khdx.Eof do
  begin
    combo_khdx.Items.AddObject(tbl_khdx.FieldByName('khdxmc').AsString,TObject(tbl_khdx.FieldByName('khdxxh').AsInteger));
    tbl_khdx.Next;
  end;

  if combo_khdx.Items.Count<>0 then
    combo_khdx.ItemIndex:=0;

  combo_khdxChange(self);

end;

procedure Tfrm_stlr.combo_khdxChange(Sender: TObject);
begin
  combo_sttxChange(self);
end;

procedure Tfrm_stlr.combo_sttxChange(Sender: TObject);
var
  s:string;
begin
  if combo_zy.Items.Count<>0 then
    s:='zyxh='+inttostr(Integer(combo_zy.Items.Objects[combo_zy.ItemIndex]))
  else
    s:='zyxh=0';

  if combo_gwlb.Items.Count<>0 then
    s:=s+' and gwlbxh='+inttostr(Integer(combo_gwlb.Items.Objects[combo_gwlb.ItemIndex]))
  else
    s:=s+' and gwlbxh=0';

  if combo_gwzl.Items.Count<>0 then
    s:=s+' and gwzlxh='+inttostr(Integer(combo_gwzl.Items.Objects[combo_gwzl.ItemIndex]))
  else
    s:=s+' and gwzlxh=0';

  if combo_khdx.Items.Count<>0 then
    s:=s+' and khdxxh='+inttostr(Integer(combo_khdx.Items.Objects[combo_khdx.ItemIndex]))
  else
    s:=s+' and khdxxh=0';

  if combo_sttx.Items.Count<>0 then
    s:=s+' and txxh='+inttostr(Integer(combo_sttx.Items.Objects[combo_sttx.ItemIndex]))
  else
    s:=s+' and txxh=0';

  tbl_stk.Filter:=s;
  tbl_stk.Open;
end;

procedure Tfrm_stlr.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Assigned(WordObject) then begin
    WordObject.Free;
    WordObject := nil;
  end;

  OleContainer1.DestroyObject;
  OleContainer2.DestroyObject;

  tbl_zy.Close;
  tbl_gwlb.Close;
  tbl_gwzl.Close;
  tbl_khdx.Close;
  tbl_sttx.Close;

  tbl_stk.Cancel;
  tbl_stk.Close;
end;

procedure Tfrm_stlr.btn_closeClick(Sender: TObject);
begin
  close;
end;

procedure Tfrm_stlr.btn_insertClick(Sender: TObject);
var
  n,max,i:integer;
begin
  n:=tbl_stk.RecordCount;
  max:=0;

  tbl_stk.First;
  while not tbl_stk.Eof do
  begin
    if max<tbl_stk.fieldbyname('stxh').AsInteger then max:=tbl_stk.fieldbyname('stxh').AsInteger;
      tbl_stk.Next;
  end;

  xh:=1;
  if n<max then
  begin
    for i:=1 to max do
    begin
      if not tbl_stk.Locate('stxh',i,[]) then
      begin
        xh:=i;
        break;
      end;
    end;
  end
  else
    xh:=n+1;


  tbl_stk.Append;

  if CheckBox1.Checked then
  begin
    memo1.Text:='';
  end
  else
  begin
    olecontainer1.CreateObject('word.document',false);

    OleContainer1.DoVerb(ovOpen);
    OleContainer1.OleObject.Application.Selection.Font.Name := '宋体';
    OleContainer1.OleObject.Application.Selection.Font.Size := 14;
    If OleContainer1.OleObject.ActiveWindow.View.SplitSpecial = wdPaneNone Then
        OleContainer1.OleObject.ActiveWindow.ActivePane.View.Type := wdWebView
    Else
        OleContainer1.OleObject.ActiveWindow.View.Type := wdWebView ;

    OleContainer1.OleObject.ActiveWindow.ActivePane.DisplayRulers := false;
  end;

  if CheckBox2.Checked then
  begin
    memo2.Text:='';
  end
  else
  begin
    olecontainer2.CreateObject('word.document',false);
    OleContainer2.DoVerb(ovOpen);

    If OleContainer2.OleObject.ActiveWindow.View.SplitSpecial = wdPaneNone Then
      OleContainer2.OleObject.ActiveWindow.ActivePane.View.Type := wdWebView
    Else
      OleContainer2.OleObject.ActiveWindow.View.Type := wdWebView ;

    OleContainer2.OleObject.ActiveWindow.ActivePane.DisplayRulers := false;
    OleContainer2.OleObject.Application.Selection.Font.Name := '宋体';
    OleContainer2.OleObject.Application.Selection.Font.Size := 14;
  end;

  if CheckBox1.Checked then
  begin
    memo1.SetFocus;
  end
  else
  begin
    OleContainer1.DoVerb(ovShow);
  end;

  btn_insert.Enabled:=false;
  btn_edit.Enabled:=false;
  btn_save.Enabled:=true;
  btn_cancel.Enabled:=true;
end;

procedure Tfrm_stlr.btn_saveClick(Sender: TObject);
var
  olestream:TStringstream;
begin
  if combo_gwzl.ItemIndex=-1 then exit;
  if combo_khdx.ItemIndex=-1 then exit;

  btn_save.Enabled:=false;
  btn_cancel.Enabled:=false;
  if tbl_stk.State=dsInsert	then
  begin
     tbl_stk.FieldByName('stxh').AsInteger:=xh;

     tbl_stk.FieldByName('zyxh').AsInteger:=integer(combo_zy.Items.Objects[combo_zy.ItemIndex]);
     if combo_gwlb.Items.Count<>0 then
       tbl_stk.FieldByName('gwlbxh').AsInteger:=integer(combo_gwlb.Items.Objects[combo_gwlb.ItemIndex]);

     tbl_stk.FieldByName('gwzlxh').AsInteger:=integer(combo_gwzl.Items.Objects[combo_gwzl.ItemIndex]);
     tbl_stk.FieldByName('khdxxh').AsInteger:=integer(combo_khdx.Items.Objects[combo_khdx.ItemIndex]);

⌨️ 快捷键说明

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