Exemple #1
0
        public void NormalReserve(string strMembershipID, int nPackageID, int nClassInstanceID, bool needToVerifyMemberPackage)
        {
            TblClassInstance classInstance = new TblClassInstance();
            classInstance.NClassInstanceID = nClassInstanceID;
            classInstance.SelectOne();

            TblClassAttendance classAttendance = new TblClassAttendance();

            DateTime classDate = new DateTime(classInstance.DtDate.Value.Year, classInstance.DtDate.Value.Month, classInstance.DtDate.Value.Day,
                classInstance.DtStartTime.Value.Hour, classInstance.DtStartTime.Value.Minute, classInstance.DtStartTime.Value.Second);

            if (DateTime.Today > classDate)
                throw new Exception("You are not allow to reserve the previous day class.");

            if (classAttendance.IsReservedThisClass(nClassInstanceID, strMembershipID))
            {
                throw new Exception("You have reserved this class.");
            }

            if (classAttendance.GetReservation(nClassInstanceID).Rows.Count > ACMS.Convert.ToInt32(classInstance.NMaxNo))
            {
                throw new Exception("Class is fully reserved by members. Please try again later.");
            }

            if (needToVerifyMemberPackage)
            {
                if (!VerifyMemberPackageAllowCertainClass(nPackageID, classInstance.StrClassCode.Value))
                {
                    //throw new Exception("The package you wish to use is not allow to attend the class. Please use other package.");
                    DialogResult result = MessageBox.Show("The package you wish to use is not allow to attend the class. Do you still want to reserve it. \n " +
                        "(An unlinked record will be create if you click yes) ", "Warning",MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        MemberPackage.CreateUnlinkedMemberPackage(strMembershipID, ref nPackageID);
                    }
                    else
                    {
                        return;
                    }
                }
            }

            //			if (!VerifyMemberPackageAllowCertainClass(nPackageID, classInstance.StrClassCode.Value))
            //				throw new Exception("The package you wish to use is not allow to reserve the class. Please use other package.");

            //Prompt Package going to expiry
            //Prompt Remaining class

            classAttendance.NClassInstanceID = nClassInstanceID;
            classAttendance.StrMembershipID = strMembershipID;
            classAttendance.NEmployeeID = User.EmployeeID;
            classAttendance.NReservedByID = User.EmployeeID;
            classAttendance.FUOBBooking = System.Data.SqlTypes.SqlBoolean.False;
            classAttendance.DtDate = classInstance.DtDate.Value;
            classAttendance.DtReservationDate = DateTime.Today.Date;
            classAttendance.DtStartTime = Convert.ToDateTime(classInstance.DtDate.Value.ToString("yyyy-MM-dd")+" "+ classInstance.DtStartTime.Value.ToString("H:mm:ss"));
            classAttendance.DtEndTime = Convert.ToDateTime(classInstance.DtDate.Value.ToString("yyyy-MM-dd") + " " + classInstance.DtEndTime.Value.ToString("H:mm:ss"));
            classAttendance.StrBranchCode = User.BranchCode;
            classAttendance.DtLastEditDate = DateTime.Now;
            classAttendance.NStatusID = 0;
            classAttendance.NPackageID = nPackageID;
            classAttendance.Insert();

            TblBranch sqlBranch = new TblBranch();
            TblClass sqlClass = new TblClass();

            sqlBranch.StrBranchCode = classAttendance.StrBranchCode.ToString();
            sqlBranch.SelectOne();

            sqlClass.StrClassCode = classInstance.StrClassCode;
            sqlClass.SelectOne();

            if (isMobileAppUser(strMembershipID))
                PushNotification(strMembershipID, "Your class booking for " + sqlClass.StrDescription.ToString() + " at " + sqlBranch.StrBranchName.ToString() + " at " + classAttendance.DtStartTime.Value.ToString("h.mmtt") + " on " + classAttendance.DtStartTime.Value.ToString("dd MMM") + " has been confirmed.");
        }