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

📄 ar_enter_eachinvoice_d.pas

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

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

Type
  TFrm_Ar_Enter_EachInvoice_D = Class(TFrm_Base_Entry_Detail)
    Edt_TotalAmount: TEdit;
    Label4: TLabel;
    Label3: TLabel;
    medt_ApInvoicedate: TMaskEdit;
    Label2: TLabel;
    Label1: TLabel;
    edt_reMainAmount: TEdit;
    Label5: TLabel;
    edt_thiSCancelAmount: TEdit;
    cmb_ApInvoiceno: TLinkEdit;
    Label6: TLabel;
    cmb_InvoiceType: TComboBox;
    procedure btn_okClick(Sender: TObject);
    procedure cmb_ApInvoicenoExit(Sender: TObject);
    procedure cmb_ApInvoicenoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure cmb_ApInvoicenoButtonClick(Sender: TObject);
  private
    UomName:String;  //记录当前单位
    MnldTime:Integer;//记录制造提前期
    runlt:integer;
    LineNo:Integer;//行号
    MoStArtWorkDate:String;//当前开工日期
    { Private declarations }
  public
    permitBackflush:integer;
    InvoiceType:integer;
    OrderType:integer;
    currencyCode:string;
    procedure InitControls; Override;
    procedure SaveBodyData; Override;
    procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
    function existSalterson(ItemCode:string):boolean;
  end;

var
  Frm_Ar_Enter_EachInvoice_D: TFrm_Ar_Enter_EachInvoice_D;

implementation

uses Sys_Global;

{$R *.DFM}



procedure TFrm_Ar_Enter_EachInvoice_D.InitControls;
var
  SqlText:String;
begin
  If (status='Add') Then
    SetFocus_Control:=cmb_InvoiceType
  Else
    begin
    SetFocus_Control:=edt_thiSCancelAmount;
    end;
  Inherited;
  with AdoQry_Body do
  begin
    cmb_InvoiceType.ItemIndex:=fieldbyname('InvoiceType').asinteger;
    cmb_ApInvoiceno.Text:=fieldbyname('Invoiceno').AsString;
    If (Status='Add') then
    begin
      Medt_ApInvoiceDate.Text:='';
      edt_TotalAmount.Text:='';
      edt_reMainAmount.Text:='';
      edt_thiSCancelAmount.Text:='0';
    end
    else
    begin
      cmb_InvoiceType.ItemIndex:=fieldbyname('InvoiceType').asinteger;
      Medt_ApInvoiceDate.Text:=FormatDateTime('yyyy.mm.dd',fieldbyname('BillDate').Asdatetime);
      edt_TotalAmount.Text:=floattostr(fieldbyname('TotalAmount').asfloat);
      edt_reMainAmount.Text:=floattostr(fieldbyname('reMainTotalAmount').asfloat);
      edt_thiSCancelAmount.Text:=floattostr(fieldbyname('thiSCancelAmount').asfloat);
    end;
  end;
end;


procedure TFrm_Ar_Enter_EachInvoice_D.SaveBodyData;
var tMpsqltext:string;
begin
  If Status='Add' Then
    AdoQry_Body.Append
  Else
    AdoQry_Body.Edit;
  with AdoQry_Body do
  begin
    fieldbyname('InvoiceType').asinteger:=cmb_InvoiceType.ItemIndex;
    fieldbyname('Invoiceno').AsString:=Trim(cmb_ApInvoiceno.Text);
    fieldbyname('BillDate').Asdatetime:=strtodatetime(Medt_ApInvoiceDate.Text);
    fieldbyname('TotalAmount').Asfloat:=strtofloat(edt_TotalAmount.text);
    
    fieldbyname('reMainTotalAmount').AsFloat:=StrtoFloat(Edt_reMainAmount.Text);
    fieldbyname('thiSCancelAmount').asfloat:=strtofloat(edt_thiSCancelAmount.text);
    Post;
  end;
end;

procedure TFrm_Ar_Enter_EachInvoice_D.SetStatus(CurrentStatus: String;
  var EnableControls: String);
begin
  inherited;
  if(CurrentStatus='Add')then
    EnableControls:='cmb_InvoiceType,cmb_ApInvoiceno,edt_thiSCancelAmount,'
  Else
    EnableControls:='edt_thiSCancelAmount,'
end;

procedure TFrm_Ar_Enter_EachInvoice_D.btn_okClick(Sender: TObject);
var
  I:String;
begin
  If (Status='Add') Then
  begin
    begin
    If AdoQry_Body.RecordCount>0 Then
      AdoQry_Body.First;
      While Not AdoQry_Body.Eof Do
      begin
        If (Trim(cmb_ApInvoiceno.Text)=Trim(AdoQry_Body.fieldbyname('Invoiceno').AsString)) then
          begin
            DispInfo('你不能输入两笔相同销售发票号的记录!',3);
            Btn_Ok.Enabled:=False;
            cmb_ApInvoiceno.SetFocus;
            Abort;
          end;
        AdoQry_Body.Next;
      end;  //end  while
    end;  //end if
  end;   //end (Add)
  inherited;
end;

function TFrm_Ar_Enter_EachInvoice_D.existSalterson(ItemCode: string): boolean;
var AdoQry:TAdoQuery;
    sqltext:string;
begin
   Result:=False;
   AdoQry:=TAdoQuery.Create(self);
   AdoQry.Connection:=dbconnect;
   sqltext:='select ItemCode from Bom where BomItemType=6 and ite_ItemCode='+quotedstr(ItemCode);
   try
     Executesql(AdoQry,sqltext,0);
     if AdoQry.RecordCount>0 then Result:=True;
   finally
    AdoQry.Free;
   end;
end;

procedure TFrm_Ar_Enter_EachInvoice_D.cmb_ApInvoicenoExit(Sender: TObject);
begin
  inherited;
  if activecontrol=btn_Cancel then  exit;
  if Tcombobox(sender).Itemindex=-1 then 
   begin
    DispInfo('请选择销售发票号!',3);
    cmb_ApInvoiceno.SetFocus;
    abort;
   end;
  Executesql(AdoQry_tmp,'select * from sa_SaleInvoice where Invoiceno='+quotedstr(Tcombobox(sender).text),0);
  medt_ApInvoicedate.Text:=formatdatetime('yyyy.mm.dd',AdoQry_tmp.fieldbyname('createdate').asdatetime);
  edt_TotalAmount.Text:=AdoQry_tmp.fieldbyname('TotaltaxAmount').asstring;
  edt_reMainAmount.Text:=floattostr(AdoQry_tmp.fieldbyname('TotaltaxAmount').asfloat-AdoQry_tmp.fieldbyname('CancelAmount').asfloat);
end;

procedure TFrm_Ar_Enter_EachInvoice_D.cmb_ApInvoicenoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
   If key=120 Then
  CommOnHint(Sender,AdoQry_Tmp,'createdate','发票日期',
         'Invoiceno','销售发票号','sa_SaleInvoice','TotaltaxAmount>isnull(CancelAmount,0)  and OrderType='+inttostr(cmb_InvoiceType.Itemindex)+' and currencyCode='+quotedstr(currencyCode));

end;

procedure TFrm_Ar_Enter_EachInvoice_D.cmb_ApInvoicenoButtonClick(
  Sender: TObject);
begin
  inherited;
  CommOnHint(Sender,AdoQry_Tmp,'createdate','发票日期',
         'Invoiceno','销售发票号','sa_SaleInvoice','TotaltaxAmount>isnull(CancelAmount,0)  and OrderType='+inttostr(cmb_InvoiceType.Itemindex)+' and currencyCode='+quotedstr(currencyCode));

end;

end.

⌨️ 快捷键说明

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