7月 19, 2015

按按鍵執行跳轉

  window.onkeyup = hr;
        var keyCount = 0;
        function hr(e) {
            if (e.keyCode === 72 && keyCount === 0) {
                keyCount++;
            } else if (e.keyCode === 82 && keyCount === 1) {
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
            };
        };
        function konami(e) {
            if (e.keyCode === 38 && keyCount === 0) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 38 && keyCount === 1) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 2) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 3) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 4) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 5) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 6) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 7) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 66 && keyCount === 8) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 65 && keyCount === 9) {            
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
                
            }
        }
        

7月 18, 2015

sql用while迴圈

declare @rt nvarchar(4)
declare @rr nvarchar(4)
declare @uu int
set @uu=0
while @uu < 22 --(select count(單位代碼) from View_LiveUnit where 單位代碼 < 0242)
begin
--print @uu
select top 1 @rr=單位代碼 from View_LiveUnit order by 單位代碼 --where 單位代碼 > @rr
select top 1 @rt=單位代碼 from View_LiveUnit where 單位代碼 > @rr order by 單位代碼
print @rt
set @uu+=1
end

7月 17, 2015

sql 指標的使用方法

declare @p3 nvarchar(4);
DECLARE cs CURSOR FAST_FORWARD for select 單位代碼 from View_LiveUnit where 單位代碼 < 0242;
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
open cs;
FETCH NEXT FROM cs INTO @p3;
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,531,getdate(),0,'作業組'

)
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,532,getdate(),0,'業務組'

)
FETCH NEXT FROM cs INTO @p3;
END

CLOSE cs;
DEALLOCATE cs;
END