Example #1
0
        public static bool ValidateSetup(SampleGroupDO sg, StratumDO st, out string error)
        {
            bool isValid = true;

            error = null;
            sg.Validate();
            string pre = "Stratum: " + st.Code + " IN SG: " + sg.Code + " -";

            if (sg.HasErrors())
            {
                isValid = false;
                error  += pre + sg.Error;
            }
            if (String.IsNullOrEmpty(sg.Code))
            {
                isValid = false;
                error  += pre + " Code can't be empty";
            }
            if (sg.TreeDefaultValues.Count == 0)
            {
                isValid = false;
                error  += pre + " No Tree Defaults Selected";
            }

            isValid = sg.ValidatePProdOnTDVs(ref error) && isValid;
            return(isValid);
        }
Example #2
0
        public static int DeleteStratum(Datastore dal, StratumDO stratum)
        {
            // check tree table for data
            if (dal.GetRowCount("Tree", "WHERE Stratum_CN = @p1", stratum.Stratum_CN) > 0)
            {
                return(-1);
            }
            // check plot table for data
            if (dal.GetRowCount("Plot", "WHERE Stratum_CN = @p1", stratum.Stratum_CN) > 0)
            {
                return(-1);
            }
            // Check Count table for each sample group
            if (dal.GetRowCount("CountTree", "JOIN SampleGroup ON CountTree.SampleGroup_CN = SampleGroup.SampleGroup_CN WHERE SampleGroup.Stratum_CN = @p1 AND CountTree.TreeCount > 0", stratum.Stratum_CN) > 0)
            {
                return(-1);
            }

            //Delete sample groups for stratum
            List <SampleGroupDO> allSGInStratum = dal.From <SampleGroupDO>()
                                                  .Where("Stratum_CN = @p1")
                                                  .Read(stratum.Stratum_CN).ToList();

            //.Read<SampleGroupDO>("WHERE Stratum_CN = ?", stratum.Stratum_CN);
            foreach (SampleGroupDO Sg in allSGInStratum)
            {
                //Delete Count Records for stratum
                List <CountTreeDO> allCountInSG = dal.From <CountTreeDO>()
                                                  .Where("SampleGroup_CN = @p1")
                                                  .Read(Sg.SampleGroup_CN).ToList();

                //.Read<CountTreeDO>("WHERE SampleGroup_CN = ?", Sg.SampleGroup_CN);
                foreach (CountTreeDO Cnt in allCountInSG)
                {
                    Cnt.Delete();
                }
                Sg.Delete();
            }

            //Delete stratum stats for stratum
            List <StratumStatsDO> allStratumStatsInStratum = dal.From <StratumStatsDO>()
                                                             .Where("Stratum_CN = @p1")
                                                             .Read(stratum.Stratum_CN)
                                                             .ToList();

            //.Read<StratumStatsDO>(
            //"WHERE Stratum_CN = ?", stratum.Stratum_CN);
            foreach (StratumStatsDO StratumStats in allStratumStatsInStratum)
            {
                StratumStats.DeleteStratumStats(dal, StratumStats.StratumStats_CN);
            }

            stratum.Delete();

            return(0);
        }
 public static bool CanEnableKZ(StratumDO stratum)
 {
     if (stratum == null) { return false; }
        if (stratum.Method == null) { return true; }
        if (Array.IndexOf(Schema.CruiseMethods.THREE_P_METHODS, stratum.Method) >= 0)
        {
        return true;
        }
        return false;
 }
 public static bool CanEnableBigBAF(StratumDO stratum)
 {
     if (stratum == null) { return false; }
        if (stratum.Method == null) { return true; }
        if (stratum.Method == "PCM")
        {
        return true;
        }
        return false;
 }
Example #5
0
 public static bool CanDefineTallys(StratumDO stratum)
 {
     if (stratum.Method == "FIX" || stratum.Method == "PNT" || stratum.Method == "100")
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
 public static bool CanEnableIFreq(StratumDO stratum)
 {
     if (stratum == null) { return false; }
        if (stratum.Method == null) { return true; }
        string method = stratum.Method;
        if (method == "3P" || method == "S3P" || method == "STR")
        {
        return true;
        }
        return false;
 }
Example #7
0
 public static bool CanEnableBigBAF(StratumDO stratum)
 {
     if (stratum == null)
     {
         return(false);
     }
     if (stratum.Method == null)
     {
         return(true);
     }
     if (stratum.Method == "PCM")
     {
         return(true);
     }
     return(false);
 }
Example #8
0
 public static bool CanEnableKZ(StratumDO stratum)
 {
     if (stratum == null)
     {
         return(false);
     }
     if (stratum.Method == null)
     {
         return(true);
     }
     if (Array.IndexOf(Schema.CruiseMethods.THREE_P_METHODS, stratum.Method) >= 0)
     {
         return(true);
     }
     return(false);
 }
        public void ReadCountsTest()
        {
            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 };

            List<CountTreeDO> expected = null; // TODO: Initialize to an appropriate value
            List<CountTreeDO> actual;
            actual = target.ReadCounts(cu, st, sg);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
 public static bool CanEnableFrequency(StratumDO stratum)
 {
     if (stratum == null) { return false; }
        if (stratum.Method == null) { return true; }
        if (stratum.Method.IndexOf("3P") != -1)
        {
        return false;
        }
        if (stratum.Method == CruiseMethods.PNT
         || stratum.Method == CruiseMethods.FIX
         || stratum.Method == CruiseMethods.H_PCT
         || stratum.Method == CruiseMethods.FIXCNT)
        {
        return false;
        }
        return true;
 }
Example #11
0
        public static bool CanEnableIFreq(StratumDO stratum)
        {
            if (stratum == null)
            {
                return(false);
            }
            if (stratum.Method == null)
            {
                return(true);
            }
            string method = stratum.Method;

            if (method == "3P" || method == "S3P" || method == "STR")
            {
                return(true);
            }
            return(false);
        }
Example #12
0
 protected void OnStratumChanged(StType newStratum)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (newStratum != null)
     {
         List <SGType> list = this.Controller.DataStore.From <SGType>()
                              .Where("Stratum_CN = ?")
                              .Read(newStratum.Stratum_CN).ToList();
         foreach (SGType sg in list)
         {
             sg.TallyMethod = sg.GetSampleGroupTallyMode();
         }
         list.Add(_newSGPlaceHolder);
         this._BS_SampleGroups.DataSource = list;
     }
     else
     {
         this._BS_SampleGroups.DataSource = new SGType[0];
     }
     Cursor.Current = Cursors.Default;
 }
Example #13
0
        public static void RecursiveDeleteStratum(StratumDO stratum)
        {
            Datastore db = stratum.DAL;

            db.BeginTransaction();
            try
            {
                string command =
                    String.Format(@"DELETE From CuttingUnitStratum WHERE Stratum_CN = {0};
DELETE FROM Log WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.Stratum_CN = {0});
DELETE FROM LogStock WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.Stratum_CN = {0});
DELETE FROM TreeCalculatedValues WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.Stratum_CN = {0});
DELETE FROM Tree WHERE Stratum_CN = {0};
DELETE FROM Plot WHERE Stratum_CN = {0};
DELETE FROM TreeEstimate WHERE CountTree_CN IN (SELECT CountTree_CN FROM CountTree JOIN SampleGroup USING (SampleGroup_CN) WHERE Stratum_CN = {0});
DELETE FROM CountTree WHERE SampleGroup_CN IN (SELECT SampleGroup_CN FROM SampleGroup WHERE SampleGroup.Stratum_CN = {0});
DELETE FROM SampleGroupTreeDefaultValue WHERE SampleGroup_CN IN (SELECT SampleGroup_CN FROM SampleGroup WHERE SampleGroup.Stratum_CN = {0});
DELETE FROM SamplerState WHERE SampleGroup_CN IN (SELECT SampleGroup_CN FROM SampleGroup WHERE SampleGroup.Stratum_CN = {0});
DELETE FROM SampleGroup WHERE Stratum_CN = {0};
DELETE FROM TreeFieldSetup WHERE Stratum_CN = {0};
DELETE FROM LogFieldSetup WHERE Stratum_CN = {0};
DELETE FROM FixCNTTallyPopulation WHERE FixCNTTallyClass_CN IN (SELECT FixCNTtallyClass_CN FROM FixCNTTallyClass WHERE Stratum_CN = {0});
DELETE FROM FixCNTTallyClass WHERE Stratum_CN = {0};
DELETE FROM SampleGroupStatsTreeDefaultValue WHERE SampleGroupStats_CN IN 
    (SELECT SampleGroupStats_CN FROM SampleGroupStats AS sgs 
        JOIN StratumStats AS ss USING (StratumStats_CN) WHERE Stratum_CN = {0});
DELETE FROM SampleGroupStats WHERE StratumStats_CN IN 
    (SELECT StratumStats_CN FROM StratumStats WHERE Stratum_CN = {0});
DELETE FROM StratumStats WHERE Stratum_CN = {0};",
                                  stratum.Stratum_CN);
                db.Execute(command);
                stratum.Delete();
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw e;
            }
        }
Example #14
0
 public static bool CanEnableFrequency(StratumDO stratum)
 {
     if (stratum == null)
     {
         return(false);
     }
     if (stratum.Method == null)
     {
         return(true);
     }
     if (stratum.Method.IndexOf("3P") != -1)
     {
         return(false);
     }
     if (stratum.Method == CruiseMethods.PNT ||
         stratum.Method == CruiseMethods.FIX ||
         stratum.Method == CruiseMethods.H_PCT ||
         stratum.Method == CruiseMethods.FIXCNT)
     {
         return(false);
     }
     return(true);
 }
        public int getPopulations(StratumDO currentStratum)
        {
            // for each stratum
             stage = statClass.isTwoStage(currentStratum.Method);
             strStats = new StratumStatsDO(cdDAL);
             strStats.Stratum = currentStratum;
             strStats.Code = currentStratum.Code;
             strStats.Description = currentStratum.Description;
             strStats.SgSet = 1;
             strStats.SgSetDescription = "";

             float totalAcres = 0;
             currentStratum.CuttingUnits.Populate();

             foreach (CuttingUnitDO cu in currentStratum.CuttingUnits)
             {
            float acres = cu.Area;
            totalAcres += acres;
             }

             strStats.TotalAcres = totalAcres;
             strStats.Method = currentStratum.Method;
             strStats.BasalAreaFactor = currentStratum.BasalAreaFactor;
             strStats.FixedPlotSize = currentStratum.FixedPlotSize;
             strStats.Used = 1;
             strStats.Save();

             if (getSampleGroupStats(currentStratum, strStats, totalAcres) < 0)
            return(-1);

             getStratumStats(strStats);
             // create stratum sets;
             // create sample group sets
             // calculate stats
             return (0);
        }
        public SampleGroupDO CreateNewSampleGroup(StratumDO stratum)
        {
            SampleGroupDO newSG = new SampleGroupDO();
            newSG.DAL = this._cDal;
            newSG.Stratum = stratum;
            newSG.UOM = this._cDal.ExecuteScalar("Select DefaultUOM FROM Sale;") as String;
            //newSG.UOM = this._cDal.ReadSingleRow<SaleDO>("Sale", false, null).DefaultUOM;

            if (this.ViewController.ShowEditSampleGroup(newSG, true) == DialogResult.OK)
            {
                return newSG;
            }
            else
            {
                return null;
            }
        }
        private void copyStratumToFScruise(DAL cdDAL)
        {
            //loop through design stratum table
             List<StratumDO> myStr = new List<StratumDO>(cdDAL.Read<StratumDO>("Stratum",null,null));
             foreach(StratumDO curStr in myStr)
             {
             // create new stratumDO
            StratumDO fsStr = new StratumDO(fsDAL);
             // copy stratum information
            fsStr.Code = curStr.Code;
            fsStr.Description = curStr.Description;
            fsStr.Method = curStr.Method;
            fsStr.BasalAreaFactor = curStr.BasalAreaFactor;
            fsStr.FixedPlotSize = curStr.FixedPlotSize;
            fsStr.KZ3PPNT = curStr.KZ3PPNT;
            fsStr.YieldComponent = curStr.YieldComponent;
            fsStr.Year = curStr.Year;
            fsStr.Month = curStr.Month;

            fsStr.Save();

             }
        }
 public StratumVM(StratumDO st)
     : base(st)
 {
 }
        /// <summary>
        /// helper method for Finish, executes database command that creates field set up entries from field setup defaults
        /// </summary>
        /// <param name="stratum"></param>
        /// <param name="database"></param>
        private void SetFieldSetup(StratumDO stratum, DAL database)
        {
            string setTreeFieldCommand = String.Format(@"INSERT OR IGNORE INTO TreeFieldSetup (Stratum_CN, Field, FieldOrder, ColumnType, Heading, Width, Format, Behavior)
            Select {0} as Stratum_CN, Field, FieldOrder, ColumnType, Heading, Width, Format, Behavior
            FROM TreeFieldSetupDefault
            WHERE Method = '{1}';", stratum.Stratum_CN, stratum.Method);

            string setLogFieldCommand = String.Format(@"INSERT OR IGNORE INTO LogFieldSetup (Stratum_CN, Field, FieldOrder, ColumnType, Heading, Width, Format, Behavior)
            Select {0} as Stratum_CN, Field, FieldOrder, ColumnType, Heading, Width, Format, Behavior
            FROM LogFieldSetupDefault;",
            stratum.Stratum_CN);

            database.Execute(setTreeFieldCommand);
            database.Execute(setLogFieldCommand);
        }
 public bool CanDefintTallys(StratumDO stratum)
 {
     return StratumDO.CanDefineTallys(stratum);
 }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // popup methods view
             string columnName = this.dataGridViewStratumStats.Columns[e.ColumnIndex].HeaderText;
             if (columnName == "Method")
             {

            //set binding list using currentStratum_cn

            currentStratumStats.Used = 0;
            currentStratumStats.Save();

            msStratumStats = new BindingList<StratumStatsDO>(cdDAL.Read<StratumStatsDO>("StratumStats", "Where Stratum_CN = ? ORDER BY Method", currentStratumStats.Stratum_CN));

            currentStratum = cdDAL.ReadSingleRow<StratumDO>("Stratum", "Where Stratum_CN = ?", currentStratumStats.Stratum_CN);

            MethodSelect mDlg = new MethodSelect(this);
            //mDlg.Owner = this;
            //        strDlg.dalFile = dalPath;
            mDlg.ShowDialog(this);
            // recreate stratum list/SampleGroup list with new selection
            currentStratumStats.Save();

            //currentStratum = cdDAL.ReadSingleRow<StratumDO>("Stratum", "Where Stratum_CN = ?", currentStratumStats.Stratum_CN);
            //currentStratum.Method = currentStratumStats.Method;
            currentStratum.Save();

            InitializeDatabaseTables();
            bindingSourceStratumStats.DataSource = cdStratumStats;

            getSaleError();
             }
        }
 protected void OnStratumChanged(StType newStratum)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (newStratum != null)
     {
         List<SGType> list = this.Controller._cDal.From<SGType>()
             .Where("Stratum_CN = ?")
             .Read(newStratum.Stratum_CN).ToList();
         foreach (SGType sg in list)
         {
             sg.TallyMethod = sg.GetSampleGroupTallyMode();
         }
         list.Add(_newSGPlaceHolder);
         this._BS_SampleGroups.DataSource = list;
     }
     else
     {
         this._BS_SampleGroups.DataSource = Constants.EMPTY_SG_LIST;
     }
     Cursor.Current = Cursors.Default;
 }
 internal void SetSelectedStratum(StratumDO stratrum)
 {
     var index = StratumBindingSource.IndexOf(stratrum);
     StratumBindingSource.Position = index;
 }
 protected List<TreeFieldSetupDO> GetSelectedTreeFields(StratumDO stratum)
 {
     return this.Database.Read<TreeFieldSetupDO>("TreeFieldSetup", "WHERE Stratum_CN = ? ORDER BY FieldOrder", stratum.Stratum_CN);
 }
		public StratumDO(StratumDO obj) : this()
		{
		    SetValues(obj);
		}
 public void HandleStratumChanging(TreeVM tree, StratumDO st, out bool cancel)
 {
     if (tree == null || st == null) { cancel = true; return; }
     if (tree.Stratum != null && tree.Stratum.Stratum_CN == st.Stratum_CN) { cancel = true; return; }
     if (tree.Stratum != null)
     {
         if (!this.ViewController.AskYesNo("You are changing the stratum of a tree, are you sure you want to do this?", "!", MessageBoxIcon.Asterisk))
         {
             cancel = true;//do not change stratum
         }
         else
         {
             //log stratum changed
             this.Database.LogMessage(String.Format("Tree Stratum Changed (Cu:{0} St:{1} -> {2} Sg:{3} Tdv_CN:{4} T#: {5} P#:{6}",
                 tree.CuttingUnit.Code,
                 tree.Stratum.Code,
                 st.Code,
                 (tree.SampleGroup != null) ? tree.SampleGroup.Code : "?",
                 (tree.TreeDefaultValue != null) ? tree.TreeDefaultValue.TreeDefaultValue_CN.ToString() : "?",
                 tree.TreeNumber,
                 (tree.Plot != null) ? tree.Plot.PlotNumber.ToString() : "-"), "I");
         }
     }
     cancel = false;
 }
        //---------------------------------------------------------------------------------------------------------
        private int getSampleGroupStats(StratumDO currentStratum, StratumStatsDO currentStratumStats, float totalAcres)
        {
            int n1, n2, measTrees, sumKpi, talliedTrees, freq, kz, insTrees;
             double st1x, st1x2, st2x, st2x2, cv1, cv2, sampErr, sumNetVol;
             float treesPerAcre;
             double comberr2 = 0;
             double totalVolume = 0;
             // for each sample group
             sampleGroups = new List<SampleGroupDO>(cdDAL.Read<SampleGroupDO>("SampleGroup", "Where Stratum_CN = ?", currentStratum.Stratum_CN));

             foreach (SampleGroupDO sg in sampleGroups)
             {
            // create samplegroupstats
            currentSgStats = new SampleGroupStatsDO(cdDAL);
            //set foriegn key
            currentSgStats.StratumStats = currentStratumStats;
            currentSgStats.SgSet = 1;
            currentSgStats.Code = sg.Code;
            currentSgStats.CutLeave = sg.CutLeave;
            currentSgStats.UOM = sg.UOM;
            currentSgStats.PrimaryProduct = sg.PrimaryProduct;
            currentSgStats.SecondaryProduct = sg.SecondaryProduct;
            currentSgStats.DefaultLiveDead = sg.DefaultLiveDead;
            currentSgStats.Description = sg.Description;
            // get POP data
            selectedPOP = cdDAL.ReadSingleRow<POPDO>("POP", "WHERE Stratum = ? AND SampleGroup = ?", currentStratum.Code, sg.Code);

            // calculate statistics (based on method)
            if (selectedPOP == null)
            {
               MessageBox.Show("Cruise Not Processed. Please Process Cruise Before Continuing.", "Warning");
               return(-1);
            }
            n1 = Convert.ToInt32(selectedPOP.StageOneSamples);
            n2 = Convert.ToInt32(selectedPOP.StageTwoSamples);
            measTrees = Convert.ToInt32(selectedPOP.MeasuredTrees);
            talliedTrees = Convert.ToInt32(selectedPOP.TalliedTrees);
            sumKpi = Convert.ToInt32(selectedPOP.SumKPI);
            st1x = selectedPOP.Stg1NetXPP;
            st1x2 = selectedPOP.Stg1NetXsqrdPP;
            st2x = selectedPOP.Stg2NetXPP;
            st2x2 = 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;
            currentSgStats.CV1 = Convert.ToSingle(cv1);
            currentSgStats.CV2 = Convert.ToSingle(cv2);
            currentSgStats.SampleSize1 = n1;
            currentSgStats.SampleSize2 = n2;
            if (stage == 11 || stage == 10)
            {
               currentSgStats.ReconTrees = n1;
               currentSgStats.ReconPlots = 0;
            }
            else if (stage == 12)
            {
               currentSgStats.ReconPlots = n1;
               currentSgStats.ReconTrees = n2;
            }
            else if (stage == 21 || stage == 22)
            {
               currentSgStats.ReconTrees = measTrees;
               currentSgStats.ReconPlots = n1;
            }
            // calculate frequency

            currentSgStats.SgError = Convert.ToSingle(sampErr);

            // get LCD data
            selectedLCD = cdDAL.Read<LCDDO>("LCD", "WHERE Stratum = ? AND SampleGroup = ?", currentStratum.Code, sg.Code);
            sumExpFac = 0;
            sumNetVol = 0;
            //foreach (SampleGroupDO sg in Owner.histSampleGroup)
            foreach (LCDDO lcd in 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)
            {
               treesPerAcre = Convert.ToSingle(Math.Round((sumExpFac / totalAcres), 2));
               currentSgStats.TreesPerAcre = treesPerAcre;
               currentSgStats.VolumePerAcre = Convert.ToSingle(Math.Round((sumNetVol / totalAcres), 2));
            }
            else
            {
               treesPerAcre = Convert.ToSingle(Math.Round((sumExpFac), 2));
               currentSgStats.TreesPerAcre = treesPerAcre;
               currentSgStats.VolumePerAcre = Convert.ToSingle(Math.Round((sumNetVol), 2));
               if (stage == 21)
                  currentSgStats.TreesPerPlot = Convert.ToSingle(Math.Round((Convert.ToSingle((float)measTrees / (float)n1)), 1));
               else
                  currentSgStats.TreesPerPlot = Convert.ToSingle(Math.Round((Convert.ToSingle((float)talliedTrees / (float)n1)), 1));
            }
            currentSgStats.TPA_Def = (long)(treesPerAcre * totalAcres);
            // 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 (currentStratum.Method == "S3P")
               {
                  currentSgStats.SamplingFrequency = Convert.ToInt32((talliedTrees / n1));
                  currentSgStats.KZ = kz;
               }
               else
               {
                  currentSgStats.SamplingFrequency = freq;
                  currentSgStats.KZ = kz;
               }
            }
            // find insurance trees
            if (stage == 11 || stage == 12)
               insTrees = getInsuranceTrees(sg);
            else
               insTrees = 0;
            currentSgStats.InsuranceFrequency = insTrees;
            // save samplegroupstats row
            currentSgStats.Save();
            // loop through TDV information
            sg.TreeDefaultValues.Populate();
            foreach (TreeDefaultValueDO tdv in sg.TreeDefaultValues)
            {
                currentSgStats.TreeDefaultValueStats.Add(tdv);
            }

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

             }
             return (0);
        }
        public static bool ValidateSetup(SampleGroupDO sg, StratumDO st, out string error)
        {
            bool isValid = true;
               error = null;
               sg.Validate();
               string pre = "Stratum: " + st.Code + " IN SG: " + sg.Code + " -";
               if (sg.HasErrors())
               {
               isValid = false;
               error += pre + sg.Error;
               }
               if (String.IsNullOrEmpty(sg.Code))
               {
               isValid = false;
               error += pre + " Code can't be empty";
               }
               if (sg.TreeDefaultValues.Count == 0)
               {
               isValid = false;
               error += pre + " No Tree Defaults Selected";
               }

               isValid  = sg.ValidatePProdOnTDVs(ref error) && isValid;
               return isValid;
        }
        public SampleGroupDO GetNewSampleGroup(StratumDO stratum, SampleGroupDO newSampleGroup)
        {
            if (newSampleGroup == null)
            {
                newSampleGroup = new SampleGroupDO(this._database);
            }

            newSampleGroup.CutLeave = "C";
            newSampleGroup.DefaultLiveDead = "L";
            newSampleGroup.Code = "<Blank>";
            newSampleGroup.Stratum = stratum;

            if (stratum.Method == CruiseDAL.Schema.CruiseMethods.FIXCNT)
            {
                newSampleGroup.UOM = "03";
            }
            else
            {
                newSampleGroup.UOM = Sale.DefaultUOM;
            }

            return newSampleGroup;
        }
Example #30
0
 private void _strataCB_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.Stratum = this._strataCB.SelectedItem as StType;
 }
        public void ShowSampleGroups(StratumDO stratum)
        {
            string errorMsg;
            if (AreStrataValid(out errorMsg) == false)
            {
                MessageBox.Show(errorMsg, "Warning", MessageBoxButtons.OK);
                return;
            }

            try
            {
                this.SaveStrata(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            this.WaitCopyTemplateDone();

            View.Display("SampleGroups");
            //if (stratum != null)
            //{
            //    View.sampleGroupPage.CurrentStratum = stratum;
            //}
        }
Example #32
0
        public bool HandleStratumChanging(StratumDO newStratum, IView view)
        {
            if (newStratum == null) { return false; }
            if (Stratum != null
                && Stratum.Stratum_CN == newStratum.Stratum_CN)
            { return false; }

            if (Stratum != null)
            {
                if (!view.AskYesNo("You are changing the stratum of a tree" +
                    ", are you sure you want to do this?"
                    , "!", System.Windows.Forms.MessageBoxIcon.Asterisk))
                {
                    return false;//do not change stratum
                }
                else
                {
                    //log stratum changed
                    DAL.LogMessage(String.Format("Tree Stratum Changed (Cu:{0} St:{1} -> {2} Sg:{3} Tdv_CN:{4} T#: {5} P#:{6}"
                        , CuttingUnit.Code
                        , Stratum.Code
                        , newStratum.Code
                        , (SampleGroup != null) ? SampleGroup.Code : "?"
                        , (TreeDefaultValue != null) ? TreeDefaultValue.TreeDefaultValue_CN.ToString() : "?"
                        , TreeNumber
                        , (Plot != null) ? Plot.PlotNumber.ToString() : "-"), "I");
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
 public List<LogFieldSetupDO> GetSelectedLogFields(StratumDO stratum)
 {
     return this.Database.Read<LogFieldSetupDO>("LogFieldSetup", "WHERE Stratum_CN = ? ORDER BY FieldOrder", stratum.Stratum_CN);
 }
		public void SetValues(StratumDO obj)
		{
			if(obj == null) { return; }
			Code = obj.Code;
			Description = obj.Description;
			Method = obj.Method;
			BasalAreaFactor = obj.BasalAreaFactor;
			FixedPlotSize = obj.FixedPlotSize;
			KZ3PPNT = obj.KZ3PPNT;
			Hotkey = obj.Hotkey;
			FBSCode = obj.FBSCode;
			YieldComponent = obj.YieldComponent;
			Month = obj.Month;
			Year = obj.Year;
		}
        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);
        }
        protected List<TreeFieldSetupDO> GetSelectedTreeFieldsDefault(StratumDO stratum)
        {
            //select from TreeFieldSetupDefault where method = stratum.method
            List<TreeFieldSetupDefaultDO> treeFieldDefaults = this.Database.Read<TreeFieldSetupDefaultDO>("TreeFieldSetupDefault", "WHERE Method = ? ORDER BY FieldOrder", stratum.Method);

            List<TreeFieldSetupDO> treeFields = new List<TreeFieldSetupDO>();

            foreach (TreeFieldSetupDefaultDO tfd in treeFieldDefaults)
            {
                TreeFieldSetupDO tfs = new TreeFieldSetupDO();
                tfs.Stratum_CN = stratum.Stratum_CN;
                tfs.Field = tfd.Field;
                tfs.FieldOrder = tfd.FieldOrder;
                tfs.ColumnType = tfd.ColumnType;
                tfs.Heading = tfd.Heading;
                tfs.Width = tfd.Width;
                tfs.Format = tfd.Format;
                tfs.Behavior = tfd.Behavior;

                treeFields.Add(tfs);
            }
            return treeFields;
        }
        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.");
        }
 private bool checkNestedPlots(StratumDO myRSt)
 {
     int nestNum = 0;
        string myMeth = "";
        float myBAF = 0;
        float myFIX = 0;
     //loop through each unit
        myRSt.CuttingUnits.Populate();
        foreach (CuttingUnitDO rcu in myRSt.CuttingUnits)
        {
       rcu.Strata.Populate();
       if (rcu.Strata.Count() > 1)
       {
          // check for different method/plot sizes
          foreach (StratumDO mySt in rcu.Strata)
          {
             if (nestNum == 0)
             {
                myMeth = mySt.Method;
                myBAF = mySt.BasalAreaFactor;
                myFIX = mySt.FixedPlotSize;
                nestNum++;
             }
             else
             {
                if (myMeth != mySt.Method)
                   return (true);
                float diff = myBAF - mySt.BasalAreaFactor;
                if (diff > 1 || diff < -1)
                   return (true);
                diff = myFIX - mySt.FixedPlotSize;
                if (diff > 1 || diff < -1)
                   return (true);
             }
          }
       }
        }
        return (false);
 }
 public void DeleteStratum(StratumDO st)
 {
     if (st.IsPersisted)
     {
         StratumDO.RecursiveDeleteStratum(st);
     }
 }
 private void _strataCB_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.Stratum = this._strataCB.SelectedItem as StType;
 }
 public DesignEditorStratum(CruiseDAL.DataObjects.StratumDO st) : base(st)
 {
 }