Ejemplo n.º 1
0
        /// <summary>
        /// Get next value for the primary key
        /// </summary>
        /// <returns></returns>
        private static int GetNextValue()
        {
            //next value will be 1 if there is no row in the datatable.
            int nextValue = 1;

            try
            {
                //Get object collection
                VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection objs = GetAll();

                //Get all objects Id
                int[] sortedObjsId = new int[objs.Count];
                for (int i = 0; i < objs.Count; i++)
                {
                    sortedObjsId[i] = objs[i].EntryId;
                }

                //Sort the object id
                Array.Sort(sortedObjsId);

                for (int j = 0; j < sortedObjsId.Length; j++)
                {
                    if (j + 1 < sortedObjsId.Length)
                    {
                        if (sortedObjsId[j] + 1 < sortedObjsId[j + 1])
                        {
                            nextValue = sortedObjsId[j] + 1;
                            break;
                        }
                    }
                    else
                    {
                        nextValue = sortedObjsId[sortedObjsId.Length - 1] + 1;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(nextValue);
        }
Ejemplo n.º 2
0
        public static VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection GetAll()
        {
            VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection accountHistories = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection();
            try
            {
                //Stored procedure must have cur_out parameter.
                //There is no need to add ref cursor for oracle in code.
                string    spName  = VaaaN.MLFF.Libraries.CommonLibrary.Constants.oraclePackagePrefix + "ACCOUNT_HISTORY_GETALL";
                DbCommand command = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.GetStoredProcCommand(spName);

                DataSet   ds = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.LoadDataSet(command, tableName);
                DataTable dt = ds.Tables[tableName];
                accountHistories = ConvertDataTableToCollection(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(accountHistories);
        }
Ejemplo n.º 3
0
        private static VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection ConvertDataTableToCollection(DataTable dt)
        {
            try
            {
                VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection accountHistories = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCollection();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCBE crossTalkPacket = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCBE();

                    if (dt.Rows[i]["TMS_ID"] != DBNull.Value)
                    {
                        crossTalkPacket.TMSId = Convert.ToInt32(dt.Rows[i]["TMS_ID"]);
                    }

                    if (dt.Rows[i]["ENTRY_ID"] != DBNull.Value)
                    {
                        crossTalkPacket.EntryId = Convert.ToInt32(dt.Rows[i]["ENTRY_ID"]);
                    }

                    if (dt.Rows[i]["TRANSACTION_ID"] != DBNull.Value)
                    {
                        crossTalkPacket.TransactionId = Convert.ToInt32(dt.Rows[i]["TRANSACTION_ID"]);
                    }

                    if (dt.Rows[i]["AMOUNT"] != DBNull.Value)
                    {
                        crossTalkPacket.Amount = Convert.ToDecimal(dt.Rows[i]["AMOUNT"]);
                    }

                    if (dt.Rows[i]["SMS_SENT"] != DBNull.Value)
                    {
                        crossTalkPacket.IsSMSSent = Convert.ToInt32(dt.Rows[i]["SMS_SENT"]);
                    }

                    if (dt.Rows[i]["EMAIL_SENT"] != DBNull.Value)
                    {
                        crossTalkPacket.IsEmailSent = Convert.ToInt32(dt.Rows[i]["EMAIL_SENT"]);
                    }


                    if (dt.Rows[i]["MODIFIED_BY"] != DBNull.Value)
                    {
                        crossTalkPacket.ModifierId = Convert.ToInt32(dt.Rows[i]["MODIFIED_BY"]);
                    }

                    if (dt.Rows[i]["CREATION_DATE"] != DBNull.Value)
                    {
                        crossTalkPacket.CreationDate = Convert.ToDateTime(dt.Rows[i]["CREATION_DATE"]);
                    }


                    accountHistories.Add(crossTalkPacket);
                }
                return(accountHistories);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }