C#执行添加事务

 
/// <summary>
  /// 执行添加事务
  /// </summary>
  /// <param name="sqls"></param>
  /// <returns></returns>
  public int AddList(List<String> sqls)
  {

  return DbHelperSQL.ExecuteSqlTran(sqls);
  }

BLL.cs
/// <summary>
  /// 执行添加事务
  /// </summary>
  /// <param name="sqls"></param>
  /// <returns></returns>
  public bool AddList(List<M_Pact_ItemMoney> list)
  {

  List<String> sqls = new List<String>();
  foreach (M_Pact_ItemMoney model in list)
  {

  sqls.Add(@" insert into Pact_ItemMoney(PactCode,ItemName,ItemCent)  
  values  
  ('" + model.PactCode + @"','" + model.ItemName + @"','" + model.ItemCent + @"')");
  }

  if (dal.AddList(sqls) > 0)
  {
  return true;
  }
  else
  {
  return false;
  }
  }

你可能感兴趣的:(list,C#,insert)