📄 managermeeting.aspx.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 managermeeting : System.Web.UI.Page
{
SqlConnection cn;
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
ds1.Clear();
if (!Page.IsPostBack)
{
if (Convert.ToString(Session["role"]) == "普通用户")
{
Response.Write("<script language='javascript'>alert('非常抱歉!您不是"管理员",不能进入该页面!^_^');window.location.href='Default.aspx'</script>");
}
this.DropDownList1.Items.Add("全部会议例表");
this.DropDownList1.SelectedIndex = this.DropDownList1.Items.Count - 1;
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlDataAdapter da = new SqlDataAdapter("select* from meeting order by id desc", cn);
da.Fill(ds1, "meeting");
this.gvmeetinginfo.DataSource = ds1.Tables["meeting"].DefaultView;
this.gvmeetinginfo.DataBind();
cn.Close();
}
}
protected void Btndel_Click(object sender, EventArgs e)
{
try
{
int intCount = this.gvmeetinginfo.Items .Count;
for (int i = 0; i < intCount; i++)
{
CheckBox CheckSingle = this.gvmeetinginfo.Items[i].Cells[6].FindControl("Checksingle") as CheckBox;
if (CheckSingle.Checked)
{
int id = Convert.ToInt32(this.gvmeetinginfo.Items[i].Cells[0].Text);
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlCommand cmd = new SqlCommand("delete from meeting where id='" + id + "'", cn);
cmd.ExecuteNonQuery();
this.Labmessage.Text = "删除所选的会议成功";
}
}
this.gvmeetinginfo .DataBind ();
}
catch
{
this.Labmessage.Text = "服务器忙,请一会在试!";
}
finally
{
cn.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
ds1.Clear();
string attr = this.DropDownList1.SelectedItem.Value.ToString();
this.gvmeetinginfo.CurrentPageIndex = 0;
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from meeting ", cn);
da.Fill(ds1, "meeting");
if (attr == "全部会议例表")
{
this.gvmeetinginfo.DataSource = ds1.Tables["meeting"].DefaultView;
}
else
{
DataView ximingds = new DataView(ds1.Tables["meeting"]);
ximingds.RowFilter = "attr='" + attr + "'";
this.gvmeetinginfo.DataSource = ximingds;
}
this.gvmeetinginfo .DataBind ();
if (this.gvmeetinginfo.Items.Count == 0)
{
this.Panel1 .Visible = false;
this.Labmessage.Text = "温馨提示:该会议状态还没有内容!";
}
else
{
this.Panel1 .Visible = true;
this.Labmessage.Text = "";
}
}
protected void gvmeetinginfo_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item .Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ffffff';");
e.Item .Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
this.Btndel.Attributes.Add("onclick", "return confirm('您确认要删除所选的会议吗?');");
}
}
protected void gvmeetinginfo_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
string attr = this.DropDownList1.SelectedItem.Value.ToString();
this.gvmeetinginfo.CurrentPageIndex = e.NewPageIndex;
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from meeting ", cn);
da.Fill(ds1,"meeting");
if (attr == "全部会议例表")
{
this.gvmeetinginfo.DataSource = ds1.Tables["meeting"].DefaultView;
}
else
{
DataView ximingds = new DataView(ds1.Tables["meeting"]);
ximingds.RowFilter = "attr='" + attr + "'";
this.gvmeetinginfo.DataSource = ximingds;
}
this.gvmeetinginfo.DataBind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -