DECLARE cs_emp CURSOR FOR
SELECT emp_code FROM t_emp where dept_code like :ls_find_dept and leave_flag="N" order by emp_code;
open cs_emp;
if sqlca.sqlcode < 0 then
Messagebox("Êý¾Ý¿â´í","ÓαêÎÞ·¨Ö´ÐÐ!" + sqlca.sqlerrtext)
return sqlca.sqlcode
end if
fetch cs_emp into :ls_emp_code;
do while sqlca.sqlcode = 0 //°´²¿ÃÅÄÚµÄÔ±¹¤
Delete from t_leave where emp_code = :ls_emp_code and datediff(day,startdate,:ld_date_start) <=0 and datediff(day,startdate,:ld_date_end) >=0 ;
For li_2 = 0 To DaysAfter(ld_date_start,ld_date_end)
is_cur_date = RelativeDate(ld_date_start,li_2)
if is_cur_date = ld_date_start then // µÚÒ»Ìì
wf_get_leavehour()
insert into t_leave(emp_code,startdate,enddate,startime,endtime,leave_type,reason,leave_day,leave_hour)
values(:ls_emp_code,:is_cur_date,:is_cur_date,:ls_startime,'1730',:ls_leavetype,:ls_reason,:ide_days2,:ide_hours2);
commit;
elseif is_cur_date = ld_date_end then //×îºóÒ»Ìì
wf_get_leaveend()
insert into t_leave(emp_code,startdate,enddate,startime,endtime,leave_type,reason,leave_day,leave_hour)
values(:ls_emp_code,:is_cur_date,:is_cur_date,'0800',:ls_endtime,:ls_leavetype,:ls_reason,:ide_days1,:ide_hours1);
commit;
else //ÖмäµÄ
insert into t_leave(emp_code,startdate,enddate,startime,endtime,leave_type,reason,leave_day,leave_hour)
values(:ls_emp_code,:is_cur_date,:is_cur_date,'0800','1730',:ls_leavetype,:ls_reason,'1','8');
commit;
end if
next
fetch cs_emp into :ls_emp_code;
loop
close cs_emp;