--刪除
delete from iodata_most
where (holdername = @original_員工姓名) and
(emp_number = @original_員工工號) and
(departmentno = @original_部門編號) and
(iodate = @original_出入日期) and
(@isnull_早班進入 = 1 and time1 is null or time1 = @original_早班進入) and
(@isnull_早班外出 = 1 and time2 is null or time2 = @original_早班外出) and
(@isnull_午班進入 = 1 and time3 is null or time3 = @original_午班進入) and
(@isnull_午班外出 = 1 and time4 is null or time4 = @original_午班外出) and
(@isnull_晚班進入 = 1 and time5 is null or time5 = @original_晚班進入) and
(@isnull_晚班外出 = 1 and time6 is null or time6 = @original_晚班外出)
--插入
insert into iodata_most
(holdername, emp_number, departmentno, iodate, time1, time2, time3,
time4, time5, time6, latetime, leaveearly, overtime)
values (@員工姓名,@員工工號,@部門編號,@出入日期,@早班進入,@早班外出,@午班進入,@午班外出,@晚班進入,@晚班外出,@遲到時間,@早退時間,@加班時間)
--更新
update iodata_most
set holdername = @員工姓名, emp_number = @員工工號, departmentno = @部門編號, iodate = @出入日期, time1 = @早班進入, time2 = @早班外出, time3 = @午班進入, time4 = @午班外出, time5 = @晚班進入, time6 = @晚班外出
where (holdername = @original_員工姓名) and
(emp_number = @original_員工工號) and
(departmentno = @original_部門編號) and
(iodate = @original_出入日期) and
(@isnull_早班進入 = 1 and time1 is null or time1 = @original_早班進入) and
(@isnull_早班外出 = 1 and time2 is null or time2 = @original_早班外出) and
(@isnull_午班進入 = 1 and time3 is null or time3 = @original_午班進入) and
(@isnull_午班外出 = 1 and time4 is null or time4 = @original_午班外出) and
(@isnull_晚班進入 = 1 and time5 is null or time5 = @original_晚班進入) and
(@isnull_晚班外出 = 1 and time6 is null or time6 = @original_晚班外出)