示例#1
0
        private void Reload()
        {
            if (fetching)
            {
                return;
            }

            fetching = true;

            if (Row.DefaultRow == null)
            {
                Row.DefaultRow = Table.Controls[0].Clone();
            }

            Project.GetAll((res) =>
            {
                Data = res;
                Table.Controls.Clear();
                Table.RowStyles.Clear();
                Table.RowCount = Data.Count();
                Data.ForEach(x =>
                {
                    var row        = new Row(x);
                    RowStyle style = new RowStyle()
                    {
                        SizeType = SizeType.Absolute,
                        Height   = 48
                    };
                    Table.Controls.Add(row.control);
                    row.Clicked += (s, e) => PhaseSelection.Open(s as Project);
                    SetMenu(x, row.control);
                    Table.RowStyles.Add(style);
                });
                Table.Controls.Add(new Panel());
                Table.Refresh();
                fetching = false;
            });

            void SetMenu(Project p, Control c)
            {
                var Menu = new ContextMenu();

                c.ContextMenu = Menu;
                MenuItem edit      = new MenuItem("Edit " + p.name);
                MenuItem locations = new MenuItem("See Locations");

                Menu.MenuItems.Add(edit);
                Menu.MenuItems.Add(locations);

                edit.Click += (s, e) => NewProject.Open(p, (saved) =>
                {
                    if (saved)
                    {
                        Reload();
                    }
                });

                locations.Click += (s, e) => LocationsPage.Show(p);
            }
        }
示例#2
0
        private async void InsertDataToDB(List <Record> allrecs, List <Location> locations, List <Level1> level1s, List <Level2> level2s, List <Level3> level3s, List <Level4> level4s)
        {
            var success = false;

            while (Form1.Bar.Visible)
            {
                await Task.Delay(1000);
            }
            await Task.Run(() => success = SQL.ImportNewData(allrecs, locations, level1s, level2s, level3s, level4s));

            if (success)
            {
                MessageBox.Show("Successfully imported data");
            }
            else
            {
                MessageBox.Show("Failed to import all the data");
            }
            Form1.Main.SafeInvoke(x => LocationsPage.Show(project));
        }