private void cbAmazonS3_SelectionChangeCommitted(object sender, EventArgs e) { if (cbAmazonS3.SelectedIndex == 0) { using (var form = new AmazonS3AccountForm(new Models.AmazonS3Account())) { form.AccountSaved += (object sender1, AmazonS3AccountSaveEventArgs e1) => { _s3dao.Insert(e1.Account); // Insert new account into the database. LoadAccounts(Models.EStorageAccountType.AmazonS3, true); SelectExistingAccount(Models.EStorageAccountType.AmazonS3, e1.Account.Id); }; form.AccountCanceled += (object sender1, AmazonS3AccountSaveEventArgs e1) => { cbAmazonS3.SelectedIndex = -1; // Deselect it. }; form.ShowDialog(this); } } if (cbAmazonS3.SelectedIndex != -1) { Models.BackupPlan plan = Model as Models.BackupPlan; plan.StorageAccountType = Models.EStorageAccountType.AmazonS3; plan.StorageAccount = _s3dao.Get((int)cbAmazonS3.SelectedValue); } }
void form_AccountSaved(object sender, AmazonS3AccountSaveEventArgs e) { _s3dao.Insert(e.Account); LoadAccounts(); }