On Wed, Apr 14, 2010 at 5:09 AM, Dr William Tormey
<[email protected]> wrote:
> Hi Stephen.
> We have been working with BOM's in agribusiness and electronics
> assembly, both of which require dynamic and recursive capabilities.
> That said we have not been SQL orientated and use it only for straight
> forward reports.
>
> Treating SOID as the BOM and COID as the ingredient in ordinary DB
> tables, with parent child, your form with tick boxes will easily drive
> the building of the result cursors of the SOR, and allow the user to
> rework results and revise judgements as to choices , to make allowances
> for equivalences in other contexts (substitutions & recursions).
----------------------------------
Finished the task, followed the remove all and insert any still checked.
Here is the code:
public static String postTCACodes(List<TCACode> tca, Guid SecParam)
{
List<String> chk = new List<string>();
List<String> unchk = new List<string>(); // not needed
but still populated.
StringBuilder SQL = new StringBuilder();
SQL.Append("Delete from TCAPicked where TCAID in(");
bool flag = false;
// make the removal run for every code presented
foreach (TCACode tc in tca)
{
if (tc.BoolCheck) chk.Add(tc.CCMSC.ToString());
else unchk.Add(tc.CCMSC.ToString());
if (flag) SQL.Append(", "); else flag = true;
SQL.Append(tc.CCMSC.ToString());
}
SQL.Append(")");
string retUnChkVal = DAL.postStatement(SQL.ToString());
SQL.Remove(0, SQL.Length);
flag = false;
// Generate the new inserts for All that were picked, all
were removed a sec ago.
SQL.Append("Insert into dbo.TCAPicked (ID, SearchKey , TCAID)");
foreach (string ch in chk)
{
Guid id = Guid.NewGuid();
if (flag) SQL.Append(" Union all "); else flag = true;
SQL.Append(" Select '" + id.ToString()+"', '"+
SecParam.ToString() + "', " + ch.ToString() );
}
// String is a union insert statement instead of a
repetitive single insert each one.
string retChkVal = DAL.postStatement(SQL.ToString());
return retUnChkVal + " removed and this is the final count
of Codes " + retChkVal ;
}
--
Stephen Russell
Sr. Production Systems Programmer
CIMSgts
901.246-0159 cell
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.