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

📄 ar_enter_saleinvoice1.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit Ar_Enter_SaleInvoice1;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Body, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  ExtCtrls, ComCtrls, ToolWin, StdCtrls, ExtEdit, Mask, linkedit, jpeg;

Type
  TFrm_Ar_Enter_SaleInvoice1 = Class(TFrm_Base_Entry_Body)
    Label1: TLabel;
    Label3: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    MEdt_CreateDate: TMaskEdit;
    Lab_CurrencyName: TLabel;
    Edt_TotalTaxAmount: TEdit;
    Label17: TLabel;
    Edt_CustomerName: TLabel;
    Lab_SaleTermName: TLabel;
    Edt_RemArk: TEdit;
    Label2: TLabel;
    Edt_InvoiceNo: TEdit;
    Edt_CreateEmployeeCode: TExtEdit;
    Label20: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edt_CustomerBank: TEdit;
    Edt_CustomerBankActNo: TEdit;
    Edt_ExchangeRate: TEdit;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    AdoQry_BodyInvoiceNo: TStringField;
    AdoQry_BodyShipNo: TStringField;
    AdoQry_BodyItemCode: TStringField;
    AdoQry_BodyShipQty: TFloatField;
    AdoQry_BodyTaxPrice: TFloatField;
    AdoQry_BodyTaxAmount: TFloatField;
    AdoQry_BodyDiSCountRate: TFloatField;
    AdoQry_BodyDiSCountAmount: TFloatField;
    AdoQry_BodyItemName: TStringField;
    AdoQry_BodyUomName: TStringField;
    AdoQry_BodyNoTaxPrice: TFloatField;
    AdoQry_BodyNoTaxAmount: TFloatField;
    edt_CustomerCode: TLinkEdit;
    edt_CurrencyCode: TLinkEdit;
    edt_SaletermCode: TLinkEdit;
    Label7: TLabel;
    edt_DeptCode: TLinkEdit;
    edt_DeptName: TEdit;
    Label9: TLabel;
    edt_SaleEmployeeCode: TLinkEdit;
    edt_SaleEmployeeName: TEdit;
    Label12: TLabel;
    edt_SaleTypeCode: TLinkEdit;
    edt_SaleTypeName: TEdit;
    Label13: TLabel;
    Edt_TotalNoTaxAmount: TEdit;
    Label16: TLabel;
    Edt_TaxRate: TEdit;
    AdoQry_BodyTaxPriceC: TFloatField;
    AdoQry_BodyTaxAmountC: TFloatField;
    AdoQry_BodyInvBillId: TFloatField;
    AdoQry_BodyShipLineNo: TStringField;
    Label18: TLabel;
    Edt_TotalTax: TEdit;
    Edt_CreateEmployeeName: TEdit;
    Label19: TLabel;
    Edt_ExportTypeCode: TLinkEdit;
    Edt_ExportTypeName: TEdit;
    MEdt_InAccountDate: TMaskEdit;
    Label21: TLabel;
    procedure Edt_SaleTermCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edt_SaleTermCodeExit(Sender: TObject);
    procedure AdoQry_BodyAfterPost(DataSet: TDataSet);
    procedure Act_DeleteLineExecute(Sender: TObject);
    procedure Act_PreviewExecute(Sender: TObject);
    procedure Act_PrintExecute(Sender: TObject);
    procedure Act_NewExecute(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Edt_CustomerCodeExit(Sender: TObject);
    procedure Edt_CurrencyCodeExit(Sender: TObject);
    procedure edt_SaletermCodeButtonClick(Sender: TObject);
    procedure edt_DeptCodeExit(Sender: TObject);
    procedure edt_SaleEmployeeCodeExit(Sender: TObject);
    procedure edt_SaleTypeCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edt_SaleTypeCodeButtonClick(Sender: TObject);
    procedure edt_SaleTypeCodeExit(Sender: TObject);
    procedure Act_SaveExecute(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Edt_ExportTypeCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edt_ExportTypeCodeButtonClick(Sender: TObject);
    procedure Edt_ExportTypeCodeExit(Sender: TObject);
    procedure MEdt_InAccountDateExit(Sender: TObject);
  private
    CurrentFormStatus:String;
    { Private declarations }
  public
//    TaxRate : Double;//销售税率
    TotalNoTaxAmount,TotalTaxAmount:double;
    procedure InitForm(AdOConnection:TAdOConnection;FormStatus:String;
      AdoQuery:TAdoQuery);Override;
    procedure InitControls; Override;
    procedure SetStatus(CurrentStatus:String;var AnswerStatus,EnableControls:String); Override;
    procedure SaveHeadData; Override;//把表头控件值写入缓存,不要Post
    procedure SaveData; Override;
    { Public declarations }
  end;

var
  Frm_Ar_Enter_SaleInvoice1: TFrm_Ar_Enter_SaleInvoice1;

implementation

uses  Sys_Global, Ar_Enter_SaleInvoice1_C1,
  Ar_Enter_SaleInvoice1H, Ar_Enter_SaleInvoice1_C;

{$R *.DFM}

{ TFrm_Sal_Enter_SaleInvoice }

procedure TFrm_Ar_Enter_SaleInvoice1.InitForm(AdOConnection: TAdOConnection;
  FormStatus: String; AdoQuery: TAdoQuery);
var
  SqlText,ShipNo:String;
//  tmpYear,tmPMonth:integer;
begin
  inherited;
  If FormStatus='Add' then
  begin
    CurrentFormStatus:='Add';
    Pnl_Title.Caption := IIfString(Param1='0','普通发票','出口发票');
    Pnl_Title.Refresh;
    Frm_Ar_Enter_SaleInvoice1.Caption := IIfString(Param1='0','普通发票','出口发票');
    MEdt_CreateDate.Text :=FormatDateTime('YYYY.MM.DD',Date());
    MEdt_InAccountDate.Text :=FormatDateTime('YYYY.MM.DD',Date());
    Edt_CustomerCode.Text :=Frm_Ar_Enter_SaleInvoice1_C1.CustomerCode;
    Edt_CustomerName.Caption :=Frm_Ar_Enter_SaleInvoice1_C1.CustomerName;
    edt_SaleTypeCode.Text:=Frm_Ar_Enter_SaleInvoice1_C1.SaleTypeCode;
    edt_SaleTypeName.Text:=Frm_Ar_Enter_SaleInvoice1_C1.SaleTypeName;
    edt_DeptCode.Text:=Frm_Ar_Enter_SaleInvoice1_C1.DeptCode;
    edt_DeptName.Text:=Frm_Ar_Enter_SaleInvoice1_C1.DeptName;
    edt_SaleEmployeeCode.Text:=Frm_Ar_Enter_SaleInvoice1_C1.SaleEmployeeCode;
    edt_SaleEmployeeName.Text:=Frm_Ar_Enter_SaleInvoice1_C1.SaleEmployeeName;    
//    TaxRate :=  Frm_Ar_Enter_SaleInvoice1_C1.TaxRate;   
    Edt_TaxRate.Text := FloatToStr(Frm_Ar_Enter_SaleInvoice1_C1.TaxRate);
    Edit2.Text:=Frm_Ar_Enter_SaleInvoice1_C1.CustomerName;
    Edt_CreateEmployeeCode.Text :=UserCode;
    ExecuteSql(AdoQry_tmp,'select EmployeeName from Employee where EmployeeCode='+QuotedStr(userCode),0);
    Edt_CreateEmployeeName.Text := AdoQry_tmp.fieldbyname('EmployeeName').AsString;
    AdoQuery.First;
    while not AdoQuery.Eof do
    begin
     If AdoQuery.fieldbyname('checkflag').AsInteger=1  Then
     begin
       ShipNo:=AdoQuery.fieldbyname('InvBillNo').asstring;
       break;
     end;
     AdoQuery.Next;
    end;
    SqlText:=' Select  InvOutBill.CustomerCode,CustomerBank,CustomerBankAccNo, '
            +'    InvOutBill.CurrencyCode,InvOutBill.PayTermCode,PayTermName,InvOutBill.RemArk,CurrencyName'
            +' From InvOutBill '
            +'   left Join Customer '
            +'     On InvOutBill.CustomerCode=Customer.CustomerCode '
            +'   left Join PayTerm '
            +'     On InvOutBill.PayTermCode=PayTerm.PayTermCode '
            +'   left Join Currency '
            +'      On Currency.CurrencyCode=InvOutBill.CurrencyCode '
            +' Where InvBillNo='''+ShipNo+'''';
    AdoQry_tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text :=SqlText;
    AdoQry_Tmp.Open;
    with AdoQry_Tmp do
    begin
      Edt_CurrencyCode.Text:=fieldbyname('CurrencyCode').AsString;
      Edt_SaleTermCode.Text:=fieldbyname('PayTermCode').AsString;
      Edt_CustomerCode.Text:=fieldbyname('CustomerCode').AsString;
      Edt_CustomerName.Caption:=fieldbyname('CustomerCode').AsString;
      Edt_CustomerBank.Text:=fieldbyname('CustomerBank').AsString;
      Edt_CustomerBankActNo.Text:=fieldbyname('CustomerBankAccNo').AsString;
      Edt_RemArk.Text:=fieldbyname('RemArk').AsString;
      Lab_CurrencyName.Caption:=fieldbyname('CurrencyName').AsString;
      Edit1.Text :=fieldbyname('CurrencyName').AsString;
      Lab_SaleTermName.Caption:=fieldbyname('PayTermName').AsString;
      Edit3.Text:=fieldbyname('PayTermName').AsString;
{      sqltext:='select * from Gl_ForeignCurrencyRate '
              +' where convert(int,substring(Accountperiod,1,4))='+inttostr(tmpYear)
              +'   and convert(int,substring(Accountperiod,6,2))='+inttostr(tmPMonth)
              +'   and currencyCode='+quotedstr(Trim(edt_CurrencyCode.text));
}
      SqlText := 'select * from Currency '
                +' where CurrencyCode='+QuotedStr(Edt_CurrencyCode.Text);
      ExecuteSql(AdoQry_Tmp,SqlText,0);
      If AdoQry_Tmp.fieldbyname('IsMaster').AsInteger=1 then edt_ExchangeRate.Text := '1'
      Else
      begin
        SqlText := 'select * from ExchRate '
                  +' where ExchMonth ='+QuotedStr(copy(MEdt_CreateDate.Text,1,7))
                  +'   and CurrencyCode='+QuotedStr(Edt_CurrencyCode.Text);
        Executesql(AdoQry_tmp,sqltext,0);
        edt_ExchangeRate.Text:=AdoQry_tmp.fieldbyname('ExchRate').asstring;
        edt_ExchangeRate.Text:=iifstring(edt_ExchangeRate.text='','1',edt_ExchangeRate.text);
      end;
    end;
    edt_CustomerCode.OnExit(edt_CustomerCode);
    SqlText:=' Select Top 0 Sa_SaleInvoiceLine.InvoiceNo,Sa_SaleInvoiceLine.InvBillId, '
            +'   InvOutBill.InvBillNo as ShipNo,Sa_SaleInvoiceLine.InvBillLineNo as ShipLineNo,   '
            +'   InvOutBillLine.ItemCode, '
            +'   InvOutBillLine.InvBillQty as ShipQty , InvOutBillLine.InvBillPrice as TaxPrice, InvOutBillLine.InvBillPriceC as TaxPriceC,'
            +'   InvOutBillLine.InvBillAmount as TaxAmount, InvOutBillLine.InvBillAmountC as TaxAmountC,InvOutBillLine.InvBillNoTaxPrice as NoTaxPrice, '
            +'   InvOutBillLine.InvBillNoTaxAmount as  NoTaxAmount,InvOutBillLine.DiSCountRate, '
            +'   InvOutBillLine.DiSCountAmount , '
            +'   Item.ItemName,Uom.UomName '
            +'   From Sa_SaleInvoiceLine '
            +'    Join InvOutBillLine on Sa_SaleInvoiceLine.InvBillId=InvOutBillLine.InvBillId '
            +'     and Sa_SaleInvoiceLine.InvBillLineNo=InvOutBillLine.InvBillLineNo '
            +'    Join InvOutBill on InvOutBillLine.InvBillId=InvOutBill.InvBillId '
            +'   left Join  Item '
            +'     On InvOutBillLine.ItemCode=Item.ItemCode '
            +'   left Join Uom '
            +'     On Item.UomCode=Uom.UomCode ';

     AdoQry_Body.Close;
     AdoQry_Body.SQL.Text:=SqlText;
     AdoQry_Body.Open;
     AdoQuery.First;
     While Not AdoQuery.Eof Do
     begin
       If AdoQuery.fieldbyname('Checkflag').AsInteger=1  Then
       begin
         SqlText:=' Select  InvOutBill.InvBillNo,InvOutBillLine.*,Item.ItemName,Uom.UomName '
            +' From InvOutBillLine '
            +'   Join InvOutBill on InvOutBillLine.InvBillId=InvOutBill.InvBillId '
            +'   left Join  Item '
            +'     On Item.ItemCode=InvOutBillLine.ItemCode '
            +'   left Join Uom '
            +'     On Item.UomCode=Uom.UomCode '
            +' where InvBillNo='+quotedstr(AdoQuery.fieldbyname('InvBillNo').asstring);

         AdoQry_tmp.Close;
         AdoQry_tmp.SQL.Text:=SqlText;
         AdoQry_tmp.Open;
         while not AdoQry_tmp.Eof do
           begin
             AdoQry_Body.Append;
             AdoQry_Body.fieldbyname('InvBillId').AsString := AdoQry_tmp.fieldbyname('InvBillId').asString;
             AdoQry_Body.fieldbyname('ShipNo').AsString:=AdoQry_tmp.fieldbyname('InvBillNo').AsString;
             AdoQry_Body.fieldbyname('ShipLineNo').Value:=Trim(AdoQry_tmp.fieldbyname('InvBillLineNo').Value);
             AdoQry_Body.fieldbyname('UomName').AsString:=AdoQry_tmp.fieldbyname('UomName').AsString;
             AdoQry_Body.fieldbyname('ItemCode').AsString:=AdoQry_tmp.fieldbyname('ItemCode').AsString;
             AdoQry_Body.fieldbyname('ItemName').AsString:=AdoQry_tmp.fieldbyname('ItemName').AsString;
             AdoQry_Body.fieldbyname('ShipQty').AsString:=AdoQry_tmp.fieldbyname('InvBillQty').AsString;

⌨️ 快捷键说明

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