winform批量查询单号剔除重复
//查询分单函数
private string GetQueryInSubbillNo()
{
string strSubbillNO = "";
string strOutput = "";
foreach (DataGridViewRow dgvRow in dgvRecieveProducts.Rows)
{
strSubbillNO += "'" + dgvRow.Cells["dgvSubbillNO"].Value.ToString() + "',";
}
if (dgvRecieveProducts.Rows.Count > 0)
{
string strinput = strAddSubbillNo + strSubbillNO.Substring(0, strSubbillNO.Length - 1);
Array stringArray = strinput.Split(',');
List<string> listString = new List<string>();
//遍历删除重复项
foreach (string eachString in stringArray)
{
if (!listString.Contains(eachString)) //确定是否存在,存在跳过
listString.Add(eachString);
}
foreach (string subbillNo in listString) //筛选值
{
strOutput += subbillNo + ",";
}
return strOutput.Substring(0, strOutput.Length - 1);
}
else { return ""; }
}