} // end fillFields public static ArrayList buildMerchArray(VolumeEquationDO vel) { ArrayList merchArray = new ArrayList(); merchArray.Add(" "); merchArray.Add(vel.VolumeEquationNumber.PadRight(10, ' ')); merchArray.Add(vel.PrimaryProduct.PadLeft(2, ' ')); merchArray.Add(Utilities.FormatField(vel.Trim, "{0,2:F1}").ToString()); merchArray.Add(Utilities.FormatField(vel.MinLogLengthPrimary, "{0,2:F0}").ToString().PadLeft(2, ' ')); merchArray.Add(Utilities.FormatField(vel.MaxLogLengthPrimary, "{0,2:F0}").ToString().PadLeft(2, ' ')); merchArray.Add(Utilities.FormatField(vel.SegmentationLogic, "{0,2:F0}").ToString().PadLeft(2, ' ')); merchArray.Add(Utilities.FormatField(vel.MinMerchLength, "{0,2:F0}").ToString().PadLeft(2, ' ')); merchArray.Add(Utilities.FormatField(vel.EvenOddSegment, "{0,1:F0}").ToString()); if (vel.PrimaryProduct == "01") { merchArray.Add("N/A"); } else { switch (vel.MerchModFlag) { case 0: merchArray.Add("NO "); break; default: merchArray.Add("YES"); break; } // end switch } // endif return(merchArray); } // end buildMerchArray
} // end fillFields public List <string> buildMerchArray(VolumeEquationDO vel) { var merchArray = new List <string>(); merchArray.Add(" "); merchArray.Add(vel.VolumeEquationNumber.PadRight(10, ' ')); merchArray.Add(vel.PrimaryProduct.PadLeft(2, ' ')); merchArray.Add(String.Format("{0,2:F1}", vel.Trim)); merchArray.Add(String.Format("{0,2:F0}", vel.MinLogLengthPrimary).PadLeft(2, ' ')); merchArray.Add(String.Format("{0,2:F0}", vel.MaxLogLengthPrimary).PadLeft(2, ' ')); merchArray.Add(String.Format("{0,2:F0}", vel.SegmentationLogic).PadLeft(2, ' ')); merchArray.Add(String.Format("{0,2:F0}", vel.MinMerchLength).PadLeft(2, ' ')); merchArray.Add(String.Format("{0,1:F0}", vel.EvenOddSegment)); if (vel.PrimaryProduct == "01") { merchArray.Add("N/A"); } else { switch (vel.MerchModFlag) { case 0: merchArray.Add("NO "); break; default: merchArray.Add("YES"); break; } // end switch } // endif return(merchArray); } // end buildMerchArray
public VolumeEquationDO ShowEditVolumeEq(VolumeEquationDO tdv) { try { using (FormAddVolumeEqs dialog = new FormAddVolumeEqs(ViewPresenter.ApplicationController.SetupService.GetProductCodes())) { if (dialog.ShowDialog(tdv) == DialogResult.OK) { return(tdv); } else { return(null); } } } catch (Exception ex) { if (!ViewPresenter.ApplicationController.ExceptionHandler.Handel(ex)) { throw; } else { return(null); } } }
public void setupDialog() { // Get unique species list from trees ArrayList uniqueSpecies = Global.BL.GetJustSpecies("Tree"); // any volume equations?? List <VolumeEquationDO> volList = Global.BL.getVolumeEquations().ToList(); if (volList.Count <= 0) { // Initialize dibs as zero jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); jd.speciesDIB = uniqueSpecies[k].ToString(); jd.productDIB = "01"; jd.primaryDIB = 0.0F; jd.secondaryDIB = 0.0F; jstDIB.Add(jd); } // end for k loop } else if (volList.Count > 0) { // Initialize dibs from volume equations jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); string currentSpecies = uniqueSpecies[k].ToString(); VolumeEquationDO ve = volList.FirstOrDefault(v => v.Species == currentSpecies); if (ve != null) { jd.speciesDIB = currentSpecies; jd.productDIB = ve.PrimaryProduct.ToString(); jd.primaryDIB = ve.TopDIBPrimary; jd.secondaryDIB = ve.TopDIBSecondary; jstDIB.Add(jd); } // endif nthRow } // end for k loop } // endif volumes // Now the list can be loaded into the data grid -- it is not bound int rowNum = 0; completedDIBs.RowCount = jstDIB.Count; completedDIBs.ColumnCount = 3; foreach (JustDIBs jd in jstDIB) { completedDIBs.Rows[rowNum].Cells[0].Value = jd.speciesDIB; completedDIBs.Rows[rowNum].Cells[1].Value = jd.primaryDIB; completedDIBs.Rows[rowNum].Cells[2].Value = jd.secondaryDIB; rowNum++; } // end foreach loop return; } // end setupDialog
private void _volEq_add_button_Click(object sender, System.EventArgs e) { VolumeEquationDO newTDV = this.ShowAddVolumeEq(); if (newTDV != null) { this._BS_VolEquations.Add(newTDV); } }
private void _volEq_delete_button_Click(object sender, EventArgs e) { VolumeEquationDO obj = this._BS_VolEquations.Current as VolumeEquationDO; if (obj != null) { obj.Delete(); this._BS_VolEquations.Remove(obj); } }
private void _volEq_delete_button_Click(object sender, EventArgs e) { VolumeEquationDO tdv = _BS_VolEquations.Current as VolumeEquationDO; if (tdv == null) { return; } ViewPresenter.DeletedVolumeEqs.Add(tdv); _BS_VolEquations.Remove(tdv); }
} // end onOK private void buildVolumeEquation(string currGrpCode, string currentSpecies, string currentProduct) { StringBuilder sb = new StringBuilder(); sb.Append("8"); // complete equation build and put in volList sb.Append(currGrpCode); sb.Append("DVEE"); // Fix incomplete species code if (currentSpecies.Length == 2) { sb.Append("0"); } else if (currentSpecies.Length == 1) { sb.Append("00"); } sb.Append(currentSpecies); // set remaining values for a volume equation entry VolumeEquationDO vel = new VolumeEquationDO(); vel.Species = currentSpecies; vel.PrimaryProduct = currentProduct; vel.VolumeEquationNumber = sb.ToString(); vel.StumpHeight = 1; vel.TopDIBPrimary = 0; vel.TopDIBSecondary = 0; vel.CalcTotal = 0; vel.CalcBoard = 1; vel.CalcCubic = 0; vel.CalcCord = 0; vel.CalcTopwood = 0; if (calcBiomass.Checked == true) { vel.CalcBiomass = 1; } else { vel.CalcBiomass = 0; } vel.Trim = 0; vel.SegmentationLogic = 0; vel.MinLogLengthPrimary = 0; vel.MaxLogLengthPrimary = 0; vel.MinMerchLength = 0; volList.Add(vel); return; } // end buildVolumeEquation
} // end updateList private void displayRecord(VolumeEquationDO currRecord) { trimText.Text = currRecord.Trim.ToString(); currVolEq.Text = currRecord.VolumeEquationNumber.ToString(); minLogLength.Value = Convert.ToDecimal(currRecord.MinLogLengthPrimary); maxLogLength.Value = Convert.ToDecimal(currRecord.MaxLogLengthPrimary); switch (currRecord.SegmentationLogic) { case 21: segmentLogic.Text = segmentDescrip[0]; break; case 22: segmentLogic.Text = segmentDescrip[1]; break; case 23: segmentLogic.Text = segmentDescrip[2]; break; case 24: segmentLogic.Text = segmentDescrip[3]; break; } // end switch minMerchLength.Value = Convert.ToDecimal(currRecord.MinMerchLength); if (currRecord.EvenOddSegment == 1) { oddSegment.Checked = true; } else if (currRecord.EvenOddSegment == 2) { evenSegment.Checked = true; } stumpHgt.Text = currRecord.StumpHeight.ToString(); topDIB.Text = currRecord.TopDIBPrimary.ToString(); return; }
} // end onFinished private void CreateEquations(string eqnPrefix) { string currentProduct; string currentSpecies; // Need to capture DIBs before creating equations List <JustDIBs> oldDIBs = Global.BL.GetJustDIBs().ToList(); // Grab tree data grouped by unique species and products string[,] speciesProduct; speciesProduct = Global.BL.GetUniqueSpeciesProduct(); StringBuilder sb = new StringBuilder(); double updatedPrimaryDIB = 0.0; double updatedSecondaryDIB = 0.0; for (int k = 0; k < speciesProduct.GetLength(0); k++) { if (speciesProduct[k, 0] != null) { VolumeEquationDO vel = new VolumeEquationDO(); // Per Mike VanDyck -- cords flag is on for everything including sawtimber vel.CalcCord = 1; // Set constant values vel.CalcTotal = 0; vel.StumpHeight = 0; vel.TopDIBPrimary = 0; vel.TopDIBSecondary = 0; vel.Trim = 0; vel.SegmentationLogic = 0; vel.MaxLogLengthPrimary = 0; vel.MinLogLengthPrimary = 0; vel.MinMerchLength = 0; currentProduct = speciesProduct[k, 1]; currentSpecies = speciesProduct[k, 0]; // build equation sb.Remove(0, sb.Length); sb.Append(eqnPrefix); // Fix species code as needed if (currentSpecies.Length == 2) { sb.Append("0"); } else if (currentSpecies.Length == 1) { sb.Append("00"); } sb.Append(currentSpecies); vel.VolumeEquationNumber = sb.ToString(); // Set calculation flags as needed vel.CalcCubic = 1; vel.CalcTopwood = 0; if (currentProduct == "01") { vel.CalcBoard = 1; // Is topwood status changed for this species if (topwoodSpecies.IndexOf(currentSpecies) >= 0) { vel.CalcTopwood = Convert.ToInt32(topwoodFlags[topwoodSpecies.IndexOf(currentSpecies)]); } } else { vel.CalcBoard = 0; } if (eqnPrefix == "900DVEE") { // Need to update DIB values here UpdateDIBs(oldDIBs, currentSpecies, currentProduct, updatedPrimaryDIB, updatedSecondaryDIB); vel.TopDIBPrimary = Convert.ToSingle(updatedPrimaryDIB); vel.TopDIBSecondary = Convert.ToSingle(updatedSecondaryDIB); } else if (eqnPrefix == "900CLKE") { // See if DIB exists in the old DIB list for this species int nthRow = oldDIBs.FindIndex( delegate(JustDIBs jds) { return(jds.speciesDIB == currentSpecies); }); if (nthRow >= 0) { vel.TopDIBPrimary = Convert.ToSingle(oldDIBs[nthRow].primaryDIB); vel.TopDIBSecondary = Convert.ToSingle(oldDIBs[nthRow].secondaryDIB); } else if (nthRow < 0) { // Was it updated by the user? int mthRow = jstDIBs.FindIndex( delegate(JustDIBs jds) { // based on conversation with M.VanDyck, Sept 2014, any DIB change applies to // any primary product value, sawtimber or non-sawtimber. Removed check for product. return(jds.speciesDIB == currentSpecies); }); if (mthRow >= 0) { // Sawtimber if (jstDIBs[mthRow].primaryDIB == 0.0) { // set to default if (Convert.ToInt32(currentSpecies) < 300) { vel.TopDIBPrimary = Convert.ToSingle(defaultConiferTop); } else { vel.TopDIBPrimary = Convert.ToSingle(defaultHardwoodTop); } } else { vel.TopDIBPrimary = Convert.ToSingle(jstDIBs[mthRow].primaryDIB); } // Non-saw if (jstDIBs[mthRow].secondaryDIB == 0.0) { vel.TopDIBSecondary = Convert.ToSingle(defaultNonSaw); } else { vel.TopDIBSecondary = Convert.ToSingle(jstDIBs[mthRow].secondaryDIB); } } else if (mthRow < 0) { // set to defaults if (Convert.ToInt32(currentSpecies) < 300) { vel.TopDIBPrimary = Convert.ToSingle(defaultConiferTop); } else { vel.TopDIBPrimary = Convert.ToSingle(defaultHardwoodTop); } vel.TopDIBSecondary = Convert.ToSingle(defaultNonSaw); } // endif mthRow } // endif nthRow } // endif eqnPrefix vel.Species = currentSpecies; vel.PrimaryProduct = currentProduct; if (calcBiomass.Checked == true) { vel.CalcBiomass = 1; } else { vel.CalcBiomass = 0; } volList.Add(vel); } // endif not blank or null } // end for k loop return; } // end CreateEquations
} // end buildMerchArray public static ArrayList buildPrintArray(VolumeEquationDO vel) { string fieldFormat = "{0,2:F1}"; ArrayList volArray = new ArrayList(); volArray.Add(" "); volArray.Add(vel.Species.PadRight(6, ' ')); volArray.Add(vel.PrimaryProduct.PadLeft(2, '0')); volArray.Add(vel.VolumeEquationNumber); volArray.Add(Utilities.FormatField(vel.StumpHeight, fieldFormat).ToString()); if (vel.CalcTotal == 0) { volArray.Add("NO "); } else if (vel.CalcTotal == 1) { volArray.Add("YES"); } volArray.Add(Utilities.FormatField(vel.TopDIBPrimary, fieldFormat).ToString()); if (vel.CalcBoard == 0) { volArray.Add("NO "); } else if (vel.CalcBoard == 1) { volArray.Add("YES"); } if (vel.CalcCubic == 0) { volArray.Add("NO "); } else if (vel.CalcCubic == 1) { volArray.Add("YES"); } if (vel.CalcCord == 0) { volArray.Add("NO "); } else if (vel.CalcCord == 1) { volArray.Add("YES"); } volArray.Add(Utilities.FormatField(vel.TopDIBSecondary, fieldFormat).ToString()); if (vel.CalcTopwood == 0) { volArray.Add("NO "); volArray.Add("NO "); volArray.Add("NO "); } else if (vel.CalcTopwood == 1) { if (vel.CalcBoard == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } if (vel.CalcCubic == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } if (vel.CalcCord == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } } // endif // Biomass flag if (vel.CalcBiomass == 0) { volArray.Add("NO "); } else if (vel.CalcBiomass == 1) { volArray.Add("YES"); } return(volArray); } // end buildPrintArray
} // end buildMerchArray public List <string> buildPrintArray(VolumeEquationDO vel) { string fieldFormat = "{0,2:F1}"; var volArray = new List <string>(); volArray.Add(" "); volArray.Add(vel.Species.PadRight(6, ' ')); volArray.Add(vel.PrimaryProduct.PadLeft(2, '0')); volArray.Add(vel.VolumeEquationNumber); volArray.Add(String.Format(fieldFormat, vel.StumpHeight)); if (vel.CalcTotal == 0) { volArray.Add("NO "); } else if (vel.CalcTotal == 1) { volArray.Add("YES"); } volArray.Add(String.Format(fieldFormat, vel.TopDIBPrimary)); if (vel.CalcBoard == 0) { volArray.Add("NO "); } else if (vel.CalcBoard == 1) { volArray.Add("YES"); } if (vel.CalcCubic == 0) { volArray.Add("NO "); } else if (vel.CalcCubic == 1) { volArray.Add("YES"); } if (vel.CalcCord == 0) { volArray.Add("NO "); } else if (vel.CalcCord == 1) { volArray.Add("YES"); } volArray.Add(String.Format(fieldFormat, vel.TopDIBSecondary)); if (vel.CalcTopwood == 0) { volArray.Add("NO "); volArray.Add("NO "); volArray.Add("NO "); } else if (vel.CalcTopwood == 1) { if (vel.CalcBoard == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } if (vel.CalcCubic == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } if (vel.CalcCord == 1) { volArray.Add("YES"); } else { volArray.Add("NO "); } } // endif // Biomass flag if (vel.CalcBiomass == 0) { volArray.Add("NO "); } else if (vel.CalcBiomass == 1) { volArray.Add("YES"); } return(volArray); } // end buildPrintArray
public void outputBannerPage(string fileName, StreamWriter strWriteOut, string currentDate, string currentVersion, string DLLversion) { int flagBLM = 0; // Data arrays for the banner page string[] bannerTitle = new string[2] { "CRUISE REPORT HEADER & CERTIFICATION", "CRUISE REPORT HEADER" }; string[] bannerYFD = new string[2] { "Year: yyyy Region: rr Forest: ff District: dd", "Year: yyyy Agency: BLM Forest: ff District: dd" }; string[] cruiseCertification = new string[17] { " **************************** CRUISE CERTIFICATION ****************************", "", " I certify that the timber for the XXXXXXXX timber sale", " has been designated and cruised by the procedures and standards in", " FSH 2409.12, Timber Cruising Handbook. Records of checks are on file", " at the District Ranger Office,", "", "", "", " ___________________ ___________________________________", " RANGER DISTRICT (name of headquarters town)", "", "", " ___________________ ______________", " DISTRICT RANGER DATE", "", " *****************************************************************************" }; string[] BLMcertification = new string[23] { " *************** B L M C R U I S E C E R T I F I C A T I O N ***************", " *******************************************************************************", "", " I certify that the timber for the XXXXXXXX timber sale", " has been cruised according to the procedures and standards set", " forth in the BLM Timber Cruising Handbook 5310-1.", "", "", "", "", " ___________________________ ___________________", " Principal Area Cruiser Date", "", "", " ___________________________ ___________________", " District Cruiser Appraiser Date", "", "", " ___________________________ ___________________", " Field Manager Date", "", " *****************************************************************************", " *****************************************************************************" }; string[] bannerFooter = new string[4] { "Developed and Maintained By:", "USDA FOREST SERVICE VERSION: ", "WASHINGTON OFFICE TIMBER MANAGEMENT VOLUME LIBRARY VERSION: ", "FORT COLLINS, COLORADO (970)295-5776 NATIONAL CRUISE PROCESSING PROGRAM" }; // need to capture region and forest string currRegion = ""; string currForest = ""; foreach (SaleDO sl in Global.BL.getSale()) { // Is this a BLM file? if (sl.Region == "7" || sl.Region == "07") { flagBLM = 1; } // Output header portion if (flagBLM == 1) { strWriteOut.WriteLine(bannerTitle[1]); } else { strWriteOut.WriteLine(bannerTitle[0]); } sb.Remove(0, sb.Length); sb.Append("CRUISE#: "); sb.Append(sl.SaleNumber); sb.Append(" SALE#: "); sb.Append(sl.SaleNumber); strWriteOut.WriteLine(sb.ToString()); // save cruise "name" for later cruiseName = sl.SaleNumber; sb.Remove(0, sb.Length); sb.Append("SALENAME: "); sb.Append(sl.Name); strWriteOut.WriteLine(sb.ToString()); // save salename for later saleName = sl.Name.TrimEnd(' '); sb.Remove(0, sb.Length); sb.Append("RUN DATE & TIME: "); sb.Append(currentDate); strWriteOut.WriteLine(sb.ToString()); strWriteOut.WriteLine(" "); // Output remaining portion of upper left corner sb.Remove(0, sb.Length); // replace fields as needed if (flagBLM == 1) { bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("yyyy", sl.CalendarYear.ToString()); bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("ff", sl.Forest.PadLeft(2, ' ')); bannerYFD[flagBLM] = bannerYFD[flagBLM].Replace("dd", sl.District.PadLeft(2, ' ')); strWriteOut.WriteLine(bannerYFD[flagBLM]); } else { bannerYFD[0] = bannerYFD[0].Replace("yyyy", sl.CalendarYear.ToString()); bannerYFD[0] = bannerYFD[0].Replace("rr", sl.Region.PadLeft(2, '0')); bannerYFD[0] = bannerYFD[0].Replace("ff", sl.Forest.PadLeft(2, ' ')); if (sl.District == "" || sl.District == " " || sl.District == null) { bannerYFD[0] = bannerYFD[0].Replace("dd", " "); } else { bannerYFD[0] = bannerYFD[0].Replace("dd", sl.District.PadLeft(2, ' ')); } strWriteOut.WriteLine(bannerYFD[0]); } // endif sb.Remove(0, sb.Length); sb.Append("Remarks: "); sb.Append(sl.Remarks ?? (" ")); strWriteOut.WriteLine(sb.ToString()); currRegion = sl.Region; currForest = sl.Forest; } // end foreach loop sb.Remove(0, sb.Length); sb.Append("FILENAME: "); sb.Append(fileName); strWriteOut.WriteLine(sb.ToString()); // Reports list sb.Remove(0, sb.Length); sb.Append("REPORTS: "); int numReports = 0; foreach (ReportsDO rd in Global.BL.GetSelectedReports()) { numReports++; if (numReports <= 20) { sb.Append(rd.ReportID); sb.Append(" "); } else if (numReports == 21) { numReports = 0; strWriteOut.WriteLine(sb.ToString()); sb.Remove(0, sb.Length); sb.Append(" "); sb.Append(rd.ReportID); sb.Append(" "); numReports++; } // endif } // end foreach loop // output BLM line if (flagBLM == 1) { // write reports line strWriteOut.WriteLine(sb.ToString()); sb.Remove(0, sb.Length); sb.Append("VOLUME BASED ON "); // need volume equation type for BLM here VolumeEquationDO vdo = Global.BL.getVolumeEquations().FirstOrDefault(ved => ved.VolumeEquationNumber.Substring(3, 4) == "B32W"); if (vdo != null) { sb.Append("32 "); } else { sb.Append("16"); } sb.Append(" FOOT EQUATIONS"); strWriteOut.WriteLine(sb.ToString()); } else { strWriteOut.WriteLine(sb.ToString()); } // Output note for Region 9 as to whether International or Scribner for board foot volume if (currRegion == "9" || currRegion == "09") { switch (currForest) { case "03": case "3": // Chippewa case "09": case "9": // Superior case "13": case "10": // Chequamegon-Nicolet and Hiawatha case "07": case "7": // Ottawa sb.Remove(0, sb.Length); sb.Append("Scribner rule was used for board foot volumes shown in the selected reports."); break; case "04": case "4": // Huron-Manistee case "05": case "5": // Mark Twain case "08": case "8": // Shawnee case "12": case "14": // Hoosier and Wayne case "19": case "21": // Allegheny and Monongahela case "20": case "22": // Green Mountain/Finger Lakes and White Mountain sb.Remove(0, sb.Length); sb.Append("International 1/4 inch rule was used for board foot volumes in the selected reports."); break; } // end switch strWriteOut.WriteLine(sb.ToString()); } // endif region 9 // Several blank lines now for (int k = 0; k < 6; k++) { strWriteOut.WriteLine(); } // Certification part if (flagBLM == 1) { for (int k = 0; k < 23; k++) { if (k == 3) { BLMcertification[k] = BLMcertification[k].Replace("XXXXXXXX", saleName); } strWriteOut.WriteLine(BLMcertification[k]); } // end for k loop } else { for (int k = 0; k < 17; k++) { if (k == 2) { cruiseCertification[k] = cruiseCertification[k].Replace("XXXXXXXX", saleName); } strWriteOut.WriteLine(cruiseCertification[k]); } // end for loop for certification } // endif // last portion for (int k = 0; k < 8; k++) { strWriteOut.WriteLine(); } strWriteOut.WriteLine(bannerFooter[0]); sb.Remove(0, sb.Length); sb.Append(bannerFooter[1]); sb.Append(currentVersion); strWriteOut.WriteLine(sb.ToString()); sb.Remove(0, sb.Length); sb.Append(bannerFooter[2]); sb.Append(DLLversion); strWriteOut.WriteLine(sb.ToString()); strWriteOut.WriteLine(bannerFooter[3]); } // end outputBannerPage
} // end LogError6 public static StringBuilder GetIdentifier(string tableName, long CNtoFind) { StringBuilder ident = new StringBuilder(); switch (tableName) { case "Sale": SaleDO sale = Global.BL.getSale().FirstOrDefault(sd => sd.Sale_CN == CNtoFind); if (sale != null) { ident.Append("Sale number = "); ident.Append(sale.SaleNumber); } else { ident.Append("Sale number not found"); } break; case "Stratum": StratumDO strat = Global.BL.getStratum().FirstOrDefault(sdo => sdo.Stratum_CN == CNtoFind); if (strat != null) { ident.Append(strat.Code); } else { ident.Append("Stratum code not found"); } break; case "Cutting Unit": CuttingUnitDO cudo = Global.BL.getCuttingUnits().FirstOrDefault(cu => cu.CuttingUnit_CN == CNtoFind); if (cudo != null) { ident.Append(" "); ident.Append(cudo.Code.PadLeft(3, ' ')); } else { ident.Append("Cutting unit not found"); } break; case "Tree": TreeDO tdo = Global.BL.getTrees().FirstOrDefault(td => td.Tree_CN == CNtoFind); if (tdo != null) { ident.Append(tdo.Stratum.Code.PadRight(3, ' ')); ident.Append(tdo.CuttingUnit.Code.PadLeft(3, ' ')); if (tdo.Plot == null) { ident.Append(" "); } else if (tdo.Plot_CN == 0) { ident.Append(" "); } else { ident.Append(tdo.Plot.PlotNumber.ToString().PadLeft(5, ' ')); } ident.Append(tdo.TreeNumber.ToString().PadLeft(5, ' ')); ident.Append(" --- "); if (tdo.Species == null) { ident.Append(" "); } else { ident.Append(tdo.Species.PadRight(7, ' ')); } if (tdo.SampleGroup == null) { ident.Append(" "); } else { if (tdo.SampleGroup.Code == "" || tdo.SampleGroup.Code == " " || tdo.SampleGroup.Code == "<Blank>" || tdo.SampleGroup.Code == null) { ident.Append(" "); } else { ident.Append(tdo.SampleGroup.Code.PadRight(3, ' ')); } ident.Append(tdo.SampleGroup.PrimaryProduct.PadRight(3, ' ')); } // endif } else { ident.Append("Tree not found"); } break; case "Log": LogDO log = Global.BL.getLogs().FirstOrDefault(ld => ld.Log_CN == CNtoFind); if (log != null) { ident.Append(log.Tree.Stratum.Code.PadRight(3, ' ')); ident.Append(log.Tree.CuttingUnit.Code.PadLeft(3, ' ')); if (log.Tree.Plot == null) { ident.Append(" "); } else { ident.Append(log.Tree.Plot.PlotNumber.ToString().PadLeft(5, ' ')); } ident.Append(log.Tree.TreeNumber.ToString().PadLeft(5, ' ')); ident.Append(log.LogNumber.PadLeft(3, ' ')); } else { ident.Append("Log not found"); } break; case "Volume Equation": if (CNtoFind == 0) { CNtoFind = 1; } //List<VolumeEquationDO> vList = Global.BL.getVolumeEquations(); VolumeEquationDO ve = Global.BL.getVolumeEquations().ElementAt((int)CNtoFind - 1); ident.Append("-- --- ---- ---- --- "); ident.Append(ve.Species.PadRight(7, ' ')); ident.Append("-- "); ident.Append(ve.PrimaryProduct.PadRight(3, ' ')); ident.Append(ve.VolumeEquationNumber.PadRight(10, ' ')); //ident.Append("-- --- ---- ---- --- "); //ident.Append(vList[(int)CNtoFind-1].Species.PadRight(7, ' ')); //ident.Append("-- "); //ident.Append(vList[(int)CNtoFind-1].PrimaryProduct.PadRight(3, ' ')); //ident.Append(vList[(int)CNtoFind-1].VolumeEquationNumber.PadRight(10,' ')); break; case "Value Equation": if (CNtoFind == 0) { CNtoFind = 1; } ValueEquationDO veq = Global.BL.getValueEquations().ElementAt((int)CNtoFind - 1); ident.Append("-- --- ---- ---- --- "); ident.Append(veq.Species.PadRight(7, ' ')); ident.Append("-- "); ident.Append(veq.PrimaryProduct.PadRight(3, ' ')); ident.Append(veq.ValueEquationNumber.PadRight(10, ' ')); //List<ValueEquationDO> veList = Global.BL.getValueEquations(); //ident.Append("-- --- ---- ---- --- "); //ident.Append(veList[(int)CNtoFind-1].Species.PadRight(7, ' ')); //ident.Append("-- "); //ident.Append(veList[(int)CNtoFind-1].PrimaryProduct.PadRight(3,' ')); //ident.Append(veList[(int)CNtoFind-1].ValueEquationNumber.PadRight(10,' ')); break; case "Quality Adjustment": if (CNtoFind == 0) { CNtoFind = 1; } QualityAdjEquationDO qe = Global.BL.getQualAdjEquations().ElementAt((int)CNtoFind - 1); ident.Append("-- --- ---- ---- --- "); ident.Append(qe.Species.PadRight(7, ' ')); ident.Append("-- -- "); ident.Append(qe.QualityAdjEq.PadRight(10, ' ')); //List<QualityAdjEquationDO> qList = Global.BL.getQualAdjEquations(); //ident.Append("-- --- ---- ---- --- "); //ident.Append(qList[(int)CNtoFind-1].Species.PadRight(7, ' ')); //ident.Append("-- -- "); //ident.Append(qList[(int)CNtoFind-1].QualityAdjEq.PadRight(10,' ')); break; case "SampleGroup": SampleGroupDO sg = Global.BL.getSampleGroups().FirstOrDefault(sgd => sgd.SampleGroup_CN == CNtoFind); if (sg != null) { ident.Append(sg.Stratum.Code.PadRight(3, ' ')); ident.Append("--- ---- ---- --- ------ "); ident.Append(sg.Code.PadRight(3, ' ')); ident.Append(sg.PrimaryProduct.PadRight(3, ' ')); } else { ident.Append("Sample Group not found"); } break; } // end switch return(ident); } // end GetIdentifier
public int setupDialog() { VolumeEqMethods Veq = new VolumeEqMethods(); // fill species list from tree table // show message box if this is BLM string currRegion = bslyr.getRegion(); if (currRegion == "7" || currRegion == "07") { MessageBox.Show("BLM Volume Equations cannot be entered here.", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return(-1); } // endif BLM // if there are volume equations, show in grid // if not, the grid is just initialized equationList = bslyr.getVolumeEquations(); // Check for missing common name and model name Veq.updateVolumeList(equationList, fileName, currRegion); string[,] speciesProduct; speciesProduct = bslyr.GetUniqueSpeciesProduct(); // pull species not used in the cruise from the equations list equationList = updateEquationList(speciesProduct); // If there are no species/products in tree default values, it's wrong // tell user to check the file design in CSM -- June 2013 if (speciesProduct.Length == 0) { MessageBox.Show("No species/product combinations found in Tree records.\nPlease enter tree records before continuing.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return(-1); } // endif // if equation list is empty, just fill in unique species and primary product if (equationList.Count == 0) { for (int k = 0; k < speciesProduct.GetLength(0); k++) { if (speciesProduct[k, 0] != "" && speciesProduct[k, 0] != null) { VolumeEquationDO ved = new VolumeEquationDO(); ved.Species = speciesProduct[k, 0]; ved.PrimaryProduct = speciesProduct[k, 1]; equationList.Add(ved); } // endif end of list } // end for k loop } else { // situation exists were a template file was made from an existing cruise and // additional species/product combinations were placed in tree default value // need to add those to the equationList so user can enter equation information // June 2013 for (int k = 0; k < speciesProduct.GetLength(0); k++) { if (speciesProduct[k, 0] != "" && speciesProduct[k, 0] != null) { // see if this combination is in the equationList int nthRow = equationList.FindIndex( delegate(VolumeEquationDO ved) { return(ved.Species == speciesProduct[k, 0] && ved.PrimaryProduct == speciesProduct[k, 1]); }); if (nthRow == -1) { // add the equation to the list so the user can enter equation information VolumeEquationDO v = new VolumeEquationDO(); v.Species = speciesProduct[k, 0]; v.PrimaryProduct = speciesProduct[k, 1]; equationList.Add(v); } // endif } // endif } // end for k loop } // endif list is empty volumeEquationDOBindingSource.DataSource = equationList; volumeEquationList.DataSource = volumeEquationDOBindingSource; // also add species and product to combo boxes at bottom ArrayList justSpecies = bslyr.GetJustSpecies("TreeDefaultValue"); for (int n = 0; n < justSpecies.Count; n++) { speciesList.Items.Add(justSpecies[n].ToString()); } ArrayList justProduct = bslyr.GetJustPrimaryProduct(); for (int n = 0; n < justProduct.Count; n++) { productList.Items.Add(justProduct[n].ToString()); } volRegion.Enabled = false; volForest.Enabled = false; volEquation.Enabled = false; speciesList.Enabled = false; productList.Enabled = false; return(1); } // end setupDialog
} // end onCellClick private void onInsertClick(object sender, EventArgs e) { // if any of the five fields at the bottom are blank, warn users before continuing if (templateFlag == 0) { if (selectedRegion == null || selectedForest == null || volEquation.SelectedItem == null || speciesList.SelectedItem == null || productList.SelectedItem == null) { MessageBox.Show("One or more items to insert cannot be blank.\nPlease correct.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else if (templateFlag == 1) { if (selectedRegion == null || selectedForest == null || volEquation.SelectedItem == null || templateSpecies.Text == null || templateProduct.Text == null) { MessageBox.Show("One or more items to insert cannot be blank.\nPlease correct.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (trackRow >= 0) { volumeEquationList.CurrentCell = volumeEquationList.Rows[trackRow].Cells[2]; //bool isNew = volumeEquationList.CurrentRow.IsNewRow; // debug statement volumeEquationList.EditMode = DataGridViewEditMode.EditOnEnter; } else if (trackRow == -1) { // means user didn't click a cell which could be the first row is being edited // so set trackRow to zero for first row trackRow = 0; } // endif trackRow if (trackRow < equationList.Count) { // must be a change equationList[trackRow].VolumeEquationNumber = volEquation.SelectedItem.ToString(); if (templateFlag == 0) { equationList[trackRow].Species = speciesList.SelectedItem.ToString(); equationList[trackRow].PrimaryProduct = productList.SelectedItem.ToString(); } else if (templateFlag == 1) { equationList[trackRow].Species = templateSpecies.Text.ToString(); equationList[trackRow].PrimaryProduct = templateProduct.Text.ToString(); } // endif templateFalg // common species name and model int nthRow = volList.FindIndex( delegate(VolEqList vel) { return(vel.vEquation == volEquation.SelectedItem.ToString() && vel.vForest == selectedForest); }); if (nthRow >= 0) { equationList[trackRow].CommonSpeciesName = volList[nthRow].vCommonName; equationList[trackRow].Model = volList[nthRow].vModelName; } // endif nthRow } else if (trackRow >= equationList.Count) { // it's a new record VolumeEquationDO ved = new VolumeEquationDO(); ved.VolumeEquationNumber = volEquation.SelectedItem.ToString(); int nthRow = volList.FindIndex( delegate(VolEqList vel) { return(vel.vEquation == ved.VolumeEquationNumber); }); if (nthRow >= 0) { ved.CommonSpeciesName = volList[nthRow].vCommonName; ved.Model = volList[nthRow].vModelName; } // endif nthRow if (templateFlag == 0) { ved.Species = speciesList.SelectedItem.ToString(); ved.PrimaryProduct = productList.SelectedItem.ToString(); } else if (templateFlag == 1) { ved.Species = templateSpecies.Text.ToString(); ved.PrimaryProduct = templateProduct.Text.ToString(); } // endif templateFlag equationList.Add(ved); } // endif trackRow volumeEquationDOBindingSource.ResetBindings(false); volumeEquationList.ClearSelection(); volumeEquationList.CurrentCell = volumeEquationList.Rows[trackRow].Cells[7]; volForest.Text = ""; volEquation.Text = ""; volRegion.Text = ""; volRegion.Enabled = false; volForest.Enabled = false; volEquation.Enabled = false; if (templateFlag == 0) { speciesList.Text = ""; productList.Text = ""; speciesList.Enabled = false; productList.Enabled = false; } else if (templateFlag == 1) { templateSpecies.Text = ""; templateProduct.Text = ""; templateSpecies.Enabled = false; templateProduct.Enabled = false; } // endif templateflag } // end onInsertClick
public DialogResult ShowDialog(VolumeEquationDO tdv) { this.VolumeEq = tdv; this._initialState.SetValues(tdv); return(this.ShowDialog()); }
public VolumeEquationDO ShowAddVolumeEq() { VolumeEquationDO newTDV = new VolumeEquationDO(ViewPresenter.ApplicationController.Database); return(this.ShowEditVolumeEq(newTDV)); }
} // end buildVolumeEquation private void buildClarkEquation(string currGeoCode, string currentSpecies, string currentProduct, int pulpwoodHeight) { StringBuilder sb = new StringBuilder(); secDIB = 0; sb.Append("8"); sb.Append(currGeoCode); // complete equation build and put in volList VolumeEquationDO vel = new VolumeEquationDO(); vel.Species = currentSpecies; vel.PrimaryProduct = currentProduct; vel.StumpHeight = 1; vel.TopDIBPrimary = 0; vel.TopDIBSecondary = 0; vel.CalcTotal = 0; vel.CalcBoard = 0; vel.CalcCubic = 0; vel.CalcCord = 0; vel.CalcTopwood = 0; if (calcBiomass.Checked == true) { vel.CalcBiomass = 1; } else { vel.CalcBiomass = 0; } vel.Trim = 0; vel.SegmentationLogic = 0; vel.MinLogLengthPrimary = 0; vel.MaxLogLengthPrimary = 0; vel.MinMerchLength = 0; // finish equation if (currentProduct == "01") { // Set sawtimber reference height 7 or 9 // pine species < 300 if (Convert.ToInt32(currentSpecies) < 300) { sb.Append("7"); } else { sb.Append("9"); // hardwoods } vel.CalcCubic = 1; // added per request from Gary Church vel.CalcBoard = 1; // topwood included? // find current species in topwoodStatus for (int j = 0; j < topwoodStatus.Length; j++) { if (topwoodStatus[j] == currentSpecies) { vel.CalcTopwood = 1; break; } // endif } // end for j loop } else if (currentProduct == "02") { // set pulpwood reference height 4 or 0 // based on selection from first window if (pulpwoodHeight == 0) { // 4 inch DOB for all species sb.Append("4"); } else if (pulpwoodHeight == 1) { // total height all species sb.Append("0"); } else if (pulpwoodHeight == 2) { // pine total height hardwood 4-inch dob if (Convert.ToInt32(currentSpecies) < 300) { sb.Append("0"); } else { sb.Append("4"); } } // endif vel.StumpHeight = Convert.ToSingle(0.5); vel.CalcCubic = 1; // added per request from Gary Church vel.CalcBoard = 1; } else if (currentProduct == "08") { // find any changed DIB for current species double DIBfound = findDIB(currentSpecies); vel.StumpHeight = Convert.ToSingle(0.5); vel.TopDIBPrimary = Convert.ToSingle(DIBfound); vel.TopDIBSecondary = Convert.ToSingle(secDIB); vel.CalcCubic = 1; vel.CalcTopwood = 1; // added per request from Gary Church vel.CalcBoard = 1; sb.Append("8"); } else { // any other product code such as 20 for biomass sb.Append("0"); vel.CalcCubic = 1; vel.CalcBoard = 1; } // endif currentProduct // add remaining components to equation sb.Append("CLKE"); // Fix species length if (currentSpecies.Length == 2) { sb.Append("0"); } else if (currentSpecies.Length == 1) { sb.Append("00"); } sb.Append(currentSpecies); vel.VolumeEquationNumber = sb.ToString(); volList.Add(vel); return; } // end buildClarkEquation
} // end buildClarkEquation private void buildNewClarkEquations(string currGeoCode, string currSpecies, string currProduct) { // For new Clark equations only // July 2017 StringBuilder sb = new StringBuilder(); secDIB = 0; sb.Append("8"); sb.Append(currGeoCode); sb.Append("1"); // complete equation and put in volList VolumeEquationDO vel = new VolumeEquationDO(); vel.Species = currSpecies; vel.PrimaryProduct = currProduct; vel.StumpHeight = 1; vel.TopDIBPrimary = 0; vel.TopDIBSecondary = 0; vel.CalcTotal = 0; vel.CalcBoard = 1; vel.CalcCubic = 1; vel.CalcCord = 0; vel.CalcTopwood = 0; if (calcBiomass.Checked == true) { vel.CalcBiomass = 1; } else { vel.CalcBiomass = 0; } // Finish equation // topwood included? for (int j = 0; j < topwoodStatus.Length; j++) { if (topwoodStatus[j] == currSpecies) { vel.CalcTopwood = 1; break; } // endif } // end for loop // Oct 2018 -- decision made that whatever DIB/DOB is ent // to the volume library is whatever user entered for those values. // set top dib values // if (Convert.ToInt32(currSpecies) < 300) // { // vel.TopDIBPrimary = 7; // vel.TopDIBSecondary = 4; // } // else // { // vel.TopDIBPrimary = 9; // vel.TopDIBSecondary = 4; // } // endif // find any changed DIB for current species // did user even use the top DOB button? if (DIBbySpecies != null) { double DIBfound = findDIB(currSpecies); vel.TopDIBPrimary = Convert.ToSingle(DIBfound); vel.TopDIBSecondary = Convert.ToSingle(secDIB); } // endif sb.Append("CLKE"); // fix species length if (currSpecies.Length == 2) { sb.Append("0"); } else if (currSpecies.Length == 1) { sb.Append("00"); } sb.Append(currSpecies); vel.VolumeEquationNumber = sb.ToString(); volList.Add(vel); return; } // buildNewClarkEquations