ad_qry_depreciationdept_c.pas

来自「一个MRPII系统源代码版本」· PAS 代码 · 共 112 行

PAS
112
字号
unit Ad_Qry_DepreciationDept_C;


Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Condition, Db, AdODB, StdCtrls, ExtEdit, Mask, linkedit;

Type
  TFrm_Ad_Qry_DepreciationDept_C = Class(TFrm_Base_Condition)
    Lbl_VendorName: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Medt_Month_Fm: TMaskEdit;
    Lbl_Operator_Name_Fm: TLabel;
    Lbl_Operator_Name_To: TLabel;
    ExtEdt_DeptCode_Fm: TLinkEdit;
    ExtEdt_DeptCode_To: TLinkEdit;
    Edt_DeptName_Fm: TEdit;
    Edt_DeptName_to: TEdit;
    Medt_Month_To: TMaskEdit;
    Label1: TLabel;
    procedure btn_okClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ExtEdt_DeptCode_ToExit(Sender: TObject);
    procedure ExtEdt_DeptCode_FmExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Ad_Qry_DepreciationDept_C: TFrm_Ad_Qry_DepreciationDept_C;

implementation
uses Ad_Qry_DepreciationDept,Sys_Global;

{$R *.DFM}

procedure TFrm_Ad_Qry_DepreciationDept_C.btn_okClick(Sender: TObject);
var
  sqltext:String;
begin
  inherited;
  sqltext:='select Ad_Depreciation_Dept.DeptCode,Dept.DeptName,Ad_Depreciation_Dept.DeptCode+'' ''+Dept.DeptName DeptFlag '+
        ',Ad_Depreciation_Dept.AssetCode,Ad_AssetCard.AssetName,Ad_Depreciation_Dept.AssetCode+'' ''+Ad_AssetCard.AssetName AssetFlag '+
        ',Ad_Depreciation_Dept.DepreciationMonth,Sum(Depreciation) SumDepreciation '+
        ' ,Sum(Depreciation)/ '+
        '(Select Sum(Depreciation) from Ad_Depreciation_Dept '+
        ' Where DepreciationMonth Between '''+Medt_Month_Fm.Text+''' And '''+Medt_Month_To.Text+''' '+
        ' And DeptCode Between '''+ExtEdt_DeptCode_Fm.Text+''' And '''+ExtEdt_DeptCode_To.Text+''' )*100 SDepreciation '+
        ' from Ad_Depreciation_Dept,Dept,Ad_AssetCard '+
        ' Where DepreciationMonth Between '''+Medt_Month_Fm.Text+''' And '''+Medt_Month_To.Text+''' '+
        ' And Ad_Depreciation_Dept.DeptCode Between '''+ExtEdt_DeptCode_Fm.Text+''' And '''+ExtEdt_DeptCode_To.Text+''' '+
        ' And Ad_Depreciation_Dept.DeptCode=Dept.DeptCode '+
        ' And Ad_Depreciation_Dept.AssetCode=Ad_AssetCard.AssetCode '+
        ' Group By Ad_Depreciation_Dept.DeptCode,Dept.DeptName,Ad_Depreciation_Dept.AssetCode,Ad_AssetCard.AssetName,Ad_Depreciation_Dept.DepreciationMonth ';
  with  Frm_Ad_Qry_DepreciationDept.AdoQry_Main do
  begin
    Close;
    sql.clear;
    sql.Add(sqltext);
    open;
  end;
  ConditionHint:='计旧月份从 '+Medt_Month_Fm.Text+' 到 '+Medt_Month_To.Text+' 部门代码从 '+ExtEdt_DeptCode_Fm.Text+'到'+ExtEdt_DeptCode_To.Text;
  self.ModalResult:=mrOk;
  ModalResult:=mrOk;
end;

procedure TFrm_Ad_Qry_DepreciationDept_C.FormCreate(Sender: TObject);
begin
  inherited;
  ExtEdt_DeptCode_Fm.Text:='';
  ExtEdt_DeptCode_To.Text:='ZZZZZ';
  Medt_Month_Fm.Text:=formatdatetime('yyyy.mm',now);
  Medt_Month_To.Text:=formatdatetime('yyyy.mm',now);
end;

procedure TFrm_Ad_Qry_DepreciationDept_C.ExtEdt_DeptCode_ToExit(Sender: TObject);
begin
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := ' Select DeptName,DeptCode From Dept '
                        +'   Where  DeptCode = '''+ExtEdt_DeptCode_To.Text +''' ';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.Eof Then
  begin
    Edt_DeptName_to.Text :='';
  end Else
     Edt_DeptName_to.Text := AdoQry_Tmp.fieldbyname('DeptName').AsString;
end;

procedure TFrm_Ad_Qry_DepreciationDept_C.ExtEdt_DeptCode_FmExit(Sender: TObject);
begin
  inherited;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := ' Select DeptName,DeptCode From Dept '
                        +'   Where  DeptCode = '''+ExtEdt_DeptCode_Fm.Text +''' ';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.Eof Then
  begin
    Edt_DeptName_Fm.Text :='';
  end Else
     Edt_DeptName_Fm.Text := AdoQry_Tmp.fieldbyname('DeptName').AsString;
end;

end.

⌨️ 快捷键说明

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