protected void init_form(string ctrID)
        {
            if (!string.IsNullOrEmpty(ctrID))
            {
                _UsersEntity = DataProvider.GetInstance().GetUsersEntity(int.Parse(ctrID));

                TextBox_ChildAccount.Text = _UsersEntity.ChildAccount.ToString();
                TextBox_ParentAccount.Text = _UsersEntity.ParentAccount.ToString();
                TextBox_Status.Text = _UsersEntity.Status.ToString();
                TextBox_GroupID.Text = _UsersEntity.GroupID.ToString();
                TextBox_IsAdmin.Text = _UsersEntity.IsAdmin.ToString();
                //TextBox_Password.Text = _UsersEntity.Password.ToString();
                TextBox_CorpName.Text = _UsersEntity.CorpName.ToString();
                //TextBox_Signature.Text = _UsersEntity.Signature.ToString();
                //TextBox_ChannelID.Text = _UsersEntity.ChannelID.ToString();
                //TextBox_Balance.Text = _UsersEntity.Balance.ToString();
                TextBox_Email.Text = _UsersEntity.Email.ToString();
                TextBox_TelePhone.Text = _UsersEntity.TelePhone.ToString();
                TextBox_MobilePhone.Text = _UsersEntity.MobilePhone.ToString();
            }
        }
 /// <summary>
 /// 验证并缓存用户权限
 /// </summary>
 /// <param name="currentUsers"></param>
 public int Validate(UsersEntity currentUsers)
 {
     string cacheKey = currentUsers.ChildAccount + "@" + currentUsers.ParentAccount;
     CacheUser = "******" + currentUsers.ChildAccount + "@" + currentUsers.ParentAccount;
     CacheMenu = "Menu_" + currentUsers.ChildAccount + "@" + currentUsers.ParentAccount;
     //换成用户
     if (HttpRuntime.Cache[CacheUser] == null)
         HttpRuntime.Cache.Insert(CacheUser, currentUsers, null, DateTime.MaxValue, TimeSpan.FromMinutes(cacheTime));
     else
     {
         HttpRuntime.Cache[CacheUser] = currentUsers;
     }
     //缓存权限菜单
     string menuWhere = "GroupID >=" + currentUsers.GroupID + " AND Status=" + 0 + " order by DisplayIndex ASC";
     IList<MenuEntity> menuList = DataProvider.GetInstance().GetMenuList(menuWhere);
     if (HttpRuntime.Cache[CacheMenu] == null)
         HttpRuntime.Cache.Insert(CacheMenu, menuList, null, DateTime.MaxValue, TimeSpan.FromMinutes(cacheTime));
     else
     {
         HttpRuntime.Cache[CacheMenu] = menuList;
     }
     return cacheTime;
 }
        protected void UsersAdd()
        {
            #region 判断是否可空


            var _ChildAccount = Request.Form["TextBox_ChildAccount"];
            if (string.IsNullOrEmpty(_ChildAccount))
            {
                Alert("[ 子账号 ]不能为空");
                return;
            }

            var _ParentAccount = Request.Form["TextBox_ParentAccount"];
            if (string.IsNullOrEmpty(_ParentAccount))
            {
                Alert("[ 企业账号 ]不能为空");
                return;
            }

            var _Status = Request.Form["TextBox_Status"];
            if (string.IsNullOrEmpty(_Status))
            {
                Alert("[ 状态(0:正常,1:停用,2:删除) ]不能为空");
                return;
            }

            var _GroupID = Request.Form["TextBox_GroupID"];
            if (string.IsNullOrEmpty(_GroupID))
            {
                Alert("[ 分组ID ]不能为空");
                return;
            }

            var _IsAdmin = Request.Form["TextBox_IsAdmin"];
            if (string.IsNullOrEmpty(_IsAdmin))
            {
                Alert("[ 是否是管理员 ]不能为空");
                return;
            }

            var _Password = Request.Form["TextBox_Password"];
            if (string.IsNullOrEmpty(_Password))
            {
                Alert("[ 密码 ]不能为空");
                return;
            }

            var _CorpName = Request.Form["TextBox_CorpName"];
            //if (string.IsNullOrEmpty(_CorpName))
            //{
            //    Alert("[ 企业名称 ]不能为空");
            //    return;
            //}

            var _Signature = Request.Form["TextBox_Signature"];
            //if (string.IsNullOrEmpty(_Signature))
            //{
            //    Alert("[ 个人签名 ]不能为空");
            //    return;
            //}

            var _ChannelID = Request.Form["TextBox_ChannelID"];
            //if (string.IsNullOrEmpty(_ChannelID))
            //{
            //    Alert("[ 通道ID ]不能为空");
            //    return;
            //}

            var _Balance = Request.Form["TextBox_Balance"];
            //if (string.IsNullOrEmpty(_Balance))
            //{
            //    Alert("[ 余额(默认为0) ]不能为空");
            //    return;
            //}

            var _Email = Request.Form["TextBox_Email"];
            //if (string.IsNullOrEmpty(_Email))
            //{
            //    Alert("[ 邮箱 ]不能为空");
            //    return;
            //}

            var _TelePhone = Request.Form["TextBox_TelePhone"];
            //if (string.IsNullOrEmpty(_TelePhone))
            //{
            //    Alert("[ 电话 ]不能为空");
            //    return;
            //}

            var _MobilePhone = Request.Form["TextBox_MobilePhone"];
            //if (string.IsNullOrEmpty(_MobilePhone))
            //{
            //    Alert("[ 手机 ]不能为空");
            //    return;
            //}

            #endregion

            #region 获取数据

            UsersEntity _UsersEntity = new UsersEntity();



            _UsersEntity.ChildAccount = Convert.ToString(_ChildAccount.ToString());


            _UsersEntity.ParentAccount = Convert.ToString(_ParentAccount.ToString());

            _UsersEntity.Status = Convert.ToInt32(_Status.ToString());

            _UsersEntity.GroupID = Convert.ToInt32(_GroupID.ToString());

            _UsersEntity.IsAdmin = Convert.ToInt32(_IsAdmin.ToString());


            _UsersEntity.Password = MD5Encrypt.MD5Hash(Convert.ToString(_Password.ToString()));


            _UsersEntity.CorpName = Convert.ToString(_CorpName.ToString());


            _UsersEntity.Signature = "";// Convert.ToString(_Signature.ToString());

            _UsersEntity.ChannelID = 0;// Convert.ToInt32(_ChannelID.ToString());

            _UsersEntity.Balance = 0;// Convert.ToInt32(_Balance.ToString());


            _UsersEntity.Email = Convert.ToString(_Email.ToString());


            _UsersEntity.TelePhone = Convert.ToString(_TelePhone.ToString());


            _UsersEntity.MobilePhone = Convert.ToString(_MobilePhone.ToString());

            _UsersEntity.CreateDate = DateTime.Now;

            _UsersEntity.UpdateDate = DateTime.Now;
            try
            {
                DataProvider.GetInstance().AddUsers(_UsersEntity);
            }
            catch
            {
                WriteLog("UsersAdd", "添加Users", "插入数据库时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("添加数据时出错,请重试");
                return;
            }
            Alert("添加Users成功");
        }
예제 #4
0
        private MideFrameWork.Data.Entity.UsersEntity GetUsers(DataRow dr)
        {
            MideFrameWork.Data.Entity.UsersEntity info = new MideFrameWork.Data.Entity.UsersEntity();
										if(DBNull.Value==dr["ID"])
					info.ID=0;
				else
					info.ID=int.Parse(dr["ID"].ToString());
									
																								
						if(DBNull.Value==dr["ChildAccount"])
				info.ChildAccount= string.Empty;
			else	
				info.ChildAccount= dr["ChildAccount"].ToString();
																								
						if(DBNull.Value==dr["ParentAccount"])
				info.ParentAccount= string.Empty;
			else	
				info.ParentAccount= dr["ParentAccount"].ToString();
																						if(DBNull.Value==dr["Status"])
					info.Status=0;
				else
					info.Status=int.Parse(dr["Status"].ToString());
									
																						if(DBNull.Value==dr["GroupID"])
					info.GroupID=0;
				else
					info.GroupID=int.Parse(dr["GroupID"].ToString());
									
																						if(DBNull.Value==dr["IsAdmin"])
					info.IsAdmin=0;
				else
					info.IsAdmin=int.Parse(dr["IsAdmin"].ToString());
									
																								
						if(DBNull.Value==dr["Password"])
				info.Password= string.Empty;
			else	
				info.Password= dr["Password"].ToString();
																								
						if(DBNull.Value==dr["CorpName"])
				info.CorpName= string.Empty;
			else	
				info.CorpName= dr["CorpName"].ToString();
																								
						if(DBNull.Value==dr["Signature"])
				info.Signature= string.Empty;
			else	
				info.Signature= dr["Signature"].ToString();
																						if(DBNull.Value==dr["ChannelID"])
					info.ChannelID=0;
				else
					info.ChannelID=int.Parse(dr["ChannelID"].ToString());
									
																						if(DBNull.Value==dr["Balance"])
					info.Balance=0;
				else
					info.Balance=int.Parse(dr["Balance"].ToString());
									
																								
						if(DBNull.Value==dr["Email"])
				info.Email= string.Empty;
			else	
				info.Email= dr["Email"].ToString();
																								
						if(DBNull.Value==dr["TelePhone"])
				info.TelePhone= string.Empty;
			else	
				info.TelePhone= dr["TelePhone"].ToString();
																								
						if(DBNull.Value==dr["MobilePhone"])
				info.MobilePhone= string.Empty;
			else	
				info.MobilePhone= dr["MobilePhone"].ToString();
																									if(DBNull.Value==dr["CreateDate"])
					info.CreateDate=DateTime.Now;
				else
					info.CreateDate=DateTime.Parse(dr["CreateDate"].ToString());
						
																									if(DBNull.Value==dr["UpdateDate"])
					info.UpdateDate=DateTime.Now;
				else
					info.UpdateDate=DateTime.Parse(dr["UpdateDate"].ToString());
						
															            return info;
        }
        protected void userEditFunc(string ctrID)
        {
            //获取数据
            string ChildAccount = Request.Form["TextBox_ChildAccount"];
            if (string.IsNullOrEmpty(ChildAccount))
            {
                Alert("子帐号不能为空");
                return;
            }
            string ParentAccount = Request.Form["TextBox_ParentAccount"];
            if (string.IsNullOrEmpty(ParentAccount))
            {
                Alert("企业帐号不能为空");
                return;
            }
            int Balance = Convert.ToInt32(Request.Form["TextBox_Balance"]);
            if (string.IsNullOrEmpty(Balance.ToString()))
            {
                Alert("余额不能为空");
                return;
            }
            string Password = Request.Form["TextBox_Password"];
            if (string.IsNullOrEmpty(Password))
            {
                Alert("密码不能为空");
                return;
            }
            DateTime CreateDate;
            DateTime.TryParse(Request.Form["TextBox_CreateDate"], out CreateDate);
            if (string.IsNullOrEmpty(CreateDate.ToString()))
            {
                Alert("创建时间不能为空");
                return;
            }
            int ChannelID = string.IsNullOrEmpty(Request.Form["TextBox_ChannelID"]) ? 0 : Convert.ToInt32(Request.Form["TextBox_ChannelID"]);
            int Status = Convert.ToInt32(Request.Form["DropDownList_Status.SelectedValue"]);
            int GroupID = Convert.ToInt32(Request.Form["DropDownList_GroupID"]);
            int IsAdmin = Convert.ToInt32(Request.Form["DropDownList_IsAdmin"]);
            string CorpName = Request.Form["TextBox_CorpName"];
            string Signature = Request.Form["TextBox_Signature"];
            string Email = Request.Form["TextBox_Email"];
            string TelePhone = Request.Form["TextBox_TelePhone"];
            string MobilePhone = Request.Form["TextBox_MobilePhone"];

            UsersEntity userEntity = new UsersEntity();
            userEntity.ID = Convert.ToInt32(ctrID);
            userEntity.ChildAccount = ChildAccount;
            userEntity.ParentAccount = ParentAccount;
            userEntity.Status = Status;
            userEntity.GroupID = GroupID;
            userEntity.IsAdmin = IsAdmin;
            userEntity.Password = Password;
            userEntity.CorpName = CorpName;
            userEntity.Signature = Signature;
            userEntity.ChannelID = ChannelID;
            userEntity.Balance = Balance;
            userEntity.Email = Email;
            userEntity.TelePhone = TelePhone;
            userEntity.MobilePhone = MobilePhone;
            userEntity.CreateDate = CreateDate;
            userEntity.UpdateDate = DateTime.Now;
            try
            {
                DataProvider.GetInstance().UpdateUsers(userEntity);
            }
            catch
            {
                WriteLog("userEditFunc", "编辑用户资料", "把新用户数据更新到数据库时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("更新数据时出错,请重试");
                return;
            }
            Alert("更新用户资料成功","");
        }