private static CategoryRating loadData(DataTable returnTable)
        {
            CategoryRating currentcr = new CategoryRating();

            if (returnTable.Rows.Count > 0)
            {
                DataRow returnRow = returnTable.Rows[0];

                currentcr = FillObjectFromRowData(returnRow);
            }
            return(currentcr);
        }
        public static CategoryRating GetByJNPID(long JNPID)
        {
            CategoryRating item = null;

            try
            {
                DataTable dataTable = ExecuteDataTable("spr_GetCategoryRatingByJNPID", JNPID);
                item = loadData(dataTable);
            }
            catch (Exception ex)
            {
                item = null;
                ExceptionBase.HandleException(ex);
            }

            return(item);
        }
        private static CategoryRating FillObjectFromRowData(DataRow dataRow)
        {
            CategoryRating currentcr = new CategoryRating();

            try
            {
                currentcr.CRID                   = (long)dataRow["CRID"];
                currentcr.JAID                   = (long)dataRow["JAID"];
                currentcr.PayPlanID              = (int)dataRow["PayPlanID"];
                currentcr.SeriesID               = (int)dataRow["SeriesID"];
                currentcr.LowestAdvertisedGrade  = (int)dataRow["LowestAdvertisedGrade"];
                currentcr.HighestAdvertisedGrade = (int)dataRow["HighestAdvertisedGrade"];
                if (dataRow["IsStandardCR"] != DBNull.Value)
                {
                    currentcr.IsStandardCR = (bool)dataRow["IsStandardCR"];
                }
                if (dataRow["CreatedByID"] != DBNull.Value)
                {
                    currentcr.CreatedByID = (int)dataRow["CreatedByID"];
                }
                if (dataRow["CreateDate"] != DBNull.Value)
                {
                    currentcr.CreateDate = (DateTime)dataRow["CreateDate"];
                }
                if (dataRow["UpdatedByID"] != DBNull.Value)
                {
                    currentcr.UpdatedByID = (int)dataRow["UpdatedByID"];
                }
                if (dataRow["UpdateDate"] != DBNull.Value)
                {
                    currentcr.UpdateDate = (DateTime)dataRow["UpdateDate"];
                }
                if (dataRow["IsActive"] != DBNull.Value)
                {
                    currentcr.IsActive = (bool)dataRow["IsActive"];
                }
            }
            catch (Exception ex)
            {
                currentcr = null;
                ExceptionBase.HandleException(ex);
            }
            return(currentcr);
        }
        // disabled this method since is not being used anywhere in the system and it adds more overhead to this object
        //public static long AddCategoryRating(CategoryRating currentcr)
        //{
        //    long crid = -1;
        //    try
        //    {
        //        DbCommand commandWrapper = GetDbCommand("spr_CreateCategoryRating");
        //        SqlParameter returnParam = new SqlParameter("@newCRID", SqlDbType.BigInt);
        //        returnParam.Direction = ParameterDirection.Output;
        //        // get the new CRID of the record
        //        commandWrapper.Parameters.Add(returnParam);
        //        commandWrapper.Parameters.Add(new SqlParameter("@jAID", currentcr.JAID ));
        //        commandWrapper.Parameters.Add(new SqlParameter("@payPlanID", currentcr.PayPlanID));
        //        commandWrapper.Parameters.Add (new SqlParameter("@seriesID",currentcr.SeriesID ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@LowestAdvertisedGrade",currentcr.LowestAdvertisedGrade ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@HighestAdvertisedGrade",currentcr.HighestAdvertisedGrade ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@isStandardCR",currentcr.IsStandardCR ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@createdByID",currentcr.CreatedByID ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@createDate",currentcr.CreateDate ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@updatedByID",currentcr.UpdatedByID ));
        //        commandWrapper.Parameters.Add (new SqlParameter("@updateDate",currentcr.UpdateDate  ));
        //        ExecuteNonQuery(commandWrapper);
        //        crid = (long)returnParam.Value;
        //    }
        //    catch (Exception ex)
        //    {
        //        HandleException(ex);

        //    }
        //    return crid;
        //}

        public static void UpdateCategoryRating(CategoryRating currentcr)
        {
            try
            {
                DbCommand commandWrapper = GetDbCommand("spr_UpdateCategoryRating");

                commandWrapper.Parameters.Add(new SqlParameter("@cRID", currentcr.CRID));
                commandWrapper.Parameters.Add(new SqlParameter("@jAID", currentcr.JAID));
                commandWrapper.Parameters.Add(new SqlParameter("@payPlanID", currentcr.PayPlanID));
                commandWrapper.Parameters.Add(new SqlParameter("@seriesID", currentcr.SeriesID));
                commandWrapper.Parameters.Add(new SqlParameter("@LowestAdvertisedGrade", currentcr.LowestAdvertisedGrade));
                commandWrapper.Parameters.Add(new SqlParameter("@HighestAdvertisedGrade", currentcr.HighestAdvertisedGrade));
                commandWrapper.Parameters.Add(new SqlParameter("@isStandardCR", currentcr.IsStandardCR));
                commandWrapper.Parameters.Add(new SqlParameter("@updatedByID", currentcr.UpdatedByID));
                commandWrapper.Parameters.Add(new SqlParameter("@IsActive", currentcr.IsActive));
                ExecuteNonQuery(commandWrapper);
            }
            catch (Exception ex)
            {
                ExceptionBase.HandleException(ex);
            }
        }
Beispiel #5
0
      /// <summary>
      /// Determines whether the specified System.Object is equal to the current object.
      /// </summary>
      /// <param name="obj">The System.Object to compare with the current object.</param>
      /// <returns>Returns true if the specified System.Object is equal to the current object; otherwise, false.</returns>
      public override bool Equals(Object obj)
      {
          CategoryRating CategoryRatingobj = obj as CategoryRating;

          return((CategoryRatingobj == null) ? false : (this.CRID == CategoryRatingobj.CRID));
      }
 public static int RestoreCategoryRating(CategoryRating currentcr, int currentUserID)
 {
     return(RestoreCategoryRating(currentcr.CRID, currentUserID));
 }
 public static int DeleteCategoryRating(CategoryRating currentcr, int currentUserID)
 {
     return(DeleteCategoryRating(currentcr.CRID, currentUserID));
 }