protected void ShowDataEntry(IDataEntryDataService dataService, ISampleSelectorRepository sampleSelectorRepository)
        {
            try
            {
                using (var dataEntryView = new FormDataEntry(this.ApplicationController
                                                             , ApplicationSettings.Instance
                                                             , dataService, sampleSelectorRepository))
                {
#if !NetCF
                    dataEntryView.ShowDialog(MainView);
#else
                    dataEntryView.ShowDialog();
#endif
                }
            }
            catch (UserFacingException e)
            {
                var exType = e.GetType();

                MessageBox.Show(e.Message, exType.Name);
            }
            finally
            {
                SaveData(dataService, sampleSelectorRepository);
            }
        }
        public LayoutPlotLogic(PlotStratum stratum
                               , LayoutPlot view
                               , IPlotDataService dataService
                               , ISoundService soundService
                               , IDialogService dialogService
                               , ApplicationSettings settings
                               , IViewController viewController
                               , ISampleSelectorRepository sampleSelectorRepository)
        {
            SampleSelectorRepository = sampleSelectorRepository;
            Stratum        = stratum;
            View           = view;
            DataService    = dataService;
            _soundService  = soundService;
            _dialogService = dialogService;
            _appSettings   = settings;
            ViewController = viewController;

            _BS_Plots = new BindingSource();
            _BS_Trees = new BindingSource();
            ((System.ComponentModel.ISupportInitialize)(_BS_Plots)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(_BS_Trees)).BeginInit();

            _BS_Plots.DataSource      = typeof(Plot);
            _BS_Plots.CurrentChanged += new System.EventHandler(_BS_Plots_CurrentChanged);

            _BS_Trees.DataSource      = typeof(Tree);
            _BS_Trees.CurrentChanged += new System.EventHandler(_BS_Trees_CurrentChanged);

            ((System.ComponentModel.ISupportInitialize)(_BS_Plots)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(_BS_Trees)).EndInit();

            _BS_Plots.DataSource = Stratum.Plots;
        }
        public LayoutPlot(IPlotDataService dataService,
                          ISampleSelectorRepository sampleSelectorRepository,
                          ApplicationSettings appSettings,
                          ISoundService soundService,
                          IViewController viewController,
                          PlotStratum stratum) : this()
        {
            SampleSelectorRepository = sampleSelectorRepository;
            //Stratum = stratum;
            DataService = dataService;
            AppSettings = appSettings;
            this.ViewLogicController = new LayoutPlotLogic(stratum,
                                                           this,
                                                           dataService,
                                                           soundService,
                                                           DialogService.Instance,
                                                           AppSettings,
                                                           viewController,
                                                           sampleSelectorRepository);

            WireSplitter(stratum);

            InitializeDataGrid(stratum);

            //no need to load tallies....?
            //Controller.PopulateTallies(this.StratumInfo, this._mode, Controller.CurrentUnit, this._tallyListPanel, this);
        }
示例#4
0
 public FormDataEntry(IApplicationController controller,
                      ApplicationSettings appSettings,
                      IDataEntryDataService dataService,
                      ISampleSelectorRepository sampleSelectorRepository) : this()
 {
     InitializeCommon(controller, appSettings, dataService, sampleSelectorRepository);
 }
示例#5
0
        public FormTallySettings(ICountTreeDataService dataService,
                                 ISampleSelectorRepository sampleSelectorRepository) : this()
        {
            DataService = dataService;
            SampleSelectorRepository = sampleSelectorRepository;

            InitializeData();
        }
 public LayoutTreeBased(IDataEntryDataService dataService,
                        ISampleSelectorRepository sampleSelectorRepository,
                        ApplicationSettings appSettings,
                        FormDataEntryLogic dataEntryController)
     : this()
 {
     Initialize(dataService,
                sampleSelectorRepository,
                appSettings,
                dataEntryController,
                _leftContentPanel);
 }
示例#7
0
        public FormDataEntry(IApplicationController controller,
                             ApplicationSettings appSettings,
                             IDataEntryDataService dataService,
                             ISampleSelectorRepository sampleSelectorRepository)
        {
            InitializeComponent();
            _startupStopwatch = new System.Diagnostics.Stopwatch();
            _startupStopwatch.Start();

            InitializeCommon(controller, appSettings, dataService, sampleSelectorRepository);

            UpdateAddTreeButton();
        }
        protected void Initialize(IDataEntryDataService dataService,
                                  ISampleSelectorRepository sampleSelectorRepository,
                                  ApplicationSettings appSettings,
                                  FormDataEntryLogic dataEntryController,
                                  Panel strataViewContainer)
        {
            SampleSelectorRepository = sampleSelectorRepository;
            AppSettings         = appSettings;
            StrataViewContainer = strataViewContainer;
            DataEntryController = dataEntryController;
            DataService         = dataService;

            InitializeStrataViews();
        }
示例#9
0
        public FormDataEntryLogic(IApplicationController controller,
                                  IDialogService dialogService,
                                  ISoundService soundService,
                                  IDataEntryDataService dataService,
                                  IApplicationSettings settings,
                                  IDataEntryView view,
                                  ISampleSelectorRepository sampleSelectorRepository)
        {
            this.Controller = controller;
            this.View       = view;

            _dialogService      = dialogService;
            _soundService       = soundService;
            _dataService        = dataService;
            _appSettings        = settings;
            _sampleSelectorRepo = sampleSelectorRepository;
        }
示例#10
0
        public LayoutPlot(IDataEntryDataService dataService
                          , ISampleSelectorRepository sampleSelectorRepository
                          , ApplicationSettings appSettings
                          , ISoundService soundService
                          , IViewController viewController
                          , PlotStratum stratum) : this()
        {
            SampleSelectorRepository = sampleSelectorRepository;
            DataService = dataService;
            AppSettings = appSettings;

            this.ViewLogicController = new LayoutPlotLogic(stratum,
                                                           this,
                                                           dataService,
                                                           soundService,
                                                           DialogService.Instance,
                                                           AppSettings,
                                                           viewController,
                                                           sampleSelectorRepository);

            //Setup DataGrid
            _tableStyle = stratum.InitializeTreeColumns(_dataGrid);

            _speciesColumn    = _tableStyle.GridColumnStyles["TreeDefaultValue"] as EditableComboBoxColumn;
            _sgColumn         = _tableStyle.GridColumnStyles["SampleGroup"] as EditableComboBoxColumn;
            _treeNumberColumn = _tableStyle.GridColumnStyles["TreeNumber"] as EditableTextBoxColumn;
            _initialsColoumn  = _tableStyle.GridColumnStyles["Initials"] as EditableComboBoxColumn;
            _logsColumn       = _tableStyle.GridColumnStyles["LogCountActual"] as DataGridButtonColumn;
            _kpiColumn        = _tableStyle.GridColumnStyles["KPI"] as EditableTextBoxColumn;
            _errorsColumn     = _tableStyle.GridColumnStyles["Error"] as DataGridTextBoxColumn;

            if (_logsColumn != null)
            {
                _logsColumn.Click += this.LogsClicked;
                LogColumnVisable   = DataService.EnableLogGrading;
            }
            Settings_CruisersChanged(null, null);//initialize initials column

            InitializeTallyPanel();

            this.ViewLogicController.UpdateCurrentPlot();
        }
示例#11
0
        protected void InitializeCommon(IApplicationController controller,
                                        ApplicationSettings appSettings,
                                        IDataEntryDataService dataService,
                                        ISampleSelectorRepository sampleSelectorRepository)
        {
            KeyPreview = true;

            Controller  = controller;
            DataService = dataService;
            AppSettings = appSettings;
            SampleSelectorRepository = sampleSelectorRepository;

            LogicController = new FormDataEntryLogic(Controller,
                                                     DialogService.Instance,
                                                     SoundService.Instance,
                                                     DataService,
                                                     AppSettings,
                                                     this,
                                                     sampleSelectorRepository);

            InitializePageContainer();
        }
        void SaveData(IDataEntryDataService dataService, ISampleSelectorRepository sampleSelectorRepository)
        {
            try
            {
                sampleSelectorRepository.SaveSamplerStates();

                Exception ex;

                ex = dataService.SaveNonPlotData();
                ex = dataService.SavePlotData() ?? ex;
                if (ex != null)
                {
                    throw ex;
                }

                ApplicationController.OnLeavingCurrentUnit();
            }
            catch (FMSC.ORM.ReadOnlyException)
            {
                MessageBox.Show("File Is Read Only \r\n" + dataService.DataStore.Path);
            }
            catch (FMSC.ORM.ConstraintException ex)
            {
                MessageBox.Show("Data Constraint Failed\r\n" + ex.Message, "Error");
                if (DialogService.AskYesNo("Would you like to go back to data entry?", string.Empty))
                {
                    ShowDataEntry(dataService, sampleSelectorRepository);
                }
            }
            catch (Exception ex)
            {
                ReportException(ex);
                if (DialogService.AskYesNo("Would you like to go back to data entry?", string.Empty))
                {
                    ShowDataEntry(dataService, sampleSelectorRepository);
                }
            }
        }
示例#13
0
        public static void OnTally(CountTree count,
                                   IDataEntryDataService dataService, ICollection <TallyAction> tallyHistory,
                                   IApplicationSettings appSettings, IDataEntryView view,
                                   IDialogService dialogService, ISoundService soundService,
                                   ISampleSelectorRepository sampleSelectorRepository)
        {
            TallyAction action  = null;
            SampleGroup sg      = count.SampleGroup;
            var         sampler = sampleSelectorRepository.GetSamplerBySampleGroupCode(sg.Stratum.Code, sg.Code);


            if (sampler == null)
            {
            }
            // if doing a manual tally create a tree and jump out
            else if (sampler is ExternalSampleSelectorPlaceholder)
            {
                try
                {
                    action = new TallyAction(count);
                    var newTree = dataService.CreateNewTreeEntry(count, true); //create measure tree
                    newTree.TreeCount = sg.SamplingFrequency;                  //increment tree count on tally
                    action.TreeRecord = newTree;
                }
                catch (FMSC.ORM.SQLException) //count save fail
                {
                    dialogService.ShowMessage("File error");
                }
            }
            else if (count.SampleGroup.Stratum.Is3P)//threeP sampling
            {
                action = TallyThreeP(count, sampler, sg, dataService, dialogService);
            }
            else//non 3P sampling (STR)
            {
                action = TallyStandard(count, sampler, dataService, dialogService);
            }

            //action may be null if cruising 3P and user doesn't enter a kpi
            if (action != null)
            {
                dataService.SaveTallyAction(action);
                soundService.SignalTally();

                var tree = action.TreeRecord;
                if (tree != null)
                {
                    if (tree.CountOrMeasure == "M")
                    {
                        soundService.SignalMeasureTree();
                    }
                    else if (tree.CountOrMeasure == "I")
                    {
                        soundService.SignalInsuranceTree();
                    }

                    if (appSettings.EnableCruiserPopup)
                    {
                        dialogService.AskCruiser(tree);
                        tree.TrySave();
                    }
                    else
                    {
                        var sampleType = (tree.CountOrMeasure == "M") ? "Measure Tree" :
                                         (tree.CountOrMeasure == "I") ? "Insurance Tree" : String.Empty;
                        dialogService.ShowMessage("Tree #" + tree.TreeNumber.ToString(), sampleType);
                    }

                    if (tree.CountOrMeasure == "M" && AskEnterMeasureTreeData(appSettings, dialogService))
                    {
                        view.GotoTreePage();
                        //this.View.TreeViewMoveLast();
                    }
                }
                tallyHistory.Add(action);
            }
        }