📄 gl_enter_balancesheet_d.pas
字号:
unit Gl_Enter_BalanceSheet_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, Mask, linkedit;
Type
TFrm_Gl_Enter_BalanceSheet_D = Class(TFrm_Base_Detail)
Label1: TLabel;
edt_ProjectCode: TEdit;
Label8: TLabel;
cmb_issum: TComboBox;
Label2: TLabel;
edt_assetproject: TEdit;
Label4: TLabel;
edt_lineno: TEdit;
Label5: TLabel;
edt_Firstproject: TEdit;
Label6: TLabel;
edt_lastproject: TEdit;
Label3: TLabel;
edt_oweproject: TEdit;
Label7: TLabel;
edt_lineno1: TEdit;
Label9: TLabel;
edt_Firstproject1: TEdit;
Label10: TLabel;
edt_lastproject1: TEdit;
procedure edt_linenoExit(Sender: TObject);
procedure edt_lineno1Exit(Sender: TObject);
procedure btn_okClick(Sender: TObject);
private
{ Private declarations }
public
procedure InitControls; Override;
procedure SaveData;Override;
procedure SetStatus(CurrentStatus:String;var EnableControls:String); Override;
procedure CheckInfo;
{ Public declarations }
end;
var
Frm_Gl_Enter_BalanceSheet_D: TFrm_Gl_Enter_BalanceSheet_D;
implementation
uses Sys_Global;
{$R *.DFM}
{ TFrm_Ar_Enter_Gathering_D }
procedure TFrm_Gl_Enter_BalanceSheet_D.CheckInfo;
var tMpstr,tmpkmCode,sqltext:string;
i,j:integer;
begin
if Add then
begin
if Trim(edt_ProjectCode.Text)='' then
begin
DispInfo('项目编号不能为空!',3);
edt_ProjectCode.SetFocus;
abort;
end;
Executesql(AdoQry_tmp,'select * from Gl_BalanceSheet where projectCode='+quotedstr(Trim(edt_ProjectCode.text)),0);
if AdoQry_tmp.RecordCount>0 then
begin
DispInfo('该项目编号已存在!',3);
edt_ProjectCode.SetFocus;
abort;
end;
end;
tMpstr:=Trim(edt_Firstproject.text);
while tMpstr<>'' do
begin
i:=pos('+',tMpstr);
j:=pos('-',tMpstr);
if (i=0) and (j=0) then
begin
tmpkmCode:=tMpstr;
tMpstr:='';
end
else
if (i=0) and (j<>0) then
begin
tmpkmCode:=copy(tMpstr,1,j-1);
tMpstr:=copy(tMpstr,j+1,length(tMpstr)-j);
end
else if (i<>0) and (j=0) then
begin
tmpkmCode:=copy(tMpstr,1,i-1);
tMpstr:=copy(tMpstr,i+1,length(tMpstr)-i);
end;
sqltext := IIFString(Cmb_IsSum.ItemIndex=0,
'select kmCode from Gl_AccountSubject'
+' where kmCode='+quotedstr(tmpkmCode),
'select ProjectCode from Gl_BalanceSheet '
+' where ProjectCode='+QuotedStr(TmpKmCode));
// +' and Kmlevel=1 ';
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo(IIFString(Cmb_IsSum.ItemIndex=0,'科目代码','项目编号')+quotedstr(tmpkmCode)+'错误!',3);
edt_Firstproject.SetFocus;
abort;
end;
end;
tMpstr:=Trim(edt_lastproject.text);
while tMpstr<>'' do
begin
i:=pos('+',tMpstr);
j:=pos('-',tMpstr);
if (i=0) and (j=0) then
begin
tmpkmCode:=tMpstr;
tMpstr:='';
end
else
if (i=0) and (j<>0) then
begin
tmpkmCode:=copy(tMpstr,1,j-1);
tMpstr:=copy(tMpstr,j+1,length(tMpstr)-j);
end
else if (i<>0) and (j=0) then
begin
tmpkmCode:=copy(tMpstr,1,i-1);
tMpstr:=copy(tMpstr,i+1,length(tMpstr)-i);
end;
sqltext := IIFString(Cmb_IsSum.ItemIndex=0,
'select kmCode from Gl_AccountSubject'
+' where kmCode='+quotedstr(tmpkmCode),
'select ProjectCode from Gl_BalanceSheet '
+' where ProjectCode='+QuotedStr(TmpKmCode));
// +' and Kmlevel=1 ';
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo(IIFString(Cmb_IsSum.ItemIndex=0,'科目代码','项目编号')+quotedstr(tmpkmCode)+'错误!',3);
edt_lastproject.SetFocus;
abort;
end;
end;
tMpstr:=Trim(edt_Firstproject1.text);
while tMpstr<>'' do
begin
i:=pos('+',tMpstr);
j:=pos('-',tMpstr);
if (i=0) and (j=0) then
begin
tmpkmCode:=tMpstr;
tMpstr:='';
end
else
if (i=0) and (j<>0) then
begin
tmpkmCode:=copy(tMpstr,1,j-1);
tMpstr:=copy(tMpstr,j+1,length(tMpstr)-j);
end
else if (i<>0) and (j=0) then
begin
tmpkmCode:=copy(tMpstr,1,i-1);
tMpstr:=copy(tMpstr,i+1,length(tMpstr)-i);
end;
sqltext := IIFString(Cmb_IsSum.ItemIndex=0,
'select kmCode from Gl_AccountSubject'
+' where kmCode='+quotedstr(tmpkmCode),
'select ProjectCode from Gl_BalanceSheet '
+' where ProjectCode='+QuotedStr(TmpKmCode));
// +' and Kmlevel=1 ';
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo(IIFString(Cmb_IsSum.ItemIndex=0,'科目代码','项目编号')+quotedstr(tmpkmCode)+'错误!',3);
edt_Firstproject1.SetFocus;
abort;
end;
end;
tMpstr:=Trim(edt_lastproject1.text);
while tMpstr<>'' do
begin
i:=pos('+',tMpstr);
j:=pos('-',tMpstr);
if (i=0) and (j=0) then
begin
tmpkmCode:=tMpstr;
tMpstr:='';
end
else
if (i=0) and (j<>0) then
begin
tmpkmCode:=copy(tMpstr,1,j-1);
tMpstr:=copy(tMpstr,j+1,length(tMpstr)-j);
end
else if (i<>0) and (j=0) then
begin
tmpkmCode:=copy(tMpstr,1,i-1);
tMpstr:=copy(tMpstr,i+1,length(tMpstr)-i);
end;
sqltext := IIFString(Cmb_IsSum.ItemIndex=0,
'select kmCode from Gl_AccountSubject'
+' where kmCode='+quotedstr(tmpkmCode),
'select ProjectCode from Gl_BalanceSheet '
+' where ProjectCode='+QuotedStr(TmpKmCode));
// +' and Kmlevel=1 ';
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo(IIFString(Cmb_IsSum.ItemIndex=0,'科目代码','项目编号')+quotedstr(tmpkmCode)+'错误!',3);
edt_lastproject1.SetFocus;
abort;
end;
end;
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.InitControls;
var i:integer;
begin
if (Add) then
begin
SetFocus_Control:=edt_ProjectCode;
// edt_ProjectCode.SetFocus;
end
else
SetFocus_Control:=cmb_issum;
inherited;
with AdoQry_Maintain do
begin
edt_ProjectCode.Text:=AdoQry_Maintain.fieldbyname('projectCode').asstring;
cmb_issum.ItemIndex:=AdoQry_Maintain.fieldbyname('issum').asinteger;
edt_assetproject.Text:=AdoQry_Maintain.fieldbyname('assetproject').asstring;
edt_lineno.Text:=AdoQry_Maintain.fieldbyname('plineno').asstring;
edt_Firstproject.Text:=AdoQry_Maintain.fieldbyname('Firstproject').asstring;
edt_lastproject.Text:=AdoQry_Maintain.fieldbyname('lastproject').asstring;
edt_oweproject.Text:=AdoQry_Maintain.fieldbyname('owesprossessoryproject').asstring;
edt_lineno1.Text:=AdoQry_Maintain.fieldbyname('plineno1').asstring;
edt_Firstproject1.Text:=AdoQry_Maintain.fieldbyname('Firstproject1').asstring;
edt_lastproject1.Text:=AdoQry_Maintain.fieldbyname('lastproject1').asstring;
if not Add then
begin
edt_ProjectCode.Enabled:=False;
cmb_issum.Enabled:=True;
end
else
begin
edt_ProjectCode.Enabled:=True;
cmb_issum.Enabled:=True;
edt_ProjectCode.SetFocus;
end;
end;
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.SaveData;
var sqltext:string;
AdoQry:TAdoQuery;
begin
inherited;
// CheckInfo;//检测信息
AdoQry:=TAdoQuery.Create(nil);
AdoQry.Connection:=dbconnect;
try
dbconnect.beginTrans;
if Add then
//新增
sqltext:='insert into Gl_BalanceSheet(projectCode,issum,'
+' assetproject,plineno,Firstproject,lastproject,owesprossessoryproject,plineno1,Firstproject1,lastproject1)'
+' Values('+quotedstr(Trim(edt_ProjectCode.text))+','
+inttostr(cmb_issum.Itemindex)+','
+quotedstr(Trim(edt_assetproject.text))+','
+iifstring(Trim(edt_lineno.text)='','null',Trim(edt_lineno.text))+','
+quotedstr(Trim(edt_Firstproject.text))+','
+quotedstr(Trim(edt_lastproject.text))+','
+quotedstr(Trim(edt_oweproject.text))+','
+iifstring(Trim(edt_lineno1.text)='','null',Trim(edt_lineno1.text))+','
+quotedstr(Trim(edt_Firstproject1.text))+','
+quotedstr(Trim(edt_lastproject1.text))
+')'
else
sqltext:='update Gl_BalanceSheet'
+' set assetproject='+quotedstr(Trim(edt_assetproject.text))+','
+' plineno='+iifstring(Trim(edt_lineno.text)='','null',Trim(edt_lineno.text))+','
+' Firstproject='+quotedstr(Trim(edt_Firstproject.text))+','
+' lastproject='+quotedstr(Trim(edt_lastproject.text))+','
+' owesprossessoryproject='+quotedstr(Trim(edt_oweproject.text))+','
+' plineno1='+iifstring(Trim(edt_lineno1.text)='','null',Trim(edt_lineno1.text))+','
+' Firstproject1='+quotedstr(Trim(edt_Firstproject1.text))+','
+' lastproject1='+quotedstr(Trim(edt_lastproject1.text))
+'where projectCode='+quotedstr(Trim(edt_ProjectCode.text));
if Add then
begin
Executesql(AdoQry_tmp,sqltext,1);
saveBalanceSheethistory(dbconnect,Trim(edt_ProjectCode.text),userCode,0);
end
else
begin
saveBalanceSheethistory(dbconnect,Trim(edt_ProjectCode.text),userCode,1);
Executesql(AdoQry_tmp,sqltext,1);
end;
if Assigned(AdoQry) then AdoQry.Free;
dbconnect.CommitTrans;
with AdoQry_Maintain do
begin
fieldbyname('projectCode').asstring:=Trim(edt_ProjectCode.text);
fieldbyname('issum').asinteger:=cmb_issum.ItemIndex;
fieldbyname('assetproject').asstring:=Trim(edt_assetproject.text);
if Trim(edt_lineno.text)='' then
fieldbyname('plineno').asinteger:=0
else fieldbyname('plineno').asinteger:=strtoint(Trim(edt_lineno.text));
fieldbyname('Firstproject').asstring:=Trim(edt_Firstproject.text);
fieldbyname('lastproject').asstring:=Trim(edt_lastproject.text);
fieldbyname('owesprossessoryproject').asstring:=Trim(edt_oweproject.text);
if Trim(edt_lineno1.text)='' then
fieldbyname('plineno1').asinteger:=0
else fieldbyname('plineno1').asinteger:=strtoint(Trim(edt_lineno1.text));
fieldbyname('Firstproject1').asstring:=Trim(edt_Firstproject1.text);
fieldbyname('lastproject1').asstring:=Trim(edt_lastproject1.text);
post;
end;
except
if dbconnect.InTransaction then
dbconnect.RollBackTrans;
if Assigned(AdoQry) then AdoQry.Free;
abort;
end;
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.edt_linenoExit(Sender: TObject);
begin
inherited;
if Trim(edt_lineno.text)='' then exit;
integercheck(sender);
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.edt_lineno1Exit(Sender: TObject);
begin
inherited;
if Trim(edt_lineno1.text)='' then
exit;
integercheck(sender);
end;
procedure TFrm_Gl_Enter_BalanceSheet_D.btn_okClick(Sender: TObject);
begin
CheckInfo;//检测信息
inherited;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -