예제 #1
0
        protected void buttonClick(object sender, EventArgs e)
        {
            HtmlInputButton b = sender as HtmlInputButton;

            int    c_pos  = b.ID.IndexOf('c');
            int    r_pos  = b.ID.IndexOf('r');
            string rowval = b.ID.Substring(r_pos + 1, (c_pos - r_pos - 1));
            string colval = b.ID.Substring(c_pos + 1);

            int row = Convert.ToInt32(rowval);
            int col = Convert.ToInt32(colval);

            var date     = days[col];
            var timeslot = timeSlots[row];

            string makeBooking = "INSERT INTO [Booking] ([facility_id],[user_id],[date],[time_start],[time_slots]) VALUES (@facility_id,@user_id,@date,@time_start,@time_slots); SELECT SCOPE_IDENTITY()";

            SqlCommand booking_cmd = new SqlCommand(makeBooking, con);

            int facility_id = Convert.ToInt32(DropDownList.SelectedValue);

            HttpCookie userCookie;
            int        user_id_session = -1;

            userCookie = Request.Cookies["UserID"];
            if (userCookie != null)
            {
                user_id_session = Convert.ToInt32(userCookie.Value);
            }

            booking_cmd.Parameters.AddWithValue("@facility_id", facility_id);
            booking_cmd.Parameters.AddWithValue("@date", date);
            booking_cmd.Parameters.AddWithValue("@user_id", user_id_session);
            booking_cmd.Parameters.AddWithValue("@time_start", timeslot);
            booking_cmd.Parameters.AddWithValue("@time_slots", 1);

            try
            {
                int id = Convert.ToInt32(booking_cmd.ExecuteScalar());

                AccessCodeController.GetInstance().GenerateCodeAndSend(user_id_session, id);


                Response.Write("<script>alert('Booking Successful');</script>");
                tableContent.Rows[row + 1].Cells[col + 1].BgColor = "Yellow";
                tableContent.Rows[row + 1].Cells[col + 1].Controls.Clear();

                HtmlInputButton input = new HtmlInputButton();
                input.ID           = "b" + id + "r" + row + "c" + col;
                input.Value        = "Delete";
                input.ServerClick += deleteClick;
                input.Attributes.Add("autopostback", "false");

                tableContent.Rows[row + 1].Cells[col + 1].Controls.Add(input);
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('Booking UnSuccessful');</script>");
            }
        }
예제 #2
0
        protected void buttonResendCode_Click(object sender, EventArgs e)
        {
            string code = AccessCodeController.GetInstance().GenerateCodeAndSend(Int16.Parse(HiddenFieldUserId.Value), Int16.Parse(HiddenFieldId.Value));

            Session.Remove("BookingId");
            Response.Redirect("~/Pages/Bookings/SearchBooking.aspx");
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["BookingId"] != null)
                {
                    int     id      = Int16.Parse((string)Session["BookingId"]);
                    Booking booking = BookingController.GetInstance().Recover(id);
                    bool    exists  = AccessCodeController.GetInstance().ExistsAccessCode(booking.user_id, booking.booking_id);

                    if (exists)
                    {
                        CheckCode.Visible = true;
                        SendCode.Visible  = false;
                    }
                    else
                    {
                        SendCode.Visible  = true;
                        CheckCode.Visible = false;
                    }
                    HiddenFieldId.Value     = id.ToString();
                    HiddenFieldUserId.Value = booking.user_id.ToString();
                }
            }
        }
예제 #4
0
        protected void CustomValidatorMatchCode_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool valid = AccessCodeController.GetInstance().ExistsAccessCode(Int16.Parse(HiddenFieldUserId.Value), Int16.Parse(HiddenFieldId.Value));

            if (!valid)
            {
                args.IsValid = false;
            }
        }
예제 #5
0
        protected void buttonCheckCode_Click(object sender, EventArgs e)
        {
            AccessCode valid = AccessCodeController.GetInstance().RetrieveAccessCode(Int16.Parse(HiddenFieldUserId.Value), Int16.Parse(HiddenFieldId.Value));

            if (valid != null)
            {
                valid.status = AccessCode.Status.Validated;
                AccessCodeController.GetInstance().UpdateAccessCode(valid);
                Session.Remove("BookingId");
                Response.Redirect("~/Pages/Bookings/SearchBooking.aspx");
            }
        }
        private void End_Access_Click(object sender, System.EventArgs args)
        {
            string     id         = ((Button)sender).CommandArgument;
            Booking    booking    = BookingController.GetInstance().Recover(Int16.Parse(id));
            AccessCode accessCode = AccessCodeController.GetInstance().RetrieveAccessCode(booking.user_id, booking.booking_id);

            if (accessCode != null)
            {
                accessCode.status = AccessCode.Status.Ended;
                AccessCodeController.GetInstance().UpdateAccessCode(accessCode);
            }
            Response.Redirect("~/Pages/Bookings/SearchBooking.aspx");
        }
        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);
            }
        }
예제 #9
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);
            }
        }