==================================================
-- sql代码 示例:
CREATE TYPE dbo.Content AS TABLE
(
ID int, --ID
OutCashAccountNo nvarchar(100), --出账账号
OutName nvarchar(50),
InCashAccountNo nvarchar(100), --进账账号
InName nvarchar(50),
CashType int,
Amount decimal(36,16), --金额
IsSuccess int, --是否成功
YuanYin nvarchar(200), --成功或失败原因
RemarkContent nvarchar(300), --ID+YuanYin//199_交易失败嘎嘎
RunWater nvarchar(300), --ID + GUID//RunWater 19982a21f02-d184-499f-a69f-32af77851f83
AddTime DateTime, --FinanceLog 表 AddTime
Type int, --FinanceLog 表 Type
OperationType int --FinanceLog 表 OperationType
)
go
--更新DebtAssignmentCashFlow
create procedure [dbo].[updateDebtAssignmentCashFlow2]
@InsertData Content READONLY --readonly
as
begin
update DebtAssignmentCashFlow set CashType=3
from DebtAssignmentCashFlow as d
inner join @InsertData as t
on d.ID=t.ID
end
go
======================================================================================
--C# 代码示例:
--调用
DataTable data2 = new DataTable();
data2 = Extensions.ToDataTable(newList);
int k = updateDebtAssignmentCashFlow2(data2);
/// <summary>
/// 批量更新DebtAssignmentCashFlow
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
private static int updateDebtAssignmentCashFlow2(DataTable dt)
{
bool flg = true;
int c = 0;
try
{
SqlConnection con = new SqlConnection(connString);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "updateDebtAssignmentCashFlow2";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@InsertData", SqlDbType.Structured);
cmd.Parameters[0].Value = dt;
c = cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
EF.BLL.LogHelper.Instance.Log.Info(string.Format("[error]:{0},表DebtAssignmentCashFlow批量更新失败!", ex));
flg = false;
c = -1;
}
return c;
}