📄 pfm_accept.pas
字号:
//table2.IndexFields
AddBackUpFields(stable.Strings[hastable[i]]);
if stable.Strings[hastable[i]]<>'pub_z_part' then
table2.tablename:=stable.Strings[hastable[i]]
else
table2.tablename:='temp_z_part';
table3.tablename:=filepath+stable.Strings[hastable[i]]+'.db';
batmove1.Execute;
if stable.Strings[hastable[i]]='pub_z_part' then
DealPartInfo();
cnt1:=cnt1+1;
//将接收记录保存进数据库
//WriteRecord(stable.Strings[i]);
end;
end;
//if cnt1=0 then exit;
memo1.lines.add('数据库恢复成功!共有'+inttostr(cnt1)+'个数据库表');
end;
procedure Tfm_databack.BBtnSelallClick(Sender: TObject);
var
i:integer;
begin
for i:=0 to cklbox1.items.count-1 do
begin
cklbox1.Checked[i]:=true;
end;
end;
procedure Tfm_databack.BBtnNoallClick(Sender: TObject);
var
i:integer;
begin
for i:=0 to cklbox1.items.count-1 do
begin
cklbox1.Checked[i]:=false;
end;
end;
function Tfm_databack.Choosestyle():boolean;
begin
if radiogroup1.ItemIndex =0 then
begin
backStyle:='日';
backTime:=datetostr(today);
result:=true;
end
else if radiogroup1.ItemIndex =1 then
begin
backStyle:='月';
backTime:=floattostr(yearof(today))+'-'+floattostr(monthof(today)) ;
result:=true;
end
else if radiogroup1.ItemIndex =2 then
begin
backStyle:='年';
backTime:=floattostr(yearof(today));
Result:=true;
end
else
begin
//showmessage(datetostr(year)+'-'+datetostr(month)+'-00');
if backstyle='' then
begin
showmessage('请选择上报类型');
result:=false;
end
else
begin
if backstyle='年' then
begin
if combobox1.Text ='' then
begin
showmessage('请选择或者输入年份');
combobox1.SetFocus ;
result:=false;
exit;
end
else
begin
backTime:=combobox1.Text ;
Result:=true;
exit;
end;
end;
if backstyle='月' then
begin
if combobox1.Text ='' then
begin
showmessage('请选择年份');
combobox1.SetFocus ;
result:=false;
exit;
end;
if combobox2.Text ='' then
begin
showmessage('请选择月份');
combobox2.SetFocus ;
result:=false;
exit;
end;
backTime:= combobox1.Text+'-'+combobox2.Text ;
result:=true;
end;
if backstyle='日' then
begin
if combobox1.Text ='' then
begin
showmessage('请选择年份');
combobox1.SetFocus ;
result:=false;
exit;
end;
if combobox2.Text ='' then
begin
showmessage('请选择月份');
combobox2.SetFocus ;
result:=false;
exit;
end;
if combobox3.Text ='' then
begin
showmessage('请选择日期');
combobox3.SetFocus ;
result:=false;
exit;
end;
backTime:=combobox1.Text+'-'+combobox2.Text+'-'+combobox3.Text ;
result:=true;
end;
end;
end;
end;
function Tfm_databack.GetSql (i:integer):string;
var
tempstr:string;
tempYear:string;
tempMonth:string;
tempDay:string;
begin
tempYear:=floattostr(yearof(today));
tempMonth:=floattostr(monthof(today));
tempDay:=floattostr(dayof(today));
if radiogroup1.ItemIndex =0 then
begin
tempstr:=backTime;
//result:= ' where year('+stimename.Strings[i]+')='''+ tempstr+'''';
result:= ' where year('+stimename.Strings[i]+')='
+tempYear + ' and month('+
stimename.Strings[i]+')='+tempMonth
+' and day('+
stimename.Strings[i]+')='+tempDay
end
else if radiogroup1.ItemIndex =1 then
begin
tempstr:=backTime ;
result:= ' where year('+stimename.Strings[i]+')='
+tempYear + ' and month('+
stimename.Strings[i]+')='+tempMonth
end
else if radiogroup1.ItemIndex =2 then
begin
tempstr:=backTime;
Result:= ' where year('+
stimename.Strings[i]+')='+tempYear;
end
else
begin
if backstyle='年' then
begin
tempstr:=combobox1.Text ;
Result:= ' where year('+
stimename.Strings[i]+')='+combobox1.Text;
end;
if backstyle='月' then
begin
tempstr:= combobox1.Text+'-'+combobox2.Text ;
result:= ' where year('+stimename.Strings[i]+')='
+combobox1.Text + ' and month('+
stimename.Strings[i]+')='+combobox2.Text;
end;
if backstyle='日' then
begin
tempstr:=combobox1.Text+'-'+combobox2.Text+'-'+combobox3.Text ;
result:= ' where year('+stimename.Strings[i]+')='
+combobox1.Text + ' and month('+
stimename.Strings[i]+')='+combobox2.Text
+' and day('+
stimename.Strings[i]+')='+combobox3.Text;
//result:= ' where '+stimename.Strings[i]+'='''+ tempstr+'''';
end;
end;
//showmessage(datetostr(year)+'-'+datetostr(month)+'-00');
end;
function Tfm_databack.IfGetBefore(tempName:string):boolean;
var
tempSql:string;
begin
Query1.Close ;
Query1.SQL.Clear ;
tempSql:='select * from pub_z_acceptrecord where 办事处='''+fromoffice+''' and 上报内容='''+
backtime+''' and 上报表名='''+tempName+'''' ;
//showmessage(tempsql);
Query1.SQL.Add(tempSql);
query1.Active :=true;
//ery1.first;
if query1.findfirst=false then
Begin
result:=false;
//showmessage('该表已经接收了,是否要删除原来的记录重新接收?')
end
else
begin
//showmessage('确定要接收该记录');
LastBackTime:=query1.fieldbyname('上报时间').AsString ;
// showmessage( LastBackTime);
result:=true;
end;
query1.Active :=false;
end;
procedure Tfm_databack.DeleteFormerRecord(tempName:string;i:integer);
var
tempSql:string;
tempStr:string;
tempLength:integer;
begin
query1.Active :=false;
query1.SQL.Clear ;
if (tempName<>'partleft') and (tempName<>'std_machine') then
begin
if backstyle='年' then
begin
if fromoffice<>'总部' then
tempSql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and year('+
stimename.Strings[i]+')='+backtime
else
tempSql:='delete from '+tempName+' where year('+ stimename.Strings[i]+')='+backtime
end
else if backstyle='月' then
begin
if fromoffice<>'总部' then
tempSql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and year('+
stimename.Strings[i]+')='+midstr(backtime,1,4) + ' and month('+
stimename.Strings[i]+')='+midstr(backtime,6,length(backtime)-5)
else
tempSql:='delete from '+tempName+' where year('+
stimename.Strings[i]+')='+midstr(backtime,1,4) + ' and month('+
stimename.Strings[i]+')='+midstr(backtime,6,length(backtime)-5)
end
//tempSql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and year('+
//stimename.Strings[i]+')='+midstr(backtime,1,4) + ' and month('+
//stimename.Strings[i]+')='+midstr(backtime,6,length(backtime)-5)
else
begin
if fromoffice<>'总部' then
begin
tempsql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and '
+stimename.Strings[i] + '='''+ backtime +'''';
if leftstr(rightstr(backtime,2),1)='-' then
begin
tempstr:=rightstr(backtime,1);
tempLength:=2;
end
else
begin
tempstr:=rightstr(backtime,2);
tempLength:=3;
end;
tempSql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and year('+
stimename.Strings[i]+')='+midstr(backtime,1,4) + ' and month('+
stimename.Strings[i]+')='+midstr(backtime,6,length(backtime)-5-tempLength)
+' and day('+ stimename.Strings[i]+')='+tempstr;
end
else
begin
tempsql:='delete from '+tempName+' where '+stimename.Strings[i] + '='''+ backtime +'''';
if leftstr(rightstr(backtime,2),1)='-' then
begin
tempstr:=rightstr(backtime,1);
tempLength:=2;
end
else
begin
tempstr:=rightstr(backtime,2);
tempLength:=3;
end;
tempSql:='delete from '+tempName+' where year('+
stimename.Strings[i]+')='+midstr(backtime,1,4) + ' and month('+
stimename.Strings[i]+')='+midstr(backtime,6,length(backtime)-5-tempLength)
+' and day('+ stimename.Strings[i]+')='+tempstr;
end;
END;
end
else
if tempName='partleft' then
tempSql:='delete from partleft where 办事处='''+ fromoffice+''''
else
tempSql:='truncate table std_machine';
//showmessage(tempsql);
//showmessage(tempsql);
query1.SQL.Add(tempSql);
query1.ExecSQL ;
//query1.Active :=false;
end;
procedure Tfm_databack.ModifyRecord(tableName:string;i:integer);
var
tempSql:string;
begin
query1.Active :=false;
query1.SQL.Clear ;
if (tableName<>'partleft') and (tableName<>'std_machine') then
begin
tempSql:='update '+ tableName +' set 上报时间='''+fromtime+''' '+ getsql(i);
query1.SQL.Add(tempSql);
end
else
begin
tempSql:='truncate table partleft';
query1.SQL.Add(tempSql);
query1.SQL.clear;
tempsql:='update pub_z_part set 办事处=''' + unit_wxp.myOffice +'''';
query1.SQL.Add(tempSql);
end;
//showmessage(tempsql);
query1.ExecSQL ;
//query1.Active :=false;
//table1.SQL.Add('select * from '+ stable.Strings[i]+ getsql(i));
end;
procedure Tfm_databack.WriteRecord (tableName:string);
var
i:integer;
tempSql:string;
begin
if backstyle='年' then
begin
for i:=1 to 12 do
begin
if GetBefore=false then
tempSql:='insert into pub_z_acceptrecord (上报时间,办事处,上报人,上报内容, 上报表名) '+
' values ('''+FromTime+''','''+FromOffice+''','''+FromUser+''','''+backtime+inttostr(i)+''','''+
tableName+''')'
else
begin
tempSql:='update '+tablename+' set 上报人='''+ fromUser+ ''',上报时间='''+
FromTime+''' where 上报内容='''+backtime+inttostr(i)+'''';
query1.Active :=false;
query1.SQL.Clear ;
//tempSql:='delete from '+tempName+' where 办事处='''+fromoffice+''' and 上报时间='''+
//backtime+'''';
query1.SQL.Add(tempSql);
query1.ExecSQL ;
end;
//query1.Active :=false;
end;
end
else
begin
if GetBefore=false then
tempSql:='insert into pub_z_acceptrecord (上报时间,办事处,上报人,上报内容, 上报表名) '+
' values ('''+FromTime+''','''+FromOffice+''','''+FromUser+''','''+backtime+''','''+
tableName+''')'
else
tempSql:='update pub_z_acceptrecord set 上报人='''+ fromUser+ ''',上报时间='''+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -