private void AgencyLongTermServiceSave_BTN_OnClick(object sender, RoutedEventArgs e) { Types_of_Service expROW = longTerm_DataGrid.SelectedItem as Types_of_Service; if (dbMethods.CheckDatabaseConnection()) { using (PubsDataContext db = new PubsDataContext()) { var completionList = new List<Types_of_Service>(from s in db.Types_of_Services where s.Agency == expROW.Agency select s); if (completionList.Count > 0) { var completion = completionList.First(); completion.Agency = expROW.Agency; completion.Body = expROW.Body; completion.CommunityBasedResearch = expROW.CommunityBasedResearch; completion.LongTerm = expROW.LongTerm; completion.ShortTerm = expROW.ShortTerm; completion.Title = expROW.Title; db.SubmitChanges(); LongTerm_Expander_OnExpanded(sender, e); } else { Types_of_Service exp = new Types_of_Service(); exp.Agency = agent.Name; exp.Body = expROW.Body; exp.CommunityBasedResearch = expROW.CommunityBasedResearch; exp.LongTerm = expROW.LongTerm; exp.ShortTerm = expROW.ShortTerm; exp.Title = expROW.Title; db.Types_of_Services.InsertOnSubmit(exp); db.SubmitChanges(); LongTerm_Expander_OnExpanded(sender, e); } } } }
partial void UpdateTypes_of_Service(Types_of_Service instance);
partial void DeleteTypes_of_Service(Types_of_Service instance);
partial void InsertTypes_of_Service(Types_of_Service instance);