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

📄 pm_enter_newfreepoh.pas

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

Interface

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

Type
  TFrm_Pm_Enter_NewFreePoH = Class(TFrm_Base_Entry_Head)
    AdoQry_HeadPONO: TStringField;
    AdoQry_HeadVendorCode: TStringField;
    AdoQry_HeadPOType: TIntegerField;
    AdoQry_HeadPODate: TDateTimeField;
    AdoQry_HeadPOTAXRATE_PERCENT: TIntegerField;
    AdoQry_HeadCURRENCYCode: TStringField;
    AdoQry_HeadEmployeeCode: TStringField;
    AdoQry_HeadPORemArk: TStringField;
    AdoQry_HeadPoSpecial: TIntegerField;
    AdoQry_HeadPcNo: TStringField;
    AdoQry_HeadVendorName: TStringField;
    AdoQry_HeadCurrencyName: TStringField;
    AdoQry_HeadEmployeeName: TStringField;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    Label1: TLabel;
    DBText1: TDBText;
    Label3: TLabel;
    DBText2: TDBText;
    Label5: TLabel;
    Lbl_VendorFlag: TLabel;
    AdoQry_HeadCreateEmpolyeeCode: TStringField;
    procedure FormDestroy(Sender: TObject);
    procedure DataSourceDataChange(Sender: TObject; Field: TField);
    procedure Act_DeleteExecute(Sender: TObject);
  private
    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
    { Public declarations }
  end;

var
  Frm_Pm_Enter_NewFreePoH: TFrm_Pm_Enter_NewFreePoH;

implementation

uses Pm_Enter_NewFreePo, Sys_Global;



{$R *.DFM}

procedure TFrm_Pm_Enter_NewFreePoH.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Pm_Enter_NewFreePoH:=Nil;
end;


procedure TFrm_Pm_Enter_NewFreePoH.InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);
begin
  Application.ProcessMessages;
  Inherited;
  FreeFields:='POTAXRATE_PERCENT,';
  If (ReadOnly) Then
  begin
    Pnl_Title.Caption:='独立采购订单查询';
    Frm_Pm_Enter_NewFreePoH.Caption:='独立采购订单查询';
    Act_New.Enabled:=False;
    Act_New.Visible:=False;
    Act_Modify.Enabled:=False;
    Act_Modify.Visible:=False;
  end
  Else
  begin
    Pnl_Title.Caption:='独立采购订单准备';
    Frm_Pm_Enter_NewFreePoH.Caption:='独立采购订单准备';
  end;
  Application.ProcessMessages;
  SelectFromSql:=' Select Po.*,Vendor.VendorName,Currency. CurrencyName, Employee.EmployeeName '
                +' From Po '
                +' Join Currency On Po.CurrencyCode= Currency. CurrencyCode '
                +' Left Join Employee On Po.EmployeeCode= Employee.EmployeeCode '
                +' Left Join Vendor On Po.VendorCode=Vendor.VendorCode ';
  ConditionUserDefine:=' (Po.PoSpecial=1) ' ;

  Condition:=' Exists (Select PoNo From PoLine where PoLine.PoNo=Po.PoNo'
            +' And PoLine.PoLineStatus in (5) )';
  OrderByFields:='PoNo,PcNo,EmployeeCode';
  GetData;
  Frm_Entry_Body:=TFrm_Pm_Enter_NewFreePo.Create(Application);
end;

procedure TFrm_Pm_Enter_NewFreePoH.DataSourceDataChange(Sender: TObject;
  Field: TField);
begin
  inherited;
  Lbl_VendorFlag.Caption:=AdoQry_Head.fieldbyname('VendorCode').AsString+' '+AdoQry_Head.fieldbyname('VendorName').AsString;
end;

procedure TFrm_Pm_Enter_NewFreePoH.Act_DeleteExecute(Sender: TObject);
var
  SqlText:String;
  AdoQuery:TAdoQuery;
begin
  inherited;
  if (not AdoQry_Head.IsEmpty)and
     (DispInfo(' 真的删除当前记录吗? ',2)='y') then
  begin
    SqlText:=' Select * From Po where '
            +' PoNo not in ( Select Distinct PoNo from  PoLine where (PoLineStatus<>5))'
            +' And  PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+'''';
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text :=SqlText;
    AdoQry_Tmp.Open;
    if  not AdoQry_Tmp.Eof then
    begin
      AdoQuery:=TAdoQuery.Create(nil);
      AdoQuery.Connection := DbConnect;
      DbConnect.beginTrans;
      try
        Sqltext:='Select * From PoLine where  PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+'''';
        AdoQuery.Close;
        AdoQuery.SQL.clear;
        AdoQuery.SQL.Text:=SqlText;
        AdoQuery.Open ;
        AdoQuery.First;
        While not AdoQuery.Eof do
        begin
          SavePoLineHistory(Dbconnect ,AdoQuery.fieldbyname('PoNo').AssTring,AdoQuery.fieldbyname('PoLineNo').AsInteger,userCode,2);
          AdoQuery.Next;
        end;


        Sqltext:='Delete PoLine where  PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+'''';
        ExecuteSql(AdoQry_Tmp,SqlText,1);

        SavePoHistory(DbConnect,AdoQry_Head.fieldbyname('PoNo').AsString,userCode,2);
        Sqltext:='Delete Po where  PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+'''';
        ExecuteSql(AdoQry_Tmp,SqlText,1);
        AdoQry_Head.Delete;
        DbConnect.CommitTrans;
      except
        DbConnect.RollBackTrans;
      end;
    end
    else
    begin
      DispInfo('有采购订单行记录处于非准备状态,不能删除',3);
      Abort;
    end;
  end;  
end;


end.

⌨️ 快捷键说明

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