private void Delete_Click(object sender, System.EventArgs args)
        {
            string id = ((Button)sender).CommandArgument;

            FacilityController.GetInstance().DeleteFacility(Int16.Parse(id));
            Response.Redirect("~/Pages/Facilities/Facilities.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["facultyId"] != null)
                {
                    int      id       = Int16.Parse((string)Session["facultyId"]);
                    Facility facility = FacilityController.GetInstance().Recover(id);
                    HiddenFieldFacilityId.Value = facility.Id.ToString();


                    textboxFacityName.Text             = facility.Name;
                    DropDownListTimeSlot.SelectedValue = facility.timeSlot.ToString();


                    DropDownListStartTime.SelectedValue    = Int16.Parse(facility.StartTime.ToString("hh", CultureInfo.InvariantCulture)).ToString();
                    DropDownListStartMinutes.SelectedValue = Int16.Parse(facility.StartTime.ToString("mm", CultureInfo.InvariantCulture)).ToString();
                    DropDownListStartPeriod.SelectedValue  = facility.StartTime.ToString("tt", CultureInfo.InvariantCulture);

                    DropDownListEndTime.SelectedValue      = Int16.Parse(facility.EndTime.ToString("hh", CultureInfo.InvariantCulture)).ToString();
                    DropDownListEndMinutes.SelectedValue   = Int16.Parse(facility.EndTime.ToString("mm", CultureInfo.InvariantCulture)).ToString();
                    DropDownListEndDayPeriod.SelectedValue = facility.EndTime.ToString("tt", CultureInfo.InvariantCulture);

                    buttonCreateFacility.Visible = false;
                    add.Visible = false;
                }
                else
                {
                    buttonUpdateFacility.Visible = false;
                    edit.Visible = false;
                }
            }
        }
 protected void buttonCreateFacility_Click(object sender, EventArgs e)
 {
     if (validateTimes())
     {
         FacilityController.GetInstance().InsertFacility(buildFacility());
         Response.Redirect("~/Pages/Facilities/Facilities.aspx");
     }
 }
        protected void buttonUpdateFacility_Click(object sender, EventArgs e)
        {
            if (validateTimes())
            {
                Facility facility = buildFacility();
                facility.Id = Int16.Parse(HiddenFieldFacilityId.Value);
                FacilityController.GetInstance().UpdateFacility(facility);

                Session.Remove("facultyId");
                Response.Redirect("~/Pages/Facilities/Facilities.aspx");
            }
        }
        private void LoadTable(String search)
        {
            //string search = TextBoxSearchFacility.Text;
            List <Facility> facilities = FacilityController.GetInstance().SearchFacility(search);

            //show or not the table
            tableFacilities.Visible    = facilities.Count > 0;
            NoFacilityElements.Visible = facilities.Count < 1;
            FacilitiesTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "Time Slot";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

            cell03.Text      = " Start Time";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "End Time";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            TableCell cell05 = new TableCell();

            cell05.Text      = " ";
            cell05.Font.Bold = true;
            row0.Cells.Add(cell05);

            TableCell cell06 = new TableCell();

            cell06.Text      = " ";
            cell06.Font.Bold = true;
            row0.Cells.Add(cell06);
            FacilitiesTable.Rows.Add(row0);

            foreach (Facility f in facilities)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = f.Name;
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = f.timeSlot + "";
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = f.StartTime.ToString("HH:mm tt");
                row.Cells.Add(cell3);

                TableCell cell4 = new TableCell();
                cell4.Text = f.EndTime.ToString("HH:mm tt");
                row.Cells.Add(cell4);
                FacilitiesTable.Rows.Add(row);

                TableCell cell5      = new TableCell();
                Button    buttonEdit = new Button();
                buttonEdit.Text            = "Edit";
                buttonEdit.CommandArgument = f.Id.ToString();
                buttonEdit.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                buttonEdit.Attributes.Add("autopostback", "false");
                buttonEdit.Click += Edit_Click;
                cell5.Controls.Add(buttonEdit);
                row.Cells.Add(cell5);
                FacilitiesTable.Rows.Add(row);

                TableCell cell6        = new TableCell();
                Button    buttonDelete = new Button();
                buttonDelete.Text            = "Delete";
                buttonDelete.CommandArgument = f.Id.ToString();
                buttonDelete.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                buttonDelete.Attributes.Add("autopostback", "false");
                buttonDelete.Click += Delete_Click;
                cell6.Controls.Add(buttonDelete);
                row.Cells.Add(cell6);
                FacilitiesTable.Rows.Add(row);
            }
        }
        private void LoadTable()
        {
            HttpCookie userCookie;
            int        user_id = -1;

            userCookie = Request.Cookies["UserID"];
            if (userCookie != null)
            {
                user_id = Convert.ToInt32(userCookie.Value);
            }
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(user_id,
                                                                                    DateTime.Now,
                                                                                    DateTime.Now.AddDays(7));

            //show or not the table
            table.Visible      = bookings.Count > 0;
            NoElements.Visible = bookings.Count < 1;
            DashboardTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell05 = new TableCell();

            cell05.Text      = "Date";
            cell05.Font.Bold = true;
            row0.Cells.Add(cell05);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            DashboardTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell15 = new TableCell();
                cell15.Text = FacilityUtil.ConvertDateTimeToDateString(b.date);
                row.Cells.Add(cell15);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                DashboardTable.Rows.Add(row);
            }
        }
        private void LoadTable(String search)
        {
            //string search = TextBoxSearchFacility.Text;
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(FacilityUtil.ConvertDateStringFromCalendarToDateTime(search));

            //show or not the table
            tableBookings.Visible     = bookings.Count > 0;
            NoBookingElements.Visible = bookings.Count < 1;
            BookingsTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            TableCell cell05 = new TableCell();

            cell05.Text      = " ";
            cell05.Font.Bold = true;
            row0.Cells.Add(cell05);

            /*
             * TableCell cell06 = new TableCell();
             * cell06.Text = " ";
             * cell06.Font.Bold = true;
             * row0.Cells.Add(cell06);*/

            BookingsTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                TableCell cell5 = new TableCell();
                if (AccessCode.ConvertStatus(status) == AccessCode.Status.Validated)
                {
                    Button buttonEndAccess = new Button();
                    buttonEndAccess.Text            = "End Access";
                    buttonEndAccess.CommandArgument = b.booking_id.ToString();
                    buttonEndAccess.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                    buttonEndAccess.Attributes.Add("autopostback", "false");
                    buttonEndAccess.Click += End_Access_Click;
                    cell5.Controls.Add(buttonEndAccess);
                }
                else if (AccessCode.ConvertStatus(status) == AccessCode.Status.Ended)
                {
                    cell5.Text = " ";
                }
                else
                {
                    Button buttonValidateAccess = new Button();
                    buttonValidateAccess.Text            = "Validate Access Code";
                    buttonValidateAccess.CommandArgument = b.booking_id.ToString();
                    buttonValidateAccess.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                    buttonValidateAccess.Attributes.Add("autopostback", "false");
                    buttonValidateAccess.Click += Validate_Click;
                    cell5.Controls.Add(buttonValidateAccess);
                }
                row.Cells.Add(cell5);

                /*
                 * TableCell cell6 = new TableCell();
                 * Button buttonDelete = new Button();
                 * buttonDelete.Text = "Delete";
                 * buttonDelete.CommandArgument = b.booking_id.ToString();
                 * buttonDelete.CssClass = "w3-button w3-black w3-padding w3-small w3-round";
                 * buttonDelete.Attributes.Add("autopostback", "false");
                 * buttonDelete.Click += Delete_Click;
                 * cell6.Controls.Add(buttonDelete);
                 * row.Cells.Add(cell6);*/
                BookingsTable.Rows.Add(row);
            }
        }
示例#8
0
        private void LoadTable(String date)
        {
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(FacilityUtil.ConvertDateStringFromCalendarToDateTime(date));

            //show or not the table
            table.Visible      = bookings.Count > 0;
            NoElements.Visible = bookings.Count < 1;
            DashboardTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            DashboardTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                DashboardTable.Rows.Add(row);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <string> dataRoles = new List <string>();

            dataRoles.Add(Core.Models.User.Category.Admin.ToString());
            dataRoles.Add(Core.Models.User.Category.Faculty.ToString());
            dataRoles.Add(Core.Models.User.Category.Moderator.ToString());
            dataRoles.Add(Core.Models.User.Category.Staff.ToString());
            dataRoles.Add(Core.Models.User.Category.Student.ToString());


            //show or not the table
            FacilityTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            foreach (string role in dataRoles)
            {
                TableCell cell02 = new TableCell();
                cell02.Text      = role;
                cell02.Font.Bold = true;
                row0.Cells.Add(cell02);
            }
            FacilityTable.Rows.Add(row0);

            List <Facility> facilities = FacilityController.GetInstance().ListFacility();


            foreach (Facility facility in facilities)
            {
                TableRow  row     = new TableRow();
                TableCell cell001 = new TableCell();
                cell001.Text = facility.Name;
                row.Cells.Add(cell001);

                foreach (string role in dataRoles)
                {
                    Access    access  = AccessController.GetInstance().RetrieveAccessCreateIfNotExists(facility.Id, role);
                    TableCell cell002 = new TableCell();
                    cell002.Text = role;
                    CheckBox cb = new CheckBox();
                    cb.ID              = access.Id.ToString();
                    cb.Checked         = access.granted;
                    cb.CheckedChanged += Checked_Changed;
                    cb.CssClass        = "w3-padding";

                    cell002.Controls.Add(cb);
                    row.Cells.Add(cell002);
                }


                FacilityTable.Rows.Add(row);
            }
        }