private void CbChannelId_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (_ChannelList != null && _ChannelList.Count > 0) { string id = cbChannelId.SelectedIndex.ToString(); ChannelItem c = _ChannelList.Where(x => x.ChannelId.Equals(id)).SingleOrDefault(); if (c != null) { txtChannelName.Text = c.ChannelName; txtAddress.Text = c.Address; } } } catch (Exception) { } }
public static void InsertData(ChannelItem channel) { using (SqliteConnection con = new SqliteConnection("Filename=ChannelDB.db")) { try { con.Open(); SqliteCommand insertCommand = new SqliteCommand(); insertCommand.Connection = con; insertCommand.CommandText = "INSERT INTO T_CHANNEL VALUES (@CHANNEL_ID, @CHANNEL_NAME,@ADDRESS);"; insertCommand.Parameters.AddWithValue("@CHANNEL_ID", channel.ChannelId); insertCommand.Parameters.AddWithValue("@CHANNEL_NAME", channel.ChannelName); insertCommand.Parameters.AddWithValue("@ADDRESS", channel.Address); insertCommand.ExecuteReader(); con.Close(); } catch (Exception) { //TODO } } }