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

📄 ap_enter_noinvoiceinvinorderh.pas

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

Interface

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

Type
  TFrm_Ap_Enter_NoInvoiceInvInOrderH = Class(TFrm_Base_Entry_Head)
    AdoQry_HeadWHCode: TStringField;
    AdoQry_HeadWHName: TStringField;
    AdoQry_HeadWhPositionCode: TStringField;
    AdoQry_HeadWhPositionName: TStringField;
    AdoQry_HeadInvBillNo: TStringField;
    AdoQry_HeadInvBillId: TFloatField;
    AdoQry_HeadInvBillDate: TDateTimeField;
    AdoQry_HeadPoNo: TStringField;
    AdoQry_HeadVendorCode: TStringField;
    AdoQry_HeadVendorName: TStringField;
    AdoQry_HeadInvBillRemArk: TStringField;
    AdoQry_HeadVendorBillNo: TStringField;
    AdoQry_HeadBillTypeCode: TStringField;
    AdoQry_HeadBillTypeName: TStringField;
    AdoQry_HeadInvBillTaxRate: TFloatField;
    AdoQry_HeadInvBillMonth: TStringField;
    AdoQry_HeadInvBillCreateTime: TDateTimeField;
    AdoQry_HeadWH_EmployeeCode: TStringField;
    AdoQry_HeadEmployeeName: TStringField;
    AdoQry_HeadCurrencyCode: TStringField;
    AdoQry_HeadCurrencyName: TStringField;
    AdoQry_HeadExchRate: TFloatField;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Act_NewExecute(Sender: TObject);
    procedure Act_DeleteExecute(Sender: TObject);
  private
    { Private declarations }
    Function SelectStArtMonthAp:string;          //应付模块启用月份;
    Function IsStArt:string;                     //0:为未启用;1:为启用;
  public
    { Public declarations }
    InvBillid:string;
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;    
  end;

var
  Frm_Ap_Enter_NoInvoiceInvInOrderH: TFrm_Ap_Enter_NoInvoiceInvInOrderH;

implementation

uses Sys_Global, Ap_Enter_NoInvoiceInvInOrder;

{$R *.DFM}

{ TFrm_Ap_Enter_NoInvoiceInvInOrderH }

procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH.InitForm(
  AdOConnection: TAdOConnection; ReadOnly: Boolean);
begin
  inherited;
  if (IsStArt='1')   then
  begin
    DispInfo('未发票入库单只可在应收模块没有启用前输入',3);
    Act_New.Enabled :=False;
    act_New.Visible :=False;
    Act_Modify.Enabled :=False;
    Act_Modify.Visible :=False;
    Act_Delete.Enabled :=False;
    Act_Delete.Visible :=False;
    //Close;
  end;
  SelectFromSQL:='  Select distinct InvInBill.WHCode'
    +',Warehouse.WHName'
    +',InvInBill.WhPositionCode'
    +',WhPosition.WhPositionName'
    +',InvInBill.InvBillNo'
    +',InvInBill.InvBillId'
    +',InvInBill.InvBillDate'
    +',InvInBill.PoNo'
    +',InvInBill.VendorCode'
    +',Vendor.VendorName'
    +',InvInBill.InvBillRemArk'
    +',InvInBill.VendorBillNo'
    +',InvInBill.BillTypeCode'
    +',BillType.BillTypeName'
    +',InvInBill.InvBillTaxRate'
    +',InvInBill.InvBillMonth'
    +',InvInBill.InvBillCreateTime'
    +',InvInBill.WH_EmployeeCode'
    +',Employee.EmployeeName'
    +',InvInBill.CurrencyCode'
    +',InvInBill.ExchRate'    
    +',Currency.CurrencyName'
    +' From InvInBill join InvInBillline on InvInBill.InvBillid=InvInBillline.InvBillid'
    +' Join Warehouse On InvInBill.WHCode=Warehouse.WHCode'
    +' Join Vendor On InvInBill.VendorCode=Vendor.VendorCode'
    +' Join WhPosition On InvInBill.WhPositionCode=WhPosition.WhPositionCode'
    +' join BillType on InvInBill.BillTypeCode=BillType.BillTypeCode'
    +' join Employee on InvInBill.WH_EmployeeCode=Employee.EmployeeCode'
    +' join Currency on InvInBill.CurrencyCode=Currency.CurrencyCode'
    +' And InvInBill.WHCode=WhPosition.WHCode ' ;

  OrderByFields:='VendorCode';
   ConditionUserDefine:=' InvInBillLine.InvBillQty =0 and InvInBillLine.InvBillNoTaxPrice=0 '+
                        ' and InvBillremArk like ''应付模块初示化数据%''';
  if SelectStArtMonthAp<>'' then
    ConditionUserDefine :=ConditionUserDefine+' and  InvInBill.InvBillMonth <'+SelectStArtMonthAp;

  GetData;
  Frm_Entry_Body:=TFrm_Ap_Enter_NoInvoiceInvInOrder.Create(Self);
end;

function TFrm_Ap_Enter_NoInvoiceInvInOrderH.SelectStArtMonthAp: string;
begin
  Result:='';
  Executesql(AdoQry_tmp,' select ApParamValueC from ApParam '
                       +' where ApParamCode=''StartUseAp'' and ApParamName=''应付模块启用'''
                       +' and ApParamValuen=1',0);

 if   AdoQry_tmp.RecordCount>0   then
  Result:=AdoQry_tmp.fieldbyname('ApParamValueC').asstring;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Ap_Enter_NoInvoiceInvInOrderH:=nil;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  //inherited;
  if Frm_Sys_Condition<>nil then
    Frm_Sys_Condition.Release;
  if Frm_Entry_Body<>nil then
    Frm_Entry_Body.Release;
  if Frm_Sys_SortOrder<>nil then
    Frm_Sys_SortOrder.Release;
  if Frm_Sys_QuickLocate<>nil then
    Frm_Sys_QuickLocate.Release;
  if Frm_Sys_SetColumn<>nil then
    Frm_Sys_SetColumn.Release;
  Action:=CaFree;
end;

function TFrm_Ap_Enter_NoInvoiceInvInOrderH.IsStArt: string;
begin
  Result:='0';
  Executesql(AdoQry_tmp,' select ApParamValueN from ApParam '
                       +' where ApParamCode=''StartUseAp'' and ApParamName=''应付模块启用''',0);
 if   AdoQry_tmp.RecordCount>0   then
  Result:=AdoQry_tmp.fieldbyname('ApParamValueN').asstring;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH.Act_NewExecute(
  Sender: TObject);
begin
  inherited;
  //从BODY返回Head后,数据重新刷新,并且要定位。因为AdO控件对CASE采段进行缓存修改
  getdata;
  if InvBillid<>'' then
  begin
    AdoQry_Head.First;
    AdoQry_Head.Locate('InvBillid',InvBillid,[]);
  end;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH.Act_DeleteExecute(
  Sender: TObject);
var
  KillNoInvoiceNo:string;//抵冲历史未开票金额未开票入库单单号:
begin
  inherited;
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select ApParamValueC '+
                    ' from ApParam '+
                    ' where ApParamCode=''KillNoInvoiceNo''');
    open;
    KillNoInvoiceNo:=fieldbyname('ApParamValueC').asstring;
  end;
  if AdoQry_Head.fieldbyname('InvBillNo').asstring=KillNoInvoiceNo then
  begin
    DispInfo('已被系统调用不能删除此入库单!',3);
    abort;
  end;
  if DispInfo('您真的想删除此单据吗?',2)='y' then
  begin
    Dbconnect.beginTrans ;
    try
      Executesql(AdoQry_tmp,'delete from InvInBillline '+
               ' where InvBillid='+AdoQry_Head.fieldbyname('InvBillId').asstring,1);
       Executesql(AdoQry_tmp,' delete from InvInBill '+
               ' where InvBillid='+AdoQry_Head.fieldbyname('InvBillId').asstring,1);
      dbconnect.CommitTrans ;
      AdoQry_Head.Delete;
    except
      dbconnect.RollBackTrans ;
      DispInfo('删除失败!',3);
      abort;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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