Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Users"] != null)
     {
         users = (Users)Session["Users"];
     }
     else
     {
         users = null;
         Response.Write("<script>parent.window.location.href='Login.aspx'</script>");
     }
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)//点击修改传值
         {
             Users model = UsersBLL.GetIdByUsers(Convert.ToInt32(Request.QueryString["id"]));
             if (model != null && model.UserId != 0)
             {
                 txtEmail.Value          = model.Email.Trim();
                 txtPhone.Value          = model.Phone.Trim();
                 txtPwd.Value            = model.Pwd.Trim();
                 txtRealName.Value       = model.RealName.Trim();
                 txtRemark.Value         = model.Remark.Trim();
                 txtUserName.Value       = model.UserName.Trim();
                 ddlRoleId.SelectedValue = model.RoleId.ToString().Trim();
                 ddlDeptId.SelectedValue = model.DeptId.ToString().Trim();
             }
             strNav         = "修改员工";
             btnUpdate.Text = "修改";
         }
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 添加,修改
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (btnUpdate.Text == "修改")
        {
            Users model = UsersBLL.GetIdByUsers(users.U_Id);
            model.U_Name     = txtName.Value.Trim();
            model.U_RealName = txtRealName.Value.Trim();
            if (rdbMan.Checked)
            {
                model.U_Sex = "男";
            }
            else
            {
                model.U_Sex = "女";
            }

            if (UsersBLL.UpdateUsers(model) > 0)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');location=location;</script>");
                return;
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>");
                return;
            }
        }
    }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Users"] != null)
     {
         users = (Users)Session["Users"];
     }
     else
     {
         users = null;
         Response.Write("<script>parent.window.location.href='Login.aspx'</script>");
     }
     if (!IsPostBack)
     {
         Users model = UsersBLL.GetIdByUsers(users.U_Id);
         if (model != null && model.U_Id != 0)
         {
             txtName.Value     = model.U_Name.Trim();
             txtRealName.Value = model.U_RealName.Trim();
             if (model.U_Sex == "男")
             {
                 rdbMan.Checked = true;
             }
             else
             {
                 rdbWoman.Checked = true;
             }
         }
     }
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Users"] != null)
     {
         users = (Users)Session["Users"];
     }
     else
     {
         users = null;
         Response.Write("<script>parent.window.location.href='Login.aspx'</script>");
     }
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)
         {
             Users model = UsersBLL.GetIdByUsers(Convert.ToInt32(Request.QueryString["id"]));
             if (model != null && model.U_Id != 0)
             {
                 txtName.Value         = model.U_Name.Trim();
                 txtPwd.Value          = model.U_Pwd.Trim();
                 txtRealName.Value     = model.U_RealName.Trim();
                 ddlType.SelectedValue = model.U_Type.Trim();
                 ddlSex.SelectedValue  = model.U_Sex.Trim();
             }
             strNav         = "修改用户";
             btnUpdate.Text = "修改";
         }
     }
 }
Ejemplo n.º 5
0
    /// <summary>
    /// 添加,修改
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (btnUpdate.Text == "添加")
        {
            Users model = new Users();
            model.U_Name     = txtName.Value.Trim();
            model.U_Pwd      = txtPwd.Value.Trim();
            model.U_RealName = txtRealName.Value.Trim();
            model.U_Sex      = ddlSex.SelectedValue;
            model.U_Type     = ddlType.SelectedValue;

            if (!UsersBLL.IsTrue(model.U_Name))
            {
                if (UsersBLL.AddUsers(model) > 0)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('UsersManage.aspx');</script>");
                    return;
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>");
                    return;
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该账号已存在!');</script>");
                return;
            }
        }
        else
        {
            Users model = UsersBLL.GetIdByUsers(Convert.ToInt32(Request.QueryString["id"]));
            model.U_Name     = txtName.Value.Trim();
            model.U_Pwd      = txtPwd.Value.Trim();
            model.U_RealName = txtRealName.Value.Trim();
            model.U_Sex      = ddlSex.SelectedValue;
            model.U_Type     = ddlType.SelectedValue;

            if (!UsersBLL.IsTrue(model.U_Name, model.U_Id))
            {
                if (UsersBLL.UpdateUsers(model) > 0)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.replace('UsersManage.aspx');</script>");
                    return;
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>");
                    return;
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该账号已存在!');</script>");
                return;
            }
        }
    }
Ejemplo n.º 6
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (btnUpdate.Text == "添加")
        {
            Users model = new Users();
            model.DeptId   = Convert.ToInt32(ddlDeptId.SelectedValue.Trim());
            model.Email    = txtEmail.Value.Trim();
            model.Phone    = txtPhone.Value.Trim();
            model.Pwd      = txtPwd.Value.Trim();
            model.RealName = txtRealName.Value.Trim();
            model.Remark   = txtRemark.Value.Trim();
            model.RoleId   = Convert.ToInt32(ddlRoleId.SelectedValue);
            model.UserName = txtUserName.Value.Trim();

            if (UsersBLL.AddUsers(model) > 0)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('UsersManage.aspx');</script>");
                return;
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>");
                return;
            }
        }
        else
        {
            Users model = UsersBLL.GetIdByUsers(Convert.ToInt32(Request.QueryString["id"]));

            model.DeptId   = Convert.ToInt32(ddlDeptId.SelectedValue.Trim());
            model.Email    = txtEmail.Value.Trim();
            model.Phone    = txtPhone.Value.Trim();
            model.Pwd      = txtPwd.Value.Trim();
            model.RealName = txtRealName.Value.Trim();
            model.Remark   = txtRemark.Value.Trim();
            model.RoleId   = Convert.ToInt32(ddlRoleId.SelectedValue);
            model.UserName = txtUserName.Value.Trim();


            if (UsersBLL.UpdateUsers(model) > 0)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.replace('UsersManage.aspx');</script>");
                return;
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>");
                return;
            }
        }
    }