码迷,mamicode.com
首页 > 其他好文 > 详细

录播教室预约系统(十)-客户端部门管理员重置本单位其他人员密码

时间:2015-02-09 18:43:20      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:networkcomms.cn

录播教室预约系统(十)-客户端部门管理员重置本单位其他人员密码

技术分享

 

客户端代码:

技术分享

 //发出的数据类型为int类型  ItemID为用户对应的ID
            ResMessage resMessage = tcpConnnection.SendReceiveObject<ResMessage>("ReqResetPsw", "ResResetPsw", 5000, itemID);            if (resMessage.Message == "操作成功")
            {
                paramHelper.ChangeParam("操作成功");

                MessageBox.Show("操作成功,用户密码为:123456");

                button1.Enabled = false;
            }            else
            {
                MessageBox.Show("出现错误,错误信息为:" + resMessage.Message);
            }

技术分享

服务器端代码:

            //客户端管理员修改用户的密码
            NetworkComms.AppendGlobalIncomingPacketHandler<int>("ReqResetPsw", HandleResetPassword);

处理方法:

技术分享

        //根据管理员提供的用户ID修改相应用户的密码

        private void HandleResetPassword(PacketHeader header, Connection connection, int  itemID)
        {
          Users theUser= DoUsers.GetUsers(itemID);
          //把密码恢复成123456
          theUser.Password = "123456";

          DoUsers.Save(theUser);

          ResMessage theMessage = new ResMessage();

          theMessage.Message = "操作成功";

          connection.SendObject("ResResetPsw", theMessage);

        }

技术分享

操作类:

技术分享

 DoUsers

Users类:

技术分享

[ProtoContract]    public class Users
    {        #region Constructors        public Users()
        { }        #endregion

        #region Private Properties        private int id = -1;        private string userID = string.Empty;        private string name = string.Empty;        private string password = string.Empty;        private string declaring = string.Empty;        private int status = -1;        private bool isMale = false;        private int userLevel = -1;        private bool enabled = false;        private DateTime registerTime = DateTime.UtcNow;        private DateTime lastLoginTime = DateTime.UtcNow;        private int depID = -1;        private string department = string.Empty;        #endregion

        #region Public Properties

        [ProtoMember(1)]        public int Id
        {            get { return id; }            set { id = value; }
        }
        [ProtoMember(2)]        public string UserID
        {            get { return userID; }            set { userID = value; }
        }
        [ProtoMember(3)]        public string Name
        {            get { return name; }            set { name = value; }
        }
        [ProtoMember(4)]        public string Password
        {            get { return password; }            set { password = value; }
        }
        [ProtoMember(5)]        public string Declaring
        {            get { return declaring; }            set { declaring = value; }
        }
        [ProtoMember(6)]        public int Status
        {            get { return status; }            set { status = value; }
        }
        [ProtoMember(7)]        public bool IsMale
        {            get { return isMale; }            set { isMale = value; }
        }
        [ProtoMember(8)]        public int UserLevel
        {            get { return userLevel; }            set { userLevel = value; }
        }
        [ProtoMember(9)]        public bool Enabled
        {            get { return enabled; }            set { enabled = value; }
        }
        [ProtoMember(10)]        public DateTime RegisterTime
        {            get { return registerTime; }            set { registerTime = value; }
        }
        [ProtoMember(11)]        public DateTime LastLoginTime
        {            get { return lastLoginTime; }            set { lastLoginTime = value; }
        }
        [ProtoMember(12)]        public int DepID
        {            get { return depID; }            set { depID = value; }
        }
        [ProtoMember(13)]        public string Department
        {            get { return department; }            set { department = value; }
        }        #endregion

    }

 

录播教室预约系统(十)-客户端部门管理员重置本单位其他人员密码

标签:networkcomms.cn

原文地址:http://networkcomms.blog.51cto.com/3011783/1613056

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!