// -------------------------------------------------------------------------------- // Name: SaveData // Abstract: Get the data off the form and save it to the database // -------------------------------------------------------------------------------- private boolean SaveData() { boolean blnResult = false; try { // Make a suitcase for moving data udtTeamType udtNewTeam = new CUserDataTypes().new udtTeamType(); // Load suitcase with data from the form udtNewTeam.intTeamID = 0; // Don't know it yet so set to 0 udtNewTeam.strTeam = m_txtTeam.getText(); udtNewTeam.strMascot = m_txtMascot.getText(); // We are busy CUtilities.SetBusyCursor(this, true); // Try to save the data blnResult = CDatabaseUtilities.AddTeamToDatabase(udtNewTeam); // Did it work? if (blnResult == true) { // Yes, save the new team ID m_intNewTeamID = udtNewTeam.intTeamID; } } catch (Exception excError) { // log and display errors CUtilities.WriteLog(excError); } finally { // We are no longer busy CUtilities.SetBusyCursor(this, false); } return blnResult; }
// -------------------------------------------------------------------------------- // Name: IsValidData // Abstract: Check all the data and warn the user if it's bad // -------------------------------------------------------------------------------- private boolean IsValidData() { // Assume data is good easier to code that way boolean blnIsValidData = true; try { String strErrorMessage = "Please correct the following error(s):\n"; // Trim all textboxes CUtilities.TrimAllFormTextBoxes(this); // Team if (m_txtTeam.getText().equals("") == true) { strErrorMessage += "-Team cannot be blank\n"; blnIsValidData = false; } // Mascot if (m_txtMascot.getText().equals("") == true) { strErrorMessage += "-Mascot cannot be blank\n"; blnIsValidData = false; } // Bad data if (blnIsValidData == false) { CMessageBox.Show(this, strErrorMessage, getTitle() + " Error", enuIconType.Warning); } } catch (Exception excError) { // log and display errors CUtilities.WriteLog(excError); } return blnIsValidData; }
// -------------------------------------------------------------------------------- // Name: GetNewTeamInformation // Abstract: Get the new team information from the form. // -------------------------------------------------------------------------------- public udtTeamType GetNewTeamInformation() { udtTeamType udtTeam = null; try { udtTeam = new CUserDataTypes().new udtTeamType(); udtTeam.intTeamID = m_intNewTeamID; udtTeam.strTeam = m_txtTeam.getText(); udtTeam.strMascot = m_txtMascot.getText(); } catch (Exception excError) { // log and display errors CUtilities.WriteLog(excError); } return udtTeam; }