519 lines
13 KiB
ObjectPascal
519 lines
13 KiB
ObjectPascal
unit U_ZdyAttachment;
|
||
|
||
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, cxDBLookupComboBox, cxPC;
|
||
|
||
type
|
||
TfrmZdyAttachment = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
ToolButton2: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
ToolButton1: TToolButton;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
Label3: TLabel;
|
||
ZdyName: TEdit;
|
||
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;
|
||
Label1: TLabel;
|
||
ZdyCode: TEdit;
|
||
v2Column10: TcxGridDBColumn;
|
||
TBedit: TToolButton;
|
||
Label2: TLabel;
|
||
DEFstr5: TEdit;
|
||
v2Column11: TcxGridDBColumn;
|
||
v2DEFStr7: TcxGridDBColumn;
|
||
v2Column12: TcxGridDBColumn;
|
||
v2Column13: TcxGridDBColumn;
|
||
v2Column14: TcxGridDBColumn;
|
||
DEFStr7: TEdit;
|
||
Label4: TLabel;
|
||
v2Column15: TcxGridDBColumn;
|
||
v2Column16: TcxGridDBColumn;
|
||
TBuser: TToolButton;
|
||
v2Column17: TcxGridDBColumn;
|
||
cxTabControl1: TcxTabControl;
|
||
CheckBox1: TCheckBox;
|
||
v2Column19: TcxGridDBColumn;
|
||
Tchk: TToolButton;
|
||
TNochk: TToolButton;
|
||
v2Column18: TcxGridDBColumn;
|
||
v2Column20: TcxGridDBColumn;
|
||
ToolButton4: TToolButton;
|
||
ToolButton5: TToolButton;
|
||
v2Column21: TcxGridDBColumn;
|
||
v2DefFlt2: TcxGridDBColumn;
|
||
v2Column22: TcxGridDBColumn;
|
||
Edit1: TEdit;
|
||
Label7: TLabel;
|
||
Button1: TButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ZdyNameChange(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure TBeditClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure TBuserClick(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
procedure TchkClick(Sender: TObject);
|
||
procedure TNochkClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure Button1Click(Sender: TObject);
|
||
private
|
||
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
procedure setstatus();
|
||
public
|
||
fkhType:string;
|
||
canshu1:string;
|
||
end;
|
||
|
||
var
|
||
frmZdyAttachment: TfrmZdyAttachment;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp,U_ZdyAttInput,U_ZdyInput, U_FjList_RZ;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmZdyAttachment.setstatus();
|
||
begin
|
||
TBedit.Visible:=false;
|
||
TBdel.Visible:=false;
|
||
tchk.Visible:=false;
|
||
tnochk.Visible:=false;
|
||
TBuser.Visible:=false;
|
||
Label7.Visible:=false;
|
||
Edit1.Visible:=false;
|
||
Button1.Visible:=false;
|
||
v2DefFlt2.Visible:=false;
|
||
IF trim(canshu1)=''then
|
||
begin
|
||
case cxTabControl1.TabIndex of
|
||
0:begin
|
||
TBedit.Visible:=true;
|
||
TBdel.Visible:=true;
|
||
end;
|
||
1:begin
|
||
end;
|
||
end;
|
||
end
|
||
else IF trim(canshu1)='<27><>Ȩ<EFBFBD><C8A8>'then
|
||
begin
|
||
TBuser.Visible:=True;
|
||
Label7.Visible:=True;
|
||
Edit1.Visible:=true;
|
||
Button1.Visible:=true;
|
||
v2DefFlt2.Visible:=true;
|
||
case cxTabControl1.TabIndex of
|
||
0:begin
|
||
TBedit.Visible:=true;
|
||
tbdel.Visible:=True;
|
||
tchk.Visible:=True;
|
||
end;
|
||
1:begin
|
||
tNochk.Visible:=True;
|
||
end;
|
||
end;
|
||
end;
|
||
// InitGrid();
|
||
end;
|
||
|
||
|
||
|
||
procedure TfrmZdyAttachment.InitGrid();
|
||
begin
|
||
try
|
||
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * from KH_Zdy_Attachment where Type=''KHName'' ');
|
||
// sql.Add(' and isnull(khType,'''')='+quotedstr(trim(fkhType)));
|
||
IF trim(canshu1)<>'<27><>Ȩ<EFBFBD><C8A8>'then
|
||
sql.Add(' and DEFstr5='+quotedstr(trim(DName)));
|
||
if cxTabControl1.TabIndex<2 then
|
||
sql.Add(' and status='''+inttostr(cxTabControl1.TabIndex)+''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TfrmZdyAttachment.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmZdyAttachment:=nil;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
Close;
|
||
end;
|
||
procedure TfrmZdyAttachment.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then Exit;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
if Trim(CDS_HZ.fieldbyname('ATID').AsString)<>'' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('delete KH_Zdy_Attachment where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
sql.Add('delete KH_Zdy_Att_Sub where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+''' and Type=''KHName'' ');
|
||
sql.Add('delete KH_Zdy where ZdyNo='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
CDS_HZ.Delete;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
setstatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.ZdyNameChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
|
||
procedure TfrmZdyAttachment.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
TcxGridToExcel(self.Caption,cxgrid2);
|
||
// SelExportData(Tv2,ADOQueryMain,'<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TBeditClick(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
try
|
||
frmZdyAttInput:=TfrmZdyAttInput.Create(Application);
|
||
with frmZdyAttInput do
|
||
begin
|
||
FCYID:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
fkhType:=self.fkhType;
|
||
if ShowModal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInput.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZdyAttInput:=TfrmZdyAttInput.Create(Application);
|
||
with frmZdyAttInput do
|
||
begin
|
||
fkhType:=self.fkhType;
|
||
FCYID:='';
|
||
if ShowModal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInput.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TBuserClick(Sender: TObject);
|
||
var
|
||
FuserName:string;
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
frmZDYHelp:=TfrmZDYHelp.Create(self);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='UserName';
|
||
FlagName:='<27><><EFBFBD><EFBFBD>Ա';
|
||
IF showmodal=1 then
|
||
begin
|
||
FuserName:=ClientDataSet1.fieldbyname('zdyName').AsString;
|
||
end;
|
||
free;
|
||
end;
|
||
IF trim(FuserName)<>'' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update KH_Zdy_Attachment SET DEFstr5='''+trim(FuserName)+''', filler='''+trim(FuserName)+''' where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_HZ,CheckBox1.Checked);
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TchkClick(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then exit;
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
try
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
iF fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update KH_Zdy_Attachment SET status=1 ');
|
||
sql.Add('where ATID='+quotedstr(trim(CDS_HZ.fieldbyname('ATID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
CDS_HZ.EnableControls;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.TNochkClick(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then exit;
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
iF fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update KH_Zdy_Attachment SET status=0 ');
|
||
sql.Add('where ATID='+quotedstr(trim(CDS_HZ.fieldbyname('ATID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
CDS_HZ.EnableControls;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.FormCreate(Sender: TObject);
|
||
begin
|
||
canshu1:=trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
setstatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then Exit;
|
||
try
|
||
frmFjList_RZ:=TfrmFjList_RZ.Create(Application);
|
||
with frmFjList_RZ do
|
||
begin
|
||
// PState:=1;
|
||
// if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then cxButton1.Visible:=false;
|
||
fkeyNO:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
fType:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmFjList_RZ.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
try
|
||
frmZdyAttInput:=TfrmZdyAttInput.Create(Application);
|
||
with frmZdyAttInput do
|
||
begin
|
||
TBsave.Visible:=false;
|
||
ToolBar2.Visible:=false;
|
||
FCYID:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
fkhType:=self.fkhType;
|
||
if ShowModal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInput.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
TBedit.Click;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachment.Button1Click(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
try
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
If fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Zdy_Attachment ');
|
||
sql.Add('where ATID='+quotedstr(trim(CDS_HZ.fieldbyname('ATID').AsString)));
|
||
open;
|
||
edit;
|
||
Fieldbyname('defflt2').Value:=strtofloatdef(edit1.Text,0);
|
||
post;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid();
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|
||
|