public static string Finalizar(TRegistro_ProcEtapa val, TRegistro_Pedido rPed, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_ProcEtapa cd = new TCD_ProcEtapa(); try { if (banco == null) { st_transacao = cd.CriarBanco_Dados(true); } else { cd.Banco_Dados = banco; } val.Dt_processo = CamadaDados.UtilData.Data_Servidor(); val.Login = Utils.Parametros.pubLogin; string retorno = cd.Gravar(val); //Verificar se etapa pode ser finalizada cd.executarSql("update TB_FAT_Pedido_Etapa set ST_Registro = 'F', DT_Fin = GETDATE(), DT_Alt = GETDATE() " + "FROM TB_FAT_Pedido_Etapa a " + "where a.nr_pedido = " + val.Nr_pedidostr + " " + "and a.id_etapa = " + val.Id_etapastr + " " + "and not exists(select 1 from TB_FAT_Pedido_ProcEtapa x " + "where x.nr_pedido = a.nr_pedido " + "and x.id_etapa = a.ID_Etapa " + "and x.DT_Processo is null) " + //Verificar se pedido pode ser fechado "update tb_fat_pedido set ST_Pedido = 'F', ST_Registro = 'F', DT_Alt = GETDATE() " + "FROM TB_FAT_PEDIDO a " + "where a.nr_pedido = " + val.Nr_pedidostr + " " + "and not exists(select 1 from TB_FAT_Pedido_Etapa x " + "where x.Nr_Pedido = a.Nr_Pedido " + "and ISNULL(x.ST_Registro, 'A') <> 'F' " + "and isnull(x.ST_Registro, 'A') <> 'C') ", null); if (st_transacao) { cd.Banco_Dados.Commit_Tran(); } return(retorno); } catch (Exception ex) { if (st_transacao) { cd.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro gravar processo: " + ex.Message.Trim()); } finally { if (st_transacao) { cd.deletarBanco_Dados(); } } }
public static string Excluir(TRegistro_ProcEtapa val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_ProcEtapa cd = new TCD_ProcEtapa(); try { if (banco == null) { st_transacao = cd.CriarBanco_Dados(true); } else { cd.Banco_Dados = banco; } cd.Excluir(val); //Verificar se etapa pode ser finalizada cd.executarSql("update TB_FAT_Pedido_Etapa set ST_Registro = 'F', DT_Fin = GETDATE(), DT_Alt = GETDATE() " + "FROM TB_FAT_Pedido_Etapa a " + "where a.nr_pedido = " + val.Nr_pedidostr + " " + "and a.id_etapa = " + val.Id_etapastr + " " + "and not exists(select 1 from TB_FAT_Pedido_ProcEtapa x " + "where x.nr_pedido = a.nr_pedido " + "and x.id_etapa = a.ID_Etapa " + "and x.DT_Processo is null) " + //Verificar se pedido pode ser fechado "update tb_fat_pedido set ST_Pedido = 'F', ST_Registro = 'F', DT_Alt = GETDATE() " + "FROM TB_FAT_PEDIDO a " + "where a.nr_pedido = " + val.Nr_pedidostr + " " + "and not exists(select 1 from TB_FAT_Pedido_Etapa x " + "where x.Nr_Pedido = a.Nr_Pedido " + "and ISNULL(x.ST_Registro, 'A') <> 'F' " + "and isnull(x.ST_Registro, 'A') <> 'C') ", null); if (st_transacao) { cd.Banco_Dados.Commit_Tran(); } return("OK"); } catch (Exception ex) { if (st_transacao) { cd.Banco_Dados.RollBack_Tran(); } throw new Exception(ex.Message); } finally { if (st_transacao) { cd.deletarBanco_Dados(); } } }
public static string Gravar(TRegistro_ProcEtapa val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_ProcEtapa cd = new TCD_ProcEtapa(); try { if (banco == null) { st_transacao = cd.CriarBanco_Dados(true); } else { cd.Banco_Dados = banco; } string retorno = cd.Gravar(val); if (st_transacao) { cd.Banco_Dados.Commit_Tran(); } return(retorno); } catch (Exception ex) { if (st_transacao) { cd.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro gravar processo: " + ex.Message.Trim()); } finally { if (st_transacao) { cd.deletarBanco_Dados(); } } }