1.DatatTable 某個字段是否重複
DataTable dtTableDisinit = (DataTable)this.c1TrueDBGrid1.DataSource;
DataView dv = new DataView(dtTableDisinit);
if (dv.Count != dv.ToTable(true, "PMD_SingProduct").Rows.Count)
{
Common.showMessageInfo("網格中存在重複的品番!");
return;
}
2.數組中去重複的數據和判斷一個數組中是否有重複的數據
string[] strSing = this.PM_CollectionGoods.Text.ToString().Trim().Split(',');
string[] strDis = strSing.Distinct().ToArray();
if (strSing.Length != strDis.Length)
{
Common.showMessageInfo("數組中存在重複的數據");
return;
}