/// <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; } if (_ModifyName == String.Empty) { //New User if (txtUserName.Text == String.Empty) { MyMessageBox.ShowMessage("Error", "Please fill username!"); return; } if (_IsAdmin) { //添加到服务器,作为Admin用户 MongoDBHelper.AddUserToSvr(txtUserName.Text, txtPassword.Text, chkReadOnly.Checked); } else { //添加到数据库 MongoDBHelper.AddUserToDB(txtUserName.Text, txtPassword.Text, chkReadOnly.Checked); } } else { //Change Password if (_IsAdmin) { MongoDBHelper.RemoveUserFromSvr(_ModifyName); MongoDBHelper.AddUserToSvr(txtUserName.Text, txtPassword.Text, chkReadOnly.Checked); } else { MongoDBHelper.RemoveUserFromDB(_ModifyName); MongoDBHelper.AddUserToDB(txtUserName.Text, txtPassword.Text, chkReadOnly.Checked); } } this.Close(); }