首页 > 代码库 > ERP权限设置(十二)

ERP权限设置(十二)

个人信息管理:

需求描述:

1.在权限信息表添加一条个人信息修改权限。

2.在TreeMenu表添加一条数据作为个“人信息修改”菜单。

3. 人事登记人员在登记员工信息的时候,自动给员工权限表添加一条“个人信息修改权限”。

4. 个人登录ERP系统后可以系统自动加载“个人信息修改”菜单,如果没有此菜单,管理员可以自行给员工赋值此权限。

5.员工可以自己修改自己基本信息。

存储过程:

---员工信息添加以后自动给员工权限信息表添加一个权限值为1的权限
-- 权限值1:个人信息修改权限
DECLARE @userid int 
SET @userid=@@IDENTITY;
INSERT tbUserRight
(	
	UserID,
	RightID
)
VALUES
(	
	@userid,
	1
)

 前端:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkerInfoUpdate.aspx.cs" Inherits="BioErpWeb.HRSystem.WorkerInfoUpdate" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="http://www.mamicode.com/Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="http://www.mamicode.com/Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            height: 20px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
     <table class="maintable">
      <tr>
       <td colspan="4" class="titlebar"><span>个人信息修改</span></td>
      </tr>
       <tr>
           <td>登录名</td><td><asp:TextBox ID="txtLoginName" runat="server"></asp:TextBox></td>
           <td>真实姓名</td><td><asp:TextBox ID="txtUserName" runat="server" ReadOnly="True"></asp:TextBox><span  style=" color:Red;">(*如有误,请管理员修改)</span></td>
       </tr>
       <tr>
           <td>登录密码</td><td><asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox></td>
           <td>确认密码</td><td><asp:TextBox ID="txtRePwd" runat="server" TextMode="Password"></asp:TextBox><span  style=" color:Red;">(*如不填写密码,则默认为原来的密码)</span></td>
       </tr>
         <tr>
             <td class="style1">
                 生日
             </td>
             <td class="style1">
                 <asp:TextBox ID="txtBirthday" runat="server"></asp:TextBox>
                 <cc1:CalendarExtender runat="server" TargetControlID="txtBirthday" Format="yyyy-MM-dd">
                 </cc1:CalendarExtender>
             </td>
             <td class="style1">
                 手机号码
                         </td>
                         <td class="style1">
                           <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                         </td>
         </tr>
         <tr>
             <td>
             Email地址
             </td>
             <td>
                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
             </td>
             <td>
              性别
             </td>
             <td>
                 <asp:DropDownList ID="ddlSex" runat="server">
                     <asp:ListItem Value="http://www.mamicode.com/0">男</asp:ListItem>
                     <asp:ListItem Value="http://www.mamicode.com/1">女</asp:ListItem>
                 </asp:DropDownList>
             </td>
         </tr>
         <tr>
             <td>
             住址
             </td>
             <td>
                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
             </td>
             <td>
                  </td>
           
             <td>  
                  </td>
         </tr>

         <tr>
             <td colspan="4" class="bottomtd">
             
                 <asp:Button ID="btnSubmit" runat="server" Text="员工确认编辑"  
                     CssClass="submitbutton" onclick="btnSubmit_Click"/>
             </td>
         </tr>

     </table>
        <br />
    </div>
    </form>
</body>
</html>

 后端:

public partial class WorkerInfoUpdate : System.Web.UI.Page
    {
        static  UserManager user=new UserManager();

        UserManagerBLL userbll;
        static bool isadd = true;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Userid"] == null)
            {
                Server.Transfer("~/Web/UserLogin.aspx");
            }
            if (!IsPostBack)
            {                
                    PageInfoBind();
                                
            }
        }
        private void PageInfoBind()
        {

               string userid = Session["Userid"].ToString();
                userbll = new UserManagerBLL();
                user = userbll.getuserbyId(userid);
                this.txtUserName.Text = user.UserName;
                this.txtLoginName.Text = user.LoginName;
                this.txtBirthday.Text = user.Birthday.ToString();
                this.txtMobile.Text = user.Mobile;
                this.txtEmail.Text = user.Email;
                
             
                this.txtAddress.Text = user.Address;
              
               
                if (user.Sex == true)
                {
                    this.ddlSex.SelectedValue = "http://www.mamicode.com/0";
                }
              
           


        }
         
        
      
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.txtLoginName.Text.Trim() == "" || txtLoginName.Text.Trim().Length == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(‘请填写登录名‘);", true);
                return;
            }

      

            if (this.txtRePwd.Text.Trim() != txtPwd.Text.Trim())
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(‘密码和重复密码必须一致‘);", true);
                return;
            }

            if (this.txtPwd.Text.Trim() != "" && this.txtRePwd.Text.Trim() != "")
            {
                user.Password = Comm.MD5(this.txtPwd.Text.Trim());
            }

            user.LoginName = this.txtLoginName.Text;
            user.UserName = this.txtUserName.Text;         
            user.Mobile = this.txtMobile.Text;
            user.Birthday = Convert.ToDateTime(this.txtBirthday.Text);
            user.Email = this.txtEmail.Text;
            user.Address = this.txtAddress.Text;
            //0:男,1,女
            user.Sex = this.ddlSex.SelectedValue =http://www.mamicode.com/="0" ? true : false;
            user.LastLoginDate =Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            userbll = new UserManagerBLL();
            user.UserId = int.Parse(Session["Userid"].ToString());

            string columns="LoginName=‘"+user.LoginName+"‘,Password=‘"+ user.Password+"‘,Birthday=‘"+user.Birthday+"‘,Mobile=‘"+user.Mobile+"‘,Email=‘"+user.Email+"‘,Sex=‘"+user.Sex+"‘,Address=‘"+user.Address+"‘";
                      
            if (!SqlComm.UpdateTableByCondition("UserManager", columns, " UserId=" + user.UserId.ToString()))
            {

                ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(‘数据提交失败‘);", true);
                return;
               
            }
                       

        }

     
    }

 

ERP权限设置(十二)