Пример #1
0
        public int setupDialog()
        {
            //  if there are value equations, show in grid
            //  if not, just initialize the grid
            valList = bslyr.getValueEquations();
            valueEquationDOBindingSource.DataSource = valList;
            valueEquationList.DataSource            = valueEquationDOBindingSource;

            //  need unique species and product
            List <TreeDefaultValueDO> tdvList = bslyr.GetUniqueSpeciesProductLiveDead();

            if (valList.Count == 0)
            {
                foreach (TreeDefaultValueDO tdv in tdvList)
                {
                    ValueEquationDO ved = new ValueEquationDO();
                    ved.Species        = tdv.Species;
                    ved.PrimaryProduct = tdv.PrimaryProduct;
                    valList.Add(ved);
                } //  end foreach loop
                valueEquationDOBindingSource.ResetBindings(false);
            }     //  endif list is empty

            //  Fill lists at bottom with unique species and primary products
            ArrayList justSpecies = bslyr.GetJustSpecies("Tree");

            for (int n = 0; n < justSpecies.Count; n++)
            {
                speciesList.Items.Add(justSpecies[n].ToString());
            }

            //  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 (justSpecies.Count == 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

            ArrayList justProducts = bslyr.GetJustPrimaryProduct();

            for (int n = 0; n < justProducts.Count; n++)
            {
                primaryProdList.Items.Add(justProducts[n].ToString());
            }

            regionNum.Enabled       = false;
            equationNumber.Enabled  = false;
            speciesList.Enabled     = false;
            primaryProdList.Enabled = false;
            return(1);
        }   //  end setupDialog
Пример #2
0
        }         //  end CheckEquations

        public static List <string> buildPrintArray(ValueEquationDO val)
        {
            StringBuilder sb          = new StringBuilder();
            string        fieldFormat = "{0,11:F7}";;
            var           valArray    = new List <string>();

            valArray.Add(" ");
            valArray.Add(val.Species.PadRight(6, ' '));
            valArray.Add(val.PrimaryProduct.PadLeft(2, '0'));
            valArray.Add(val.Grade);
            valArray.Add(val.ValueEquationNumber);

            //  coefficients
            valArray.Add(String.Format(fieldFormat, val.Coefficient1));
            valArray.Add(String.Format(fieldFormat, val.Coefficient2));
            valArray.Add(String.Format(fieldFormat, val.Coefficient3));
            valArray.Add(String.Format(fieldFormat, val.Coefficient4));
            valArray.Add(String.Format(fieldFormat, val.Coefficient5));
            valArray.Add(String.Format(fieldFormat, val.Coefficient6));
            return(valArray);
        }   //  end buildPrintArray
Пример #3
0
        }         //  end CheckEquations

        public static ArrayList buildPrintArray(ValueEquationDO val)
        {
            StringBuilder sb          = new StringBuilder();
            string        fieldFormat = "{0,11:F7}";;
            ArrayList     valArray    = new ArrayList();

            valArray.Add(" ");
            valArray.Add(val.Species.PadRight(6, ' '));
            valArray.Add(val.PrimaryProduct.PadLeft(2, '0'));
            valArray.Add(val.Grade);
            valArray.Add(val.ValueEquationNumber);

            //  coefficients
            valArray.Add(Utilities.FormatField(val.Coefficient1, fieldFormat).ToString());
            valArray.Add(Utilities.FormatField(val.Coefficient2, fieldFormat).ToString());
            valArray.Add(Utilities.FormatField(val.Coefficient3, fieldFormat).ToString());
            valArray.Add(Utilities.FormatField(val.Coefficient4, fieldFormat).ToString());
            valArray.Add(Utilities.FormatField(val.Coefficient5, fieldFormat).ToString());
            valArray.Add(Utilities.FormatField(val.Coefficient6, fieldFormat).ToString());
            return(valArray);
        }   //  end buildPrintArray
Пример #4
0
        }     //  end onCellClick

        private void onInsertEquation(object sender, EventArgs e)
        {
            if (trackRow >= 0)
            {
                valueEquationList.CurrentCell = valueEquationList.Rows[trackRow].Cells[2];
                //bool isNew = valueEquationList.CurrentRow.IsNewRow;
                valueEquationList.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 < valList.Count)
            {
                //  must be a change
                valList[trackRow].ValueEquationNumber = equationNumber.SelectedItem.ToString();
                valList[trackRow].Species             = speciesList.SelectedItem.ToString();
                valList[trackRow].PrimaryProduct      = primaryProdList.SelectedItem.ToString();
            }
            else if (trackRow >= valList.Count)
            {
                //  it's a new record
                ValueEquationDO ved = new ValueEquationDO();
                ved.ValueEquationNumber = equationNumber.SelectedItem.ToString();
                ved.Species             = speciesList.SelectedItem.ToString();
                ved.PrimaryProduct      = primaryProdList.SelectedItem.ToString();
                valList.Add(ved);
            }
            valueEquationDOBindingSource.ResetBindings(false);

            valueEquationList.ClearSelection();
            valueEquationList.CurrentCell = valueEquationList.Rows[trackRow].Cells[5];

            regionNum.Enabled       = false;
            equationNumber.Enabled  = false;
            speciesList.Enabled     = false;
            primaryProdList.Enabled = false;
        }   //  end onInsertEquation
Пример #5
0
        }   //  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