public static string DeletarFechamentoCaixa(TRegistro_LanFechamentoCaixa val, TObjetoBanco banco) { bool st_transacao = false; TCD_LanFechamentoCaixa qtb_fechamento = new TCD_LanFechamentoCaixa(); try { if (banco == null) { st_transacao = qtb_fechamento.CriarBanco_Dados(true); } else { qtb_fechamento.Banco_Dados = banco; } TList_LanFechamentoCaixa lFechamento = Buscar(decimal.Zero, string.Empty, val.Dt_ultimofechamentostring, string.Empty, val.Cd_contager, 0, string.Empty, string.Empty, qtb_fechamento.Banco_Dados); lFechamento.ForEach(p => qtb_fechamento.DeletarFechamentoCaixa(p)); if (st_transacao) { qtb_fechamento.Banco_Dados.Commit_Tran(); } return("OK"); } catch (System.Data.SqlClient.SqlException ex) { if (st_transacao) { qtb_fechamento.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro excluir fechamento caixa: " + ex.Message); } finally { if (st_transacao) { qtb_fechamento.deletarBanco_Dados(); } } }
public static string GravarFechamentoCaixa(TRegistro_LanFechamentoCaixa val, TObjetoBanco banco) { bool st_transacao = false; TCD_LanFechamentoCaixa qtb_fechamento = new TCD_LanFechamentoCaixa(); try { if (banco == null) { st_transacao = qtb_fechamento.CriarBanco_Dados(true); } else { qtb_fechamento.Banco_Dados = banco; } string retorno = qtb_fechamento.GravarFechamentoCaixa(val); if (st_transacao) { qtb_fechamento.Banco_Dados.Commit_Tran(); } return(retorno); } catch (System.Data.SqlClient.SqlException ex) { if (st_transacao) { qtb_fechamento.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro gravar fechamento de caixa: " + ex.Message); } finally { if (st_transacao) { qtb_fechamento.deletarBanco_Dados(); } } }