public DialogResult ShowDialog(TreeDefaultValueDO tdv)
        {
            this._viewLoading = true;
            this.TreeDefaultValue = tdv;

            this._primaryFieldsPanel.Enabled = !tdv.IsPersisted;

            return this.ShowDialog();
        }
Exemplo n.º 2
0
        private void _editTDV_BTN_Click(object sender, EventArgs e)
        {
            TreeDefaultValueDO tdv = new TreeDefaultValueDO();

            using (var view = new FormEditTreeDefault((FMSC.ORM.Core.DatastoreRedux)null))
            {
                view.Load += (Object sndr, EventArgs args) =>
                    {
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.SPECIES).Text = "test";
                        view.Controls.Find<ComboBox>(TREEDEFAULTVALUE.LIVEDEAD).Text = "D";
                        view.Controls.Find<ComboBox>(TREEDEFAULTVALUE.PRIMARYPRODUCT).Text = "02";
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.FIACODE).Text = 1.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.AVERAGEZ).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.BARKTHICKNESSRATIO).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.CONTRACTSPECIES).Text = "test";
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.CULLPRIMARY).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.CULLSECONDARY).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.FORMCLASS).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.HIDDENPRIMARY).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.HIDDENSECONDARY).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.MERCHHEIGHTLOGLENGTH).Text = 1.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.MERCHHEIGHTTYPE).Text = "test";
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.RECOVERABLE).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.REFERENCEHEIGHTPERCENT).Text = .2f.ToString();
                        view.Controls.Find<TextBox>(TREEDEFAULTVALUE.TREEGRADE).Text = "test";
                    };
                view.ShowDialog(tdv);

                Debug.Assert(tdv.Species == "test");
                Debug.Assert(tdv.LiveDead == "D");
                Debug.Assert(tdv.PrimaryProduct == "02");
                Debug.Assert(tdv.FIAcode == 1);

                Debug.Assert(tdv.AverageZ == .2f);
                Debug.Assert(tdv.BarkThicknessRatio == .2f);
                Debug.Assert(tdv.ContractSpecies == "test");
                Debug.Assert(tdv.CullPrimary == .2f);
                Debug.Assert(tdv.CullSecondary == .2f);
                Debug.Assert(tdv.FormClass == .2f);
                Debug.Assert(tdv.HiddenPrimary == .2f);
                Debug.Assert(tdv.HiddenSecondary == .2f);
                Debug.Assert(tdv.MerchHeightLogLength == 1);
                Debug.Assert(tdv.MerchHeightType == "test");
                Debug.Assert(tdv.Recoverable == .2f);
                Debug.Assert(tdv.ReferenceHeightPercent == .2f);
                Debug.Assert(tdv.TreeGrade == "test");
            }
        }
        public static void SetTreeTDV(TreeVM tree, TreeDefaultValueDO tdv)
        {
            tree.TreeDefaultValue = tdv;
            if (tdv != null)
            {
                tree.Species = tdv.Species;

                tree.LiveDead = tdv.LiveDead;
                tree.Grade = tdv.TreeGrade;
                tree.FormClass = tdv.FormClass;
                tree.RecoverablePrimary = tdv.Recoverable;
                //tree.HiddenPrimary = tdv.HiddenPrimary; //#367
            }
            else
            {
                //tree.Species = string.Empty;
                //tree.LiveDead = string.Empty;
                //tree.Grade = string.Empty;
                //tree.FormClass = 0;
                //tree.RecoverablePrimary = 0;
                //tree.HiddenPrimary = 0;
            }
        }
 //public TreeDefaultValueDO CheckForExistingRecord(TreeDefaultValueDO tdv)
 //{
 //    CruiseDAL.DAL db = tdv.DAL;
 //    TreeDefaultValueDO tdv2 = db.ReadSingleRow<TreeDefaultValueDO>(CruiseDAL.Schema.TREEDEFAULTVALUE._NAME, "WHERE Species = ? and LiveDead = ? and Chargeable = ? and PrimaryProduct = ?", tdv.Species, tdv.LiveDead, tdv.Chargeable, tdv.PrimaryProduct);
 //    return (tdv2 != null) ? tdv2 : tdv;
 //}
 private void CreateCountRecord(SGType sg, TreeDefaultValueDO tdv)
 {
 }
Exemplo n.º 5
0
		public void SetValues(TreeDefaultValueDO obj)
		{
			if(obj == null) { return; }
			PrimaryProduct = obj.PrimaryProduct;
			Species = obj.Species;
			LiveDead = obj.LiveDead;
			FIAcode = obj.FIAcode;
			CullPrimary = obj.CullPrimary;
			HiddenPrimary = obj.HiddenPrimary;
			CullSecondary = obj.CullSecondary;
			HiddenSecondary = obj.HiddenSecondary;
			Recoverable = obj.Recoverable;
			ContractSpecies = obj.ContractSpecies;
			TreeGrade = obj.TreeGrade;
			MerchHeightLogLength = obj.MerchHeightLogLength;
			MerchHeightType = obj.MerchHeightType;
			FormClass = obj.FormClass;
			BarkThicknessRatio = obj.BarkThicknessRatio;
			AverageZ = obj.AverageZ;
			ReferenceHeightPercent = obj.ReferenceHeightPercent;
		}
Exemplo n.º 6
0
        public void SetTreeTDV(TreeDefaultValueDO tdv)
        {
            //if (tdv == _newPopPlaceHolder && this.SampleGroup != null)
            //{
            //    tdv = ViewController.ShowAddPopulation(this.SampleGroup);
            //}

            this.TreeDefaultValue = tdv;
            if (tdv != null)
            {
                this.Species = tdv.Species;

                this.LiveDead = tdv.LiveDead;
                this.Grade = tdv.TreeGrade;
                this.FormClass = tdv.FormClass;
                this.RecoverablePrimary = tdv.Recoverable;
                //tree.HiddenPrimary = tdv.HiddenPrimary;//#367
            }
            else
            {
                this.Species = string.Empty;
                this.LiveDead = string.Empty;
                this.Grade = string.Empty;
                this.FormClass = 0;
                this.RecoverablePrimary = 0;
                //this.HiddenPrimary = 0;
            }
        }
 public abstract void ShowEditTreeDefault(TreeDefaultValueDO tdv);
Exemplo n.º 8
0
        public virtual TreeVM CreateNewTreeEntry(SampleGroupModel sg, TreeDefaultValueDO tdv, bool isMeasure)
        {
            Debug.Assert(this.CuttingUnit != null);
            var newTree = this.CuttingUnit.CreateNewTreeEntryInternal(this.Stratum, sg, tdv, isMeasure);

            newTree.Plot = this;
            newTree.TreeNumber = this.HighestTreeNum + 1;
            newTree.TreeCount = 1;

            return newTree;
        }
        private void copyPopulations(DAL cDAL, DAL rDAL, DAL fsDAL, bool reconData, string[] stRecCode)
        {
            StratumDO cdStr;
             TreeDefaultValueDO currentTDV = new TreeDefaultValueDO();
             List<StratumStatsDO> cdStratumStats = new List<StratumStatsDO>(cDAL.Read<StratumStatsDO>("StratumStats", "JOIN Stratum ON StratumStats.Stratum_CN = Stratum.Stratum_CN AND StratumStats.Method = Stratum.Method AND StratumStats.Used = 1 ORDER BY Stratum.Code", null));

             List<PlotDO> myPlots = new List<PlotDO>();
             List<TreeDO> myTree = new List<TreeDO>();
             List<LogDO> myLogs = new List<LogDO>();
             treeFields = new BindingList<TreeFieldSetupDO>();
             logFields = new BindingList<LogFieldSetupDO>();
             bool first;
             string method = "";
             Random rnd = new Random();
             int measHit;

             foreach (StratumStatsDO myStStats in cdStratumStats)
             {
            setRecData = false;
            first = true;

            // check if recon data is to be saved
            cdStr = fsDAL.ReadSingleRow<StratumDO>("Stratum", "Where Code = ?", myStStats.Code);
            string strCode = myStStats.Code;
            thisStrCN = (long)cdStr.Stratum_CN;
            if (reconData)
            {

               if (myStStats.Method == "PNT" || myStStats.Method == "PCM")
                  method = "PNT";
               else if (myStStats.Method == "FIX" || myStStats.Method == "FCM")
                  method = "FIX";

               foreach (string stRec in stRecCode)
               {
                  if (stRec == strCode)
                  {
                     setRecData = true;
                     myPlots = (rDAL.Read<PlotDO>("Plot", "JOIN Stratum ON Plot.Stratum_CN = Stratum.Stratum_CN WHERE Stratum.Method = ?", method));
                     if(myTree.Count == 0)
                     {
                        myTree = (rDAL.Read<TreeDO>("Tree", null, null));
                        myLogs = (rDAL.Read<LogDO>("Log", null, null));
                     }
                  }
               }
            }
               // get fsDAl stratum record
            List<SampleGroupStatsDO> mySgStats = new List<SampleGroupStatsDO>(cDAL.Read<SampleGroupStatsDO>("SampleGroupStats", "Where StratumStats_CN = ?", myStStats.StratumStats_CN));
               // loop through sample groups
            foreach (SampleGroupStatsDO sgStats in mySgStats)
            {
               measHit = 0;
               SampleGroupDO fsSg = new SampleGroupDO(fsDAL);
               // save sample group information
               fsSg.Stratum_CN = thisStrCN;
               fsSg.Code = sgStats.Code;
               fsSg.Description = sgStats.Description;
               fsSg.CutLeave = sgStats.CutLeave;
               fsSg.UOM = sgStats.UOM;
               fsSg.PrimaryProduct = sgStats.PrimaryProduct;
               fsSg.SecondaryProduct = sgStats.SecondaryProduct;
               fsSg.DefaultLiveDead = sgStats.DefaultLiveDead;
               fsSg.KZ = sgStats.KZ;
               fsSg.InsuranceFrequency = sgStats.InsuranceFrequency;
               if (myStStats.Method == "PCM" || myStStats.Method == "FCM")
               {
                  if (radioButton1.Checked)
                  {
                     fsSg.SamplingFrequency = sgStats.SamplingFrequency;
                     // find random start
                     int freq = (int)fsSg.SamplingFrequency;
                     measHit = rnd.Next(1, freq);
                     fsSg.BigBAF = 0;
                     fsSg.SmallFPS = 0;
                  }
                  else
                  {
                     fsSg.SamplingFrequency = 0;
                     fsSg.BigBAF = Convert.ToInt32(sgStats.BigBAF);
                     fsSg.SmallFPS = Convert.ToInt32(sgStats.BigFIX);
                  }
               }
               else
               {
                  fsSg.SamplingFrequency = sgStats.SamplingFrequency;
                  fsSg.BigBAF = 0;
                  fsSg.SmallFPS = 0;
               }
               // find treedefaultvalues
               sgStats.TreeDefaultValueStats.Populate();
               foreach (TreeDefaultValueDO tdv in sgStats.TreeDefaultValueStats)
               {
                  fsSg.TreeDefaultValues.Add(tdv);
               }
               fsSg.Save();
               fsSg.TreeDefaultValues.Save();
               // if recon can be saved
               if (setRecData)
               {
                  getReconData(myStStats, sgStats, rDAL, fsDAL, myPlots, myTree, myLogs, fsSg.SampleGroup_CN, first, measHit);
                 first = false;
               }
            }

            getTreeFieldSetup(cDAL,fsDAL,myStStats);
            if(logData)
               getLogFieldSetup(cDAL,fsDAL,myStStats);
             }
        }
 private bool HasUniqueConflict(TreeDefaultValueDO tdv)
 {
     if (Datastore == null) { return false; }
     return (Datastore.GetRowCount(CruiseDAL.Schema.TREEDEFAULTVALUE._NAME,
         "WHERE PrimaryProduct = ? AND Species = ? AND LiveDead = ?",
             tdv.PrimaryProduct, tdv.Species, tdv.LiveDead) > 0);
 }
        private void _newSubPopBTN_Click(object sender, EventArgs e)
        {
            //TreeDefaultValueDO newTDV = Presenter.GetNewTreeDefaultValue();
            //FormAddTreeDefault dialog = new FormAddTreeDefault(Presenter.ProductCodes);
            //if (dialog.ShowDialog(newTDV) == DialogResult.OK)
            //{
            //    newTDV.Save();
            //    this.Presenter.TreeDefaults.Add(newTDV);
            //    UpdateTDVList();

            //    int i = this.TreeDefaultBindingSource.IndexOf(newTDV);
            //    if (i >= 0)
            //    {
            //        this.TreeDefaultBindingSource.Position = i;
            //    }
            //}

            TreeDefaultValueDO newTDV = new TreeDefaultValueDO(this.Presenter.Database);
            newTDV = this.Presenter.WindowPresenter.ShowAddTreeDefault(newTDV);
            if (newTDV != null)
            {
                this.Presenter.TreeDefaults.Add(newTDV);
                this.UpdateTDVList();

                int i = this.TreeDefaultBindingSource.IndexOf(newTDV);
                if (i >= 0)
                {
                    this.TreeDefaultBindingSource.Position = i;
                }
            }
        }
        public void ReadLogsTest()
        {
            IWindowPresenter wp = new WindowPresenterStub() { Database = new CruiseDAL.DAL(readTestFile) };
            PrivateObject param0 = new PrivateObject(new DataEditorView(wp));
            DataEditorView_Accessor target = new DataEditorView_Accessor(param0);

            CuttingUnitDO cu = new CuttingUnitDO() { rowID = 1 };
            StratumDO st = new StratumDO() { rowID = 1 };
            SampleGroupDO sg = new SampleGroupDO() { rowID = 1 };
            TreeDefaultValueDO tdv = new TreeDefaultValueDO() { rowID = 1 };

            List<LogVM> actual;
            actual = target.ReadLogs(cu, st, sg, tdv);

            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public void ReadTreesTest()
        {
            IWindowPresenter wp = new WindowPresenterStub() { Database = new CruiseDAL.DAL(readTestFile) };
            PrivateObject param0 = new PrivateObject(new DataEditorView(wp));
            DataEditorView_Accessor target = new DataEditorView_Accessor(param0);

            CuttingUnitDO cu = new CuttingUnitDO() { rowID = 1 };
            StratumDO st = new StratumDO() { rowID = 1 };
            SampleGroupDO sg = new SampleGroupDO() { rowID = 1 };
            TreeDefaultValueDO tdv = new TreeDefaultValueDO() { rowID = 1 };

            List<TreeVM> actual;
            actual = target.ReadTrees(cu, st, sg, tdv);

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Count > 0);
        }
Exemplo n.º 14
0
 public override DialogResult ShowEditTreeDefault(TreeDefaultValueDO tdv)
 {
     using (FormEditTreeDefault view = new FormEditTreeDefault(ApplicationController._cDal))
     {
         return view.ShowDialog(tdv);
     }
 }
 public bool HandleSpeciesChanged(TreeVM tree, TreeDefaultValueDO tdv)
 {
     if (tree == null) { return true; }
     //if (tree.TreeDefaultValue == tdv) { return true; }
     tree.SetTreeTDV(tdv);
     return tree.TrySave();
 }
        public override void ShowEditTreeDefault(TreeDefaultValueDO tdv)
        {
            TreeDefaultValueDO temp = new TreeDefaultValueDO(tdv);

            try
            {
                using (FormAddTreeDefault dialog = new FormAddTreeDefault(this.ApplicationController.SetupService.GetProductCodes()))
                {
                    if (dialog.ShowDialog(temp) == DialogResult.OK)
                    {
                        try
                        {
                            tdv.SetValues(temp);
                            tdv.Save();
                        }
                        catch (FMSC.ORM.UniqueConstraintException ex)
                        {
                            throw new UserFacingException("Values Conflict With Existing Tree Default", ex);
                        }
                        catch (FMSC.ORM.ConstraintException ex)
                        {
                            throw new UserFacingException("Invalid Values", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (!this.ApplicationController.ExceptionHandler.Handel(ex))
                {
                    throw;
                }
            }
        }
Exemplo n.º 17
0
 public SubPop(SampleGroupModel sg, TreeDefaultValueDO tdv)
 {
     this.SG = sg;
     this.TDV = tdv;
 }
 public override DialogResult ShowEditTreeDefault(TreeDefaultValueDO tdv)
 {
     throw new NotImplementedException();
 }
        private void _BS_SPList_CurrentChanged(object sender, EventArgs e)
        {
            _currTDV = _BS_SPList.Current as TreeDefaultValueDO;
            if (_currTDV == null) { return; }

            TallyDO tally = this.CurrentSampleGroup.Tallies[_currTDV];
            CurrentTally = tally;
        }
        //*************************************************************************
        private void getSampleGroupStats()
        {
            calcStats statClass = new calcStats();
             stage = statClass.isTwoStage(Owner.currentStratum.Method);

             double comberr2 = 0;
             double totalVolume = 0;
             // for each sample group
             foreach (SampleGroupDO sg in Owner.histSampleGroup)
             {
            // create samplegroupstats
            Owner.currentSgStats = new SampleGroupStatsDO(Owner.cdDAL);
            //set foriegn key
            Owner.currentSgStats.StratumStats = Owner.currentStratumStats;
            Owner.currentSgStats.SgSet = 1;
            Owner.currentSgStats.Code = sg.Code;
            Owner.currentSgStats.CutLeave = sg.CutLeave;
            Owner.currentSgStats.UOM = sg.UOM;
            Owner.currentSgStats.PrimaryProduct = sg.PrimaryProduct;
            Owner.currentSgStats.SecondaryProduct = sg.SecondaryProduct;
            Owner.currentSgStats.DefaultLiveDead = sg.DefaultLiveDead;
            Owner.currentSgStats.Description = sg.Description;
            // get POP data
            //Owner.selectedPOP = new POPDO(Owner.hDAL);
            Owner.selectedPOP = Owner.hDAL.ReadSingleRow<POPDO>("POP", "WHERE Stratum = ? AND SampleGroup = ?", Owner.selectedStratum.Code, sg.Code);
            // calculate statistics (based on method)
            if (Owner.selectedPOP == null)
            {
               MessageBox.Show("Cruise Not Processed. Cannot Import Data.", "Warning");
               return;
            }
            n1 = Convert.ToInt32(Owner.selectedPOP.StageOneSamples);
            n2 = Convert.ToInt32(Owner.selectedPOP.StageTwoSamples);
            measTrees = Convert.ToInt32(Owner.selectedPOP.MeasuredTrees);
            talliedTrees = Convert.ToInt32(Owner.selectedPOP.TalliedTrees);
            sumKpi = Convert.ToInt32(Owner.selectedPOP.SumKPI);
            st1x = Owner.selectedPOP.Stg1NetXPP;
            st1x2 = Owner.selectedPOP.Stg1NetXsqrdPP;
            st2x = Owner.selectedPOP.Stg2NetXPP;
            st2x2 = Owner.selectedPOP.Stg2NetXsqrdPP;
            // trees per plot
            // find CVs
            cv1 = statClass.getCV(st1x, st1x2, n1);
            if (stage == 12 || stage == 22)
               cv2 = statClass.getCV(st2x, st2x2, n2);
            else
               cv2 = 0;
            // find errors stage 11=tree,single 12=tree,2 stage 21=plot,single 22=plot,2 stage
            if (stage == 11 || stage == 21)
               sampErr = statClass.getSampleError(cv1, n1, 0);
            else if (stage == 12 || stage == 22)
               sampErr = statClass.getTwoStageError(cv1, cv2, n1, n2);
            else
               sampErr = 0;
            Owner.currentSgStats.CV1 = Convert.ToSingle(cv1);
            Owner.currentSgStats.CV2 = Convert.ToSingle(cv2);
            Owner.currentSgStats.SampleSize1 = n1;
            Owner.currentSgStats.SampleSize2 = n2;
            // calculate frequency

            Owner.currentSgStats.SgError = Convert.ToSingle(sampErr);

            // get LCD data
            Owner.selectedLCD = Owner.hDAL.Read<LCDDO>("LCD", "WHERE Stratum = ? AND SampleGroup = ?", Owner.selectedStratum.Code, sg.Code);
            sumExpFac = 0;
            sumNetVol = 0;
            //foreach (SampleGroupDO sg in Owner.histSampleGroup)
            foreach (LCDDO lcd in Owner.selectedLCD)
            {
               // sum volume
               double expFac = lcd.SumExpanFactor;
               sumExpFac += expFac;
               // sum trees
               double netVol = lcd.SumNCUFT;
               sumNetVol += netVol;
            }
            comberr2 += (sampErr * sumNetVol) * (sampErr * sumNetVol);
            totalVolume += sumNetVol;
            // find volume/acre and trees/acre
            if (stage < 20)
            {
               Owner.currentSgStats.TreesPerAcre = Convert.ToSingle(Math.Round((sumExpFac / totalAcres), 2));
               Owner.currentSgStats.VolumePerAcre = Convert.ToSingle(Math.Round((sumNetVol / totalAcres), 2));
            }
            else
            {
               Owner.currentSgStats.TreesPerAcre = Convert.ToSingle(Math.Round((sumExpFac), 2));
               Owner.currentSgStats.VolumePerAcre = Convert.ToSingle(Math.Round((sumNetVol), 2));
               if(stage == 21)
                  Owner.currentSgStats.TreesPerPlot = Convert.ToSingle(Math.Round((Convert.ToSingle((float)measTrees / (float)n1)), 1));
               else
                  Owner.currentSgStats.TreesPerPlot = Convert.ToSingle(Math.Round((Convert.ToSingle((float)talliedTrees / (float) n1)), 1));
            }
            // find frequency/KZ/BigBAF values
            if ((stage == 11 || stage == 12 || stage == 22) && measTrees > 0)
            {
               freq = Convert.ToInt32((talliedTrees / measTrees));
               kz = Convert.ToInt32((sumKpi / measTrees));

               if (Owner.currentStratum.Method == "S3P")
               {
                  Owner.currentSgStats.SamplingFrequency = Convert.ToInt32((talliedTrees / n1));
                  Owner.currentSgStats.KZ = kz;
               }
               else
               {
                  Owner.currentSgStats.SamplingFrequency = freq;
                  Owner.currentSgStats.KZ = kz;
               }
            }

            // save samplegroupstats row
            Owner.currentSgStats.Save();
            // loop through TDV information
            sg.TreeDefaultValues.Populate();
            foreach (TreeDefaultValueDO tdv in sg.TreeDefaultValues)
            {
               // check with current TDV values
               Owner.currentTreeDefaults = Owner.cdDAL.ReadSingleRow<TreeDefaultValueDO>("TreeDefaultValue", "WHERE Species = ? AND PrimaryProduct = ? AND LiveDead = ?",tdv.Species,tdv.PrimaryProduct,tdv.LiveDead);
               if (Owner.currentTreeDefaults == null)
               {
                  // if null, add tdv to list then create link
                  TreeDefaultValueDO newTdv = new TreeDefaultValueDO(Owner.cdDAL);
                  newTdv.SetValues(tdv);
                  newTdv.Save();
                  Owner.currentSgStats.TreeDefaultValueStats.Add(newTdv);
               }
               else
               {
                  // if exists, create link
                  Owner.currentSgStats.TreeDefaultValueStats.Add(Owner.currentTreeDefaults);
               }
            }

            Owner.currentSgStats.Save();
            Owner.currentSgStats.TreeDefaultValueStats.Save();

             }
             // calculate stats for stratum
            // double stratumError = Math.Sqrt(comberr2) / totalVolume;
             // wted CVs
             //Owner.currentStratumStats.StrError = Convert.ToSingle(stratumError);

             //Owner.currentStratumStats.Save();
        }
 public abstract TreeDefaultValueDO ShowAddTreeDefault(TreeDefaultValueDO newTDV);
 public TreeDefaultValueDO GetNewTreeDefaultValue()
 {
     TreeDefaultValueDO tdv = new TreeDefaultValueDO(this._database);
     return tdv;
 }
        public TreeDefaultValueDO CreateNewTreeDefaultValue(String pProd)
        {
            TreeDefaultValueDO newTDV = new TreeDefaultValueDO();
            newTDV.DAL = this._cDal;
            newTDV.PrimaryProduct = pProd;
            newTDV.LiveDead = "L";

            if (this.ViewController.ShowEditTreeDefault(newTDV) == DialogResult.OK)
            {
                try
                {
                    newTDV.Save();
                    return newTDV;
                }
                catch (Exception e)
                {
                    ExceptionHandler.HandelEx(new UserFacingException("oops Tree Default save error", e));
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
 public TreeVM CreateNewTreeEntry(StratumModel stratum
     , SampleGroupModel sg
     , TreeDefaultValueDO tdv
     , bool isMeasure)
 {
     var tree = CreateNewTreeEntryInternal(stratum, sg, tdv, isMeasure);
     tree.TreeNumber = GetNextNonPlotTreeNumber();
     return tree;
 }
Exemplo n.º 25
0
		public TreeDefaultValueDO(TreeDefaultValueDO obj) : this()
		{
		    SetValues(obj);
		}
        internal TreeVM CreateNewTreeEntryInternal(StratumModel stratum
            , SampleGroupModel sg
            , TreeDefaultValueDO tdv
            , bool isMeasure)
        {
            TreeVM newTree = new TreeVM(this.DAL);
            newTree.TreeCount = 0;
            newTree.CountOrMeasure = (isMeasure) ? "M" : "C";
            newTree.CuttingUnit = this;

            if (sg != null)
            {
                newTree.SampleGroup = sg;
                if (tdv == null)
                {
                    if (sg.TreeDefaultValues.IsPopulated == false)
                    {
                        sg.TreeDefaultValues.Populate();
                    }
                    if (sg.TreeDefaultValues.Count == 1)
                    {
                        tdv = sg.TreeDefaultValues[0];
                    }
                }
            }
            if (stratum != null) { newTree.Stratum = stratum; }
            if (tdv != null)
            {
                newTree.SetTreeTDV(tdv);
            }

            newTree.Validate();
            //newTree.Save();

            return newTree;
        }
Exemplo n.º 27
0
 //protected bool ProcessSampleGroupChanging(TreeVM tree, SampleGroupVM newSG)
 //{
 //    if (tree == null || newSG == null) { return false; }
 //    if (tree.SampleGroup != null)
 //    {
 //        if (MessageBox.Show("You are changing the Sample Group of a tree, are you sure you want to do this?", "!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2)
 //            == DialogResult.No)
 //        {
 //            return false;
 //        }
 //        else
 //        {
 //            this.AppController._cDal.LogMessage(String.Format("Tree Sample Group Changed (Cu:{0} St:{1} Sg:{2} -> {3} Tdv_CN:{4} T#: {5}",
 //                tree.CuttingUnit.Code,
 //                tree.Stratum.Code,
 //                (tree.SampleGroup != null) ? tree.SampleGroup.Code : "?",
 //                newSG.Code,
 //                (tree.TreeDefaultValue != null) ? tree.TreeDefaultValue.TreeDefaultValue_CN.ToString() : "?",
 //                tree.TreeNumber), "high");
 //            tree.SampleGroup = newSG;
 //        }
 //    }
 //    else
 //    {
 //        tree.SampleGroup = newSG;
 //    }
 //    if (tree.TreeDefaultValue != null)
 //    {
 //        var hasTDV = tree.DAL.ExecuteScalar<bool>("SELECT count(1) " +
 //            "FROM SampleGroupTreeDefaultValue " +
 //            "WHERE TreeDefaultValue_CN = ? AND SampleGroup_CN"
 //            , tree.TreeDefaultValue_CN, newSG.SampleGroup_CN);
 //        if (!hasTDV)
 //        {
 //            tree.SetTreeTDV(null);
 //        }
 //    }
 //    return tree.TrySave();
 //}
 protected bool ProcessSpeciesChanged(TreeVM tree, TreeDefaultValueDO tdv)
 {
     if (tree == null) { return true; }
     if (tree.TreeDefaultValue == tdv) { return true; }
     tree.SetTreeTDV(tdv);
     return tree.TrySave();
 }
 public override TreeDefaultValueDO ShowAddTreeDefault(TreeDefaultValueDO newTDV)
 {
     try
     {
         FormAddTreeDefault dialog = new FormAddTreeDefault(ApplicationController.SetupService.GetProductCodes());
         if (dialog.ShowDialog(newTDV) == DialogResult.OK)
         {
             newTDV.Save();
             return newTDV;
         }
         else
         {
             return null;
         }
     }
     catch (Exception ex)
     {
         if (!this.ApplicationController.ExceptionHandler.Handel(ex))
         {
             throw;
         }
         else
         {
             return null;
         }
     }
 }
Exemplo n.º 29
0
 public bool HasTreeDefault(TreeDefaultValueDO tdv)
 {
     return DAL.ExecuteScalar<bool>("SELECT count(1) " +
             "FROM SampleGroupTreeDefaultValue " +
             "WHERE TreeDefaultValue_CN = ? AND SampleGroup_CN = ?"
             , tdv.TreeDefaultValue_CN, SampleGroup_CN);
 }
        public override TreeDefaultValueDO ShowAddTreeDefault()
        {
            TreeDefaultValueDO newTDV = new TreeDefaultValueDO(this.ApplicationController.Database);

            return this.ShowAddTreeDefault(newTDV);
        }