Exemplo n.º 1
0
        /// <summary>
        /// 处理所有关注的消息
        /// </summary>
        /// <param name="notification"></param>
        public override void HandleNotification(INotification notification)
        {
            switch (notification.Name)
            {
            //初始化信息
            case ProConsts.MSG_Not_InitUserFormMediator:
                UserForm userFormObj = notification.Body as UserForm;
                InitUserFormMediator(userFormObj);
                break;

            //处理用户选择信息(更新数据)
            case ProConsts.MSG_Not_SendCurUserInfoToUserForm:
                _UserFormType = UserFormType.Update;
                UserVO userVoObj = notification.Body as UserVO;
                DisplayAndUpdateUserForm(UserFormType.Update, userVoObj);
                break;

            //增加用户信息
            case ProConsts.MSG_Not_AddUserInfo:
                _UserFormType = UserFormType.Create;
                DisplayAndUpdateUserForm(UserFormType.Create);
                break;

            //清除用户信息(一条)
            case ProConsts.MSG_Not_ClearUserInfo:
                _UserFormType = UserFormType.Create;
                _UserFormProp.ClearForm();
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 处理所有关注的消息
        /// </summary>
        /// <param name="notification"></param>
        public override void HandleNotification(INotification notification)
        {
            switch (notification.Name)
            {
            //初始化
            case ProConsts.MSG_Not_InitUserListMediator:
                //调用初始化方法
                UserList userListObj = notification.Body as UserList;
                InitUserListMediator(userListObj);
                break;

            //处理用户选择的数据积记录
            case ProConsts.MSG_Not_SendCurUserInfoToMediator:
                UserVO userVO = notification.Body as UserVO;
                HandleSelectedUserInfo(userVO);
                break;

            //从UserFormMediator发来的消息:增加新用户
            case ProConsts.MSG_Not_AddUserInfoToList:
                UserVO userVOObj = notification.Body as UserVO;
                SubmitNewUser(userVOObj);
                break;

            //从UserFormMediator发来的消息:更新用户
            case ProConsts.MSG_Not_UpdateUserInfoToList:
                UserVO userVOObj2 = notification.Body as UserVO;
                SubmitUpdateUserInfo(userVOObj2);
                break;


            default:
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 显示用户列表中的一条记录
        /// </summary>
        /// <param name="userData"></param>
        public void ShowUserListItem(UserVO userData)
        {
            if (userData == null)
            {
                return;
            }
            //保存当前信息
            _CurUserVO = userData;

            //显示内容
            if (Txt_UserName != null)
            {
                Txt_UserName.text = userData.UserName;
            }
            if (Txt_Sex != null)
            {
                Txt_Sex.text = userData.Sex == PersonSex.Male?"男":"女";
            }
            if (Txt_Department != null)
            {
                Txt_Department.text = userData.Department;
            }
            if (Txt_PhoneNum != null)
            {
                Txt_PhoneNum.text = userData.PhoneNum;
            }
            if (Txt_Email != null)
            {
                Txt_Email.text = userData.Email;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 增加用户数据
 /// </summary>
 public void AddUserItem(UserVO user)
 {
     //不为空
     if (user != null)
     {
         Users.Add(user);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 提交(处理)更新用户信息操作
        /// </summary>
        /// <param name="updateUserInfo"></param>
        private void SubmitUpdateUserInfo(UserVO updateUserInfo)
        {
            if (_UserProxy == null || updateUserInfo == null)
            {
                return;
            }

            _UserProxy.UpdateUserItems(updateUserInfo);
            //刷新窗体信息
            _UserListProp.LoadAndShowUserListInfo(_UserProxy.Users);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="user"></param>
 public void DeleteUserItems(UserVO user)
 {
     for (int i = 0; i < Users.Count; i++)
     {
         if (Users[i].Equals(user))
         {
             Users.RemoveAt(i);
             break;
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 清空窗体
 /// </summary>
 public void ClearForm()
 {
     _UserVO             = null;
     Inp_FirstName.text  = "";
     Inp_LastName.text   = "";
     Tog_Male.isOn       = true;
     Inp_Department.text = "";
     Inp_PhoneNum.text   = "";
     Inp_Email.text      = "";
     //冻结确认按钮
     Btn_Confirm.interactable = false;
 }
Exemplo n.º 8
0
        /// <summary>
        /// 提交(处理)增加新用户操作
        /// </summary>
        /// <param name="newUserVO"></param>
        private void SubmitNewUser(UserVO newUserVO)
        {
            //调用模型层代理方法,增加一条记录
            if (_UserProxy == null || newUserVO == null)
            {
                return;
            }

            _UserProxy.AddUserItem(newUserVO);
            //刷新窗体信息
            _UserListProp.LoadAndShowUserListInfo(_UserProxy.Users);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="user"></param>
 public void UpdateUserItems(UserVO user)
 {
     for (int i = 0; i < Users.Count; i++)
     {
         if (Users[i].Equals(user))
         {
             //更新
             Users[i] = user;
             break;
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 对象比较方法
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool Equals(object other)
        {
            UserVO otherVO = other as UserVO;

            if (otherVO != null)
            {
                if (this.UserName == otherVO.UserName)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        private void HandleSelectedUserInfo(UserVO userVO)
        {
            if (userVO == null)
            {
                return;
            }

            //保存当前用户选择的记录
            _CurUserVO = userVO;
            //显示窗体的“删除”按钮
            _UserListProp.UnfreezeBtn_Delete();
            //发送消息到“用户信息窗体”类
            SendNotification(ProConsts.MSG_Not_SendCurUserInfoToUserForm, _CurUserVO);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 检查用户窗体信息(即不允许用户输入空信息)
        /// </summary>
        /// <returns></returns>
        private bool CheckUserForm()
        {
            if (_UserVO == null)
            {
                _UserVO = new UserVO();
            }
            //获取数据
            //TODO:这段代码是不是多此一举或者需要重构???
            _UserVO.FirstName  = Inp_FirstName.text;
            _UserVO.LastName   = Inp_LastName.text;
            _UserVO.Sex        = Tog_Male.isOn ? PersonSex.Male : PersonSex.Female;
            _UserVO.Department = Inp_Department.text;
            _UserVO.PhoneNum   = Inp_PhoneNum.text;
            _UserVO.Email      = Inp_Email.text;

            return(_UserVO.IsValid);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 显示用户窗体信息
        /// </summary>
        /// <param name="userFormType"></param>
        /// <param name="userVO"></param>
        public void ShowUserForm(UserFormType userFormType, UserVO userVO)
        {
            switch (userFormType)
            {
            case UserFormType.Create:
                //空,清空窗体内控件的内容
                ClearForm();
                break;

            case UserFormType.Update:
                //显示窗体信息
                ShowUserFormInfo(userVO);
                break;

            default:
                break;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 显示用户窗体信息
        /// </summary>
        /// <param name="userVOObj"></param>
        public void ShowUserFormInfo(UserVO userVOObj)
        {
            if (userVOObj == null)
            {
                return;
            }
            _UserVO = userVOObj;

            //控件显示
            Inp_FirstName.text = userVOObj.FirstName;
            Inp_LastName.text  = userVOObj.LastName;
            if (userVOObj.Sex == PersonSex.Male)
            {
                Tog_Male.isOn = true;
            }
            else
            {
                Tog_Female.isOn = true;
            }

            Inp_Department.text = userVOObj.Department;
            Inp_PhoneNum.text   = userVOObj.PhoneNum;
            Inp_Email.text      = userVOObj.Email;
        }
Exemplo n.º 15
0
 /// <summary>
 /// 提交:更新用户信息
 /// 功能:往用户列表Mediator发送消息,更新记录
 /// TODO:有必要带参数吗?
 /// </summary>
 private void UpdateUserInfo(UserVO userVOObj)
 {
     SendNotification(ProConsts.MSG_Not_UpdateUserInfoToList, userVOObj);
 }
Exemplo n.º 16
0
 /// <summary>
 /// 更新与显示用户的表单窗体信息
 /// </summary>
 /// <param name="userFormType"></param>
 /// <param name="userVOObj"></param>
 private void DisplayAndUpdateUserForm(UserFormType userFormType, UserVO userVOObj = null)
 {
     _UserFormProp?.ShowUserForm(userFormType, userVOObj);
 }