解释 protected void Button1_Click(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Default.aspx"); return; } string userid = Session["UserId"].ToString(); string spId = Request.QueryString["id"].ToString(); string orderId = Request.QueryString["oid"].ToString(); //实例化对象 Model.Comment en = new Model.Comment(); en.SPId = int.Parse(spId); en.UserId = int.Parse(userid); en.Orderid = int.Parse(orderId); en.Content = txtContent.Text; en.AddTime = DateTime.Now; //用户业务逻辑层 BLL.CommentBusiness busi = new BLL.CommentBusiness(); busi.Add(en); var orderB = new XiangXiDDBusiness(); orderB.UpdateState(en.Orderid); Alert.AlertAndRedirect("评论成功", "MyOrder.aspx"); }
时间: 2024-04-05 18:35:20 浏览: 162
这是一个 C# 的 ASP.NET 事件处理函数,它处理名为 Button1 的按钮的点击事件。在这个函数中,首先检查当前用户是否已登录,如果没有登录,则将页面重定向到默认页,return 语句用于退出函数。接下来,从 Session 和 QueryString 中获取一些参数值,用于构造实例化对象 Model.Comment。然后,实例化一个 BLL.CommentBusiness 对象,并调用其 Add 方法,将构造好的评论对象添加到数据库中。在添加评论成功后,更新订单状态,并弹出一个提示框,告知用户评论成功,并将页面重定向到 MyOrder.aspx。
相关问题
protected void LinkButton2_Click(object sender, EventArgs e) { Response.Redirect("UserStReg.aspx"); } protected void Button4_Click(object sender, EventArgs e) { Session.Abandon(); Session.Clear(); Session["UserId"] = null; Session["UserName"] = null; Response.Redirect("Default.aspx"); } protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("UserHome.aspx"); } protected void Button2_Click(object sender, EventArgs e) { if (TxtUserName.Text == "" && TxtPassword.Text == "") { Alert.AlertAndRedirect("没有输入账号和密码!", "Default.aspx"); } else { //用户业务逻辑层 BLL.UsersBusiness busi = new BLL.UsersBusiness(); DataSet ds = new DataSet(); //加载列表 ds = busi.GetList("UserName='" + TxtUserName.Text.Trim() + "'and pwd='" + TxtPassword.Text.Trim() + "'"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { Session["UserId"] = ds.Tables[0].Rows[0]["id"].ToString(); Session["UserName"] = ds.Tables[0].Rows[0]["UserName"].ToString(); Session["XingMing"] = ds.Tables[0].Rows[0]["XingMing"].ToString(); Session["ZheKou"] = ds.Tables[0].Rows[0]["ZheKou"].ToString(); Response.Redirect("Default.aspx"); } } else { Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Default.aspx"); } } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("FindPwd.aspx"); }
这段代码是一个ASP.NET的代码,主要实现了一些按钮的点击事件。
1. LinkButton2_Click: 当LinkButton2被点击时,会跳转到UserStReg.aspx页面,即用户注册页面。
2. Button4_Click: 当Button4被点击时,会清空Session中的用户信息,然后跳转到Default.aspx页面。
3. Button1_Click: 当Button1被点击时,会跳转到UserHome.aspx页面,即用户主页。
4. Button2_Click: 当Button2被点击时,会首先判断输入的用户名和密码是否为空,如果为空,则弹出提示框;如果不为空,则通过业务逻辑层(BLL.UsersBusiness)查询数据库判断是否存在该用户。如果存在,则将用户信息存入Session中,然后跳转到Default.aspx页面;如果不存在,则弹出提示框。
5. LinkButton1_Click: 当LinkButton1被点击时,会跳转到FindPwd.aspx页面,即找回密码页面。
阅读全文
相关推荐
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)