Example #1
0
        public bool Change(string newDate, string newStartTime, string newEndTime)
        {
            DateTime time = DateTime.Now;
            string timeFormat = "HH:mm:ss";

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

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

            //check for possible user-based errors before submitting the cancellation to DB

            //connect to DB for change
            DBWrapper wrap = new DBWrapper("localhost", "finalproject", "devon", "devon");
            wrap.Connect();
            wrap.ChangeReservation(resID, resDate, resStartTime, resEndTime, resRoom, resUserID);
            wrap.Disconnect();

            cancelMsg = "Change successful.";
            return true;
        }