public void UpdateTake(DataAccess.EntityData ds)
{
SqlConnection sqlconn = new SqlConnection(Common.sqlstring);
sqlconn.Open();
SqlTransaction sqltrana = sqlconn.BeginTransaction();
try
{
foreach (DataRow row in ds.Tables["stock_take_a"].Rows)
{
row["actualmoney"] = Convert.ToDecimal(row["unitprice"]) * Convert.ToInt64(row["actualamount"]);
row["lossamount"] = Convert.ToInt64(row["actualamount"]) - Convert.ToInt64(row["nowamount"]);
row["lossmoney"] = Convert.ToDecimal(row["unitprice"]) * Convert.ToInt64(row["lossamount"]);
string Up = "update tb_stock_take set where and ";
SqlCommand sqlcom = new SqlCommand(Up,sqlconn);
sqlcom.Parameters.AddWithValue("@actualamount", row["actualamount"]);
sqlcom.Parameters.AddWithValue("@actualmoney", row["actualmoney"]);
sqlcom.Parameters.AddWithValue("@lossamount", row["lossamount"]);
sqlcom.Parameters.AddWithValue("@lossmoney", row["lossmoney"]);
sqlcom.Parameters.AddWithValue("@Stockid", row["Stockid"]);
sqlcom.Parameters.AddWithValue("@drugid", row["drugid"]);
sqlcom.Parameters.AddWithValue("@adjustmark",1);
sqlcom.Transaction = sqltrana;
sqlcom.ExecuteNonQuery();
}
sqlconn.Close();
sqlconn.Dispose();
sqltrana.Commit();
}
catch(Exception ex)
{
sqltrana.Rollback();
throw ex;
}
}
各位高手帮忙看看,这个事务报错:此 SqlTransaction 已完成;它再也无法使用。谢谢大家
补充问你一下大家:怎么实现dataGridView控件中的数据,满足某种条件的情况下该条数据的背景色改变?