Пример #1
0
        /// <summary>
        /// Refreshing the dataset
        /// </summary>
        public override void Refresh()
        {
            if (!DataValidation.CheckPrerequisites(CRUD.Load))
            {
                return;
            }

            tblMeasuringDevice current = SelectedAnalyticalInstrument;
            int id = 0;

            try
            {
                if (SelectedAnalyticalInstrument != null)
                {
                    id = SelectedAnalyticalInstrument.mdIdPk;
                }

                LoadData();
                SelectedAnalyticalInstrument = AnalyticalInstruments.Where(p => p.mdIdPk == id).First();
            }
            catch
            {
                try
                {
                    LoadData();
                    SelectedAnalyticalInstrument = new tblMeasuringDevice();
                }
                catch
                {
                    ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured.");
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Go to the first dataset
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void First()
 {
     if (AnalyticalInstruments.Count != 0)
     {
         SelectedAnalyticalInstrument = AnalyticalInstruments.First();
     }
 }
Пример #3
0
        //Loading filtered data
        private async void LoadData()
        {
            if (!ServerInteractionHelper.IsNetworkAvailable() && !ServerInteractionHelper.TryAccessDatabase())
            {
                AnalyticalInstruments        = new BindableCollection <tblMeasuringDevice>();
                SelectedAnalyticalInstrument = new tblMeasuringDevice();
                return;
            }

            try
            {
                await Task.Run(() =>
                {
                    using (var db = new ApirsRepository <tblMeasuringDevice>())
                    {
                        AnalyticalInstruments = new BindableCollection <tblMeasuringDevice>(db.GetModel().ToList());
                    }
                });

                this.allAnalyticalInstruments = AnalyticalInstruments;

                if (AnalyticalInstruments.Count == 0)
                {
                    SelectedAnalyticalInstrument = new tblMeasuringDevice();
                }
                else if (AnalyticalInstruments.Count > 1)
                {
                    SelectedAnalyticalInstrument = AnalyticalInstruments.First();
                }
                else
                {
                    SelectedAnalyticalInstrument = AnalyticalInstruments.First();
                }
            }
            catch (Exception e)
            {
                AnalyticalInstruments         = new BindableCollection <tblMeasuringDevice>();
                this.allAnalyticalInstruments = AnalyticalInstruments;
                SelectedAnalyticalInstrument  = new tblMeasuringDevice();
            }
        }