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

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

 

客户端代码:

复制代码

 //发出的数据类型为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,教室预约)