207 lines
5.0 KiB
ObjectPascal
207 lines
5.0 KiB
ObjectPascal
![]() |
unit U_AddYFGYS;
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
type
|
|||
|
TfrmAddYFGYS = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
TBsave: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
Label4: TLabel;
|
|||
|
Label5: TLabel;
|
|||
|
Label6: TLabel;
|
|||
|
Label7: TLabel;
|
|||
|
Label10: TLabel;
|
|||
|
Label11: TLabel;
|
|||
|
Label12: TLabel;
|
|||
|
Label13: TLabel;
|
|||
|
Label18: TLabel;
|
|||
|
ZdyName: TEdit;
|
|||
|
Linkman: TEdit;
|
|||
|
FaxNo: TEdit;
|
|||
|
BankName: TEdit;
|
|||
|
Note: TEdit;
|
|||
|
MobileNo: TEdit;
|
|||
|
Shortened: TEdit;
|
|||
|
TelNo: TEdit;
|
|||
|
Address: TEdit;
|
|||
|
BankNo: TEdit;
|
|||
|
Label1: TLabel;
|
|||
|
Panel2: TPanel;
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBsaveClick(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
function SaveData():Boolean;
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
FATID,FFromATID:String;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmAddYFGYS: TfrmAddYFGYS;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_Fun,U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmAddYFGYS.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered:=False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from KH_Zdy_Attachment where ATID='''+Trim(FATID)+''' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCSHDataNew(ADOQueryMain,Panel1,0);
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add(' select * from KH_Zdy_Attachment where ATID='''+Trim(FFromATID)+''' ');
|
|||
|
Open;
|
|||
|
Panel2.Caption:=Trim(FieldByName('ZdyName').AsString);
|
|||
|
end;
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmAddYFGYS.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmAddYFGYS.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmAddYFGYS.SaveData():Boolean;
|
|||
|
var
|
|||
|
fzdyCode,maxId:string;
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
if ( Trim(FATID)='' ) then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQueryCmd,maxId,'AT','KH_Zdy_Attachment',4,1)=False then
|
|||
|
begin
|
|||
|
Result:=False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if GetLSNo(ADOQueryCmd,fzdyCode,'YF','KH_Zdy_Attachment',4,0)=False then
|
|||
|
begin
|
|||
|
Result:=False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡӦ<C8A1><D3A6><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
maxId:=Trim(FATID);
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from KH_Zdy_Attachment where ATID='''+Trim(FATID)+''' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
if Trim(FATID)='' then
|
|||
|
begin
|
|||
|
Append;
|
|||
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
FieldByName('ZdyCode').Value:=Trim(fzdyCode);
|
|||
|
FieldByName('ATID').Value:=Trim(maxId);
|
|||
|
FieldByName('Type').Value:='GYS';
|
|||
|
if ( Trim(FFromATID)='' ) then
|
|||
|
FieldByName('FromATID').Value:=Trim(maxId)
|
|||
|
else
|
|||
|
FieldByName('FromATID').Value:=Trim(FFromATID);
|
|||
|
end else
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTemp);
|
|||
|
end;
|
|||
|
SSetsavedataNew(ADOQueryCmd,'KH_Zdy_Attachment',Panel1,0);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select * from KH_Zdy_Attachment where ZdyName='''+Trim(maxId)+''' ');
|
|||
|
sql.Add(' and Type=''GYS'' and Valid=''Y'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryCmd.RecordCount>1 then
|
|||
|
begin
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('Ӧ<><D3A6><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result:=True;
|
|||
|
except
|
|||
|
Result:=False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmAddYFGYS.TBsaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ZdyName.SetFocus;
|
|||
|
if Trim(ZdyName.Text)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('Ӧ<><D3A6><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
|||
|
|
|||
|
if SaveData() then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
ModalResult:=1;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
end.
|