public SelectHeader(List <string> fieldnames)
        {
            InitializeComponent();

            // TheList is name of our listbox
            TheList = new ObservableCollection <BoolStringClass>();
            Headers = fieldnames;

            // load the list with headers and checkboxes in the first place
            foreach (string item in fieldnames)
            {
                BoolStringClass checkboxobject = new BoolStringClass();
                checkboxobject.IsSelected = true;
                checkboxobject.TheText    = item;
                TheList.Add(checkboxobject);
                NumberOfColumns++;
            }

            this.ListBoxHeaders.ItemsSource = TheList;

            // set the selected headers to true
            if (NumberOfColumns != 0)
            {
                SelectedHeaders = new bool[NumberOfColumns];
                for (int i = 0; i < NumberOfColumns; i++)
                {
                    SelectedHeaders[i] = true;
                }
            }
        }
        private void Select_Click(object sender, RoutedEventArgs e)
        {
            //Acts like switch for turn on/off the selected and unselected
            this.IsAllSelected = !this.IsAllSelected;

            //Delete everything from the list
            TheList.Clear();


            if (IsAllSelected) //If we decide that select all
            {
                //If we select all, the "se selected" button should be enabled
                btnUseSelected.IsEnabled = true;

                // Load the list with headers and set the checkboxes to true
                for (int i = 0; i < Headers.Count; i++)
                {
                    BoolStringClass checkboxobject = new BoolStringClass();
                    checkboxobject.IsSelected = true;
                    checkboxobject.TheText    = Headers[i];
                    TheList.Add(checkboxobject);
                    NumberOfColumns++;
                }
            }
            else //If we decide unselect all
            {
                // Disable the select button
                btnUseSelected.IsEnabled = false;

                // Populate the data and unckeck the boxes
                for (int i = 0; i < Headers.Count; i++)
                {
                    BoolStringClass checkboxobject = new BoolStringClass();
                    checkboxobject.IsSelected = false;
                    checkboxobject.TheText    = Headers[i];
                    TheList.Add(checkboxobject);
                    NumberOfColumns++;
                }
            }
        }
Exemple #3
0
        public static void SaveStandards(List <BoolStringClass> standards)
        {
            string path = Directory.GetCurrentDirectory() + "\\database.srph";
            //IObjectContainer db;
            IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();

            config.Common.ObjectClass(typeof(BoolStringClass)).CascadeOnUpdate(true);
            config.Common.ObjectClass(typeof(BoolStringClass)).CascadeOnDelete(true);
            config.Common.ObjectClass(typeof(BoolStringClass)).CascadeOnActivate(true);

            //db = Db4oEmbedded.OpenFile(config, path);

            using (IObjectContainer db = Db4oEmbedded.OpenFile(config, path))
            {
                foreach (var item in standards)
                {
                    var standard = new BoolStringClass(item.StandardName, item.StandardPrice, item.IsPermamentOrIsNotPermament);

                    db.Store(standard);
                    db.Commit();
                    db.Close();
                }
            }
        }