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

📄 useradmin.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 Manager_Useradmin : System.Web.UI.Page
{
    ManagerClass mcObj = new ManagerClass();
    DBClass dbObj = new DBClass();
    PersonRecordClass prObj = new PersonRecordClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Admin"] == null)
            {
                Response.Write("<script>parent.location='../Default.aspx';</script>");
            }
            else
            {

                tabList.Visible = true;
                tabAdd.Visible = false;
                tabUpdate.Visible = false;
                btnListAdd.Visible = true;
                gvListBind();


            }
        }

    }
    /// <summary>
    /// 显示所有用户基本资料信息
    /// </summary>
    public void gvListBind()
    {
        if (Session["Admin"] == null)
        {
            Response.Write("<script>parent.location='../Default.aspx';</script>");
        }
        else
        {
            SqlCommand myCmd = mcObj.GetALCmd();
            prObj.GVBind(myCmd, gvList, "AUI");
        }

    }
    //=============================================================
    // 事 件 名: gvList_RowDeleting()
    // 功能描述: 对GridView中的某行进行删除
    // ==============================================================
    protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int P_Int_id = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);
        mcObj.DeleteResumeInfo(P_Int_id);
        gvListBind();
    }
    //=============================================================
    // 事 件 名: gvList_RowUpdating()
    // 功能描述: 对GridView中的某行进行修改时,修改表显示其修改内容
    // ==============================================================
    protected void gvList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        tabUpdate.Visible = true;
        tabList.Visible = false;
        tabAdd.Visible = false;
        int P_Int_id = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);
        labValue.Text = P_Int_id.ToString();
        DataSet ds = mcObj.ReturnTLDs(P_Int_id, "UI");
        txtUName.Text = ds.Tables["UI"].Rows[0][0].ToString();
        txtUUserPass.Text = ds.Tables["UI"].Rows[0][1].ToString();
        ddlASex.SelectedItem.Text = ds.Tables["UI"].Rows[0][2].ToString();
        txtUAge.Text = ds.Tables["UI"].Rows[0][3].ToString();
        txtUCollege.Text = ds.Tables["UI"].Rows[0][4].ToString();
        txtUClass.Text = ds.Tables["UI"].Rows[0][5].ToString();

    }
    //=============================================================
    // 事 件 名: btnAdd_Click()
    // 功能描述: 在添加表上,单击添加按钮时,将教师的登录资料添加到表tb_userInfo中
    // ==============================================================
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtAName.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写教师名!');</script>");
        }
        else if (txtAUserPass.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写密码!');</script>");
        }
        else if (txtAAge.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写年龄!');</script>");
        }
        else if (txtACollege.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写所在单位!');</script>");
        }
        else if (txtAClass.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写授课专业!');</script>");
        }

        else
        {
            string P_Str_userId = txtAName.Text.Trim();
            SqlConnection myConn = dbObj.GetConnection();
            SqlCommand myCmd = new SqlCommand("Proc_GetUserInfo", myConn);
            myCmd.CommandType = CommandType.StoredProcedure;
            //添加参数
            SqlParameter userId = new SqlParameter("@userid", SqlDbType.NVarChar, 50);
            userId.Value = P_Str_userId;
            myCmd.Parameters.Add(userId);
            //执行过程
            myConn.Open();
            SqlDataReader rd = myCmd.ExecuteReader();
            if (rd.Read())
            {
                rd.Close();
                myCmd.Dispose();
                myConn.Close();
                Response.Write("<script>alert('该用户名已存在,请输入其它的用户名!');</script>");
               
            }
            else 
            {
                rd.Close();
                myCmd.Dispose();
                myConn.Close();
                bool P_BL_sex;
                if(ddlASex.SelectedIndex ==0)
                {
                 P_BL_sex =true ;
                }
                else
                {
                  P_BL_sex =false ;
                }
                mcObj.AddTLInfo(txtAName.Text.Trim(), txtAUserPass.Text.Trim(), P_BL_sex, Convert.ToInt32(txtAAge.Text.Trim()), txtACollege.Text.Trim(), txtAClass.Text.Trim());
                Response.Redirect("~/Manager/UserAdmin.aspx");
            }

        }
    }
    //=============================================================
    // 事 件 名: btnReset_Click()
    // 功能描述: 在添加表上,单击重置按钮时,重新填写教师的登录资料
    // ==============================================================
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtAName.Text = "";
        txtAUserPass.Text = "";
        txtAAge.Text = "";
        txtACollege.Text = "";
        txtAClass.Text = "";
    }
    //=============================================================
    // 事 件 名: btnUpdate_Click()
    // 功能描述: 在修改表上,单击修改按钮时,修改教师的登录资料
    // ==============================================================
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (txtUName.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写教师名!');</script>");
        }
        else if (txtUUserPass.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写密码!');</script>");
        }
        else if (txtUAge.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写年龄!');</script>");
        }
        else if (txtUCollege.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写所在单位!');</script>");
        }
        else if (txtUClass.Text.Trim() == "")
        {
            Response.Write("<script>alert('请填写授课专业!');</script>");
        }
        else
        {

          bool P_BL_sex;
          if (ddlUSex.SelectedIndex == 0)
             {
                P_BL_sex = true;
             }
          else
             {
                P_BL_sex = false;
             }
             mcObj.UpdateTLInfo(Convert.ToInt32(labValue.Text.Trim()),txtUName.Text.Trim(), txtUUserPass.Text.Trim(), P_BL_sex, Convert.ToInt32(txtUAge.Text.Trim()), txtUCollege.Text.Trim(), txtUClass.Text.Trim());
             Session["Username"] = txtUName.Text.Trim();
             Response.Redirect("~/Manager/UserAdmin.aspx");
          

        }
    }
    //=============================================================
    // 事 件 名: lnkbtnAdd_Click()
    // 功能描述: 当用户单击添加按钮,添加表显示
    // ==============================================================
    protected void btnListAdd_Click(object sender, EventArgs e)
    {
        tabAdd.Visible = true;
        tabList.Visible = false;
        tabUpdate.Visible = false;
       
    }
    protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvList.PageIndex = e.NewPageIndex;
        gvListBind();
    }
}

⌨️ 快捷键说明

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