public bool InsertRow(RowWithCategoryInfo rwci) { bool updated = false; try { // MPBDataSet.PhrasebookRow newRow = PhrasebookDataTable.AddPhrasebookRow( rwci.Row._english, rwci.Row._language ); string _english = rwci.Row._english; string _language = rwci.Row._language; rwci.Row._id = this.phrasebookTableAdapter.Insert(rwci.Row._english, rwci.Row._language); this.phrasebookTableAdapter.Update(MyDataSet); CommitChanges(); // newRow = PhrasebookDataTable.Select( string.Format( "_english LIKE '{0}' AND _language LIKE '{1}'", _english, _language ) )[ 0 ] as MPBDataSet.PhrasebookRow; // RowWithCategoryInfo newRWCI = new RowWithCategoryInfo( newRow ); // UpdateRow( newRWCI ); UpdateRow(rwci); updated = true; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } return(updated); }
public void UpdateRow(RowWithCategoryInfo rwci) { DeleteRowFromCat2Phrase(rwci.Row); rwci.CatID2CheckboxMap[0] = true; // This is the "All" category which every record should have. // Add Cat2Phrase lines foreach (KeyValuePair <long, bool> kvp in rwci.CatID2CheckboxMap) { if (kvp.Value == true) { long _catID = kvp.Key; long _phraseID = rwci.Row._id; cat2PhraseTableAdapter.Insert(_catID, _phraseID); } } // Now update the database with any changes that occurred on rwci.Row this.cat2PhraseTableAdapter.Update(MyDataSet); CommitChanges(); DataRow[] c2pRows = MyDataSet.Cat2Phrase.Select("_phraseID = 0"); DataRow[] categories = DBWrapper.Instance.Cat2PhraseDataTable.Select(string.Format("_phraseID = {0}", rwci.Row._id)); }