示例#1
0
        public ProcurementAggregatorData fetchProcurementAggregator(CmsPage page, int identifier, CmsLanguage lang, bool createIfNotExist)
        {
            if (page.Id < 0 || identifier < 0)
            {
                return(new ProcurementAggregatorData());
            }

            StringBuilder sql = new StringBuilder("SELECT DefaultYearToDisplay FROM ");

            sql.Append(TableNameAggregator);
            sql.Append(" WHERE PageId=" + page.Id.ToString());
            sql.Append(" AND LangCode='" + lang.shortCode + "'");
            sql.Append(" AND Identifier=" + identifier.ToString());
            sql.Append(" AND Deleted is null;");

            ProcurementAggregatorData entity = new ProcurementAggregatorData();
            DataSet ds = this.RunSelectQuery(sql.ToString());

            if (this.hasSingleRow(ds))
            {
                DataRow dr = ds.Tables[0].Rows[0];
                entity.YearToDisplay = Convert.ToInt32(dr["DefaultYearToDisplay"]);
            }
            else
            {
                if (createIfNotExist)
                {
                    if (addProcurementAggregator(page, identifier, lang, entity) == false)
                    {
                        throw new Exception("fetchProcurementAggregator() database error: Error creating new placeholder");
                    }
                }
                else
                {
                    throw new Exception("fetchProcurementAggregator() database error: placeholder does not exist");
                }
            }
            return(entity);
        }
示例#2
0
        public bool addProcurementAggregator(CmsPage page, int identifier, CmsLanguage lang, ProcurementAggregatorData entity)
        {
            StringBuilder sql = new StringBuilder("INSERT INTO ");

            sql.Append(TableNameAggregator);
            sql.Append(" (PageId,Identifier,LangCode,DefaultYearToDisplay) VALUES (");
            sql.Append(page.Id.ToString() + ",");
            sql.Append(identifier.ToString() + ",'");
            sql.Append(dbEncode(lang.shortCode) + "',");
            sql.Append(entity.YearToDisplay.ToString() + ");");

            int affected = this.RunUpdateQuery(sql.ToString());

            if (affected > 0)
            {
                return(page.setLastUpdatedDateTimeToNow());
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        public bool updateProcurementAggregator(CmsPage page, int identifier, CmsLanguage lang, ProcurementAggregatorData entity)
        {
            StringBuilder sql = new StringBuilder("UPDATE ");

            sql.Append(TableNameAggregator);
            sql.Append(" SET DefaultYearToDisplay = " + entity.YearToDisplay.ToString());
            sql.Append(" WHERE PageId=" + page.Id.ToString());
            sql.Append(" AND LangCode='" + lang.shortCode + "'");
            sql.Append(" AND Identifier=" + identifier.ToString());

            int affected = this.RunUpdateQuery(sql.ToString());

            return(affected > 0);
        }