C50108
  • 2019/0801/轉職成功路途開始
  • 自學心得與此網站使用方式
  • 行事曆&課程大綱
  • 2019/0224/自我檢視
  • 雜記
    • 2019/0103/雜記
    • 2019/0410/作品集建構
    • 2019/0429/職訓局書單
    • 2019/0317/自我檢視
    • 2019/0316/陪玄松去高車討論&環境圖流程圖大神們line討論
    • 2019/0305/Gitbook使用方法
  • 2018/10XX/轉職心路歷程
  • 職訓局里程碑
    • 201901
      • 2019/0103/行動商務系統設計與開發,職訓局報到
      • 2019/0104/正式開課日&行動商務課程簡介
      • 2019/0108/資料庫理論/Access&WEB開發簡介
      • 2019/0109/資料庫資料型態屬性&HTMLtag
      • 2019/0110/計概基礎概念
      • 2019/0111/HTML表格table&form表單_post/get&iframe
      • 2019/0114/計&網概概念&網路層概念
      • 2019/0115/資料庫Access運算值&CSS簡介&在職班補充
      • 2019/0116/Access比較/邏輯運算&CSS_在職班補充+選擇器+Box model
      • 2019/0117/資訊系統架構&網路層
      • 2019/0118/資料庫正規化
      • 2019/0121/計概IT分工&資料庫正規化
      • 2019/0122/網路層&CSS父子容器切版
      • 2019/0123/Access資料庫關聯&CSS position&偵錯
      • 2019/0124/C#宣告、指定運算子
      • 2019/0125/VM虛擬機_基礎介紹
      • 2019/0128/VM虛擬機架設_虛擬網卡設定&伺服器權限設置
      • 2019/0129/Wireshark查詢網路層&資料庫物件導向
      • 2019/0130/ERmod雞爪圖&C#if、for時間複雜度
      • 2019/0131/C#流程控制&變數型別
    • 201902
      • 2019/0201/系統分析與設計_資料庫ERmod&c#Homework
      • 2019/0211/ASP.NET_Webforms&物件命名空間
      • 2019/0212/定址&網路遮罩
      • 2019/0213/SQLSeverM.S.介紹&AspWebforms表單控制項
      • 2019/0214/網概乙太網路&網路安全
      • 2019/0215/Pre Javascript 基礎 & 在職班補充
      • 2019/0218/TSQL基本指令&ASP.net左右置換表格/驗證傳值
      • 2019/0219/Javascript終極密碼&musicplay&asp.net驗證器
      • 2019/0220/SS基本語法&網概line機器人
      • 2019/0221/前端Javascript musicplay、內聚力耦合率
      • 2019/0222/前端Javascript musicplay、內聚力耦合率&伺服器權限
      • 2019/0223/SqlServerHomework&第一次專案報告
      • 2019/0225/SS合併查詢&ASP.NET驗證器
      • 2019/0226/伺服器ntfs安全性權限/共用權限
      • 2019/0227/Javascript_music_play_end&ASP.net串聯SQL(datasource就是拿來串SQLServer的)
    • 201903
      • 2019/0304/SS集合運算/子查詢/exists&asp.net GridView 事件 OnRowDataBound
      • 2019/0305/SS查詢式end&ASP.NET_Gridview_自訂樣式分頁
      • 2019/0306/Javascript musicplay_really_end
      • 2019/0307/前端HTML5鑲嵌字型&伺服器網域概念
      • 2019/0308/Android Studio_基礎概念&開發環境建置
      • 2019/0311/胡中興 工業4.0講習
      • 2019/0312/安卓系統_開發基礎介紹
      • 2019/0313/安卓工作室_基礎/布局內元件
      • 2019/0314/Asp.net鏈結資料庫-查詢
      • 2019/0315/SQS DML&第二次專案報告
      • 2019/0318/SQL DDL & 伺服器 自學基礎
      • 2019/0319/Android Studio_布局內元件&佈局規劃元件
      • 2019/0320/SQL檢視表&tsql基礎&Asp.net_Gridview
      • 2019/0321/TSQL&TDM&ASP.NET_Datalist
      • 2019/0322/DOM&JQ基礎&系統分析設計PPT&在職班補充
      • 2019/0325/TMD&Asp.net上傳圖片/產生QRCode
      • 2019/0326/SQLServer_預存程序+函數&Asp.net_Webforms半自動鏈結資料庫與自動化更新
      • 2019/0327/安卓工作室_佈局規劃元件
      • 2019/0328/jQuery選擇器應用&Ajax導讀+應用&asp.net串sserver_註冊帳號功能
      • 2019/0329/ADDS伺服器架設&第三次專題報告
    • 201904
      • 2019/0401/SQL觸發程序&Asp.net自動寄信&認證信
      • 2019/0402/前端作業四-jQ應用轉換樣式&ASP.NET_FormView控制項-會員資料維護實例
      • 2019/0403/JQ事件動畫&股市&Usecase
      • 2019/0408/安卓工作室_元件/布局基本end
      • 2019/0409/安卓工作室-物件導向事件驅動實作+Homework1&2
      • 2019/0410/上午小組討論-作品集自習&Visual studio webform+MVC範本
      • 2019/0411/安卓工作室-UI觸發委派函式與控制物件
      • 2019/0412/JQ動畫實做(寶可夢遊戲開場)&第四次專題報告
      • 2019/0415/前端JQ-Ajax+JSON&後端ADO建置、主板頁面概念控制項、Bootstrap演示
      • 2019/0416/安卓工作室UI控件案例結束、IDE Eclipse_Java物件導向基礎
      • 2019/0417/伺服器網域ADDNS&416LINE討論
      • 2019/0418/SQL指標、索引&Use cace
      • 2019/0419/主頁、Webform ADO.NET Entity Fromwork 增刪修實作&第五次專題報告
      • 2019/0423/Java基礎(型別/溢位/自動強制型別轉換/鑄造物件/串流/)&I/O物件用法(底層/較不底層)
      • 2019/0424/Bootstrap_RWD基礎/應用&Asp.Net_MVC實作增刪修(修待補)
      • 2019/0425/伺服器IIS安裝&資料匯入與管理
      • 2019/0426/Asp.Net_MVC增刪修實作(補修)&bootstrap – gridsystem– 網格系統&第六次專題報告&全國技能競賽網頁設計
      • 2019/0429/物件導向技術原理方法實作
      • 2019/0430/資料庫設計應用效能調教_SQL all end&ASP.NET_MVC_Controller單元_純C無V無M操作/簡單複雜繫結
    • 201905
      • 2019/0501/內部網站辨識&外部DNS域名/IP+自架DNS伺服器理解
      • 2019/0502/Java語言基礎、物件導向基礎
      • 2019/0503/Asp.net泛型處理常式驗證圖片應用&第七次專題報告Usecase
      • 2017/0506/Bs_FlexBox&Asp.Net_MVC_View+Razor@+Viewbag+helper
      • 2019/0507/Java 物件導向_類別+函式觀念&階段性作業三
      • 2019/0508/Asp.Net_MVC_Model_ADO.NET+Entityframework+LoginMember實作+MVC觀念
      • 2019/0509/Java物件導向(函式)_儲存型態+回傳值+多載+自制+例外處理+this參照+存取+複合
      • 20919/0510/第八次專題報告=功能DEMO
      • 2019/0514/Java_靜態類別+繼承特性
      • 2019/0515/RWD Utility+Card&MVC ViewModel+CRUD(RD)
      • 2019/0516/BS form&驗證+JQ驗證 & MVC_CRUD(CU)
      • 2019/0517/ASP.NET Webform介紹Master page 主頁 & Session 簡介 & 登入login驗證 & 隱碼攻擊injection & 工具箱程式碼片段使用
      • 2019/0520/繼承&存取權特性+java作業四+字符串格式化+多形+抽象類別
      • 2019/0521/抽象類別+介面
      • 2019/0522/Bootstrap Components 元件介紹 + MVC API 概念&實作
      • 2019/0523/IIS IP限制&ASP.NET部屬
      • 2019/0524/WebApi異質程式連線方式&第九次專題報告_循序圖
      • 2019/0528/Bootstrap Components 元件介紹 + MVC 登入驗證 + 商品加入購物車 實作
      • 2019/0529/ASP.NET_MVC購物車訂單功能完成+BootstrapComponents元件介紹
      • 2019/0530/原本是伺服器的課,但拿來做專題。
      • 2019/0531/ASP.NET_WebformAllView物件功能清單&ListView實作&第十次專案報告(完整循序圖)
    • 201906
      • 2019/0603/Bootstrap Components RWD End + ASP.NET_MVC Part2 PhotoSharing CodeFirst & Model 驗證
      • 2019/0604/ASP.NET_MVC Part2 PhotoSharing Controller & Filter & ADO.NET & View@RAZOR Helper
      • 2019/0605/Java介面實作&結束+安卓工作室(整合Layout與Java)Intent意圖&Bundle包裹
      • 2019/0606/第十一次專案報告功能demo+SingnaIR+伺服器作業+端午歌唱比賽
      • 2019/0609/黃大神傳授Visual_Studio&除錯技巧
      • 2019/0610/番外篇 Web Socket 即時連線& 就業前準備與技巧
      • 2019/0611/安卓工作室_(意圖+隱含意圖)資料傳遞+Android生命週期+硬體裝置與應用
      • 2019/0612/WebSockets Notification + MVC Part2 PhotoSharing PartialView & ADO.NET & EntitySQL & VMd
      • 2019/0613/MVC Part2 PhotoSharing ViewModel & ErrorHandle
      • 2019/0614/第十二次專案報告 功能Demo
      • 2019/0618/MVC Part2 PhotoSharing Route & Sitemap & _LayOut & AJAX
      • 2019/0618/RWD在職班_(Javascript_object-oriented programming)
      • 2019/0619/安卓工作室_(硬體裝置與應用)相機操作&GPS+階段性作業6+延伸 ( APP End )
      • 2019/0620/MVC補充C#MS SQL匯入CSV+上傳CSV存入MS SQL
      • 2019/0621/第十三次專案報告 功能Demo
    • 2019/0701/最終專案報告
    • 2019/0702/結訓與家人遊台東預計0708開始找工作自學筆記應該會等工作穩定後繼續開始
  • 自學里程碑
    • 201901
      • 2019/0107/DR
      • 2019/0108/UW
      • 2019/0103/Git
      • 2019/0103/CS
      • 2019/0115/Vscode
      • 2019/0116/JSON&AJAX
      • 2019/0122/卡內基
      • 2019/0126/MBTI
      • 2019/0131/PDP 外在 內在
    • 201902
      • 2019/0217/huli_half Developer
      • 2019/0219/SEO
      • 2019/0219/雪球速讀法
    • 201903
      • 2019/0304/asp、php、jsp、asp.net、net. Framework、asp.net core
      • 2019/0329/網站架站初嘗試
    • 201904
      • 2019/0415/Datatype-Explanation
      • 2019/0416/ASP.NET_Webform&Core&MVC(MVVM/MVP)
    • 201905
      • 2019/0613/開發職訓局共同專案時遇到的問題與解法
      • 2019/0514/ASP.NET SignalR
      • 2019/0514/JS擴展-JQ、React、Vue、Angular...
      • 2019/0514/Sass&Scss
      • 2019/0514/MVC結合Webform
      • 2019/0515/ASP.NET MVC_TempData/ViewData/ViewBag
      • 2019/0522/[自學筆記]海綿體啟蒙??
Powered by GitBook
On this page
  • JSmusicplay
  • 第十次 單曲循環
  • 第十一次 隨機撥放
  • 第十二次 全曲循環撥放
  • 第十三次 資訊看板顯示時間
  • 第十四次 歌曲循環功能(單曲/隨機/全曲)
  • 第十五次 進度條顯示
  • 第十六次 進度條操作
  • 第十七次 調整耦合/內聚
  • 原始
  • 改過
  • ASP串聯SQL
  • 第一步 鏈結資料庫
  • 第二步 GUI 控制項 設計 分頁 排序修改 刪除
  • 第三步 不需要寫C#可以修改刪除分頁? 因為有處理資料控制項裡面的物件與屬性
  • 第四步 GUI輔助工具箱物件

Was this helpful?

  1. 職訓局里程碑
  2. 201902

2019/0227/Javascript_music_play_end&ASP.net串聯SQL(datasource就是拿來串SQLServer的)

JSmusicplay

自動撥放 => if ( 目前播放的時間=這首歌的長度 ){ 撥放下一首 };

第十次 單曲循環

<span id="loop">q</span>
<div id="info2"></div>
 
 <cript>
 var loop = document.getElementById("loop");
 var info2 = document.getElementById("info2");
 loop.addEventListener("click", loopSong);

//單曲循環
function loopSong() 
{
if (info2.innerText == "單曲循環")
{info2.innerText = "";}
else 
{info2.innerText = "單曲循環";}
}

判斷自身狀態 如果是開啟單曲循環中則取消 如果是取消中則開啟

第十一次 隨機撥放

<span id="random">s</span>
<div id="info2"></div>

<cript>
var random = document.getElementById("random");
var info2 = document.getElementById("info2");
random.addEventListener("click", randomSong);

//隨機播放
        function randomSong() {
            if (info2.innerText == "隨機播放") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "隨機播放";
            }
        }

第十二次 全曲循環撥放

<span id="allloop">`</span>
<div id="info2"></div>

<cript>
var allloop = document.getElementById("allloop");
var info2 = document.getElementById("info2");
allloop.addEventListener("click", allloopSong);

//全曲循環
        function allloopSong() {
            if (info2.innerText == "全曲循環") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "全曲循環";
            }
        }

第十三次 資訊看板顯示時間

<div id="duration">00:00 / 00:00</div>

function getDuration() {

Var durationTime = audio.duration 歌曲總長度
Var currebtTime = audio.currentTime目前播放的長度
取得時間值

duration.innerText = currentTime + " / " + durationTime;
顯示時間值

setTimeout(getDuration,1000);
每隔多久呼叫此功能顯示一次

}

function getTimeFormat(TimeSec) 
{
var min = Math.floor(TimeSec / 60);
var sec = Math.floor(TimeSec) - min * 60;
min = min < 10 ? "0" + min : min;
sec = sec < 10 ? "0" + sec : sec;
但預設取得的是秒數,所以要寫分秒計算

return min + ":" + sec; 重新呼叫的時候重新丟值
}

第十四次 歌曲循環功能(單曲/隨機/全曲)

目前播放時間 = 整首歌曲時間 => 歌曲播完了

單取循環時 一首歌播完時 讓歌曲回到原點播放

隨機播放 一首歌播完時 陣列裡面隨機選一首

循環播放 一首歌播完時 跳下一首 如果是最後一首就變第一首

三個功能互斥不能同時存在

上一首 下一首 變化 進度條 其實也能整合過來

if (durationTime == currentTime) 
{



if (info2.innerText == "單曲循環") 
{
audio.currentTime = 0;
audio.load();
audio.play();
}



else if (info2.innerText == "隨機播放") 
//如果else後面要加條件必須使用eles if
{
index = Math.floor(Math.random() * music.options.length);
//0~1的小數*乘上歌曲幾首並取整數 ( 只會介於0~6
//JS隨機值是給0~1的一個數 所以也須經過運算

song.src = music.options[index].value;
//運算完變化後傳值切換歌曲數值

music.options[index].selected = true;
//同時切換下拉式選單裡的歌曲曲目

audio.load();
audio.play();
//換掉曲目物件裡面的數值,並重新lord play一次





else if (music.selectedIndex == music.options.length - 1)
//目前選曲歌曲的位置 等於 陣列內歌曲的位置 = 最後一首
{
if (info2.innerText == "全曲循環") 
//當歌曲模式為全曲循環時
{
index = 0;
//回到第一首
song.src = music.options[index].value;
music.options[index].selected = true;
audio.load();
audio.play();
}
else {
StopMusic();
}
}


                
//所有模式都沒點時回到播放器最初始值
else
{
index = music.selectedIndex+1;
song.src = music.options[index].value;
music.options[index].selected = true;
audio.load();
}


}

第十五次 進度條顯示

除了隨著時間調整顯示樣式外,還可以操作(每首歌不同時間換算歌曲比例%)

雙div 一個最寬當底 一個當進度條 ,進度條隨著時間慢慢加長(改變css style),

#progress 
{
background-color: #ff6a00;
height: 20px;
width:0;
}

<div id="settime">
<div id="progress"></div>
</div>






progress.style.width = 
Math.floor(audio.currentTime / audio.duration * 100) + "%";
//現在時間 除與 歌曲長度 * 100% 

console.log(progress.style.width); 
//f12可以看到console值做偵錯

第十六次 進度條操作

傳事件

當動作mouseclick時

抓 x & y 軸 標值

以進度條為範圍

歌的總時間 * 進度條長度百分比( 滑鼠點取時的 x 值 / 600 )

settime.addEventListener("click", function () { setTimeUseBar(event); });
//當settime這個物件被點擊時傳值到event這個變數

//event = evt
function setTimeUseBar(evt) 
{
//console.log(ControlPanel.style.width);
audio.currentTime = audio.duration * (evt.offsetX / 600);
console.log(audio.currentTime);
}

寬度 = 撥放器寬度 但不知道位啥抓不到 所以給 600

evt.offsetX 從 evt這個click後抓取的數值中叫出 offsetX的值

第十七次 調整耦合/內聚

雖然 程式功能FUNCTION每個都獨立出來了,但有雖然不同名稱但內容重複的功能FUNCTION

或是 IF ELSE 改成 SWITCH CASS

ex.

上一首下一首

case n 為上一首 做完 break

case p 為下一首 做完 break

單曲循環 case s

隨機撥放 case r

全曲循環 case a

呼叫與上面同一功能 但傳不同值(參數)

什麼都不做的 case c

switch 裡面再將可以動 "不是指定值給屬性的、等號左邊、設定用" 重複的變數縮減

重複寫的程式改為只寫一次

不能重複寫的寫出來

但很容易出錯 變成不知道怎偵錯

原始

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        #ControlPanel{
            width:600px;
            margin:auto;
            border:5px solid
        }
        #FuncBtn > span {
            border: 2px solid;
            box-shadow: 3px 3px 3px black;
            cursor: pointer;
            font-family: Webdings;
            font-size: 24pt;
        }
        #volValue {
            width: 25px;
            background-color: black;
            color: yellow;
            text-align: center;
        }
        #settime{
            background-color:#808080;
            height:10px;
            cursor:pointer;
        }
        #progress {
            background-color: #ff6a00;
            height: 10px;
            width:0;
        }
    </style>
</head>
<body>

    <audio id="audio">
        <source id="song" src="music/nothing.mp3" type="audio/mpeg" />

    </audio>

    <div id="ControlPanel">
        <select id="music">
            <option value="music/nothing.mp3">Nothing Gonna Change My Love For You</option>
            <option value="music/nomouth.mp3">真的不想嘴</option>
            <option value="music/travel.mp3">帶你去旅行</option>
            <option value="music/tearshining.mp3">夏川里美-淚光閃閃</option>
            <option value="music/airball.mp3">周杰倫-告白汽球</option>
            <option value="music/sweety.mp3">汪蘇瀧&By2-有點甜</option>
            <option value="music/careyou.mp3">鄧麗君-我只在乎你</option>
        </select>

        <div id="FuncBtn">
            <span id="play">4</span>
            <!--<span id="pause">;</span>-->
            <span id="stop"><</span>
            <span id="prevsong">9</span>
            <span id="prevtime">7</span>
            <span id="nexttime">8</span>
            <span id="nextsong">:</span>
            <span id="muted">V</span>
            <span id="loop">q</span>
            <span id="random">s</span>
            <span id="allloop">`</span>

        </div>
        <div id="volume">
            <input id="vol" type="range" min="0" max="100" value="10" />
            <input id="volM" type="button" value="-" />
            <input id="volP" type="button" value="+" />
            <input id="volValue" type="text"  readonly="readonly" />
        </div>
        <div id="settime">
            <div id="progress"></div>
        </div>

        <div id="InfoPanel">
            <div id="duration">00:00 / 00:00</div>
            <marquee id="info">請按播放鈕~~~~~</marquee>
            <div id="info2"></div>
        </div>
    </div>

    <script>
        var audio = document.getElementById("audio");
        var play = document.getElementById("play");
        //var pause = document.getElementById("pause");
        var stop = document.getElementById("stop");
        var info = document.getElementById("info");
        var music = document.getElementById("music");
        var song = document.getElementById("song");
        var prevtime = document.getElementById("prevtime");
        var nexttime = document.getElementById("nexttime");
        var prevsong = document.getElementById("prevsong");
        var nextsong = document.getElementById("nextsong");

        var vol = document.getElementById("vol");
        var volM = document.getElementById("volM");
        var volP = document.getElementById("volP");
        var volValue = document.getElementById("volValue");
        var muted = document.getElementById("muted");
        var loop = document.getElementById("loop");
        var random = document.getElementById("random");
        var allloop = document.getElementById("allloop");

        var info2 = document.getElementById("info2");
        var duration = document.getElementById("duration");
        var settime = document.getElementById("settime");


        play.addEventListener("click", PlayMusic);
        //pause.addEventListener("click", PauseMusic);
        stop.addEventListener("click", StopMusic);
        music.addEventListener("change", ChangeMusic);
        prevtime.addEventListener("click", function () { TimeChange(false); });
        nexttime.addEventListener("click", function () { TimeChange(true); });
        prevsong.addEventListener("click", function () { SongChange(false); });
        nextsong.addEventListener("click", function () { SongChange(true); });
        vol.addEventListener("input", function () { VolumeChange("c"); });
        volM.addEventListener("click", function () { VolumeChange("m"); });
        volP.addEventListener("click", function () { VolumeChange("p"); });
        muted.addEventListener("click", SetMuted);
        loop.addEventListener("click", loopSong);
        random.addEventListener("click", randomSong);
        allloop.addEventListener("click", allloopSong);
        settime.addEventListener("click", function () { setTimeUseBar(event); });

        VolumeChange("c");

        function setTimeUseBar(evt) {
            //console.log(ControlPanel.style.width);
            audio.currentTime = audio.duration * (evt.offsetX / 600);
            //console.log(ControlPanel.style.width);
        }


        function getDuration() {
            var durationTime = getTimeFormat(audio.duration);
            var currentTime = getTimeFormat(audio.currentTime);
            duration.innerText = currentTime + " / " + durationTime;

            progress.style.width = Math.floor(audio.currentTime/audio.duration  * 100) + "%";
            console.log(progress.style.width);
            setTimeout(getDuration, 1000);

            if (durationTime == currentTime) {
                if (info2.innerText == "單曲循環") {
                    audio.currentTime = 0;
                    audio.load();
                    audio.play();
                }
                else if (info2.innerText == "隨機播放") {
                    index = Math.floor(Math.random() * music.options.length);
                    song.src = music.options[index].value;
                    music.options[index].selected = true;
                    audio.load();
                    audio.play();

                }
                else if (music.selectedIndex == music.options.length - 1) {
                    if (info2.innerText == "全曲循環") {
                        index = 0;
                        song.src = music.options[index].value;
                        music.options[index].selected = true;
                        audio.load();
                        audio.play();
                    }
                    else {
                        StopMusic();
                    }
                }
                else {
                    index = music.selectedIndex+1;
                    song.src = music.options[index].value;
                    music.options[index].selected = true;
                    audio.load();
                    audio.play();
                }

            }

        }


        function getTimeFormat(TimeSec) {
            var min = Math.floor(TimeSec / 60);
            var sec = Math.floor(TimeSec) - min * 60;
            min = min < 10 ? "0" + min : min;
            sec = sec < 10 ? "0" + sec : sec;
            return min + ":" + sec;
        }

        //全曲循環
        function allloopSong() {
            if (info2.innerText == "全曲循環") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "全曲循環";
            }
        }

        //隨機播放
        function randomSong() {
            if (info2.innerText == "隨機播放") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "隨機播放";
            }
        }

        //單曲循環
        function loopSong() {
            if (info2.innerText == "單曲循環") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "單曲循環";
            }
        }



        function SetMuted() {
            if (muted.innerText == "V") {
                audio.muted = true;
                muted.innerText = "U";
            }
            else {
                audio.muted = false;
                muted.innerText = "V";
            }
        }

        function VolumeChange(sound) {
            switch (sound) {
                case "m":
                    vol.value--;
                    break;
                case "p":
                    vol.value++;
                    break;

            }
            volValue.value = vol.value;

            audio.volume = volValue.value/100;
        }

        function SongChange(boolFlag) {
            music.options.length;
            if (boolFlag) {
                if (music.selectedIndex < music.options.length - 1)
                    music.selectedIndex++;
                else
                    music.selectedIndex = 0;
            }
            else {
                if (music.selectedIndex == 0)
                    music.selectedIndex = music.options.length - 1;
                else
                    music.selectedIndex--;
            }
            console.log(music.selectedIndex);
            ChangeMusic();
        }

        function TimeChange(boolFlag) {
            if (boolFlag)
                audio.currentTime += 10;
            else
                audio.currentTime -= 10;
        }


        function PlayMusic() {
            audio.play();
            getDuration();
            ShowStatus(1);
            if (play.innerText == "4")
                play.innerText = ";";
            else {
                play.innerText = "4";
                PauseMusic();
            }
        }
        function PauseMusic() {
            audio.pause();
            ShowStatus(2);
        }
      

        function StopMusic() {
            audio.pause();
            audio.load();
            play.innerText = "4";
            ShowStatus(3);
           
        }
       

        function ChangeMusic() {
            song.src = music.options[music.selectedIndex].value;
            audio.load();
            if (info.innerText == "音樂播放中")
                audio.play();
                //PlayMusic();
        }

        function ShowStatus(status) {
            var strStatus = "";

            switch (status) {
                case 1:
                    strStatus = "音樂播放中";
                    break;
                case 2:
                    strStatus = "音樂暫停";
                    break;
                case 3:
                    strStatus = "音樂停止";
                    break;
            }

            info.innerText = strStatus;
        }
    </script>
</body>
</html>

改過

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        #ControlPanel{
            width:600px;
            margin:auto;
            border:5px solid
        }
        #FuncBtn > span {
            border: 2px solid;
            box-shadow: 3px 3px 3px black;
            cursor: pointer;
            font-family: Webdings;
            font-size: 24pt;
        }
        #volValue {
            width: 25px;
            background-color: black;
            color: yellow;
            text-align: center;
        }
        #settime{
            background-color:#808080;
            height:10px;
            cursor:pointer;
        }
        #progress {
            background-color: #ff6a00;
            height: 10px;
            width:0;
        }
    </style>
</head>
<body>

    <audio id="audio">
        <source id="song" src="music/nothing.mp3" type="audio/mpeg" />

    </audio>

    <div id="ControlPanel">
        <select id="music">
            <option value="music/nothing.mp3">Nothing Gonna Change My Love For You</option>
            <option value="music/nomouth.mp3">真的不想嘴</option>
            <option value="music/travel.mp3">帶你去旅行</option>
            <option value="music/tearshining.mp3">夏川里美-淚光閃閃</option>
            <option value="music/airball.mp3">周杰倫-告白汽球</option>
            <option value="music/sweety.mp3">汪蘇瀧&By2-有點甜</option>
            <option value="music/careyou.mp3">鄧麗君-我只在乎你</option>
        </select>

        <div id="FuncBtn">
            <span id="play">4</span>
            <!--<span id="pause">;</span>-->
            <span id="stop"><</span>
            <span id="prevsong">9</span>
            <span id="prevtime">7</span>
            <span id="nexttime">8</span>
            <span id="nextsong">:</span>
            <span id="muted">V</span>
            <span id="loop">q</span>
            <span id="random">s</span>
            <span id="allloop">`</span>

        </div>
        <div id="volume">
            <input id="vol" type="range" min="0" max="100" value="10" />
            <input id="volM" type="button" value="-" />
            <input id="volP" type="button" value="+" />
            <input id="volValue" type="text"  readonly="readonly" />
        </div>
        <div id="settime">
            <div id="progress"></div>
        </div>

        <div id="InfoPanel">
            <div id="duration">00:00 / 00:00</div>
            <marquee id="info">請按播放鈕~~~~~</marquee>
            <div id="info2"></div>
        </div>
    </div>

    <script>
        var audio = document.getElementById("audio");
        var play = document.getElementById("play");
        //var pause = document.getElementById("pause");
        var stop = document.getElementById("stop");
        var info = document.getElementById("info");
        var music = document.getElementById("music");
        var song = document.getElementById("song");
        var prevtime = document.getElementById("prevtime");
        var nexttime = document.getElementById("nexttime");
        var prevsong = document.getElementById("prevsong");
        var nextsong = document.getElementById("nextsong");

        var vol = document.getElementById("vol");
        var volM = document.getElementById("volM");
        var volP = document.getElementById("volP");
        var volValue = document.getElementById("volValue");
        var muted = document.getElementById("muted");
        var loop = document.getElementById("loop");
        var random = document.getElementById("random");
        var allloop = document.getElementById("allloop");

        var info2 = document.getElementById("info2");
        var duration = document.getElementById("duration");
        var settime = document.getElementById("settime");


        play.addEventListener("click", PlayMusic);
        //pause.addEventListener("click", PauseMusic);
        stop.addEventListener("click", StopMusic);
        music.addEventListener("change", function () { ChangeMusic(music.selectedIndex); });
        prevtime.addEventListener("click", function () { TimeChange(false); });
        nexttime.addEventListener("click", function () { TimeChange(true); });
        prevsong.addEventListener("click", function () { SongChange("p"); });
        nextsong.addEventListener("click", function () { SongChange("n"); });
        vol.addEventListener("input", function () { VolumeChange("c"); });
        volM.addEventListener("click", function () { VolumeChange("m"); });
        volP.addEventListener("click", function () { VolumeChange("p"); });
        muted.addEventListener("click", SetMuted);
        loop.addEventListener("click", loopSong);
        random.addEventListener("click", randomSong);
        allloop.addEventListener("click", allloopSong);
        settime.addEventListener("click", function () { setTimeUseBar(event); });

        VolumeChange("c");

        function setTimeUseBar(evt) {
            //console.log(ControlPanel.style.width);
            audio.currentTime = audio.duration * (evt.offsetX / 600);
            //console.log(ControlPanel.style.width);
        }


        function getDuration() {
            var durationTime = getTimeFormat(audio.duration);
            var currentTime = getTimeFormat(audio.currentTime);
            duration.innerText = currentTime + " / " + durationTime;

            progress.style.width = Math.floor(audio.currentTime/audio.duration  * 100) + "%";
            console.log(progress.style.width);
            setTimeout(getDuration, 1000);

            if (durationTime == currentTime) {
                if (info2.innerText == "單曲循環") {
                    SongChange("s");
                }
                else if (info2.innerText == "隨機播放") {
                    SongChange("r");
                }
                else if (music.selectedIndex == music.options.length - 1) {
                    if (info2.innerText == "全曲循環") {
                        SongChange("a");
                        
                    }
                    else {
                        StopMusic();
                    }
                }
                else {
                    SongChange("c");
                
                }

            }

        }


        function getTimeFormat(TimeSec) {
            var min = Math.floor(TimeSec / 60);
            var sec = Math.floor(TimeSec) - min * 60;
            min = min < 10 ? "0" + min : min;
            sec = sec < 10 ? "0" + sec : sec;
            return min + ":" + sec;
        }

        //全曲循環
        function allloopSong() {
            if (info2.innerText == "全曲循環") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "全曲循環";
            }
        }

        //隨機播放
        function randomSong() {
            if (info2.innerText == "隨機播放") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "隨機播放";
            }
        }

        //單曲循環
        function loopSong() {
            if (info2.innerText == "單曲循環") {
                info2.innerText = "";
            }
            else {
                info2.innerText = "單曲循環";
            }
        }



        function SetMuted() {
            if (muted.innerText == "V") {
                audio.muted = true;
                muted.innerText = "U";
            }
            else {
                audio.muted = false;
                muted.innerText = "V";
            }
        }

        function VolumeChange(sound) {
            switch (sound) {
                case "m":
                    vol.value--;
                    break;
                case "p":
                    vol.value++;
                    break;

            }
            volValue.value = vol.value;

            audio.volume = volValue.value/100;
        }

        function SongChange(strFlag) {
            var index = music.selectedIndex;
            var length = music.options.length;

            switch (strFlag) {
                case "n":
                    if (index < music.options.length - 1)
                        index++;
                    else
                        index = 0;
                    break;
                case "p":
                    if (index == 0)
                        index = length- 1;
                    else
                        index--;
                    break;
                case "s":
                    audio.currentTime = 0;
                    break;
                case "r":
                    index = Math.floor(Math.random() * length);
                    break;
                case "a":
                    index = 0;
                    break;
                default:
                    index++;
                    break;

            }

            //song.src = music.options[index].value;
            //music.options[index].selected = true;

            ChangeMusic(index);
        }

        function TimeChange(boolFlag) {
            if (boolFlag)
                audio.currentTime += 10;
            else
                audio.currentTime -= 10;
        }


        function PlayMusic() {
            audio.play();
            getDuration();
            ShowStatus(1);
            if (play.innerText == "4")
                play.innerText = ";";
            else {
                play.innerText = "4";
                PauseMusic();
            }
        }
        function PauseMusic() {
            audio.pause();
            ShowStatus(2);
        }
      

        function StopMusic() {
            audio.pause();
            audio.load();
            play.innerText = "4";
            ShowStatus(3);
           
        }
       

        function ChangeMusic(index) {
            song.src = music.options[index].value;
            music.options[index].selected = true;
            audio.load();
            if (info.innerText == "音樂播放中")
                audio.play();
                //PlayMusic();
        }

        function ShowStatus(status) {
            var strStatus = "";

            switch (status) {
                case 1:
                    strStatus = "音樂播放中";
                    break;
                case 2:
                    strStatus = "音樂暫停";
                    break;
                case 3:
                    strStatus = "音樂停止";
                    break;
            }

            info.innerText = strStatus;
        }
    </script>
</body>
</html>

ASP串聯SQL

處理資料控制器

看到的明碼因該是雜湊演算

雜湊不可逆 跟加密SSL不一樣

WAN/CRY 128 BIT 加密

A 雜湊完一定 = A1 但不可逆

所以可以雜湊跟雜湊比對 知道本來的內容

樂透彩=課窮人的稅 , 如果有賺郭台銘早就包牌了

12支排 猜中其中1支 賠十倍 你就算全包 也要12000 他頂多種1支 陪10000 老闆一定賺2000

趨近於零 不等於零 就是有機率重 趨近於一百 不等於一百 就是有機率沒重

第一步 鏈結資料庫

利用程式碼自動部屬資料庫(如同上面兩張圖) or 自己設計

USE master 
GO
IF  EXISTS (SELECT name FROM sys.databases WHERE name='MySystem')
DROP DATABASE MySystem
GO

Create database [MySystem]
go

use [MySystem]
go

Create table Members(
	Account varchar(10) primary key,
	Pswd varchar(4000) not null,
	[Name] nvarchar(20) not null,
	Birthday datetime not null,
	Email varchar(30) not null,
	Gender bit not null,
	EduLevel char(1) not null,
	Notes nvarchar(max)
)

Create table Edu(
	EduLevel_Code char(1) primary key,
	EduLevel nvarchar(5) not null
)
go

ALTER TABLE Members
  ADD FOREIGN KEY([EduLevel]) REFERENCES [Edu] ([EduLevel_Code])
GO

Insert into Edu values('1','國小'),('2','國中'),('3','高中'),('4','大學'),('5','研究所以上')
go

Insert into Members values
('wuchi',HASHBYTES('SHA2_256','abcd1234'),'張無忌','1999-12-3','wuchi@wda.gov.tw',1,'4',null ),
('huchun',HASHBYTES('SHA2_256','1234abcd'),'令狐沖','1984-11-6','huchun@wda.gov.tw',1,'5',null ),
('fone',HASHBYTES('SHA2_256','abcdaaaa'),'蕭峰','1993-2-23','fone@wda.gov.tw',1,'3',null ),
('bubai',HASHBYTES('SHA2_256','1234aaaa'),'東方不敗','1988-7-25','bubai@wda.gov.tw',0,'3',null ),
('hufay',HASHBYTES('SHA2_256','fhff4aaaa'),'胡斐','1970-6-22','hufay@wda.gov.tw',1,'4',null ),
('guochin',HASHBYTES('SHA2_256','ddfh6789'),'郭靖','1971-4-7','guochin@wda.gov.tw',1,'4',null ),
('bow',HASHBYTES('SHA2_256','dsfa53df'),'韋小寶','1976-8-31','bow@wda.gov.tw',1,'4',null ),
('yang',HASHBYTES('SHA2_256','sfjaaao9t'),'楊過','1985-6-11','yang@wda.gov.tw',1,'5',null ),
('dragan',HASHBYTES('SHA2_256','df$678hff'),'小龍女','1986-10-10','dragan@wda.gov.tw',0,'2',null ),
('HuangRong',HASHBYTES('SHA2_256','4rtkdasdf'),'黃蓉','1998-4-8','HuangRong@wda.gov.tw',0,'3',null ),
('WangYuYen',HASHBYTES('SHA2_256','fgfbhn6asf'),'王語焉','1963-6-17','WangYuYen@wda.gov.tw',0,'4',null ),
('bochun',HASHBYTES('SHA2_256','dsf56tyhdd'),'岳不群','1989-5-21','bochun@wda.gov.tw',0,'4',null ),
('botong',HASHBYTES('SHA2_256','abcd233455'),'周伯通','1990-9-15','botong@wda.gov.tw',1,'5',null )
go

1.設定資料庫伺服器位置在哪(IP位置or電腦名稱)

websevrer datebase

ODBC ?

第二步 GUI 控制項 設計 分頁 排序修改 刪除

第三步 不需要寫C#可以修改刪除分頁? 因為有處理資料控制項裡面的物件與屬性

 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Account" DataSourceID="SqlDataSource1" EmptyDataText="沒有資料錄可顯示。" Height="399px" Width="1501px">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="Account" HeaderText="Account" ReadOnly="True" SortExpression="Account" />
                    <asp:BoundField DataField="Pswd" HeaderText="Pswd" SortExpression="Pswd" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Birthday" HeaderText="Birthday" SortExpression="Birthday" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                    <asp:CheckBoxField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                    <asp:BoundField DataField="EduLevel" HeaderText="EduLevel" SortExpression="EduLevel" />
                    <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MySystemConnectionString1 %>" DeleteCommand="DELETE FROM [Members] WHERE [Account] = @Account" InsertCommand="INSERT INTO [Members] ([Account], [Pswd], [Name], [Birthday], [Email], [Gender], [EduLevel], [Notes]) VALUES (@Account, @Pswd, @Name, @Birthday, @Email, @Gender, @EduLevel, @Notes)" ProviderName="<%$ ConnectionStrings:MySystemConnectionString1.ProviderName %>" SelectCommand="SELECT [Account], [Pswd], [Name], [Birthday], [Email], [Gender], [EduLevel], [Notes] FROM [Members]" UpdateCommand="UPDATE [Members] SET [Pswd] = @Pswd, [Name] = @Name, [Birthday] = @Birthday, [Email] = @Email, [Gender] = @Gender, [EduLevel] = @EduLevel, [Notes] = @Notes WHERE [Account] = @Account">
                <DeleteParameters>
                    <asp:Parameter Name="Account" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Account" Type="String" />
                    <asp:Parameter Name="Pswd" Type="String" />
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="Birthday" Type="DateTime" />
                    <asp:Parameter Name="Email" Type="String" />
                    <asp:Parameter Name="Gender" Type="Boolean" />
                    <asp:Parameter Name="EduLevel" Type="String" />
                    <asp:Parameter Name="Notes" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Pswd" Type="String" />
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="Birthday" Type="DateTime" />
                    <asp:Parameter Name="Email" Type="String" />
                    <asp:Parameter Name="Gender" Type="Boolean" />
                    <asp:Parameter Name="EduLevel" Type="String" />
                    <asp:Parameter Name="Notes" Type="String" />
                    <asp:Parameter Name="Account" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
    public partial class _16DB_Connection : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }

鏈結到資料庫的原始碼 寫在web.config可以讓整個專案都能使用,但寫在單一頁則只有那頁能使用

第四步 GUI輔助工具箱物件

將工具箱內物件拖移至CODING頁面在切換到設計頁面使用GUI自動部屬屬性

撈回來的資料會放在伺服器的記憶體中

​SqlDataSource

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:MySystemConnectionString1 %>" 
                SelectCommand="SELECT * FROM [Members]"></asp:SqlDataSource>

GridView

選擇前

<asp:GridView ID="GridView" runat="server"></asp:GridView>

GUI選擇後

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Account" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:BoundField DataField="Account" HeaderText="Account" ReadOnly="True" SortExpression="Account" />
                    <asp:BoundField DataField="Pswd" HeaderText="Pswd" SortExpression="Pswd" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Birthday" HeaderText="Birthday" SortExpression="Birthday" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                    <asp:CheckBoxField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                    <asp:BoundField DataField="EduLevel" HeaderText="EduLevel" SortExpression="EduLevel" />
                    <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
                </Columns>
            </asp:GridView>

DataSourceID=資料來源ID

其實給這個屬性就能顯示資料庫了

DataKeyNames=索引主key (可能由兩個以上欄位組成用,隔開)

AutoGenerateColumns ="False" 是否自動產生欄位

如不不要則需要寫 Columns

columns 列

bind 繫結 = 被動與態 bound

boundfield = 只顯示欄位

datafield = 要顯示的欄位名稱

headertext = 資料表名稱

visible = 是否顯示(用於計算)

dateformatstring = 資料格式化字串

dateformatstring ="<{0}>" 自式化字元 原封不動顯示

dateformatstring ="<{0:D}>" 自式化字元 每種格式具有代碼取決於資料型態

自動部屬通常具有預設屬性

細節還是要自己調整

checkboxfield

Previous2019/0226/伺服器ntfs安全性權限/共用權限Next201903

Last updated 6 years ago

Was this helpful?

深刻认识clientX,offsetX,screenX_weinideai的专栏-CSDN博客
ODBC - Google SearchGoogle
BoundField.DataFormatString 屬性 (System.Web.UI.WebControls)docsmsft
[ASP.NET] Gridview 欄位輸出格式 DataFormatString隨意窩 Xuite日誌
Logo
Logo
Logo
Hashing
Logo