237 lines
5.9 KiB
ObjectPascal
237 lines
5.9 KiB
ObjectPascal
|
unit U_ZdyAttInput;
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
type
|
|||
|
TfrmZdyAttInput = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv2: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
DS_HZ: TDataSource;
|
|||
|
CDS_HZ: TClientDataSet;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v2Column2: TcxGridDBColumn;
|
|||
|
v2Column3: TcxGridDBColumn;
|
|||
|
v2Column4: TcxGridDBColumn;
|
|||
|
v2Column5: TcxGridDBColumn;
|
|||
|
v2Column7: TcxGridDBColumn;
|
|||
|
v2Column8: TcxGridDBColumn;
|
|||
|
v2Column9: TcxGridDBColumn;
|
|||
|
v2Column10: TcxGridDBColumn;
|
|||
|
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);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
function SaveData():Boolean;
|
|||
|
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
RKFlag,FCYID:String;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmZdyAttInput: TfrmZdyAttInput;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_RTFun,U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered:=False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from KH_Zdy_Attachment where ATID='''+Trim(FCYID)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain,CDS_HZ);
|
|||
|
SInitCDSData(ADOQueryMain,CDS_HZ);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
//frmZdyAttInput:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
//Action:=caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
procedure TfrmZdyAttInput.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
|||
|
InitGrid();
|
|||
|
if Trim(FCYID)='' then
|
|||
|
begin
|
|||
|
CDS_HZ.Append;
|
|||
|
CDS_HZ.Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmZdyAttInput.SaveData():Boolean;
|
|||
|
var
|
|||
|
maxId,CRID:String;
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
if Trim(FCYID)='' 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;
|
|||
|
end else
|
|||
|
begin
|
|||
|
maxId:=Trim(FCYID);
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select * from KH_Zdy_Attachment where ATID='''+Trim(FCYID)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
if Trim(FCYID)='' then
|
|||
|
begin
|
|||
|
Append;
|
|||
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
end else
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTemp);
|
|||
|
end;
|
|||
|
FieldByName('ATID').Value:=Trim(maxId);
|
|||
|
FieldByName('ZdyName').Value:=Trim(CDS_HZ.fieldbyname('ZdyName').AsString);
|
|||
|
RTSetSaveDataCDS(ADOQueryCmd,Tv2,CDS_HZ,'',0);
|
|||
|
FieldByName('Type').Value:='KHName';
|
|||
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select * from KH_Zdy where ZdyNo='''+Trim(FCYID)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
if Trim(FCYID)='' then
|
|||
|
begin
|
|||
|
Append;
|
|||
|
end else
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
end;
|
|||
|
FieldByName('ZdyNo').Value:=Trim(maxId);
|
|||
|
FieldByName('ZdyName').Value:=Trim(CDS_HZ.fieldbyname('ZdyName').AsString);
|
|||
|
FieldByName('Type').Value:='KHName';
|
|||
|
FieldByName('MainType').Value:=Trim(CDS_HZ.fieldbyname('DEFstr5').AsString);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from KH_Zdy where ZdyName='''+Trim(CDS_HZ.fieldbyname('ZdyName').AsString)+'''');
|
|||
|
sql.Add(' and Type=''KHName'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryCmd.RecordCount>1 then
|
|||
|
begin
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with CDS_HZ do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('ATID').Value:=Trim(maxId);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result:=True;
|
|||
|
except
|
|||
|
Result:=True;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInput.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if Trim(CDS_HZ.FieldByName('ZdyName').AsString)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27>ͻ<EFBFBD><CDBB><EFBFBD><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;
|
|||
|
ToolBar1.SetFocus;
|
|||
|
if SaveData() then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
ModalResult:=1;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
end.
|