265 lines
6.4 KiB
ObjectPascal
265 lines
6.4 KiB
ObjectPascal
![]() |
unit U_ZdyAttInputGYS;
|
|||
|
|
|||
|
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
|
|||
|
TfrmZdyAttInputGYS = 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;
|
|||
|
Label14: 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;
|
|||
|
ZdyType: TComboBox;
|
|||
|
Label2: TLabel;
|
|||
|
ZYCP: TEdit;
|
|||
|
Grade: TEdit;
|
|||
|
Label3: TLabel;
|
|||
|
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;
|
|||
|
FZdyname: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmZdyAttInputGYS: TfrmZdyAttInputGYS;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmZdyAttInputGYS.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);
|
|||
|
ZdyType.Text := ADOQueryMain.fieldbyname('ZdyType').AsString;
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
|
|||
|
FZdyname := ADOQueryMain.fieldbyname('zdyname').AsString;
|
|||
|
|
|||
|
ZdyType.Items.Clear;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add('select ZDYName from KH_ZDY where type=''GYSSZ''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
ADOQueryCmd.First;
|
|||
|
while not ADOQueryCmd.Eof do
|
|||
|
begin
|
|||
|
ZdyType.Items.Add(ADOQueryCmd.fieldByName('ZDYName').AsString);
|
|||
|
ADOQueryCmd.Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInputGYS.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInputGYS.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmZdyAttInputGYS.SaveData(): Boolean;
|
|||
|
var
|
|||
|
fzdyCode, maxId, GZ: 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;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select top 1 note from KH_ZDY where Type=''GYSSZ'' and ZDYName=''' + ZdyType.Text + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
GZ := ADOQueryCmd.fieldByName('note').AsString;
|
|||
|
|
|||
|
if GetLSNo(ADOQueryCmd, fzdyCode, GZ, 'KH_Zdy_Attachment', 4, 0) = False then
|
|||
|
begin
|
|||
|
Result := False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡ<><C8A1>Ӧ<EFBFBD>̱<EFBFBD><CCB1><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(ZdyName.Text) + ''' ');
|
|||
|
sql.Add(' and Type=''GYS'' and Valid=''Y'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryCmd.RecordCount > 1 then
|
|||
|
begin
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
if (Trim(FATID) <> '') then
|
|||
|
begin
|
|||
|
if Trim(ZdyName.Text) <> FZdyname then
|
|||
|
begin
|
|||
|
if Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8><C4A3>Ƿ<EFBFBD>ͬ<EFBFBD><CDAC>Ӧ<EFBFBD><D3A6><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
begin
|
|||
|
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('update YF_Money_CR set OldFactoryName=FactoryName ,FactoryName=''' + trim(ZdyName.Text) + ''' ');
|
|||
|
sql.Add('where CRFlag=''Ӧ<><D3A6><EFBFBD><EFBFBD>'' and FactoryName=''' + Trim(FZdyname) + ''' ');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result := True;
|
|||
|
except
|
|||
|
Result := False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttInputGYS.TBsaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ZdyName.SetFocus;
|
|||
|
if Trim(ZdyName.Text) = '' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if Trim(ZdyType.Text) = '' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD>Ͳ<EFBFBD><CDB2><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.
|
|||
|
|