コード例 #1
0
        private int m_iDefaultValue          = 0;                    // Default value index

        #endregion Data members

        #region Consturctors, Initialization & Destructor

        public cCatItem(IErrorHandler cErrors, IRepository rep, enumCatType eType)
        {
            m_objErrorHandler = cErrors;
            repository        = rep;
            m_enumCategory    = eType;
            //setCategoryItems();
        }//constructor
コード例 #2
0
        }                                                                    //getCategoryItemByName

        private ICategoryCollection getCategoryCollectionByType(enumCatType eType)
        { // Returns the desired category collection
            switch (eType)
            {
            case enumCatType.StockMarket: return(m_colMarkets);

            case enumCatType.SecurityType: return(m_colSecTypes);

            default: return(m_colSectors);
            }
        }//getCategoryCollectionByType
コード例 #3
0
 public int getCollectionPos(enumCatType eCat)
 { // Retrieves the position of the category in collection
     for (int iCats = 0; iCats < base.Count; iCats++)
     {
         if (this[iCats].CategoryType == eCat)
         {
             return(iCats);
         }
     }
     return(0);
 }//getCollectionPos
コード例 #4
0
        }//loadSecuritiesFromCollection

        public ICategoryItem getCatItemByID(enumCatType eType, int iId, ICategoryCollection cCollection)
        { // Retrieves category Item From given category ID
            ICategoryItem cCurrItem = cCollection.getItemByID(iId);

            if (cCurrItem == null) // new item
            {                      // Doesn't exist - create new
                cCurrItem = new cCategoryItem(eType, m_objCatHandler.getCategoryCol(eType).getCategoryVal(iId), iId, m_objErrorHandler, m_objPortfolio);
                cCollection.Add(cCurrItem);
            }
            return(cCurrItem);
        }//getCatItemByID
コード例 #5
0
        }//getSecDisplayValue

        //public String getSecurityCurrencyFormat()
        //{ // Retrieves the currency format suitable for current security
        //    String strSymbol = "$";
        //    switch (m_catCurrency.ID)
        //    {
        //        case 1: strSymbol = "$"; break;
        //        case 2: strSymbol = "€"; break;
        //        case 3: strSymbol = "£"; break;
        //        case 4: strSymbol = "₪"; break;
        //    }
        //    return "#,0.00" + strSymbol + ";#,0.00" + strSymbol;
        //}//getSecurityCurrencyFormat

        #endregion General methods

        #region Category Items

        public ICategoryItem getCurrentCategoryValue(enumCatType eType)
        { // Retrieves the desired category item by type
            switch (eType)
            {
            case enumCatType.Sector: return(m_catSector);

            case enumCatType.SecurityType: return(m_catSecType);

            case enumCatType.StockMarket: return(m_catMarket);
                //case enumCatType.Currency: return m_catCurrency;
            }
            return(null);
        }//getCurrentCategoryValue
コード例 #6
0
        }//calculateItemWeight

        public cCategoryCollection getCategoryMatchingItems(enumCatType eType)
        { // Retrieves the desired category items matching the current item
            cCategoryCollection cFinalCol = new cCategoryCollection(eType, m_objErrorHandler);

            try
            {
                for (int iSecs = 0; iSecs < m_colSecurities.Count; iSecs++) // Goes through item securities (to obtain target items)
                {
                    cFinalCol.AddIfNotExists(m_colSecurities[iSecs].Properties.getCurrentCategoryValue(eType));
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
            return(cFinalCol);
        }//getCategoryMatchingItems
コード例 #7
0
        private ISecurities m_colSecurities; // Securities belonging to current

        #endregion Data Members

        #region Constructors, Initialization & Destructors

        public cCategoryItem(enumCatType eType, String strName, int iId, IErrorHandler cErrors, IPortfolioBL cPort)
        {
            m_enumItemType    = eType;
            m_strName         = strName;
            m_iItemId         = iId;
            m_objErrorHandler = cErrors;
            m_objPortfolio    = cPort;
            m_colSecurities   = new cSecurities(m_objPortfolio);

            try
            {
                m_objColor = Color.FromArgb(cProperties.RndGenerator.Next(0, 255), cProperties.RndGenerator.Next(0, 255), cProperties.RndGenerator.Next(0, 255));
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//constructor
コード例 #8
0
        private enumCatType m_enCategoryType; // Category type of collection

        #endregion Data members

        #region Constructor

        public cCategoryCollection(enumCatType eType, IErrorHandler cErrors)
        {
            m_objErrorHandler = cErrors;
            m_enCategoryType  = eType;
        }//constructor
コード例 #9
0
        }//initSelCollections

        public ICategoryItem getCategoryItemByName(String strName, enumCatType eType)
        {
            return(getCategoryCollectionByType(eType).getItemByName(strName));
        }                                                                    //getCategoryItemByName
コード例 #10
0
        }//getCategoryPos

        public int getCategoryId(enumCatType eType, String strName)
        { // Retrieves the id of a given name from a given category table
            return(m_colCatItems[m_colCatItems.getCollectionPos(eType)].getCategoryId(strName));
        }//getCategoryId
コード例 #11
0
        }//initMainCatCollection

        #endregion Internal methods

        #region Data insertion

        //public void addNewValue(enumCatType eType, String strVal)
        //{ // Inserts new value to DB and Category collections
        //    String strTblName = getTblName(eType);
        //    insertValToDB(strTblName, strVal);
        //    m_colCatItems[m_colCatItems.getCollectionPos(eType)].Items.Add(new sCatData(getCategoryIdFromDB(eType, strTblName, strVal), strVal));
        //}//addNewValue

        //private void insertValToDB(String strTblName, String strVal)
        //{ // Inserts category value to DB
        //    String strCommand = cSqlStatements.insertCategoryItemToDbSQL(strTblName, strVal);
        //    SqlCommand sqlNewCommand = new SqlCommand(strCommand, m_objMainConnection.dbConnection);
        //    sqlNewCommand.ExecuteNonQuery();
        //    if (sqlNewCommand != null) sqlNewCommand.Dispose();
        //}//insertValToDB

        //private int getCategoryIdFromDB(enumCatType eType, String strTblName, String strVal)
        //{ // Retrieves the category ID after it has been inserted to DB
        //    SqlDataReader sqlNewReader = null;
        //    try
        //    {
        //        SqlCommand sqlNewCommand = new SqlCommand(cSqlStatements.getTblValsByStrConditionSQL(strTblName, "strName", strVal), m_objMainConnection.dbConnection);
        //        sqlNewReader = sqlNewCommand.ExecuteReader();
        //        if (sqlNewReader.Read()) return Convert.ToInt32(sqlNewReader[getIdFldName(eType)]);
        //    } catch (Exception ex) {
        //        m_objErrorHandler.LogInfo(ex);
        //    } finally {
        //        if (sqlNewReader != null) sqlNewReader.Dispose();
        //    }
        //    return -1;
        //}//getCatValIdFromDB

        #endregion Data insertion

        #region Retrieve data

        public int getCategoryPos(enumCatType eType, String strName)
        { // Retrieves the position of a given name from a given category array
            return(m_colCatItems[m_colCatItems.getCollectionPos(eType)].getCategoryPos(strName));
        }//getCategoryPos
コード例 #12
0
        }//getCategoryCol

        public String getCategoryDefault(enumCatType eType)
        { // Retrieves default value of a given category
            return(m_colCatItems[m_colCatItems.getCollectionPos(eType)].DefaultItem.strValue);
        }//getCategoryDefault
コード例 #13
0
        }//getCategoryName

        public ICatItem getCategoryCol(enumCatType eType)
        { // Retrieves collection of a given category
            return(m_colCatItems[m_colCatItems.getCollectionPos(eType)]);
        }//getCategoryCol
コード例 #14
0
        }//getCategoryId

        public String getCategoryName(enumCatType eType, int iCatId)
        { // Returns category value for a given index
            return(m_colCatItems[m_colCatItems.getCollectionPos(eType)].getCategoryVal(iCatId));
        }//getCategoryName