private void b_moderatorMakeModerator_Click( object sender, System.EventArgs e) { displayJoke("", 0, 0, 0, this.isModerator); string newModeratorUserName = this.tb_moderatorNewModeratorUserName.Text; if (newModeratorUserName.Length > 0) { newModeratorUserName = newModeratorUserName.Substring( 0, Math.Min(newModeratorUserName.Length, 20)); if (!this.userAdminObjCreated) { this.userAdminObj = new userAdmin.userAdmin(); this.userAdminObjCreated = true; } try { // Call our Web Service method addModerator this.userAdminObj.addModerator( this.userName, this.password, newModeratorUserName); // OK this.l_statusMessage.Text = "OK: " + newModeratorUserName + " is now a moderator"; } catch (SoapException ex) { XmlNode[] customErrorMsgs = ex.OtherElements; if (customErrorMsgs.Length > 0) { XmlNode customErrorMsg = customErrorMsgs[0]; if (customErrorMsg.InnerText.Length > 0) { this.l_statusMessage.Text = "Error: " + customErrorMsg.InnerText; return; } } } catch (Exception ex) { this.l_statusMessage.Text = "Error: " + ex.Message; } } }
private void logon(bool isModerator, bool register) { string userName = this.tb_logonUserName.Text; string password = this.tb_logonPassword.Text; if ((userName.Length > 0) && (password.Length > 0)) { userName = userName.Substring(0, Math.Min(userName.Length, 20)); password = password.Substring(0, Math.Min(password.Length, 20)); if (!this.userAdminObjCreated) { this.userAdminObj = new userAdmin.userAdmin(); this.userAdminObjCreated = true; } try { // register new user? if (register) { // Call our Web Service method addUser this.userAdminObj.addUser(userName, password); } else { // Call our Web Service method checkUser this.userAdminObj.checkUser( userName.Substring(0, Math.Min(userName.Length, 20)), password.Substring(0, Math.Min(password.Length, 20)), isModerator); } // OK this.userName = userName; this.password = password; this.isModerator = isModerator; if (isModerator) { this.gb_moderatorMenu.Enabled = true; } else { this.gb_moderatorMenu.Enabled = false; } this.gb_userMenu.Enabled = true; this.gb_userInfo.Enabled = false; this.l_statusMessage.Text = ""; displayJoke("", 0, 0, 0, this.isModerator); if (register) { this.l_statusMessage.Text = "OK: you have successfully " + "registered with the system!"; } } catch (SoapException ex) { XmlNode[] customErrorMsgs = ex.OtherElements; if (customErrorMsgs.Length > 0) { XmlNode customErrorMsg = customErrorMsgs[0]; if (customErrorMsg.InnerText.Length > 0) { this.l_statusMessage.Text = "Error: " + customErrorMsg.InnerText; return; } } } catch (Exception ex) { this.l_statusMessage.Text = "Error: " + ex.Message; } } }