protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null || !UserController.isAdmin(Int32.Parse(Session["user"].ToString())))
            {
                Response.Redirect("/View/Home.aspx");
                return;
            }

            PaymentTypeTable.DataSource = PaymentTypeController.getAllPaymentTypes();
            PaymentTypeTable.DataBind();
        }
示例#2
0
        protected void Load_PaymentTypes()
        {
            List <PaymentType> paymentTypeList = PaymentTypeController.getAllPaymentTypes();

            for (int i = 0; i < paymentTypeList.Count; i++)
            {
                TableRow newRow = new TableRow();
                PaymentTypeTable.Controls.Add(newRow);

                TableCell paymentTypeIdCell = new TableCell();
                paymentTypeIdCell.Controls.Add(new Label()
                {
                    Text = paymentTypeList.ElementAt(i).ID.ToString()
                });
                newRow.Cells.Add(paymentTypeIdCell);

                TableCell typeCell = new TableCell();
                typeCell.Controls.Add(new Label()
                {
                    Text = paymentTypeList.ElementAt(i).Type
                });
                newRow.Cells.Add(typeCell);

                User user = UserController.getUserByID(Convert.ToInt32(Session["auth_user"]));
                if (user != null)
                {
                    TableCell ActionCell = new TableCell();
                    int       id         = paymentTypeList.ElementAt(i).ID;
                    if (user.RoleID == 3)
                    {
                        Button btnUpdate = new Button {
                            CssClass = "btn-primary", Text = "Update", ID = id.ToString()
                        };
                        Button btnDelete = new Button {
                            CssClass = "btn-danger", Text = "Delete", ID = id.ToString() + "delete"
                        };
                        btnUpdate.Click += new EventHandler(Btn_Update_Click);
                        btnDelete.Click += new EventHandler(Btn_Delete_Click);
                        ActionCell.Controls.Add(btnUpdate);
                        ActionCell.Controls.Add(btnDelete);
                        newRow.Cells.Add(ActionCell);
                    }
                    else
                    {
                        Response.Redirect("Home.aspx");
                    }
                }
            }
        }