




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
PAGEPAGE1《ASP.NET程序設(shè)計》課程實驗報告實驗課題:專業(yè):計算機應(yīng)用班級:指導(dǎo)教師:完成人:2011年5月29
5.3留言板publicpartialclassliuyan:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){if(Session["userID"]!=null){if(TextBox1.Text==""||TextBox2.Text==""){Page.RegisterStartupScript("","<script>alert('請輸入留言主題和內(nèi)容!');</script>");}else{try{stringconnstr=ConfigurationManager.ConnectionStrings["WShopConnectionString"].ConnectionString;SqlConnectionconn=newSqlConnection(connstr);conn.Open();SqlCommandcmd=newSqlCommand("Proc_InsertMessageInfo",conn);cmd.CommandType=CommandType.StoredProcedure;SqlParameterpara1=newSqlParameter("@userID",SqlDbType.Int);para1.Value=Session["userID"].ToString();cmd.Parameters.Add(para1);SqlParameterpara2=newSqlParameter("@Heading",TextBox1.Text);cmd.Parameters.Add(para2);SqlParameterpara3=newSqlParameter("@Content",SqlDbType.NVarChar);para3.Value=TextBox2.Text;cmd.Parameters.Add(para3);SqlParameterpara4=newSqlParameter("@Time",SqlDbType.DateTime);para4.Value=DateTime.Now.ToShortDateString();cmd.Parameters.Add(para4);SqlParameterpara5=newSqlParameter("@flag",DbType.Int32);para5.Direction=ParameterDirection.Output;cmd.Parameters.Add(para5);cmd.ExecuteNonQuery();Page.RegisterStartupScript("","<script>alert('發(fā)表成功!');</script>");conn.Close();}catch{}}}else{Response.Redirect("denglu.aspx");}Response.Redirect("liuyan.aspx");}}5.4商品查詢protectedvoidButton1_Click(objectsender,EventArgse){SqlDataSource2.SelectParameters.Clear();stringstr=SqlDataSource2.SelectCommand+"whereWaretype.typeID=@typeID";Parameterpara1=newParameter("typeID",DbType.Int16);para1.DefaultValue=DropDownList1.SelectedItem.Value;SqlDataSource2.SelectParameters.Add(para1);if(TextBox1.Text!=""){str+="andWare.Warenamelike'%'+@Warename+'%'";SqlDataSource2.SelectParameters.Add("Warename",TextBox1.Text);}GridView1.DataSourceID=null;SqlDataSource2.SelectCommand=str;GridView1.DataSourceID="SqlDataSource2";}5.5在線聊天protectedvoidPage_Load(objectsender,EventArgse)
{
if(Session["uName"]!=null)
{
lblOnlineNum.Text="當(dāng)前在線人數(shù)為"+Application["count"].ToString()+"人";
txtChatRoom.Text=Application["chat"].ToString();
lblName.Text=Session["uName"].ToString();
}
else
{
Response.Redirect("denglu.aspx");
}
}
protectedvoidbtnSend_Click(objectsender,EventArgse)
{
stringtab="";
stringnewline="\r";
stringnewMessage=lblName.Text+";"+tab+txtChat.Text+newline+Application["chat"];
if(newMessage.Length>500)
newMessage=newMessage.Substring(0,499);
Application.Lock();
Application["chat"]=newMessage;
Application.UnLock();
txtChat.Text="";
txtChatRoom.Text=Application["chat"].ToString();
}
5.6在線投票publicpartialclasstoupiao:System.Web.UI.Page{ArrayListcn=newArrayList();protectedvoidPage_Load(objectsender,EventArgse){//validatorlogin.Validator();if(Request.Cookies["vote"]!=null){lblState.Text="<b>您已經(jīng)投過票了!</b>";}else{lblState.Text="<b>您可以投票!</b>";}getVote();}protectedvoidgetVote(){stringfilePath=Server.MapPath("vote.txt");try{StreamReadersr=File.OpenText(filePath);stringstr=sr.ReadLine();string[]strvote=str.Split(',');foreach(stringssinstrvote)cn.Add(int.Parse(ss));sr.Close();}catch(Exceptionee){Response.Write("<script>alert('"+ee.Message+"')</script>");}}protectedvoidputVote(){stringfilePath=Server.MapPath("vote.txt");try{StreamWritersw=newStreamWriter(filePath,false);//false表示不是追加的stringstr=cn[0].ToString();for(inti=1;i<cn.Count;i++){str+=","+cn[i].ToString();}sw.WriteLine(str);sw.Close();}catch(Exceptionee){Response.Write("<script>alert('"+ee.Message+"')</script>");}}protectedvoidbtnVote_Click(objectsender,EventArgse){if(rbtlVote.SelectedIndex!=-1){if(Request.Cookies["vote"]==null){inti=rbtlVote.SelectedIndex;cn[i]=int.Parse(cn[i].ToString())+1;putVote();Response.Cookies["vote"].Value="vt";Response.Cookies["vote"].Expires=DateTime.Now.AddDays(14);Response.Write("<script>alert('投票成功!')</script>");}else{Response.Write("<script>alert('您
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 洞子噴漿掛網(wǎng)施工方案
- 三農(nóng)村公共服務(wù)設(shè)施市場化運營與管理方案
- 農(nóng)業(yè)生產(chǎn)農(nóng)業(yè)水資源節(jié)約利用手冊
- 信息技術(shù)行業(yè)網(wǎng)絡(luò)規(guī)劃與實施指南
- 電桿臨時拉線施工方案
- 活動腳手架施工方案
- 中型水庫的施工方案
- 索道運輸施工方案
- 井口保溫盒施工方案
- 鋼大門安裝施工方案
- 血液透析護理質(zhì)控
- 人工智能訓(xùn)練師理論知識考核要素細(xì)目表四級
- 《欣賞 中華人民共和國國歌(簡譜、五線譜)》課件
- 初三化學(xué)一輪復(fù)習(xí)計劃
- 關(guān)于進一步加強路基路面施工質(zhì)量的通知
- (正式版)YS∕T 5040-2024 有色金屬礦山工程項目可行性研究報告編制標(biāo)準(zhǔn)
- AQ/T 2080-2023 金屬非金屬地下礦山在用人員定位系統(tǒng)安全檢測檢驗規(guī)范(正式版)
- NB-T35020-2013水電水利工程液壓啟閉機設(shè)計規(guī)范
- JCT 841-2024《耐堿玻璃纖維網(wǎng)布》
- 醫(yī)學(xué)檢驗技術(shù)專業(yè)《跟崗實習(xí)》課程標(biāo)準(zhǔn)
- 2024年甘肅省天水市中考生物·地理試題卷(含答案)
評論
0/150
提交評論