/// <summary> /// Handles the RowEditEnding event of the DGAttachData control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs"/> instance containing the event data.</param> private void DGAttachData_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e) { try { Microsoft.Windows.Controls.DataGridRow dgRow = e.Row; if (dgRow != null) { var selectedCallData = dgRow.Item as CallData; string key = selectedCallData.Key.ToString().Trim(); string value = selectedCallData.Value.ToString().Trim(); var updateCallData = new SoftPhone(); if (_dataContext.userAttachData.ContainsKey(key)) { string originalValue = _dataContext.userAttachData[key]; if (value != originalValue) { _dataContext.userAttachData.Remove(key); _dataContext.userAttachData.Add(key, value); updateCallData.UpdateUserData(_dataContext.userAttachData); } } BindGrid(); } } catch (Exception ex) { _logger.Error("Error occurred as " + ex.Message); } }
/// <summary> /// Handles the Click event of the btnUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void btnUpdate_Click(object sender, RoutedEventArgs e) { try { var selectedCallData = DGAttachData.SelectedCells[0].Item as CallData; string key = selectedCallData.Key.ToString().Trim(); string value = selectedCallData.Value.ToString().Trim(); var updateCallData = new SoftPhone(); if (_dataContext.userAttachData.ContainsKey(key)) { string originalValue = _dataContext.userAttachData[key]; if (value != originalValue) { _dataContext.userAttachData.Remove(key); _dataContext.userAttachData.Add(key, value); updateCallData.UpdateUserData(_dataContext.userAttachData); } } BindGrid(); } catch (Exception commonException) { _logger.Error("Error occurred as " + commonException.Message); } }