public static OperationResult Insert(DataFieldCollection pValues, ConnectionInfo pInfo) { Transaction lTransaction; lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (lTransaction != null); InsertCommand lInsert; OperationResult lReturn = new OperationResult(NPJ_ALUNOXATENDIMENTOQD.TableName, NPJ_ALUNOXATENDIMENTOQD.TableName); if (!lReturn.HasError){ try{ if (lLocalTransaction){ lReturn.Trace("Transação local, instanciando banco..."); } lInsert = new InsertCommand(NPJ_ALUNOXATENDIMENTOQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys){ lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction); if (!lReturn.HasError){ if (lLocalTransaction){ if (!lReturn.HasError){ lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else{ lTransaction.Rollback(); } } } else{ if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex){ lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult Update( DataFieldCollection pValues, ConnectionInfo pInfo ) { Transaction pTransaction; pTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (pTransaction != null); UpdateCommand lUpdate; OperationResult lReturn = new OperationResult(PaisQD.TableName, PaisQD.TableName); ValidateUpdate(pValues, lReturn); if (lReturn.IsValid) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lUpdate = new UpdateCommand(PaisQD.TableName); lReturn.Trace("Adicionando campos ao objeto de update"); foreach (DataField lField in pValues.Keys) { if ( (lField.Name != PaisQD._PS_ID.Name) ) lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } string lSql = ""; lSql = String.Format("WHERE {0} = <<{0}", PaisQD._PS_ID.Name); lUpdate.Condition = lSql; lUpdate.Conditions.Add(PaisQD._PS_ID.Name, pValues[PaisQD._PS_ID].DBToDecimal()); lReturn.Trace("Executando o Update"); lUpdate.Execute(pTransaction); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Update finalizado, executando commit"); pTransaction.Commit(); } else { pTransaction.Rollback(); } } } else { if (lLocalTransaction) pTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) pTransaction.Rollback(); } } return lReturn; }
public static OperationResult Insert( DataFieldCollection pValues, Transaction pTransaction, ConnectionInfo pInfo ) { Transaction lTransaction; bool lLocalTransaction = (pTransaction == null); if (lLocalTransaction) lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); else lTransaction = pTransaction; InsertCommand lInsert; OperationResult lReturn = new OperationResult(InteressadoQD.TableName, InteressadoQD.TableName); if (!lReturn.HasError) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lInsert = new InsertCommand(InteressadoQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys) { lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lSequence = DataBaseSequenceControl.GetNext(pInfo, "INTE_ID"); lInsert.Fields.Add(InteressadoQD._INTE_ID.Name, lSequence, (ItemType)InteressadoQD._INTE_ID.DBType); lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult Exluir_ByNUC_ID( decimal pNUC_ID, ConnectionInfo pInfo ) { Transaction pTransaction; pTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (pTransaction != null); UpdateCommand lUpdate; OperationResult lReturn = new OperationResult(NucleoxAreaAtuacaoQD.TableName, NucleoxAreaAtuacaoQD.TableName); if (lReturn.IsValid) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lUpdate = new UpdateCommand(NucleoxAreaAtuacaoQD.TableName); lReturn.Trace("Adicionando campos ao objeto de update"); lUpdate.Fields.Add(NucleoxAreaAtuacaoQD._NUCARATUA_STATUS.Name, "I", (ItemType)NucleoxAreaAtuacaoQD._NUCARATUA_STATUS.DBType); string lSql = ""; lSql = String.Format("WHERE {0} = <<{0}", NucleoxAreaAtuacaoQD._NUC_ID.Name); lUpdate.Condition = lSql; lUpdate.Conditions.Add(NucleoxAreaAtuacaoQD._NUC_ID.Name, pNUC_ID); lReturn.Trace("Executando o Update"); lUpdate.Execute(pTransaction); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Update finalizado, executando commit"); pTransaction.Commit(); } else { pTransaction.Rollback(); } } } else { if (lLocalTransaction) pTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) pTransaction.Rollback(); } } return lReturn; }
public static OperationResult Insert( DataFieldCollection pValues, List<DataFieldCollection> pListInterrupcao, ConnectionInfo pInfo ) { Transaction lTransaction; lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (lTransaction != null); InsertCommand lInsert; OperationResult lReturn = new OperationResult(DCALC_CONDENACAOQD.TableName, DCALC_CONDENACAOQD.TableName); if (!lReturn.HasError) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lInsert = new InsertCommand(DCALC_CONDENACAOQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys) { lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lSequence = DataBaseSequenceControl.GetNext(pInfo, "COND_ID"); lInsert.Fields.Add(DCALC_CONDENACAOQD._COND_ID.Name, lSequence, (ItemType)DCALC_CONDENACAOQD._COND_ID.DBType); decimal lCOND_ID = 0; lCOND_ID = lReturn.SequenceControl; lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction); if (!lReturn.HasError) { if (pListInterrupcao.Count > 0) { foreach (DataFieldCollection lFields in pListInterrupcao) { lFields.Add(DCALC_INTERRUPCAOQD._COD_CONDENACAO, lSequence); lReturn = DCALC_INTERRUPCAODo.Insert(lFields, lTransaction, pInfo); if (lReturn.HasError) { lTransaction.Rollback(); return lReturn; } } } if (!lReturn.HasError) { lReturn.SequenceControl = lSequence; lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult Insert( DataFieldCollection pValues, ConnectionInfo pInfo ) { Transaction lTransaction; lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (lTransaction != null); InsertCommand lInsert; OperationResult lReturn = new OperationResult(OficioQD.TableName, OficioQD.TableName); if (!lReturn.HasError) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lInsert = new InsertCommand(OficioQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys) { lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lSequence = DataBaseSequenceControl.GetNext(pInfo, "OFC_ID"); lInsert.Fields.Add(OficioQD._OFC_ID.Name, lSequence, (ItemType)OficioQD._OFC_ID.DBType); string lNumeroOficio = "OFC" + lSequence.ToString().PadLeft(7, '0') + "/" + DateTime.Now.Date.Year.ToString(); lInsert.Fields.Add(OficioQD._OFC_NUMERO.Name, lNumeroOficio, (ItemType)OficioQD._OFC_NUMERO.DBType); lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction, false); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult Insert( DataFieldCollection pValues, ConnectionInfo pInfo ) { Transaction lTransaction; lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (lTransaction != null); InsertCommand lInsert; OperationResult lReturn = new OperationResult(TriagemQD.TableName, TriagemQD.TableName); if (!lReturn.HasError) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } lInsert = new InsertCommand(TriagemQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys) { lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lSequence = DataBaseSequenceControl.GetNext(pInfo, "TRG_ID"); lInsert.Fields.Add(TriagemQD._TRG_ID.Name, lSequence, (ItemType)TriagemQD._TRG_ID.DBType); lReturn.SequenceControl = lSequence; decimal lSequenceSenha; if (pValues[TriagemQD._ASTTRG_ID].ToString() == "1") { lSequenceSenha = DataBaseSequenceControl.GetNext(lTransaction, TriagemQD.TableName, "TRG_SENHA", " NUC_ID = " + pValues[TriagemQD._NUC_ID] + " AND TO_CHAR(TRG_REGDATE,'dd/MM/yyyy') = TO_CHAR(SYSDATE,'dd/MM/yyyy') AND ASTTRG_ID = 1 AND TRG_PRIORIDADE = " + pValues[TriagemQD._TRG_PRIORIDADE]); lInsert.Fields.Add(TriagemQD._TRG_SENHA.Name, lSequenceSenha, (ItemType)TriagemQD._TRG_SENHA.DBType); } else if (pValues[TriagemQD._ASTTRG_ID].ToString() == "4") { lSequenceSenha = DataBaseSequenceControl.GetNext(lTransaction, TriagemQD.TableName, "TRG_SENHA", " NUC_ID = " + pValues[TriagemQD._NUC_ID] + " AND TO_CHAR(TRG_REGDATE,'dd/MM/yyyy') = TO_CHAR(SYSDATE,'dd/MM/yyyy') AND ASTTRG_ID = 4 AND TRG_PRIORIDADE = " + pValues[TriagemQD._TRG_PRIORIDADE]); lInsert.Fields.Add(TriagemQD._TRG_SENHA.Name, lSequenceSenha, (ItemType)TriagemQD._TRG_SENHA.DBType); } else if (pValues[TriagemQD._ASTTRG_ID].ToString() == "7") { lSequenceSenha = DataBaseSequenceControl.GetNext(lTransaction, TriagemQD.TableName, "TRG_SENHA", " NUC_ID = " + pValues[TriagemQD._NUC_ID] + " AND TO_CHAR(TRG_REGDATE,'dd/MM/yyyy') = TO_CHAR(SYSDATE,'dd/MM/yyyy') AND ASTTRG_ID = 7 AND TRG_PRIORIDADE = " + pValues[TriagemQD._TRG_PRIORIDADE]); lInsert.Fields.Add(TriagemQD._TRG_SENHA.Name, lSequenceSenha, (ItemType)TriagemQD._TRG_SENHA.DBType); } lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult Update( DataFieldCollection pValues, ConnectionInfo pInfo ) { Transaction pTransaction; pTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (pTransaction != null); UpdateCommand lUpdate; OperationResult lReturn = new OperationResult(NucleoQD.TableName, NucleoQD.TableName); ValidateUpdate(pValues, lReturn); if (lReturn.IsValid) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } //16/10/2012 Ricardo Almeida - retirada da função, pois registro não pode ser excluido se estiver usuário cadastrado //lReturn = NucleoxAreaAtuacaoDo.Exluir_ByNUC_ID(pValues[NucleoQD._NUC_ID].DBToDecimal(), pInfo); //if (lReturn.HasError) //{ // if (lLocalTransaction) // pTransaction.Rollback(); // return lReturn; //} lReturn = NucleoxSecretariaDo.Exluir_ByNUC_ID(pValues[NucleoQD._NUC_ID].DBToDecimal(), pInfo); if (!lReturn.HasError) { lUpdate = new UpdateCommand(NucleoQD.TableName); lReturn.Trace("Adicionando campos ao objeto de update"); foreach (DataField lField in pValues.Keys) { if ((lField.Name != NucleoQD._NUC_ID.Name)) lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } string lSql = ""; lSql = String.Format("WHERE {0} = <<{0}", NucleoQD._NUC_ID.Name); lUpdate.Condition = lSql; lUpdate.Conditions.Add(NucleoQD._NUC_ID.Name, pValues[NucleoQD._NUC_ID].DBToDecimal()); lReturn.Trace("Executando o Update"); lUpdate.Execute(pTransaction); } if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Update finalizado, executando commit"); pTransaction.Commit(); } else { pTransaction.Rollback(); } } } else { if (lLocalTransaction) pTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) pTransaction.Rollback(); } } return lReturn; }
public static OperationResult Insert( DataFieldCollection pValues, Transaction pTransaction, ConnectionInfo pInfo ) { Transaction lTransaction; bool lLocalTransaction = (pTransaction == null); if (lLocalTransaction) lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); else lTransaction = pTransaction; InsertCommand lInsert; OperationResult lReturn = new OperationResult(AtuacaoQD.TableName, AtuacaoQD.TableName); if (!lReturn.HasError) { try { if (lLocalTransaction) { lReturn.Trace("Transação local, instanciando banco..."); } //lReturn.Trace("Excluído Atuações..."); //lReturn = UpdateInativo(pValues[AtuacaoQD._PESF_ID].DBToDecimal(), pValues[AtuacaoQD._ATUA_STATUS].ToString(), pInfo); //if (lReturn.HasError) //{ // return lReturn; //} lInsert = new InsertCommand(AtuacaoQD.TableName); lReturn.Trace("Adicionando campos ao objeto de insert"); foreach (DataField lField in pValues.Keys) { lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType); } decimal lSequence; lSequence = DataBaseSequenceControl.GetNext(pInfo, "ATUA_ID"); lInsert.Fields.Add(AtuacaoQD._ATUA_ID.Name, lSequence, (ItemType)AtuacaoQD._ATUA_ID.DBType); lReturn.SequenceControl = lSequence; lReturn.Trace("Executando o Insert"); lInsert.Execute(lTransaction); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } return lReturn; }
public static OperationResult InsertPeticao( DataFieldCollection pValuesDocMovAddPeticao, DataFieldCollection pValuesPeticao, DataFieldCollection pValuesDocMovTram, DataFieldCollection pValuesTramitacao, ConnectionInfo pInfo ) { Transaction lTransaction; lTransaction = new Transaction(Instance.CreateDatabase(pInfo)); bool lLocalTransaction = (lTransaction != null); InsertCommand lInsert; OperationResult lReturn = new OperationResult(DocumentoMovimentoQD.TableName, DocumentoMovimentoQD.TableName); decimal lPTC_ID = 0; decimal lDOCMOV = 0; if (!lReturn.HasError) { try { lReturn = DocumentoMovimentoDo.Insert(pValuesDocMovAddPeticao, lTransaction, pInfo); if (lReturn.HasError) { lTransaction.Rollback(); return lReturn; } lReturn = PeticaoDo.Insert(pValuesPeticao, lTransaction, pInfo); if (lReturn.HasError) { lTransaction.Rollback(); return lReturn; } lPTC_ID = lReturn.SequenceControl; pValuesDocMovTram.Add(DocumentoMovimentoQD._PTC_ID, lPTC_ID); lReturn = DocumentoMovimentoDo.Insert(pValuesDocMovTram, lTransaction, pInfo); if (lReturn.HasError) { lTransaction.Rollback(); return lReturn; } lDOCMOV = lReturn.SequenceControl; pValuesTramitacao.Add(DocumentoTramitacaoQD._DOCMOV_ID, lDOCMOV); lReturn = DocumentoTramitacaoDo.Insert(pValuesTramitacao, lTransaction, pInfo); if (!lReturn.HasError) { if (lLocalTransaction) { if (!lReturn.HasError) { lReturn.Trace("Insert finalizado, executando commit"); lTransaction.Commit(); } else { lTransaction.Rollback(); } } } else { if (lLocalTransaction) lTransaction.Rollback(); } } catch (Exception ex) { lReturn.OperationException = new SerializableException(ex); if (lLocalTransaction) lTransaction.Rollback(); } } lReturn.SequenceControl = lPTC_ID; return lReturn; }