예제 #1
0
        //Loading filtered data
        private void LoadData()
        {
            try
            {
                using (var db = new ApirsRepository <tblBasin>())
                {
                    try
                    {
                        Basins         = new BindableCollection <tblBasin>(db.GetModel().ToList());
                        this.allBasins = Basins;

                        if (Basins.Count == 0)
                        {
                            SelectedBasin = new tblBasin()
                            {
                                basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId
                            };
                        }
                        else if (Basins.Count > 1)
                        {
                            SelectedBasin = Basins.First();
                        }
                        else
                        {
                            SelectedBasin = Basins.First();
                        }
                    }
                    catch
                    {
                        Basins         = new BindableCollection <tblBasin>();
                        this.allBasins = Basins;
                        SelectedBasin  = new tblBasin()
                        {
                            basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId
                        };
                    }
                }
                using (var db = new ApirsRepository <LithostratigraphyUnion>())
                {
                    try
                    {
                        Lithostratigraphy = new BindableCollection <LithostratigraphyUnion>(db.GetCompleteLithostratigraphy().ToList());
                    }
                    catch
                    {
                        Lithostratigraphy = new BindableCollection <LithostratigraphyUnion>();
                    }
                }
            }
            catch
            {
                Basins        = new BindableCollection <tblBasin>();
                SelectedBasin = new tblBasin()
                {
                    basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId
                };
            }
        }
예제 #2
0
        // Sets up the form so that user can enter data. Data is later
        // saved when user clicks Commit.
        public void Add()
        {
            try
            {
                if (!DataValidation.CheckPrerequisites(CRUD.Add))
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            SelectedBasin = new tblBasin()
            {
                basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId
            };
        }
예제 #3
0
        /// <summary>
        /// Refreshing the dataset
        /// </summary>
        public override void Refresh()
        {
            try
            {
                if (!DataValidation.CheckPrerequisites(CRUD.Add))
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            tblBasin current = SelectedBasin;
            int      id      = 0;

            try
            {
                if (SelectedBasin != null)
                {
                    id = SelectedBasin.basIdPk;
                }

                LoadData();
                SelectedBasin = Basins.Where(p => p.basIdPk == id).First();
            }
            catch
            {
                try
                {
                    LoadData();
                    SelectedBasin = new tblBasin()
                    {
                        basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId
                    };
                }
                catch
                {
                    ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occurred.");
                }
            }
        }