public static bool ValidateSetup(SampleGroupDO sg, StratumDO st, out string error) { bool isValid = true; error = null; sg.Validate(); string pre = "Stratum: " + st.Code + " IN SG: " + sg.Code + " -"; if (sg.HasErrors()) { isValid = false; error += pre + sg.Error; } if (String.IsNullOrEmpty(sg.Code)) { isValid = false; error += pre + " Code can't be empty"; } if (sg.TreeDefaultValues.Count == 0) { isValid = false; error += pre + " No Tree Defaults Selected"; } isValid = sg.ValidatePProdOnTDVs(ref error) && isValid; return(isValid); }
public static void RecutsiveDeleteSampleGroup(SampleGroupDO sg) { var db = sg.DAL; if (db == null) { return; } db.BeginTransaction(); try { string command = String.Format(@" DELETE FROM Log WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM LogStock WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM TreeCalculatedValues WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM Tree WHERE SampleGroup_CN = {0}; DELETE FROM TreeEstimate WHERE CountTree_CN IN (SELECT CountTree_CN FROM CountTree WHERE SampleGroup_CN = {0}); DELETE FROM CountTree WHERE SampleGroup_CN = {0}; DELETE FROM SampleGroupTreeDefaultValue WHERE SampleGroup_CN = {0}; DELETE FROM FixCNTTallyPopulation WHERE SampleGroup_CN = {0}; DELETE FROM SamplerState WHERE SampleGroup_CN = {0};", sg.SampleGroup_CN); db.Execute(command); sg.Delete(); db.CommitTransaction(); } catch (Exception e) { db.RollbackTransaction(); throw e; } }
//************************************************************************* public int getInsuranceTrees(SampleGroupDO currentSg) { int insTrees; myTrees = new List<TreeDO>(cdDAL.Read<TreeDO>("Tree", "Where SampleGroup_CN = ? AND CountOrMeasure = ?", currentSg.SampleGroup_CN, "I")); insTrees = myTrees.Count(); return (insTrees); }
protected void OnSampleGroupChanging(SGType newSG, SGType prevSG) { Cursor.Current = Cursors.WaitCursor; if (prevSG != null)//check previous Sg { this.SaveTDVChanges(); } this.BuildTDVList(newSG); this._addTDV_BTN.Enabled = newSG != null; Cursor.Current = Cursors.Default; }
public override TreeDefaultValueDO ShowAddPopulation(SampleGroupDO sg) { if (this.ApplicationController._cDal == null) { MessageBox.Show("No File Selected"); return null; } using (FormAddPopulation view = new FormAddPopulation(this.ApplicationController)) { Cursor.Current = Cursors.WaitCursor; view.ShowDialog(sg); return null; } }
public DialogResult ShowDialog(SGType sg) { this.SampleGroup = sg; this._sgInfo_LBL.Text = this.SampleGroup.Code + "-" + this.SampleGroup.TallyMethod.ToString(); if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.BySampleGroup) == CruiseDAL.Enums.TallyMode.BySampleGroup) { this._species_LBL.Visible = false; this._speciesSelect_CB.Visible = false; TallyDO t = this.Controller.DataStore.From <TallyDO>() .Join("CountTree", "USING (Tally_CN)") .Where("SampleGroup_CN = ?") .Read(sg.SampleGroup_CN).FirstOrDefault(); if (t == null) { t = new TallyDO(this.Controller.DataStore); t.Description = sg.Code; } this.Tally = t; } else if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.BySpecies) == CruiseDAL.Enums.TallyMode.BySpecies) { this._species_LBL.Visible = true; this._speciesSelect_CB.Visible = true; this._speciesSelect_CB.DisplayMember = "Species"; this._speciesSelect_CB.ValueMember = "Tag"; foreach (TreeDefaultValueDO tdv in sg.TreeDefaultValues) { TallyDO t = this.Controller.DataStore.From <TallyDO>() .Join("CountTree", "USING (Tally_CN)") .Where("SampleGroup_CN = ? and TreeDefaultValue_CN = ?") .Read(sg.SampleGroup_CN, tdv.TreeDefaultValue_CN).FirstOrDefault(); if (t == null) { t = new TallyDO(this.Controller.DataStore); t.Description = tdv.Species; } tdv.Tag = t; } this._speciesSelect_CB.DataSource = sg.TreeDefaultValues; } else { } return(this.ShowDialog()); }
public DialogResult ShowDialog(SGType sg) { this.SampleGroup = sg; this._sgInfo_LBL.Text = this.SampleGroup.Code + "-" + this.SampleGroup.TallyMethod.ToString(); if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.BySampleGroup) == CruiseDAL.Enums.TallyMode.BySampleGroup) { this._species_LBL.Visible = false; this._speciesSelect_CB.Visible = false; TallyDO t = this.Controller._cDal.From<TallyDO>() .Join("CountTree", "USING (Tally_CN)") .Where("SampleGroup_CN = ?") .Read(sg.SampleGroup_CN).FirstOrDefault(); if (t == null) { t = new TallyDO(this.Controller._cDal); t.Description = sg.Code; } this.Tally = t; } else if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.BySpecies) == CruiseDAL.Enums.TallyMode.BySpecies) { this._species_LBL.Visible = true; this._speciesSelect_CB.Visible = true; this._speciesSelect_CB.DisplayMember = "Species"; this._speciesSelect_CB.ValueMember = "Tag"; foreach (TreeDefaultValueDO tdv in sg.TreeDefaultValues) { TallyDO t = this.Controller._cDal.From<TallyDO>() .Join("CountTree", "USING (Tally_CN)") .Where("SampleGroup_CN = ? and TreeDefaultValue_CN = ?") .Read(sg.SampleGroup_CN, tdv.TreeDefaultValue_CN).FirstOrDefault(); if (t == null) { t = new TallyDO(this.Controller._cDal); t.Description = tdv.Species; } tdv.Tag = t; } this._speciesSelect_CB.DataSource = sg.TreeDefaultValues; } else { } return this.ShowDialog(); }
public void ReadCountsTest() { IWindowPresenter wp = new WindowPresenterStub() { Database = new CruiseDAL.DAL(readTestFile) }; PrivateObject param0 = new PrivateObject( new DataEditorView(wp)); DataEditorView_Accessor target = new DataEditorView_Accessor(param0); CuttingUnitDO cu = new CuttingUnitDO() { rowID = 1 }; StratumDO st = new StratumDO() { rowID = 1 }; SampleGroupDO sg = new SampleGroupDO() { rowID = 1 }; List<CountTreeDO> expected = null; // TODO: Initialize to an appropriate value List<CountTreeDO> actual; actual = target.ReadCounts(cu, st, sg); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public DialogResult ShowDialog(SampleGroupDO sampleGroup, bool allowEdit) { bool isNew = !sampleGroup.IsPersisted; this.SampleGroup = sampleGroup; this.AllowEdit = allowEdit; //TODO insted of reseting values from initial state could just reread from database this._initialState.SetValues(sampleGroup); if (isNew) { this.Text = "New Sample Group"; } else if (allowEdit) { this.Text = "Edit Sample Group"; } else { this.Text = "View Sample Group"; } if ((this.SampleGroup.TallyMethod & CruiseDAL.Enums.TallyMode.BySampleGroup) == CruiseDAL.Enums.TallyMode.BySampleGroup) { this._tallyBySg_RB.Checked = true; } else if ((this.SampleGroup.TallyMethod & CruiseDAL.Enums.TallyMode.BySpecies) == CruiseDAL.Enums.TallyMode.BySpecies) { this._tallyBySpecies_RB.Checked = true; } this._systematicOpt_ChB.Checked = (sampleGroup.SampleSelectorType == CruiseDAL.Schema.CruiseMethods.SYSTEMATIC_SAMPLER_TYPE); this._systematicOpt_ChB.Enabled = this._tallyBySg_RB.Enabled = this._tallyBySpecies_RB.Enabled = CanEditTallyMode(sampleGroup); //if (isNew || allowEdit) //{ // StratumDO st = sampleGroup.Stratum; // this._bigBaf_TB.Enabled = SampleGroupDO.CanEnableBigBAF(st); // this._samplingFreq_TB = SampleGroupDO.CanEnableFrequency(st); // this._insuranceFreq_TB.Enabled = SampleGroupDO.CanEnableIFreq(st); // this._kz_TB.Enabled = SampleGroupDO.CanEnableKZ(st); //} return base.ShowDialog(); }
public SampleGroupDO GetNewSampleGroup(StratumDO stratum, SampleGroupDO newSampleGroup) { if (newSampleGroup == null) { newSampleGroup = new SampleGroupDO(this._database); } newSampleGroup.CutLeave = "C"; newSampleGroup.DefaultLiveDead = "L"; newSampleGroup.Code = "<Blank>"; newSampleGroup.Stratum = stratum; if (stratum.Method == CruiseDAL.Schema.CruiseMethods.FIXCNT) { newSampleGroup.UOM = "03"; } else { newSampleGroup.UOM = Sale.DefaultUOM; } return newSampleGroup; }
public void DeleteSampleGroup(SampleGroupDO sg) { if (sg.IsPersisted) { SampleGroupDO.RecutsiveDeleteSampleGroup(sg); } }
private void copyPopulations(DAL cDAL, DAL rDAL, DAL fsDAL, bool reconData, string[] stRecCode) { TreeDefaultValueDO currentTDV = new TreeDefaultValueDO(); List<StratumStatsDO> cdStratumStats = new List<StratumStatsDO>(cDAL.Read<StratumStatsDO>("StratumStats", "JOIN Stratum ON StratumStats.Stratum_CN = Stratum.Stratum_CN AND StratumStats.Method = Stratum.Method AND StratumStats.Used = 1 ORDER BY Stratum.Code", null)); List<PlotDO> myPlots = new List<PlotDO>(); List<TreeDO> myTree = new List<TreeDO>(); BindingList<TreeFieldSetupDO> treeFields = new BindingList<TreeFieldSetupDO>(); bool first; string method = ""; foreach (StratumStatsDO myStStats in cdStratumStats) { setRecData = false; first = true; // check if recon data is to be saved if (reconData) { string strCode = myStStats.Code; if (myStStats.Method == "PNT" || myStStats.Method == "PCM") method = "PNT"; else if (myStStats.Method == "FIX" || myStStats.Method == "FCM") method = "FIX"; foreach (string stRec in stRecCode) { if (stRec == strCode) { setRecData = true; myPlots = (rDAL.Read<PlotDO>("Plot", "JOIN Stratum ON Plot.Stratum_CN = Stratum.Stratum_CN WHERE Stratum.Method = ?", method)); if(myTree.Count == 0) myTree = (rDAL.Read<TreeDO>("Tree", null, null)); } } } // get fsDAl stratum record List<SampleGroupStatsDO> mySgStats = new List<SampleGroupStatsDO>(cDAL.Read<SampleGroupStatsDO>("SampleGroupStats", "Where StratumStats_CN = ?", myStStats.StratumStats_CN)); // loop through sample groups foreach (SampleGroupStatsDO sgStats in mySgStats) { SampleGroupDO fsSg = new SampleGroupDO(fsDAL); // save sample group information fsSg.Stratum_CN = sgStats.StratumStats.Stratum_CN; fsSg.Code = sgStats.Code; fsSg.Description = sgStats.Description; fsSg.CutLeave = sgStats.CutLeave; fsSg.UOM = sgStats.UOM; fsSg.PrimaryProduct = sgStats.PrimaryProduct; fsSg.SecondaryProduct = sgStats.SecondaryProduct; fsSg.DefaultLiveDead = sgStats.DefaultLiveDead; fsSg.KZ = sgStats.KZ; fsSg.InsuranceFrequency = sgStats.InsuranceFrequency; if (myStStats.Method == "PCM" || myStStats.Method == "FCM") { if (checkBoxFreq.Checked) { fsSg.SamplingFrequency = sgStats.SamplingFrequency; fsSg.BigBAF = 0; } else { fsSg.SamplingFrequency = 0; fsSg.BigBAF = Convert.ToInt32(sgStats.BigBAF); } } else { fsSg.SamplingFrequency = sgStats.SamplingFrequency; fsSg.BigBAF = Convert.ToInt32(sgStats.BigBAF); } // find treedefaultvalues sgStats.TreeDefaultValueStats.Populate(); foreach (TreeDefaultValueDO tdv in sgStats.TreeDefaultValueStats) { fsSg.TreeDefaultValues.Add(tdv); } fsSg.Save(); fsSg.TreeDefaultValues.Save(); // if recon can be saved if (setRecData) { getReconData(myStStats, sgStats, rDAL, fsDAL, myPlots, myTree, fsSg.SampleGroup_CN, first); // get plot data first = false; // get tree data // get log data } } //select from TreeFieldSetupDefault where method = stratum.method List<TreeFieldSetupDefaultDO> treeFieldDefaults = new List<TreeFieldSetupDefaultDO>(cDAL.Read < TreeFieldSetupDefaultDO >("TreeFieldSetupDefault", "WHERE Method = ? ORDER BY FieldOrder", myStStats.Method)); foreach (TreeFieldSetupDefaultDO tfd in treeFieldDefaults) { TreeFieldSetupDO tfs = new TreeFieldSetupDO(); tfs.Stratum_CN = myStStats.Stratum_CN; tfs.Field = tfd.Field; tfs.FieldOrder = tfd.FieldOrder; tfs.ColumnType = tfd.ColumnType; tfs.Heading = tfd.Heading; tfs.Width = tfd.Width; tfs.Format = tfd.Format; tfs.Behavior = tfd.Behavior; treeFields.Add(tfs); } } fsDAL.Save(treeFields); }
public SampleGroupDO(SampleGroupDO obj) : this() { SetValues(obj); }
void OnStratumFilterChanged() { if (this.DesignMode == true) { return; } //if all stratum selected if (StratumFilter == null) { //read all cutting units this.CuttingUnits = Database.Read<CuttingUnitDO>("CuttingUnit", null, null); //and disable ability to select samplegroup or tree default _sampleGroupFilter = ANY_OPTION_SAMPLEGROUP; _treeDefaultValueFilter = ANY_OPTION_TREEDEFAULT; CanSelectSampleGroup = false; CanSelectTreeDefaultValue = false; } else { //load cutting unit selection list with all cutting units in stratum if (StratumFilter.CuttingUnits.IsPopulated == false) { StratumFilter.CuttingUnits.Populate(); } this.CuttingUnits = StratumFilter.CuttingUnits.ToList(); //load sample group selection list with all sample groups in stratum this.SampleGroups = Database.Read<SampleGroupDO>("SampleGroup", "WHERE Stratum_CN = ?", StratumFilter.Stratum_CN.ToString()); //and enable ability to select sample group and tree default CanSelectSampleGroup = true; CanSelectTreeDefaultValue = true; } }
//public TreeDefaultValueDO CheckForExistingRecord(TreeDefaultValueDO tdv) //{ // CruiseDAL.DAL db = tdv.DAL; // TreeDefaultValueDO tdv2 = db.ReadSingleRow<TreeDefaultValueDO>(CruiseDAL.Schema.TREEDEFAULTVALUE._NAME, "WHERE Species = ? and LiveDead = ? and Chargeable = ? and PrimaryProduct = ?", tdv.Species, tdv.LiveDead, tdv.Chargeable, tdv.PrimaryProduct); // return (tdv2 != null) ? tdv2 : tdv; //} private void CreateCountRecord(SGType sg, TreeDefaultValueDO tdv) { }
public static bool ValidateSetup(SampleGroupDO sg, StratumDO st, out string error) { bool isValid = true; error = null; sg.Validate(); string pre = "Stratum: " + st.Code + " IN SG: " + sg.Code + " -"; if (sg.HasErrors()) { isValid = false; error += pre + sg.Error; } if (String.IsNullOrEmpty(sg.Code)) { isValid = false; error += pre + " Code can't be empty"; } if (sg.TreeDefaultValues.Count == 0) { isValid = false; error += pre + " No Tree Defaults Selected"; } isValid = sg.ValidatePProdOnTDVs(ref error) && isValid; return isValid; }
public void ReadTreesTest() { IWindowPresenter wp = new WindowPresenterStub() { Database = new CruiseDAL.DAL(readTestFile) }; PrivateObject param0 = new PrivateObject(new DataEditorView(wp)); DataEditorView_Accessor target = new DataEditorView_Accessor(param0); CuttingUnitDO cu = new CuttingUnitDO() { rowID = 1 }; StratumDO st = new StratumDO() { rowID = 1 }; SampleGroupDO sg = new SampleGroupDO() { rowID = 1 }; TreeDefaultValueDO tdv = new TreeDefaultValueDO() { rowID = 1 }; List<TreeVM> actual; actual = target.ReadTrees(cu, st, sg, tdv); Assert.IsNotNull(actual); Assert.IsTrue(actual.Count > 0); }
public static bool CanChangeSamplerType(SampleGroupDO sg) { return String.IsNullOrEmpty(sg.SampleSelectorState); }
public override DialogResult ShowEditSampleGroup(SampleGroupDO sg, bool allowEdit) { using (FormEditSampleGroup view = new FormEditSampleGroup()) { return view.ShowDialog(sg, allowEdit); } }
public static void RecutsiveDeleteSampleGroup(SampleGroupDO sg) { var db = sg.DAL; if (db == null) { return; } db.BeginTransaction(); try { string command = String.Format(@" DELETE FROM Log WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM LogStock WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM TreeCalculatedValues WHERE Tree_CN IN (SELECT Tree_CN FROM Tree WHERE Tree.SampleGroup_CN = {0}); DELETE FROM Tree WHERE SampleGroup_CN = {0}; DELETE FROM TreeEstimate WHERE CountTree_CN IN (SELECT CountTree_CN FROM CountTree WHERE SampleGroup_CN = {0}); DELETE FROM CountTree WHERE SampleGroup_CN = {0}; DELETE FROM SampleGroupTreeDefaultValue WHERE SampleGroup_CN = {0};", sg.SampleGroup_CN); db.Execute(command); sg.Delete(); db.CommitTransaction(); } catch (Exception e) { db.RollbackTransaction(); throw e; } }
public static bool CanChangeSamplerType(SampleGroupDO sg) { return(String.IsNullOrEmpty(sg.SampleSelectorState)); }
private static bool CanEditTallyMode(SampleGroupDO sg) { if (!StratumDO.CanDefineTallys(sg.Stratum)) { return false; } if (sg.DAL != null && sg.IsPersisted) { if (sg.DAL.GetRowCount("Tree", "WHERE SampleGroup_CN = ?", sg.SampleGroup_CN) > 0) { return false; } else if (sg.DAL.GetRowCount("CountTree", "WHERE SampleGroup_CN = ? AND TreeCount > 0", sg.SampleGroup_CN) > 0) { return false; } } return true; }
private void copyPopulations(DAL cDAL, DAL rDAL, DAL fsDAL, bool reconData, string[] stRecCode) { StratumDO cdStr; TreeDefaultValueDO currentTDV = new TreeDefaultValueDO(); List<StratumStatsDO> cdStratumStats = new List<StratumStatsDO>(cDAL.Read<StratumStatsDO>("StratumStats", "JOIN Stratum ON StratumStats.Stratum_CN = Stratum.Stratum_CN AND StratumStats.Method = Stratum.Method AND StratumStats.Used = 1 ORDER BY Stratum.Code", null)); List<PlotDO> myPlots = new List<PlotDO>(); List<TreeDO> myTree = new List<TreeDO>(); List<LogDO> myLogs = new List<LogDO>(); treeFields = new BindingList<TreeFieldSetupDO>(); logFields = new BindingList<LogFieldSetupDO>(); bool first; string method = ""; Random rnd = new Random(); int measHit; foreach (StratumStatsDO myStStats in cdStratumStats) { setRecData = false; first = true; // check if recon data is to be saved cdStr = fsDAL.ReadSingleRow<StratumDO>("Stratum", "Where Code = ?", myStStats.Code); string strCode = myStStats.Code; thisStrCN = (long)cdStr.Stratum_CN; if (reconData) { if (myStStats.Method == "PNT" || myStStats.Method == "PCM") method = "PNT"; else if (myStStats.Method == "FIX" || myStStats.Method == "FCM") method = "FIX"; foreach (string stRec in stRecCode) { if (stRec == strCode) { setRecData = true; myPlots = (rDAL.Read<PlotDO>("Plot", "JOIN Stratum ON Plot.Stratum_CN = Stratum.Stratum_CN WHERE Stratum.Method = ?", method)); if(myTree.Count == 0) { myTree = (rDAL.Read<TreeDO>("Tree", null, null)); myLogs = (rDAL.Read<LogDO>("Log", null, null)); } } } } // get fsDAl stratum record List<SampleGroupStatsDO> mySgStats = new List<SampleGroupStatsDO>(cDAL.Read<SampleGroupStatsDO>("SampleGroupStats", "Where StratumStats_CN = ?", myStStats.StratumStats_CN)); // loop through sample groups foreach (SampleGroupStatsDO sgStats in mySgStats) { measHit = 0; SampleGroupDO fsSg = new SampleGroupDO(fsDAL); // save sample group information fsSg.Stratum_CN = thisStrCN; fsSg.Code = sgStats.Code; fsSg.Description = sgStats.Description; fsSg.CutLeave = sgStats.CutLeave; fsSg.UOM = sgStats.UOM; fsSg.PrimaryProduct = sgStats.PrimaryProduct; fsSg.SecondaryProduct = sgStats.SecondaryProduct; fsSg.DefaultLiveDead = sgStats.DefaultLiveDead; fsSg.KZ = sgStats.KZ; fsSg.InsuranceFrequency = sgStats.InsuranceFrequency; if (myStStats.Method == "PCM" || myStStats.Method == "FCM") { if (radioButton1.Checked) { fsSg.SamplingFrequency = sgStats.SamplingFrequency; // find random start int freq = (int)fsSg.SamplingFrequency; measHit = rnd.Next(1, freq); fsSg.BigBAF = 0; fsSg.SmallFPS = 0; } else { fsSg.SamplingFrequency = 0; fsSg.BigBAF = Convert.ToInt32(sgStats.BigBAF); fsSg.SmallFPS = Convert.ToInt32(sgStats.BigFIX); } } else { fsSg.SamplingFrequency = sgStats.SamplingFrequency; fsSg.BigBAF = 0; fsSg.SmallFPS = 0; } // find treedefaultvalues sgStats.TreeDefaultValueStats.Populate(); foreach (TreeDefaultValueDO tdv in sgStats.TreeDefaultValueStats) { fsSg.TreeDefaultValues.Add(tdv); } fsSg.Save(); fsSg.TreeDefaultValues.Save(); // if recon can be saved if (setRecData) { getReconData(myStStats, sgStats, rDAL, fsDAL, myPlots, myTree, myLogs, fsSg.SampleGroup_CN, first, measHit); first = false; } } getTreeFieldSetup(cDAL,fsDAL,myStStats); if(logData) getLogFieldSetup(cDAL,fsDAL,myStStats); } }
public SampleGroupDO CreateNewSampleGroup(StratumDO stratum) { SampleGroupDO newSG = new SampleGroupDO(); newSG.DAL = this._cDal; newSG.Stratum = stratum; newSG.UOM = this._cDal.ExecuteScalar("Select DefaultUOM FROM Sale;") as String; //newSG.UOM = this._cDal.ReadSingleRow<SaleDO>("Sale", false, null).DefaultUOM; if (this.ViewController.ShowEditSampleGroup(newSG, true) == DialogResult.OK) { return newSG; } else { return null; } }
public DialogResult ShowDialog(SGType sg) { this.SampleGroup = sg; return base.ShowDialog(); }
private void ResetViewFilters() { _CuttingUnitFilter = ANY_OPTION_CUTTINGUNIT; _stratumFilter = ANY_OPTION_STRATUM; _sampleGroupFilter = ANY_OPTION_SAMPLEGROUP; _treeDefaultValueFilter = ANY_OPTION_TREEDEFAULT; OnCuttingUnitFilterChanged(); OnStratumFilterChanged(); PopulateData(); }
private void BuildTDVList(SampleGroupDO sg) { this._speciesSelectPanel.SuspendLayout(); this._speciesSelectPanel.Controls.Clear(); if (sg != null) { List<TreeDefaultValueDO> treeDefaults = this.Controller._cDal.From<TreeDefaultValueDO>() .Where("PrimaryProduct = ?") .Read(sg.PrimaryProduct).ToList(); foreach (TreeDefaultValueDO tdv in treeDefaults) { CheckBox cb = new CheckBox(); cb.Dock = DockStyle.Top; cb.Text = String.Format("{0}-{1}", tdv.Species, tdv.LiveDead); sg.TreeDefaultValues.Populate(); if (sg.TreeDefaultValues.Contains(tdv)) { cb.Checked = true; } cb.Tag = tdv; this._speciesSelectPanel.Controls.Add(cb); } } this._speciesSelectPanel.ResumeLayout(); }
public DialogResult ShowDialog(SGType sg) { this.SampleGroup = sg; return(base.ShowDialog()); }
protected List<TreeVM> ReadTrees(CuttingUnitDO cu, StratumDO st, SampleGroupDO sg, TreeDefaultValueDO tdv) { var selectionList = new List<string>(); var selectionArgs = new List<string>(); if (cu != null) { selectionList.Add(CruiseDAL.Schema.TREE.CUTTINGUNIT_CN + " = ?"); selectionArgs.Add(cu.CuttingUnit_CN.ToString()); } if (st != null) { selectionList.Add("Tree." + CruiseDAL.Schema.TREE.STRATUM_CN + " = ?"); selectionArgs.Add(st.Stratum_CN.ToString()); } if (sg != null) { selectionList.Add(CruiseDAL.Schema.TREE.SAMPLEGROUP_CN + " = ?"); selectionArgs.Add(sg.SampleGroup_CN.ToString()); } if (tdv != null) { selectionList.Add(CruiseDAL.Schema.TREE.TREEDEFAULTVALUE_CN + " = ?"); selectionArgs.Add(tdv.TreeDefaultValue_CN.ToString()); } if (selectionList.Count > 0) { String selection = "WHERE " + String.Join(" AND ", selectionList.ToArray()); return Database.Read<TreeVM>(CruiseDAL.Schema.TREE._NAME, selection + " ORDER BY TreeNumber, Plot_CN", selectionArgs.ToArray()); } else { return Database.Read<TreeVM>(CruiseDAL.Schema.TREE._NAME, "ORDER BY TreeNumber, Plot_CN", null); } }
public bool HandleSampleGroupChanging(SampleGroupDO newSG, IView view) { if (newSG == null) { return false; } if (SampleGroup != null && SampleGroup.SampleGroup_CN == newSG.SampleGroup_CN) { return true; } if (SampleGroup != null) { if (!view.AskYesNo("You are changing the Sample Group of a tree, are you sure you want to do this?" , "!" , System.Windows.Forms.MessageBoxIcon.Asterisk , true)) { return false; } else { DAL.LogMessage(String.Format("Tree Sample Group Changed (Cu:{0} St:{1} Sg:{2} -> {3} Tdv_CN:{4} T#: {5}", CuttingUnit.Code, Stratum.Code, (SampleGroup != null) ? SampleGroup.Code : "?", newSG.Code, (TreeDefaultValue != null) ? TreeDefaultValue.TreeDefaultValue_CN.ToString() : "?", TreeNumber), "high"); return true; } } else { return true; } }
public override DialogResult ShowEditSampleGroup(SampleGroupDO sg, bool allowEdit) { throw new NotImplementedException(); }
public void SetValues(SampleGroupDO obj) { if(obj == null) { return; } Code = obj.Code; CutLeave = obj.CutLeave; UOM = obj.UOM; PrimaryProduct = obj.PrimaryProduct; SecondaryProduct = obj.SecondaryProduct; BiomassProduct = obj.BiomassProduct; DefaultLiveDead = obj.DefaultLiveDead; SamplingFrequency = obj.SamplingFrequency; InsuranceFrequency = obj.InsuranceFrequency; KZ = obj.KZ; BigBAF = obj.BigBAF; SmallFPS = obj.SmallFPS; TallyMethod = obj.TallyMethod; Description = obj.Description; SampleSelectorType = obj.SampleSelectorType; SampleSelectorState = obj.SampleSelectorState; MinKPI = obj.MinKPI; MaxKPI = obj.MaxKPI; }
public void PullNewSampleGroups(ComponentFileVM comp) { StartJob("Add New Sample Groups"); var compSGList = comp.Database.From<SampleGroupDO>().Query(); foreach (SampleGroupDO sg in compSGList) { SampleGroupDO match = Master.From<SampleGroupDO>() .Where("Code = ? AND Stratum_CN = ?") .Query(sg.Code, sg.Stratum_CN).FirstOrDefault(); if (match == null) { SampleGroupDO newSG = new SampleGroupDO(Master); newSG.SuspendEvents(); newSG.SetValues(sg); newSG.Stratum_CN = sg.Stratum_CN; newSG.ResumeEvents(); newSG.Save(); match = newSG; } if (sg.SampleGroup_CN != match.SampleGroup_CN) { comp.Database.Execute("UPDATE SampleGroup SET SampleGroup_CN = ? WHERE SampleGroup_CN = ?;", match.SampleGroup_CN, sg.SampleGroup_CN); } } EndJob(); }
public void ReadLogsTest() { IWindowPresenter wp = new WindowPresenterStub() { Database = new CruiseDAL.DAL(readTestFile) }; PrivateObject param0 = new PrivateObject(new DataEditorView(wp)); DataEditorView_Accessor target = new DataEditorView_Accessor(param0); CuttingUnitDO cu = new CuttingUnitDO() { rowID = 1 }; StratumDO st = new StratumDO() { rowID = 1 }; SampleGroupDO sg = new SampleGroupDO() { rowID = 1 }; TreeDefaultValueDO tdv = new TreeDefaultValueDO() { rowID = 1 }; List<LogVM> actual; actual = target.ReadLogs(cu, st, sg, tdv); Assert.Inconclusive("Verify the correctness of this test method."); }
public override TreeDefaultValueDO ShowAddPopulation(SampleGroupDO sg) { throw new NotImplementedException(); }