53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
|
|
namespace ArchiviazionePDF
|
|
{
|
|
public class TransactionStoredProcedure
|
|
{
|
|
private SqlCommand cmdRM = null;
|
|
private SqlConnection connRM = null;
|
|
public void BeginTransactionStoredProcedure(string stored, SqlParameter[] parametri)
|
|
{
|
|
connRM = new SqlConnection(Config.connSqlServer);
|
|
cmdRM = new SqlCommand(stored, connRM);
|
|
cmdRM.CommandType = CommandType.StoredProcedure;
|
|
cmdRM.CommandTimeout = 14400;
|
|
cmdRM.Parameters.AddRange(parametri);
|
|
connRM.Open();
|
|
cmdRM.Transaction = connRM.BeginTransaction(IsolationLevel.Serializable);
|
|
cmdRM.ExecuteNonQuery();
|
|
|
|
}
|
|
public void CommitTransactionStoredProcedure()
|
|
{
|
|
cmdRM.Transaction.Commit();
|
|
}
|
|
public bool RollbackTransactionStoredProcedure()
|
|
{
|
|
bool ok = false;
|
|
try
|
|
{
|
|
cmdRM.Transaction.Rollback();
|
|
ok = true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ok = false;
|
|
}
|
|
finally
|
|
{
|
|
connRM.Close();
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|