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

📄 inv_opmaterialsum_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Inv_OpMaterialSum_D;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  StdCtrls, ExtCtrls, ComCtrls, ToolWin, jpeg;

Type
  TFrm_Inv_OpMaterialSum_D = Class(TFrm_Base_Qry)
    procedure TlBtn_PrintClick(Sender: TObject);
    procedure DBGridEhTitleBtnClick(Sender: TObject; ACol: Integer;
      Column: TColumnEh);
  private
    { Private declarations }
    flagTrue:boolean;
  public
    { Public declarations }
    tmPMonth:string;
    procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
  end;

var
  Frm_Inv_OpMaterialSum_D: TFrm_Inv_OpMaterialSum_D;

implementation

{$R *.DFM}
procedure TFrm_Inv_OpMaterialSum_D.InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);
var
  priorMonth:string;
begin
  AdoQry_tmp.Connection:=AdOConnection;
  AdoQry_Main.Connection:=AdOConnection;
  priorMonth:=FormatDateTime('yyyy.mm',incMonth(strtodate(tmPMonth+'.01'),-1));
  flagTrue:=False;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='drop table #aa ';
    try
      ExecSQL;
    except
    end;
  end;
  with AdoQry_Main do
  begin
    Close;
    sql.text:='create table #aa (flag int,VendorCode varchAr(8),VendorName varchAr(100)) '+
              'insert #aa(flag,VendorCode,VendorName) '+
              'select distinct 0,InvInBill.VendorCode,Vendor.VendorName from InvInBill '+
              'join Vendor on Vendor.VendorCode=InvInBill.VendorCode '+
              'where InvInBill.InvBillMonth='+QuotedStr(tmPMonth)+
              ' and (InvInBill.BillTypeCode=''0103'' or opBill=1) '+
              ' Order by InvInBill.VendorCode '+
              'insert #aa(flag,VendorCode,VendorName) '+
              'select distinct 0,OpMonthSum.VendorCode,Vendor.VendorName from OpMonthSum '+
              'join Vendor on Vendor.VendorCode=OpMonthSum.VendorCode '+
              'where OpMonthSum.InvMonth='+QuotedStr(priorMonth)+
              ' and (InvblncAmount<>0 or Invblncqty<>0) and OpMonthSum.VendorCode '+
              ' not in (select VendorCode from #aa) '+
              'select distinct flag,VendorCode,VendorName from #aa ';
    open;
  end;
end;

procedure TFrm_Inv_OpMaterialSum_D.TlBtn_PrintClick(Sender: TObject);
begin
  if AdoQry_Main.State<>dsbrowse then
     AdoQry_Main.Post;
  with AdoQry_Main do
  begin
    DisableControls;
    First;
    while not eof do
    begin
      if fieldbyname('flag').AsInteger=1 then
      begin
        AdoQry_tmp.Close;
        AdoQry_tmp.sql.text:='update #aa set flag=1 '+
                             ' where VendorCode='+QuotedStr(fieldbyname('VendorCode').asstring);
        AdoQry_tmp.ExecSQL;
      end;
      next;
    end;
  end;
  ModalResult:=mrok;
end;

procedure TFrm_Inv_OpMaterialSum_D.DBGridEhTitleBtnClick(Sender: TObject;
  ACol: Integer; Column: TColumnEh);
begin
  with AdoQry_Main do
  begin
    DisableControls;
    First;
    if not flagTrue then
    begin
      while not eof do
      begin
        edit;
        fieldbyname('flag').AsInteger:=1;
        post;
        next;
      end;
    end
    else
    begin
      while not eof do
      begin
        edit;
        fieldbyname('flag').AsInteger:=0;
        post;
        next;
      end;
    end;
    First;
    EnableControls;
    flagTrue:=not flagTrue;
  end;
end;

end.

⌨️ 快捷键说明

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