private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (_ShipCombo != null) { _ShipCombo.SelectedIndex = _ShipCombo.FindStringExact(_ShipCombo.Text); if (_ShipCombo.SelectedIndex != -1) { long charactedID = (long)dataGridView[CharacterID.Index, e.RowIndex].Value; IntelData.IntelDataRow row = _IntelData.IntelDataTable.Single(o => o.CharacterID == charactedID); row.ShipTypeID = (int?)_ShipCombo.SelectedValue; row.ShipTypeTime = DateTime.UtcNow; _IntelData.IntelDataTable.AddOrUpdate(row); _IntelData.SaveChanges(); dataGridView.Refresh(); } } }
public void ClientIntelUpdate(List <EveIntelCharacterInfo> characters) { IntelData intelData = new IntelData();; foreach (EveIntelCharacterInfo character in characters) { var stored = intelData.IntelDataTable.FirstOrDefault(o => o.CharacterID == character.CharacterID); if (stored != null) { stored.SolarsystemID = character.SolarsystemID; stored.SolarsystemTime = character.SolarsystemTime; stored.ShipTypeID = character.ShipTypeID; stored.ShipTypeTime = character.ShipTypeTime; stored.Notes = character.Notes; } else { var row = new IntelData.IntelDataRow(); row.CharacterID = character.CharacterID; row.CharacterName = character.CharacterName; row.CharacterKos = character.CharacterKos; row.CorporationName = character.CorporationName; row.CorporationKos = character.CorporationKos; row.AllianceName = character.AllianceName; row.AllianceKos = character.AllianceKos; row.SolarsystemID = character.SolarsystemID; row.SolarsystemTime = character.SolarsystemTime; row.ShipTypeID = character.ShipTypeID; row.ShipTypeTime = character.ShipTypeTime; row.Notes = character.Notes; intelData.IntelDataTable.Add(row); } } intelData.SaveChanges(); //mapControl1.UpdateData(); intelGrid1.UpdateData(); }