// This method contains the functionality to be executed when button is pressed. // It ensures all fileds are filled before sending, creates and saves an sms object, // and provides meaning of any abbreviations private void SendButtonClick() { // If statement prompts user to fill in all fields before message can be sent, by checking if the // component is empty if (string.IsNullOrWhiteSpace(HeaderTextBox) || string.IsNullOrWhiteSpace(SenderTextBox) || string.IsNullOrWhiteSpace(BodyTextBox)) { MessageBox.Show("Please Enter All Values"); return; } Textspeak(); // Call Textspeak method // If statement checks if body contains textspeak abbreviation, if true creates new object and adds // textspeak, then saves to json file if (saveRegular == true) { // Create object Sms smsMessage = new Sms() { Header = HeaderTextBox, // Set header Sender = SenderTextBox, // Set sender Body = newMessage // Set body to textspeak }; SaveToFile save = new SaveToFile(); // Create new instance of SaveToFIle class // If cannot be saved display error message, otherwise save file if (!save.ToJsonSms(smsMessage)) { MessageBox.Show("Error While Saving\n" + save.ErrorCode); // Display error code } else { MessageBox.Show("Order Saved"); // Let user know file has been saved save = null; } } // If statement checks if body contains textspeak abbreviation, if false creates new object and saves standard body, // then saves to json file if (saveRegular == false) { Sms smsMessage = new Sms() { Header = HeaderTextBox, // Set header Sender = SenderTextBox, // Set sender Body = BodyTextBox // Set body to standard body text }; SaveToFile save = new SaveToFile(); // Create new instance of SaveToFIle class // If cannot be saved display error message, otherwise save file if (!save.ToJsonSms(smsMessage)) { MessageBox.Show("Error While Saving\n" + save.ErrorCode); // Display error code } else { MessageBox.Show("Order Saved"); // Let user know file has been saved save = null; } } }