I have one Issue i don't know how to do this i have a dataset if it has duplicates rows then i want to print a message. can anybody suggest me how can i do this. Below is Code
bool ErrorOcc = false;
StringBuilder script = new StringBuilder();
string Filter = "";
string XmlCheck = "";
string[] IfExists = null;
for (int i = 0; i < ColumnsToks[0].Length; i++)
{
if (ColumnsToks[0][i] != "")
{
xml += @"<" + objModule.TableName + ">";
for (int j = 0; j < objModule.Cols.Count; j++)
{
MCol col = objModule.Cols[j];
DataTable dt = EBusiness.GetModuleColsValidation(this.Data.MID, col.ID);
if (dt.Select("ValidationOnClient = 'False' and ValidationType = 'Unique'").Length == 0)
{
}
for (int m = 0; m < dt.Rows.Count; m++)
{
if (!Convert.ToBoolean(dt.Rows[m]["ValidationOnClient"]) && dt.Rows[m]["ValidationType"].ToString() == "Unique")
{
// Filter += col.ColName + "='" + ColumnsToks[j][i] + "' And ";
XmlCheck += col.ColName + "='" + ColumnsToks[j][i] + "',";
}
}
IfExists = XmlCheck.Split(",".ToCharArray());
xml += "<" + col.ColName + ">" + ColumnsToks[j][i].Replace("<", "<").Replace(">", ">").Replace(" ", "") + "</" + col.ColName + ">";
}
bool IfDuplicate = false;
foreach (string count in IfExists)
{
if (count != "")
{
Filter += count + " and ";
}
}
objData.Query = "select COUNT(*) from " + objModule.TableName + " where " + Filter + " 1=1 ";
IfDuplicate = Convert.ToBoolean(objData.GetSingleValue());
if (IfDuplicate)
{
script.Append("alert('Error - There are some Duplicate entries.'); ");
ErrorOcc = true;
}
if (ErrorOcc)
{
this.ScriptOutput = script + " ValidateBeforeSaving = false;";
this.StayContent = "yes";
return;
}
if (DataSetupColumnName != "")
{
foreach (MModule module in dataSetupModules.Modules)
{
xml += "<" + module.TableName + ">" + Request["d" + module.TableName] + "</" + module.TableName + ">";
}
}
foreach (DataRow dr in dtChildModule.Rows)
{
if (Request["t" + dr["ParentModuleID"]] == "")
{
this.Message = "Please select Parent Module ID.";
return;
}
xml += "<t" + dr["ParentModuleID"] + ">" + Convert.ToInt32("0" + Request["t" + dr["ParentModuleID"]]) + "</t" + dr["ParentModuleID"] + ">";
}
xml += "<Status>1</Status><CreatedBy>0</CreatedBy><UpdatedBy>0</UpdatedBy>";
if (dtRestrictions.Rows.Count > 0)
{
xml += "<Level>" + GetLevel(EBusiness.GetCompanySetupModules(this.Data.WFID)) + "</Level>";
xml += "<LevelDataID>" + Request["t" + Request["ParentModuleID"]] + "</LevelDataID>";
}
xml += "</" + objModule.TableName + ">";
}
}
xml += "</Table>";
DataSet dsXml = new DataSet();
dsXml.ReadXml(new XmlTextReader(new StringReader(xml)));