Example #1
0
        public bool SubmitBooking(string username, DateTime startDate, DateTime endDate)
        {
            try
            {
                int staffID = (from s in db.Staffs
                               where s.UserID == username
                               select s.StaffID).FirstOrDefault();

                HolidayCheck holiday = new HolidayCheck()
                {
                    StaffID   = staffID,
                    StartDate = startDate,
                    EndDate   = endDate,
                    Pending   = true,
                    Approved  = false,
                    Cancel    = false,
                };

                db.HolidayChecks.InsertOnSubmit(holiday);
                db.SubmitChanges();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in " + MethodBase.GetCurrentMethod().Name + "function \nError Message: " + e);
            }

            return(false);
        }
Example #2
0
        private bool UpdateBooking(string username, DateTime startDate, DateTime endDate, bool approve)
        {
            try
            {
                // Get staff
                int staffID = (from s in db.Staffs
                               where s.UserID == username
                               select s.StaffID).FirstOrDefault();

                // Get holiday
                HolidayCheck holiday = (from hc in db.HolidayChecks
                                        where hc.StaffID == staffID && hc.StartDate == startDate && hc.EndDate == endDate
                                        select hc).FirstOrDefault();


                holiday.Pending  = false;
                holiday.Approved = approve;

                db.SubmitChanges();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in " + MethodBase.GetCurrentMethod().Name + "function \nError Message: " + e);
            }

            return(false);
        }