}   //  end onRegionSelected

        private void fillForests(string selectedRegion)
        {
            VolumeEqMethods Veq = new VolumeEqMethods();

            volList = Veq.GetRegionVolumes(selectedRegion);
            //  find unique forests to generate list
            string currentForest = "";

            for (int k = 0; k < volList.Count; k++)
            {
                //  first forest
                if (k == 0)
                {
                    currentForest = volList[k].vForest;
                    volForest.Items.Add(currentForest);
                }
                else if (currentForest != volList[k].vForest)
                {
                    //  add to list and store
                    currentForest = volList[k].vForest;
                    volForest.Items.Add(currentForest);
                } //  endif
            }     //  end for k loop

            volForest.Enabled = true;
            return;
        }   //  end fillForests
Exemplo n.º 2
0
        }       //  end WriteSampleGroup

        private void WriteMerchRules(StreamWriter strWriteOut, reportHeaders rh, IEnumerable <VolumeEquationDO> currEQ, ref int pageNum)
        {
            //  output merch rules
            foreach (VolumeEquationDO ce in currEQ)
            {
                WriteReportHeading(strWriteOut, rh.reportTitles[0], rh.reportTitles[1],
                                   rh.reportTitles[2], rh.A15columns, 11, ref pageNum, "");
                prtFields.Clear();
                prtFields = VolumeEqMethods.buildMerchArray(ce);
                printOneRecord(fieldLengths, prtFields, strWriteOut);
            }       //  end foreach

            //  output footer
            strWriteOut.WriteLine("\n\n");
            strWriteOut.WriteLine(" SEGMENT DESCRIPTIONS");
            strWriteOut.WriteLine("			21 -- If top seg < 1/2 nom log len, combine with next lowest log");
            strWriteOut.WriteLine("			22 -- Top placed with next lowest log and segmented");
            strWriteOut.WriteLine("			23 -- Top segment stands on its own");
            strWriteOut.WriteLine("			24 -- If top seg < 1/4 log len drop the top.  If top >= 1/4 and <= 3/4 nom length, ");
            strWriteOut.WriteLine("						top is 1/2 of nom log lenght, else top is nom log len.");
            return;
        }       //  end WriteMerchRules
Exemplo n.º 3
0
        public int TableEditChecks(IEnumerable <SaleDO> saleList, IEnumerable <StratumDO> strList,
                                   IEnumerable <CountTreeDO> cntList, IEnumerable <TreeDO> tList, IEnumerable <SampleGroupDO> sgList)
        {
            ErrorLogMethods.fileName = fileName;
            string currentRegion = Global.BL.getRegion();
            string isVLL         = "";

            //string isVLL = Global.BL.getVLL();

            //  edit checks for each table
            //  sale table
            //  empty or more than one record?
            errorValue = SaleMethods.MoreThanOne(saleList);
            if (errorValue == 0)
            {
                ErrorLogMethods.LoadError("Sale", "E", "25", errorValue, "NoName");           //  error 25 -- table cannot be empty
            }
            else if (errorValue > 1)
            {
                ErrorLogMethods.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)
                {
                    ErrorLogMethods.LoadError("Sale", "E", " 8Sale Number", errorValue, "SaleNumber");
                }
            }       //  endif
            //  end sale table edit checks

            // *******************************************************************
            //  stratum table
//                List<StratumDO> strList = Global.BL.getStratum();
            errorValue = StratumMethods.IsEmpty(strList);
            if (errorValue != 0)
            {
                ErrorLogMethods.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)
                    {
                        ErrorLogMethods.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)
                    {
                        ErrorLogMethods.LoadError("Stratum", "E", "23", (long)sdo.Stratum_CN, "FixedPlotSize");
                    }

                    //  check for acres on area based methods
                    double currAcres = Utilities.AcresLookup((long)sdo.Stratum_CN, 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)
                    {
                        ErrorLogMethods.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)
                    {
                        ErrorLogMethods.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)
                    {
                        ErrorLogMethods.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 = Global.BL.getCuttingUnits();
            errorValue = CuttingUnitMethods.IsEmpty(Global.BL.getCuttingUnits());
            if (errorValue != 0)
            {
                ErrorLogMethods.LoadError("Cutting Unit", "E", errorValue.ToString(), 0, "NoName");
            }
            //  end cutting unit edit checks

            //  **************************************************************************
            //  count table
            //List<CountTreeDO> cntList = Global.BL.getCountTrees();
            foreach (StratumDO sl in strList)
            {
                errorValue = CountTreeMethods.check3Pcounts(cntList, sl);
                if (errorValue != 0)
                {
                    ErrorLogMethods.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 = Global.BL.getTrees();
            errorValue = TreeListMethods.IsEmpty(tList);
            if (errorValue != 0)
            {
                ErrorLogMethods.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.First().Method != "FIXCNT")
                {
                    var tMeas = tList.Select(tree => tree.CountOrMeasure = "M");
                    //tList = Global.BL.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 (tMeas.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 = TreeListMethods.GeneralChecks(tList, currentRegion);
                }   //  endif single stratum
            }       //  endif
            //  end tree table edit checks

            //  *************************************************************************
            //  log table
            List <LogDO> logList = Global.BL.getLogs().ToList();

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

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

            errorValue = VolumeEqMethods.IsEmpty(volList);
            //  pull region
            string currRegion = saleList.First().Region;

            //string currRegion =  Global.BL.getRegion();
            if (errorValue != 0)
            {
                ErrorLogMethods.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 = VolumeEqMethods.MatchSpeciesProduct(volList, tList);
                errorValue = VolumeEqMethods.GeneralEquationChecks(volList);
                //  if VLL, check equations for Behrs
                if (isVLL == "true")
                {
                    errorValue = VolumeEqMethods.FindBehrs(volList);
                }
            }       //  endif
            //  end volume equation edit checks

            //  *************************************************************************
            //  value equations
            // Check for valid equations
            IEnumerable <ValueEquationDO> valList = Global.BL.getValueEquations();

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

            //  *************************************************************************
            //  quality adjustment equations
            IEnumerable <QualityAdjEquationDO> qaeList = Global.BL.getQualAdjEquations();

            if (qaeList.Any())          //  there are records to check
            {
                errorValue = QualityAdjMethods.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 = Global.BL.GetSelectedReports();
 *              if (selectedReports.Count == 0)
 *              {
 *                  ErrorLogMethods.LoadError("Reports", "E", "26", 0,"NoName");
 *                  errorValue++;
 *              }   //  endif no reports
 */
            //  ************************************************************************
            //  sample group table
            //List<SampleGroupDO> sampGroups = Global.BL.getSampleGroups();
            errorValue = SampleGroupMethods.CheckAllUOMandCutLeave(strList, sgList, fileName);
            //  ************************************************************************
            errList = ErrorLogMethods.errList;
            if (errList.Count > 0)
            {
                Global.BL.SaveErrorMessages(errList);
            }   //  endif
            return(errorValue);
        }       //  end TableEditChecks
Exemplo n.º 4
0
        public void outputEquationTable(StreamWriter strWriteOut, reportHeaders rh, ref int pageNumb)
        {
            //  Define table lists
            //List<VolumeEquationDO> veqList = new List<VolumeEquationDO>();
            //List<ValueEquationDO> valList = new List<ValueEquationDO>();
            //List<BiomassEquationDO> bioList = new List<BiomassEquationDO>();
            //List<QualityAdjEquationDO> qualList = new List<QualityAdjEquationDO>();

            string currRegion = Global.BL.getRegion();

            if (currRegion != "7" && currRegion != "07")
            {
                //  Volume equation table
                //veqList = Global.BL.getVolumeEquations();
                if (Global.BL.getVolumeEquations().Any())
                {
                    WriteReportHeading(strWriteOut, "VOLUME EQUATION TABLE", "", "", rh.VolEqHeaders, 12, ref pageNumb, "");

                    int[] fieldLengths = new int[15] {
                        5, 10, 6, 14, 11, 10, 6, 6, 6, 14, 6, 6, 6, 9, 7
                    };
                    ArrayList prtFields = new ArrayList();
                    foreach (VolumeEquationDO vel in Global.BL.getVolumeEquations())
                    {
                        //  build an array of fields to pass into creating a data table for printing
                        prtFields = VolumeEqMethods.buildPrintArray(vel);
                        StringBuilder oneRecord = buildPrintLine(fieldLengths, prtFields);
                        strWriteOut.WriteLine(oneRecord.ToString());
                        numOlines++;
                    } //  end foreach loop
                }     //  endif volume equations exist

                //  Value equations
                //valList = Global.BL.getValueEquations();
                if (Global.BL.getValueEquations().Any())
                {
                    numOlines = 0;
                    WriteReportHeading(strWriteOut, "VALUE EQUATION TABLE", "", "", rh.ValEqHeaders, 9, ref pageNumb, "");

                    int[] fieldLengths = new int[11] {
                        1, 10, 8, 5, 12, 16, 16, 16, 16, 16, 12
                    };
                    ArrayList prtFields = new ArrayList();
                    foreach (ValueEquationDO val in Global.BL.getValueEquations())
                    {
                        // build array first of fields to pass for creating data table
                        prtFields = ValueEqMethods.buildPrintArray(val);
                        StringBuilder oneRecord = buildPrintLine(fieldLengths, prtFields);
                        strWriteOut.WriteLine(oneRecord.ToString());
                        numOlines++;
                    } //  end foreach loop
                }     //  endif value equations exist

                //  Biomass equations
                //bioList = Global.BL.getBiomassEquations();
                if (Global.BL.getBiomassEquations().Any())
                {
                    numOlines = 0;
                    WriteReportHeading(strWriteOut, "BIOMASS EQUATION TABLE", "", "", rh.BiomassHeaders, 10, ref pageNumb, "");

                    int[] fieldLengths = new int[12] {
                        2, 8, 5, 20, 7, 8, 8, 4, 6, 9, 6, 1
                    };
                    ArrayList prtFields    = new ArrayList();
                    string    prevSP       = "**";
                    string    prevPP       = "**";
                    int       printSpecies = 0;
                    foreach (BiomassEquationDO bel in Global.BL.getBiomassEquations())
                    {
                        //  new header?
                        WriteReportHeading(strWriteOut, "BIOMASS EQUATION TABLE", "", "", rh.BiomassHeaders, 10, ref pageNumb, "");

                        if (prevSP != bel.Species || prevPP != bel.Product)
                        {
                            printSpecies = 1;
                            prevSP       = bel.Species;
                            //  find biomass product in the sample group table

                            prevPP = bel.Product;
                        }
                        else if (prevSP == bel.Species || prevPP == bel.Product)
                        {
                            printSpecies = 0;
                        }   //  endif
                        //  build array for creating equation line
                        prtFields = BiomassEqMethods.buildPrintArray(bel, printSpecies);
                        StringBuilder oneRecord = buildPrintLine(fieldLengths, prtFields);
                        strWriteOut.WriteLine(oneRecord.ToString());
                        numOlines++;
                    } //  end foreach loop
                }     //  endif biomass equations exist

                //  Quality adjustment equations
                //qualList = Global.BL.getQualAdjEquations();
                if (Global.BL.getQualAdjEquations().Any())
                {
                    numOlines = 0;
                    WriteReportHeading(strWriteOut, "QUALITY ADJUSTMENT EQUATION TABLE", "", "", rh.QualityEqHeaders, 8, ref pageNumb, "");

                    int[] fieldLengths = new int[10] {
                        5, 7, 15, 13, 15, 15, 15, 15, 15, 15
                    };
                    ArrayList prtFields = new ArrayList();
                    foreach (QualityAdjEquationDO qal in Global.BL.getQualAdjEquations())
                    {
                        //  build array of fields for creating data table
                        prtFields = QualityAdjMethods.buildPrintArray(qal);
                        StringBuilder oneRecord = buildPrintLine(fieldLengths, prtFields);
                        strWriteOut.WriteLine(oneRecord.ToString());
                        numOlines++;
                    } //  end foreach loop
                }     //  endif quality adjustment equations exist
            }         //  endif not BLM
            return;
        }             //  end outputEquationTable
        public int setupDialog()
        {
            VolumeEqMethods Veq = new VolumeEqMethods();
            //  fill species list from tree table
            //  show message box if this is BLM
            string currRegion = bslyr.getRegion();

            if (currRegion == "7" || currRegion == "07")
            {
                MessageBox.Show("BLM Volume Equations cannot be entered here.", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
                return(-1);
            }   //  endif BLM

            //  if there are volume equations, show in grid
            //  if not, the grid is just initialized
            equationList = bslyr.getVolumeEquations();

            //  Check for missing common name and model name
            Veq.updateVolumeList(equationList, fileName, currRegion);

            string[,] speciesProduct;
            speciesProduct = bslyr.GetUniqueSpeciesProduct();
            //  pull species not used in the cruise from the equations list
            equationList = updateEquationList(speciesProduct);

            //  If there are no species/products in tree default values, it's wrong
            //  tell user to check the file design in CSM --  June 2013
            if (speciesProduct.Length == 0)
            {
                MessageBox.Show("No species/product combinations found in Tree records.\nPlease enter tree records before continuing.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return(-1);
            }   //  endif

            //  if equation list is empty, just fill in unique species and primary product
            if (equationList.Count == 0)
            {
                for (int k = 0; k < speciesProduct.GetLength(0); k++)
                {
                    if (speciesProduct[k, 0] != "" && speciesProduct[k, 0] != null)
                    {
                        VolumeEquationDO ved = new VolumeEquationDO();
                        ved.Species        = speciesProduct[k, 0];
                        ved.PrimaryProduct = speciesProduct[k, 1];
                        equationList.Add(ved);
                    } //  endif end of list
                }     //  end for k loop
            }
            else
            {
                //  situation exists were a template file was made from an existing cruise and
                //  additional species/product combinations were placed in tree default value
                //  need to add those to the equationList so user can enter equation information
                //  June 2013
                for (int k = 0; k < speciesProduct.GetLength(0); k++)
                {
                    if (speciesProduct[k, 0] != "" && speciesProduct[k, 0] != null)
                    {
                        //  see if this combination is in the equationList
                        int nthRow = equationList.FindIndex(
                            delegate(VolumeEquationDO ved)
                        {
                            return(ved.Species == speciesProduct[k, 0] && ved.PrimaryProduct == speciesProduct[k, 1]);
                        });
                        if (nthRow == -1)
                        {
                            //  add the equation to the list so the user can enter equation information
                            VolumeEquationDO v = new VolumeEquationDO();
                            v.Species        = speciesProduct[k, 0];
                            v.PrimaryProduct = speciesProduct[k, 1];
                            equationList.Add(v);
                        } //  endif
                    }     //  endif
                }         //  end for k loop
            }             //  endif list is empty

            volumeEquationDOBindingSource.DataSource = equationList;
            volumeEquationList.DataSource            = volumeEquationDOBindingSource;

            //  also add species and product to combo boxes at bottom
            ArrayList justSpecies = bslyr.GetJustSpecies("TreeDefaultValue");

            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++)
            {
                productList.Items.Add(justProduct[n].ToString());
            }

            volRegion.Enabled   = false;
            volForest.Enabled   = false;
            volEquation.Enabled = false;
            speciesList.Enabled = false;
            productList.Enabled = false;
            return(1);
        }   //  end setupDialog