public void setupDialog() { // Initially, set default equations to whatever is in the volume equation table // if empty, set to Clark volList = bslyr.getVolumeEquations(); if (volList.Count > 0) { foreach (VolumeEquationDO vel in volList) { string firstEquation = vel.VolumeEquationNumber.ToString(); if (firstEquation.Substring(3, 3) == "DVE") { taperEquations.Checked = false; topDIB.Enabled = false; oldEquations.Checked = true; break; } // endif } // end foreach } else if (volList.Count == 0) { // Need to save equations before user can specify topwood // Remove all equations as they are rebuilt with either of these calls bslyr.SaveVolumeEquations(volList); if (taperEquations.Checked == true) { CreateEquations("900CLKE"); } else if (oldEquations.Checked == true) { CreateEquations("900DVEE"); } // Save equations bslyr.SaveVolumeEquations(volList); } // endif equations exist // load lists for topwood portion foreach (VolumeEquationDO vel in volList) { if (vel.PrimaryProduct == "01") { topwoodSpecies.Add(vel.Species); topwoodFlags.Add(vel.CalcTopwood); } // endif sawtimber } // end foreach loop return; } // end setupDialog
private void onFinished(object sender, EventArgs e) { // update list with current entry -- next or previous may not have been pushed updateList(); // and update volume list for saving updateVolumeList(); // save volume equation list bslyr.SaveVolumeEquations(vList); Close(); return; }
} // end onInsertClick private void onFinished(object sender, EventArgs e) { // make sure volume equation is not blank for any species/product and make sure at least one volume flag is checked int noEquation = 0; int noVolume = 0; foreach (VolumeEquationDO ved in equationList) { if ((ved.VolumeEquationNumber == "" || ved.VolumeEquationNumber == null) && (ved.Species != "" || ved.Species == null)) { noEquation = 1; } if (ved.CalcBoard == 0 && ved.CalcCubic == 0 && ved.CalcCord == 0) { noVolume = 1; } if (noEquation == 1 || noVolume == 1) { break; } } // end foreach loop if (noEquation == 1) { MessageBox.Show("One or more records have no volume equation.\nPlease correct now.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // endif no equation if (noVolume == 1) { MessageBox.Show("One or more records have no volume selected.\nPlease correct now.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // endif no volume // Otherwise, make sure user wants to save all entries DialogResult nResult = MessageBox.Show("Do you want to save changes?", "CONFIRMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (nResult == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; bslyr.SaveVolumeEquations(equationList); Cursor.Current = this.Cursor; } // endif int sumBiomassFlag = (int)equationList.Sum(eq => eq.CalcBiomass); if (sumBiomassFlag > 0) { // Load biomass information if biomass flag was checked // But if it's an edited template then capture region and forest // before updating biomass. March 2017 if (templateFlag == 1) { TemplateRegionForest trf = new TemplateRegionForest(); trf.ShowDialog(); updateBiomass(equationList, trf.currentRegion, trf.currentForest); } else { updateBiomass(equationList); } } else if (sumBiomassFlag == 0) { // remove all biomass equations bslyr.ClearBiomassEquations(); } // endif if (bslyr.DAL_V3 != null) { //on finish sync biomass and volume eq. bslyr.syncVolumeEquationToV3(); bslyr.syncBiomassEquationToV3(); }//end if Close(); return; } // end onFinished
} // end onTopwoodClick private void onOK(object sender, EventArgs e) { // open volume equation table and remove all before building and saving equations bslyr.deleteVolumeEquations(); volList.Clear(); // Need to build volume equation and store in table, so goes into VolumeEqList string currentForest = ""; string currentDistrict = ""; string currGeoCode = ""; string currGrpCode = ""; List <SaleDO> saleList = bslyr.getSale(); foreach (SaleDO sd in saleList) { 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 = bslyr.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 bslyr.SaveVolumeEquations(volList); if (calcBiomass.Checked == true) { VolumeEquations ve = new VolumeEquations(); ve.bslyr.fileName = fileName; ve.fileName = fileName; ve.bslyr.DAL = bslyr.DAL; ve.updateBiomass(volList); } // endif calculate biomass Close(); return; } // end onOK