日期:2014-05-18 浏览次数:20949 次
conn.Open();//采用事件处理时行数据提交 SqlCommand cmd = new SqlCommand(); SqlTransaction sqltran = conn.BeginTransaction(); cmd.Connection = conn; cmd.Transaction = sqltran; cmd.CommandText = "SELECT [" + outdept + "],[" + outdept1 + "],[" + indept + "] FROM [Order] where [ClientOrder]='" +lvw_list.Items[1].SubItems[2].Text + "'"; SqlDataReader getnumber = cmd.ExecuteReader(); getnumber.Read(); outi = Convert.ToInt32(getnumber[0].ToString()) -Convert.ToInt32( lvw_list.Items[0].SubItems[4].Text); outo = Convert.ToInt32(getnumber[1].ToString()) +Convert.ToInt32( lvw_list.Items[0].SubItems[4].Text); ini = Convert.ToInt32(getnumber[2].ToString()) + Convert.ToInt32(lvw_list.Items[0].SubItems[4].Text); cmd.CommandText = "UPDATE [Order] SET [" + outdept + "]='" + outi + "',[" + outdept1 + "]='" + outo + "',[" + indept + "]='" + ini + "' WHERE [ClientOrder]='" + lvw_list.Items[1].SubItems[2].Text + "' "; cmd.ExecuteNonQuery(); sqltran.Commit(); lvw_list.Items.RemoveAt(1); conn.Close();