Exemple #1
0
        public List <SeriesOPMTitleEntity> GetSeriesOPMTitlesBySeriesID(int seriesID)
        {
            List <SeriesOPMTitleEntity> listCollection = new List <SeriesOPMTitleEntity>();

            DataTable dataItems = ExecuteDataTable("spr_GetSeriesOPMTitlesBySeriesID", seriesID);

            if (dataItems != null)
            {
                for (int i = 0; i < dataItems.Rows.Count; i++)
                {
                    SeriesOPMTitleEntity item = new SeriesOPMTitleEntity();

                    item.SeriesID       = dataItems.Rows[i].Field <int>("Series");
                    item.OPMTitle       = dataItems.Rows[i].Field <string>("SeriesOPMTitle");
                    item.OPMDescription = dataItems.Rows[i].Field <string>("SeriesOPMTitleDescription");

                    listCollection.Add(item);
                }
            }
            else
            {
                throw new Exception("You cannot create a SeriesOPMTitleEntity collection from a null data table.");
            }

            return(listCollection.OrderBy(t => t.OPMTitle).ToList());
        }
Exemple #2
0
        public bool AddOPMTitle(SeriesOPMTitleEntity entity, TransactionManager currentTransaction)
        {
            bool isSuccessfullyInserted = false;
            int  retcode = -1;

            DbCommand commandWrapper = GetDbCommand("spr_AddSeriesOPMTitle");

            try
            {
                if (entity.SeriesID <= 0)
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@Series", DBNull.Value));
                }
                else
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@Series", entity.SeriesID));
                }

                if (string.IsNullOrEmpty(entity.OPMTitle))
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitle", DBNull.Value));
                }
                else
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitle", entity.OPMTitle));
                }

                if (string.IsNullOrEmpty(entity.OPMDescription))
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitleDescription", DBNull.Value));
                }
                else
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitleDescription", entity.OPMDescription));
                }

                if (currentTransaction != null)
                {
                    retcode = (int)DatabaseUtility.ExecuteScalar(currentTransaction, commandWrapper);
                }
                else
                {
                    retcode = (int)ExecuteScalar(commandWrapper);
                }
            }
            catch (Exception ex)
            {
                currentTransaction.Rollback();
                HandleException(ex);
            }

            if (retcode > 0)
            {
                isSuccessfullyInserted = true;
            }

            return(isSuccessfullyInserted);
        }
Exemple #3
0
        public void Update(SeriesOPMTitleEntity entity, TransactionManager currentTransaction)
        {
            if (base.ValidateKeyField(entity.SeriesID))
            {
                DbCommand commandWrapper = GetDbCommand("spr_UpdateSeriesOPMTitle");

                try
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@series", entity.SeriesID));

                    if (string.IsNullOrEmpty(entity.OPMTitle))
                    {
                        commandWrapper.Parameters.Add(new SqlParameter("@seriesOPMTitle", DBNull.Value));
                    }
                    else
                    {
                        commandWrapper.Parameters.Add(new SqlParameter("@seriesOPMTitle", entity.OPMTitle));
                    }

                    if (string.IsNullOrEmpty(entity.OPMDescription))
                    {
                        commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitleDescription", DBNull.Value));
                    }
                    else
                    {
                        commandWrapper.Parameters.Add(new SqlParameter("@SeriesOPMTitleDescription", entity.OPMDescription));
                    }

                    if (currentTransaction != null)
                    {
                        DatabaseUtility.ExecuteNonQuery(currentTransaction, commandWrapper);
                    }
                    else
                    {
                        ExecuteNonQuery(commandWrapper);
                    }
                }
                catch (Exception ex)
                {
                    currentTransaction.Rollback();
                    HandleException(ex);
                }
            }
        }
Exemple #4
0
        public SeriesOPMTitleEntity GetSeriesOPMTitlesByID(int seriesID, string ompTitle)
        {
            SeriesOPMTitleEntity entity;

            DataTable dt = ExecuteDataTable("spr_GetSeriesOPMTitleByID", seriesID, ompTitle);

            if (dt != null && dt.Rows.Count > 0)
            {
                entity = new SeriesOPMTitleEntity();

                entity.SeriesID       = dt.Rows[0].Field <int>("Series");
                entity.OPMTitle       = dt.Rows[0].Field <string>("SeriesOPMTitle");
                entity.OPMDescription = dt.Rows[0].Field <string>("SeriesOPMTitleDescription");
            }
            else
            {
                throw new Exception("You cannot create a SeriesOPMTitleEntity object from a null data table.");
            }

            return(entity);
        }
Exemple #5
0
 public void Update(SeriesOPMTitleEntity entity)
 {
     Update(entity, null);
 }
Exemple #6
0
 public bool AddOPMTitle(SeriesOPMTitleEntity entity)
 {
     return(AddOPMTitle(entity, null));
 }