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

📄 info.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 renshi_Info : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        
        string userId="";
        string username="";
        string DepartId="";
        string Gender="";
        string ImageName="";
        string Roleid="";
       
        String sqlLogin = "select * from UserInfo where Userid=" + Request["Userid"]; ;
        String con = ConfigurationManager.AppSettings["MyConnection"].ToString();
        SqlConnection MyCon = new SqlConnection(con);
        MyCon.Open();
        SqlCommand cmd = new SqlCommand(sqlLogin, MyCon);
        SqlDataReader reader = cmd.ExecuteReader();
        
      
        while (reader.Read())
        {
            userId = reader[0].ToString();
            username = reader[8].ToString();
            DepartId = reader[3].ToString();
            Gender = reader[4].ToString();
            Roleid = reader[5].ToString();
            ImageName = reader[7].ToString();


        }
        this.userID.Text = userId;
        this.name.Text = username;
        if (Gender == "0")
        {
            this.txtsex.Text = "女";
        }
        else
        {
            this.txtsex.Text = "男";
        }


        if (DepartId == "0")
        {
            this.txtdep.Text = "人事部门";
        }
        else if(DepartId == "1")
        {
            this.txtdep.Text = "档案部门";
        }
        else if (DepartId == "2")
        {
            this.txtdep.Text = "主管部门";
        }
        else
        {
            this.txtdep.Text = "后勤部门";
        }
        this.Image1.ImageUrl = Server.MapPath("imagesworker" + "\\" + ImageName);
       
        if (Roleid== "0")
        {
            this.DropDownList1.SelectedItem.Text= "普通用户";
        }
        else if(DepartId == "1")
        {
            this.DropDownList1.SelectedItem.Text = "后勤管理员";

        }
        else
        {
            this.DropDownList1.SelectedItem.Text = "高级主管";
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String sqlLogin = "update  UserInfo set Roleid="+this.DropDownList1.SelectedItem.Value +" where Userid=" +int.Parse( this.userID.Text); 
        String con = ConfigurationManager.AppSettings["MyConnection"].ToString();
        SqlConnection MyCon = new SqlConnection(con);
        MyCon.Open();
        SqlCommand cmd = new SqlCommand(sqlLogin, MyCon);
        if (cmd.ExecuteNonQuery() > 0)
        {
            this.Label1.Text = "更改用户角色成功!";
        }
        MyCon.Close();
    }
}

⌨️ 快捷键说明

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