Example #1
0
        public bool Cancel()
        {
            DateTime time = DateTime.Now;
            string timeFormat = "HH:mm:ss";

            string today = time.ToString("yyyy-MM-dd");

            //check for possible time-based errors before submitting the cancellation to DB
            if (string.Compare(resDate, today) < 0)
            {
                cancelMsg = "Unable to cancel reservation: date has already passed.";
                return false;
            }
            else if (resDate == today)
            {
                if (string.Compare(resStartTime, time.ToString(timeFormat)) < 0)
                {
                    cancelMsg = "Unable to cancel reservation: reserved time has already passed.";
                    return false;
                }
            }

            //check for possible user-based errors before submitting the cancellation to DB
            // 12/5/12 May not need to anymore

            //connect to DB for cancellation
            DBWrapper wrap = new DBWrapper("localhost", "finalproject", "devon", "devon");
            wrap.Connect();
            wrap.CancelReservation(resID);
            wrap.Disconnect();

            cancelMsg = "Cancellation successful.";
            NotifyCancelByEmail();
            return true;
        }