/// <summary> /// Update existing data or include new data /// </summary> private void btnUpdate_Click(object sender, RoutedEventArgs e) { string error = null; var itemToSave = TerritoriesDataContext.modelNotifiedForTerritoriesMain; if (btnUpdate.Tag == "btnSave")//todo este if nao funciona mais. pegar da "if new " da classe. { dataConnection.AddData(itemToSave, out error); } else { dataConnection.SaveData(itemToSave, out error); } if (error != null) { MessageBox.Show(error); } else { MessageBox.Show("OK"); } }
private void SaveClick(object sender, RoutedEventArgs e) { ModelNotifiedForTerritories itemSelected = (ModelNotifiedForTerritories)DataGridTerritories.SelectedItem; if (itemSelected == null) { return; } string error = null; if (itemSelected.NewItem) { dataConnection.AddData(itemSelected, out error); if (error == null) { btnReload_Click(null, null); } } else { dataConnection.SaveData(itemSelected, out error); } if (error == null) { //MessageBox.Show(MessageBoxSaveOK); MessageBox.Show(TerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK); } else { //MessageBox.Show(MessageBoxSaveError + error); MessageBox.Show(TerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error); } }