本文整理汇总了C#中OpenCbsCommand.ResetParams方法的典型用法代码示例。如果您正苦于以下问题:C# OpenCbsCommand.ResetParams方法的具体用法?C# OpenCbsCommand.ResetParams怎么用?C# OpenCbsCommand.ResetParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCbsCommand
的用法示例。
在下文中一共展示了OpenCbsCommand.ResetParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _SetLoanShareAmount
private void _SetLoanShareAmount(Loan pLoan, SqlTransaction pSqlTransac)
{
// Get group id
int group_id;
const string q = @"SELECT p.tiers_id
FROM dbo.Projects AS p
LEFT JOIN dbo.Contracts AS c ON c.project_id = p.id
WHERE c.id = @contract_id";
using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
{
c.AddParam("@contract_id", pLoan.Id);
group_id = Convert.ToInt32(c.ExecuteScalar());
}
const string sqlText = @"INSERT INTO LoanShareAmounts (person_id, group_id, contract_id, amount)
VALUES (@person_id, @group_id, @contract_id, @amount)";
using(OpenCbsCommand c = new OpenCbsCommand(sqlText, pSqlTransac.Connection, pSqlTransac))
{
foreach (LoanShare ls in pLoan.LoanShares)
{
c.ResetParams();
c.AddParam("@person_id", ls.PersonId);
c.AddParam("@group_id", group_id);
c.AddParam("@contract_id", pLoan.Id);
c.AddParam("@amount", ls.Amount.Value);
c.ExecuteNonQuery();
}
}
}
示例2: DeleteAccount
public void DeleteAccount(Account account)
{
using (SqlConnection conn = GetConnection())
{
OpenCbsCommand cmd = new OpenCbsCommand
{
Connection = conn,
CommandText =
@"DELETE FROM dbo.ChartOfAccounts
WHERE lft >= @lft AND rgt <= @rgt"
};
cmd.AddParam("@lft", account.Left);
cmd.AddParam("@rgt", account.Right);
cmd.ExecuteNonQuery();
cmd.ResetParams();
cmd.CommandText =
@"UPDATE dbo.ChartOfAccounts
SET lft = lft - @diff, rgt = rgt - @diff
WHERE lft > @lft";
cmd.AddParam("@diff", account.Right - account.Left + 1);
cmd.AddParam("@lft", account.Left);
cmd.ExecuteNonQuery();
}
}