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

📄 fptzsdy.pas

📁 北京铁路局住房分配系统,数据库为MSSql2000,依次执行crebas4.sql
💻 PAS
字号:
unit Fptzsdy;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, CELLLib_TLB, ExtCtrls,math;

type
  TFormFPTZSDY = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Cell1: TCell;
    Label1: TLabel;
    Button1: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Panel3: TPanel;
    Button2: TButton;
    ComboBox1: TComboBox;
    Label2: TLabel;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    procedure Button6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
    PagS:smallint;//总打印页数
    PagN:smallint;// 当前打印页号
  public
    { Public declarations }
  end;

var
  FormFPTZSDY: TFormFPTZSDY;

implementation

uses datamodl,PublicFun;

{$R *.dfm}

procedure TFormFPTZSDY.Button6Click(Sender: TObject);
begin
  close;
end;

procedure TFormFPTZSDY.Button1Click(Sender: TObject);
var
  opendlg:TOpendialog;
  Sfilename:string;
  i,j:smallint;
begin
  opendlg:=TOpendialog.create(Application);
  opendlg.DefaultExt:='CLL';
  opendlg.filter:='报表格式文件(*.CLL)|*.CLL';
  if opendlg.execute then
  begin
     Sfilename :=opendlg.filename;
     if not comp(sfilename,'分配通知书') then
       begin
         showmessage('请打开指定名称结构文件!');
         exit;
       end;
     if cell1.DoOpenFile(Sfilename)>0 then
     begin
       cell1.DoRedrawAll ;
       for i:=0 to 10 do
         for j:=0 to 31 do
           cell1.DoSetCellReadOnly(i,j,true);
     end;
     button2.Enabled:=true;
     button3.Enabled:=true;
     button4.Enabled:=true;
     button5.Enabled:=true;
  end;
  opendlg.free;
end;

procedure TFormFPTZSDY.FormCreate(Sender: TObject);
begin
   cell1.DoLogin('北京金天鹏软件科技有限公司',363,'00FD18FF080193035CFE09FF9908');
   cell1.EnablePopMenu:=false;
   button2.Enabled:=false;
   button3.Enabled:=false;
   button4.Enabled:=false;
   button5.Enabled:=false;
   button8.Enabled:=false;
   button9.Enabled:=false;

  with datamodule1 do
  begin
    if ADOQry.Active= true then ADOQry.close;
    ADOQry.sql.Clear;
    ADOQry.sql.Add('select dwbh,dwmc from dwxxb ');
    ADOQry.open;
    ADOQry.first;
    while not ADOQry.Eof  do
    begin
      combobox1.Items.Add(ADOQry.fieldbyname('dwbh').AsString+' | '
                         +ADOQry.fieldbyname('dwmc').AsString);
      ADOQry.Next;
    end;
    ADOQry.Close;

  end;
end;

procedure TFormFPTZSDY.Button2Click(Sender: TObject);
var
  i:smallint;
  dw,dwmc:string;
begin
  if trim(combobox1.Text)<>'' then
    begin
      dw:= copy(trim(combobox1.Text),1,3);
      dwmc:= copy(trim(combobox1.Text),7,length(trim(combobox1.Text))-6);
      cell1.DoSetCellString(2,3,dwmc);
    end
  else
    begin
      showmessage('分配楼宇不能为空,请选择!');
      exit;
    end;
  for i:=1 to 20 do
    begin
      cell1.DoSetCellReadOnly(0,i+4,false);
      cell1.DoClearCell(0,i+4,1);
      cell1.DoSetCellReadOnly(0,i+4,true);
      cell1.DoSetCellReadOnly(1,i+4,false);
      cell1.DoClearCell(1,i+4,1);
      cell1.DoSetCellReadOnly(1,i+4,true);
     // cell1.DoSetCellReadOnly(2,i+4,false);
      //cell1.DoClearCell(2,i+4,1);
      //cell1.DoSetCellReadOnly(2,i+4,true);
      cell1.DoSetCellReadOnly(3,i+4,false);
      cell1.DoClearCell(3,i+4,1);
      cell1.DoSetCellReadOnly(3,i+4,true);
      cell1.DoSetCellReadOnly(4,i+4,false);
      cell1.DoClearCell(4,i+4,1);
      cell1.DoSetCellReadOnly(4,i+4,true);
      cell1.DoSetCellReadOnly(5,i+4,false);
      cell1.DoClearCell(5,i+4,1);
      cell1.DoSetCellReadOnly(5,i+4,true);
      cell1.DoSetCellReadOnly(6,i+4,false);
      cell1.DoClearCell(6,i+4,1);
      cell1.DoSetCellReadOnly(6,i+4,true);
      cell1.DoSetCellReadOnly(7,i+4,false);
      cell1.DoClearCell(7,i+4,1);
      cell1.DoSetCellReadOnly(7,i+4,true);
      cell1.DoSetCellReadOnly(8,i+4,false);
      cell1.DoClearCell(8,i+4,1);
      cell1.DoSetCellReadOnly(8,i+4,true);
      cell1.DoSetCellReadOnly(9,i+4,false);
      cell1.DoClearCell(9,i+4,1);
      cell1.DoSetCellReadOnly(9,i+4,true);
      cell1.DoSetCellReadOnly(10,i+4,false);
      cell1.DoClearCell(10,i+4,1);
      cell1.DoSetCellReadOnly(10,i+4,true);
    end;
  cell1.DoRedrawAll;
  with datamodule1 do
  begin
    if ADOQry.Active= true then ADOQry.close;
    ADOQry.sql.Clear;
    Adoqry.SQL.Add('select lymc=b.mc,lh=substring(b.lybh,4,2),dyh=(case substring(zfbh,6,1) when ''0'' then '''' else substring(zfbh,6,1) end),fjh=substring(zfbh,7,4),cs=substring(zfbh,7,2),ytmc= c.mc,'+
                   'jss=(case d.mc when ''一居室'' then ''1'' when ''二居室'' then ''2'' when ''三居室'' then ''3'' when ''复式二居室'' then ''复2'' when ''复式三居室'' then ''复3'' else ''''  end),area,cost '+#10+
                   'from zfxxb a, lyxxb b,fwytb c,fwhxb d '+#10+
                   'where a.lybh= b.lybh and a.hxbh=d.bh and a.ytbh=c.bh and dwbh=:dwbh ');
    Adoqry.Parameters.ParamByName('dwbh').Value:=dw;
    ADOQry.open;
    ADOQry.First;
    if ADOQry.RecordCount >= 1 then
      PagS:= ceil( ADOQry.RecordCount / 20)
    else
      pags:=1;
    PagN:= 1 ;
    cell1.DoSetCellString(6,3,inttostr(ADOQry.RecordCount));
    cell1.DoSetCellString(8,3,DateToStr(Date));
   // for i:=length(DateToStr(Date)) downto length(DateToStr(Date))-2 do
    //if copy(DateToStr(Date),i,1)='-' then
    //  cell1.DoSetCellString(8,3,copy(DateToStr(Date),1,4)+'年'+copy(DateToStr(Date),6,i-6)+'月'+
    //                       copy(DateToStr(Date),c+1,length(DateToStr(Date))-i)+' 日');
    cell1.DoSetCellString(0,2,'第 '+inttostr(PagN)+' 页');
    if PagS >= 2 then button8.Enabled:=true;
    cell1.DoSetPrintRange(0,8,0,31);
    i:= 1;
    while not ADOQry.Eof do
      begin
        Cell1.DoSetCellString(0,i+4,inttostr(i));
        Cell1.DoSetCellString(1,i+4,trim(Adoqry.fieldbyname('lymc').AsString));
        //Cell1.DoSetCellString(3,i+4,inttostr(Adoqry.fieldbyname('lh').AsInteger));
        Cell1.DoSetCellString(4,i+4,Adoqry.fieldbyname('dyh').AsString);
        Cell1.DoSetCellString(5,i+4,Adoqry.fieldbyname('fjh').AsString);
        Cell1.DoSetCellString(6,i+4,inttostr(Adoqry.fieldbyname('cs').AsInteger));
        Cell1.DoSetCellString(7,i+4,Adoqry.fieldbyname('jss').AsString);
        if trim(Adoqry.fieldbyname('area').AsString)<>'0' then
          Cell1.DoSetCellString(8,i+4,Adoqry.fieldbyname('area').AsString);
        if trim(Adoqry.fieldbyname('cost').AsString)<>'0' then
          Cell1.DoSetCellString(9,i+4,Adoqry.fieldbyname('cost').AsString);
        Cell1.DoSetCellString(10,i+4,trim(Adoqry.fieldbyname('ytmc').AsString));
        if i = 20 then exit;
        ADOQry.Next;
        if not ADOQry.Eof then
          i:=i+1;
      end;
    //ADOQry.Close;
    cell1.DoRedrawAll;
  end;
end;

procedure TFormFPTZSDY.Button3Click(Sender: TObject);
begin
   cell1.DoPrintPageSetup;
end;

procedure TFormFPTZSDY.Button4Click(Sender: TObject);
begin
  cell1.DoPrintPreview(true);
end;

procedure TFormFPTZSDY.Button5Click(Sender: TObject);
begin
  cell1.DoPrint(false);
end;

procedure TFormFPTZSDY.Button8Click(Sender: TObject);
var
  i:smallint;
begin
  if PagS <> PagN then
    begin
      PagN:= PagN + 1;
      button9.Enabled:=true;
      if PagN= PagS then
        button8.Enabled:=false;
    end
  else
    button8.Enabled:=false;

  cell1.DoSetCellString(0,2,'第 '+inttostr(PagN)+' 页');
  for i:=1 to 20 do
    begin
      cell1.DoSetCellReadOnly(0,i+4,false);
      cell1.DoClearCell(0,i+4,1);
      cell1.DoSetCellReadOnly(0,i+4,true);
      cell1.DoSetCellReadOnly(1,i+4,false);
      cell1.DoClearCell(1,i+4,1);
      cell1.DoSetCellReadOnly(1,i+4,true);
     // cell1.DoSetCellReadOnly(2,i+4,false);
      //cell1.DoClearCell(2,i+4,1);
      //cell1.DoSetCellReadOnly(2,i+4,true);
      cell1.DoSetCellReadOnly(3,i+4,false);
      cell1.DoClearCell(3,i+4,1);
      cell1.DoSetCellReadOnly(3,i+4,true);
      cell1.DoSetCellReadOnly(4,i+4,false);
      cell1.DoClearCell(4,i+4,1);
      cell1.DoSetCellReadOnly(4,i+4,true);
      cell1.DoSetCellReadOnly(5,i+4,false);
      cell1.DoClearCell(5,i+4,1);
      cell1.DoSetCellReadOnly(5,i+4,true);
      cell1.DoSetCellReadOnly(6,i+4,false);
      cell1.DoClearCell(6,i+4,1);
      cell1.DoSetCellReadOnly(6,i+4,true);
      cell1.DoSetCellReadOnly(7,i+4,false);
      cell1.DoClearCell(7,i+4,1);
      cell1.DoSetCellReadOnly(7,i+4,true);
      cell1.DoSetCellReadOnly(8,i+4,false);
      cell1.DoClearCell(8,i+4,1);
      cell1.DoSetCellReadOnly(8,i+4,true);
      cell1.DoSetCellReadOnly(9,i+4,false);
      cell1.DoClearCell(9,i+4,1);
      cell1.DoSetCellReadOnly(9,i+4,true);
      cell1.DoSetCellReadOnly(10,i+4,false);
      cell1.DoClearCell(10,i+4,1);
      cell1.DoSetCellReadOnly(10,i+4,true);

    end;
  cell1.DoRedrawAll;
  with datamodule1 do
  begin
    ADOQry.First;
    i:=1;
    while not ADOQry.Eof do
      begin
        if (i > (PagN-1)*20) and (i<= PagN* 20) then
         begin
           Cell1.DoSetCellString(0,i-(PagN-1)*20+4,inttostr(i));
           Cell1.DoSetCellString(1,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('lymc').AsString));
           //Cell1.DoSetCellString(3,i-(PagN-1)*20+4,inttostr(Adoqry.fieldbyname('lh').AsInteger));
           Cell1.DoSetCellString(5,i-(PagN-1)*20+4,Adoqry.fieldbyname('fjh').AsString);
           Cell1.DoSetCellString(6,i-(PagN-1)*20+4,inttostr(Adoqry.fieldbyname('cs').AsInteger));
           Cell1.DoSetCellString(7,i-(PagN-1)*20+4,Adoqry.fieldbyname('jss').AsString);
           if trim(Adoqry.fieldbyname('area').AsString)<>'0' then
             Cell1.DoSetCellString(8,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('area').AsString));
           if trim(Adoqry.fieldbyname('cost').AsString)<>'0' then
             Cell1.DoSetCellString(9,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('cost').AsString));
           Cell1.DoSetCellString(10,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('ytmc').AsString));
         end;
        ADOQry.Next;
        if not ADOQry.Eof then
          i:=i+1;
      end;
  end;
  cell1.DoRedrawAll;
end;

procedure TFormFPTZSDY.Button9Click(Sender: TObject);
var
  i:smallint;
begin
  if PagN > 1  then
    begin
      PagN:= PagN - 1;
      button8.Enabled:=true;
      if PagN= 1 then
        button9.Enabled:=false;
    end
  else
    button9.Enabled:=false;
 { cell1.DoSetCellReadOnly(0,i+4,false);
  cell1.DoClearCell(0,i+4,1);
  cell1.DoSetCellReadOnly(0,i+4,true);       }
  cell1.DoSetCellString(0,2,'第 '+inttostr(PagN)+' 页');
  for i:=1 to 20 do
    begin
      cell1.DoSetCellReadOnly(0,i+4,false);
      cell1.DoClearCell(0,i+4,1);
      cell1.DoSetCellReadOnly(0,i+4,true);
      cell1.DoSetCellReadOnly(1,i+4,false);
      cell1.DoClearCell(1,i+4,1);
      cell1.DoSetCellReadOnly(1,i+4,true);
     // cell1.DoSetCellReadOnly(2,i+4,false);
      //cell1.DoClearCell(2,i+4,1);
      //cell1.DoSetCellReadOnly(2,i+4,true);
      cell1.DoSetCellReadOnly(3,i+4,false);
      cell1.DoClearCell(3,i+4,1);
      cell1.DoSetCellReadOnly(3,i+4,true);
      cell1.DoSetCellReadOnly(4,i+4,false);
      cell1.DoClearCell(4,i+4,1);
      cell1.DoSetCellReadOnly(4,i+4,true);
      cell1.DoSetCellReadOnly(5,i+4,false);
      cell1.DoClearCell(5,i+4,1);
      cell1.DoSetCellReadOnly(5,i+4,true);
      cell1.DoSetCellReadOnly(6,i+4,false);
      cell1.DoClearCell(6,i+4,1);
      cell1.DoSetCellReadOnly(6,i+4,true);
      cell1.DoSetCellReadOnly(7,i+4,false);
      cell1.DoClearCell(7,i+4,1);
      cell1.DoSetCellReadOnly(7,i+4,true);
      cell1.DoSetCellReadOnly(8,i+4,false);
      cell1.DoClearCell(8,i+4,1);
      cell1.DoSetCellReadOnly(8,i+4,true);
      cell1.DoSetCellReadOnly(9,i+4,false);
      cell1.DoClearCell(9,i+4,1);
      cell1.DoSetCellReadOnly(9,i+4,true);
      cell1.DoSetCellReadOnly(10,i+4,false);
      cell1.DoClearCell(10,i+4,1);
      cell1.DoSetCellReadOnly(10,i+4,true);
    end;
  cell1.DoRedrawAll;
  with datamodule1 do
  begin
    ADOQry.First;
    i:=1;
    while not ADOQry.Eof do
      begin
        if (i > (PagN-1)*20) and (i<= PagN* 20) then
         begin
           Cell1.DoSetCellString(0,i-(PagN-1)*20+4,inttostr(i));
           Cell1.DoSetCellString(1,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('lymc').AsString));
           //Cell1.DoSetCellString(3,i-(PagN-1)*20+4,inttostr(Adoqry.fieldbyname('lh').AsInteger));
           Cell1.DoSetCellString(5,i-(PagN-1)*20+4,Adoqry.fieldbyname('fjh').AsString);
           Cell1.DoSetCellString(6,i-(PagN-1)*20+4,inttostr(Adoqry.fieldbyname('cs').AsInteger));
           Cell1.DoSetCellString(7,i-(PagN-1)*20+4,Adoqry.fieldbyname('jss').AsString);
           if trim(Adoqry.fieldbyname('area').AsString)<>'0' then
             Cell1.DoSetCellString(8,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('area').AsString));
           if trim(Adoqry.fieldbyname('cost').AsString)<>'0' then
             Cell1.DoSetCellString(9,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('cost').AsString));
           Cell1.DoSetCellString(10,i-(PagN-1)*20+4,trim(Adoqry.fieldbyname('ytmc').AsString));
         end;
        ADOQry.Next;
        if not ADOQry.Eof then
          i:=i+1;
      end;
  end;
  cell1.DoRedrawAll;
end;

procedure TFormFPTZSDY.ComboBox1Change(Sender: TObject);
begin
  button8.Enabled:=false;
  button9.Enabled:=false;
end;

procedure TFormFPTZSDY.Button7Click(Sender: TObject);
begin
  cell1.DoSetCellReadOnly(9,2,false);
  cell1.DoSetCellReadOnly(1,29,false);
  cell1.DoSetCellReadOnly(6,28,false);
  cell1.DoSetCellReadOnly(6,29,false);
  cell1.DoSetCellReadOnly(1,25,false);
  cell1.DoSetCellReadOnly(6,25,false);
  cell1.DoSetCellReadOnly(1,30,false);
  cell1.DoSetCellReadOnly(1,31,false);
  cell1.DoRedrawAll;
end;

end.

⌨️ 快捷键说明

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