Private void dbind (string PID)
{
Datatable DT;
String strsql = "select * from" + session ["outtable"]. tostring () + "where" + session ["filed_id"]. tostring () + "=" + PID;
Dt = new CC. dbhepler (). runsql (strsql, commandtype. Text, null, null). Tables [0];
If (Dt. Rows. Count> 0)
{
// Strsql = "insert into" + session ["intable"]. tostring () + "(name, parent_id) values ('" + dt. rows [0] ["name"]. tostring () + "'," + session ["pnode"]. tostring () + ")";
String sqlfield = "";
String sqlvalues = "";
Strsql = "insert into" + session ["intable"]. tostring () + "(";
For (INT I = 0; I <DT. Columns. Count; I ++)
{
If (Dt. Rows [0] [I]. tostring ()! = "" & DT. Columns [I]. columnname. tolower ()! = Session ["filed_id"]. tostring () & DT. Columns [I]. columnname. tolower ()! = Session ["filed_pid"]. tostring ())
{
Sqlfield + = DT. Columns [I]. columnname + ",";
Sqlvalues + = "'" + dt. Rows [0] [I]. tostring () + "',";
}
}
Sqlfield + = session ["filed_pid"]. tostring ();
Sqlvalues + = session ["pnode"]. tostring ();
Strsql + = sqlfield + ") values (" + sqlvalues + ")";
New cc. dbhepler (). runsqlretnull (strsql, commandtype. Text, null, null); // Insert the first data
Strsql = "select max (" + session ["filed_id"]. tostring () + ") from" + session ["intable"]. tostring ();
Session ["num"] = NULL;
Session ["num"] = new CC. dbhepler (). runsqlretobj (strsql, commandtype. Text, null, null). tostring (); // get the maximum ID of the inserted Table
Strsql = "select * from" + session ["outtable"]. tostring () + "where" + session ["filed_pid"]. tostring () + "=" + PID;
Dt = new CC. dbhepler (). runsql (strsql, commandtype. Text, null, null). Tables [0];
For (INT I = 0; I <DT. Rows. Count; I ++)
{
// Strsql = "insert into" + session ["intable"]. tostring () + "(name," + session ["filed_pid"]. tostring () + ") values ('" + dt. rows [I] ["name"]. tostring () + "'," + session ["num"]. tostring () + ")";
Sqlfield = "";
Sqlvalues = "";
Strsql = "insert into" + session ["intable"]. tostring () + "(";
For (INT num = 0; num <DT. Columns. Count; num ++)
{
If (Dt. Rows [I] [num]. tostring ()! = "" & DT. Columns [num]. columnname. tolower ()! = Session ["filed_id"]. tostring () & DT. Columns [num]. columnname. tolower ()! = Session ["filed_pid"]. tostring ())
{
Sqlfield + = DT. Columns [num]. columnname + ",";
}
}
Sqlfield + = session ["filed_pid"]. tostring ();
For (INT num1 = 0; num1 <DT. Columns. Count; num1 ++)
{
If (Dt. Rows [I] [num1]. tostring ()! = "" & DT. Columns [num1]. columnname. tolower ()! = Session ["filed_id"]. tostring () & DT. Columns [num1]. columnname. tolower ()! = Session ["filed_pid"]. tostring ())
{
Sqlvalues + = "'" + dt. Rows [I] [num1]. tostring () + "',";
}
}
Sqlvalues + = session ["num"]. tostring ();
Strsql + = sqlfield + ") values (" + sqlvalues + ")";
New cc. dbhepler (). runsqlretnull (strsql, commandtype. Text, null, null); // Insert lower-level data
}
}
}