258 lines
6.6 KiB
ObjectPascal
258 lines
6.6 KiB
ObjectPascal
|
|
unit U_GSInPutMain;
|
|||
|
|
|
|||
|
|
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, BtnEdit;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmGSInPutMain = class(TForm)
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
Panel2: TPanel;
|
|||
|
|
Label15: TLabel;
|
|||
|
|
Label16: TLabel;
|
|||
|
|
LabKHName: TLabel;
|
|||
|
|
Label20: TLabel;
|
|||
|
|
KHAdd: TMemo;
|
|||
|
|
KHAddEng: TMemo;
|
|||
|
|
KHName: TEdit;
|
|||
|
|
KHNameJC: TEdit;
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBSave: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
DS_HZ3: TDataSource;
|
|||
|
|
CDS_HZ3: TClientDataSet;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
KHNameEng: TEdit;
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
{ Private declarations }
|
|||
|
|
procedure InitGrid();
|
|||
|
|
function SaveData():Boolean;
|
|||
|
|
procedure initBtnColor(panel12:TPanel);
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
FKHMainid,FTSFlag,FKHFlag:String;
|
|||
|
|
end;
|
|||
|
|
var
|
|||
|
|
frmGSInPutMain: TfrmGSInPutMain;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_RTFun,U_ZDYHelp;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmGSInPutMain.InitGrid();
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
|
if ADOQueryTemp.IsEmpty=false then
|
|||
|
|
SCSHDataNew(ADOQueryTemp,Panel2,2);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmGSInPutMain.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmGSInPutMain.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
procedure TfrmGSInPutMain.FormShow(Sender: TObject);
|
|||
|
|
|
|||
|
|
begin
|
|||
|
|
KHName.SetFocus;
|
|||
|
|
InitGrid();
|
|||
|
|
if TBSave.Visible=False then
|
|||
|
|
begin
|
|||
|
|
initBtnColor(Panel2);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
procedure TfrmGSInPutMain.initBtnColor(panel12:TPanel);
|
|||
|
|
var
|
|||
|
|
i:Integer;
|
|||
|
|
begin
|
|||
|
|
with panel12 do
|
|||
|
|
begin
|
|||
|
|
for i:=0 to panel12.ControlCount-1 do
|
|||
|
|
begin
|
|||
|
|
if Controls[i] is TEdit then
|
|||
|
|
begin
|
|||
|
|
TEdit(Controls[i]).Color:=clMenu;
|
|||
|
|
TEdit(Controls[i]).ReadOnly:=True;
|
|||
|
|
end else
|
|||
|
|
if Controls[i] is TMemo then
|
|||
|
|
begin
|
|||
|
|
TMemo(Controls[i]).Color:=clMenu;
|
|||
|
|
TMemo(Controls[i]).ReadOnly:=True;
|
|||
|
|
end else
|
|||
|
|
if Controls[i] is TComboBox then
|
|||
|
|
begin
|
|||
|
|
TComboBox(Controls[i]).Color:=clMenu;
|
|||
|
|
TComboBox(Controls[i]).Enabled:=False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmGSInPutMain.SaveData():Boolean;
|
|||
|
|
var
|
|||
|
|
maxno,FGYSNO,maxnoYWY:String;
|
|||
|
|
begin
|
|||
|
|
result:=false;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
if Trim(FKHMainid)='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd,maxno,'GS','KH_Main',4,1)=False then
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>IDʧ<44><CAA7>GSKH<4B><48>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Trim(FKHFlag)='GS' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd,FGYSNO,Trim('GS'),'KH_Main',2,0)=False then
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
maxno:=Trim(FKHMainid);
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
If IsEmpty then
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
|
FieldByName('Fillercode').Value:=Trim(DCode);
|
|||
|
|
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
|
|||
|
|
FieldByName('KHNO').Value:=Trim(FGYSNO);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
|
FieldByName('EditerCode').Value:=Trim(DCode);
|
|||
|
|
FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTemp);
|
|||
|
|
end;
|
|||
|
|
FieldByName('KHMainID').Value:=Trim(maxno);
|
|||
|
|
RTSetsavedata(ADOQueryCmd,'KH_Main',Panel2,2);
|
|||
|
|
FieldByName('KHFlag').Value:=Trim(FKHFlag);
|
|||
|
|
FieldByName('Valid').Value:='Y';
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from KH_Main where KHName='''+Trim(KHName.Text)+'''');
|
|||
|
|
sql.Add(' and KHFlag='''+Trim(FKHFlag)+''' and Valid=''Y'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryCmd.RecordCount>1 then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from KH_Main where KHNameJC='''+Trim(KHNameJC.Text)+'''');
|
|||
|
|
sql.Add(' and KHFlag='''+Trim(FKHFlag)+''' and Valid=''Y'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryCmd.RecordCount>1 then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
FKHMainid:=maxno;
|
|||
|
|
result:=true;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Result:=false;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmGSInPutMain.TBSaveClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Panel2.SetFocus;
|
|||
|
|
IF trim(KHName.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><>˾<EFBFBD><CBBE><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
if Trim(KHNameJC.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
IF trim(KHNameEng.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>(Ӣ<><D3A2>)<29><><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
if Trim(KHAdd.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><>˾<EFBFBD><CBBE>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
if Trim(KHAddEng.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><>˾<EFBFBD><CBBE>ַ(Ӣ<><D3A2>)<29><><EFBFBD><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.
|