예제 #1
0
    protected void ServerValidationFilled(object source, ServerValidateEventArgs arguments)
    {
        //Makes sure that the date range has not already been filled for this time period/position/slot.
        DropDownList RoleDownList        = FormView1.FindControl("RoleDownList") as DropDownList;
        CheckBox     MorningSlotCheckBox = FormView1.FindControl("MorningSlotCheckBox") as CheckBox;


        Calendar Calendar1 = FormView1.FindControl("Calendar1") as Calendar;
        Calendar Calendar2 = FormView1.FindControl("Calendar2") as Calendar;

        if (Calendar1.SelectedDate != new DateTime() && Calendar2.SelectedDate != null && Calendar1.SelectedDate <= Calendar2.SelectedDate)
        {
            using (var db = new SupervisionDBDataContext())
            {
                arguments.IsValid = !db.Designations.Any(
                    x => x.MorningSlot == MorningSlotCheckBox.Checked &&
                    x.Role == RoleDownList.SelectedValue &&
                    (x.EndDate >= Calendar1.SelectedDate &&
                     x.StartDate <= Calendar2.SelectedDate)       //Making sure ranges do not overlap
                    );
            }
        }
        else
        {
            arguments.IsValid = true;
        }
    }
예제 #2
0
    protected void FreeDatesChanged(object sender, EventArgs e)
    {
        DropDownList RoleDownList        = FormView1.FindControl("RoleDownList") as DropDownList;
        CheckBox     MorningSlotCheckBox = FormView1.FindControl("MorningSlotCheckBox") as CheckBox;

        using (var db = new SupervisionDBDataContext())
        {
            List <DateTime> startDates = new List <DateTime>();
            List <DateTime> endDates   = new List <DateTime>();

            dateRangesUsed = db.Designations.Where(
                x => x.MorningSlot == MorningSlotCheckBox.Checked &&
                x.Role == RoleDownList.SelectedValue).ToList();
        }
    }
예제 #3
0
    protected void FreeDatesChanged(object sender, EventArgs e)
    {
        DropDownList RoomDownList        = FormView1.FindControl("RoomDownList") as DropDownList;
        CheckBox     MorningSlotCheckBox = FormView1.FindControl("MorningSlotCheckBox") as CheckBox;

        using (var db = new SupervisionDBDataContext())
        {
            List <DateTime> Date = new List <DateTime>();


            datesUsed = db.RoomAssignments.Where(
                x => x.MorningSlot == MorningSlotCheckBox.Checked &&
                x.RoomID == Int32.Parse(RoomDownList.SelectedValue)).ToList();
        }
    }
예제 #4
0
    private void SetDatesWhichCannotBeUsed()
    {
        DropDownList RoomDownList        = FormView1.FindControl("RoomDownList") as DropDownList;
        CheckBox     MorningSlotCheckBox = FormView1.FindControl("MorningSlotCheckBox") as CheckBox;

        using (var db = new SupervisionDBDataContext())
        {
            List <DateTime> Date = new List <DateTime>();


            datesUsed = db.RoomAssignments.Where(
                x => x.MorningSlot == MorningSlotCheckBox.Checked &&
                x.RoomID == Int32.Parse(RoomDownList.SelectedValue)).ToList();
        }
    }
 private void SetDateRangesWhichCannotBeUsed()
 {
     if (FormView1.FindControl("StaffDropDownList") is DropDownList StaffDropDownList && FormView1.FindControl("MorningSlotList") is DropDownList MorningSlotList)
     {
         using (var db = new SupervisionDBDataContext())
         {
             if (MorningSlotList.Text.Equals(""))
             {
                 DateRangesUsed = db.StaffBusies.Where(x => x.StaffID.ToString() == StaffDropDownList.SelectedValue).ToList();
             }
             else
             {
                 DateRangesUsed = db.StaffBusies.Where(x => x.StaffID.ToString() == StaffDropDownList.SelectedValue && (x.MorningSlot == Convert.ToBoolean(MorningSlotList.Text))).ToList();
             }
         }
     }
 }
예제 #6
0
    private void SetDateRangesWhichCannotBeUsed()
    {
        DropDownList RoleDownList        = FormView1.FindControl("RoleDownList") as DropDownList;
        CheckBox     MorningSlotCheckBox = FormView1.FindControl("MorningSlotCheckBox") as CheckBox;

        if (RoleDownList != null && MorningSlotCheckBox != null)
        {
            using (var db = new SupervisionDBDataContext())
            {
                List <DateTime> startDates = new List <DateTime>();
                List <DateTime> endDates   = new List <DateTime>();

                dateRangesUsed = db.Designations.Where(
                    x => x.MorningSlot == MorningSlotCheckBox.Checked &&
                    x.Role == RoleDownList.SelectedValue).ToList();
            }
        }
    }
예제 #7
0
    protected void ServerValidationStaff(object source, ServerValidateEventArgs arguments)
    {
        //Makes sure that the staff member is not busy for this time period/position/slot.

        DropDownList StaffDropDownList = FormView1.FindControl("StaffDropDownList") as DropDownList;


        Calendar Calendar1 = FormView1.FindControl("Calendar1") as Calendar;
        Calendar Calendar2 = FormView1.FindControl("Calendar2") as Calendar;

        if (Calendar1.SelectedDate != new DateTime() && Calendar2.SelectedDate != null && Calendar1.SelectedDate <= Calendar2.SelectedDate)
        {
            using (var db = new SupervisionDBDataContext())
            {
                var staffIsBusy = db.StaffBusies.Where(
                    x =>
                    x.StaffID.ToString() == StaffDropDownList.SelectedValue &&
                    (x.EndDate >= Calendar1.SelectedDate &&
                     x.StartDate <= Calendar2.SelectedDate)).ToList();          //Making sure ranges do not overlap
                if (staffIsBusy.Count == 0)
                {
                    arguments.IsValid = true;
                }
                else
                {
                    arguments.IsValid = false;
                    var errorMessage = "The staff member is unavailiable for the date range.";
                    staffIsBusy.ForEach(x =>
                    {
                        errorMessage += String.Format("<br /> {0} from {1:dd/MM/yyyy} to {2:dd/MM/yyyy}", x.reason, x.StartDate, x.EndDate);
                    });
                    StaffValidator.ErrorMessage = errorMessage;
                }
            }
        }
        else
        {
            arguments.IsValid = true;
        }
    }