Exemple #1
0
        }   //  end GetSingleValue

        public static int check3Pcounts(List <CountTreeDO> countList, CPbusinessLayer bslyr, StratumDO currStratum)
        {
            int checkResult = 0;

            //  is this a 3P stratum?
            if (currStratum.Method == "3P")
            {
                //  find stratum in CountTree by finding cutting unit first
                List <CuttingUnitStratumDO> uList = bslyr.getCuttingUnitStratum((long)currStratum.Stratum_CN);
                foreach (CuttingUnitStratumDO ul in uList)
                {
                    List <CountTreeDO> justCounts = countList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(ctd.CuttingUnit_CN == ul.CuttingUnit_CN && ctd.SampleGroup.Stratum.Code == currStratum.Code);
                    });       //  end
                    foreach (CountTreeDO jc in justCounts)
                    {
                        if (jc.TreeDefaultValue_CN == null)
                        {
                            checkResult++;
                        }
                    }
                } //  end foreach on cutting unit
            }     //  endif 3P stratum
            return(checkResult);
        }         //  end check3Pcounts
Exemple #2
0
        }     //  end onFinished

        private void updateBiomassList()
        {
            string          currentUserSpecies;
            string          currentBioSpecies;
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.fileName = fileName;
            int    nLength = 0;
            int    nthPosition;
            string currentAssn = "";

            //  updates bioList before it is saved in the database
            //  remove all rows first
            bioList.Clear();

            //  rows must be added for all strata where this species is located
            for (int k = 0; k < associations.Items.Count; k++)
            {
                currentAssn = associations.Items[k].ToString();
                //  split out user and bio species
                nLength            = currentAssn.Length;
                nthPosition        = currentAssn.IndexOf("-");
                currentUserSpecies = currentAssn.Substring(0, nthPosition - 1);
                currentAssn        = currentAssn.Remove(0, nthPosition + 3);
                currentBioSpecies  = currentAssn;


                //  How many strata have the user species?
                //List<TreeDO> speciesList = bslyr.GetStratumForBiomassReport(currentUserSpecies);
                string[,] stratumSG = bslyr.GetStratumForBiomassReport(currentUserSpecies);
                for (int j = 0; j < stratumSG.GetLength(0); j++)
                {
                    //  setup fields to load into bioList
                    Biomass bms = new Biomass();
                    bms.userSpecies = currentUserSpecies;
                    bms.bioSpecies  = currentBioSpecies;
                    bms.FLIW        = fractionLeftInWoods.Items[k].ToString();
                    bms.DSTincluded = damSmallTreesIncluded.Items[k].ToString();

                    bms.userStratum = stratumSG[j, 0];
                    bms.userSG      = stratumSG[j, 1];

                    bioList.Add(bms);
                }

                /*foreach (TreeDO tree in speciesList)
                 * {
                 *  bms.userStratum = tree.Stratum.Code;
                 *  bms.userSG = tree.SampleGroup.Code;
                 *
                 *  bioList.Add(bms);
                 * }   //  end foreach loop
                 */
            }   //  end for k loop

            return;
        }   //  end updateBiomassList
        }     //  end AcresLookup

        public static double ReturnCorrectAcres(string currentStratum, CPbusinessLayer bslyr, long currStrCN)
        {
            string currentMethod = MethodLookup(currentStratum, bslyr);

            if (currentMethod == "100" || currentMethod == "STR" ||
                currentMethod == "S3P" || currentMethod == "3P")
            {
                return(1.0);
            }
            return(AcresLookup(currStrCN, bslyr, currentStratum));
        }   //  end ReturnCorrectAcres
        }   //  end unitAcres

        public static string MethodLookup(string currentStratum, CPbusinessLayer bslyr)
        {
            //  Need to call CP business layer to get stratum list
            List <StratumDO> stratumList = bslyr.GetCurrentStratum(currentStratum);

            if (stratumList.Count > 0)
            {
                return(stratumList[0].Method);
            }
            else
            {
                return("");
            }
        }   //  end MethodLookup
Exemple #5
0
        public void CalcValues()
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;

            List <SampleGroupDO>      sgList  = bslyr.getSampleGroups();
            List <TreeDefaultValueDO> tdvList = bslyr.getTreeDefaults();
            List <CountTreeDO>        ctList  = bslyr.getCountTrees();
            List <PlotDO>             pList   = bslyr.getPlots();

            ClearCalculatedTables();
            MakePopulationIDs(sgList, tdvList);
        }
Exemple #6
0
        }   //  end onInsertClick

        private void onFinished(object sender, EventArgs e)
        {
            //  Make sure user wants to save all entries
            DialogResult nResult = MessageBox.Show("Do you want to save changes?", "CONFIRMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (nResult == DialogResult.Yes)
            {
                Cursor.Current = Cursors.WaitCursor;
                CPbusinessLayer bslyr = new CPbusinessLayer();
                bslyr.fileName = fileName;
                bslyr.SaveWeightEquations(wgtList);
                Cursor.Current = this.Cursor;
            }   //  endif
            Close();
            return;
        }   //  end onFinished
Exemple #7
0
        public void setupDialog()
        {
            StringBuilder sb = new StringBuilder();
            //  Get just species from tree list
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.fileName = fileName;
            ArrayList justSpecies = bslyr.GetJustSpecies();

            //  if there are rows in the bioList, show the data in the dialog
            if (bioList.Count() > 0)
            {
                //  Load values as needed
                foreach (Biomass bms in bioList)
                {
                    //  Is species from tree table already associated?  Suppress from user species list if so.
                    for (int k = 0; k < justSpecies.Count; k++)
                    {
                        if (justSpecies[k].ToString() != bms.userSpecies)
                        {
                            userSpecies.Items.Add(justSpecies[k].ToString());
                        }
                        else
                        {
                            sb.Remove(0, sb.Length);
                            sb.Append(bms.userSpecies);
                            sb.Append(" -- ");
                            sb.Append(bms.bioSpecies);
                            associations.Items.Add(sb.ToString());
                        } //  endif justSpecies
                        //  add the other fields
                    }     //  end for k loop
                    fractionLeftInWoods.Items.Add(bms.FLIW);
                    damSmallTreesIncluded.Items.Add(bms.DSTincluded);
                }   //  end foreach loop
            }
            else if (bioList.Count() <= 0)
            {
                //  Add just species
                for (int k = 0; k < justSpecies.Count; k++)
                {
                    userSpecies.Items.Add(justSpecies[k].ToString());
                } //  end for k loop
            }     //  endif bioList has rows

            return;
        }   //  end setupDialog
Exemple #8
0
        public void setupDialog()
        {
            //  if there are weight equations, show in grid
            //  if not, just initialize the grid
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.fileName = fileName;
            wgtList        = bslyr.getWeightEquations();
            weightEquationDOBindingSource.DataSource = wgtList;
            weightEquationList.DataSource            = weightEquationDOBindingSource;
            //  need unique species, livedead and primary product from trees
            List <TreeDefaultValueDO> tList = bslyr.GetUniqueSpeciesProductLiveDead();

            if (wgtList.Count == 0)
            {
                //  Fill species, livedead and primary product with unique items from trees
                foreach (TreeDefaultValueDO tdo in tList)
                {
                    WeightEquationDO wedo = new WeightEquationDO();
                    wedo.Species        = tdo.Species;
                    wedo.LiveDead       = tdo.LiveDead;
                    wedo.PrimaryProduct = tdo.PrimaryProduct;
                    wgtList.Add(wedo);
                } //  end foreach loop
                weightEquationDOBindingSource.ResetBindings(false);
            }     //  endif wgtList is empty

            // Fill lists at bottom with unique species and primary products
            ArrayList justSpecies = bslyr.GetJustSpecies();

            for (int n = 0; n < justSpecies.Count; n++)
            {
                speciesList.Items.Add(justSpecies[n].ToString());
            }

            ArrayList justProduct = bslyr.GetJustPrimaryProduct();

            for (int n = 0; n < justProduct.Count; n++)
            {
                primaryProdList.Items.Add(justProduct[n].ToString());
            }

            speciesList.Enabled     = true;
            liveDeadList.Enabled    = true;
            primaryProdList.Enabled = true;
            return;
        }   //  end setupDialog
        //  AcresLookup will go away once the updated ReturnCorrectAcres is tested and complete
        public static double AcresLookup(long currStrCN, CPbusinessLayer bslyr, string currStratum)
        {
            //  Need call to CP business layer to get all CUs for this stratum
            List <StratumDO> stratumList = bslyr.GetCurrentStratum(currStratum);

            float stratumAcres = 0;

            foreach (StratumDO sdo in stratumList)
            {
                sdo.CuttingUnits.Populate();
                foreach (CuttingUnitDO cudo in sdo.CuttingUnits)
                {
                    stratumAcres += cudo.Area;
                }
            } //  end foreach loop
            return(stratumAcres);
        }     //  end AcresLookup
        }   //  end CurrentDLLversion

        public static void LogError(string tableName, int table_CN, string errLevel, string errMessage, string filename)
        {
            List <ErrorLogDO> errList = new List <ErrorLogDO>();
            ErrorLogDO        eldo    = new ErrorLogDO();

            eldo.TableName  = tableName;
            eldo.CN_Number  = table_CN;
            eldo.Level      = errLevel;
            eldo.ColumnName = "Volume";
            eldo.Message    = errMessage;
            eldo.Program    = "CruiseProcessing";
            errList.Add(eldo);

            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.fileName = filename;
            bslyr.SaveErrorMessages(errList);
        }   //  end LogError6
Exemple #11
0
        }     //  end onCancel

        private void onFinished(object sender, EventArgs e)
        {
            //  Store data in biomass table
            //  Update bioList before saving to database
            updateBiomassList();

            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.fileName = fileName;
            bslyr.SaveBiomassData(bioList, tableExists);

            DialogResult dnr = MessageBox.Show("All edits are saved.\nOK to exit?", "INFORMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dnr == DialogResult.Yes)
            {
                Close();
                return;
            } //  endif
        }     //  end onFinished
        }   //  end ReturnCorrectAcres

/*  following code is for change to capture stratum acres and needs testing when DAL is updated -- April 2015
 *      public static double ReturnCorrectAcres(StratumDO cs, CPbusinessLayer bslyr)
 *      {
 *          double strataAcres = 0;
 *          if (cs.Method == "100" || cs.Method == "STR" ||
 *              cs.Method == "S3P" || cs.Method == "3P")
 *              return 1.0;
 *          else
 *          {
 *              //  pull units for current stratum
 *              List<CuttingUnitStratumDO> justStratum = bslyr.GetJustStratum(cs.Stratum_CN);
 *              //  sum area
 *              strataAcres = justStratum.Sum(j => j.StrataArea);
 *              if (strataAcres == 0)
 *              {
 *                  //  find acres for all units
 *                  strataAcres = unitAcres(justStratum, gbslyr);
 *                  return strataAcres;
 *              }
 *              else if (strataAcres > 0)
 *                  return strataAcres;
 *          }   //  endif
 *          return strataAcres;
 *      }   //  end ReturnCorrectAcres
 */

        public static double unitAcres(List <CuttingUnitStratumDO> justStratum, CPbusinessLayer bslyr)
        {
            List <CuttingUnitDO> cutList = bslyr.getCuttingUnits();
            double acresSum = 0;

            foreach (CuttingUnitStratumDO js in justStratum)
            {
                int nthRow = cutList.FindIndex(
                    delegate(CuttingUnitDO c)
                {
                    return(c.CuttingUnit_CN == js.CuttingUnit_CN);
                });
                if (nthRow >= 0)
                {
                    acresSum += cutList[nthRow].Area;
                }
            }  //  end foreach loop

            return(acresSum);
        }   //  end unitAcres
        }       //  end TableEditChecks

        public int MethodChecks()
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;

            List <StratumDO> strList = bslyr.getStratum();
            List <TreeDO>    tList   = bslyr.getTrees();

            elm.bslyr.fileName = fileName;
            elm.bslyr.DAL      = bslyr.DAL;
            errorValue         = elm.CheckCruiseMethods(strList, tList);
            errList            = elm.errList;
            bslyr.fileName     = fileName;
            if (errList.Count > 0)
            {
                bslyr.SaveErrorMessages(errList);
            }
            return(errorValue);
        } //  end MethodChecks
Exemple #14
0
        //  this will contain methods for any calculated values
        public void ClearCalculatedTables()
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  if any of these tables have data, delete all
            //  Tree calculated values
            //List<TreeCalculatedValuesDO> tcvList = bslyr.getTreeCalculatedValues();

            //if (tcvList.Count > 0)
            bslyr.deleteTreeCalculatedValues();
            //bslyr.fileName = fileName;

            //  Log stock
            //List<LogStockDO> lsList = bslyr.getLogStock();
            // if (lsList.Count > 0)
            bslyr.DeleteLogStock();
            // bslyr.fileName = fileName;

            //  LCD
            //List<LCDDO> lcdList = bslyr.getLCD();
            //if (lcdList.Count > 0)
            bslyr.DeleteLCD();
            //bslyr.fileName = fileName;

            //  POP
            //List<POPDO> popList = bslyr.getPOP();
            // if (popList.Count > 0)
            bslyr.DeletePOP();
            //bslyr.fileName = fileName;

            //  PRO
            //List<PRODO> proList = bslyr.getPRO();
            //if (proList.Count > 0)
            bslyr.DeletePRO();
            //bslyr.fileName = fileName;

            return;
        }   //  end ClearCalculatedTables
Exemple #15
0
        }   //  end UpdateExpansionFactors

        private void DefaultSecondaryProduct(string currRegion)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();
            ErrorLogMethods elm   = new ErrorLogMethods();

            bslyr.DAL = DAL;

            List <SampleGroupDO> sgList = bslyr.getSampleGroups();

            foreach (SampleGroupDO sgd in sgList)
            {
                if (sgd.SecondaryProduct == "" || sgd.SecondaryProduct == " " ||
                    sgd.SecondaryProduct == "  " || sgd.SecondaryProduct == null)
                {
                    switch (currRegion)
                    {
                    case "06":
                    case "6":
                        sgd.SecondaryProduct = "08";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    case "05":
                    case "5":
                        sgd.SecondaryProduct = "20";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    default:
                        sgd.SecondaryProduct = "02";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;
                    } //  end switch
                }     //  endif
            }         //  end foreach loop
            bslyr.SaveSampleGroups(sgList);
            return;
        }   //  end DefaultSecondaryProduct
        }         //  end addReports

        public static List <ReportsDO> deleteReports(List <ReportsDO> rList, CPbusinessLayer bslyr)
        {
            //  probably used infrequently
            //  currently deletes CSV reports from the reports list
            //  however it does not delete in the database
            //  so do that first
            string[] reportsToDelete = new string[6] {
                "CSV1", "CSV2", "CSV3", "CSV4", "CSV5", "CSV6"
            };
            for (int j = 0; j < 6; j++)
            {
                bslyr.deleteReport(reportsToDelete[j]);

                foreach (ReportsDO rr in rList)
                {
                    if (rr.ReportID == reportsToDelete[j])
                    {
                        rr.Delete();
                    }
                } //  end foreach loop
            }     //  end for j loop
            return(rList);
        }         //  end deleteReports
Exemple #17
0
        }     //  end GetCutGroupedBy

        public static List <LCDDO> GetStratumGroupedBy(string fileName, string currentST, CPbusinessLayer bslyr)
        {
            List <LCDDO> justStratum = new List <LCDDO>();

            justStratum = bslyr.getLCDOrdered("WHERE CutLeave = @p1 AND Stratum = @p2  GROUP BY ", "SampleGroup,Species,STM", "C", currentST);
            return(justStratum);
        }   //  end GetStratumGroupedBy
        }   //  end CheckForNoDBH

        private int CheckForMeasuredTrees(List <TreeDO> treeList, int currST_CN, string currMeth, CPbusinessLayer bslyr)
        {
            int             numErrs = 0;
            ErrorLogMethods elm     = new ErrorLogMethods();

            //  if the tree list is empty, could be the strata just doesn't have any trees.
            //  this is probably a cruise in process so return no errors on this stratum.
            //  October 2014
            if (treeList.Count == 0)
            {
                return(numErrs);
            }

            //  need sample group(s) for current stratum
            List <SampleGroupDO> sgList = bslyr.getSampleGroups(currST_CN);

            //  check is method based
            switch (currMeth)
            {
            case "3P":
            case "STR":
            case "S3P":
                foreach (SampleGroupDO sg in sgList)
                {
                    //  find count records for the sample group
                    List <CountTreeDO> justGroups = bslyr.getCountTrees((long)sg.SampleGroup_CN);
                    //  sum up tree count
                    float totalCount = justGroups.Sum(jg => jg.TreeCount);
                    if (totalCount > 0)
                    {
                        //  Any measured trees?  look for just one measured tree in the stratum
                        List <TreeDO> justMeasured = treeList.FindAll(
                            delegate(TreeDO t)
                        {
                            return(t.CountOrMeasure == "M" && t.SampleGroup_CN == sg.SampleGroup_CN && t.Stratum_CN == currST_CN);
                        });
                        if (justMeasured.Count == 0)
                        {
                            //  this is the error
                            elm.LoadError("SampleGroup", "W", "30", (long)sg.SampleGroup_CN, "NoName");
                            numErrs++;
                        } //  endif
                    }     //  endif totalCount
                }         //  end foreach loop
                break;

            default:            //  all area based
                foreach (SampleGroupDO sg in sgList)
                {
                    List <TreeDO> justGroups = treeList.FindAll(
                        delegate(TreeDO t)
                    {
                        return(t.SampleGroup_CN == sg.SampleGroup_CN);
                    });

                    float totalCount = justGroups.Sum(jg => jg.TreeCount);
                    if (totalCount > 0)
                    {
                        //  any measured trees?
                        List <TreeDO> justMeasured = justGroups.FindAll(
                            delegate(TreeDO td)
                        {
                            return(td.CountOrMeasure == "M");
                        });
                        if (justMeasured.Count == 0)
                        {
                            // here's the error
                            elm.LoadError("SampleGroup", "W", "30", (long)sg.SampleGroup_CN, "NoName");
                            numErrs++;
                        } //  endif
                    }     //  endif totalCount
                }         //  end foreach loop
                break;
            }             //  end switch
            return(numErrs);
        }                 //  end CheckForMeasuredTrees
Exemple #19
0
        public void outputBannerPage(string fileName, StreamWriter strWriteOut, string currentDate,
                                     string currentVersion, string DLLversion, CPbusinessLayer bslyr)
        {
            int flagBLM = 0;

            //  Data arrays for the banner page
            string[] bannerTitle = new string[2] {
                "CRUISE REPORT HEADER & CERTIFICATION",
                "CRUISE REPORT HEADER"
            };
            string[] bannerYFD = new string[2] {
                "Year: yyyy    Region: rr   Forest: ff   District: dd",
                "Year: yyyy    Agency: BLM   Forest: ff   District: dd"
            };
            string[] cruiseCertification = new string[17] {
                "                            **************************** CRUISE CERTIFICATION ****************************",
                "",
                "                                I certify that the timber for the XXXXXXXX timber sale",
                "                                has been designated and cruised by the procedures and standards in",
                "                                FSH 2409.12, Timber Cruising Handbook.  Records of checks are on file",
                "                                at the District Ranger Office,",
                "",
                "",
                "",
                "                                ___________________                 ___________________________________",
                "                                RANGER DISTRICT                     (name of headquarters town)",
                "",
                "",
                "                                ___________________                 ______________",
                "                                DISTRICT RANGER                     DATE",
                "",
                "                            *****************************************************************************"
            };
            string[] BLMcertification = new string[23] {
                "                            ***************  B L M  C R U I S E  C E R T I F I C A T I O N  ***************",
                "                            *******************************************************************************",
                "",
                "                                I certify that the timber for the XXXXXXXX timber sale",
                "                                has been cruised according to the procedures and standards set",
                "                                forth in the BLM Timber Cruising Handbook 5310-1.",
                "",
                "",
                "",
                "",
                "                                ___________________________                 ___________________",
                "                                Principal Area Cruiser                             Date",
                "",
                "",
                "                                ___________________________                 ___________________",
                "                                District Cruiser Appraiser                         Date",
                "",
                "",
                "                                ___________________________                 ___________________",
                "                                Field Manager                                      Date",
                "",
                "                            *****************************************************************************",
                "                            *****************************************************************************"
            };
            string[] bannerFooter = new string[4] {
                "Developed and Maintained By:",
                "USDA FOREST SERVICE                                                                                             VERSION: ",
                "WASHINGTON OFFICE TIMBER MANAGEMENT                                                              VOLUME LIBRARY VERSION: ",
                "FORT COLLINS, COLORADO (970)295-5776                                                             NATIONAL CRUISE PROCESSING PROGRAM"
            };

            //  open sale table
            List <SaleDO> saleList = bslyr.getSale();
            //  need to capture region and forest
            string currRegion = "";
            string currForest = "";

            foreach (SaleDO sl in saleList)
            {
                //  Is this a BLM file?
                if (sl.Region == "7" || sl.Region == "07")
                {
                    flagBLM = 1;
                }

                //  Output header portion
                if (flagBLM == 1)
                {
                    strWriteOut.WriteLine(bannerTitle[1]);
                }
                else
                {
                    strWriteOut.WriteLine(bannerTitle[0]);
                }
                sb.Clear();
                sb.Append("CRUISE#: ");
                sb.Append(sl.SaleNumber);
                sb.Append("      SALE#: ");
                sb.Append(sl.SaleNumber);
                strWriteOut.WriteLine(sb.ToString());
                //  save cruise "name" for later
                cruiseName = sl.SaleNumber;

                sb.Clear();
                sb.Append("SALENAME: ");
                sb.Append(sl.Name);
                strWriteOut.WriteLine(sb.ToString());
                //  save salename for later
                saleName = sl.Name.TrimEnd(' ');

                sb.Clear();
                sb.Append("RUN DATE & TIME: ");
                sb.Append(currentDate);
                strWriteOut.WriteLine(sb.ToString());
                strWriteOut.WriteLine(" ");

                //  Output remaining portion of upper left corner
                sb.Clear();
                // replace fields as needed
                if (flagBLM == 1)
                {
                    bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("yyyy", sl.CalendarYear.ToString());
                    bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("ff", sl.Forest.PadLeft(2, ' '));
                    bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("dd", sl.District.PadLeft(2, ' '));
                    strWriteOut.WriteLine(bannerYFD[flagBLM]);
                }
                else
                {
                    bannerYFD[0] = bannerYFD[0].Replace("yyyy", sl.CalendarYear.ToString());
                    bannerYFD[0] = bannerYFD[0].Replace("rr", sl.Region.PadLeft(2, '0'));
                    bannerYFD[0] = bannerYFD[0].Replace("ff", sl.Forest.PadLeft(2, ' '));
                    if (sl.District == "" || sl.District == " " || sl.District == null)
                    {
                        bannerYFD[0] = bannerYFD[0].Replace("dd", "  ");
                    }
                    else
                    {
                        bannerYFD[0] = bannerYFD[0].Replace("dd", sl.District.PadLeft(2, ' '));
                    }
                    strWriteOut.WriteLine(bannerYFD[0]);
                }   //  endif

                sb.Clear();
                sb.Append("Remarks: ");
                sb.Append(sl.Remarks ?? (" "));
                strWriteOut.WriteLine(sb.ToString());

                currRegion = sl.Region;
                currForest = sl.Forest;
            }   //  end foreach loop

            sb.Clear();
            sb.Append("FILENAME: ");
            sb.Append(fileName);
            strWriteOut.WriteLine(sb.ToString());

            //  Reports list
            List <ReportsDO> rList = bslyr.GetSelectedReports();

            sb.Clear();
            sb.Append("REPORTS: ");
            int numReports = 0;

            foreach (ReportsDO rd in rList)
            {
                numReports++;
                if (numReports <= 20)
                {
                    sb.Append(rd.ReportID);
                    sb.Append(" ");
                }
                else if (numReports == 21)
                {
                    numReports = 0;
                    strWriteOut.WriteLine(sb.ToString());
                    sb.Clear();
                    sb.Append("         ");
                    sb.Append(rd.ReportID);
                    sb.Append(" ");
                    numReports++;
                } //  endif
            }     //  end foreach loop

            //  output BLM line
            if (flagBLM == 1)
            {
                //  write reports line
                strWriteOut.WriteLine(sb.ToString());
                sb.Clear();
                sb.Append("VOLUME BASED ON ");
                //  need volume equation type for BLM here
                List <VolumeEquationDO> vList = bslyr.getVolumeEquations();
                int nthRow = vList.FindIndex(
                    delegate(VolumeEquationDO ved)
                {
                    return(ved.VolumeEquationNumber.Substring(3, 4) == "B32W");
                });
                if (nthRow >= 0)
                {
                    sb.Append("32 ");
                }
                else
                {
                    sb.Append("16");
                }
                sb.Append(" FOOT EQUATIONS");
                strWriteOut.WriteLine(sb.ToString());
            }
            else
            {
                strWriteOut.WriteLine(sb.ToString());
            }

            //  Output note for Region 9 as to whether International or Scribner for board foot volume
            if (currRegion == "9" || currRegion == "09")
            {
                switch (currForest)
                {
                case "03":
                case "3":                           //  Chippewa
                case "09":
                case "9":                           //  Superior
                case "13":
                case "10":                          //  Chequamegon-Nicolet and Hiawatha
                case "07":
                case "7":                           //  Ottawa
                    sb.Clear();
                    sb.Append("Scribner rule was used for board foot volumes shown in the selected reports.");
                    break;

                case "04":
                case "4":                           //  Huron-Manistee
                case "05":
                case "5":                           //  Mark Twain
                case "08":
                case "8":                           //  Shawnee
                case "12":
                case "14":                          //  Hoosier and Wayne
                case "19":
                case "21":                          //  Allegheny and Monongahela
                case "20":
                case "22":                          //  Green Mountain/Finger Lakes and White Mountain
                    sb.Clear();
                    sb.Append("International 1/4 inch rule was used for board foot volumes in the selected reports.");
                    break;
                } //  end switch
                strWriteOut.WriteLine(sb.ToString());
            }     //  endif region 9

            //  Several blank lines now
            for (int k = 0; k < 6; k++)
            {
                strWriteOut.WriteLine();
            }

            //  Certification part
            if (flagBLM == 1)
            {
                for (int k = 0; k < 23; k++)
                {
                    if (k == 3)
                    {
                        BLMcertification[k] = BLMcertification[k].Replace("XXXXXXXX", saleName);
                    }


                    strWriteOut.WriteLine(BLMcertification[k]);
                }   //  end for k loop
            }
            else
            {
                for (int k = 0; k < 17; k++)
                {
                    if (k == 2)
                    {
                        cruiseCertification[k] = cruiseCertification[k].Replace("XXXXXXXX", saleName);
                    }

                    strWriteOut.WriteLine(cruiseCertification[k]);
                } //  end for loop for certification
            }     //  endif

            //  last portion
            for (int k = 0; k < 8; k++)
            {
                strWriteOut.WriteLine();
            }

            strWriteOut.WriteLine(bannerFooter[0]);

            sb.Clear();
            sb.Append(bannerFooter[1]);
            sb.Append(currentVersion);
            strWriteOut.WriteLine(sb.ToString());

            sb.Clear();
            sb.Append(bannerFooter[2]);
            sb.Append(DLLversion);
            strWriteOut.WriteLine(sb.ToString());

            strWriteOut.WriteLine(bannerFooter[3]);
        }   //  end outputBannerPage
        }   //  end LogError6

        public static StringBuilder GetIdentifier(string tableName, long CNtoFind, CPbusinessLayer bslyr)
        {
            StringBuilder ident  = new StringBuilder();
            int           ithRow = -1;

            switch (tableName)
            {
            case "Sale":
                List <SaleDO> sList = bslyr.getSale();
                ithRow = sList.FindIndex(
                    delegate(SaleDO sd)
                {
                    return(sd.Sale_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append("Sale number = ");
                    ident.Append(sList[ithRow].SaleNumber);
                }
                else
                {
                    ident.Append("Sale number not found");
                }
                break;

            case "Stratum":
                List <StratumDO> stList = bslyr.getStratum();
                ithRow = stList.FindIndex(
                    delegate(StratumDO sdo)
                {
                    return(sdo.Stratum_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append(stList[ithRow].Code);
                }
                else
                {
                    ident.Append("Stratum code not found");
                }
                break;

            case "Cutting Unit":
                List <CuttingUnitDO> cList = bslyr.getCuttingUnits();
                ithRow = cList.FindIndex(
                    delegate(CuttingUnitDO cu)
                {
                    return(cu.CuttingUnit_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append("   ");
                    ident.Append(cList[ithRow].Code.PadLeft(3, ' '));
                }
                else
                {
                    ident.Append("Cutting unit not found");
                }
                break;

            case "Tree":
                List <TreeDO> tList = bslyr.getTrees();
                ithRow = tList.FindIndex(
                    delegate(TreeDO td)
                {
                    return(td.Tree_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append(tList[ithRow].Stratum.Code.PadRight(3, ' '));
                    ident.Append(tList[ithRow].CuttingUnit.Code.PadLeft(3, ' '));
                    if (tList[ithRow].Plot == null)
                    {
                        ident.Append("     ");
                    }
                    else if (tList[ithRow].Plot_CN == 0)
                    {
                        ident.Append("     ");
                    }
                    else
                    {
                        ident.Append(tList[ithRow].Plot.PlotNumber.ToString().PadLeft(5, ' '));
                    }
                    ident.Append(tList[ithRow].TreeNumber.ToString().PadLeft(5, ' '));
                    ident.Append(" --- ");
                    if (tList[ithRow].Species == null)
                    {
                        ident.Append("       ");
                    }
                    else
                    {
                        ident.Append(tList[ithRow].Species.PadRight(7, ' '));
                    }
                    if (tList[ithRow].SampleGroup == null)
                    {
                        ident.Append("   ");
                    }
                    else
                    {
                        if (tList[ithRow].SampleGroup.Code == "" || tList[ithRow].SampleGroup.Code == " " ||
                            tList[ithRow].SampleGroup.Code == "<Blank>" || tList[ithRow].SampleGroup.Code == null)
                        {
                            ident.Append("   ");
                        }
                        else
                        {
                            ident.Append(tList[ithRow].SampleGroup.Code.PadRight(3, ' '));
                        }
                        ident.Append(tList[ithRow].SampleGroup.PrimaryProduct.PadRight(3, ' '));
                    }       //  endif
                }
                else
                {
                    ident.Append("Tree not found");
                }
                break;

            case "Log":
                List <LogDO> lList = bslyr.getLogs();
                ithRow = lList.FindIndex(
                    delegate(LogDO ld)
                {
                    return(ld.Log_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append(lList[ithRow].Tree.Stratum.Code.PadRight(3, ' '));
                    ident.Append(lList[ithRow].Tree.CuttingUnit.Code.PadLeft(3, ' '));
                    if (lList[ithRow].Tree.Plot == null)
                    {
                        ident.Append("     ");
                    }
                    else
                    {
                        ident.Append(lList[ithRow].Tree.Plot.PlotNumber.ToString().PadLeft(5, ' '));
                    }
                    ident.Append(lList[ithRow].Tree.TreeNumber.ToString().PadLeft(5, ' '));
                    ident.Append(lList[ithRow].LogNumber.PadLeft(3, ' '));
                }
                else
                {
                    ident.Append("Log not found");
                }
                break;

            case "Volume Equation":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                List <VolumeEquationDO> vList = bslyr.getVolumeEquations();
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(vList[(int)CNtoFind - 1].Species.PadRight(7, ' '));
                ident.Append("-- ");
                ident.Append(vList[(int)CNtoFind - 1].PrimaryProduct.PadRight(3, ' '));
                ident.Append(vList[(int)CNtoFind - 1].VolumeEquationNumber.PadRight(10, ' '));
                break;

            case "Value Equation":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                List <ValueEquationDO> veList = bslyr.getValueEquations();
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(veList[(int)CNtoFind - 1].Species.PadRight(7, ' '));
                ident.Append("-- ");
                ident.Append(veList[(int)CNtoFind - 1].PrimaryProduct.PadRight(3, ' '));
                ident.Append(veList[(int)CNtoFind - 1].ValueEquationNumber.PadRight(10, ' '));
                break;

            case "Quality Adjustment":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                List <QualityAdjEquationDO> qList = bslyr.getQualAdjEquations();
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(qList[(int)CNtoFind - 1].Species.PadRight(7, ' '));
                ident.Append("-- -- ");
                ident.Append(qList[(int)CNtoFind - 1].QualityAdjEq.PadRight(10, ' '));
                break;

            case "SampleGroup":
                List <SampleGroupDO> sgList = bslyr.getSampleGroups();
                ithRow = sgList.FindIndex(
                    delegate(SampleGroupDO sgd)
                {
                    return(sgd.SampleGroup_CN == CNtoFind);
                });
                if (ithRow >= 0)
                {
                    ident.Append(sgList[ithRow].Stratum.Code.PadRight(3, ' '));
                    ident.Append("--- ---- ---- --- ------ ");
                    ident.Append(sgList[ithRow].Code.PadRight(3, ' '));
                    ident.Append(sgList[ithRow].PrimaryProduct.PadRight(3, ' '));
                }
                else
                {
                    ident.Append("Sample Group not found");
                }
                break;
            } //  end switch
            return(ident);
        }     //  end GetIdentifier
Exemple #21
0
        }     //  end onFile

        private void onButton1Click(object sender, EventArgs e)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL = DAL;

            if (this.DAL_V3 != null)
            {
                bslyr.DAL_V3 = this.DAL_V3;
            }//end if


            if (whichProcess == 1)       //  equations
            {
                VolumeEquations volEqObj = new VolumeEquations();
                volEqObj.bslyr.fileName = fileName;
                volEqObj.bslyr.DAL      = DAL;
                if (this.DAL_V3 != null)
                {
                    volEqObj.bslyr.DAL_V3 = DAL_V3;
                }//end if

                if (templateFlag == 0)
                {
                    int nResult = volEqObj.setupDialog();
                    if (nResult != -1)
                    {
                        volEqObj.ShowDialog();
                    }
                }
                else if (templateFlag == 1)
                {
                    int nResult = volEqObj.setupTemplateDialog();
                    if (nResult == 1)
                    {
                        volEqObj.templateFlag = templateFlag;
                        volEqObj.ShowDialog();
                    }                   //  endif
                }                       //  endif
            }
            else if (whichProcess == 2) //  reports
            {
                //  calls routine to add standard and regional reports
                List <ReportsDO> currentReports = new List <ReportsDO>();
                if (templateFlag == 1)
                {
                    bslyr.fileName = newTemplateFile;
                    bslyr.DAL      = new DAL(newTemplateFile);
                }
                else
                {
                    bslyr.fileName = fileName;
                }
                //  get all reports
                currentReports = bslyr.GetReports();
                //  and get the all reports array
                allReportsArray ara = new allReportsArray();
                //  then check for various conditions to know what to do with the reports list
                if (currentReports.Count == 0)
                {
                    currentReports = ReportMethods.fillReportsList();
                    bslyr.SaveReports(currentReports);
                    if (DAL_V3 != null)
                    {
                        bslyr.insertReportsV3();
                    }
                }//end if
                else if (currentReports.Count < ara.reportsArray.GetLength(0))
                {
                    //  old or new list?  Check title
                    if (currentReports[0].Title == "" || currentReports[0].Title == null)
                    {
                        //  old reports -- update list
                        currentReports = ReportMethods.updateReportsList(currentReports, ara);
                        bslyr.SaveReports(currentReports);
                    }
                    else
                    {
                        //  new reports -- just add
                        currentReports = ReportMethods.addReports(currentReports, ara);
                        bslyr.SaveReports(currentReports);
                    }   //  endif

                    //if the reports are out of sync delete and refresh V3.
                    if (DAL_V3 != null)
                    {
                        bslyr.insertReportsV3();
                    }
                }   //  endif
                //  now get reports selected


                currentReports = ReportMethods.deleteReports(currentReports, bslyr);
                currentReports = bslyr.GetSelectedReports();
                //  Get selected reports
                ReportsDialog rd = new ReportsDialog();
                rd.fileName       = fileName;
                rd.bslyr.fileName = bslyr.fileName;
                rd.bslyr.DAL      = bslyr.DAL;
                //add version 3 ref for saving back.
                rd.bslyr.DAL_V3 = bslyr.DAL_V3;


                rd.reportList   = currentReports;
                rd.templateFlag = templateFlag;
                rd.setupDialog();
                rd.ShowDialog();
            }
            else if (whichProcess == 4)  //  output
            {
                //  Pull reports selected
                bslyr.fileName = fileName;
                //  See if volume has been calculated (sum expansion factor since those are calculated before volume)
                //  July 2014 -- However it looks like expansion factors could be present but volume is not
                //  need to pull calculated values as well and sum net volumes
                List <TreeDO> tList    = bslyr.getTrees();
                double        summedEF = tList.Sum(t => t.ExpansionFactor);
                List <TreeCalculatedValuesDO> tcvList = bslyr.getTreeCalculatedValues();
                double summedNetBDFT = tcvList.Sum(tc => tc.NetBDFTPP);
                double summedNetCUFT = tcvList.Sum(tc => tc.NetCUFTPP);
                if (summedEF == 0 && summedNetBDFT == 0 && summedNetCUFT == 0)
                {
                    MessageBox.Show("Looks like volume has not been calculated.\nReports cannot be produced without calculated volume.\nPlease calculate volume before continuing.", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }   //  endif no volume for reports
                List <ReportsDO> selectedReports = bslyr.GetSelectedReports();

                //  no reports?  let user know to go back and select reports
                if (selectedReports.Count == 0)
                {
                    MessageBox.Show("No reports selected.\nReturn to Reports section and select reports.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }   //  endif no reports

                //  Show dialog creating text file
                TextFileOutput tfo = new TextFileOutput();
                tfo.selectedReports = selectedReports;
                tfo.fileName        = fileName;
                tfo.currRegion      = currentRegion;
                tfo.bslyr           = bslyr;
                tfo.setupDialog();
                tfo.ShowDialog();
                string outFile    = tfo.outFile;
                int    retrnState = tfo.retrnState;

                //  Let user know the file is complete
                //  This shows only when the Finished button is clicked
                //  X-button click just closes the window
                if (retrnState == 0)
                {
                    StringBuilder message = new StringBuilder();
                    message.Append("Text output file is complete and can be found at:\n");
                    message.Append(outFile);
                    MessageBox.Show(message.ToString(), "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    processButton2.Enabled = true;
                    processButton3.Enabled = true;
                    processButton4.Enabled = true;
                    processButton5.Enabled = true;
                    processButton6.Enabled = true;
                    return;
                } //  endif
            }     //  endif whichProcess
        }         //  endif onButton1Click
Exemple #22
0
        }   //  end SumTreeCountsLCD

        public void SumTreeCountsPOP(string currST, List <CountTreeDO> ctList, List <PlotDO> justPlots,
                                     List <POPDO> justCurrentPOP, string currMethod, List <POPDO> popList)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  also need first and second stage sample counts
            double stage1 = 0.0;

            double stage2 = 0.0;

            //  Sums trees and counts from either the Count Tree table or tree count records
            foreach (POPDO pop in justCurrentPOP)
            {
                firstSum         = 0.0;
                talliedSum       = 0.0;
                totalKPI         = 0.0;
                totalMeasuredKPI = 0.0;
                //  find measured trees for current POP group
                List <TreeDO> popTrees = bslyr.getPOPtrees(pop, "M");
                //  measured tree is just a count of the trees for the current group
                pop.MeasuredTrees = popTrees.Count();

                //  now need count trees from tree count records
                List <TreeDO> popCntTrees = bslyr.getPOPtrees(pop, "C");

                //  sum all tree counts for first stage and total tallied
                if (currMethod == "STR" || currMethod == "100")
                {
                    firstSum = popTrees.Count();
                    //  I thought tree count was supposed to default to 1 for 100% -- Feb 2014
                    //  Apparently, FScruiser can put whatever it wants in tree count
                }
                else if (currMethod != "3P")
                {
                    firstSum  = popTrees.Sum(tdo => tdo.TreeCount);
                    firstSum += popCntTrees.Sum(tdo => tdo.TreeCount);
                }
                if (pop.STM == "Y")
                {
                    firstSum   += pop.MeasuredTrees;
                    talliedSum += pop.MeasuredTrees;
                    //talliedSum = popTrees.Sum(tdo => tdo.TreeCount);
                }
                else
                {
                    //  see note above on 100% method
                    //if (currMethod == "3P" || currMethod == "100")
                    if (currMethod == "100")
                    {
                        talliedSum += pop.MeasuredTrees;
                    }
                    else
                    {
                        talliedSum  = popTrees.Sum(tdo => tdo.TreeCount);
                        talliedSum += popCntTrees.Sum(tdo => tdo.TreeCount);
                    } //  endif on current method
                }     //  endif
                //  insurance trees go into just the tallied tree count
                List <TreeDO> lcdInsurance = bslyr.getPOPtrees(pop, "I");
                talliedSum += lcdInsurance.Sum(tdo => tdo.TreeCount);
                //  Complete totals for tree count and stage samples and KPIs based on method
                stage1 = justPlots.Count();
                List <CountTreeDO> popCountCounts = new List <CountTreeDO>();
                switch (currMethod)
                {
                case "100":
                    stage1 = popTrees.Count();
                    break;

                case "STR":
                    stage1         = popTrees.Count();
                    popCountCounts = ctList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(pop.CutLeave == ctd.SampleGroup.CutLeave &&
                               pop.Stratum == ctd.SampleGroup.Stratum.Code &&
                               pop.SampleGroup == ctd.SampleGroup.Code &&
                               pop.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                               pop.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                               pop.UOM == ctd.SampleGroup.UOM);
                    });
                    talliedSum += popCountCounts.Sum(ctd => ctd.TreeCount);
                    break;

                case "S3P":
                case "3P":
                    if (currMethod == "S3P")
                    {
                        stage2 = popTrees.Count();
                    }
                    popCountCounts = ctList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(pop.CutLeave == ctd.SampleGroup.CutLeave &&
                               pop.Stratum == ctd.SampleGroup.Stratum.Code &&
                               pop.SampleGroup == ctd.SampleGroup.Code &&
                               pop.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                               pop.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                               pop.UOM == ctd.SampleGroup.UOM);
                    });
                    if (pop.STM == "N")
                    {
                        stage1      = popTrees.Count();
                        firstSum   += pop.MeasuredTrees;
                        talliedSum += popCountCounts.Sum(ctd => ctd.TreeCount);
                        totalKPI   += popCountCounts.Sum(ctd => ctd.SumKPI);
                    }
                    //  Sum measured KPI from trees
                    totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    //  for S3P and 3P, sum of KPI is total of count and measured KPI from the trees == November 2013
                    //  even though individual KPI may be zero for either one.
                    //  however, countTree has sum of count and measured KPI for 3P so adding measured and count
                    //  from trees will double count for 3P ONLY -- December 2013
                    if (currMethod == "S3P")
                    {
                        totalKPI += popCntTrees.Sum(lc => lc.KPI);
                        totalKPI += popTrees.Sum(lt => lt.KPI);
                    }       //  endif on method
                    break;

                case "PCM":
                case "PCMTRE":
                    stage2 = popTrees.Count();
                    break;

                case "F3P":
                case "P3P":
                    stage2           = popTrees.Count();
                    totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    totalKPI         = popCntTrees.Sum(tdo => tdo.KPI);
                    totalKPI        += totalMeasuredKPI;
                    totalKPI        += popCountCounts.Sum(ctd => ctd.SumKPI);
                    break;

                case "FCM":
                    //  August 2014 -- according to Ken C. this needs to be just the total measured trees
                    //  and not the sum of tree counts.  Some tree counts could be zero when they should be one.
                    //stage2 = popTrees.Sum(p => p.TreeCount);
                    stage2 = pop.MeasuredTrees;
                    break;

                case "3PPNT":
                    //  Stage 2 samples
                    foreach (PlotDO pdo in justPlots)
                    {
                        int nthRow = popTrees.FindIndex(
                            delegate(TreeDO tdo)
                        {
                            return(tdo.Plot_CN == pdo.Plot_CN);
                        });
                        if (nthRow >= 0)
                        {
                            stage2++;
                            nthRow = -1;
                        }   //  endif nthRow
                    }       //  end foreach loop
                    //  this will probably no longer work on legacy data until
                    //  the conversion program handles this change
                    if (popTrees.Count > 0)
                    {
                        //  means there are measured trees so this was a measured plot
                        //  KPI in the plot table is measured
                        totalMeasuredKPI = justPlots.Sum(pd => pd.KPI);
                        //  plus add to total KPI
                        totalKPI = justPlots.Sum(pd => pd.KPI);
                    }
                    else
                    {
                        //  no measured trees means this is a count plot
                        //  just add plot KPI to total KPI
                        totalKPI += justPlots.Sum(pd => pd.KPI);
                    }       //  endif
                    //  this piece of code will no longer work -- September 2013
                    //totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += lcdCountCounts.Sum(ctd => ctd.SumKPI);
                    //  Add plot KPI to total KPI
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    //totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += popCntTrees.Sum(tdo => tdo.KPI);
                    //  Also need plot KPI for this method
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    break;
                }   //  end switch on method
                pop.FirstStageTrees = firstSum;
                pop.TalliedTrees    = talliedSum;
                pop.SumKPI          = totalKPI;
                pop.SumMeasuredKPI  = totalMeasuredKPI;
                pop.StageOneSamples = stage1;
                pop.StageTwoSamples = stage2;
            }   //  end foreach loop

            //  Save list before continuing
            bslyr.SavePOP(popList);

            return;
        }   //  end SumTreeCountsPOP
Exemple #23
0
        }   //  end MakePopulationIDs

        // NOTE: Converted files - sum of KPI for 3P and S3P is the total of the SumKPI from the Count table
        //  plus the sum of measured KPI from the tree table.  No longer need to sum KPI from Count Tree and Tree
        //  April 2013
        //  methods to sum trees and KPI for individual methods
        public void SumTreeCountsLCD(string currST, List <CountTreeDO> ctList, List <PlotDO> justPlots,
                                     List <LCDDO> justCurrentLCD, string currMethod, List <LCDDO> lcdList)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;

            string currSG = "*";
            string prevSP = "*";

            //  Sums trees and counts from either the CountTree table or tree count records
            foreach (LCDDO lcd in justCurrentLCD)
            {
                firstSum         = 0.0;
                talliedSum       = 0.0;
                totalMeasuredKPI = 0.0;
                totalKPI         = 0.0;
                //  find measured trees for current LCD group
                List <TreeDO> lcdTrees = bslyr.getLCDtrees(lcd, "M");
                //  measured trees is just a count of the trees for current LCD group
                lcd.MeasuredTrees = lcdTrees.Count();

                //  now need count trees from tree count records
                List <TreeDO> lcdCntTrees = bslyr.getLCDtrees(lcd, "C");
                //  Sum all tree counts for first stage and total tallied
                //  see note in POP section on 100% method
                if (currMethod == "STR" || currMethod == "100")
                {
                    firstSum = lcdTrees.Count();
                }
                else if (currMethod != "3P")
                {
                    firstSum  = lcdTrees.Sum(tdo => tdo.TreeCount);
                    firstSum += lcdCntTrees.Sum(tdo => tdo.TreeCount);
                }
                if (lcd.STM == "Y")
                {
                    firstSum += lcd.MeasuredTrees;
                    //talliedSum += lcdTrees.Sum(tdo => tdo.TreeCount);
                    talliedSum += lcd.MeasuredTrees;
                }
                else
                {
                    //if (currMethod == "3P" || currMethod == "100")
                    if (currMethod == "100")
                    {
                        talliedSum += lcd.MeasuredTrees;
                    }
                    else
                    {
                        talliedSum  = lcdTrees.Sum(tdo => tdo.TreeCount);
                        talliedSum += lcdCntTrees.Sum(tdo => tdo.TreeCount);
                    } //  endif on current method
                }     //  endif
                //  insurance trees go into just the tallied tree count
                List <TreeDO> lcdInsurance = bslyr.getLCDtrees(lcd, "I");
                talliedSum += lcdInsurance.Sum(tdo => tdo.TreeCount);
                //  Complete totals based on method --  KPIs too
                List <CountTreeDO> lcdCountCounts = new List <CountTreeDO>();
                switch (currMethod)
                {
                case "STR":
                    currSG = "*";
                    prevSP = "*";
                    foreach (CountTreeDO ctd in ctList)
                    {
                        if (lcd.Stratum == ctd.SampleGroup.Stratum.Code &&
                            lcd.SampleGroup == ctd.SampleGroup.Code)
                        {
                            if (currSG != lcd.SampleGroup && prevSP != lcd.Species &&
                                (ctd.TreeDefaultValue_CN == 0 || ctd.TreeDefaultValue_CN == null))
                            {
                                //  multiple species for this sample group so avoid double counting
                                talliedSum += ctd.TreeCount;
                                currSG      = lcd.SampleGroup;
                                prevSP      = lcd.Species;
                            }
                            else if (currSG == lcd.SampleGroup && prevSP != lcd.Species &&
                                     (ctd.TreeDefaultValue_CN == 0 || ctd.TreeDefaultValue_CN == null))
                            {
                                //  do not add tree count
                                prevSP = lcd.Species;
                            }
                            else if (currSG != lcd.SampleGroup && prevSP != lcd.Species &&
                                     (ctd.TreeDefaultValue_CN > 0 || ctd.TreeDefaultValue_CN == null))
                            {
                                //  sample group probably doesn't have multiple species
                                talliedSum += ctd.TreeCount;
                            }
                            else if (currSG == lcd.SampleGroup && prevSP == lcd.Species &&
                                     (ctd.TreeDefaultValue_CN > 0 || ctd.TreeDefaultValue_CN == null))
                            {
                                talliedSum += ctd.TreeCount;
                            } //  endif
                        }     //  endif
                    }         //  end foreach count tree

                    break;

                case "3P":
                case "S3P":
                    lcdCountCounts = ctList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(lcd.CutLeave == ctd.SampleGroup.CutLeave &&
                               lcd.Stratum == ctd.SampleGroup.Stratum.Code &&
                               lcd.SampleGroup == ctd.SampleGroup.Code &&
                               lcd.Species == ctd.TreeDefaultValue.Species &&
                               lcd.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                               lcd.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                               lcd.UOM == ctd.SampleGroup.UOM &&
                               lcd.LiveDead == ctd.TreeDefaultValue.LiveDead &&
                               lcd.Yield == ctd.SampleGroup.Stratum.YieldComponent &&
                               //  per K.Cormier, dropping contract species from LCD ID
                               //lcd.ContractSpecies == ctd.TreeDefaultValue.ContractSpecies &&
                               lcd.TreeGrade == ctd.TreeDefaultValue.TreeGrade);
                    });
                    if (lcd.STM == "N")
                    {
                        firstSum   += lcd.MeasuredTrees;
                        talliedSum += lcdCountCounts.Sum(ctd => ctd.TreeCount);
                        totalKPI   += lcdCountCounts.Sum(ctd => ctd.SumKPI);
                    }

                    //  Sum measured KPI from trees
                    totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    //  for S3P and 3P, sum of KPI is total of count and measured KPI from the trees == November 2013
                    //  even though KPI on an individual may be zero for one or the other
                    //  however, countTree has sum of count and measured KPI for 3P so adding measured and count
                    //  from trees will double count for 3P ONLY -- December 2013
                    if (currMethod == "S3P")
                    {
                        totalKPI += lcdCntTrees.Sum(lc => lc.KPI);
                        totalKPI += lcdTrees.Sum(lt => lt.KPI);
                    }       //   endif on method
                    break;

                case "F3P":
                case "P3P":
                    //  Sum measured KPI from trees
                    totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    totalKPI         = lcdCntTrees.Sum(tdo => tdo.KPI);
                    totalKPI        += totalMeasuredKPI;
                    break;

                case "3PPNT":
                    //  this will probably no longer work on legacy data until
                    //  the conversion program handles this change
                    if (lcdTrees.Count > 0)
                    {
                        //  means there are measured trees so this was a measured plot
                        //  KPI in the plot table is measured
                        totalMeasuredKPI = justPlots.Sum(pd => pd.KPI);
                        //  plus add to total KPI
                        totalKPI = justPlots.Sum(pd => pd.KPI);
                    }
                    else
                    {
                        //  no measured trees means this is a count plot
                        //  just add plot KPI to total KPI
                        totalKPI += justPlots.Sum(pd => pd.KPI);
                    }       //  endif
                    //  this piece of code will no longer work -- September 2013
                    //totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += lcdCountCounts.Sum(ctd => ctd.SumKPI);
                    //  Add plot KPI to total KPI
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    break;
                }   //  end switch on method

                lcd.FirstStageTrees = firstSum;
                lcd.TalliedTrees    = talliedSum;
                lcd.SumKPI          = totalKPI;
                lcd.SumMeasuredKPI  = totalMeasuredKPI;
            }   //  end foreach loop

            //  Save list before continuing
            bslyr.SaveLCD(lcdList);
            return;
        }   //  end SumTreeCountsLCD
Exemple #24
0
        }   //  end SumTreeCountsPOP

        public void SumTreeCountsPRO(string currST, List <CountTreeDO> ctList, List <PlotDO> justPlots, List <PRODO> justCurrentPRO, string currMethod, List <PRODO> proList)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  Sums tree counts from either the Count Tree table or tree count records
            foreach (PRODO pro in justCurrentPRO)
            {
                firstSum         = 0.0;
                talliedSum       = 0.0;
                totalKPI         = 0.0;
                totalMeasuredKPI = 0.0;
                //  find measured trees for current PRO group
                List <TreeDO> proTrees = bslyr.getPROtrees(pro, "M");
                //  measured trees is just a count of the trees for current PRO group
                pro.MeasuredTrees = proTrees.Count();

                //  now need count trees from tree count records
                List <TreeDO> proCntTrees = bslyr.getPROtrees(pro, "C");
                //  Sum all tree counts for first stage and total tallied
                //  see note in POP or LCD section on 100% method
                if (currMethod == "STR" || currMethod == "100")
                {
                    firstSum = proTrees.Count();
                }
                else if (currMethod != "3P")
                {
                    firstSum  = proTrees.Sum(tdo => tdo.TreeCount);
                    firstSum += proCntTrees.Sum(tdo => tdo.TreeCount);
                }

                if (pro.STM == "Y")
                {
                    firstSum   += pro.MeasuredTrees;
                    talliedSum += pro.MeasuredTrees;
                    //talliedSum = proTrees.Sum(tdo => tdo.TreeCount);
                }
                else
                {
                    //if (currMethod == "3P" || currMethod == "100")
                    if (currMethod == "100")
                    {
                        talliedSum += pro.MeasuredTrees;
                    }
                    else
                    {
                        talliedSum  = proTrees.Sum(tdo => tdo.TreeCount);
                        talliedSum += proCntTrees.Sum(tdo => tdo.TreeCount);
                    } //  endif on current method
                }     //  endif
                //  insurance trees go into just the tallied tree count
                List <TreeDO> lcdInsurance = bslyr.getPROtrees(pro, "I");
                talliedSum += lcdInsurance.Sum(tdo => tdo.TreeCount);
                //  Complete totals and KPIs based on method
                List <CountTreeDO> proCountCounts = new List <CountTreeDO>();
                switch (currMethod)
                {
                case "3P":
                case "S3P":
                    proCountCounts = ctList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(pro.CutLeave == ctd.SampleGroup.CutLeave &&
                               pro.Stratum == ctd.SampleGroup.Stratum.Code &&
                               pro.SampleGroup == ctd.SampleGroup.Code &&
                               pro.CuttingUnit == ctd.CuttingUnit.Code &&
                               pro.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                               pro.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                               pro.UOM == ctd.SampleGroup.UOM);
                    });
                    if (pro.STM == "N")
                    {
                        firstSum   += pro.MeasuredTrees;
                        talliedSum += proCountCounts.Sum(ctd => ctd.TreeCount);
                        totalKPI   += proCountCounts.Sum(ctd => ctd.SumKPI);
                    }
                    //  Sum measured KPI from trees
                    totalMeasuredKPI = proTrees.Sum(tdo => tdo.KPI);
                    //  for S3P, sum of KPI is total of count and measured KPI from the trees == November 2013
                    //  even though individual KPI may be zero for either method
                    //  however, countTree has sum of count and measured KPI for 3P so adding measured and count
                    //  from trees will double count for 3P ONLY -- December 2013
                    if (currMethod == "S3P")
                    {
                        totalKPI += proCntTrees.Sum(lc => lc.KPI);
                        totalKPI += proTrees.Sum(lt => lt.KPI);
                    }       //  endif on current method
                    break;

                case "STR":
                    proCountCounts = ctList.FindAll(
                        delegate(CountTreeDO ctd)
                    {
                        return(pro.CutLeave == ctd.SampleGroup.CutLeave &&
                               pro.Stratum == ctd.SampleGroup.Stratum.Code &&
                               pro.SampleGroup == ctd.SampleGroup.Code &&
                               pro.CuttingUnit == ctd.CuttingUnit.Code &&
                               pro.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                               pro.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                               pro.UOM == ctd.SampleGroup.UOM);
                    });
                    talliedSum += proCountCounts.Sum(ctd => ctd.TreeCount);
                    break;

                case "F3P":
                case "P3P":
                    //  Sum measured KPI from trees
                    totalMeasuredKPI = proTrees.Sum(tdo => tdo.KPI);
                    totalKPI         = proCntTrees.Sum(tdo => tdo.KPI);
                    totalKPI        += totalMeasuredKPI;
                    totalKPI        += proCountCounts.Sum(ctd => ctd.SumKPI);
                    break;

                case "3PPNT":
                    //  this will probably no longer work on legacy data until
                    //  the conversion program handles this change
                    if (proTrees.Count > 0)
                    {
                        //  means there are measured trees so this was a measured plot
                        //  KPI in the plot table is measured
                        totalMeasuredKPI = justPlots.Sum(pd => pd.KPI);
                        //  plus add to total KPI
                        totalKPI = justPlots.Sum(pd => pd.KPI);
                    }
                    else
                    {
                        //  no measured trees means this is a count plot
                        //  just add plot KPI to total KPI
                        totalKPI += justPlots.Sum(pd => pd.KPI);
                    }       //  endif
                    //  this piece of code will no longer work -- September 2013
                    //totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += lcdCountCounts.Sum(ctd => ctd.SumKPI);
                    //  Add plot KPI to total KPI
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    //  Sum measured KPI from trees
                    //totalMeasuredKPI = proTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += proCountCounts.Sum(ctd => ctd.SumKPI);
                    //  Add plot KPI to total KPI
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    break;
                }   //  end switch on method

                pro.FirstStageTrees = firstSum;
                pro.TalliedTrees    = talliedSum;
                pro.SumKPI          = totalKPI;
                pro.SumMeasuredKPI  = totalMeasuredKPI;
            }   //  end foreach loop

            //  Save list before continuing
            bslyr.SavePRO(proList);

            return;
        }   //  end SumTreeCountsPRO
Exemple #25
0
 public static void Init(CPbusinessLayer cPbusinessLayer)
 {
     BL = cPbusinessLayer;
 }
Exemple #26
0
        private void on_GO(object sender, EventArgs e)
        {
            processingStatus.Text = "READY TO BEGIN?  Click GO.";
            Cursor.Current        = Cursors.WaitCursor;
            //  perform edit checks --
            processingStatus.Text = "Edit checking the data.  Please wait.";
            processingStatus.Refresh();
            //  calls edit check routines

            /*            string outputFileName;
             *          //  check for errors from FScruiser before running edit checks
             *          //  generate an error report
             *          //  June 2013
             *          List<ErrorLogDO> fscList = bslyr.getErrorMessages("E", "FScruiser");
             *          if (fscList.Count > 0)
             *          {
             *              ErrorReport eRpt = new ErrorReport();
             *              eRpt.fileName = fileName;
             *              eRpt.bslyr.fileName = bslyr.fileName;
             *              eRpt.bslyr.DAL = bslyr.DAL;
             *              outputFileName = eRpt.PrintFScruiserErrors(fscList);
             *              string outputMessage = "ERRORS FROM FSCRUISER FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
             *              MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *              //  request made to open error report in preview -- May 2015
             *              PrintPreview pp = new PrintPreview();
             *              pp.fileName = outputFileName;
             *              pp.setupDialog();
             *              pp.ShowDialog();
             *              Environment.Exit(0);
             *          }   //  endif report needed
             *
             *          //  clear out error log table for just CruiseProcessing before performing checks
             *          bslyr.DeleteErrorMessages();
             *
             *          EditChecks eChecks = new EditChecks();
             *          eChecks.fileName = fileName;
             *          eChecks.bslyr.fileName = bslyr.fileName;
             *          eChecks.bslyr.DAL = bslyr.DAL;
             *
             *          int errors = eChecks.TableEditChecks();
             *          if (errors == -1)
             *          {
             *              //  no measured trees detected in the cruise.  critical errpor stops the program.
             *              Close();
             *              return;
             *          }   //  endif
             *          errors = eChecks.MethodChecks();
             *          if (errors == -1)
             *          {
             *              //  empty stratum detected and user wants to quit
             *              Close();
             *              return;
             *          }   //  endif
             *          //  just check the ErrorLog table for entries
             *          List<ErrorLogDO> errList = bslyr.getErrorMessages("E", "CruiseProcessing");
             *          if (errList.Count > 0)
             *          {
             *              ErrorReport er = new ErrorReport();
             *              er.fileName = fileName;
             *              er.bslyr.fileName = fileName;
             *              er.bslyr.DAL = bslyr.DAL;
             *              outputFileName = er.PrintErrorReport(errList);
             *              string outputMessage = "ERRORS FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
             *              MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *              //  request made to open error report in preview -- May 2015
             *              PrintPreview pp = new PrintPreview();
             *              pp.fileName = outputFileName;
             *              pp.setupDialog();
             *              pp.ShowDialog();
             *              Environment.Exit(0);
             *          }   //  endif report needed
             * moved to EditCheck routine*/
            //  Show editCheck message -- edit checks complete

            EditChecks eChecks = new EditChecks();

            eChecks.fileName = fileName;
            eChecks.DAL      = DAL;

            int err = eChecks.CheckErrors();

            if (err < 0)
            {
                Close();
                return;
            }

            editCheck.Enabled = true;

            //  next show preparation of data
            processingStatus.Text = "Preparing data for processing.";
            processingStatus.Refresh();

            //  before making IDs, need to check for blank or null secondary products in sample groups
            //  if blank, default to 02 for every region but 6 where it will be 08 instead
            //  put a warning message in the error log table indicating the secondary product was set to a default
            //  June 2013
            List <SaleDO> saleList = new List <SaleDO>();

            saleList = DAL.From <SaleDO>().Read().ToList();
            string currRegion = saleList[0].Region;

            //string currRegion = bslyr.getRegion();

            DefaultSecondaryProduct(currRegion);

            CalculateTreeValues calcTreeVal = new CalculateTreeValues();
            CalculatedValues    calcVal     = new CalculatedValues();


            //  retrieve lists needed and sets up population IDs
            calcVal.fileName = fileName;
            calcVal.DAL      = DAL;
            //   List<SampleGroupDO> sgList = bslyr.getSampleGroups();
            //   List<TreeDefaultValueDO> tdvList = bslyr.getTreeDefaults();
            //   List<CountTreeDO> ctList = bslyr.getCountTrees();
            //   List<PlotDO> pList = bslyr.getPlots();

            //   calcVal.ClearCalculatedTables();
            //   calcVal.MakePopulationIDs(sgList, tdvList);

            calcVal.CalcValues();

            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL = DAL;
            //  now need some other tables to start summing values
            List <LCDDO>              lcdList = bslyr.getLCD();
            List <POPDO>              popList = bslyr.getPOP();
            List <PRODO>              proList = bslyr.getPRO();
            List <StratumDO>          sList   = bslyr.getStratum();
            List <SampleGroupDO>      sgList  = bslyr.getSampleGroups();
            List <TreeDefaultValueDO> tdvList = bslyr.getTreeDefaults();
            List <CountTreeDO>        ctList  = bslyr.getCountTrees();
            List <PlotDO>             pList   = bslyr.getPlots();
            List <TreeDO>             tList   = bslyr.getTrees();

            calcTreeVal.fileName       = fileName;
            calcTreeVal.bslyr.fileName = fileName;
            calcTreeVal.bslyr.DAL      = bslyr.DAL;

            //  show preparation of data is complete
            prepareCheck.Enabled = true;
            //  now loop through strata and show status message updating for each stratum
            StringBuilder sb = new StringBuilder();

            foreach (StratumDO sdo in sList)
            {
                //  update status message for next stratum
                sb.Clear();
                sb.Append("Calculating stratum ");
                sb.Append(sdo.Code);
                processingStatus.Text = sb.ToString();
                processingStatus.Refresh();

                //  Sum counts and KPI for LCD table
                List <PlotDO> justPlots = PlotMethods.GetStrata(pList, sdo.Code);
                //  need cut and leave trees for this
                List <LCDDO> justCurrentLCD = LCDmethods.GetStratum(lcdList, sdo.Code);
                calcVal.SumTreeCountsLCD(sdo.Code, ctList, justPlots, justCurrentLCD, sdo.Method, lcdList);

                //  Sum counts and KPI for POP table
                List <POPDO> justCurrentPOP = POPmethods.GetStratumData(popList, sdo.Code, "");
                calcVal.SumTreeCountsPOP(sdo.Code, ctList, justPlots, justCurrentPOP, sdo.Method, popList);

                //  Sum counts and KPI for PRO table
                List <PRODO> justCurrentPRO = PROmethods.GetCutTrees(proList, sdo.Code, "", "", 0);
                calcVal.SumTreeCountsPRO(sdo.Code, ctList, justPlots, justCurrentPRO, sdo.Method, proList);

                //  Calculate expansion factor
                calcVal.CalcExpFac(sdo, justPlots, justCurrentPOP);

                //  Calculate volumes
                calcTreeVal.ProcessTrees(sdo.Code, sdo.Method, (long)sdo.Stratum_CN);

                //  Update 3P tally
                if (sdo.Method == "3P")
                {
                    List <LCDDO> LCDstratum = LCDmethods.GetStratumGroupedBy(fileName, sdo.Code, bslyr);

                    Update3Ptally(fileName, ctList, justCurrentLCD, tList, LCDstratum);
                    //  Save
                    bslyr.SaveLCD(justCurrentLCD);
                }   //  endif method is 3P


                //  Update expansion factors for methods 3PPNT, F3P, and P3P
                if (sdo.Method == "3PPNT" || sdo.Method == "F3P" || sdo.Method == "P3P")
                {
                    List <TreeDO> justCurrentStratum = tList.FindAll(
                        delegate(TreeDO td)
                    {
                        return(td.Stratum.Code == sdo.Code);
                    });
                    List <TreeCalculatedValuesDO> tcvList = bslyr.getTreeCalculatedValues((int)sdo.Stratum_CN);
                    UpdateExpansionFactors(justCurrentStratum, tcvList);
                    //  Save update
                    bslyr.SaveTrees(justCurrentStratum);
                }   //  endif on method

                //  Sum data for the LCD, POP and PRO table
                SumAll Sml = new SumAll();
                Sml.fileName       = fileName;
                Sml.bslyr.fileName = bslyr.fileName;
                Sml.bslyr.DAL      = bslyr.DAL;
                Sml.SumAllValues(sdo.Code, sdo.Method, (int)sdo.Stratum_CN, sList, pList, justCurrentLCD,
                                 justCurrentPOP, justCurrentPRO);

                //  Update STR tally after expansion factors are summed
                if (sdo.Method == "STR")
                {
                    UpdateSTRtally(fileName, sdo.Code, justCurrentLCD, ctList, lcdList);
                    //  save
                    bslyr.SaveLCD(lcdList);
                } //  endif method is STR
            }     //  end foreach stratum

            //  show volume calculation is finished
            volumeCheck.Enabled   = true;
            processingStatus.Text = "Processing is DONE";
            processingStatus.Refresh();
            System.Threading.Thread.Sleep(5000);
            Cursor.Current = this.Cursor;

            Close();
            return;
        }   //  end on_GO
        public int TableEditChecks()
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            elm.fileName   = fileName;
            string currentRegion = bslyr.getRegion();
            string isVLL         = "";
            //string isVLL = bslyr.getVLL();

            //  edit checks for each table
            //  sale table
            List <SaleDO> saleList = bslyr.getSale();

            //  empty or more than one record?
            errorValue = SaleMethods.MoreThanOne(saleList);
            if (errorValue == 0)
            {
                elm.LoadError("Sale", "E", "25", errorValue, "NoName");           //  error 25 -- table cannot be empty
            }
            else if (errorValue > 1)
            {
                elm.LoadError("Sale", "E", "28", errorValue, "SaleNumber");           //  error 28 -- more than one sale record not allowed
            }
            if (errorValue == 1)
            {
                //  and blank sale number
                errorValue = SaleMethods.BlankSaleNum(saleList);
                if (errorValue != -1)
                {
                    elm.LoadError("Sale", "E", " 8Sale Number", errorValue, "SaleNumber");
                }
            }       //  endif
            //  end sale table edit checks

            // *******************************************************************
            //  stratum table
            List <StratumDO> strList = bslyr.getStratum();

            errorValue = StratumMethods.IsEmpty(strList);
            if (errorValue != 0)
            {
                elm.LoadError("Stratum", "E", errorValue.ToString(), errorValue, "NoName");
            }
            else if (errorValue == 0)        //  means there are records to check
            {
                foreach (StratumDO sdo in strList)
                {
                    //  check for valid fixed plot size or BAF for each stratum
                    double BAForFPS = StratumMethods.CheckMethod(strList, sdo.Code);
                    if ((sdo.Method == "PNT" || sdo.Method == "P3P" || sdo.Method == "PCM" ||
                         sdo.Method == "PCMTRE" || sdo.Method == "3PPNT") && BAForFPS == 0)
                    {
                        elm.LoadError("Stratum", "E", "22", (long)sdo.Stratum_CN, "BasalAreaFactor");
                    }
                    else if ((sdo.Method == "FIX" || sdo.Method == "F3P" || sdo.Method == "FIXCNT" ||
                              sdo.Method == "FCM") && BAForFPS == 0)
                    {
                        elm.LoadError("Stratum", "E", "23", (long)sdo.Stratum_CN, "FixedPlotSize");
                    }

                    //  check for acres on area based methods
                    double currAcres = Utilities.AcresLookup((long)sdo.Stratum_CN, bslyr, sdo.Code);
                    if ((sdo.Method == "PNT" || sdo.Method == "FIX" || sdo.Method == "P3P" ||
                         sdo.Method == "F3P" || sdo.Method == "PCM" || sdo.Method == "3PPNT" ||
                         sdo.Method == "FCM" || sdo.Method == "PCMTRE") && currAcres == 0)
                    {
                        elm.LoadError("Stratum", "E", "24", (long)sdo.Stratum_CN, "NoName");
                    }
                    else if ((sdo.Method == "100" || sdo.Method == "3P" ||
                              sdo.Method == "S3P" || sdo.Method == "STR") && currAcres == 0)
                    {
                        elm.LoadError("Stratum", "W", "Stratum has no acres", (long)sdo.Stratum_CN, "NoName");
                    }

                    //  August 2017 -- added check for valid yield component code
                    if (sdo.YieldComponent != "CL" && sdo.YieldComponent != "CD" &&
                        sdo.YieldComponent != "ND" && sdo.YieldComponent != "NL" &&
                        sdo.YieldComponent != "" && sdo.YieldComponent != " " &&
                        sdo.YieldComponent != null)
                    {
                        elm.LoadError("Stratum", "W", "Yield Component has invalid code", (long)sdo.Stratum_CN, "YieldComponent");
                    }
                }   //  end foreach loop
            }       //  endif
            //  end stratum table edit checks

            //  ************************************************************************
            // cutting unit table
            List <CuttingUnitDO> cuList = bslyr.getCuttingUnits();

            errorValue = CuttingUnitMethods.IsEmpty(cuList);
            if (errorValue != 0)
            {
                elm.LoadError("Cutting Unit", "E", errorValue.ToString(), 0, "NoName");
            }
            //  end cutting unit edit checks

            //  **************************************************************************
            //  count table
            List <CountTreeDO> cntList = bslyr.getCountTrees();

            foreach (StratumDO sl in strList)
            {
                errorValue = CountTreeMethods.check3Pcounts(cntList, bslyr, sl);
                if (errorValue != 0)
                {
                    elm.LoadError("CountTree", "E", "Cannot tally by sample group for 3P strata.", (long)sl.Stratum_CN, "TreeDefaultValue");
                }
            }       //  end foreach on stratum

            //  **************************************************************************
            //  tree table
            List <TreeDO> tList = bslyr.getTrees();

            errorValue = Tlm.IsEmpty(tList);
            if (errorValue != 0)
            {
                elm.LoadError("Tree", "E", errorValue.ToString(), 0, "NoName");
            }
            else if (errorValue == 0)           //  means tree table has records
            {
                //  make sure single stratum is NOT FIXCNT which cannot have measured trees anyway.
                //if(strList.Count == 1 && strList[0].Method != "FIXCNT")
                //  doesn't matter if it's a single stratum or any stratum that's FIXCNT
                //  that method still has no measured trees so need to skip these checks.
                if (strList[0].Method != "FIXCNT")
                {
                    tList = bslyr.JustMeasuredTrees();
                    //  March 2016 -- if the entire cruisde has no measured trees, that uis a critical erro
                    //  and should stop the program.  Since no report can be generated, a message box appears to warn the user
                    //  of the condition.
                    if (tList.Count == 0)
                    {
                        MessageBox.Show("NO MEASURED TREES IN THIS CRUISE.\nCannot continue and cannot produce any reports.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return(-1);
                    }       //endif
                    //  general checks include  checking for secondary top DIB greater than primary
                    //  recoverable percent greater than seen defect primary
                    //  missing species, product or uom when tree count is greater than zero or DBH is greater than zero
                    //  and check for upper stem diameter greater than DBH
                    errorValue = Tlm.GeneralChecks(tList, currentRegion);
                }   //  endif single stratum
            }       //  endif
            //  end tree table edit checks

            //  *************************************************************************
            //  log table
            List <LogDO> logList = bslyr.getLogs();

            if (logList.Count > 0)
            {
                errorValue = Lms.CheckNumberLogs(logList);
                errorValue = Lms.CheckFBS(logList);
                if (isVLL == "true")
                {
                    errorValue = Lms.CheckVLL(logList);
                }
                errorValue = Lms.CheckDefect(logList);
                if (currentRegion != "05")
                {
                    errorValue = Lms.CheckLogGrade(logList);
                }
            }       //  endif records in log table to check
            //  end log table edit checks

            //  *************************************************************************
            //  volume equation table
            List <VolumeEquationDO> volList = bslyr.getVolumeEquations();

            Veq.DAL    = DAL;
            errorValue = Veq.IsEmpty(volList);
            //  pull region
            string currRegion = bslyr.getRegion();

            if (errorValue != 0)
            {
                elm.LoadError("VolumeEquation", "E", errorValue.ToString(), 0, "NoName");
            }
            else if (errorValue == 0)        //  means the table is not empty and checks can proceed
            {
                //  Match unique species/product to volume equation
                errorValue = Veq.MatchSpeciesProduct(volList, tList);
                errorValue = Veq.GeneralEquationChecks(volList);
                //  if VLL, check equations for Behrs
                if (isVLL == "true")
                {
                    errorValue = Veq.FindBehrs(volList);
                }
            }       //  endif
                    //  end volume equation edit checks

            //  *************************************************************************
            //  value equations
            // Check for valid equations
            ValueEqMethods         Vem     = new ValueEqMethods();
            List <ValueEquationDO> valList = bslyr.getValueEquations();

            if (valList.Count > 0)          //  there are records to check
            {
                errorValue = Vem.CheckEquations(valList, currentRegion);
            }
            //  end value equation edit checks

            //  *************************************************************************
            //  quality adjustment equations
            QualityAdjMethods           Qam     = new QualityAdjMethods();
            List <QualityAdjEquationDO> qaeList = bslyr.getQualAdjEquations();

            if (qaeList.Count > 0)          //  there are records to check
            {
                errorValue = Qam.CheckEquations(qaeList);
            }
            //  end quality adjustment equation edit checks

            //  ************************************************************************
            //  June 2014 -- apparently the error log table is not meant to capture
            //  errors on the basis of an entire table.  Only on individual records.
            //  so if no reports have been selected, this check needs to move to
            //  the Output section when the user clicks GO.  If the reports list
            //  comes up empty then display a message box telling them to go back
            //  and enter reports.
            //  no reports selected

            /*
             *              List<ReportsDO> selectedReports = bslyr.GetSelectedReports();
             *              if (selectedReports.Count == 0)
             *              {
             *                  elm.LoadError("Reports", "E", "26", 0,"NoName");
             *                  errorValue++;
             *              }   //  endif no reports
             */
            //  ************************************************************************
            //  sample group table
            SampleGroupMethods   Sgm        = new SampleGroupMethods();
            List <SampleGroupDO> sampGroups = bslyr.getSampleGroups();

            errorValue = Sgm.CheckAllUOMandCutLeave(strList, sampGroups, fileName);
            //  ************************************************************************
            errList = elm.errList;
            if (errList.Count > 0)
            {
                bslyr.fileName = fileName;
                bslyr.SaveErrorMessages(errList);
            }   //  endif
            return(errorValue);
        }       //  end TableEditChecks
Exemple #28
0
        }   //  end SumTreeCountsPRO

        public void CalcExpFac(StratumDO sdo, List <PlotDO> justPlots, List <POPDO> justCurrentPOP)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  Calculates expansion factor, tree factor and point factor for each tree in the current population
            double EF = 0.0;        //  expansion factor
            double TF = 0.0;        //  tree factor
            double PF = 0.0;        //  point factor

            //  Need total number of plots and measured plots (3PPNT only)
            double totalPlots     = justPlots.Count();
            double totalMeasPlots = 0.0;

            //  process by population
            foreach (POPDO pdo in justCurrentPOP)
            {
                //  pull trees for population
                List <TreeDO> justTrees = new List <TreeDO>();
                if (sdo.Method == "FIXCNT")
                {
                    justTrees = bslyr.getPOPtrees(pdo, "C");
                }
                else
                {
                    justTrees = bslyr.getPOPtrees(pdo, "M");
                }

                //  3PPNT uses measured plots
                if (sdo.Method == "3PPNT")
                {
                    foreach (PlotDO p in justPlots)
                    {
                        int nthRow = justTrees.FindIndex(
                            delegate(TreeDO td)
                        {
                            return(td.Plot_CN == p.Plot_CN && td.Stratum_CN == p.Stratum_CN);
                        });
                        if (nthRow >= 0)
                        {
                            totalMeasPlots++;
                        }
                    } //  end foreach loop
                }     //  endif Method is 3PPNT

                //  calculate factors on each tree
                foreach (TreeDO tdo in justTrees)
                {
                    //  Calculate point factor for P3P S3P F3P PCM FCM and 3PPNT
                    switch (sdo.Method)
                    {
                    case "P3P":
                    case "S3P":
                    case "F3P":
                        PF = CommonEquations.Frequency3P(pdo.SumKPI, tdo.KPI, pdo.MeasuredTrees);
                        break;

                    case "PCM":
                    case "PCMTRE":
                        PF = CommonEquations.CalcTreeFactor(pdo.FirstStageTrees, pdo.MeasuredTrees, 0.0, 1, 2);
                        break;

                    case "FCM":
                        PF = CommonEquations.CalcTreeFactor(0.0, pdo.MeasuredTrees, pdo.TalliedTrees, 3, 2);
                        break;

                    case "3PPNT":
                        //  uses plot KPI
                        PlotDO plotKPI = justPlots.Find(
                            delegate(PlotDO p)
                        {
                            return(p.Plot_CN == tdo.Plot_CN);
                        });
                        PF = CommonEquations.Frequency3P(pdo.SumKPI, plotKPI.KPI, totalMeasPlots);
                        break;
                    }   //  end switch on method to calculate point factor

                    //  Calculate tree factor for FIXCNT FIX F3P FCM PNT P3P PCM 3PPNT and S3P
                    switch (sdo.Method)
                    {
                    case "FIXCNT":
                    case "FIX":
                    case "F3P":
                        TF = sdo.FixedPlotSize;
                        break;

                    case "FCM":
                        if (totalPlots > 0)
                        {
                            TF = sdo.FixedPlotSize / totalPlots;
                        }
                        break;

                    case "PNT":
                    case "P3P":
                    case "PCM":
                    case "PCMTRE":
                    case "3PPNT":
                        if (tdo.DBH > 0)
                        {
                            TF = CommonEquations.PointSampleFrequency(sdo.BasalAreaFactor, tdo.DBH);
                        }
                        else if (tdo.DRC > 0)
                        {
                            TF = CommonEquations.PointSampleFrequency(sdo.BasalAreaFactor, tdo.DRC);
                        }
                        break;

                    case "S3P":
                        TF = CommonEquations.CalcTreeFactor(pdo.FirstStageTrees, 0.0, pdo.TalliedTrees, 3, 1);
                        break;
                    }   //  end switch on method to calculate tree factor

                    //  Calculate expansion factor
                    switch (sdo.Method)
                    {
                    case "100":
                        EF = 1.0;
                        break;

                    case "FIXCNT":
                        if (totalPlots > 0)
                        {
                            EF = (sdo.FixedPlotSize / totalPlots) * tdo.TreeCount;
                        }
                        break;

                    case "FIX":
                        if (totalPlots > 0)
                        {
                            EF = sdo.FixedPlotSize / totalPlots;
                        }
                        break;

                    case "PNT":
                        if (totalPlots > 0)
                        {
                            EF = TF / totalPlots;
                        }
                        break;

                    case "STR":
                        EF = CommonEquations.CalcTreeFactor(0.0, pdo.MeasuredTrees, pdo.TalliedTrees, 3, 2);
                        break;

                    case "P3P":
                    case "F3P":
                    case "PCM":
                    case "PCMTRE":
                    case "3PPNT":
                        if (totalPlots > 0)
                        {
                            EF = (TF * PF) / totalPlots;
                        }
                        break;

                    case "FCM":
                    case "S3P":
                        EF = TF * PF;
                        break;

                    case "3P":
                        EF = CommonEquations.Frequency3P(pdo.SumKPI, tdo.KPI, pdo.MeasuredTrees);
                        break;
                    }   //  end switch on method to calculate expansion factor
                    if (tdo.STM == "Y")
                    {
                        EF = 1.0;
                    }

                    //  round just the expansion factor
                    EF = CommonEquations.RoundExpansionFactor(EF);
                    //  store factors
                    tdo.ExpansionFactor = (float)EF;
                    tdo.TreeFactor      = (float)TF;
                    tdo.PointFactor     = (float)PF;
                }   //  end foreach loop on justTrees
                //  save this bunch of trees
                bslyr.SaveTrees(justTrees);
            }   //  end foreach loop on justCurrentPOP

            return;
        } //  end CalcExpFac
        public int CheckErrors()
        {
            string          outputFileName;
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  check for errors from FScruiser before running edit checks
            //  generate an error report
            //  June 2013
            List <ErrorLogDO> fscList = bslyr.getErrorMessages("E", "FScruiser");

            if (fscList.Count > 0)
            {
                ErrorReport eRpt = new ErrorReport();
                eRpt.fileName       = fileName;
                eRpt.bslyr.fileName = bslyr.fileName;
                eRpt.bslyr.DAL      = DAL;
                outputFileName      = eRpt.PrintFScruiserErrors(fscList);
                string outputMessage = "ERRORS FROM FSCRUISER FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015


                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed

            //  clear out error log table for just CruiseProcessing before performing checks
            bslyr.DeleteErrorMessages();


            int errors = TableEditChecks();

            if (errors == -1)
            {
                //  no measured trees detected in the cruise.  critical errpor stops the program.
                return(-1);
            }   //  endif
            errors = MethodChecks();
            if (errors == -1)
            {
                //  empty stratum detected and user wants to quit
                return(-1);
            }   //  endif
            //  just check the ErrorLog table for entries
            List <ErrorLogDO> errList = bslyr.getErrorMessages("E", "CruiseProcessing");

            if (errList.Count > 0)
            {
                ErrorReport er = new ErrorReport();
                er.fileName       = fileName;
                er.bslyr.fileName = fileName;
                er.bslyr.DAL      = bslyr.DAL;
                outputFileName    = er.PrintErrorReport(errList);
                string outputMessage = "ERRORS FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015
                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed
            return(0);
        }
Exemple #30
0
        }   //  end ClearCalculatedTables

        public void MakePopulationIDs(List <SampleGroupDO> sgList, List <TreeDefaultValueDO> tdvList)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  Load ID info into tables
            List <LCDDO>  lcdList = new List <LCDDO>();
            List <POPDO>  popList = new List <POPDO>();
            List <PRODO>  proList = new List <PRODO>();
            List <TreeDO> tList   = bslyr.getTrees();

            //  need to check Contract Species in TDV table before doing unique
            //  reset to a blank if it is null -- September 2016
            List <TreeDefaultValueDO> treeDefaults = bslyr.getTreeDefaults();

            foreach (TreeDefaultValueDO tdv in treeDefaults)
            {
                if (tdv.ContractSpecies == null)
                {
                    tdv.ContractSpecies = " ";
                }
                else if (tdv.ContractSpecies == "")
                {
                    tdv.ContractSpecies = " ";
                }
            }   //  end foreach
            bslyr.SaveTreeDefaults(treeDefaults);

            foreach (SampleGroupDO sgd in sgList)
            {
                //  Load LCD population IDs
                //  Need unique species, livedead and grade from Tree table
                // not sure about the count table -- need IDs from there?  11/2012
                List <TreeDO> distinctSpecies = bslyr.GetDistinctSpecies((long)sgd.SampleGroup_CN);
                foreach (TreeDO t in distinctSpecies)
                {
                    LCDDO lcd = new LCDDO();
                    lcd.CutLeave         = sgd.CutLeave;
                    lcd.Stratum          = sgd.Stratum.Code;
                    lcd.SampleGroup      = sgd.Code;
                    lcd.PrimaryProduct   = sgd.PrimaryProduct;
                    lcd.SecondaryProduct = sgd.SecondaryProduct;
                    lcd.UOM      = sgd.UOM;
                    lcd.Species  = t.Species;
                    lcd.LiveDead = t.LiveDead;
                    if (t.Grade == null)
                    {
                        lcd.TreeGrade = "";
                    }
                    else
                    {
                        lcd.TreeGrade = t.Grade;
                    }
                    lcd.STM = t.STM;
                    //  per K.Cormier, because a null value in contract species causes
                    //  causes problems, it is being dropped from the population ID for LCD
                    //  Howeverm it will be stored as null but not used as part of the ID
                    //  September 2016
                    //  Found a slicker way to address this -- default contract species to a blank
                    //  however, this would be in the TreeDefaultValue table and only affects
                    //  new cruises.  CP still needs to set CS in TDV to blank (see above).
                    lcd.ContractSpecies = t.TreeDefaultValue.ContractSpecies;
                    //if (t.TreeDefaultValue.ContractSpecies != null)
                    //    lcd.ContractSpecies = t.TreeDefaultValue.ContractSpecies;
                    //else lcd.ContractSpecies = "";
                    if (t.Stratum.YieldComponent != null)
                    {
                        lcd.Yield = t.Stratum.YieldComponent;
                    }
                    else
                    {
                        lcd.Yield = "";
                    }
                    //}   //  endif nthRow

                    lcdList.Add(lcd);
                }   //  end foreach loop on species

                //  Load POP population IDs
                POPDO pop = new POPDO();
                //  Don't need unique species for this group
                pop.CutLeave         = sgd.CutLeave;
                pop.Stratum          = sgd.Stratum.Code;
                pop.SampleGroup      = sgd.Code;
                pop.PrimaryProduct   = sgd.PrimaryProduct;
                pop.SecondaryProduct = sgd.SecondaryProduct;
                pop.UOM = sgd.UOM;
                //  check for sure-to-measure trees for this group
                //  Add non-sure-to-measure first  and then STM
                pop.STM = "N";
                popList.Add(pop);
                List <TreeDO> justSTM = tList.FindAll(
                    delegate(TreeDO td)
                {
                    return(sgd.CutLeave == td.SampleGroup.CutLeave && sgd.Stratum.Code == td.Stratum.Code &&
                           sgd.Code == td.SampleGroup.Code && sgd.PrimaryProduct == td.SampleGroup.PrimaryProduct &&
                           sgd.SecondaryProduct == td.SampleGroup.SecondaryProduct && sgd.UOM == td.SampleGroup.UOM &&
                           td.STM == "Y");
                });
                if (justSTM.Count > 0)
                {
                    POPDO popSTM = new POPDO();
                    popSTM.CutLeave         = sgd.CutLeave;
                    popSTM.Stratum          = sgd.Stratum.Code;
                    popSTM.SampleGroup      = sgd.Code;
                    popSTM.PrimaryProduct   = sgd.PrimaryProduct;
                    popSTM.SecondaryProduct = sgd.SecondaryProduct;
                    popSTM.UOM = sgd.UOM;
                    popSTM.STM = "Y";
                    popList.Add(popSTM);
                }   //  endif

                //  Load PRO population IDs
                //  These need cutting unit numbers -- from Cutting Unit
                List <CuttingUnitStratumDO> strataUnits = bslyr.getCuttingUnitStratum((long)sgd.Stratum_CN);
                foreach (CuttingUnitStratumDO cudo in strataUnits)
                {
                    PRODO pro = new PRODO();
                    pro.CutLeave         = sgd.CutLeave;
                    pro.Stratum          = sgd.Stratum.Code;
                    pro.CuttingUnit      = cudo.CuttingUnit.Code;
                    pro.SampleGroup      = sgd.Code;
                    pro.PrimaryProduct   = sgd.PrimaryProduct;
                    pro.SecondaryProduct = sgd.SecondaryProduct;
                    pro.UOM = sgd.UOM;
                    //  check for sure-to-measure trees for this group
                    //  Add non-sure-to-measure first  and then STM
                    pro.STM = "N";
                    proList.Add(pro);
                    justSTM = tList.FindAll(
                        delegate(TreeDO td)
                    {
                        return(sgd.CutLeave == td.SampleGroup.CutLeave && sgd.Stratum.Code == td.Stratum.Code &&
                               cudo.CuttingUnit.Code == td.CuttingUnit.Code &&
                               sgd.Code == td.SampleGroup.Code && sgd.PrimaryProduct == td.SampleGroup.PrimaryProduct &&
                               sgd.SecondaryProduct == td.SampleGroup.SecondaryProduct && sgd.UOM == td.SampleGroup.UOM &&
                               td.STM == "Y");
                    });
                    if (justSTM.Count > 0)
                    {
                        PRODO proSTM = new PRODO();
                        proSTM.CutLeave         = sgd.CutLeave;
                        proSTM.Stratum          = sgd.Stratum.Code;
                        proSTM.CuttingUnit      = cudo.CuttingUnit.Code;
                        proSTM.SampleGroup      = sgd.Code;
                        proSTM.PrimaryProduct   = sgd.PrimaryProduct;
                        proSTM.SecondaryProduct = sgd.SecondaryProduct;
                        proSTM.UOM = sgd.UOM;
                        proSTM.STM = "Y";
                        proList.Add(proSTM);
                    } //  endif
                }     //  end foreach loop on strataUnits
            }         //  end foreach loop on SampleGroup
            bslyr.SaveLCD(lcdList);
            bslyr.SavePOP(popList);
            bslyr.SavePRO(proList);

            return;
        }   //  end MakePopulationIDs