Esempio n. 1
0
 protected void BindData()
 {
     UserItem userObj = new UserItem();
     PagerNavication.RecordsCount = DataBase.HEntityCommon.HEntity(userObj).EntityCount();
     UserItem[] al = UserItem.List("", "", PagerNavication.PageIndex, PagerNavication.PageSize);
     rptItems.DataSource = al;
     rptItems.DataBind();
 }
Esempio n. 2
0
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            string strUserName = txt_UserName.Value.Trim();
            string strNickName = txt_NickName.Value.Trim();
            string strPassword = txt_Password.Value.Trim();
            string strPasswordSecond = txt_PasswordSecond.Value.Trim();
            if ("" == strUserName || "" == strNickName || "" == strPassword || "" == strPasswordSecond)
                return;
            if(UserItem.ExistUser(strUserName))
            {
                PageUtil.PageAlert(this.Page, "该用户名已存在!");
                return;
            }
            if (!strPassword.Equals(strPasswordSecond))
            {
                PageUtil.PageAlert(this.Page, "密码和确认密码不一致!");
                return;
            }
            if (lb_RoleSelect.Items.Count == 0)
            {
                PageUtil.PageAlert(this.Page, "请选择角色!");
                return;
            }
            UserItem addItem = new UserItem();
            addItem.UserName = strUserName;
            addItem.NickName = strNickName;
            addItem.Password = Util.MD5Encrypt(strPassword);
            addItem.Gender = rb_GenderMale.Checked ? "男" : "女";
            string strTel = txt_Tel.Value.Trim();
            if ("" != strTel)
                addItem.Tel = txt_Tel.Value.Trim();
            string strEmail = txt_Email.Value.Trim();
            if ("" != strEmail)
                addItem.Email = txt_Email.Value.Trim();
            int nNewId = UserItem.Save(addItem);
            if (nNewId <= 0)
                return;

            UserRoleItem[] alUserRoles = UserRoleItem.GetUserRoles(nNewId);
            Hashtable htExistRoles = new Hashtable();
            if (null != alUserRoles)
            {
                foreach (UserRoleItem item in alUserRoles)
                    htExistRoles[item.RoleItemId + ""] = 1;
            }
            foreach (ListItem item in lb_RoleSelect.Items)
            {
                if (htExistRoles.ContainsKey(item.Value))
                    continue;
                UserRoleItem addUserRole = new UserRoleItem();
                addUserRole.RoleItemId = int.Parse(item.Value);
                addUserRole.UserItemId = nNewId;
                UserRoleItem.Save(addUserRole);
            }
            PageUtil.PageAlert(this.Page, "保存成功!");
        }
Esempio n. 3
0
 public static bool ExistUser(string _strUserName)
 {
     if (string.IsNullOrEmpty(_strUserName))
         return false;
     UserItem item = new UserItem();
     item.UserName = _strUserName;
     int nCount = HEntityCommon.HEntity(item).EntityCount();
     if (nCount > 1)
         throw new Exception(string.Format("UserItem(UserName:{0}) exist mutil records!", _strUserName));
     return nCount == 1;
 }
Esempio n. 4
0
 public static UserItem Get(int __nId)
 {
     if (__nId <= 0)
         return null;
     string strFilter = "Id=" + __nId;
     UserItem uItem = new UserItem();
     UserItem[] alist = (UserItem[])HEntityCommon.HEntity(uItem).EntityList(strFilter);
     if (null == alist || alist.Length == 0)
         return null;
     if (alist.Length > 1)
         throw new Exception(string.Format("{0}-{1}:{2} exist mutil records", uItem.GetTableName(), uItem.GetKeyName(), __nId));
     return alist[0];
 }
Esempio n. 5
0
 public static int Save(UserItem _saveObj)
 {
     if (null == _saveObj)
         return -1;
     return HEntityCommon.HEntity(_saveObj).EntitySave();
 }
Esempio n. 6
0
 public static UserItem[] List(string __strFilter, string __strSort, int __nPageIndex, int __nPageSize)
 {
     UserItem userItem = new UserItem();
     UserItem[] al = (UserItem[])DataBase.HEntityCommon.HEntity(userItem).EntityList(__strFilter, "", __nPageIndex, __nPageSize);
     if (null == al || al.Length == 0)
         return null;
     return al;
 }
Esempio n. 7
0
 public static UserItem Get(string _strUserName)
 {
     UserItem item = new UserItem();
     item.UserName = _strUserName;
     UserItem[] alItems = (UserItem[])HEntityCommon.HEntity(item).EntityList();
     if(null == alItems || alItems.Length == 0)
         return null;
     if (alItems.Length > 1)
         throw new Exception(string.Format("UserItem(UserName:{0}) exist mutil records!", _strUserName));
     return alItems[0];
 }