public string Save() { string result = ""; int recordschanged = 0; SingingClubClient client = new SingingClubClient(); client.Open(); if (songs != null && songsref != null) { List <MVCSongs> tobeadded = new List <MVCSongs>(); foreach (MVCSongs q in songs) { bool found = false; foreach (MVCSongs qref in songsref) { if (q.KeyEquals(qref) == true) { found = true; if (MVCSongs.FieldsEqual(q, qref) == false) { result = client.GeneralStore("TSCSongList_Main", "UPDATE", q.GetDataXml()); if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0) { recordschanged++; } } } } if (found == false) { tobeadded.Add(q); } } if (tobeadded.Count > 0) { foreach (MVCSongs tba in tobeadded) { result = client.GeneralStore("TSCSongList_Main", "INSERT", tba.GetDataXml()); if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0) { recordschanged++; } } } } client.Close(); return(recordschanged.ToString()); }