393 lines
11 KiB
ObjectPascal
393 lines
11 KiB
ObjectPascal
unit U_FYDJInput;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ComCtrls, ToolWin, DB, ADODB, cxControls, cxContainer, cxEdit,
|
||
cxTextEdit, cxCurrencyEdit, BtnEdit, StdCtrls, ExtCtrls, cxStyles,
|
||
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxDBData,
|
||
cxButtonEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, DBClient, cxDropDownEdit;
|
||
|
||
type
|
||
TfrmFYDJInput = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TSAVE: TToolButton;
|
||
Tclose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label8: TLabel;
|
||
Label2: TLabel;
|
||
CRTime: TDateTimePicker;
|
||
ADOQueryTMP: TADOQuery;
|
||
ADOQueryCMD: TADOQuery;
|
||
FeeType: TComboBox;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v2Column5: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column9: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
CDS_HZ: TClientDataSet;
|
||
ADOQueryMain: TADOQuery;
|
||
DS_HZ: TDataSource;
|
||
v2Column3: TcxGridDBColumn;
|
||
ToolBar2: TToolBar;
|
||
ToolButton1: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
v2Column4: TcxGridDBColumn;
|
||
procedure TcloseClick(Sender: TObject);
|
||
procedure TSAVEClick(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FeeTypeChange(Sender: TObject);
|
||
procedure v2Column3PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure v2Column5PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
private
|
||
procedure savedata();
|
||
procedure initdata();
|
||
procedure SetComboBox();
|
||
function SaveZL():Boolean;
|
||
{ Private declarations }
|
||
public
|
||
fkeyNo: string;
|
||
fflag:integer;
|
||
fSYRName:string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmFYDJInput: TfrmFYDJInput;
|
||
|
||
implementation
|
||
|
||
uses U_ZDYHelpSel, U_ZDYHelp,U_Fun, U_ProductOrderNewList,U_DataLink;
|
||
|
||
{$R *.dfm}
|
||
function TfrmFYDJInput.SaveZL():Boolean;
|
||
var
|
||
LLNO:string;
|
||
begin
|
||
if GetLSNo(ADOQueryCMD,LLNO,'YL','YF_Money_LL',3,1)=False then
|
||
begin
|
||
ADOQueryCMD.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ');
|
||
Exit;
|
||
end;
|
||
result:=false;
|
||
try
|
||
with ADOqueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
IF Trim(CDS_HZ.fieldbyname('FeeID').AsString)<>'' then
|
||
SQL.Add('delete from YF_Money_LL where fromMainID='''+Trim(CDS_HZ.fieldbyname('FeeID').AsString)+''' ');
|
||
execsql;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from YF_Money_LL where fromMainID='''+Trim(CDS_HZ.fieldbyname('FeeID').AsString)+''' ');
|
||
Open;
|
||
append;
|
||
fieldbyname('filler').Value:=trim(Dname);
|
||
FieldByName('LLNO').Value:=Trim(LLNO);
|
||
fieldbyname('CRTime').Value:=formatdateTime('yyyy-MM-dd',CRTime.DateTime);
|
||
fieldbyname('CRType').Value:=Trim(CDS_HZ.fieldbyname('FeeName').AsString);
|
||
fieldbyname('factoryName').Value:=Trim(CDS_HZ.fieldbyname('bankNo').AsString);
|
||
// fieldbyname('TOfactoryName').Value:=Trim(CDS_HZ.fieldbyname('factoryName').AsString);
|
||
fieldbyname('NOTE').Value:=Trim(CDS_HZ.fieldbyname('note').AsString);
|
||
IF Fflag=1 then
|
||
fieldbyname('inMoney').Value:=CDS_HZ.fieldbyname('Money').AsFloat
|
||
else
|
||
fieldbyname('OutMoney').Value:=CDS_HZ.fieldbyname('Money').AsFloat;
|
||
fieldbyname('status').Value:='0';
|
||
FieldByName('fromMainID').Value:=Trim(CDS_HZ.fieldbyname('FeeID').AsString);
|
||
FieldByName('syrName').Value:=Trim(fsyrName);
|
||
Post;
|
||
end;
|
||
result:=true;
|
||
except
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.initdata();
|
||
begin
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(' select * from YF_Money_Fee ');
|
||
sql.Add(' where FeeNo='+quotedstr(trim(fkeyNo)) );
|
||
sql.Add(' and money<>0 ') ;
|
||
open;
|
||
if not IsEmpty then
|
||
begin
|
||
SCSHDataNew(ADOQueryMain,Panel1,0);
|
||
end;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.savedata();
|
||
var
|
||
MaxNo:string;
|
||
SMaxNo:string;
|
||
begin
|
||
try
|
||
ADOQueryCMD.Connection.BeginTrans;
|
||
if Trim(fkeyNo)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCMD,MaxNo,'FM','YF_Money_Fee',3,1)=False then
|
||
begin
|
||
ADOQueryCMD.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ');
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
MaxNo:=Trim(fkeyNo);
|
||
end;
|
||
with CDS_HZ do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
IF trim(CDS_HZ.FieldByName('FeeID').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCMD,SMaxNo,'FS','YF_Money_Fee',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
edit;
|
||
CDS_HZ.FieldByName('FeeID').AsString:=trim(SMaxNo);
|
||
post;
|
||
end;
|
||
with ADOQueryCMD do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add(' select * from YF_Money_Fee where FeeNo='''+Trim(MaxNo)+''' ');
|
||
SQL.Add(' and FeeID='''+Trim(CDS_HZ.FieldByName('FeeID').AsString)+''' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryCMD.IsEmpty then
|
||
begin
|
||
ADOQueryCMD.Append;
|
||
ADOQueryCMD.FieldByName('Filler').Value:=Trim(Dname);
|
||
ADOQueryCMD.FieldByName('FeeNo').Value:=Trim(MaxNo);
|
||
ADOQueryCMD.FieldByName('FeeID').Value:=Trim(CDS_HZ.FieldByName('FeeID').AsString);
|
||
end else
|
||
begin
|
||
ADOQueryCMD.Edit;
|
||
ADOQueryCMD.FieldByName('Editer').Value:=Trim(Dname);
|
||
ADOQueryCMD.FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTMP);
|
||
end;
|
||
SSetsaveSqlNew(ADOQueryCMD,'YF_Money_Fee',Panel1,0);
|
||
SSetSaveDataCDSNew(ADOQueryCMD,Tv2,CDS_HZ,'YF_Money_Fee',0);
|
||
ADOQueryCMD.FieldByName('Money').Value:=CDS_HZ.FieldByName('Money').AsFloat;
|
||
ADOQueryCMD.FieldByName('SYRName').Value:=trim(fSYRName);
|
||
ADOQueryCMD.FieldByName('FeeFlag').Value:=fflag;
|
||
IF fflag=1 then
|
||
ADOQueryCMD.FieldByName('CRType').Value:='<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
IF fflag=0 then
|
||
ADOQueryCMD.FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
ADOQueryCMD.Post;
|
||
|
||
try
|
||
with ADOqueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('delete from YF_Money_LL where fromMainID='''+Trim(CDS_HZ.fieldbyname('FeeID').AsString)+''' ');
|
||
execsql;
|
||
end;
|
||
IF (CDS_HZ.FieldByName('Money').AsFloat<>0) and
|
||
(trim(CDS_HZ.fieldbyname('bankNo').AsString)<>'') then
|
||
begin
|
||
IF not saveZL() then
|
||
begin
|
||
ADOquerycmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB><EFBFBD>ˮ<EFBFBD><CBAE>Ϣʧ<CFA2><CAA7>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
exit;
|
||
end;
|
||
end;
|
||
except
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
ADOquerycmd.Connection.CommitTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
ModalResult:=1;
|
||
except
|
||
ADOquerycmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.TcloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Self.Caption + Tv2.Name,Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.TSAVEClick(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
savedata();
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
action:=cahide;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmFYDJInput:=nil;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(Self.Caption + Tv2.Name,Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
CRTime.DateTime:=SGetServerDate10(adoqueryTmp);
|
||
SetComboBox();
|
||
initData();
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.SetComboBox();
|
||
begin
|
||
FeeType.Items.Clear;
|
||
with ADOQueryTMP do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add(' select distinct Note from KH_ZDY ');
|
||
SQL.Add(' where Type=''FeeType'' and ISNULL(Note,'''')<>'''' and zdyFlag='''+inttostr(fflag)+''' ');
|
||
Open;
|
||
while not Eof do
|
||
begin
|
||
FeeType.Items.Add(Trim(FieldByName('Note').AsString));
|
||
Next;
|
||
end;
|
||
end;
|
||
FeeType.ItemIndex:=-1;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.FeeTypeChange(Sender: TObject);
|
||
var
|
||
SMaxNo:string;
|
||
begin
|
||
CDS_HZ.EmptyDataSet;
|
||
with ADOQueryTMP do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add(' select * from KH_ZDY where Type=''FeeType'' and Note='''+Trim(FeeType.Text)+''' ');
|
||
Open;
|
||
while not Eof do
|
||
begin
|
||
if GetLSNo(ADOQueryCMD,SMaxNo,'FS','YF_Money_Fee',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with CDS_HZ do
|
||
begin
|
||
Append;
|
||
FieldByName('FeeID').Value:=Trim(SMaxNo);
|
||
FieldByName('FeeName').Value:=Trim(ADOQueryTMP.FieldByName('ZdyName').AsString);
|
||
FieldByName('BZType').Value:='RMB';
|
||
FieldByName('Money').Value:='0';
|
||
Post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.v2Column3PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(self);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:=trim(fsyrName)+'XJLLFLAG';
|
||
flagname:='<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>';
|
||
if showmodal=1 then
|
||
begin
|
||
CDS_HZ.Edit;
|
||
CDS_HZ.FieldByName('bankNo').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
CDS_HZ.Post;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.ToolButton1Click(Sender: TObject);
|
||
var
|
||
SMaxNo:string;
|
||
begin
|
||
if GetLSNo(ADOQueryCMD,SMaxNo,'FS','YF_Money_Fee',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
CDS_HZ.Append;
|
||
CDS_HZ.FieldByName('FeeID').Value:=Trim(SMaxNo);
|
||
CDS_HZ.FieldByName('BZType').Value:='RMB';
|
||
CDS_HZ.post;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
CDS_HZ.Delete;
|
||
end;
|
||
|
||
procedure TfrmFYDJInput.v2Column5PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='FeeType';
|
||
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
fnote:=True;
|
||
fZdyFlag:=True;
|
||
V1Note.Caption:='<27><><EFBFBD><EFBFBD>';
|
||
IF Showmodal=1 then
|
||
begin
|
||
CDS_HZ.edit;
|
||
CDS_HZ.fieldbyName('FeeName').AsString:=frmZDYHelp.ClientDataSet1.fieldbyName('zdyName').AsString;
|
||
CDS_HZ.fieldbyName('FeeType').AsString:=frmZDYHelp.ClientDataSet1.fieldbyName('Note').AsString;
|
||
CDS_HZ.Post;
|
||
end;
|
||
free;
|
||
end;
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
|
||
end;
|
||
|
||
end.
|