版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
PAGEPAGE1《ASP.NET程序设计》课程实验报告实验课题:专业:计算机应用班级:指导教师:完成人: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('请输入留言主题和内容!');</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('发表成功!');</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="当前在线人数为"+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>您已经投过票了!</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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 检察院法院书记员考试
- 《交通安全我知道》幼儿园中班
- 2024届河北省邯郸市高三下学期5月保温试题语文答案
- 2024春夏防晒服白皮书-多平台分析-知衣数据
- 混凝土回弹法委托单 2023.6.1
- 干部人事档案审核情况登记表格
- 高考生物一轮复习 第一单元 重点强化练6 突破蛋白质的相关计算(含解析)-人教版高三全册生物试题
- 北师大版二年级下册数学口算题大全带答案
- 物流运输项目 投标方案(适用烟草、煤炭、化肥、橡胶等运输项目)(技术方案)
- 2024届天津市河北区高三总复习质量检测(一)地理答案
- 2024年浙江温州市铁投集团运营分公司招聘笔试参考题库含答案解析
- 大学生维护心理健康的策略有
- 中医临床模块处方法
- 2022-2023学年山东省淄博市鲁科版(五四学制)(三起)三年级下册期末英语试卷
- cad工艺流程图图形符号
- 小学二年级教师实习报告实习报告
- 预防接种工作规范(2023年版)解读课件
- 第8课《这些物品不共用》课件
- 初中音乐八年级下册(简谱) 踏浪(省一等奖)
- 岗位危险源辨识培训课件
- 武汉市2024届七年级数学第二学期期末监测试题含解析
评论
0/150
提交评论