我正在从方案上建立一个数据网,我希望把一个从用户那里变化的单位的价值提高到另一个数据网。
我的守则是:
connTo.Open();
SqlDataReader sqlFromReader1 = null;
SqlDataReader sqlFromReader2 = null;
SqlDataReader sqlFromReader3 = null;
SqlCommand myFromCommand1 = new SqlCommand("select distinct m.catid1, c.descr "+
"from material m "+
"inner join cat1 c on c.id = m.catid1", connTo);
sqlFromReader1 = myFromCommand1.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(sqlFromReader1);
for (i = 0; i < dt1.Rows.Count; i++)
{
//int c1 = (int)(dt1.Rows[i]["catid1"]);
TabPage tbg = new TabPage(dt1.Rows[i]["descr"].ToString());
tabControl1.Controls.Add(tbg);
TabControl tbi = new TabControl();
tbi.Name = i.ToString() + i.ToString();
SqlCommand myFromCommand2 = new SqlCommand(
"select distinct m.catid2, c.descr " +
"from material m " +
"inner join cat2 c on c.id = m.catid2 "+
"and m.catid1 = " + dt1.Rows[i]["catid1"].ToString(), connTo);
sqlFromReader2 = myFromCommand2.ExecuteReader();
DataTable dt2 = new DataTable();
dt2.Load(sqlFromReader2);
for (int k = 0; k < dt2.Rows.Count; k++)
{
//int c2 = (int)(dt2.Rows[k]["catid2"]);
TabPage tbgi = new TabPage(dt2.Rows[k]["descr"].ToString());
tbi.Controls.Add(tbgi);
tbi.Left = 1;
tbi.Top = 1;
tbi.Width = 880;
tbi.Height = 400;
DataGridView gv = new DataGridView();
gv.Width = 850;
gv.Height = 340;
gv.Left = 10;
gv.Top = 10;
gv.ColumnCount = 4;
gv.Columns[0].Name = "code";
gv.Columns[0].Width = 120;
gv.Columns[0].ReadOnly = true;
gv.Columns[1].Name = "name";
gv.Columns[1].Width = 450;
gv.Columns[1].ReadOnly = true;
gv.Columns[2].Name = "price";
gv.Columns[2].Width = 80;
gv.Columns[2].ReadOnly = true;
gv.Columns[3].Name = "qty";
gv.Columns[3].Width = 120;
SqlCommand myFromCommand3 = new SqlCommand(
"select m.code, m.descr, m.cost1 price " +
"from material m " +
"where m.catid1 = " + dt1.Rows[i]["catid1"].ToString() + " " +
"and m.catid2 = " + dt2.Rows[k]["catid2"].ToString(), connTo);
sqlFromReader3 = myFromCommand3.ExecuteReader();
DataTable dt3 = new DataTable();
dt3.Load(sqlFromReader3);
for (int l = 0; l < dt3.Rows.Count; l++)
{
gv.Rows.Add(dt3.Rows[l]["code"].ToString(), dt3.Rows[l]["descr"].ToString(), dt3.Rows[l]["price"].ToString(), "");
}
tbgi.Controls.Add(gv);
}
tbg.Controls.Add(tbi);
现在,当用户改变格夫·哥伦斯的价值时,我想赶上。 姓名(“qty”)在新数据清单中添加这一数值和其余数据。
如何做到这一点? 这是可能的吗?