/// <summary>
        /// 解析数据
        /// </summary>
        /// <param name="values">数据</param>
        /// <returns>用户和房间关系</returns>
        public UserRoom Parse(object[] values)
        {
            UserRoom result = new UserRoom();

            try
            {
                result = DatabaseHibernate.ParseModule(result, values) as UserRoom;

                result.UserId = DatabaseHibernate.ParseString(values[7]);
                result.RoomId = DatabaseHibernate.ParseString(values[8]);
            }
            catch (Exception exception)
            {
                result = null;
                EnvironmentalMonitor.Support.Resource.Variable.Logger.Log(exception);
            }

            return result;
        }
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="value">值</param>
        /// <returns>结果</returns>
        public bool Insert(UserRoom value)
        {
            bool result = false;

            string sql = string.Format("insert into e_user_room ({0}) values (:guid, :insert_user_id, :insert_time, :update_user_id, :update_time, :remark, :validity, :user_id, :room_id)", this.Asterisk(""));
            List<Parameter> parameters = new List<Parameter>();

            parameters.Add(new Parameter("guid", DatabaseHibernate.Parameter(DatabaseHibernate.GUID())));
            parameters.Add(new Parameter("insert_user_id", DatabaseHibernate.Parameter(value.InsertUserId)));
            parameters.Add(new Parameter("insert_time", DatabaseHibernate.Parameter(value.InsertTime)));
            parameters.Add(new Parameter("update_user_id", DatabaseHibernate.Parameter(value.UpdateUserId)));
            parameters.Add(new Parameter("update_time", DatabaseHibernate.Parameter(value.UpdateTime)));
            parameters.Add(new Parameter("remark", DatabaseHibernate.Parameter(value.Remark)));
            parameters.Add(new Parameter("validity", DatabaseHibernate.Parameter(value.Validity)));
            parameters.Add(new Parameter("user_id", DatabaseHibernate.Parameter(value.UserId)));
            parameters.Add(new Parameter("room_id", DatabaseHibernate.Parameter(value.RoomId)));

            DatabaseHibernate hibernate = new DatabaseHibernate();

            result = hibernate.Write(Variable.Link, sql, parameters);

            return result;
        }
        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            string guid = this.DropDownListUsers.SelectedValue;
            if (!string.IsNullOrEmpty(guid))
            {
                bool done = false;
                StringBuilder stringBuilder = new StringBuilder();

                UserBusiness business = new UserBusiness();
                User module = business.QueryByGuid(guid);

                this.InitializeUpdateModule(module);

                module.Name = this.TextBoxName.Text;
                module.Account = this.TextBoxAccount.Text;
                module.Password = this.TextBoxPassword.Text;
                module.Prerogative = false;

                User user = business.QueryByAccount(module.Account);

                if ((user == null) || (string.Equals(user.Guid, module.Guid, StringComparison.CurrentCulture)))
                {
                    done = business.Update(module);

                    if (done)
                    {
                        stringBuilder.Append("修改用户成功!");
                    }
                    else
                    {
                        stringBuilder.Append("修改用户失败!");
                    }
                }
                else
                {
                    stringBuilder.Append("用户已经存在(账户相同)!");
                }

                if (done)
                {
                    user = business.QueryByAccount(module.Account);
                    if ((user != null) && (user.Guid != null))
                    {
                        if (this.CheckBoxListRooms.Items != null)
                        {
                            List<UserRoom> userRooms = new List<UserRoom>();
                            for (int i = 0; i < this.CheckBoxListRooms.Items.Count; i++)
                            {
                                if (this.CheckBoxListRooms.Items[i].Selected)
                                {
                                    UserRoom userRoom = new UserRoom();
                                    this.InitializeInsertModule(userRoom);

                                    userRoom.UserId = user.Guid;
                                    userRoom.RoomId = this.CheckBoxListRooms.Items[i].Value;

                                    userRooms.Add(userRoom);
                                }
                            }
                            UserRoomBusiness userRoomBusiness = new UserRoomBusiness();
                            done = userRoomBusiness.Refresh(user.Guid, userRooms);

                            if (done)
                            {
                                stringBuilder.Append("更新机房成功!");
                            }
                            else
                            {
                                stringBuilder.Append("更新机房失败!");
                            }
                        }
                    }
                    if ((user != null) && (user.Guid != null))
                    {
                        if (this.CheckBoxListModules.Items != null)
                        {
                            List<UserModule> userModules = new List<UserModule>();
                            for (int i = 0; i < this.CheckBoxListModules.Items.Count; i++)
                            {
                                if (this.CheckBoxListModules.Items[i].Selected)
                                {
                                    UserModule userModule = new UserModule();
                                    this.InitializeInsertModule(userModule);

                                    userModule.UserId = user.Guid;
                                    userModule.ModuleCode = this.CheckBoxListModules.Items[i].Value;

                                    userModules.Add(userModule);
                                }
                            }
                            UserModuleBusiness userModuleBusiness = new UserModuleBusiness();
                            done = userModuleBusiness.Refresh(user.Guid, userModules);

                            if (done)
                            {
                                stringBuilder.Append("更新权限成功!");
                            }
                            else
                            {
                                stringBuilder.Append("更新权限失败!");
                            }
                        }
                    }
                }

                this.LabelMessage.Text = stringBuilder.ToString();

                this.InitializeBind();
            }
        }