} // end updateList private void addGraphReports() { string[,] graphReports = new string[11, 2] { { "GR01", "Scatter plot of DBH and Total Height by Species" }, { "GR02", "Species Distribution for the Sale (pie chart)" }, { "GR03", "Volume by Species - Sawtimber Only (pie chart)" }, { "GR04", "Volume by Product(pie chart)" }, { "GR05", "Number of 16-foot Logs by DIB Class by Species (bar chart)" }, { "GR06", "Number of Trees by DBH (bar chart)" }, { "GR07", "Number of Trees by Species (bar chart)" }, { "GR08", "Number of Trees by DBH by Stratum (bar chart)" }, { "GR09", "Number of Trees by KPI by Species (bar chart)" }, { "GR10", "BA/Acre by Species (pie chart)" }, { "GR11", "BA/Acre by 2-inch DBH Class by Sample Group (bar chart)" } }; for (int k = 0; k < 11; k++) { ReportsDO rd = new ReportsDO(); rd.ReportID = graphReports[k, 0]; rd.Selected = false; rd.Title = graphReports[k, 1]; reportList.Add(rd); } // end for k loop return; }
} // end onCancel private void onFinished(object sender, EventArgs e) { // Did user open a file? if (fileName == "" || fileName == null || fileName == " ") { MessageBox.Show("NO FILENAME ENTERED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // endif filename missing // reset selected to zero before updating foreach (ReportsDO rl in reportList) { rl.Selected = false; } // end foreach // update selected reports and store in database // check for no reports selected if (reportsSelected.Items.Count <= 0) { DialogResult dr = MessageBox.Show("NO REPORTS SELECTED\nOK to Exit?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { Close(); return; } else if (dr == DialogResult.No) { return; } } // endif no reports selected for (int k = 0; k < reportsSelected.Items.Count; k++) { string sReport = reportsSelected.Items[k].ToString(); int ithRow = reportList.FindIndex( delegate(ReportsDO rl) { return(rl.ReportID == sReport); }); if (ithRow >= 0) { reportList[ithRow].Selected = true; } else if (ithRow < 0) // added report -- update report list { ReportsDO rd = new ReportsDO(); rd.ReportID = sReport; rd.Selected = true; reportList.Add(rd); } // endif ithRow } // end foreach loop // Update reports table in database bslyr.updateReports(reportList); Close(); return; } // end onFinished
public static List <ReportsDO> fillReportsList() { // this would be used to fill the list with reports when there are none in the database List <ReportsDO> rList = new List <ReportsDO>(); // need the reports array to loop through allReportsArray ara = new allReportsArray(); for (int k = 0; k < ara.reportsArray.GetLength(0); k++) { ReportsDO rl = new ReportsDO(); rl.ReportID = ara.reportsArray[k, 0]; // since this is an initial list where none exists, selected will always be zero or false rl.Selected = false; rl.Title = ara.reportsArray[k, 1]; rList.Add(rl); } // end for k loop return(rList); } // end fillReportsList
} // end updateReportsList public static List <ReportsDO> addReports(List <ReportsDO> rList, allReportsArray ara) { // check current reports list for each report and add if not there // hoping this catches new reports as they are added to the reports // March 2014 for (int k = 0; k < ara.reportsArray.GetLength(0); k++) { int nthRow = rList.FindIndex( delegate(ReportsDO r) { return(r.ReportID == ara.reportsArray[k, 0]); }); if (nthRow < 0) { // add report to list ReportsDO rr = new ReportsDO(); rr.ReportID = ara.reportsArray[k, 0]; rr.Title = ara.reportsArray[k, 1]; rr.Selected = false; rList.Add(rr); } // endif nthRow } // end for k loop return(rList); } // end addReports