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

10月 25, 2014

免用SQL的SqlDataAdapter的新增修改和刪除

        Dim dt As New DataTable
        Using cn As New SqlConnection(conn)
            Dim rr$ = "select * from city where id=@id"

            Dim cmds As New SqlDataAdapter(rr, cn)
            cmds.SelectCommand.Parameters.AddWithValue("id", 8)
            cmds.Fill(dt)
            Dim cb As New SqlCommandBuilder(cmds)
            '新增
            'Dim dr As DataRow = dt.NewRow
            'dr("id") = 9
            'dr("pp") = "hh"
            'dt.Rows.Add(dr)
            'dt.Rows.Add(8, "ert")'偷懶用
            '修改
            'dt.Rows(0)("city") = "666"'偷懶用
            'For Each dr As DataRow In dt.Select("id=" & 8)
            '    dr("kk") = "hello"
            'Next
            '刪除
            'dt.Rows(0).Delete()'偷懶用
            'For Each dr As DataRow In dt.Select("id=" & 8)
            '    dr.Delete()
            'Next
            cmds.Update(dt)
            cmds.Dispose()
        End Using
        GridView1.DataSource = dt
        GridView1.DataBind()

8月 25, 2014

獲得system權限

因为需要对注册表进行操作,才发现原来管理员的权限也是不够的。打开注册表下一些特殊文件夹的权限一看,发现只有SYSTEM这个身份具备所有权限。由于其他所有身份删除注册表都是被拒绝的,所以,需要切换到SYSTEM身份下。 网上又使用at指令进行操作的,发现在win7下不可行,早已升级了。 最后在管理员权限下打开cmd,输入以下命令 sc Create SuperCMD binPath= "cmd /K start" type= own type= interact sc start SuperCMD 然后win7下就会弹出一个消息,询问是否现在查看,点击立即查看,窗口会跳转到另外一个界面,这个界面就是用System身份打开的cmd,具备所有权限,然后用一下命令删除注册表的指定目标文件夹,OK reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_093A&PID_2521" /f whoami指令可以看當前用戶