public void CreateLiveDead(StreamWriter strWriteOut, reportHeaders rh, ref int pageNumb)
        {
            //  generates LD1-LD8 live/dead reports
            string currentTitle           = fillReportTitle(currentReport);
            IEnumerable <StratumDO> sList = Global.BL.getStratum().ToList();
            //List<CuttingUnitDO> cList = Global.BL.getCuttingUnits();
            List <PRODO> proList = Global.BL.getPRO().ToList();
            List <LCDDO> lcdList = Global.BL.getLCD().ToList();

            //  clear total values
            productSubtotal.Clear();
            unitMethodSubtotal.Clear();
            grandTotal.Clear();
            ldList.Clear();

            numOlines = 0;
            //  set volume type based on report
            switch (currentReport)
            {
            case "LD1":
            case "LD3":
            case "LD5":
            case "LD7":
                volType = "CUFT";
                //  any data for report?
                if (lcdList.Sum(l => l.SumGCUFT) == 0)
                {
                    noDataForReport(strWriteOut, currentReport, " >>>> No cubic foot volume for report");
                    return;
                }       //  endif testVolume
                break;

            case "LD2":
            case "LD4":
            case "LD6":
            case "LD8":
                volType = "BDFT";
                //  any data for report?
                if (lcdList.Sum(l => l.SumGBDFT) == 0)
                {
                    noDataForReport(strWriteOut, currentReport, " >>>> No board foot volume for report");
                    return;
                } //  endif no volume
                break;
            }     //  end switch
            //  create report title and headers
            rh.createReportTitle(currentTitle, 6, 0, 0, reportConstants.FTS, reportConstants.FCTO);
            //  pull LCD groups
            IEnumerable <LCDDO> justGroups = LCDmethods.GetCutGroupedBy("", "", 9);

            switch (currentReport)
            {
            case "LD1":
            case "LD2":
                ldList.Clear();
                finishColumnHeaders(rh.LD1LD2left, rh.LiveDeadRight);
                fieldLengths = new int[] { 1, 3, 7, 9, 10, 12, 9, 10, 12, 9, 10, 12, 9, 10, 8 };
                AccumulateAllData(justGroups, lcdList, sList);
                OutputData(strWriteOut, rh, ref pageNumb, "");
                //  output last product subtotal and then grand total
                OutputSubtotal("P", rh, productSubtotal, strWriteOut, ref pageNumb, "");
                OutputSubtotal("G", rh, grandTotal, strWriteOut, ref pageNumb, "");
                break;

            case "LD3":
            case "LD4":
                finishColumnHeaders(rh.LD3LD4left, rh.LiveDeadRight);
                fieldLengths = new int[] { 1, 4, 3, 7, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 8 };
                AccumulateAllData("CUT", justGroups, sList, proList);
                OutputData(strWriteOut, rh, ref pageNumb, "CUT");
                //  output last product subtotal
                OutputSubtotal("P", rh, productSubtotal, strWriteOut, ref pageNumb, "CUT");
                OutputSubtotal("U", rh, unitMethodSubtotal, strWriteOut, ref pageNumb, "CUT");
                OutputSubtotal("G", rh, grandTotal, strWriteOut, ref pageNumb, "CUT");
                break;

            case "LD5":
            case "LD6":
                finishColumnHeaders(rh.LD5LD6left, rh.LiveDeadRight);
                fieldLengths = new int[] { 1, 4, 3, 7, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 8 };
                AccumulateAllData("PAY", justGroups, sList, proList);
                OutputData(strWriteOut, rh, ref pageNumb, "PAY");
                //  output last product subtotal
                OutputSubtotal("P", rh, productSubtotal, strWriteOut, ref pageNumb, "PAY");
                OutputSubtotal("U", rh, unitMethodSubtotal, strWriteOut, ref pageNumb, "PAY");
                OutputSubtotal("G", rh, grandTotal, strWriteOut, ref pageNumb, "PAY");
                break;

            case "LD7":
            case "LD8":
                //  June 2017 -- these reports are by logging method so if blank or null
                // report cannot be generated
                int noMethod = 0;
                foreach (CuttingUnitDO ct in Global.BL.getCuttingUnits())
                {
                    if (ct.LoggingMethod == "" || ct.LoggingMethod == " " || ct.LoggingMethod == null)
                    {
                        noDataForReport(strWriteOut, currentReport, " >>>> One or more logging methods are missing.  Cannot generate report.");
                        noMethod = -1;
                    }   //  endif
                }       //  end foreach loop
                if (noMethod != -1)
                {
                    finishColumnHeaders(rh.LD7LD8left, rh.LiveDeadRight);
                    fieldLengths = new int[] { 1, 4, 3, 7, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 8 };
                    AccumulateAllData("LOG", justGroups, sList, proList);
                    OutputData(strWriteOut, rh, ref pageNumb, "LOG");
                    //  output last product subtotal
                    OutputSubtotal("P", rh, productSubtotal, strWriteOut, ref pageNumb, "LOG");
                    OutputSubtotal("U", rh, unitMethodSubtotal, strWriteOut, ref pageNumb, "LOG");
                    OutputSubtotal("G", rh, grandTotal, strWriteOut, ref pageNumb, "LOG");
                } //  endif
                break;
            }     //  end switch on current report
            //  output footer
            strWriteOut.WriteLine("");
            strWriteOut.WriteLine(rh.LiveDeadFooter[0]);
            strWriteOut.WriteLine(rh.LiveDeadFooter[1]);
            strWriteOut.WriteLine(rh.LiveDeadFooter[2]);

            return;
        }   // end CreateLiveDead
示例#2
0
        public void CreateTreeGradeReports(StreamWriter strWriteOut, reportHeaders rh, ref int pageNumb)
        {
            string currentTitle = fillReportTitle(currRept);

            numOlines = 0;
            //  need data from LCD; cut trees only; ordered by primary product, species and tree grade
            List <LCDDO> lcdList = LCDmethods.GetCutGroupedBy("", "", 8, bslyr);

            string volType = "";
            double volSum  = 0;

            //  make sure there's data for the current report
            if (currRept == "A11")
            {
                volType = "BDFT";
                volSum  = lcdList.Sum(l => l.SumNBDFT);
            }
            else if (currRept == "A12")
            {
                volType = "CUFT";
                volSum  = lcdList.Sum(l => l.SumNCUFT);
            }   //  endif
            if (volSum == 0)
            {
                sb.Clear();
                sb.Append(">> No ");
                sb.Append(volType);
                sb.Append(" volume for report ");
                noDataForReport(strWriteOut, currRept, sb.ToString());
                return;
            }   //  endif volSum

            //  use a ReportSubtotal list for individual lines
            string prevSpecies = "*";
            string prevProduct = "*";

            //  loop twice to get the two separate pages
            for (int k = 0; k < 2; k++)
            {
                //  need complete report title
                if (k == 1)
                {
                    currentTitle  = currentTitle.Substring(0, 32);
                    currentTitle += " ESTIMATED NUMBER OF TREES";
                    eachLine.Clear();
                    productSubTotal.Clear();
                    saleTotal.Clear();
                    prevSpecies = "*";
                    prevProduct = "*";
                    numOlines   = 0;
                }   //  endif page 2
                rh.createReportTitle(currentTitle, 4, 32, 0, reportConstants.FCTO_PPO, "");


                //  Loop through LCD list and accumulate lines
                foreach (LCDDO lcd in lcdList)
                {
                    WriteReportHeading(strWriteOut, rh.reportTitles[0], rh.reportTitles[1], rh.reportTitles[2],
                                       rh.A11A12columns, 7, ref pageNumb, "");
                    //  need a new line or subtotal?
                    if (prevSpecies == "*" && prevProduct == "*")
                    {
                        prevSpecies = lcd.Species;
                        prevProduct = lcd.PrimaryProduct;
                        firstLine   = 1;
                    }
                    else if (prevSpecies != lcd.Species)
                    {
                        //  output individual line
                        WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 1, eachLine);
                        //  update product subtotal
                        UpdateTotals(eachLine, productSubTotal, 1);
                        //  update sale total
                        UpdateTotals(eachLine, saleTotal, 2);
                        //  empty eachLine list and save current species
                        eachLine.Clear();
                        prevSpecies = lcd.Species;
                    }
                    else if (prevProduct != lcd.PrimaryProduct)
                    {
                        //  time for a subtotal line
                        WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 1, eachLine);
                        //  Update product subtotal
                        UpdateTotals(eachLine, productSubTotal, 1);
                        //  Update sale total
                        UpdateTotals(eachLine, saleTotal, 2);
                        //  Output product subtotal
                        WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 2, productSubTotal);
                        //  Clear product subtotal
                        productSubTotal.Clear();
                        //  Clear each line
                        eachLine.Clear();
                        //  save species and product
                        prevProduct = lcd.PrimaryProduct;
                        prevSpecies = lcd.Species;
                    }   //  endif

                    //  Load eachLine with correct volume
                    LoadEachLine(volType, ref firstLine, lcd, k);
                }   //  end foreach loop

                //  Output last species group
                WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 1, eachLine);
                //  Update product subtotal
                UpdateTotals(eachLine, productSubTotal, 1);
                //  Output product total
                WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 2, productSubTotal);
                //  Update sale total
                UpdateTotals(eachLine, saleTotal, 2);
                //  Output sale total
                WriteCurrentGroup(strWriteOut, rh, ref pageNumb, 3, saleTotal);
            }   //  end for k loop

            return;
        }   //  end CreateTreeGradeReports
示例#3
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