unit U_BankFlowInInput; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, DB, ADODB, cxControls, cxContainer, cxEdit, cxTextEdit, cxCurrencyEdit, BtnEdit, StdCtrls, ExtCtrls, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, dxSkinWXI, dxCore, cxDateUtils, cxMaskEdit, cxDropDownEdit, cxCalendar, cxButtonEdit, cxMemo; type TfrmBankFlowInInput = class(TForm) ToolBar1: TToolBar; TSAVE: TToolButton; Tclose: TToolButton; Panel1: TPanel; Label5: TLabel; ADOQueryTMP: TADOQuery; ADOQueryCMD: TADOQuery; Amount: TcxCurrencyEdit; ToolButton1: TToolButton; Label20: TLabel; BFTime: TcxDateEdit; Label19: TLabel; Label2: TLabel; OppCoName: TcxButtonEdit; OppBKName: TcxButtonEdit; Label18: TLabel; OurBKName: TcxButtonEdit; Label7: TLabel; Note: TcxMemo; procedure TcloseClick(Sender: TObject); procedure TSAVEClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure OppCoNameBtnUpClick(Sender: TObject); procedure OppBKNameBtnUpClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure OurBKNameBtnUpClick(Sender: TObject); procedure OppCoNameBtnDnClick(Sender: TObject); procedure OppCoNameDblClick(Sender: TObject); procedure OppCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure OppBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); private function savedata(): Boolean; procedure initdata(); { Private declarations } public FBFID: string; { Public declarations } end; var frmBankFlowInInput: TfrmBankFlowInInput; implementation uses U_ZDYHelp, U_RTFun, U_DataLink, U_BankSel, U_CompanySel; {$R *.dfm} procedure TfrmBankFlowInInput.initdata(); begin with ADOQueryTMP do begin close; sql.clear; sql.Add('select * from BS_Bank_Flow '); sql.Add('where BFID=' + quotedstr(trim(FBFID))); open; end; if not ADOQueryTMP.isempty then begin SCSHData(ADOQueryTMP, Panel1, 0); OurBKName.Properties.LookupItems.Text := ADOQueryTMP.FieldByName('OurBKID').AsString; OppBKName.Properties.LookupItems.Text := ADOQueryTMP.FieldByName('OppBKID').AsString; OppCoName.Properties.LookupItems.Text := ADOQueryTMP.FieldByName('OppCoNO').AsString; end; end; function TfrmBankFlowInInput.savedata(): Boolean; var MaxNo: string; begin try ADOQueryCMD.Connection.BeginTrans; if Trim(FBFID) = '' then begin if GetLSNo(ADOQueryCMD, MaxNo, 'YL', 'BS_Bank_Flow', 4, 1) = False then raise Exception.Create('取最大号失败!'); end else MaxNo := FBFID; with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('select * from BS_Bank_Flow where BFID=''' + Trim(MaxNo) + ''' '); Open; if Trim(FBFID) = '' then begin Append; fieldbyname('fillid').Value := trim(DCode); fieldbyname('filler').Value := trim(Dname); end else begin Edit; fieldbyname('Editid').Value := trim(DCode); Fieldbyname('Editer').Value := trim(Dname); Fieldbyname('Edittime').Value := SGetServerDateTime(adoqueryTmp); end; RTSetsavedata(ADOQueryCmd, 'BS_Bank_Flow', Panel1, 0); FieldByName('BFID').Value := Trim(MaxNo); FieldByName('BFType').Value := '收款'; fieldbyname('inAmount').Value := strtofloatdef(trim(Amount.Text), 0); fieldbyname('OutAmount').Value := 0; fieldbyname('status').Value := '0'; fieldbyname('OurBKID').Value := OurBKName.Properties.LookupItems.Text; fieldbyname('OppBKID').Value := OppBKName.Properties.LookupItems.Text; fieldbyname('OppCoNo').Value := OppCoName.Properties.LookupItems.Text; Post; end; { with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('delete from BS_Bank_Flow where fromBFID=''' + Trim(FBFID) + ''' '); execsql; end; if trim(CRType.Text) = '账户互转' then begin if GetLSNo(ADOQueryCMD, fid, 'YL', 'BS_Bank_Flow', 4, 1) = False then begin ADOQueryCMD.Connection.RollbackTrans; Application.MessageBox('取流水号失败!', '提示'); Exit; end; with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('select * from BS_Bank_Flow where BFID=''' + Trim(fid) + ''' '); Open; append; fieldbyname('filler').Value := trim(Dname); RTSetsavedata(ADOQueryCmd, 'BS_Bank_Flow', Panel1, 0); FieldByName('BFID').Value := Trim(fid); fieldbyname('Bkid').Value := trim(OppBKName.TxtCode); fieldbyname('OurBKName').Value := trim(OppBKName.Text); fieldbyname('ToBkid').Value := trim(OurBKName.TxtCode); fieldbyname('OppBKName').Value := trim(OurBKName.Text); fieldbyname('inAmount').Value := strtofloatdef(trim(OutAmount.Text), 0); fieldbyname('OutAmount').Value := strtofloatdef(trim(InAmount.Text), 0); fieldbyname('status').Value := '0'; fieldbyname('fromBFID').Value := trim(FBFID); Post; end; end; if trim(CRType.Text) = '结汇' then begin if GetLSNo(ADOQueryCMD, fid, 'YL', 'BS_Bank_Flow', 4, 1) = False then begin ADOQueryCMD.Connection.RollbackTrans; Application.MessageBox('取流水号失败!', '提示'); Exit; end; with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('select * from BS_Bank_Flow where BFID=''' + Trim(fid) + ''' '); Open; append; fieldbyname('filler').Value := trim(Dname); RTSetsavedata(ADOQueryCmd, 'BS_Bank_Flow', Panel1, 0); FieldByName('BFID').Value := Trim(fid); fieldbyname('Bkid').Value := trim(OppBKName.TxtCode); fieldbyname('OurBKName').Value := trim(OppBKName.Text); fieldbyname('ToBkid').Value := trim(OurBKName.TxtCode); fieldbyname('OppBKName').Value := trim(OurBKName.Text); fieldbyname('inAmount').Value := strtofloatdef(trim(JHAmount.Text), 0); fieldbyname('OutAmount').Value := strtofloatdef(trim(InAmount.Text), 0); fieldbyname('JHAmount').Value := strtofloatdef(trim(JHAmount.Text), 0); fieldbyname('JHHulLv').Value := strtofloatdef(trim(JHHulLv.Text), 0); fieldbyname('status').Value := '0'; fieldbyname('fromBFID').Value := trim(FBFID); Post; end; end; } ADOquerycmd.Connection.CommitTrans; FBFID := MaxNo; Result := True; except Result := false; ADOquerycmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmBankFlowInInput.TcloseClick(Sender: TObject); begin ModalResult := 1; end; procedure TfrmBankFlowInInput.ToolButton1Click(Sender: TObject); begin if OurBKName.Text = '' then begin Application.MessageBox('我方账户不能为空!', '提示', 0); Exit; end; if OppBKName.Text = '' then begin Application.MessageBox('对方账户不能为空!', '提示', 0); Exit; end; if Amount.Text = '' then begin Application.MessageBox('金额不能为空!', '提示', 0); Exit; end; if SaveData() then begin Amount.Text := ''; FBFID := ''; end; end; procedure TfrmBankFlowInInput.TSAVEClick(Sender: TObject); begin if OurBKName.Text = '' then begin Application.MessageBox('我方账户不能为空!', '提示', 0); Exit; end; if OppBKName.Text = '' then begin Application.MessageBox('对方账户不能为空!', '提示', 0); Exit; end; if Amount.Text = '' then begin Application.MessageBox('金额不能为空!', '提示', 0); Exit; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); ModalResult := 1; end; end; procedure TfrmBankFlowInInput.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := cafree; end; procedure TfrmBankFlowInInput.FormDestroy(Sender: TObject); begin frmBankFlowInInput := nil; end; procedure TfrmBankFlowInInput.FormShow(Sender: TObject); begin BFTime.Date := SGetServerDate(adoqueryTmp); initData(); end; procedure TfrmBankFlowInInput.FormCreate(Sender: TObject); begin Panel1.Align := alclient; end; procedure TfrmBankFlowInInput.OppBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := self.OppCoName.Properties.LookupItems.Text; flagname := '对方账户'; if ShowModal = 1 then begin TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmBankFlowInInput.OppBKNameBtnUpClick(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin MainType := 'Bank'; flag := self.OppCoName.Properties.LookupItems.Text; flagname := '对方账户'; if ShowModal = 1 then begin TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmBankFlowInInput.OppCoNameBtnDnClick(Sender: TObject); begin TBtnEditC(Sender).Text := ''; TBtnEditC(Sender).TxtCode := ''; end; procedure TfrmBankFlowInInput.OppCoNameBtnUpClick(Sender: TObject); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin if ShowModal = 1 then begin OppCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString); OppCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmBankFlowInInput.OppCoNameDblClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; end; procedure TfrmBankFlowInInput.OppCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '供应商'; if ShowModal = 1 then begin OppCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); OppCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmBankFlowInInput.OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmBankSel := TfrmBankSel.Create(Application); with frmBankSel do begin if ShowModal = 1 then begin OurBkName.Text := Trim(CDS_1.fieldbyname('BankName').AsString); OurBkName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('BkID').AsString); end; end; finally frmBankSel.Free; end; end; procedure TfrmBankFlowInInput.OurBKNameBtnUpClick(Sender: TObject); begin try frmBankSel := TfrmBankSel.Create(self); with frmBankSel do begin if showmodal = 1 then begin SELF.OurBKName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('BKID').AsString); SELF.OurBKName.Text := Trim(CDS_1.fieldbyname('BankName').AsString); end; end; finally frmBankSel.Free; end; end; end.