private void subscribeButton_Click(object sender, EventArgs e) { string message = ""; sendEmailMobile("Subscription"); if (emailChecked && mobileChecked) { if (isValidEmail && isValidMobile) { send2Email = new SendViaEmail(email); send2Email.Subscribe(pubForm); send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(pubForm); message = "Subscription successful!!!"; } else { message = "Please check your mobile/ email address"; } } else if (emailChecked && !mobileChecked) { if (isValidEmail) { message = "Subscription successful!!!"; send2Email = new SendViaEmail(email); send2Email.Subscribe(pubForm); } else { message = "Please check your email address"; } } else if (mobileChecked && !emailChecked) { if (isValidMobile) { message = "Subscription successful!!!"; send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(pubForm); } else { message = "Please check your mobile number"; } } MessageBox.Show(message); }
//Subscribe for a notification if subscribe button is clicked private void subscribeButton_Click(object sender, EventArgs e) { string message = ""; manager.PublishMessage(); //Check if none of the checkboxes are checked sendEmailMobile("Subscription"); //Check if the email already exists if (emailChecked) { if (manager.emailList.Contains(email)) { MessageBox.Show("The email already exists"); emailExist = true; } } //Check if the mobile already exists if (mobileChecked) { if (manager.mobileList.Contains(mobile)) { MessageBox.Show("The phone number already exists"); mobileExist = true; } } //If the email and/or mobile is valid and new, add it to the list by subscribing if (!mobileExist && !emailExist) { if (emailChecked && mobileChecked) { if (isValidEmail && isValidMobile) { send2Email = new SendViaEmail(email); send2Email.Subscribe(manager); send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(manager); message = "Subscription successful!!!"; } else { message = "Please check your mobile/ email address"; } } else if (emailChecked && !mobileChecked) { if (isValidEmail) { message = "Subscription successful!!!"; send2Email = new SendViaEmail(email); send2Email.Subscribe(manager); } else { message = "Please check your email address"; } } else if (mobileChecked && !emailChecked) { if (isValidMobile) { message = "Subscription successful!!!"; send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(manager); } else { message = "Please check your mobile number"; } } if (message != "") { MessageBox.Show(message); } } }