?? commbook.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;
using lalablog;
public partial class tongxue_commbook : System.Web.UI.Page
{
int tid, cid; SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userid"] != null)
{
this.tid = Convert.ToInt32(Session["userid"].ToString());
}
else
Response.Redirect("userLogin.aspx?url=" + Server.HtmlEncode(Request.RawUrl));
if(Request .QueryString ["cid"]!=null)
this.cid=Convert .ToInt32(Request .QueryString ["cid"]);
isValidUser();
if (isAdmin())
{
if (Request.QueryString["action"] == "delete")
delete();
if (Request.QueryString["action"] == "give")
give();
}
readTongXunLu();
}
private void give()
{
int givetid = 0;
if (Request.QueryString["givetid"] != null)
givetid = Convert.ToInt32(Request.QueryString["givetid"]);
string sql = "update tbanji set adminuserid=" + givetid + " where cid=" + this.cid;
openDb o1 = new openDb(sql);
o1.update();
}
private void delete()
{
int deletetid = 0;
if (Request.QueryString["deletetid"] != null)
deletetid = Convert.ToInt32(Request.QueryString["deletetid"]);
string sql = "delete from tidcid where tid=" + deletetid + " and cid=" + this.cid;
openDb o1 = new openDb(sql);
o1.update();
}
private void isValidUser()
{
string sql = "select * from tidcid where tid=" + this.tid + " and cid=" + this.cid;
openDb o1 = new openDb(sql);
if (!o1.haveRows())
{
myfunc m1 = new myfunc("您還沒有加入這個班級"+sql );
Response.Write(m1.JavaMsg("index.aspx"));
}
}
private void readTongXunLu()
{
string strconn = ConfigurationManager.ConnectionStrings["dsn"].ToString();
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
string sql = "select tongxue.* from tongxue,tidcid where tongxue.tid=tidcid.tid and cid="+this.cid ;
SqlCommand cm = new SqlCommand(sql, cn);
this. dr = cm.ExecuteReader();
displyTongXunLu();
cn.Close();
}
private void displyTongXunLu()
{
bool admin = isAdmin();
string str;
str = "<table class=tclass ><tr>";
str += "<td class=tjilu>姓名</td>";
str += "<td>單位</td>";
str += "<td>手機</td>";
str += "<td>辦公電話</td>";
str += "<td>QQ</td>";
str += "<td>MSN</td>";
if(admin)
str += "<td>管理</td>";
str+="</tr>";
while (this.dr.Read())
{
str += "<tr><td class=tjilu>" + dr["realname"].ToString() + "</td>";
str += "<td>" + dr["bureau"].ToString() + "</td>";
str += "<td>" + dr["handset"].ToString() + "</td>";
str += "<td>" + dr["tele"].ToString() + "</td>";
str += "<td>" + dr["qq"].ToString() + "</td>";
str += "<td>" + dr["msn"].ToString() + "</td>";
if (admin)
{
str += "<td><a href=commbook.aspx?action=delete&deletetid=" + dr["tid"].ToString() + "&cid=" + this.cid + ">刪除</a>//";
str += "<a href=commbook.aspx?action=give&givetid=" + dr["tid"].ToString() + "&cid=" + this.cid + ">轉讓管理員權限</a>";
str += "</td></tr>";
}
else
str += "</tr>";
}
str += "</table>";
tongxunlu.InnerHtml = str;
}
private bool isAdmin()
{
string sql = "select * from tbanji where cid=" + this.cid + " and adminuserid=" + this.tid;
openDb o1 = new openDb(sql);
return o1.haveRows();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -