RTFormwork/项目代码/RTBasicsV1/A09财务通用管理/U_PayInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

527 lines
15 KiB
ObjectPascal
Raw Permalink 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_PayInput;
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, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
dxBarBuiltInMenu, U_BaseList, cxContainer, cxCurrencyEdit, dxSkinBasic,
dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
dxSkinDarkroom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinOffice2016Colorful,
dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful,
dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven,
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue,
dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010,
dxSkinWhiteprint, dxSkinWXI, dxSkinXmas2008Blue, dxCore, cxDateUtils, cxMemo;
type
TfrmPayInput = class(TForm)
ToolBar1: TToolBar;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ToolButton3: TToolButton;
ScrollBox1: TScrollBox;
Label18: TLabel;
Label19: TLabel;
Label2: TLabel;
Label5: TLabel;
Label9: TLabel;
Label20: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label8: TLabel;
Label3: TLabel;
Label7: TLabel;
OurCoName: TcxButtonEdit;
OppCoName: TcxButtonEdit;
OppParentCoName: TcxButtonEdit;
FFTime: TcxDateEdit;
OurBankName: TcxButtonEdit;
OppBankName: TcxButtonEdit;
ConNo: TcxButtonEdit;
OrderNo: TcxButtonEdit;
FFAbstract: TcxButtonEdit;
PayMent: TcxButtonEdit;
Amount: TcxCurrencyEdit;
Currency: TcxComboBox;
Note: TcxMemo;
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 PayMentBtnDnClick(Sender: TObject);
procedure OurCoNameBtnUpClick(Sender: TObject);
procedure OurBankNameBtnUpClick(Sender: TObject);
procedure OppBankNameBtnUpClick(Sender: TObject);
procedure ConNoBtnUpClick(Sender: TObject);
procedure OrderNoBtnUpClick(Sender: TObject);
procedure OurCoNameDblClick(Sender: TObject);
procedure OurCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure ConNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure FFAbstractPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure OppCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure OppParentCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure OrderNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure OppBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
private
{ Private declarations }
procedure InitGrid();
function SaveData(): Boolean;
public
{ Public declarations }
FFFID: string;
end;
var
frmPayInput: TfrmPayInput;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel, U_BankSel, U_FinTradePlanSel,
U_FinTradeSalesContractSel;
{$R *.dfm}
procedure TfrmPayInput.InitGrid();
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, 0);
OppCoName.Properties.LookupItems.Text := Trim(ADOQueryMain.FieldByName('OppCoNo').AsString);
OurCoName.Properties.LookupItems.Text := Trim(ADOQueryMain.FieldByName('OurCoNo').AsString);
OppParentCoName.Properties.LookupItems.Text := Trim(ADOQueryMain.FieldByName('OppParentCoNo').AsString);
OurBankName.Properties.LookupItems.Text := Trim(ADOQueryMain.FieldByName('OurBankID').AsString);
end
else
begin
FFTime.Date := SGetServerDateTime(ADOQueryTemp);
end;
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmPayInput.OppBankNameBtnUpClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := self.OppCoName.Properties.LookupItems.Text;
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 TfrmPayInput.OppBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := self.OppCoName.Properties.LookupItems.Text;
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 TfrmPayInput.OppCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
if ShowModal = 1 then
begin
OppCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
OppCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
OppParentCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
OppParentCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmPayInput.OppParentCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
if ShowModal = 1 then
begin
OppParentCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
OppParentCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmPayInput.OrderNoBtnUpClick(Sender: TObject);
begin
try
frmFinTradePlanSel := TfrmFinTradePlanSel.Create(Application);
with frmFinTradePlanSel do
begin
if ShowModal = 1 then
begin
with frmFinTradePlanSel.CDS_1 do
begin
self.ConNo.Text := Trim(frmFinTradePlanSel.CDS_1.fieldbyname('ConNo').AsString);
self.OrderNo.Text := Trim(frmFinTradePlanSel.CDS_1.fieldbyname('OrderNo').AsString);
end;
end;
end;
finally
frmFinTradePlanSel.Free;
end;
end;
procedure TfrmPayInput.OrderNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmFinTradePlanSel := TfrmFinTradePlanSel.Create(Application);
with frmFinTradePlanSel do
begin
if ShowModal = 1 then
begin
with frmFinTradePlanSel.CDS_1 do
begin
self.ConNo.Text := Trim(frmFinTradePlanSel.CDS_1.fieldbyname('ConNo').AsString);
self.OrderNo.Text := Trim(frmFinTradePlanSel.CDS_1.fieldbyname('OrderNo').AsString);
end;
end;
end;
finally
frmFinTradePlanSel.Free;
end;
end;
procedure TfrmPayInput.OurBankNameBtnUpClick(Sender: TObject);
begin
try
frmBankSel := TfrmBankSel.Create(Application);
with frmBankSel do
begin
if ShowModal = 1 then
begin
OurBankName.Text := Trim(CDS_1.fieldbyname('BankName').AsString);
OurBankName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('BkID').AsString);
end;
end;
finally
frmBankSel.Free;
end;
end;
procedure TfrmPayInput.OurBankNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmBankSel := TfrmBankSel.Create(Application);
with frmBankSel do
begin
if ShowModal = 1 then
begin
OurBankName.Text := Trim(CDS_1.fieldbyname('BankName').AsString);
OurBankName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('BkID').AsString);
end;
end;
finally
frmBankSel.Free;
end;
end;
procedure TfrmPayInput.OurCoNameBtnUpClick(Sender: TObject);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>˾';
if ShowModal = 1 then
begin
OurCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
OurCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmPayInput.OurCoNameDblClick(Sender: TObject);
begin
TcxButtonEdit(Sender).Text := '';
TcxButtonEdit(Sender).Properties.LookupItems.Text := '';
end;
procedure TfrmPayInput.OurCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>˾';
if ShowModal = 1 then
begin
OurCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
OurCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmPayInput.FormDestroy(Sender: TObject);
begin
frmPayInput := nil;
end;
procedure TfrmPayInput.PayMentBtnDnClick(Sender: TObject);
begin
TBtnEditC(Sender).Text := '';
TBtnEditC(Sender).TxtCode := '';
end;
procedure TfrmPayInput.ConNoBtnUpClick(Sender: TObject);
begin
try
frmFinTradeSalesContractSel := TfrmFinTradeSalesContractSel.Create(Application);
with frmFinTradeSalesContractSel do
begin
if ShowModal = 1 then
begin
self.ConNo.Text := Trim(frmFinTradeSalesContractSel.CDS_1.fieldbyname('ConNo').AsString);
end;
end;
finally
frmFinTradeSalesContractSel.Free;
end;
end;
procedure TfrmPayInput.ConNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmFinTradeSalesContractSel := TfrmFinTradeSalesContractSel.Create(Application);
with frmFinTradeSalesContractSel do
begin
if ShowModal = 1 then
begin
self.ConNo.Text := Trim(frmFinTradeSalesContractSel.CDS_1.fieldbyname('ConNo').AsString);
end;
end;
finally
frmFinTradeSalesContractSel.Free;
end;
end;
procedure TfrmPayInput.FFAbstractPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
fsj: string;
FWZ: Integer;
begin
fsj := Trim(TEdit(Sender).Hint);
FWZ := Pos('/', fsj);
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
MainType := '<27><><EFBFBD><EFBFBD>';
flag := Copy(fsj, 1, FWZ - 1);
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
if ShowModal = 1 then
begin
TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmPayInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmPayInput.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmPayInput.FormShow(Sender: TObject);
begin
if Trim(FFFID) = '' then
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add(' select top 1 * from BS_Company where CoType=''<27><>˾'' order by CoCode ');
Open;
end;
OurCoName.Text := Trim(ADOQueryTemp.fieldbyname('CoAbbrName').AsString);
OurCoName.Properties.LookupItems.Text := Trim(ADOQueryTemp.fieldbyname('CoCode').AsString);
end;
InitGrid();
end;
procedure TfrmPayInput.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
function TfrmPayInput.SaveData(): Boolean;
var
MaxId, MaxSubId, FCoCode, FCCID: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FFFID) = '' then
begin
if not GetLSNo(ADOQueryCmd, MaxId, 'FK', 'Finance_Flow', 4, 1) then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxId := Trim(FFFID);
end;
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('FFFlag').Value := <><D3A6><EFBFBD><EFBFBD>';
FieldByName('FFType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
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('OurCoNo').Value := Trim(OurCoName.Properties.LookupItems.Text);
FieldByName('OppParentCoNo').Value := Trim(OppParentCoName.Properties.LookupItems.Text);
FieldByName('OurBankID').Value := Trim(OurBankName.Properties.LookupItems.Text);
FieldByName('FFID').Value := Trim(MaxId);
RTSetsavedata(ADOQueryCmd, 'Finance_Flow', ScrollBox1, 0);
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 TfrmPayInput.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(OurCoName.Text) = '' then
begin
Application.MessageBox('<27>ҷ<EFBFBD><D2B7><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;
end.