let _menuitem = 'zrp_dlg_ndflAdd';
dialog zrp_dlg_ndflAdd;
$if object_id('tempdb..#reestr') is not null drop table tempdb..#reestr;
create table #reestr
(
id int,
tyear int
)
;
insert into #reestr (id, tyear)
select id, tyear from zrp_pachka where uname = @@netname and convert(date,mdate) = convert(date,getdate()) ;
_begin:;
if exists (
select top 1 1
from #reestr
)
then
{
select top 1
id,
tyear
into
:_id_,
:_tyear_
from #reestr
order by 1;
Execute
{
DELETE FROM zrp_rep WHERE st = curstation;
INSERT INTO zrp_rep (st,t_id,pid,i1)
SELECT curstation, zrp_pachka_emp.auto_card, zrp_pachka_emp.pid, zrp_pachka_emp.id
FROM
zrp_pachka_emp _hintbrowser inner join
(
select auto_card, id_pachka, ndoc
from zrp_pachka_emp
where --id = @zrp_pachka_reestr_e:id
id_pachka = _id_[']
) ss
on zrp_pachka_emp.auto_card = ss.auto_card
and zrp_pachka_emp.id_pachka = ss.id_pachka
and zrp_pachka_emp.ndoc = ss.ndoc;
IF _tyear_ <= 2009 THEN
{
Error [\3 Программа поддерживает формирование \10\3 отчетности с 2010 года];
} ELSE IF _tyear_ <= 2014 THEN
{
UDF Z, "zrp_2НДФЛ_10", _id_, '1';
} ELSE
{
UDF Z, "zrp_2НДФЛ_2015", _id_, '1';
};
execute zrp_PRC_printNDFL06( 0, 100, _tyear_ );
DELETE FROM zrp_rep WHERE st = curstation;
};
}; --then
--удаление реестров
DELETE zrptb_tax
FROM
zrptb_tax
JOIN
zrp_pachka_emp ON zrptb_tax.ID_zrp_pachka_emp = zrp_pachka_emp.ID
JOIN
zrp_pachka ON zrp_pachka_emp.id_pachka = zrp_pachka.id
WHERE
zrp_pachka.id = _id_['];
DELETE zrp_pachka_emp
FROM
zrp_pachka_emp
JOIN
zrp_pachka ON zrp_pachka_emp.id_pachka = zrp_pachka.id
WHERE
zrp_pachka.id = _id_['];
DELETE FROM zrp_pachka WHERE id = _id_['];
delete #reestr
where id = _id_
and tyear = _tyear_
;
if exists (
select top 1 1
from #reestr
)
then
{
goto _begin;
};
|