private void saveUser_BTN_Click(object sender, RoutedEventArgs e) { Application_User userROW = users_DataGrid.SelectedItem as Application_User; if (userROW != null) { if (dbMethods.CheckDatabaseConnection()) { using (PubsDataContext db = new PubsDataContext()) { var completionList = new List<Application_User>(from s in db.Application_Users where s.Username == userROW.Username select s); if (completionList.Count > 0) { var completion = completionList.First(); completion.Username = userROW.Username; completion.Password = userROW.Password; completion.LastName = userROW.LastName; completion.IsAdmin = userROW.IsAdmin; completion.FirstName = userROW.FirstName; completion.Birthdate = userROW.Birthdate; // Fixes the issue with saving birthdates db.SubmitChanges(); LoadUsers(users_DataGrid); } else { Application_User exp = new Application_User(); exp.Username = userROW.Username; exp.Password = userROW.Password; exp.LastName = userROW.LastName; exp.IsAdmin = userROW.IsAdmin; exp.FirstName = userROW.FirstName; exp.Birthdate = userROW.Birthdate; // Fixes the issue with saving birthdates db.Application_Users.InsertOnSubmit(exp); db.SubmitChanges(); LoadUsers(users_DataGrid); } } } } }
partial void UpdateApplication_User(Application_User instance);
partial void DeleteApplication_User(Application_User instance);
partial void InsertApplication_User(Application_User instance);