myjionmeeting.aspx.cs

来自「会议室管理系统,本系统是我大学毕业时候的毕业设计,一次通过的!」· CS 代码 · 共 100 行

CS
100
字号
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 myjionmeeting : System.Web.UI.Page
{
    SqlConnection cn;
    DataSet ds = new DataSet();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.databindmyjionmeetinginfo();
        }
    }
    public static string pagecount;
    private void databindmyjionmeetinginfo()
    {
        int countpage = Convert.ToInt32(this.Labelye.Text);
        cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
        cn.Open();
        SqlDataAdapter da = new SqlDataAdapter("select* from meeting where person like'%" + Convert.ToString(Session["username"]) + "%' order by id desc", cn);
        da.Fill(ds, "Result");
        System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
        ps.DataSource = ds.Tables["Result"].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.gvmyjionmeeting.DataSource = ps;
        this.gvmyjionmeeting.DataBind();
        if (this.gvmyjionmeeting.Rows.Count == 0)
        {
            this.Panel1.Visible = false;
            this.Labmessage.Text = "温馨的提示:还没有会议,不能进行管理";
        }
        else
        {
            this.Panel1.Visible = true;
        }

        SqlCommand cmd = new SqlCommand("select count(*) from meeting where person like'%" + Convert.ToString(Session["username"]) + "%'", 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.databindmyjionmeetinginfo();

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

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

    }
    protected void gvmyjionmeeting_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;");
        }
    }
}

⌨️ 快捷键说明

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