示例#1
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
        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