public static CourseCreditsBLL GetDetails(string Key)
        {
            DataTable        dt = CourseCreditsDAL.GetDetails(Key).Tables[0];
            CourseCreditsBLL cc;

            if (dt.Rows.Count > 0)
            {
                cc = (CourseCreditsBLL)dt.Rows[0];
            }
            else
            {
                cc = new CourseCreditsBLL();
            }
            return(cc);
        }
        public int Save()
        {
            CourseCreditsBLL cc = null;

            if (Key != null)
            {
                cc = CourseCreditsBLL.GetDetails(Key);
                if (cc == null)
                {
                    throw new CourseCreditsException("Invalid Key.");
                }
                if (cc.UsedCredits < cc.TotalCredits)
                {
                    EventID = cc.EventID;
                }
                else
                {
                    throw (new CourseCreditsException("There are no credits left for this key."));
                }
            }
            if (EventID > 0)
            {
                if (UserEnrolmentBLL.GetDetails(UserID, EventID).ID == 0)
                {
                    AdminUserID = UserBLL.AdminID;
                    ID          = UserEnrolmentDAL.Save(UserID, EventID, AdminUserID, (cc.ID > 0) ? "s" : "a", "v", cc.ID);
                    if (ID > 0 && cc != null)
                    {
                        cc++;
                    }
                }
                else
                {
                    throw new UserEnrolException("This user is already enrolled on this event.");
                }
            }
            else
            {
                throw (new UserEnrolException("Must include valid EventID or Credit Key"));
            }

            return(ID);
        }
 public static CourseCreditsBLL GetDetails(string Key)
 {
     DataTable dt = CourseCreditsDAL.GetDetails(Key).Tables[0];
     CourseCreditsBLL cc;
     if (dt.Rows.Count > 0)
     { cc = (CourseCreditsBLL)dt.Rows[0]; }
     else
     { cc = new CourseCreditsBLL(); }
     return cc;
 }