Ejemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                InitChannelIds = new List <int>();

                using (GeelyPtlEntities dbContext = new GeelyPtlEntities())
                {
                    channelSelModels = new List <ChannelSelModel>();

                    List <CFG_Channel> cfgChannels = dbContext.CFG_Channels.OrderBy(t => t.Id).ToList();

                    foreach (CFG_Channel cfgChannel in cfgChannels)
                    {
                        ChannelSelModel channelSelModel = new ChannelSelModel();
                        channelSelModel.Id        = cfgChannel.Id;
                        channelSelModel.Code      = cfgChannel.Code;
                        channelSelModel.Name      = cfgChannel.Name;
                        channelSelModel.IsChecked = false;

                        channelSelModels.Add(channelSelModel);
                    }

                    this.dataGrid.ItemsSource = channelSelModels;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }