62,243
社区成员




if (ds.Tables.Count > 0)
{
int cpidcount;
int cpcount;
for (int m = 0; m < ds.Tables[0].Rows.Count; m++)
{
if (int.TryParse(ds.Tables[0].Rows[m][1].ToString(),out cpcount))
{
if (cpcount > 1)
{
for (int j = 0; j < cpcount; j++)
{
TableRow tbcpsec = new TableRow();
TableCell tbcpidsec = new TableCell();
TableCell tbcpvlsec = new TableCell();
cpidcount = j + 1;
tbcpidsec.Text = ds.Tables[0].Rows[m][0].ToString() + cpidcount + ":";
tbcpvlsec.Text = Production.GetCompentIDBySNAndPD(txtSN.Text, ds.Tables[0].Rows[m][0].ToString() ,j);
tbcpsec.Cells.Add(tbcpidsec);
tbcpsec.Cells.Add(tbcpvlsec);
Table1.Rows.Add(tbcpsec);
cpID.Add(ds.Tables[0].Rows[m][0].ToString() + cpidcount);
cpValue.Add (Production.GetCompentIDBySNAndPD(txtSN.Text, ds.Tables[0].Rows[m][0].ToString(), j));
}
}
else
{
TableRow tr = new TableRow();
TableCell tcID = new TableCell();
TableCell tcIDVl = new TableCell();
tr.Cells.Add(tcID);
tr.Cells.Add(tcIDVl);
tcID.Text = ds.Tables[0].Rows[m][0].ToString() + ":";
tcIDVl.Text = Production.GetCompentIDBySN(txtSN.Text, ds.Tables[0].Rows[m][0].ToString());
Table1.Rows.Add(tr);
cpID.Add(ds.Tables[0].Rows[m][0].ToString());
cpValue.Add(Production.GetCompentIDBySN(txtSN.Text, ds.Tables[0].Rows[m][0].ToString()));
}
}
}
if (ds.Tables.Count > 0)
{int m = 0;
int cpidcount;
int cpcount;
int a=ds.Tables[0].Rows.Count;
for ( m = 0; m <a; m++)
{
if (int.TryParse(ds.Tables[0].Rows[m][1].ToString(),out cpcount))
{
if (cpcount > 1)
{
for (int j = 0; j < cpcount; j++)
{TableRow tbcpsec = new TableRow();
TableCell tbcpidsec = new TableCell();
TableCell tbcpvlsec = new TableCell();
cpidcount = j + 1;
tbcpidsec.Text = ds.Tables[0].Rows[m][0].ToString() + cpidcount + ":";
tbcpvlsec.Text = Production.GetCompentIDBySNAndPD(txtSN.Text, ds.Tables[0].Rows[m][0].ToString() ,j);
tbcpsec.Cells.Add(tbcpidsec);
tbcpsec.Cells.Add(tbcpvlsec);
Table1.Rows.Add(tbcpsec);
cpID.Add(ds.Tables[0].Rows[m][0].ToString() + cpidcount);
cpValue.Add (Production.GetCompentIDBySNAndPD(txtSN.Text, ds.Tables[0].Rows[m][0].ToString(), j));
}
}
else
{
TableRow tr = new TableRow();
TableCell tcID = new TableCell();
TableCell tcIDVl = new TableCell();
tr.Cells.Add(tcID);
tr.Cells.Add(tcIDVl);
tcID.Text = ds.Tables[0].Rows[m][0].ToString() + ":";
tcIDVl.Text = Production.GetCompentIDBySN(txtSN.Text, ds.Tables[0].Rows[m][0].ToString());
Table1.Rows.Add(tr);
cpID.Add(ds.Tables[0].Rows[m][0].ToString());
cpValue.Add(Production.GetCompentIDBySN(txtSN.Text, ds.Tables[0].Rows[m][0].ToString()));
}
}
}
尽量不要再for循环内定义变量