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

📄 uaccept.pas

📁 天涯進銷存系統
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit uAccept;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, LBCtrls, DBCtrls, StdCtrls, ExtCtrls, FR_DSet, FR_DBSet,
  FR_Class, DB, DBClient, SimpleDS, ActnList, LBDBScrollBar, LBDBCtrls,
  Mask, dbcgrids, LBCurrencyCtrls, LBDBCurrencyCtrls;

type
  TfrmAccept = class(TForm)
    ActionList1: TActionList;
    Action1: TAction;
    Action2: TAction;
    Action3: TAction;
    Action4: TAction;
    Action5: TAction;
    Action6: TAction;
    Action7: TAction;
    Action8: TAction;
    Action9: TAction;
    BillHandData: TSimpleDataSet;
    BillHandDs: TDataSource;
    BillBodyData: TSimpleDataSet;
    BillBodyDs: TDataSource;
    Report: TfrReport;
    ReportDataSet: TfrDBDataSet;
    plToolbar: TPanel;
    LBSpeecButton2: TLBSpeecButton;
    LBSpeecButton1: TLBSpeecButton;
    LBSpeecButton3: TLBSpeecButton;
    LBSpeecButton4: TLBSpeecButton;
    LBSpeecButton5: TLBSpeecButton;
    LBSpeecButton6: TLBSpeecButton;
    Image2: TImage;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    LBSpeecButton9: TLBSpeecButton;
    Label1: TLabel;
    Label2: TLabel;
    DBText2: TDBText;
    BillPanel: TPanel;
    BillNextButton: TLBLabel;
    BillPriorButton: TLBLabel;
    Shape1: TShape;
    Label3: TLabel;
    Label4: TLabel;
    DBText7: TDBText;
    Label14: TLabel;
    Shape4: TShape;
    Shape3: TShape;
    Shape2: TShape;
    Label11: TLabel;
    Label17: TLabel;
    DBText1: TDBText;
    DBText3: TDBText;
    Label12: TLabel;
    Label13: TLabel;
    DBText4: TDBText;
    Label15: TLabel;
    DBText5: TDBText;
    Label23: TLabel;
    DBText6: TDBText;
    Shape6: TShape;
    DBCtrlGrid: TDBCtrlGrid;
    Panel5: TPanel;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Panel6: TPanel;
    PartCodeDBEdit: TDBEdit;
    PartNameDBEdit: TDBEdit;
    CarModelDBEdit: TDBEdit;
    ProducingDBEdit: TDBEdit;
    DepotPlaceDBEdit: TDBEdit;
    UnitDBEdit: TDBEdit;
    Panel4: TPanel;
    MemoDBEdit: TLBDBEdit;
    LBDBScrollBar1: TLBDBScrollBar;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label24: TLabel;
    Shape5: TShape;
    SaveButton: TLBButton;
    CancelButton: TLBButton;
    Auditing: TImage;
    Label9: TLabel;
    Label10: TLabel;
    Label16: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    DBText8: TDBText;
    Label22: TLabel;
    DBText9: TDBText;
    Panel1: TPanel;
    SumInfoPanel: TPanel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    DBText10: TDBText;
    DBText11: TDBText;
    DBText12: TDBText;
    Panel2: TPanel;
    LBDBComboBox1: TLBDBComboBox;
    LBDBEdit1: TLBDBEdit;
    isPrepaySumCheck: TLBDBCheckBox;
    Shape7: TShape;
    CurrentsumEdit: TLBDBCurrencyEdit;
    ISPAYSUMCheck: TDBCheckBox;
    LBEditButton1: TLBEditButton;
    OTHERUNITDBEdit: TLBDBEdit;
    LBEditButton2: TLBEditButton;
    BillDateDBEdit: TLBDBEdit;
    PayInfoPanel: TPanel;
    Image1: TImage;
    Shape8: TShape;
    DBCurrencyEdit: TLBDBCurrencyEdit;
    FilialeinfoName: TLBDBComboBox;
    BillInfoLabel: TLabel;
    BillHandDataBILLCODE: TStringField;
    BillHandDataBILLDATE: TSQLTimeStampField;
    BillHandDataOTHERUNITCODE: TStringField;
    BillHandDataOTHERUNITNAME: TStringField;
    BillHandDataBILLMODEL: TStringField;
    BillHandDataBILLMODELCODE: TStringField;
    BillHandDataPAYTOTALSUM: TBCDField;
    BillHandDataPREPAYSUM: TBCDField;
    BillHandDataCURRENTSUM: TBCDField;
    BillHandDataPAYTYPE: TStringField;
    BillHandDataBANKBILLCODE: TStringField;
    BillHandDataAGIOSUM: TBCDField;
    BillHandDataISUSEPREPAYSUM: TStringField;
    BillHandDataCANUSESUM: TBCDField;
    BillHandDataBALANCE: TBCDField;
    BillHandDataBALANCEWHITHER: TStringField;
    BillHandDataTOTALSUM: TBCDField;
    BillHandDataBIGSUM: TStringField;
    BillHandDataISAUDITING: TStringField;
    BillHandDataAUDITINGMAN: TStringField;
    BillHandDataAUDITINGDATE: TSQLTimeStampField;
    BillHandDataMEMO: TStringField;
    BillHandDataBILLTYPE: TStringField;
    BillHandDataOPERATIONMAN: TStringField;
    BillHandDataOPERATOR: TStringField;
    BillHandDataPAYMENTWHITHER: TStringField;
    BillHandDataISBALANCETO: TStringField;
    BillBodyDataBILLCODE: TStringField;
    BillBodyDataID: TIntegerField;
    BillBodyDataPAYBILLCODE: TStringField;
    BillBodyDataPAYBILLDATE: TSQLTimeStampField;
    BillBodyDataPAYTOTALSUM: TBCDField;
    BillBodyDataALREADYPAYSUM: TBCDField;
    BillBodyDataOUGHTPAYSUM: TBCDField;
    BillBodyDataCURRENTSUM: TBCDField;
    BillBodyDataISPAYSUM: TStringField;
    procedure FormShow(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BillHandDataAfterScroll(DataSet: TDataSet);
    procedure LBEditButton1Click(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
    procedure Action2Execute(Sender: TObject);
    procedure Action3Execute(Sender: TObject);
    procedure Action4Execute(Sender: TObject);
    procedure Action5Execute(Sender: TObject);
    procedure Action6Execute(Sender: TObject);
    procedure Action7Execute(Sender: TObject);
    procedure Action8Execute(Sender: TObject);
    procedure Action9Execute(Sender: TObject);
    procedure OTHERUNITDBEditEnter(Sender: TObject);
    procedure OTHERUNITDBEditExit(Sender: TObject);
    procedure OTHERUNITDBEditKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure LBEditButton2Click(Sender: TObject);
    procedure BillDateDBEditKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure CurrentsumEditExit(Sender: TObject);
    procedure CurrentsumEditKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBCurrencyEditExit(Sender: TObject);
    procedure isPrepaySumCheckClick(Sender: TObject);
    procedure BillNextButtonClick(Sender: TObject);
    procedure BillPriorButtonClick(Sender: TObject);
    procedure FilialeinfoNameDropDown(Sender: TObject);
    procedure FilialeinfoNameExit(Sender: TObject);
    procedure FilialeinfoNameChange(Sender: TObject);
    procedure FilialeinfoNameKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    procedure SetView;
    procedure GetSum;
    procedure PayTypeView;
    procedure SetAuditing;
  public
    { Public declarations }
  end;

var
  frmAccept: TfrmAccept;
  isEdit, isStateEdit: Boolean;

  OldOtherUnitCode: string;
  Sum : Extended;
  AcceptBillModel: Integer;

implementation

uses uMain, uPublicvar, Tools, uDataMo, uSelectAccept, uConst;

{$R *.dfm}

procedure TfrmAccept.SetView;
begin
  BillPanel.Enabled:=not BillPanel.Enabled;

  Action1.Enabled:=not Action1.Enabled;
  Action2.Enabled:=not Action2.Enabled;
  Action3.Enabled:=not Action3.Enabled;
  Action4.Enabled:=not Action4.Enabled;
  Action5.Enabled:=not Action5.Enabled;
  Action6.Enabled:=not Action6.Enabled;
  Action7.Enabled:=not Action7.Enabled;
  Action8.Enabled:=not Action8.Enabled;
  Action9.Enabled:=not Action9.Enabled;

  SaveButton.Visible:=not SaveButton.Visible;
  CancelButton.Visible:=not CancelButton.Visible;
end;

procedure TfrmAccept.GetSum;
begin
  //可用金额
  //如果使用预付款则加上预付金额
  BillHandData.Edit;
  if isPrepaySumCheck.Checked then
    BillHandData.FieldByName('CANUSESUM').asFloat:=
    BillHandData.FieldByName('PREPAYSUM').asFloat+CurrentsumEdit.Value
  else
    BillHandData.FieldByName('CANUSESUM').asFloat:=CurrentsumEdit.Value;
  //如果可用金额大于应收款总金额则有余额
  if BillHandData.FieldByName('CANUSESUM').asFloat-
     BillHandData.FieldByName('PAYTOTALSUM').asFloat>0 then
  begin
    BillHandData.FieldByName('BALANCE').asFloat:=
     BillHandData.FieldByName('CANUSESUM').asFloat-
     BillHandData.FieldByName('PAYTOTALSUM').asFloat;
    BillHandData.FieldByName('TOTALSUM').asFloat:=
     BillHandData.FieldByName('PAYTOTALSUM').asFloat;
  end
  else
  begin
    BillHandData.FieldByName('BALANCE').asFloat:=0;
    BillHandData.FieldByName('TOTALSUM').asFloat:=
      BillHandData.FieldByName('CANUSESUM').asFloat;
    BillHandData.FieldByName('BigSum').asstring:=
    SumSmallTOBig(BillHandData.FieldByName('TotalSum').Asfloat);
  end;
end;

procedure TFrmAccept.PayTypeView;
begin
  FilialeinfoName.Visible:=False;
  OTHERUNITDBEdit.Visible:=True;
  isPrepaySumCheck.Visible:=True;
  PayInfoPanel.Visible:=False;
  SumInfoPanel.Visible:=True;
  Label22.Visible:=True;
  DBText9.Visible:=True;
  if BillHandData.Fieldbyname('BillModel').asstring='内部调出收款' then
  begin
    FilialeinfoName.Visible:=True;
    OTHERUNITDBEdit.Visible:=False;
    Label22.Visible:=False;
    DBText9.Visible:=False;
    isPrepaySumCheck.Visible:=False;
  end
  else
  if BillHandData.Fieldbyname('BillModel').asstring='预收款' then
  begin
    PayInfoPanel.Visible:=True;
    SumInfoPanel.Visible:=False;
    Label22.Enabled:=False;
    DBText9.Enabled:=False;
  end
  else
  if BillHandData.Fieldbyname('BillModel').asstring='采购退货收款' then
  begin
    Label22.Caption:='预付金额:';
    isPREPAYSUMCheck.Visible:=False;
  end
  else
  begin
    Label22.Caption:='预收金额:';
    isPREPAYSUMCheck.Visible:=True;
  end;
end;

procedure TFrmAccept.SetAuditing;
var
  s: String;
  AgioSum: Extended;
begin
  try
    BillHandData.ReadOnly:=False;
    BillHandData.Edit;
    BillHandData.FieldByName('isAuditing').AsString:='1';
    BillHandData.FieldByName('AuditingMan').AsString:=UserName;
    BillHandData.FieldByName('AuditingDate').asDateTime:=Now;
    AgioSum:=BillHandData.Fieldbyname('AGIOSUM').AsFloat;
    BillBodyData.First;
    //销售收款 
    if BillHandData.FieldByName('BillModelCode').asString='0' then
    begin
      while not BillBodyData.Eof do
      begin
        s:='select BILLCODE, TOTALSUM, ACCEPTSUM, AGIOSUM, '+
           ' ISACCEPT From PARTSOUTPUTHAND where BILLCODE='+
           #39+Trim(BillBodyData.FieldByName('PAYBILLCODE').asstring)+#39;
        OpenData(s, dmData.sdsPublic);
        if not dmData.sdsPublic.IsEmpty then
        begin
          //收款金额
          dmData.sdsPublic.Edit;
          dmData.sdsPublic.FieldByName('ACCEPTSUM').asFloat:=
          dmData.sdsPublic.FieldByName('ACCEPTSUM').asFloat+
          BillBodyData.Fieldbyname('CURRENTSUM').asFloat;
          //如果有折扣金额
          if (BillBodyData.RecordCount=BillBodyData.RecNo)
          and (AgioSum>0) then
              dmData.sdsPublic.FieldByName('AGIOSUM').asFloat:=
              dmData.sdsPublic.FieldByName('AGIOSUM').asFloat+AgioSum;
          if (dmData.sdsPublic.FieldByName('ACCEPTSUM').asFloat+
              dmData.sdsPublic.FieldByName('AGIOSUM').asFloat)>=
             dmData.sdsPublic.FieldByName('TOTALSUM').asFloat then
          begin
            dmData.sdsPublic.FieldByName('ACCEPTSUM').asFloat:=
            dmData.sdsPublic.FieldByName('TOTALSUM').asFloat-
            dmData.sdsPublic.FieldByName('AGIOSUM').asFloat;
            dmData.sdsPublic.FieldByName('ISACCEPT').asString:='1';
          end;
          dmData.sdsPublic.ApplyUpdates(-1);
        end;
        BillBodyData.Next;
      end;
      s:='Update ClientInfo Set ARREARAGESUM=ARREARAGESUM-'+
         FloatToStr(BillHandData.Fieldbyname('TOTALSUM').asFloat+DBCurrencyEdit.Value);
      //如果有使用预收款,则减预收金额
      if BillHandData.FieldByName('ISUSEPREPAYSUM').asString='True' then
      s:=s+',PREPAYSUM=PREPAYSUM-'+FloatToStr(BillHandData.FieldByName('PREPAYSUM').asFloat);
      //如果是转成预收款则转为预收款
      if BillHandData.FieldByName('BALANCEWHITHER').asString='转预收款' then
      s:=s+',PREPAYSUM=PREPAYSUM+'+FloatToStr(BillHandData.FieldByName('BALANCE').asFloat);
      //未收金额
      s:=s+', PAYMENTSUM=ARREARAGESUM-PREPAYSUM-REIMBURSESUM '+
         'where Code='+#39+BillHandData.Fieldbyname('OTHERUNITCODE').asString+#39;
    end
    else
    // 内部调入付款
    if (BillHandData.FieldByName('BillModelCode').asString='3') then
    begin
      while not BillBodyData.Eof do
      begin
        s:='select BILLCODE, TOTALSUM, ACCEPTSUM, AGIOSUM, '+
           ' ISACCEPT From PARTSOUTPUTHAND where BILLCODE='+
           #39+Trim(BillBodyData.FieldByName('PAYBILLCODE').asstring)+#39;
        OpenData(s, dmData.sdsPublic);
        if not dmData.sdsPublic.IsEmpty then
        begin

⌨️ 快捷键说明

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