474 lines
12 KiB
ObjectPascal
474 lines
12 KiB
ObjectPascal
unit U_ZdyAttachGYSX_SJG;
|
||
|
||
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, cxPC, cxDropDownEdit;
|
||
|
||
type
|
||
TfrmZdyAttachGYSX_SJG = 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;
|
||
zjm: TEdit;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
Tadd: TToolButton;
|
||
TBedit: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
Label5: TLabel;
|
||
GYSNameZC: TEdit;
|
||
Panel2: TPanel;
|
||
Panel3: TPanel;
|
||
Panel4: TPanel;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
V1Column1: TcxGridDBColumn;
|
||
cxGYSName: TcxGridDBColumn;
|
||
cxGridDBGYSNameZC: TcxGridDBColumn;
|
||
B1GYSFZRen: TcxGridDBColumn;
|
||
cxGridDBGYSTel: TcxGridDBColumn;
|
||
cxGridDBGYSAdd: TcxGridDBColumn;
|
||
cxGridDBNote: TcxGridDBColumn;
|
||
V1GYSCodeFW: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
V2Column1: TcxGridDBColumn;
|
||
cxGridDBColumn11: TcxGridDBColumn;
|
||
cxGridDBColumn12: TcxGridDBColumn;
|
||
cxGridDBColumn13: TcxGridDBColumn;
|
||
cxGridDBColumn14: TcxGridDBColumn;
|
||
cxGridDBColumn15: TcxGridDBColumn;
|
||
cxGridDBColumn16: TcxGridDBColumn;
|
||
cxGridDBColumn20: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxGrid3: TcxGrid;
|
||
TV3: TcxGridDBTableView;
|
||
V3Column1: TcxGridDBColumn;
|
||
cxGridDBColumn29: TcxGridDBColumn;
|
||
cxGridDBColumn26: TcxGridDBColumn;
|
||
cxGridDBColumn28: TcxGridDBColumn;
|
||
cxGridDBColumn25: TcxGridDBColumn;
|
||
cxGridDBColumn27: TcxGridDBColumn;
|
||
cxGridDBColumn30: TcxGridDBColumn;
|
||
cxGridLevel3: TcxGridLevel;
|
||
cxGridPopupMenu3: TcxGridPopupMenu;
|
||
DS_HZ2: TDataSource;
|
||
ADOQueryMain2: TADOQuery;
|
||
CDS_HZ2: TClientDataSet;
|
||
DS_HZ3: TDataSource;
|
||
ADOQueryMain3: TADOQuery;
|
||
CDS_HZ3: TClientDataSet;
|
||
cxGridPopupMenu4: TcxGridPopupMenu;
|
||
V1Column4: TcxGridDBColumn;
|
||
V2Column4: TcxGridDBColumn;
|
||
V1GYSType: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
TCK: TToolButton;
|
||
Tchk: TToolButton;
|
||
TNochk: TToolButton;
|
||
Label4: TLabel;
|
||
V1SHStatus: TcxGridDBColumn;
|
||
status: TComboBox;
|
||
Label1: TLabel;
|
||
GYSCodeFW: TEdit;
|
||
V2ZHXX_JC: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
GYSFZRen: TEdit;
|
||
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 zjmChange(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure TBeditClick(Sender: TObject);
|
||
procedure TaddClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure TV1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
procedure TCKClick(Sender: TObject);
|
||
procedure TV1CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure TchkClick(Sender: TObject);
|
||
procedure TNochkClick(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
procedure setstatus();
|
||
|
||
public
|
||
fDEFstr5:string;
|
||
canshu1,FGYSType:string;
|
||
end;
|
||
|
||
var
|
||
frmZdyAttachGYSX_SJG: TfrmZdyAttachGYSX_SJG;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp,U_ZdyAttInputGYS_SJG, U_FjList_RZ;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmZdyAttachGYSX_SJG.setstatus();
|
||
begin
|
||
tchk.Visible:=false;
|
||
tnochk.Visible:=false;
|
||
Tadd.Visible:=false;
|
||
TBedit.Visible:=false;
|
||
TBDel.Visible:=false;
|
||
IF trim(canshu1)='<27><>Ȩ<EFBFBD><C8A8>'then
|
||
begin
|
||
Tadd.Visible:=True;
|
||
TBedit.Visible:=True;
|
||
TBDel.Visible:=True;
|
||
tchk.Visible:=True;
|
||
tNochk.Visible:=True;
|
||
end;
|
||
if Trim(canshu1)='' then
|
||
begin
|
||
Tadd.Visible:=True;
|
||
TBedit.Visible:=True;
|
||
TBDel.Visible:=True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.InitGrid();
|
||
begin
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select *,zjm=dbo.getpinyin(GYSName) ');
|
||
sql.add(',SHStatus=(case when isnull(status,''0'')=''0'' then ''δ<><CEB4><EFBFBD><EFBFBD>'' else ''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' end)');
|
||
sql.Add(' from KH_Zdy_AttachmentX ');
|
||
sql.add(' where isnull(GYSType,'''')=''<27><><EFBFBD>ӹ<EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmZdyAttachGYSX_SJG:=nil;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('SJGGYS1',Tv1,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
WriteCxGrid('SJGGYS2',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
WriteCxGrid('SJGGYS3',Tv3,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
Close;
|
||
end;
|
||
procedure TfrmZdyAttachGYSX_SJG.TBDelClick(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;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
CDS_HZ.DisableControls;
|
||
with CDS_HZ do
|
||
begin
|
||
while not eof do
|
||
begin
|
||
iF fieldbyname('ssel').AsBoolean=true then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('delete KH_Zdy_AttachmentX where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
sql.Add('delete from GYS_ZHXX where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
sql.Add('delete from GYS_LXFS where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
CDS_HZ.Delete;
|
||
end
|
||
else
|
||
next;
|
||
end;
|
||
end;
|
||
CDS_HZ.EnableControls;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.FormShow(Sender: TObject);
|
||
begin
|
||
// ReadCxGrid('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
IF trim(fDEFstr5)<>'' then
|
||
begin
|
||
end;
|
||
setstatus();
|
||
// InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
ToolBar1.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.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 TfrmZdyAttachGYSX_SJG.zjmChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
TcxGridToExcel(self.Caption,cxgrid2);
|
||
// SelExportData(Tv2,ADOQueryMain,'<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TBeditClick(Sender: TObject);
|
||
var
|
||
i:Integer;
|
||
FieldName:String;
|
||
begin
|
||
try
|
||
frmZdyAttInputGYS_SJG:=TfrmZdyAttInputGYS_SJG.Create(Application);
|
||
with frmZdyAttInputGYS_SJG do
|
||
begin
|
||
FCYID:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
if ShowModal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInputGYS_SJG.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TaddClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZdyAttInputGYS_SJG:=TfrmZdyAttInputGYS_SJG.Create(Application);
|
||
with frmZdyAttInputGYS_SJG do
|
||
begin
|
||
FCYID:='';
|
||
if ShowModal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInputGYS_SJG.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.FormCreate(Sender: TObject);
|
||
begin
|
||
canshu1:=trim(DParameters1);
|
||
FGYSType:=trim(DParameters2);
|
||
ReadCxGrid('SJGGYS1',Tv1,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
ReadCxGrid('SJGGYS2',Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
ReadCxGrid('SJGGYS3',Tv3,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
setstatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then Exit;
|
||
try
|
||
frmFjList_RZ:=TfrmFjList_RZ.Create(Application);
|
||
with frmFjList_RZ do
|
||
begin
|
||
fkeyNO:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
fType:='<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmFjList_RZ.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TV1MouseDown(Sender: TObject;
|
||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
with ADOQueryMain2 do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from GYS_ZHXX where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').asstring)+'''');
|
||
sql.Add(' order by XHNO');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain2,CDS_HZ2);
|
||
SInitCDSData20(ADOQueryMain2,CDS_HZ2);
|
||
with ADOQueryMain3 do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from GYS_LXFS where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').asstring)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain3,CDS_HZ3);
|
||
SInitCDSData20(ADOQueryMain3,CDS_HZ3);
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TCKClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZdyAttInputGYS_SJG:=TfrmZdyAttInputGYS_SJG.Create(Application);
|
||
with frmZdyAttInputGYS_SJG do
|
||
begin
|
||
FCYID:=Trim(Self.CDS_HZ.fieldbyname('ATID').AsString);
|
||
ToolBar2.Visible:=false;
|
||
ToolBar3.Visible:=false;
|
||
ToolButton3.Visible:=false;
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttInputGYS_SJG.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.TV1CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
TCK.Click;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.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_AttachmentX SET status=1,chker='''+trim(DName)+''',chkTime=getdate() ');
|
||
sql.Add('where ATID='+quotedstr(trim(CDS_HZ.fieldbyname('ATID').AsString)));
|
||
execsql;
|
||
end;
|
||
delete;
|
||
end
|
||
else
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
CDS_HZ.EnableControls;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttachGYSX_SJG.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_AttachmentX SET status=0,chker='''',chkTime=null');
|
||
sql.Add('where ATID='+quotedstr(trim(CDS_HZ.fieldbyname('ATID').AsString)));
|
||
execsql;
|
||
end;
|
||
delete;
|
||
end
|
||
else
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
CDS_HZ.EnableControls;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|
||
|