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

📄 adminuserinfodetail.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 adminuserinfodetail : System.Web.UI.Page
{
    ArrayList year, month, day, year1;
    int i;
    SqlCommand cmd, cmd1,cmd2,cmd5,cmd4,cmd3,cmd6;
    SqlConnection cn;
    SqlDataReader dr, dr1,dr2,dr5,dr4;
    SqlDataAdapter da, da1;
    DataSet ds = new DataSet();
    DataSet ds1 = new DataSet();
    DataTable mytable = new DataTable();
    DataTable mytable1 = new DataTable();
    string strsql, strsql1, strsql2,strsql3,strsql6,strsql4,strsql5;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Labusername.Text = this.txtname.Text.ToString ();
        int userid = int.Parse(Request.QueryString["userid"]);
        if(!this.IsPostBack )
        {
            if (Session["adminname"] == null)
            {
                Response.Redirect("index.aspx");
            }
            else
            {

              
                year1 = new ArrayList();
                year = new ArrayList();
                month = new ArrayList();
                day = new ArrayList();

                for (i = 1999; i <= 2007; i++)
                    year1.Add(i.ToString());
                for (i = 1945; i <= 2007; i++)
                    year.Add(i.ToString());
                for (i = 1; i <= 12; i++)
                    month.Add(i.ToString());
                for (i = 1; i <= 31; i++)
                    day.Add(i.ToString());

                ddlyear.DataSource = year;
                ddlyear.DataBind();

                ddlmonth.DataSource = month;
                ddlmonth.DataBind();

                ddlday.DataSource = day;
                ddlday.DataBind();

                this.DropDownList3.DataSource = year1;
                this.DropDownList3.DataBind();

                this.DropDownList5.DataSource = month;
                this.DropDownList5.DataBind();

                this.DropDownList6.DataSource = day;
                this.DropDownList6.DataBind();


                cn = sqldata.createcon();
                cn.Open();
                strsql = "select ximing from ximing ";
                cmd = new SqlCommand(strsql, cn);
                dr = cmd.ExecuteReader();
                this.ddlximing.DataSource = dr;
                this.ddlximing.DataTextField = "ximing";
                this.ddlximing.DataBind();
                dr.Close();
                cn.Close();

                cn = sqldata.createcon();
                cn.Open();
                strsql6 = "select zhuanye from zhuanye ";
                cmd5 = new SqlCommand(strsql6, cn);
                dr5 = cmd5.ExecuteReader();
                this.ddlzhuanye.DataSource = dr5;
                this.ddlzhuanye.DataTextField = "zhuanye";
                this.ddlzhuanye.DataBind();

                this.ddlzhuanye.Items.Add("请选择您的专业名称");
                this.ddlzhuanye.SelectedIndex = this.ddlzhuanye.Items.Count - 1;



                this.ddlximing.Items.Add("请选择您的系别名称");
                this.ddlximing.SelectedIndex = this.ddlximing.Items.Count - 1;

                cn.Close();

                cn = sqldata.createcon();
                cn.Open();
                strsql4 = "select home from homedetail ";
                cmd4 = new SqlCommand(strsql4, cn);
                dr4 = cmd4.ExecuteReader();
                this.ddlhomeflood .DataSource = dr4;
                this.ddlhomeflood .DataTextField = "home";
                this.ddlhomeflood .DataBind();
                this.ddlhomeflood.Items.Add("请选择您的寝室楼");
                this.ddlhomeflood .SelectedIndex = this.ddlhomeflood .Items.Count - 1;

                cn.Close();


                cn = sqldata.createcon();
                cn.Open();
                strsql2 = "select userid,username,usersex,userage,userminzu,useraddress,homephone,useremail,userdepartment,userzhuanye,classname,teacher,shenfen from users where userid=" + userid;
                da1 = new SqlDataAdapter(strsql2 ,cn);
                da1.Fill(ds1);
                mytable1 = ds1.Tables[(0)];
                this.txtname.Text = Convert.ToString(mytable1.Rows[0]["username"]);
                this.txtage.Text = Convert.ToString(mytable1.Rows[0]["userage"]);
                this.txtaddress.Text = Convert.ToString(mytable1.Rows[0]["useraddress"]);
                this.txtclassname.Text = Convert.ToString(mytable1.Rows[0]["classname"]);
                this.txtteacher.Text = Convert.ToString(mytable1.Rows[0]["teacher"]);
                this.txtuseremail.Text = Convert.ToString(mytable1.Rows[0]["useremail"]);
                this.txtuserid.Text = Convert.ToString(mytable1.Rows[0]["userid"]);
                this.txtuserphone.Text = Convert.ToString(mytable1.Rows[0]["homephone"]);
                this.labxiname.Text = Convert.ToString(mytable1.Rows[0]["userdepartment"]);
                this.Labzhuanye.Text = Convert.ToString(mytable1.Rows[0]["userzhuanye"]);
                this.Labshenfen.Text = Convert.ToString(mytable1.Rows[0]["shenfen"]);
                this.Labsex.Text = Convert.ToString(mytable1.Rows[0]["usersex"]);
                this.Labminzu.Text = Convert.ToString(mytable1.Rows[0]["userminzu"]);

                strsql1 = "select uid, homeflood,homehao,homecount,homephone,homesex,homediffenet from home where uid=" + userid;
                da = new SqlDataAdapter(strsql1, cn);
                da.Fill(ds);
                mytable = ds.Tables[(0)];
                this.Labhomeflood .Text = Convert.ToString(mytable.Rows[0]["homeflood"]);
                this.Labhomecount.Text = Convert.ToString(mytable.Rows[0]["homecount"]);
                this.Labhomesex.Text = Convert.ToString(mytable.Rows[0]["homesex"]);
                this.txthomehao.Text = Convert.ToString(mytable.Rows[0]["homehao"]);
                this.txthomephone.Text = Convert.ToString(mytable.Rows[0]["homephone"]);
                this.labhomediffenet.Text = Convert.ToString(mytable.Rows[0]["homediffenet"]);

                cn.Close();
            }
        }
    }
   
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.txthomehao.Text = "";
            this.txthomephone.Text = "";
            this.txthomehao.Focus();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
         int userid = int.Parse(Request.QueryString["userid"]);
        if (this.IsValid)
        {
            this.Panel2.Visible = false;
            this.Panel3.Visible = true;
            cn = sqldata.createcon();
            cn.Open();
            strsql = "update home set homeflood='" + this.ddlhomeflood .SelectedItem.Value.ToString() + "',homesex='" + this.DropDownList1 .SelectedItem .Value .ToString () + "', homehao='" + this.txthomehao.Text + "', homecount='" + this.DropDownList2 .SelectedItem .Value .ToString() + "', homephone='" + this.txthomephone .Text.ToString ().Trim () + "',homediffenet='"+this.ddlyesno .SelectedItem .Value .ToString ()+"' where uid='"+userid +"'";
            cmd6 = new SqlCommand(strsql, cn);
            cmd6.ExecuteNonQuery();
           
            cn.Close();
        }
    }
    protected void Button3_Click1(object sender, EventArgs e)
    {
        int userid = int.Parse(Request.QueryString["userid"]);
        if (this.IsValid)
        {
            try
            {
                this.Panel2.Visible = true;
                this.Panel1.Visible = false;
                cn = sqldata.createcon();
                cn.Open();
                strsql5 = "update users set username='" + this.txtname.Text.ToString().Trim() + "',userminzu='" + this.ddlminzu.SelectedItem.Value.ToString() + "',usersex='" + this.ddlsex.SelectedItem.Value.ToString() + "',useraddress='" + this.txtaddress.Text.ToString().Trim() + "',userage='" + this.txtage.Text.ToString().Trim() + "',homephone='" + this.txtuserphone.Text.ToString().Trim() + "',userbirthday='" + ddlyear.SelectedItem.Value.ToString() + "-" + ddlmonth.SelectedItem.Value.ToString() + "-" + ddlday.SelectedItem.Value.ToString() + "',useremail='" + this.txtuseremail.Text.ToString().Trim() + "',shenfen='" + this.ddlhomeshenfen.SelectedItem.Value.ToString() + "',enterdate='" + this.DropDownList3.SelectedItem.Value.ToString() + "-" + this.DropDownList6.SelectedItem.Value.ToString() + "-" + this.DropDownList6.SelectedItem.Value.ToString() + "',userdepartment='" + this.ddlximing.SelectedItem.Value.ToString() + "',userzhuanye='" + this.ddlzhuanye.SelectedItem.Value.ToString() + "',classname='" + txtclassname.Text.ToString().Trim() + "',teacher='" + txtteacher.Text.ToString().Trim() + "' where userid=" + userid;
                cmd3 = new SqlCommand(strsql5, cn);
                cmd3.ExecuteNonQuery();
            }
            catch
            {
                this.Label2.Text = "数据库操作失败,可能是服务器出现错误,请稍后再试!非常抱歉影响了您的工作!";
            }
            finally
            {
                cn.Close();
                txtname.Focus();
            }
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {

        this.txtaddress.Text = "";
        this.txtage.Text = "";
        this.txtclassname.Text = "";

        this.txtname.Text = "";
        this.txtteacher.Text = "";
        this.txtuseremail.Text = "";
        this.txtuserid.Text = "";
        this.txtuserphone.Text = "";
        this.txtname.Focus();
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        this.Panel1.Visible = true;
        this.Panel2.Visible = false;
    }
}

⌨️ 快捷键说明

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