private static void ValidateDecimal(string pFieldName, object pValue, OperationResult pOperationResult)
        {
            decimal lResult;

            if (!Decimal.TryParse(pValue.ToString(), out lResult))
            {
                pOperationResult.InvalidField(pFieldName, "Invalid", pValue);
            }
        }
        private static void ValidateDate(string pFieldName, object pValue, OperationResult pOperationResult)
        {
            DateTime lResult;

            if (pValue.GetType() == typeof(DateTime)) return;

            if (!DateTime.TryParse(pValue.ToString(), out lResult))
            {
                pOperationResult.InvalidField(pFieldName, "Invalid", pValue);
            }
        }
        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 decimal GetNext(Transaction pTransaction, string pIDFieldValue)
        {
            decimal lID;

            // Inicializa operação
            OperationResult lReturn = new OperationResult(QueryDictionaries.SequencesQD.TableName, QueryDictionaries.SequencesQD.TableName);

            // Recupera Valor
            SelectCommand lSelectNext;

            string lSelectQuery = QueryDictionaries.SequencesQD.qSequencesMax;
            lSelectQuery += String.Format("WHERE {0} = >>{0}", QueryDictionaries.SequencesQD._SEQ_NAME.Name);

            object lScalarReturn;

            lSelectNext = new SelectCommand(lSelectQuery);

            // Passagem dos Valores de Parametros para a Clausula WHERE [comando SELECT]
            lSelectNext.Fields.Add(QueryDictionaries.SequencesQD._SEQ_NAME.Name, pIDFieldValue, ItemType.String);

            // Recupera Valor do Select (Seq_Value)
            lScalarReturn = lSelectNext.ReturnScalar(pTransaction);

            if (lScalarReturn == null || lScalarReturn == DBNull.Value) lScalarReturn = 1;
            lID = Convert.ToDecimal(lScalarReturn);

            // Altera Valor da Sequence
            UpdateCommand lUpdate;
            lUpdate = new UpdateCommand(QueryDictionaries.SequencesQD.TableName);

            // Identificação dos Campos a serem Alterados
            lUpdate.Fields.Add(QueryDictionaries.SequencesQD._SEQ_VALUE.Name, lID, (ItemType) QueryDictionaries.SequencesQD._SEQ_VALUE.DBType);

            string lUpdateQuery;

            lUpdateQuery = String.Format("WHERE {0} = >>{0}", QueryDictionaries.SequencesQD._SEQ_NAME.Name);
            lUpdate.Condition = lUpdateQuery;

            // Passagem dos Valores para a Condição Where do Update
            lUpdate.Conditions.Add(QueryDictionaries.SequencesQD._SEQ_NAME.Name, pIDFieldValue);

            // Execução do UPDATE
            lUpdate.Execute(pTransaction);

            // Retorna novo valor da chave [SEQUENCE VALUE]
            return lID;
        }
 public static void ValidateRequired(DataField pField, DataFieldCollection pValues, OperationResult pOperationResult)
 {
     if (!pValues.ContainsKey(pField))
     {
         pOperationResult.InvalidField(pField.Name, "Required", null);
     }
     else
     {
         if (pValues[pField] == null)
         {
             pOperationResult.InvalidField(pField.Name, "Required", null);
         }
         else
         {
             if (pValues[pField].ToString() == "")
                 pOperationResult.InvalidField(pField.Name, "Required", null);
         }
     }
 }
        public static void ValidateConversion(DataFieldCollection pValues, OperationResult pOperationResult)
        {
            foreach (DataField lField in pValues.Keys)
            {
                switch (lField.DBType)
                {
                    case 0:

                        ValidateDecimal(lField.Name, pValues[lField], pOperationResult);

                        break;

                    case 2:

                        ValidateDate(lField.Name, pValues[lField], pOperationResult);

                        break;
                }
            }
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(SituacaoEscolarQD._STESC_ID, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(NPJ_ALUNOXATENDIMENTOQD._DOC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(NPJ_ALUNOXATENDIMENTOQD._SUSR_ID, pValues, pResult);
     //GenericDataObject.ValidateRequired(NPJ_ALUNOXATENDIMENTOQD._SIT_ID, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(MedidasCriminalQD._MDCRM_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(MedidasCriminalQD._MDCRM_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(MedidasCriminalQD._MDCRM_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(MedidasCriminalQD._MDCRM_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(SEG_USUARIOXGRUPOQD._GRP_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(SEG_USUARIOXGRUPOQD._SUSR_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(SEG_USUARIOXGRUPOQD._SUSR_REGSTATUS, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(SEG_GRUPOXPROGRAMAQD._GRP_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(SEG_GRUPOXPROGRAMAQD._PRO_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(SEG_GRUPOXPROGRAMAQD._GRP_REGSTATUS, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(DCALC_CONDENACAOQD._COND_ID, pValues, pResult);
 }
        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(SituacaoFamiliarResideQD.TableName, SituacaoFamiliarResideQD.TableName);

            if (!lReturn.HasError)
            {
                try
                {
                    lInsert = new InsertCommand(SituacaoFamiliarResideQD.TableName);

                    foreach (DataField lField in pValues.Keys)
                    {
                        lInsert.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
                    }
                    decimal lSequence;
                    lSequence = DataBaseSequenceControl.GetNext(pInfo, "STFRES_ID");
                    lInsert.Fields.Add(SituacaoFamiliarResideQD._STFRES_ID.Name, lSequence, (ItemType)SituacaoFamiliarResideQD._STFRES_ID.DBType);

                    lInsert.Execute(lTransaction);

                    if (!lReturn.HasError)
                    {
                        if (lLocalTransaction)
                        {
                            if (!lReturn.HasError)
                            {

                                lTransaction.Commit();
                            }
                            else
                            {
                                lTransaction.Rollback();
                            }
                        }
                    }
                    else
                    {
                        if (lLocalTransaction)
                            lTransaction.Rollback();
                    }
                }
                catch (Exception ex)
                {
                    lReturn.OperationException = new SerializableException(ex);

                    if (lLocalTransaction)
                        lTransaction.Rollback();
                }
            }

            return lReturn;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(SituacaoFamiliarResideQD._STFAM_ID, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(DocumentoxEETipoAcaoQD._DOCEETPAC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEETipoAcaoQD._DOCEETPAC_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEETipoAcaoQD._DOCEETPAC_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEETipoAcaoQD._DOCEETPAC_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(AssuntoPsicossocialQD._ASSPS_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoPsicossocialQD._ASSPS_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoPsicossocialQD._ASSPS_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoPsicossocialQD._ASSPS_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(ObservacoesDocumentoQD._OBSDOC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(ObservacoesDocumentoQD._OBSDOC_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(ObservacoesDocumentoQD._OBSDOC_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(ObservacoesDocumentoQD._OBSDOC_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(AtividadeDefensorQD._ATDEF_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(AtividadeDefensorQD._ATDEF_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(AtividadeDefensorQD._ATDEF_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(AtividadeDefensorQD._ATDEF_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(ParametrosModeloPeticaoQD._PRMPT_ID, pValues, pResult);
 }
Пример #20
0
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(InteressadoQD._INTE_ID, pValues, pResult);
     //GenericDataObject.ValidateRequired(InteressadoQD._INTE_REGDATE, pValues, pResult);
     //GenericDataObject.ValidateRequired(InteressadoQD._INTE_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(InteressadoQD._INTE_STATUS, pValues, pResult);
 }
Пример #21
0
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(ModeloOficioQD._MDOFC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(ModeloOficioQD._MDOFC_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(ModeloOficioQD._MDOFC_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(ModeloOficioQD._MDOFC_STATUS, pValues, pResult);
 }
Пример #22
0
 private static void ValidateInsert(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateConversion(pValues, pResult);
 }
        public static OperationResult ExcluirTodos(
           DataFieldCollection pValues,
           Transaction pTransactionAtivo,
           ConnectionInfo pInfo
        )
        {
            Transaction pTransaction;

            bool lLocalTransaction = (pTransactionAtivo == null);

            if (lLocalTransaction)
                pTransaction = new Transaction(Instance.CreateDatabase(pInfo));
            else
                pTransaction = pTransactionAtivo;

            UpdateCommand lUpdate;

            OperationResult lReturn = new OperationResult(SituacaoFamiliarResideQD.TableName, SituacaoFamiliarResideQD.TableName);

            ValidateUpdate(pValues, lReturn);

            if (lReturn.IsValid)
            {
                try
                {

                    lUpdate = new UpdateCommand(SituacaoFamiliarResideQD.TableName);

                    foreach (DataField lField in pValues.Keys)
                    {
                        if ((lField.Name != SituacaoFamiliarResideQD._STFAM_ID.Name))
                            lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
                    }

                    string lSql = "";
                    lSql = String.Format("WHERE {0} = <<{0}", SituacaoFamiliarResideQD._STFAM_ID.Name);
                    lUpdate.Condition = lSql;
                    lUpdate.Conditions.Add(SituacaoFamiliarResideQD._STFAM_ID.Name, pValues[SituacaoFamiliarResideQD._STFAM_ID].DBToDecimal());

                    lUpdate.Execute(pTransaction);

                    if (!lReturn.HasError)
                    {
                        if (lLocalTransaction)
                        {
                            if (!lReturn.HasError)
                            {
                                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;
        }
Пример #25
0
        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;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(VisitasAcolhimentoQD._VTACO_ID, pValues, pResult);
 }
Пример #27
0
        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;
        }
Пример #28
0
        public static OperationResult Insert(
           DataFieldCollection pValuesPESF,
           List<DataFieldCollection> pListValuesATUA,
           DataFieldCollection pValuesSUSR,
           List<DataFieldCollection> pListValuesPERMISSAO,
           ConnectionInfo pInfo
        )
        {
            Transaction lTransaction;

            lTransaction = new Transaction(Instance.CreateDatabase(pInfo));

            bool lLocalTransaction = (lTransaction != null);

            InsertCommand lInsert;

            OperationResult lReturn = new OperationResult(PessoaFuncaoQD.TableName, PessoaFuncaoQD.TableName);

            if (!lReturn.HasError)
            {
                try
                {
                    lInsert = new InsertCommand(PessoaFuncaoQD.TableName);

                    foreach (DataField lField in pValuesPESF.Keys)
                    {
                        lInsert.Fields.Add(lField.Name, pValuesPESF[lField], (ItemType)lField.DBType);
                    }
                    decimal lSequencePESF_ID;
                    lSequencePESF_ID = DataBaseSequenceControl.GetNext(pInfo, "PESF_ID");
                    lInsert.Fields.Add(PessoaFuncaoQD._PESF_ID.Name, lSequencePESF_ID, (ItemType)PessoaFuncaoQD._PESF_ID.DBType);

                    lReturn.SequenceControl = lSequencePESF_ID;

                    lInsert.Execute(lTransaction);

                    if (!lReturn.HasError)
                    {

                        if (pListValuesATUA.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListValuesATUA)
                            {
                                lFields.Add(AtuacaoQD._PESF_ID, lSequencePESF_ID);

                                lReturn = AtuacaoDo.Insert(lFields, lTransaction, pInfo);

                                if (lReturn.HasError)
                                {
                                    lTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        lReturn = SystemUserDo.Insert(pValuesSUSR, lTransaction, pInfo);
                        if (lReturn.HasError)
                        {
                            lTransaction.Rollback();
                            return lReturn;
                        }

                        if (pListValuesPERMISSAO.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListValuesPERMISSAO)
                            {
                                lFields.Add(SecurityUsersDtQD._SU_ID, lSequencePESF_ID);

                                lReturn = SecurityUsersDtDo.Insert(lFields, lTransaction, pInfo);

                                if (lReturn.HasError)
                                {
                                    lTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        if (!lReturn.HasError)
                        {
                            lTransaction.Commit();
                        }
                        else
                        {
                            lTransaction.Rollback();
                        }
                    }
                    else
                    {
                        if (lLocalTransaction)
                            lTransaction.Rollback();
                    }
                }
                catch (Exception ex)
                {
                    lReturn.OperationException = new SerializableException(ex);

                    if (lLocalTransaction)
                        lTransaction.Rollback();
                }
            }

            return lReturn;
        }
Пример #29
0
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(PaisQD._PS_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(PaisQD._PS_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(PaisQD._PS_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(PaisQD._PS_STATUS , pValues, pResult);
 }
Пример #30
0
        public static OperationResult Update(
            DataFieldCollection pValues,
            List<DataFieldCollection> pListAtuaInc,
            List<DataFieldCollection> pListAtuaUpd,
            DataFieldCollection pValuesAtuaExcluir,
            List<DataFieldCollection> pListPermissao,
            ConnectionInfo pInfo
        )
        {
            Transaction pTransaction;

            pTransaction = new Transaction(Instance.CreateDatabase(pInfo));

            bool lLocalTransaction = (pTransaction != null);

            UpdateCommand lUpdate;

            OperationResult lReturn = new OperationResult(PessoaFuncaoQD.TableName, PessoaFuncaoQD.TableName);

            ValidateUpdate(pValues, lReturn);

            if (lReturn.IsValid)
            {
                try
                {
                    lUpdate = new UpdateCommand(PessoaFuncaoQD.TableName);

                    foreach (DataField lField in pValues.Keys)
                    {
                        if ((lField.Name != PessoaFuncaoQD._PESF_ID.Name))
                            lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
                    }

                    string lSql = "";
                    lSql = String.Format("WHERE {0} = <<{0}", PessoaFuncaoQD._PESF_ID.Name);
                    lUpdate.Condition = lSql;
                    lUpdate.Conditions.Add(PessoaFuncaoQD._PESF_ID.Name, pValues[PessoaFuncaoQD._PESF_ID].DBToDecimal());

                    lUpdate.Execute(pTransaction);

                    if (!lReturn.HasError)
                    {
                        //Excluir atuação do núcleo alterado
                        if (pValuesAtuaExcluir.Count > 0)
                        {
                            lReturn = AtuacaoDo.UpdateInativo(pValuesAtuaExcluir, pInfo);

                            if (lReturn.HasError)
                            {
                                pTransaction.Rollback();
                                return lReturn;
                            }
                        }

                        if (pListAtuaInc.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListAtuaInc)
                            {
                                lReturn = AtuacaoDo.Insert(lFields, pTransaction, pInfo);

                                if (lReturn.HasError)
                                {
                                    pTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        if (pListAtuaUpd.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListAtuaUpd)
                            {
                                lReturn = AtuacaoDo.Update(lFields, pTransaction, pInfo);

                                if (lReturn.HasError)
                                {
                                    pTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        if (pListPermissao.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListPermissao)
                            {
                                lReturn = SecurityUsersDtDo.Insert(lFields, pTransaction, pInfo);

                                if (lReturn.HasError)
                                {
                                    pTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        if (!lReturn.HasError)
                        {
                            pTransaction.Commit();
                        }
                        else
                        {
                            pTransaction.Rollback();
                        }
                    }
                    else
                    {
                        if (lLocalTransaction)
                            pTransaction.Rollback();
                    }
                }
                catch (Exception ex)
                {
                    lReturn.OperationException = new SerializableException(ex);

                    if (lLocalTransaction)
                        pTransaction.Rollback();
                }
            }

            return lReturn;
        }