Esempio n. 1
0
        private void onFinished(object sender, EventArgs e)
        {
            //  Remove all equations as they are rebuilt with either of these calls
            volList.Clear();
            Global.BL.SaveVolumeEquations(volList);
            if (taperEquations.Checked == true)
            {
                CreateEquations("900CLKE");
            }
            else if (oldEquations.Checked == true)
            {
                CreateEquations("900DVEE");
            }

            //  Save equations
            Global.BL.SaveVolumeEquations(volList);
            if (calcBiomass.Checked == true)
            {
                VolumeEquations ve = new VolumeEquations();
                ve.fileName = fileName;
                ve.updateBiomass(volList);
            }   //  endif calculate biomass
            Close();
            return;
        }   //  end onFinished
Esempio n. 2
0
        }     //  end onFile

        private void onButton1Click(object sender, EventArgs e)
        {
            if (whichProcess == 1)       //  equations
            {
                VolumeEquations volEqObj = new VolumeEquations();
                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
            {
                if (templateFlag == 1)
                {
                    Global.Init(new CPbusinessLayer(new CruiseDAL.DAL(newTemplateFile), newTemplateFile));
                }
                //else Global.BL.fileName = fileName;
                //  get all reports
                List <ReportsDO> currentReports = Global.BL.GetReports().ToList();
                //  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();
                    Global.BL.SaveReports(currentReports);
                }
                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);
                        Global.BL.SaveReports(currentReports);
                    }
                    else
                    {
                        //  new reports -- just add
                        currentReports = ReportMethods.addReports(currentReports, ara);
                        Global.BL.SaveReports(currentReports);
                    } //  endif
                }     //  endif
                //  now get reports selected
                currentReports = ReportMethods.deleteReports(currentReports);
                currentReports = Global.BL.GetSelectedReports().ToList();
                //  Get selected reports
                ReportsDialog rd = new ReportsDialog();
                rd.fileName     = fileName;
                rd.reportList   = currentReports;
                rd.templateFlag = templateFlag;
                rd.setupDialog();
                rd.ShowDialog();
            }
            else if (whichProcess == 4)  //  output
            {
                //  Pull reports selected
                //  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 = Global.BL.getTrees();
                double summedEF = Global.BL.getTrees().Sum(t => t.ExpansionFactor);
                //List<TreeCalculatedValuesDO> tcvList = Global.BL.getTreeCalculatedValues();
                double summedNetBDFT = 0;
                double summedNetCUFT = 0;

                foreach (TreeCalculatedValuesDO tcv in Global.BL.getTreeCalculatedValues())
                {
                    summedNetBDFT += tcv.NetBDFTPP;
                    summedNetCUFT += tcv.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 = Global.BL.GetSelectedReports().ToList();

                //  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.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
Esempio n. 3
0
        }   //  end onTopwoodClick

        private void onOK(object sender, EventArgs e)
        {
            //  open volume equation table and remove all before building and saving equations
            Global.BL.deleteVolumeEquations();
            volList.Clear();

            //  Need to build volume equation and store in table, so goes into VolumeEqList
            string currentForest   = "";
            string currentDistrict = "";
            string currGeoCode     = "";
            string currGrpCode     = "";

            foreach (SaleDO sd in Global.BL.getSale())
            {
                currentForest = sd.Forest;
                if (sd.District == null)
                {
                    currentDistrict = "";
                }
                else
                {
                    currentDistrict = sd.District;
                }
            }   //  end foreach

            //  Look up geo code and group code for this forest and district (if any)
            //  First look in defaults
            for (int k = 0; k < 12; k++)
            {
                if (currentForest == forestDefaultList[k, 0])
                {
                    currGeoCode = forestDefaultList[k, 1];
                    currGrpCode = forestDefaultList[k, 2];
                } //  endif
            }     //  end for k loop

            //  Check for an override on district
            for (int k = 0; k < 33; k++)
            {
                if (currentForest == forestDistrictList[k, 0] && currentDistrict == forestDistrictList[k, 1])
                {
                    currGeoCode = forestDistrictList[k, 2];
                    currGrpCode = forestDistrictList[k, 3];
                } //  endif
            }     //  end for k loop

            //  if geocode and group code are still blank, means forest or district are incorrect
            if (currGeoCode == "" || currGrpCode == "")
            {
                MessageBox.Show("Could not find Forest and/or District number.\nCannot complete equations.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }   //  endif

            //  get unique species/product combinations
            string[,] speciesProduct = Global.BL.GetUniqueSpeciesProduct();
            for (int k = 0; k < speciesProduct.GetLength(0); k++)
            {
                //  need species and product
                string currentSpecies = speciesProduct[k, 0];
                string currentProduct = speciesProduct[k, 1];

                //  call build equation for this combination
                if (currentSpecies != null && currentProduct != null)
                {
                    //  change in volume library no longer has DVEE equations used for board for board foot volume
                    //  so commented out the call to build those equations
                    //  October 2015
                    //if (currentProduct == "01")
                    //  buildVolumeEquation(currGrpCode, currentSpecies, currentProduct);
                    //  Build Clark equations -- old or new -- July 2017
                    if (newClarkCheckBox.Checked == true)
                    {
                        buildNewClarkEquations(currGeoCode, currentSpecies, currentProduct);
                    }
                    else if (oldClarkCheckBox.Checked == true)
                    {
                        if (pulpwoodHeight >= 0)
                        {
                            buildClarkEquation(currGeoCode, currentSpecies, currentProduct, pulpwoodHeight);
                        }
                        else if (pulpwoodHeight < 0)
                        {
                            Close();
                            return;
                        } //  endif
                    }     //  endif
                }         //  endif no null
            }             //  end foreach

            //  Save equations in database
            Global.BL.SaveVolumeEquations(volList);

            if (calcBiomass.Checked == true)
            {
                VolumeEquations ve = new VolumeEquations();
                ve.fileName = fileName;
                ve.updateBiomass(volList);
            }   //  endif calculate biomass
            Close();
            return;
        }   //  end onOK