public void UpdateData() { DataTable dtA = new DataTable(); DataTable dtM = new DataTable(); dtA = dt.GetChanges(DataRowState.Added); dtM = dt.GetChanges(DataRowState.Modified); bool b_Ans = false; if (dtA != null) { for (int i = 0; i < dtA.Rows.Count; i++) { if (dtA.Rows[i]["GroupName"].ToString() != "") { b_Ans = UnitDirBL.FoundOCGName(dtA.Rows[i]["GroupName"].ToString()); if (b_Ans == true) { MessageBox.Show("Already Exist"); return; } UnitDirBL.InsertOCG(dtA.Rows[i]["GroupName"].ToString()); } } } if (dtM != null) { for (int i = 0; i < dtM.Rows.Count; i++) { if (dtM.Rows[i]["GroupName"].ToString() != "") { b_Ans = UnitDirBL.FoundOCGName(dtM.Rows[i]["GroupName"].ToString()); if (b_Ans == true) { MessageBox.Show("Already Exist"); return; } UnitDirBL.UpdateOCG(Convert.ToInt32(dtM.Rows[i]["GroupId"]), dtM.Rows[i]["GroupName"].ToString()); } } } }