private void btnOK_Click(object sender, EventArgs e) { bool isOk = true ; //Validate UserID if (string.IsNullOrWhiteSpace(this.txtUserID.Text)) { this.errorProvider1.SetError(this.txtUserID, "請輸入帳號"); isOk = false ; } else this.errorProvider1.SetError(this.txtUserID, ""); //Validate Password if (string.IsNullOrWhiteSpace(this.txtPassword.Text)) { if (MessageBox.Show("確定密碼是空白嗎?","注意", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != System.Windows.Forms.DialogResult.Yes) { isOk = false ; } } if (isOk) { if (this.AfterInputCredential != null) { EmailCredentialEventArgs arg = new EmailCredentialEventArgs(this.txtUserID.Text, this.txtPassword.Text, this.txtCC.Text); this.AfterInputCredential(this, arg); } this.Close(); } }
void frmCred_AfterInputCredential(object sender, EmailCredentialEventArgs args) { this.SenderEmail = args.UserID; this.SenderPassword = args.Password; this.CC = args.CC; }