Beispiel #1
0
 private Entity.Base_User GetEntity()
 {
     Entity.Base_User e = new Entity.Base_User();
     e.UserId   = Convert.ToInt32(txtnum.Text.Trim());
     e.UserName = txtusername.Text.Trim();
     e.Userpwd  = Smart.Security.MD5.MD5Encrypt(txtpwd.Text.Trim()).ToUpper();
     e.RoleId   = Convert.ToInt32(rdoRoles.SelectedValue);
     return(e);
 }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BindRoles();
         BindFunctionl();
         try
         {
             int id = Convert.ToInt32(Request.QueryString["id"]);
             Entity.Base_User model = new Entity.Base_User();
             model            = user.GetModel(id);
             txtnum.Text      = model.UserId.ToString();
             txtusername.Text = model.UserName;
             //txtpwd.Text = model.Userpwd;
         }
         catch { }
     }
 }
Beispiel #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (checkinput())
            {
                Entity.Base_User entity = GetEntity();
                if (entity.UserId < 0)
                {
                    //添加
                    if (user.Add(entity) > 0)
                    {
                        //设定角色和功能模块权限
                        //DataTable dt = new DataTable();
                        //dt = user.GetList(string.Format("UserName='******' AND Userpwd='{1}'", entity.UserName, entity.Userpwd)).Tables[0];
                        //BLL.Base_UserRole userRole = new BLL.Base_UserRole();
                        //for (int i = 0; i < chkFunctionList.Items.Count; i++)
                        //{
                        //    if (chkFunctionList.Items[i].Selected)
                        //    {
                        //        Entity.Base_UserRole model = new Entity.Base_UserRole();
                        //        model.NewsTypeId = Convert.ToInt32(chkFunctionList.Items[i].Value);
                        //        model.RoleId = Convert.ToInt32(rdoRoles.SelectedValue);
                        //        model.UserId = Convert.ToInt32(dt.Rows[0]["UserId"].ToString());

                        //        BLL.Base_UserRole bllRole = new BLL.Base_UserRole();
                        //        bllRole.Add(model);
                        //    }
                        //}

                        //成功
                        Response.Redirect("userList.aspx");
                    }
                    else
                    {
                        //失败
                        lblmsg.Text = "添加失败";
                    }
                }
                else
                {
                    //修改
                    if (user.Update(entity))
                    {
                        //设定角色和功能模块权限
                        //BLL.Base_UserRole userRole = new BLL.Base_UserRole();
                        //for (int i = 0; i < chkFunctionList.Items.Count; i++)
                        //{
                        //    if (chkFunctionList.Items[i].Selected)
                        //    {
                        //        Entity.Base_UserRole model = new Entity.Base_UserRole();
                        //        model.NewsTypeId = Convert.ToInt32(chkFunctionList.Items[i].Value);
                        //        model.RoleId = Convert.ToInt32(rdoRoles.SelectedValue);
                        //        model.UserId = entity.UserId;

                        //        BLL.Base_UserRole bllRole = new BLL.Base_UserRole();
                        //        bllRole.Update(model);
                        //    }
                        //}

                        //成功
                        Response.Redirect("userList.aspx");
                    }
                    else
                    {
                        //失败
                        lblmsg.Text = "修改失败";
                    }
                }
            }
        }