public void AddDeviceConfig() { Guid newId = Guid.NewGuid(); ValidateMandatoryFields(); DeviceConfig d = new DeviceConfig() { DeviceConfigId = newId, DeviceId = string.IsNullOrEmpty(txtDeviceId.Text) ? null : txtDeviceId.Text, ApplicationName = string.IsNullOrEmpty(txtApplicationName.Text) ? null : txtApplicationName.Text, ApplicationWebServiceURL = string.IsNullOrEmpty(txtApplicationWebServiceUrl.Text) ? null : txtApplicationWebServiceUrl.Text, ApplicationReplicationWebServiceURL = string.IsNullOrEmpty(txtApplicationReplicationWebServiceUrl.Text) ? null : txtApplicationReplicationWebServiceUrl.Text, ClientConfigWebServiceURL = string.IsNullOrEmpty(txtClientConfigWebServiceUrl.Text) ? null : txtClientConfigWebServiceUrl.Text, LicenseExpiryDate = dtpLicenseExpiryDate.Value, CustomerId = _deviceConfigCustomerId.Value, DateCreated = DateTime.Now }; if (_deviceConfigUnderUpdate != null) { d.NotifyOnInactivity = _deviceConfigUnderUpdate.NotifyOnInactivity; } _deviceConfigCache.Add(d); ClearInputControls(); RefreshGrid(newId); _unsavedChanges = true; }
public void RefreshGrid() { string originalStatus = Status; try { int selectedRowIndex = -1; if (grdDeviceConfigs.SelectedRows.Count > 0) { selectedRowIndex = grdDeviceConfigs.SelectedRows[0].Index; } if (_filtersEnabled) { Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add(EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceId, false), txtFilterDeviceId.Text); properties.Add(EntityReader <DeviceConfig> .GetPropertyName(p => p.ApplicationName, false), txtFilterApplicationName.Text); grdDeviceConfigs.DataSource = _deviceConfigCache.GetDataTable( properties, false, true, chkFilterExpired.Checked, _filteredDeviceConfigCache); //After this call the filtered cache will only contain the items included while the filtered was applied. } else { grdDeviceConfigs.DataSource = _deviceConfigCache.GetDataTable(null, false, true); _filteredDeviceConfigCache.Clear(); _deviceConfigCache.ToList().ForEach(p => _filteredDeviceConfigCache.Add(p)); } _hiddenColumns.ForEach(c => grdDeviceConfigs.Columns[c].Visible = false); if (selectedRowIndex < grdDeviceConfigs.Rows.Count && selectedRowIndex > -1) { grdDeviceConfigs.Rows[selectedRowIndex].Selected = true; } grdDeviceConfigs.Refresh(); } finally { if (Status != originalStatus) { Status = originalStatus; } } }