public void LoadCounts(CuttingUnitDO unit) { var counts = new List<CountTreeVM>(); var tallySettings = DAL.From<TallySettingsDO>() .Where("SampleGroup_CN = ?") .GroupBy("CountTree.SampleGroup_CN", "CountTree.TreeDefaultValue_CN", "CountTree.Tally_CN") .Read(SampleGroup_CN); foreach (TallySettingsDO ts in tallySettings) { CountTreeVM count = DAL.From<CountTreeVM>() .Where("CuttingUnit_CN = ? AND SampleGroup_CN = ? AND Tally_CN = ?") .Read(unit.CuttingUnit_CN , ts.SampleGroup_CN , ts.Tally_CN).FirstOrDefault(); if (count == null) { count = new CountTreeVM(DAL); count.CuttingUnit = unit; count.SampleGroup_CN = ts.SampleGroup_CN; count.TreeDefaultValue_CN = ts.TreeDefaultValue_CN; count.Tally_CN = ts.Tally_CN; count.Save(); } count.SampleGroup = this; counts.Add(count); } Counts = counts; }
public void ShowTallySettings(CountTreeVM count) { try { count.Save(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return; } using (FormTallySettings view = new FormTallySettings(this.ApplicationController)) { view.ShowDialog(count); } }