private async void EditAdditionalServiceForm_Load(object sender, EventArgs e) { if (additionalServiceId != Guid.Empty) { Enabled = false; using (Channel<IServerTcpService> channel = ChannelManager.CreateChannel()) { try { AdditionalService = await taskPool.AddTask(channel.Service.GetAdditionalService(additionalServiceId)); Enabled = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } } else { AdditionalService = new AdditionalService() { Name = "Новая дополнительная услуга" }; } }
private async void saveButton_Click(object sender, EventArgs e) { using (Channel<IServerTcpService> channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; AdditionalService = await taskPool.AddTask(channel.Service.EditAdditionalService(additionalService)); if (Saved != null) { Saved(this, EventArgs.Empty); } } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } finally { saveButton.Enabled = true; } } }