bas_batch_h.pas

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

PAS
128
字号
unit Bas_Batch_H;

Interface

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

Type
  TFrm_Bas_Batch_H = Class(TFrm_Base_Entry_Head)
    AdoQry_HeadItemCode: TStringField;
    AdoQry_HeadBackflush: TIntegerField;
    AdoQry_HeadBatchremArk: TStringField;
    AdoQry_HeadItemName: TStringField;
    AdoQry_HeadUomName: TStringField;
    AdoQry_HeadBatchid: TAutoIncField;
    AdoQry_HeadBackflush1: TStringField;
    procedure Act_FilterExecute(Sender: TObject);
    procedure Act_DeleteExecute(Sender: TObject);
    procedure Act_NewExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
  end;

var
  Frm_Bas_Batch_H: TFrm_Bas_Batch_H;

implementation

uses Bas_Batch_B,Sys_Global;

{$R *.DFM}

{ TFrm_Pm_Pc_Entry_H }

procedure TFrm_Bas_Batch_H.InitForm(AdOConnection: TAdOConnection;
  ReadOnly: Boolean);
begin
  if ReadOnly then
  begin
    Caption:='批次主文件查询';
    Pnl_Title.Caption:='批次主文件查询';
  end
  else
  begin
    Caption:='批次主文件维护';
    Pnl_Title.Caption:='批次主文件维护';
  end;
  inherited;
  SelectFromSQL:='select Batch.Batchid,Batch.ItemCode,case Batch.Backflush when 1 then '''+'是'+''' else '''+'否'+''' end Backflush1 '+
              ',Batch.BatchremArk,Batch.Backflush,'+
              'Item.ItemName,Uom.UomName'+
              ' from Batch join Item  on Batch.ItemCode=Item.ItemCode '+
              'join Uom on Item.UomCode=Uom.UomCode';
  OrderByFields:='ItemCode';
  GetData;
  Frm_Entry_Body:=TFrm_Bas_Batch_B.Create(Self);
end;

procedure TFrm_Bas_Batch_H.Act_FilterExecute(Sender: TObject);
var
  i:integer;
begin
  for i:=0 to dbgrideh.Columns.Count-1 do
  begin
    if dbgrideh.Columns[i].FieldName='ItemName' then
      dbgrideh.Columns[i].Field.Origin:='Item'
    else if dbgrideh.Columns[i].FieldName='UomName' then
      dbgrideh.Columns[i].Field.Origin:='Uom'
    else
      dbgrideh.Columns[i].Field.Origin:='Batch'
  end;
  inherited;
  lbl_Conditiontitle.Visible :=True;
  lbl_Condition.Visible :=True;
end;

procedure TFrm_Bas_Batch_H.Act_DeleteExecute(Sender: TObject);
var
  aa:string;
begin
  if AdoQry_Head.RecordCount=0 then
     exit;
  aa:=AdoQry_Head.fieldbyname('Batchid').asstring;
  if aa='' then
  begin
    AdoQry_Head.Delete ;
    exit;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.Text :='select * from Batchline where Batchid='+aa+'';
    open;
    if not eof then
    begin
      DispInfo('该物料还存在批次定义,不能删除。',3);
      abort;
    end
    else
    begin
      AdoQry_Head.Delete ;
      Close;
      sql.text:='delete from Batch where Batchid='+aa+'';
      execsql;
    end;
  end;
end;

procedure TFrm_Bas_Batch_H.Act_NewExecute(Sender: TObject);
var
  ItemCodes:string;
begin
  inherited;
{  ItemCodes:=Frm_Bas_Batch_B.ExtEdt_ItemCode.Text;
  AdoQry_Head.DisableControls ;
  AdoQry_Head.Close;
  AdoQry_Head.Open;
  AdoQry_Head.Locate('ItemCode',ItemCodes,[]);
  AdoQry_Head.EnableControls ;   }
end;

end.

⌨️ 快捷键说明

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