496 lines
12 KiB
ObjectPascal
496 lines
12 KiB
ObjectPascal
unit U_ZdyAttInputXH;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ExtCtrls, cxPC, cxControls, ComCtrls, ToolWin, StdCtrls, Menus,
|
||
cxTextEdit, cxCurrencyEdit, BtnEdit, cxContainer, cxEdit, cxImage, DB, ADODB,
|
||
cxDBEdit, cxLookAndFeelPainters, cxButtons, IdBaseComponent, IdComponent,
|
||
IdTCPConnection, IdTCPClient, IdFTP, ShellAPI, strutils, cxGraphics,
|
||
cxLookAndFeels;
|
||
|
||
type
|
||
TfrmZdyAttInputXH = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
Tsave: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
GroupBox1: TGroupBox;
|
||
Label1: TLabel;
|
||
zdyCode: TEdit;
|
||
Label2: TLabel;
|
||
zdyName: TEdit;
|
||
Label6: TLabel;
|
||
defnote1: TEdit;
|
||
Label13: TLabel;
|
||
Label17: TLabel;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
N3: TMenuItem;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
ADOQueryImage: TADOQuery;
|
||
ADOQuerymain: TADOQuery;
|
||
Picture4: TcxDBImage;
|
||
FileName: TcxButton;
|
||
IdFTP1: TIdFTP;
|
||
DataSource1: TDataSource;
|
||
note: TMemo;
|
||
Label7: TLabel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
defstr1: TEdit;
|
||
defstr2: TEdit;
|
||
Label5: TLabel;
|
||
Label8: TLabel;
|
||
defnote2: TBtnEditA;
|
||
Label9: TLabel;
|
||
defnote5: TBtnEditA;
|
||
defstr3: TBtnEditA;
|
||
Label10: TLabel;
|
||
defnote6: TBtnEditA;
|
||
Label11: TLabel;
|
||
DEFStr4: TComboBox;
|
||
Label12: TLabel;
|
||
DJ: TEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TsaveClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure cxDBImage1DblClick(Sender: TObject);
|
||
procedure FileNameClick(Sender: TObject);
|
||
procedure defnote2BtnClick(Sender: TObject);
|
||
procedure defnote5BtnClick(Sender: TObject);
|
||
procedure defstr3BtnClick(Sender: TObject);
|
||
procedure defnote6BtnClick(Sender: TObject);
|
||
private
|
||
function savedata(): Boolean;
|
||
procedure InitGrid();
|
||
procedure InitImage();
|
||
{ Private declarations }
|
||
public
|
||
canshu1: string;
|
||
FATID, FHXType: string;
|
||
Fflag: integer;
|
||
fFlileFlag, UserDataFlag: string;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmZdyAttInputXH: TfrmZdyAttInputXH;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun10, U_ZDYHelp, getpic, U_KHListSelJJ;
|
||
{$R *.dfm}
|
||
|
||
function TfrmZdyAttInputXH.savedata(): Boolean;
|
||
var
|
||
fzdyCode, fType: string;
|
||
begin
|
||
result := false;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
if fflag = 0 then
|
||
begin
|
||
if Trim(DEFStr4.Text) = 'ӡ<><D3A1><EFBFBD><EFBFBD>' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, fzdyCode, 'P', 'KH_Zdy_Attachment', 4, 0) = False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else if Trim(DEFStr4.Text) = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, fzdyCode, 'CSB', 'KH_Zdy_Attachment', 3, 0) = False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, fzdyCode, 'T', 'KH_Zdy_Attachment', 4, 0) = False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
zdyCode.Text := fzdyCode;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from KH_Zdy_Attachment where ATID=''' + Trim(FATID) + '''');
|
||
Open;
|
||
if IsEmpty then
|
||
begin
|
||
append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTmp);
|
||
end;
|
||
SSetsaveSqlNew(ADOQueryCmd, 'KH_Zdy_Attachment', GroupBox1, 2);
|
||
FieldByName('ATID').Value := Trim(FATID);
|
||
FieldByName('Type').Value := 'CPHX';
|
||
post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Zdy_Attachment where ZdyName=''' + Trim(zdyName.Text) + '''');
|
||
sql.Add('and Type=''CPHX'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.RecordCount > 1 then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
result := true;
|
||
except
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.InitGrid();
|
||
begin
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Zdy_Attachment A');
|
||
sql.Add('where ATID=' + quotedstr(trim(FATID)));
|
||
open;
|
||
end;
|
||
if not ADOQueryMain.IsEmpty then
|
||
begin
|
||
zdyCode.Enabled := false;
|
||
FHXType := Trim(ADOQuerymain.fieldbyname('DEFstr4').AsString);
|
||
SCSHDataNew(ADOQueryMain, GroupBox1, 2);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.InitImage();
|
||
begin
|
||
with ADOQueryImage do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File A');
|
||
sql.Add('where WBID=' + quotedstr(trim(FATID)));
|
||
sql.Add('and TFType=' + quotedstr(trim('HX')));
|
||
open;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmZdyAttInputXH := nil;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.TBCloseClick(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.FormCreate(Sender: TObject);
|
||
begin
|
||
Panel1.Align := alclient;
|
||
clearControl(GroupBox1, 2);
|
||
// canshu1 := trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.TsaveClick(Sender: TObject);
|
||
begin
|
||
if trim(DEFStr4.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
if trim(canshu1) = '<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if trim(DJ.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end;
|
||
if trim(DEFStr4.Text) <> 'ӡ<><D3A1><EFBFBD><EFBFBD>' then
|
||
begin
|
||
if trim(defnote5.Text) = '' then
|
||
begin
|
||
if trim(zdyName.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
if trim(defstr1.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
if trim(defstr2.Text) = '' then
|
||
begin
|
||
application.MessageBox('ͷ<><EFBFBD><E0B2BB>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
if trim(defstr3.Text) = '' then
|
||
begin
|
||
application.MessageBox('ҵ<><D2B5>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end;
|
||
if trim(defnote2.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from TP_File where WBID=' + quotedstr(trim(FATID)));
|
||
SQL.Add('and TFType=''HX''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTmp.IsEmpty then
|
||
begin
|
||
application.MessageBox('ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end;
|
||
if not savedata() then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
end
|
||
else
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
self.ModalResult := 1;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.FormShow(Sender: TObject);
|
||
begin
|
||
fFlileFlag := UserDataFlag + 'HX';
|
||
FHXType := '';
|
||
InitGrid();
|
||
InitImage();
|
||
if trim(canshu1) = '<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
Label12.Visible := true;
|
||
DJ.Visible := true;
|
||
end;
|
||
if fflag = 0 then
|
||
begin
|
||
zdyCode.Text := '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
if GetLSNo(ADOQueryCmd, FATID, 'HX', 'KH_Zdy_Attachment', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
DEFStr4.Enabled := False;
|
||
defnote2.ReadOnly := True;
|
||
|
||
{ IF ((trim(ADOQueryMain.FieldByName('Filler').AsString)<>trim(DName)) and (Trim(DName)<>'ADMIN')) then
|
||
begin
|
||
zdyName.Enabled:=false;
|
||
defnote1.Enabled:=false;
|
||
defstr1.Enabled:=false;
|
||
defstr2.Enabled:=false;
|
||
end; }
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.cxDBImage1DblClick(Sender: TObject);
|
||
var
|
||
sFieldName: string;
|
||
fileName: string;
|
||
begin
|
||
{
|
||
IF TcxDBImage(Sender).Picture.Height=0 then exit;
|
||
|
||
sFieldName:='D:\ͼƬ<CDBC>鿴';
|
||
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName),nil);
|
||
|
||
fileName:=adoqueryImage.fieldbyname(TcxDBImage(Sender).Hint).asstring;
|
||
|
||
sFieldName:=sFieldName+'\'+trim(fileName);
|
||
try
|
||
IdFTP1.Host := PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
;
|
||
end;
|
||
|
||
if IdFTP1.Connected then
|
||
begin
|
||
try
|
||
IdFTP1.Get('TP\'+ Trim(fileName), sFieldName,false, true);
|
||
except
|
||
Application.MessageBox('<27>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL); }
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.FileNameClick(Sender: TObject);
|
||
begin
|
||
if trim(zdyCode.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
try
|
||
FormGetPic := TFormGetPic.Create(Application);
|
||
with FormGetPic do
|
||
begin
|
||
fFlileFlag := self.fFlileFlag;
|
||
fkeyNO := trim(FATID);
|
||
pat1 := TCXbutton(Sender).Name;
|
||
pic1 := TCXbutton(Sender).Hint;
|
||
FTFType := 'HX';
|
||
// pat1:='PatFile1';
|
||
// pic1:='Picture1';
|
||
if ShowModal = 1 then
|
||
begin
|
||
// self.Timage(Tbutton(Sender).Hint).Picture.Assign(FormGetPic.Image2.Picture.Bitmap);
|
||
zdycode.Enabled := false;
|
||
end;
|
||
|
||
Release;
|
||
end;
|
||
Initimage();
|
||
except
|
||
if FormGetPic <> nil then
|
||
FormGetPic.Release;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.defnote2BtnClick(Sender: TObject);
|
||
begin
|
||
{frmZdyAttachment_Sel:=TfrmZdyAttachment_Sel.create(self);
|
||
with frmZdyAttachment_Sel do
|
||
begin
|
||
if showmodal=1 then
|
||
begin
|
||
IF trim(defnote2.Text)='' then
|
||
defnote2.Text:=trim(CDS_HZ.fieldbyname('ZdyNameZ').asstring)
|
||
else
|
||
defnote2.Text:=trim(defnote2.Text)+';'+trim(CDS_HZ.fieldbyname('ZdyNameZ').asstring);
|
||
end;
|
||
free;
|
||
end;}
|
||
try
|
||
frmKHListSelJJ := TfrmKHListSelJJ.Create(Application);
|
||
with frmKHListSelJJ do
|
||
begin
|
||
frmKHListSelJJ.canshu2 := '<27><>Ȩ<EFBFBD><C8A8>';
|
||
if ShowModal = 1 then
|
||
begin
|
||
if trim(defnote2.Text) = '' then
|
||
defnote2.Text := trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNameJC').asstring)
|
||
else
|
||
defnote2.Text := trim(defnote2.Text) + ';' + trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNameJC').asstring);
|
||
end;
|
||
end;
|
||
finally
|
||
frmKHListSelJJ.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.defnote5BtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := 'ZhikaDanwei';
|
||
flagname := '<27>ƿ<EFBFBD><C6BF><EFBFBD>λ';
|
||
if ShowModal = 1 then
|
||
begin
|
||
defnote5.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.defstr3BtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := 'YWY';
|
||
flagname := 'ҵ<><D2B5>Ա';
|
||
if ShowModal = 1 then
|
||
begin
|
||
defstr3.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputXH.defnote6BtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := 'ZhikaType';
|
||
flagname := '<27>ƿ<EFBFBD><C6BF><EFBFBD><EFBFBD><EFBFBD>';
|
||
if ShowModal = 1 then
|
||
begin
|
||
defnote6.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|