Ejemplo n.º 1
0
        }             //  end setupDialog

        private void onFinished(object sender, EventArgs e)
        {
            //  which graphs were selected?  Set Selected in reportList and then save the list
            if (GR01check.Checked)
            {
                updateList("GR01", true);
            }
            else
            {
                updateList("GR01", false);
            }

            if (GR02check.Checked)
            {
                updateList("GR02", true);
            }
            else
            {
                updateList("GR02", false);
            }

            if (GR03check.Checked)
            {
                updateList("GR03", true);
            }
            else
            {
                updateList("GR03", false);
            }

            if (GR04check.Checked)
            {
                updateList("GR04", true);
            }
            else
            {
                updateList("GR04", false);
            }

            if (GR05check.Checked)
            {
                updateList("GR05", true);
            }
            else
            {
                updateList("GR05", false);
            }

            if (GR06check.Checked)
            {
                updateList("GR06", true);
            }
            else
            {
                updateList("GR06", false);
            }

            if (GR07check.Checked)
            {
                updateList("GR07", true);
            }
            else
            {
                updateList("GR07", false);
            }

            if (GR08check.Checked)
            {
                updateList("GR08", true);
            }
            else
            {
                updateList("GR08", false);
            }

            if (GR09check.Checked)
            {
                updateList("GR09", true);
            }
            else
            {
                updateList("GR09", false);
            }

            if (GR10check.Checked)
            {
                updateList("GR10", true);
            }
            else
            {
                updateList("GR10", false);
            }

            if (GR11check.Checked)
            {
                updateList("GR11", true);
            }
            else
            {
                updateList("GR11", false);
            }

            //  save reports list
            bslyr.SaveReports(reportList);
            Close();
            return;
        }   //  end onFinished
Ejemplo n.º 2
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