?? ggjs.pas
字號:
i_record:=i_record-1;
datamodule1.ggjss.next;
datamodule1.ggjs.next;
end;
end;
end
else//重寫公式
begin
//找上月數據
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+a_month;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //如果找不到上月數據
begin //根據最新看過的數據進行
button3.click;
datamodule1.ggjsn.close;
datamodule1.ggjsn.open;
while not datamodule1.ggjsn.eof do
begin
with datamodule1.ggjss do //開始復制
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjsn.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjsn.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjsn.fieldbyname('a_jsgs').asstring;
post;
end;
datamodule1.ggjsn.next;
end;
end
else //有上月數據
begin
while i_record>0 do
begin
with datamodule1.ggjs do //開始復制上月數據
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
datamodule1.ggjss.next;
datamodule1.ggjs.Next;
end;
end;
end;
end;
end;
str:='select *from ggjs where extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+edit2.text;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
end;
procedure Tggjsb.UpDown2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
str:string;
a_month:string;
i_record:integer;
begin
button3.click;
i_record:=20;
if strtoint(edit2.text)=0 then
a_month:='12'
else
a_month:=inttostr(strtoint(edit2.text)-1);
button3.click;
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+edit2.text;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //還沒有錄入公式
if application.messagebox('本月還未輸入公式要輸入公式嗎?','程序執行確認',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)=idyes then
if application.messagebox('要帶入上月數據嗎?','程序執行確認',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)=idyes then
begin //找到上月數據
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+a_month;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //如果沒有上月數據
begin //根據最新看過的數據進行
while not datamodule1.ggjsn.eof do
begin
with datamodule1.ggjss do //開始復制
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjsn.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjsn.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
fieldbyname('a_jsgs').asstring:=datamodule1.ggjsn.fieldbyname('a_jsgs').asstring;
post;
end;
datamodule1.ggjsn.next;
end;
end
else //有上月數據
begin
while i_record>0 do
begin
with datamodule1.ggjss do //開始復制上月數據
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
end;
end;
end
else//不帶上月數據
begin //找上月數據
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+a_month;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //如果找不到上月數據
begin //根據最新看過的數據進行
datamodule1.ggjsn.close;
datamodule1.ggjsn.open;
while not datamodule1.ggjsn.eof do
begin
with datamodule1.ggjss do //開始復制
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjsn.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjsn.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjsn.fieldbyname('a_jsgs').asstring;
post;
end;
datamodule1.ggjsn.next;
end;
end
else //有上月數據
begin
while i_record>0 do
begin
with datamodule1.ggjss do //開始復制上月數據
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
end;
end;
end;
datasource1.dataset.close;
datasource1.dataset.open;
end;
procedure Tggjsb.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if datamodule1.ggjss.State in [dsinsert,dsedit] then
datamodule1.ggjss.Post;
self.release;
end;
procedure Tggjsb.Button3Click(Sender: TObject);
var
i_record:integer;
str:string;
begin
i_record:=20;
str:='select *from ggjs where a_date<';
str:=str+''''+(edit2.text+'/'+'15'+'/'+edit1.text)+'''';
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
datamodule1.ggjsn.close;
datamodule1.ggjsn.open;
while i_record>0 do
begin
with datamodule1.ggjsn do
begin
edit;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=datamodule1.ggjss.fieldbyname('a_date').asdatetime;
fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
datamodule1.ggjsn.next;
datamodule1.ggjss.next;
end;
end;
procedure Tggjsb.Button4Click(Sender: TObject);
var
str:string;
a_month:string;
i_record:integer;
begin
i_record:=20;
if strtoint(edit2.text)=0 then
a_month:='12'
else
a_month:=inttostr(strtoint(edit2.text)-1);
button3.click;
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+edit2.text;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //還沒有錄入公式
begin
// if application.messagebox('本月還未輸入公式要輸入公式嗎?','程序執行確認',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)=idyes then
//begin
if application.messagebox('要重新輸入公式嗎?','程序執行確認',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)<>idyes then
begin// 不重新輸入公式
//找上月數據
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+a_month;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //如果沒有上月數據
begin //根據最新看過的數據進行
button3.click;
if datamodule1.ggjsn.state in [dsinsert,dsedit] then
datamodule1.ggjsn.post;
datamodule1.ggjsn.close;
datamodule1.ggjsn.open;
// showmessage(inttostr(datamodule1.ggjsn.recordcount));
while not datamodule1.ggjsn.eof do
begin
with datamodule1.ggjss do //開始復制
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjsn.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjsn.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
fieldbyname('a_jsgs').asstring:=datamodule1.ggjsn.fieldbyname('a_jsgs').asstring;
post;
end;
datamodule1.ggjsn.next;
end;
end
else //有上月數據
begin
// showmessage('有上月數據');
while i_record>0 do
begin
datamodule1.ggjs.close;
datamodule1.ggjs.open;
with datamodule1.ggjs do //開始復制上月數據
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
datamodule1.ggjss.next;
datamodule1.ggjs.next;
end;
end;
end
else//重寫公式
begin
//找上月數據
str:='select *from ggjs where Extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+a_month;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
if datamodule1.ggjss.eof then //如果找不到上月數據
begin //根據最新看過的數據進行
button3.click;
datamodule1.ggjsn.close;
datamodule1.ggjsn.open;
while not datamodule1.ggjsn.eof do
begin
with datamodule1.ggjss do //開始復制
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjsn.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjsn.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjsn.fieldbyname('a_jsgs').asstring;
post;
end;
datamodule1.ggjsn.next;
end;
end
else //有上月數據
begin
while i_record>0 do
begin
with datamodule1.ggjs do //開始復制上月數據
begin
append;
fieldbyname('a_gzcm').asstring:=datamodule1.ggjss.fieldbyname('a_gzcm').asstring;
fieldbyname('a_smdm').asstring:=datamodule1.ggjss.fieldbyname('a_smdm').asstring;
fieldbyname('a_date').asdatetime:=strtodate(edit1.text+'-'+edit2.text+'-'+'15');
//fieldbyname('a_jsgs').asstring:=datamodule1.ggjss.fieldbyname('a_jsgs').asstring;
post;
end;
i_record:=i_record-1;
datamodule1.ggjss.next;
datamodule1.ggjs.Next;
end;
end;
end;
//end;
end;
str:='select *from ggjs where extract(year from a_date)=';
str:=str+edit1.text+' and extract(month from a_date)=';
str:=str+edit2.text;
with datamodule1.ggjss do
begin
close;
sql.clear;
sql.add(str);
prepare;
open;
end;
datasource1.dataset.close;
datasource1.dataset.open;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -