dwyjhzfrm.pas

来自「本人编写的有关军队营房工作的管理系统」· PAS 代码 · 共 143 行

PAS
143
字号
unit dwyjhzfrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, db,dbtables,Grids, DBGridEh, Buttons, StdCtrls,
  te_controls,ksthemeedits, PrnDbgeh;

type
  Tdwyjhz = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    DBGridEh1: TDBGridEh;
    SpeedButton3: TSpeedButton;
    SpeedButton1: TSpeedButton;
    TeThemeEdit1: TTeThemeEdit;
    CheckBox1: TCheckBox;
    PrintDBGridEh1: TPrintDBGridEh;
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dwyjhz: Tdwyjhz;

implementation
uses datafrm;
{$R *.dfm}

procedure Tdwyjhz.SpeedButton3Click(Sender: TObject);
begin
close;
end;

procedure Tdwyjhz.FormShow(Sender: TObject);
var
  i:integer;
begin
yfgldata.yjtemp.Active:=false;
dwyjhz.DBGridEh1.Columns.Clear;
dwyjhz.DBGridEh1.SumList.Active:=false;
with yfgldata.yjtemp do
  begin
    with fielddefs do
      begin
        clear;
        with addfielddef do
          begin
            name:='单位代码';
            datatype:=ftstring;
            size:=20;
          end;
        dwyjhz.DBGridEh1.Columns.Add;
        dwyjhz.DBGridEh1.Columns[0].FieldName:='单位代码';
        dwyjhz.DBGridEh1.Columns[0].Title.caption:='单位代码';
        with addfielddef do
          begin
            name:='单位名称';
            datatype:=ftstring;
            size:=50;
          end;
        dwyjhz.DBGridEh1.Columns.Add;
        dwyjhz.DBGridEh1.Columns[1].FieldName:='单位名称';
        dwyjhz.DBGridEh1.Columns[1].Title.caption:='单位名称';
        dwyjhz.DBGridEh1.Columns[1].Footers.add;
        dwyjhz.DBGridEh1.Columns[1].Footers[0].FieldName:='单位名称';
        dwyjhz.DBGridEh1.Columns[1].Footers[0].Value:='总      计';
        dwyjhz.DBGridEh1.Columns[1].Footers[0].Alignment:=tacenter;
        dwyjhz.DBGridEh1.Columns[1].Footers[0].ValueType:=fvtstatictext;
        yfgldata.yjzl.First;
        for i:=1 to yfgldata.yjzl.RecordCount do
        begin
          with addfielddef do
           begin
             name:=yfgldata.yjzl.fieldbyname('营具代码').AsString;
             datatype:=ftinteger;
           end;
          dwyjhz.DBGridEh1.Columns.Add;
          dwyjhz.DBGridEh1.Columns[i+1].FieldName:=yfgldata.yjzl.fieldbyname('营具代码').AsString;
          dwyjhz.DBGridEh1.Columns[i+1].Title.caption:=yfgldata.yjzl.fieldbyname('营具名称').AsString+'||'+yfgldata.yjzl.fieldbyname('单位').AsString;
          dwyjhz.DBGridEh1.Columns[i+1].Footers.add;
          dwyjhz.DBGridEh1.Columns[i+1].Footers[0].FieldName:=yfgldata.yjzl.fieldbyname('营具代码').AsString;
          dwyjhz.DBGridEh1.Columns[i+1].Footers[0].Alignment:=tarightjustify;
          dwyjhz.DBGridEh1.Columns[i+1].Footers[0].ValueType:=fvtsum;
          yfgldata.yjzl.Next;
        end;
      end;
    createtable;
    active:=true; 
  end;
yfgldata.dw.First;
for i:=1 to yfgldata.dw.RecordCount do
  begin
    if yfgldata.dw.FieldByName('上级代码').AsString<>'' then
      begin
        yfgldata.yjtemp.Append;
        yfgldata.yjtemp.FieldByName('单位代码').AsString:=yfgldata.dw.FieldByName('单位代码').AsString;
        yfgldata.yjtemp.FieldByName('单位名称').AsString:=yfgldata.dw.FieldByName('单位名称').AsString;
        yfgldata.yjtemp.Post;
      end;
    yfgldata.dw.Next;
  end;
yfgldata.dwyj1.First;
for i:=1 to yfgldata.dwyj1.RecordCount do
  begin
    if yfgldata.yjtemp.Locate('单位代码',yfgldata.dwyj1.fieldbyname('使用单位').AsString,[loCaseInsensitive]) then
      begin
        yfgldata.yjtemp.Edit;
        yfgldata.yjtemp.FieldByName(yfgldata.dwyj1.fieldbyname('代码').AsString).AsInteger:=yfgldata.dwyj1.fieldbyname('数量').AsInteger;
        yfgldata.yjtemp.Post;
      end;
    yfgldata.dwyj1.Next;
  end;
dwyjhz.DBGridEh1.FrozenCols:=2;
dwyjhz.DBGridEh1.SumList.Active:=true;
end;

procedure Tdwyjhz.CheckBox1Click(Sender: TObject);
begin
dwyjhz.DBGridEh1.Columns[0].Visible:=dwyjhz.CheckBox1.Checked;
end;

procedure Tdwyjhz.SpeedButton1Click(Sender: TObject);
begin
if dwyjhz.TeThemeEdit1.Text<>'' then
  begin
    dwyjhz.PrintDBGridEh1.PageHeader.CenterText.Clear;
    dwyjhz.PrintDBGridEh1.PageHeader.CenterText.Add(dwyjhz.TeThemeEdit1.Text);
    dwyjhz.PrintDBGridEh1.Preview;
  end
else
  messagebox(dwyjhz.handle,'请在报表上侧输入报表标题。','营房工作管理系统',16);
end;

end.

⌨️ 快捷键说明

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