253 lines
6.3 KiB
ObjectPascal
253 lines
6.3 KiB
ObjectPascal
unit U_ZdyAttInputGYS_ZXX;
|
||
|
||
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, cxPC;
|
||
|
||
type
|
||
TfrmZdyAttInputGYS_ZXX = class(TForm)
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
Panel2: TPanel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label7: TLabel;
|
||
Label8: TLabel;
|
||
Label10: TLabel;
|
||
GYSName: TEdit;
|
||
GYSFZRen: TEdit;
|
||
GYSNameZC: TEdit;
|
||
GYSTel: TEdit;
|
||
GYSCodeFW: TMemo;
|
||
Note: TMemo;
|
||
GYSAdd: TMemo;
|
||
GYSNo: TEdit;
|
||
ToolBar1: TToolBar;
|
||
ToolButton3: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label2: TLabel;
|
||
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 }
|
||
FKHMainid,formid:String;
|
||
end;
|
||
var
|
||
frmZdyAttInputGYS_ZXX: TfrmZdyAttInputGYS_ZXX;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp,U_FjList_RZ;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.InitGrid();
|
||
begin
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+'''');
|
||
Open;
|
||
end;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
if ADOQueryMain.IsEmpty=false then
|
||
SCSHDataNew(ADOQueryMain,Panel2,2);
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmZdyAttInputGYS_ZXX:=nil;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
procedure TfrmZdyAttInputGYS_ZXX.FormShow(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
|
||
|
||
function TfrmZdyAttInputGYS_ZXX.SaveData():Boolean;
|
||
var
|
||
maxId,CRID,fzdyCode,FYSSubId,maxno,maxnum,FMXNO:String;
|
||
begin
|
||
///ȡmaxId
|
||
result:=false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
if Trim(FKHMainid)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,maxId,'KH','KH_Main',4,1)=False then
|
||
begin
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if GetLSNo(ADOQueryCmd,fzdyCode,'PB','KH_Main',4,0)=False then
|
||
begin
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
GYSNo.Text:=Trim(fzdyCode);
|
||
end else
|
||
begin
|
||
maxId:=Trim(FKHMainid);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+'''');
|
||
Open;
|
||
If IsEmpty then
|
||
begin
|
||
append;
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('fillcode').Value:=Trim(DCode);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
FieldByName('KHMainID').Value:=Trim(maxId);
|
||
FieldByName('GYSType').Value:='<27><><EFBFBD><EFBFBD>';
|
||
SSetsaveSqlNew(ADOQueryCmd,'KH_Main',Panel2,2);
|
||
post;
|
||
end;
|
||
if FKHMainid='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,maxno,'HB','KH_Sub',4,1)=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡϵ<C8A1><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IDʧ<44><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from KH_Sub where KHSubid='''+Trim(maxno)+'''');
|
||
Open;
|
||
If IsEmpty then
|
||
begin
|
||
append;
|
||
FieldByName('XHNo').Value:=1;
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
end;
|
||
FieldByName('KHSubid').Value:=Trim(maxno);
|
||
FieldByName('KHMainID').Value:=Trim(maxId);
|
||
FieldByName('KHMXName').Value:=Trim(GYSName.Text);
|
||
FieldByName('KHMXJC').Value:=Trim(GYSNameZC.Text);
|
||
FieldByName('KHMXLXR').Value:=Trim(GYSFZRen.Text);
|
||
FieldByName('KHMXTel').Value:=Trim(GYSTel.Text);
|
||
FieldByName('KHMXAdd').Value:=Trim(GYSAdd.Text);
|
||
FieldByName('KHMXSJAdd').Value:=Trim(GYSAdd.Text);
|
||
FieldByName('KHMXNo').Value:=Trim(fzdyCode);
|
||
//FieldByName('KHMXNote').Value:=Trim(Note.Text);
|
||
post;
|
||
end;
|
||
end;
|
||
FKHMainid:=maxId;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Main where GYSName='''+Trim(GYSName.Text)+'''');
|
||
sql.Add(' and GYSType=''<27><><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.RecordCount>1 then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Main where GYSNameZC='''+Trim(GYSNameZC.Text)+'''');
|
||
sql.Add(' and GYSType=''<27><><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.RecordCount>1 then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><>Ӧ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
result:=true;
|
||
end;
|
||
|
||
procedure TfrmZdyAttInputGYS_ZXX.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
Panel2.SetFocus;
|
||
IF trim(GYSName.Text)='' then
|
||
begin
|
||
application.MessageBox('<27><>Ӧ<EFBFBD>̲<EFBFBD><CCB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
if Trim(GYSNameZC.Text)='' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
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.
|