D10SZKaiXiYa/A09财务通用管理/U_CollectInput2.pas
2026-05-30 17:45:45 +08:00

453 lines
13 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_CollectInput2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
cxTextEdit, cxDropDownEdit, BtnEdit, cxLookAndFeels, cxLookAndFeelPainters,
cxNavigator, dxDateRanges, dxBarBuiltInMenu, U_BaseList, cxContainer,
cxCurrencyEdit, dxSkinsCore, dxSkinsDefaultPainters, dxCore, cxDateUtils,
dxScrollbarAnnotations, Vcl.Menus, Clipbrd, dxCoreGraphics, dxSkinWXI, cxLabel;
type
TfrmCollectInput2 = class(TForm)
ToolBar1: TToolBar;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ToolButton3: TToolButton;
ScrollBox1: TScrollBox;
Label7: TLabel;
Note: TMemo;
Currency: TcxComboBox;
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
Amount: TcxTextEdit;
Label6: TLabel;
Label8: TLabel;
OurBankCardNo: TcxTextEdit;
OurBankName: TcxButtonEdit;
OppCoName: TcxButtonEdit;
FFTime: TcxDateEdit;
Label13: TLabel;
Panel1: TPanel;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
DS_1: TDataSource;
CDS_1: TClientDataSet;
Tv1CoName: TcxGridDBColumn;
Tv1BankName: TcxGridDBColumn;
Tv1BankNo: TcxGridDBColumn;
Tv1ShuiNo: TcxGridDBColumn;
PM_1: TPopupMenu;
GPM_1: TcxGridPopupMenu;
N1: TMenuItem;
Label15: TLabel;
IVNo: TcxButtonEdit;
oppShuiNo: TcxTextEdit;
FFID: TEdit;
cxLookAndFeelController1: TcxLookAndFeelController;
cxLabel1: TcxLabel;
OurCoName: TcxButtonEdit;
OppParentCoName: TcxButtonEdit;
cxLabel2: TcxLabel;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure OppCoNameBtnUpClick(Sender: TObject);
procedure OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure AmountPropertiesEditValueChanged(Sender: TObject);
procedure TaxNumberPropertiesChange(Sender: TObject);
procedure Tv1DblClick(Sender: TObject);
procedure ScrollBox1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure cxButtonEdit1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
private
{ Private declarations }
procedure InitGrid();
function SaveData(): Boolean;
procedure InitGrid2();
public
{ Public declarations }
FFFID: string;
FoppShuiNoChange: string;
end;
var
frmCollectInput2: TfrmCollectInput2;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel, U_BankSel, U_FinTradePlanSel,
U_FinTradeSalesContractSel, U_ZDYBankSel, U_InvoiceOutSel;
{$R *.dfm}
procedure TfrmCollectInput2.InitGrid();
var
nAmount: Double;
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' select * from Finance_Flow where FFID=''' + Trim(FFFID) + '''');
Open;
end;
if not ADOQueryMain.IsEmpty then
begin
SCSHData(ADOQueryMain, ScrollBox1, 2);
if ADOQueryMain.FieldByName('Amount').AsString <> '' then
begin
nAmount := ADOQueryMain.FieldByName('Amount').AsFloat;
Amount.Text := FormatFloat('#,##0.00', nAmount);
end;
end
else
begin
FFTime.Date := SGetServerDateTime(ADOQueryTemp);
end;
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmCollectInput2.InitGrid2();
begin
try
ADOQueryCmd.DisableControls;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select A.* from BS_Company A where 1=1 ');
sql.Add(' and A.CoType=''<27><>Ӧ<EFBFBD><D3A6>'' ');
SQL.Add(' and ShuiNo like ''%' + oppShuiNo.Text + '%'' ');
Open;
end;
SCreateCDS(ADOQueryCmd, CDS_1);
SInitCDSData(ADOQueryCmd, CDS_1);
finally
ADOQueryCmd.EnableControls;
TV1.DataController.Filter.Clear;
end;
end;
procedure TfrmCollectInput2.N1Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmCollectInput2.OppCoNameBtnUpClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'OppCoName';
flagname := '<27>Է<EFBFBD><D4B7><EFBFBD>λ';
if ShowModal = 1 then
begin
TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmCollectInput2.OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
fsj: string;
FWZ: Integer;
begin
fsj := Trim(TcxButtonEdit(Sender).Hint);
FWZ := Pos('/', fsj); //<2F><>Ӣ<EFBFBD><D3A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
try
frmZDYBankSel := TfrmZDYBankSel.Create(Application);
with frmZDYBankSel do
begin
MainType := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
flag := Copy(fsj, 1, FWZ - 1);
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
if ShowModal = 1 then
begin
OurBankName.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
OurBankCardNo.Text := Trim(ClientDataSet1.fieldbyname('note').AsString);
end;
end;
finally
frmZDYBankSel.Free;
end;
end;
procedure TfrmCollectInput2.FormDestroy(Sender: TObject);
begin
frmCollectInput2 := nil;
end;
procedure TfrmCollectInput2.AmountPropertiesEditValueChanged(Sender: TObject);
var
n: Double;
CleanText: string;
DecimalPos: Integer;
DecimalDigits: Integer;
FormatStr: string;
CaretPos: Integer;
TextBeforeCaret: string;
begin
CaretPos := Amount.SelStart;
TextBeforeCaret := Copy(Amount.Text, 1, CaretPos);
CleanText := StringReplace(Amount.Text, ',', '', [rfReplaceAll]);
if TryStrToFloat(CleanText, n) then
begin
Amount.Properties.OnEditValueChanged := nil;
try
DecimalPos := Pos('.', CleanText);
if DecimalPos > 0 then
DecimalDigits := Length(CleanText) - DecimalPos
else
DecimalDigits := 0;
if DecimalDigits = 0 then
FormatStr := '#,##0'
else
FormatStr := '#,##0.' + StringOfChar('0', DecimalDigits);
Amount.Text := FormatFloat(FormatStr, n);
if CaretPos > 0 then
begin
CaretPos := Length(TextBeforeCaret) + (StringReplace(Copy(Amount.Text, 1, Length(TextBeforeCaret)), ',', '', [rfReplaceAll]).Length - TextBeforeCaret.Length);
if CaretPos <= Length(Amount.Text) then
Amount.SelStart := CaretPos;
end;
finally
Amount.Properties.OnEditValueChanged := AmountPropertiesEditValueChanged;
end;
end;
end;
procedure TfrmCollectInput2.cxButtonEdit1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
CurrentAmount: Double;
TaxAmount: Double;
begin
try
frmInvoiceOutSel := TfrmInvoiceOutSel.Create(Application);
with frmInvoiceOutSel do
begin
if ShowModal = 1 then
begin
FoppShuiNoChange := '0';
Self.IVNo.Text := '';
Self.IVNo.Properties.LookupItems.Text := '';
Self.Amount.Text := '0';
while CDS_Invoice.Locate('SSel', true, []) do
begin
with frmInvoiceOutSel.CDS_Invoice do
begin
CurrentAmount := StrToFloatDef(StringReplace(Self.Amount.Text, ',', '', [rfReplaceAll]), 0);
TaxAmount := FieldByName('TaxAmount').AsFloat;
if Self.IVNo.Text = '' then
begin
Self.IVNo.Text := frmInvoiceOutSel.CDS_Invoice.FieldByName('IVNo').AsString;
Self.IVNo.Properties.LookupItems.Text := frmInvoiceOutSel.CDS_Invoice.FieldByName('IVID').AsString;
Self.Amount.Text := FormatFloat('#,##0.00', TaxAmount);
end
else
begin
Self.IVNo.Text := Trim(Self.IVNo.Text) + ',' + Trim(frmInvoiceOutSel.CDS_Invoice.FieldByName('IVNo').AsString);
Self.IVNo.Properties.LookupItems.Text := trim(Self.IVNo.Properties.LookupItems.Text) + ',' + Trim(frmInvoiceOutSel.CDS_Invoice.FieldByName('IVID').AsString);
Self.Amount.Text := FormatFloat('#,##0.00', CurrentAmount + TaxAmount);
end;
Self.OppCoName.Text := frmInvoiceOutSel.CDS_Invoice.FieldByName('Supplier').AsString;
Self.OppCoName.Properties.LookupItems.Text := frmInvoiceOutSel.CDS_Invoice.FieldByName('CoCode').AsString;
Self.oppShuiNo.Text := trim(frmInvoiceOutSel.CDS_Invoice.FieldByName('SupplierShuiNo').AsString);
Self.Currency.Text := frmInvoiceOutSel.CDS_Invoice.FieldByName('Currency').AsString;
OurBankName.Text := Trim(frmInvoiceOutSel.CDS_Invoice.fieldbyname('BankDeposit').AsString);
OurBankCardNo.Text := Trim(frmInvoiceOutSel.CDS_Invoice.fieldbyname('BankCardNo').AsString);
end;
CDS_Invoice.Delete;
end;
FoppShuiNoChange := '1';
end;
end;
finally
frmInvoiceOutSel.Free;
end;
end;
procedure TfrmCollectInput2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmCollectInput2.TaxNumberPropertiesChange(Sender: TObject);
begin
if FoppShuiNoChange <> '0' then
begin
InitGrid2();
Panel1.Visible := True;
end;
end;
procedure TfrmCollectInput2.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmCollectInput2.FormShow(Sender: TObject);
begin
InitGrid();
Panel1.Visible := False;
end;
procedure TfrmCollectInput2.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
function TfrmCollectInput2.SaveData(): Boolean;
var
MaxId, MaxSubId, FCoCode, FCCID: string;
CleanAmount: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FFFID) = '' then
begin
if not GetLSNo(ADOQueryCmd, MaxId, 'SK', 'Finance_Flow', 4, 1) then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxId := Trim(FFFID);
end;
FFID.Text := MaxId;
CleanAmount := StringReplace(Amount.Text, ',', '', [rfReplaceAll]);
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from Finance_Flow where FFID=''' + Trim(FFFID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FFFID) = '' then
begin
Append;
FieldByName('FillId').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
FieldByName('Filltime').Value := SGetServerDateTime(ADOQueryTemp);
FieldByName('FFFlag').Value := <><D3A6><EFBFBD><EFBFBD>';
FieldByName('FFType').Value := '<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
FieldByName('ourShuiNo').Value := '1102083046';
// FieldByName('OurCoName').Value := 'DESHINE VIETNAM CO., LTD';
FieldByName('OurCoNo').Value := 'W0001';
FieldByName('status').Value := '0';
FieldByName('FFQtyFlag').Value := -1;
end
else
begin
Edit;
FieldByName('EditId').Value := Trim(DCode);
FieldByName('Editer').Value := Trim(DName);
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('OppCoNo').Value := trim(OppCoName.Properties.LookupItems.Text);
FieldByName('IVID').Value := trim(IVNO.Properties.LookupItems.Text);
if CleanAmount <> '' then
FieldByName('Amount').AsFloat := StrToFloatDef(CleanAmount, 0);
RTSetsavedata(ADOQueryCmd, 'Finance_Flow', ScrollBox1, 2);
Post;
end;
ADOQueryCmd.Connection.CommitTrans;
FCCID := Trim(MaxSubId);
Result := True;
except
Result := false;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmCollectInput2.ScrollBox1Click(Sender: TObject);
begin
Panel1.Visible := False;
end;
procedure TfrmCollectInput2.ToolButton3Click(Sender: TObject);
begin
ToolBar1.SetFocus;
if Trim(OppCoName.Text) = '' then
begin
Application.MessageBox('<27>Է<EFBFBD><D4B7><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if Trim(Currency.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmCollectInput2.Tv1DblClick(Sender: TObject);
begin
OppCoName.Text := Trim(CDS_1.fieldbyname('CoName').AsString);
OppCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
oppShuiNo.Text := Trim(CDS_1.fieldbyname('ShuiNo').AsString);
Panel1.Visible := false;
end;
end.