Skip to content

Instantly share code, notes, and snippets.

@tdcbm
Created March 23, 2018 08:16
Show Gist options
  • Save tdcbm/a5b6be677ea3a793dc2903e9dc82ef32 to your computer and use it in GitHub Desktop.
Save tdcbm/a5b6be677ea3a793dc2903e9dc82ef32 to your computer and use it in GitHub Desktop.
GetKey5ForUD06
private static string GetKey5ForUD06(EpiDataView edvUD06, Ice.UI.App.UD06Entry.Transaction ud06Trans)
{
// Get unique row count id for Key5
int rowCount = edvUD06.dataView.Table.Rows.Count;
int lineNum = rowCount;
bool goodIndex = false;
while ((goodIndex == false))
{
// Check to see if index exists
DataRow[] matchingRows = edvUD06.dataView.Table.Select("Key5 = \'" + lineNum.ToString() + "\'");
if ((matchingRows.Length > 0))
{
lineNum = (lineNum + 1);
}
else
{
goodIndex = true;
}
}
var edvUD06Row = edvUD06.CurrentDataRow;
var ud06Adapter = new UD06Adapter(ud06Trans);
ud06Adapter.BOConnect();
try
{
var ud06Exists = ud06Adapter.GetByID(edvUD06Row["Key1"], "", "", "", lineNum.ToString());
if (ud06Exists)
{
goodIndex = false;
var dsUD06 = ud06Adapter.GetData(edvUD06Row["Key1"], "", "", "", lineNum.ToString());
while ((goodIndex == false))
{
// Check to see if index exists
DataRow[] matchingRows = dsUD06.Tables[0].Select("Key5 = \'" + lineNum.ToString() + "\'");
if ((matchingRows.Length > 0))
{
lineNum = (lineNum + 1);
}
else
{
goodIndex = true;
}
}
}
}
catch (Exception) { }
finally
{
ud06Adapter.Dispose();
}
return lineNum.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment