private void SavePB_Click(object sender, RoutedEventArgs e) { WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.GetAllFilters(); if (success) { bool goodData = true; string errStr = "No Error"; // check to make sure that the FilterChanger/FilterPosition combination is not already occupied for (int i = 0; i < wgDB.m_filterList.Count(); i++) { if (FilterVM.Filter.FilterChanger == wgDB.m_filterList[i].FilterChanger && FilterVM.Filter.PositionNumber == wgDB.m_filterList[i].PositionNumber) { goodData = false; errStr = ((FilterPositionEnum)FilterVM.Filter.PositionNumber).ToString() + " already taken in " + ((FilterChangerEnum)FilterVM.Filter.FilterChanger).ToString() + " Filter Changer"; } } if (goodData) { if (m_addingNew) { // adding new filter, so call insert FilterContainer fc = FilterVM.Filter; success = wgDB.InsertFilter(ref fc); } else { // updating existing filter, so call update FilterContainer fc = FilterVM.Filter; success = wgDB.UpdateFilter(fc); } if (success) { m_OK = true; Close(); } else { errStr = wgDB.GetLastErrorMsg(); MessageBox.Show(errStr, "Database Error", MessageBoxButton.OK, MessageBoxImage.Error); } } if (!goodData) { MessageBox.Show(errStr, "Error in Filter Data", MessageBoxButton.OK, MessageBoxImage.Error); } } }