Exemple #1
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (txtConfirmPsw.Text != txtPassword.Text)
            {
                MyMessageBox.ShowMessage("Error", "Password and Confirm Password not match!");
                return;
            }
            //MongoUser不能同时具备Password和userSource字段!
            MongoDBHelper.MongoUserEx user = new MongoDBHelper.MongoUserEx();
            user.Username = txtUserName.Text;
            user.Password = txtUserName.Text;
            user.roles    = userRoles.getRoles();
            BsonDocument otherDBRoles = new BsonDocument();

            foreach (var item in OtherDBRolesDict.Values)
            {
                otherDBRoles.Add(item);
            }
            user.otherDBRoles = otherDBRoles;
            user.userSource   = txtuserSource.Text;
            if (txtUserName.Text == String.Empty)
            {
                MyMessageBox.ShowMessage("Error", "Please fill username!");
                return;
            }
            //2013/08/13 用户结构发生大的变化
            //取消了ReadOnly字段,添加了Roles等字段
            //简化逻辑,不论新建还是修改,AddUser都可以
            try
            {
                MongoDBHelper.AddUserToSystem(user, _IsAdmin);
            }
            catch (Exception ex)
            {
                SystemManager.ExceptionDeal(ex);
            }
            this.Close();
        }