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 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(AssuntoProcessualQD._ASSPRC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoProcessualQD._ASSPRC_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoProcessualQD._ASSPRC_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(AssuntoProcessualQD._ASSPRC_STATUS, pValues, pResult);
 }
        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(AssuntoProcessualQD.TableName, AssuntoProcessualQD.TableName);

            ValidateUpdate(pValues, lReturn);

            if (lReturn.IsValid)
            {
                try
                {
                    if (lLocalTransaction)
                    {
                        lReturn.Trace("Transação local, instanciando banco...");
                    }

                    lUpdate = new UpdateCommand(AssuntoProcessualQD.TableName);

                    lReturn.Trace("Adicionando campos ao objeto de update");
                    foreach (DataField lField in pValues.Keys)
                    {
                        if ((lField.Name != AssuntoProcessualQD._ASSPRC_ID.Name))
                            lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
                    }

                    string lSql = "";
                    lSql = String.Format("WHERE {0} = <<{0}", AssuntoProcessualQD._ASSPRC_ID.Name);
                    lUpdate.Condition = lSql;
                    lUpdate.Conditions.Add(AssuntoProcessualQD._ASSPRC_ID.Name, pValues[AssuntoProcessualQD._ASSPRC_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;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(CasaPenalQD._CSP_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(CasaPenalQD._CSP_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(CasaPenalQD._CSP_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(CasaPenalQD._CSP_STATUS, pValues, pResult);
 }
        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(NucleoxSecretariaQD.TableName, NucleoxSecretariaQD.TableName);

            if (lReturn.IsValid)
            {
                try
                {
                    if (lLocalTransaction)
                    {
                        lReturn.Trace("Transação local, instanciando banco...");
                    }

                    lUpdate = new UpdateCommand(NucleoxSecretariaQD.TableName);

                    lReturn.Trace("Adicionando campos ao objeto de update");

                    lUpdate.Fields.Add(NucleoxSecretariaQD._NUCSCT_STATUS.Name, "I", (ItemType)NucleoxSecretariaQD._NUCSCT_STATUS.DBType);

                    string lSql = "";
                    lSql = String.Format("WHERE {0} = <<{0}", NucleoxSecretariaQD._NUC_ID.Name);
                    lUpdate.Condition = lSql;
                    lUpdate.Conditions.Add(NucleoxSecretariaQD._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;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(UnidadeVaraInfracionalQD._UVI_ID, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(NucleoxAreaAtuacaoQD._NUCARATUA_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxAreaAtuacaoQD._NUCARATUA_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxAreaAtuacaoQD._NUCARATUA_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxAreaAtuacaoQD._NUCARATUA_STATUS, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(ALUNOXATENDIMENTONPJQD._AAN_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(ALUNOXATENDIMENTONPJQD._AAN_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(ALUNOXATENDIMENTONPJQD._AAN_USUARIO, pValues, pResult);
     GenericDataObject.ValidateRequired(ALUNOXATENDIMENTONPJQD._AAN_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(TipoOficioQD._TPOFC_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(TipoOficioQD._TPOFC_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(TipoOficioQD._TPOFC_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(TipoOficioQD._TPOFC_STATUS, pValues, pResult);
 }
        private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
        {
            GenericDataObject.ValidateRequired(SystemUserQD._SUSR_ID, pValues, pResult);

            GenericDataObject.ValidateRequired(SystemUserQD._SUSR_REGDATE, pValues, pResult);

            GenericDataObject.ValidateRequired(SystemUserQD._SUSR_REGUSR, pValues, pResult);

            GenericDataObject.ValidateRequired(SystemUserQD._SUSR_STATUS, pValues, pResult);
        }
        public static string ChangePassword(decimal pSusr_Id, string pSusr_Login, string pSusr_Password_old, string pSusr_Password_new, ConnectionInfo pConnectionInfo)
        {
            bool lPasswordOK;
            string lPassword;
            string lResult = "";
            OperationResult lReturn;

            Transaction pTransaction;

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

            // Validando a Senha Digitada.
            lPassword = GetPassword(pSusr_Login, pConnectionInfo);
            lPasswordOK = (lPassword == pSusr_Password_old) ? true : false;
            if (!lPasswordOK)
                lResult = "Senha Atual Incorreta";

            // Verificando Transação
            bool lLocalTransaction = (pTransaction != null);
            UpdateCommand lUpdate;
            lReturn = new OperationResult(SystemUserQD.TableName, SystemUserQD.TableName);

            if (lPasswordOK)
            {
                // Iniciando processo de update...
                if (lReturn.IsValid)
                {
                    try
                    {
                        if (lLocalTransaction)
                        {
                            lReturn.Trace("ExternalUser: Transação local, instanciando banco...");
                        }

                        lUpdate = new UpdateCommand(SystemUserQD.TableName);

                        lReturn.Trace("ExternalUser: Adicionando campos ao objeto de update");

                        lUpdate.Fields.Add(SystemUserQD._SUSR_PASSWORD.Name, APB.Framework.Encryption.Crypto.Encode(pSusr_Password_new), (ItemType)SystemUserQD._SUSR_PASSWORD.DBType);

                        string lSql = "";

                        //TODO: Condição where customizada
                        lSql = String.Format("WHERE {0} = >>{0}", SystemUserQD._SUSR_ID.Name);

                        lUpdate.Condition = lSql;

                        lUpdate.Conditions.Add(SystemUserQD._SUSR_ID.Name, pSusr_Id);

                        lReturn.Trace("ExternalUser: Executando o Update");

                        lUpdate.Execute(pTransaction);

                        if (!lReturn.HasError)
                        {
                            if (lLocalTransaction)
                            {
                                if (!lReturn.HasError)
                                {
                                    lReturn.Trace("ExternalUser: 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();
                    }
                }
            }
            else
            {
                return "Senha atual incorreta";
            }

            if (lReturn.IsValid)
                lResult = "";
            else
                lResult = lReturn.ToString();

            return lResult;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(CalendarioJuridicoQD._CLDJ_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(CalendarioJuridicoQD._CLDJ_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(CalendarioJuridicoQD._CLDJ_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(CalendarioJuridicoQD._CLDJ_STATUS, pValues, pResult);
 }
        public static OperationResult UpdateByNucleoArea(
            DataFieldCollection pValues,
            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");
                    foreach (DataField lField in pValues.Keys)
                    {
                        if ((lField.Name != NucleoxAreaAtuacaoQD._NUC_ID.Name) && (lField.Name != NucleoxAreaAtuacaoQD._ARATUA_ID.Name))
                            lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
                    }

                    string lSql = "";
                    lSql = String.Format("WHERE {0} = >>{0} AND {1} = >>{1} AND {2} = >>{2}", NucleoxAreaAtuacaoQD._NUC_ID.Name, NucleoxAreaAtuacaoQD._ARATUA_ID.Name, NucleoxAreaAtuacaoQD._NUCARATUA_STATUS.Name);
                    lUpdate.Condition = lSql;
                    lUpdate.Conditions.Add(NucleoxAreaAtuacaoQD._NUC_ID.Name, pValues[NucleoxAreaAtuacaoQD._NUC_ID].DBToDecimal());
                    lUpdate.Conditions.Add(NucleoxAreaAtuacaoQD._ARATUA_ID.Name, pValues[NucleoxAreaAtuacaoQD._ARATUA_ID].DBToDecimal());
                    lUpdate.Conditions.Add(NucleoxAreaAtuacaoQD._NUCARATUA_STATUS.Name, pValues[NucleoxAreaAtuacaoQD._NUCARATUA_STATUS].ToString());

                    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;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(DocumentoxAssuntoPsicossocialQD._DOCASSPS_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxAssuntoPsicossocialQD._DOCASSPS_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxAssuntoPsicossocialQD._DOCASSPS_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxAssuntoPsicossocialQD._DOCASSPS_STATUS, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(DocumentoxEEDestinoQD._DOCEEDST_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEEDestinoQD._DOCEEDST_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEEDestinoQD._DOCEEDST_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(DocumentoxEEDestinoQD._DOCEEDST_STATUS, pValues, pResult);
 }
        public static OperationResult Update(
            DataFieldCollection pValues,
            List<DataFieldCollection> pListValuesSFR,
            DataFieldCollection pValuesSFRExcluir,
            ConnectionInfo pInfo
        )
        {
            Transaction pTransaction;

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

            bool lLocalTransaction = (pTransaction != null);

            UpdateCommand lUpdate;

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

            ValidateUpdate(pValues, lReturn);

            if (lReturn.IsValid)
            {
                try
                {

                    lUpdate = new UpdateCommand(SituacaoFamiliarQD.TableName);

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

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

                    lUpdate.Execute(pTransaction);

                    if (!lReturn.HasError)
                    {

                        if (pListValuesSFR.Count > 0)
                        {
                            //1º Exclui todos os registros ja salvos
                            lReturn = SituacaoFamiliarResideDo.ExcluirTodos(pValuesSFRExcluir, pTransaction, pInfo);

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

                            //2º inclui os novos registros
                            foreach (DataFieldCollection lFields in pListValuesSFR)
                            {
                                lFields.Add(SituacaoFamiliarResideQD._STFAM_ID, pValues[SituacaoFamiliarQD._STFAM_ID].DBToDecimal());

                                lReturn = SituacaoFamiliarResideDo.Insert(lFields, pTransaction, pInfo);
                                if (lReturn.HasError)
                                {
                                    pTransaction.Rollback();
                                    return lReturn;
                                }
                            }
                        }

                        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;
        }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(EEProcedimentoQD._EEPCD_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(EEProcedimentoQD._EEPCD_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(EEProcedimentoQD._EEPCD_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(EEProcedimentoQD._EEPCD_STATUS , pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(SituacaoFamiliarQD._STFAM_ID, pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(NucleoxSecretariaQD._NUCSCT_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxSecretariaQD._NUCSCT_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxSecretariaQD._NUCSCT_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(NucleoxSecretariaQD._NUCSCT_STATUS, pValues, pResult);
 }
        public static OperationResult Insert(
           DataFieldCollection pValues,
           List<DataFieldCollection> pListValuesSFR,
           ConnectionInfo pInfo
        )
        {
            Transaction lTransaction;

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

            bool lLocalTransaction = (lTransaction != null);

            InsertCommand lInsert;

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

            if (!lReturn.HasError)
            {
                try
                {

                    lInsert = new InsertCommand(SituacaoFamiliarQD.TableName);

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

                    lInsert.Execute(lTransaction);

                    if (!lReturn.HasError)
                    {
                        if (pListValuesSFR.Count > 0)
                        {
                            foreach (DataFieldCollection lFields in pListValuesSFR)
                            {
                                lFields.Add(SituacaoFamiliarResideQD._STFAM_ID, lSequence);

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

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

                        if (lLocalTransaction)
                        {
                            if (!lReturn.HasError)
                            {
                                lReturn.SequenceControl = lSequence;
                                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(VisitasSocioEducativasQD._VTSCE_ID, pValues, pResult);
 }
Beispiel #26
0
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(sectorQD._SECT_ID, pValues, pResult);
 }
 private static void ValidateInsert(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateConversion(pValues, pResult);
 }
 private static void ValidateUpdate(DataFieldCollection pValues, OperationResult pResult)
 {
     GenericDataObject.ValidateRequired(AgendamentoDefensorQD._AGDF_ID, pValues, pResult);
     //GenericDataObject.ValidateRequired(AgendamentoDefensorQD._AGDF_REGDATE, pValues, pResult);
     //GenericDataObject.ValidateRequired(AgendamentoDefensorQD._AGDF_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(AgendamentoDefensorQD._AGDF_STATUS, pValues, pResult);
 }
        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(AssuntoProcessualQD.TableName, AssuntoProcessualQD.TableName);

            if (!lReturn.HasError)
            {
                try
                {
                    if (lLocalTransaction)
                    {
                        lReturn.Trace("Transação local, instanciando banco...");
                    }

                    lInsert = new InsertCommand(AssuntoProcessualQD.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, "ASSPRC_ID");
                    lInsert.Fields.Add(AssuntoProcessualQD._ASSPRC_ID.Name, lSequence, (ItemType)AssuntoProcessualQD._ASSPRC_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(RelatorioAtualizacaoQD._RLT_ID, pValues, pResult);
     GenericDataObject.ValidateRequired(RelatorioAtualizacaoQD._RLT_REGDATE, pValues, pResult);
     GenericDataObject.ValidateRequired(RelatorioAtualizacaoQD._RLT_REGUSER, pValues, pResult);
     GenericDataObject.ValidateRequired(RelatorioAtualizacaoQD._RLT_STATUS , pValues, pResult);
 }