Ejemplo n.º 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.");
                }
            }
        }
Ejemplo n.º 2
0
        // Sets up the form so that user can enter data. Data is later
        // saved when user clicks Commit.
        public void Add()
        {
            if (!DataValidation.CheckPrerequisites(CRUD.Add))
            {
                return;
            }

            SelectedAnalyticalInstrument = new tblMeasuringDevice();
            SelectedAnalyticalInstrument.mdUploaderId = (int)((ShellViewModel)IoC.Get <IShell>()).UserId;
        }
Ejemplo n.º 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();
            }
        }