コード例 #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ConferenceEditWindow" /> class.
 /// </summary>
 /// <param name="conf">The conference to be edited.</param>
 public ConferenceEditWindow(Conference conf)
     : this()
 {
     _curConf = conf;
     txtName.Text = conf.Name;
     txtDivisions.Text = "";
     MainWindow.Divisions.Where(division => division.ConferenceID == conf.ID)
               .ToList()
               .ForEach(division => txtDivisions.Text += division.Name + "\n");
     txtDivisions.Text = txtDivisions.Text.TrimEnd(new[] { '\n' });
 }
コード例 #2
0
        /// <summary>Handles the Click event of the btnAdd control. Allows the user to add a new item.</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 btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var ibw = new InputBoxWindow("Enter the name for the new conference:");
            if (ibw.ShowDialog() == true)
            {
                var name = InputBoxWindow.UserInput.Replace(':', '-');
                if (MainWindow.Conferences.Any(conference => conference.Name == name))
                {
                    MessageBox.Show("There's already a conference with the name " + name + ".");
                    return;
                }
                var usedIDs = new List<int>();
                MainWindow.Conferences.ForEach(conference => usedIDs.Add(conference.ID));
                var i = 0;
                while (usedIDs.Contains(i))
                {
                    i++;
                }

                MainWindow.Conferences.Add(new Conference { ID = i, Name = name });

                var db = new SQLiteDatabase(MainWindow.CurrentDB);
                db.Insert("Conferences", new Dictionary<string, string> { { "ID", i.ToString() }, { "Name", name } });
                lstData.ItemsSource = null;
                lstData.ItemsSource = MainWindow.Conferences;

                var confToEdit = new Conference();
                foreach (Conference item in lstData.Items)
                {
                    if (item.Name == name)
                    {
                        confToEdit = item;
                        break;
                    }
                }

                showEditConferenceWindow(confToEdit);
            }
        }
コード例 #3
0
        /// <summary>Shows the edit conference window, and reloads the conferences the window is closed, if required.</summary>
        /// <param name="conf">The conf.</param>
        private void showEditConferenceWindow(Conference conf)
        {
            var cew = new ConferenceEditWindow(conf);
            cew.ShowDialog();

            if (MustUpdate)
            {
                lstData.ItemsSource = null;
                lstData.ItemsSource = MainWindow.Conferences;
            }
        }