editroom.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class editroom : System.Web.UI.Page
{
    SqlConnection cn;
    DataSet ds = new DataSet();
    DataTable mytable = new DataTable();

    protected void Page_Load(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"]);
        if (!Page.IsPostBack)
        {
            if (Convert.ToString(Session["role"]) == "普通用户")
            {
                Response.Write("<script language='javascript'>alert('非常抱歉!您不是"管理员",不能进入该页面!^_^');window.location.href='Default.aspx'</script>");
            }
            cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
            cn.Open();
            SqlDataAdapter da = new SqlDataAdapter("select* from room where id='"+id+"'", cn);
            da.Fill(ds, "room");
            mytable = ds.Tables["room"];
            this.txtaddr .Text = Convert.ToString(mytable.Rows[0]["roompos"]);
            this.txtcount .Text = Convert.ToString(mytable.Rows[0]["pcount"]);
            this.txtnote.Text = Convert.ToString(mytable.Rows[0]["note"]);
            this.txtname .Text = Convert.ToString(mytable.Rows[0]["roomname"]);


        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
       int id = int.Parse(Request.QueryString["id"]);
        if (Page.IsValid)
        {
            try
            {
                int count = Convert.ToInt32(this.txtcount.Text.Trim());
                cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
                cn.Open();
                SqlCommand cmd = new SqlCommand("update room set roomname='" + this.txtname.Text.Trim() + "',roompos='" + this.txtaddr.Text.Trim() + "',pcount='" + count + "',note='" + this.txtnote.Text.Trim() + "' where id='"+id+"'", cn);
                cmd.ExecuteNonQuery();
                this.HyperLink1.Visible = true;
                this.Labmessage.Text = "编辑会议室成功";
            }
            catch
            {
                this.Labmessage.Text = "服务器忙,请一会在试!";
            }
            finally
后面还有 16 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。