⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message.aspx.cs

📁 会议室管理系统,本系统是我大学毕业时候的毕业设计,一次通过的!
💻 CS
字号:
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 Message : System.Web.UI.Page
{
    SqlConnection cn;
    DataSet ds = new DataSet();
    DataTable mytable = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int id = int.Parse(Request.QueryString["id"]);
            cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
            cn.Open();
            SqlDataAdapter da = new SqlDataAdapter("select* from meeting where id=" + id, cn);
            da.Fill(ds, "meeting");
            this.dlmeeting.DataSource = ds.Tables["meeting"].DefaultView;
            this.dlmeeting.DataBind();
            mytable = ds.Tables["meeting"];
            if (Convert.ToString(mytable.Rows[0]["builder"]) == Convert.ToString(Session["username"]))
            {
                this.Btndel.Enabled = true;
            }
            else
            {
                this.Btndel.Enabled = false;
            }
            if (Convert.ToString(mytable.Rows[0]["attr"]) == "待审批")
            {
                this.Button5.Enabled = false;
            }
            else
            {
                this.Button5.Enabled = true;
            }
            this.databindmymeetinginfo();
            cn.Close();

        }
    }
    public static string pagecount;

    private void databindmymeetinginfo()
    {
        int id = int.Parse(Request.QueryString["id"]);
        int countpage = Convert.ToInt32(this.Labelye.Text);
        cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
        cn.Open();
        SqlDataAdapter da = new SqlDataAdapter("select* from message where mid='"+ id+"' order by id desc", cn);
        da.Fill(ds, "message");
        System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
        ps.DataSource = ds.Tables["message"].DefaultView;
        ps.AllowPaging = true;
        ps.PageSize = 12;
        ps.CurrentPageIndex = countpage - 1;
        this.lblPageCount.Text = Convert.ToString(ps.PageCount);

        this.Button2.Enabled = true;
        this.Button3.Enabled = true;

        if (countpage == 1)
        {
            this.Button2.Enabled = false;
        }
        if (countpage == ps.PageCount)
        {
            this.Button3.Enabled = false;
        }
        this.gvmessage.DataSource = ps;
        this.gvmessage.DataBind();
        if (this.gvmessage.Rows.Count == 0)
        {
            this.Panel1 .Visible = false;
            this.Labmessage.Text = "温馨的提示:还没有留言信息!";
        }
        else
        {
            this.Panel1 .Visible = true;
        }

        SqlCommand cmd = new SqlCommand("select count(*) from message where  mid="+id, cn);
        this.lblRecordCount.Text = Convert.ToString(cmd.ExecuteScalar());
        pagecount = Convert.ToString(ps.PageCount);
        cn.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.Labelye.Text = "1";
        this.databindmymeetinginfo();

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        this.Labelye.Text = Convert.ToString(Convert.ToInt32(this.Labelye.Text) - 1);
        this.databindmymeetinginfo();

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        this.Labelye.Text = Convert.ToString(Convert.ToInt32(this.Labelye.Text) + 1);
        this.databindmymeetinginfo();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        this.Labelye.Text = pagecount;
        this.databindmymeetinginfo();

    }
    protected void Btndel_Click(object sender, EventArgs e)
    {
        try
        {
            int intCount = this.gvmessage.Rows.Count;
            for (int i = 0; i < intCount; i++)
            {
                CheckBox CheckSingle = this.gvmessage.Rows[i].Cells[4].FindControl("itemchk") as CheckBox;
                if (CheckSingle.Checked)
                {
                    int id = Convert.ToInt32(this.gvmessage.Rows[i].Cells[0].Text);
                    cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("delete from message where id='" + id + "'and touser='" + Convert.ToString(Session["username"]) + "'", cn);
                    cmd.ExecuteNonQuery();
                    this.Labmessage.Text = "删除所选的留言成功";
                }

            }

            this.databindmymeetinginfo();
        }
        catch
        {
            this.Labmessage.Text = "服务器忙,请一会在试!";

        }
        finally
        {
            cn.Close();
        }
    }
    protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
    {
        foreach (GridViewRow gr in gvmessage.Rows)
        {
            CheckBox chk = (CheckBox)gr.Cells[4].FindControl("itemchk");
            if (!chk.Checked)
            {
                chk.Checked = true;
            }
            else
            {
                chk.Checked = false;
            }
        }


    }
    protected void gvmymeeting_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ffffff';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            this.Btndel.Attributes.Add("onclick", "return confirm('您确认要删除所选的会议室吗?');");
        }

    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        Response.Redirect("post.aspx?id="+Request .QueryString ["id"]);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -