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

📄 commbook.aspx.cs

📁 本程序基于 asp.net 2.0 +sql server 2
💻 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 + -