Created
December 21, 2010 16:30
-
-
Save juanplopes/750161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ExcluirPacote(Int32 idPacote) | |
{ | |
ISession session = SessionManager.GetSession(); | |
session.BeginTransaction(); | |
try | |
{ | |
TbPacoteDao daoP = new TbPacoteDao(session); | |
TbItemPacoteDao daoItemP = new TbItemPacoteDao(session); | |
TbMovimentoDao daoCreditos = new TbMovimentoDao(session); | |
TbClientePacoteDao daoClientePacote = new TbClientePacoteDao(session); | |
ICriteria criteriaClientes = daoClientePacote.CreateCriteria(); | |
criteriaClientes.Add(Expression.Eq(TbClientePacote.PacoteProperty.Dot(TbPacote.IdProperty), idPacote)); | |
daoClientePacote.DeleteByCriteria(criteriaClientes); | |
ICriteria criteria = daoItemP.CreateCriteria(); | |
criteria.Add(Expression.Eq(TbItemPacote.PacoteProperty.Dot(TbPacote.IdProperty), idPacote)); | |
daoItemP.DeleteByCriteria(criteria); | |
ICriteria criteriaCredito = daoCreditos.CreateCriteria(); | |
criteriaCredito.Add(Expression.Eq(TbMovimento.PacoteProperty.Dot(TbPacote.IdProperty), idPacote)); | |
daoCreditos.DeleteByCriteria(criteriaCredito); | |
daoP.DeleteById(idPacote); | |
session.Transaction.Commit(); | |
} | |
catch (Exception) | |
{ | |
session.Transaction.Rollback(); | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment