private async void EditOfficeForm_Load(object sender, EventArgs e) { if (officeId != Guid.Empty) { Enabled = false; using (var channel = ChannelManager.CreateChannel()) { try { Office = await taskPool.AddTask(channel.Service.GetOffice(officeId)); 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 { Office = new Office() { Name = "Новый филиал", Endpoint = "net.tcp://queue:4505" }; } }
private void OfficesGridViewRenderRow(DataGridViewRow row, Office office) { row.Cells["nameColumn"].Value = office.Name; row.Tag = office; }
private async void saveButton_Click(object sender, EventArgs e) { using (var channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; Office = await taskPool.AddTask(channel.Service.EditOffice(office)); 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; } } }