如:数据
N NU NM
A 1 3
A 2 3
A 3 5
B 1 3
B 2 3
B 3 5
显示如下:(之所以这样显示是因为Nu 不确定)
N 1 2 3
A 3 3 5
B 3 3 5
列:
DataTable Col(string cal_id)
{
using (SqlConnection conn = new SqlConnection(strDBConnect))
{
conn.Open();
string str_sql = string.Format("select distinct MRP_DETAIL_WEEKNO from QZ_MRP_RESULT where CAL_ID='{0}'", cal_id);
SqlDataAdapter da = new SqlDataAdapter(str_sql, conn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
行:
DataTable Row(string cal_id)
{
using (SqlConnection conn = new SqlConnection(strDBConnect))
{
conn.Open();
string str_sql = string.Format("select distinct PART_NO from QZ_MRP_RESULT where CAL_ID='{0}'", cal_id);
SqlDataAdapter da = new SqlDataAdapter(str_sql, conn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
具体数据:
DataTable Get_data(string cal_id)
{
using (SqlConnection conn = new SqlConnection(strDBConnect))
{
conn.Open();
string str_sql = string.Format("select PART_NO,MRP_DETAIL_WEEKNO,PULL_QTY_MRP from QZ_MRP_RESULT where CAL_ID='{0}'", cal_id);
SqlDataAdapter da = new SqlDataAdapter(str_sql, conn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
我写的方法:
void Bind(string cal_id)
{
DataTable dt_getdata = Get_data(cal_id);
DataTable dt_col = Col(cal_id);
DataTable dt_row = Row(cal_id);
//DataTable dt = new DataTable();
foreach (DataRow dr_col in dt_col.Rows)
{
dt_row.Columns.Add(dr_col["MRP_DETAIL_WEEKNO"].ToString());
}
foreach (DataRow dr_row in dt_row.Rows)
{
foreach (DataColumn dc_col in dt_row.Columns)
{
//DataRow[] dr = dt_getdata.Select(string.Format("PART_NO='{0}' and MRP_DETAIL_WEEKNO='{1}'", dr_row["PART_NO"].ToString(),dr_row[dc_col].ToString()));
}
}
}
我显示出来后是这样的:
N 1 2 3
A
B
中间的内容没有了....求代码
没看懂规则