close

1.點擊按鈕跳出彈跳視窗

2.讓被景色透明化

3.利用資料庫的網址顯示圖片

4.預約時間不能是過去時間

5.撈取兩段時間內資料的SQL寫法;撈取時間做增減

1.點擊按鈕跳出彈跳視窗

cs:

 Response.Write("<script language=javascript>alert('成功送出');</" + "script>");

2.讓被景色透明化

css:

background-color:rgba(154,195,201,0.3)

3.利用資料庫的網址顯示圖片

cs:

static string connString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["連接字串"].ConnectionString;
 System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
String[] array_pic = new string[10];
 int count;

protected void Page_Load(object sender, EventArgs e)
        {
            conn.Open();//打開資料庫
           //輸入sql語法放於cmd,並在兩者時間撈取資料
            System.Data.SqlClient.SqlCommand cmd =new System.Data.SqlClient.SqlCommand("Select 圖片位置 From image", conn);
            //將資料放置dr
            System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
            try
            {
               while (dr.Read())
                {
                    array_pic[count] = Convert.ToString(dr[0]);
                    count++;
                    
                        }
                    }
         
            finally
            {
                cmd.Dispose();
                conn.Close();
                conn.Dispose();
            }
            img1.Src = array_pic[0];
            img2.Src = array_pic[1];
            img3.Src = array_pic[2];
            img4.Src = array_pic[3];
            img5.Src = array_pic[4];
            img6.Src = array_pic[5];
            img7.Src = array_pic[6];
            img8.Src = array_pic[7];
            img9.Src = array_pic[8];
            img10.Src = array_pic[9];
        }

解釋:

String[] array_pic = new string[10];固定10個圖片

html:
      <img id="img1" src=" " alt="..." runat="server">...

4.預約時間不能是過去時間

html:

<asp:TextBox ID="TextBox" runat="server" class="form-control" TextMode="DateTimeLocal"></asp:TextBox>

注意:TextMode="DateTimeLocal":此TextBox有用時間樣式

cs:

DateTime strDate = DateTime.Parse(TextBox.Text);

if (strDate < DateTime.Now)
 {
 }

解釋:

if (strDate < DateTime.Now){}:TextBox時間小時現在時間則執行{}內程式碼

5.撈取兩段時間內資料的SQL寫法;撈取時間做增減

cs:

DateTime strDate = DateTime.Parse(TextBox4.Text);
DateTime strDate2 = DateTime.Parse(TextBox4.Text).AddHours(1); //增加一小時

System.Data.SqlClient.SqlCommand cmd =  new System.Data.SqlClient.SqlCommand

("Select 人數 From book Where 時間 BETWEEN'" + String.Format("{0:yyyy/MM/dd HH:mm}", strDate)+"' AND '" + String.Format("{0:yyyy/MM/dd HH:mm}", strDate2) + "'", conn);

解釋:

String.Format("{0:yyyy/MM/dd HH:mm}", strDate):{0:yyyy/MM/dd HH:mm}是轉化格式strDate是變數


 

arrow
arrow
    創作者介紹
    創作者 馬達加斯加 的頭像
    馬達加斯加

    各種事的部落格

    馬達加斯加 發表在 痞客邦 留言(0) 人氣()