protected void Page_Load(object sender, EventArgs e)
        {
            SQLTrans.LoginData ldata = ((SQLTrans.LoginData)Session["userdata"]);
            bool admin = false;

            if (ldata != null)
            {
                admin = ldata.isAdmin;
            }
            if (!admin && (Request["action"] == "edit" || Request["action"] == "delete"))
            {
                output.Text = MSGNOGRANT;
            }
            else if (Request["id"] != null)
            {
                int id = Convert.ToInt32(Request["id"]);
                if (Request["action"] == "delete")
                {
                    try
                    {
                        client.sp_Delete(ldata, SQLTrans.DeleteType.Restaurante, id);
                        output.Text = MSGDEL;
                    }
                    catch { output.Text = MSGNODEL; }
                    return;
                }
                if (Request["action"] == "edit")
                {
                    Button btnEdit = new Button();
                    Button btnDel  = new Button();
                    btnEdit.Text         = "Editar";
                    btnDel.Text          = "Eliminar";
                    btnDel.OnClientClick = "if ( ! UserDeleteConfirmation()) return false;";
                    btnDel.Click        += BtnDel_Click;
                    btnEdit.Click       += BtnEdit_Click;
                    editcontrols.Controls.Add(btnEdit);
                    editcontrols.Controls.Add(btnDel);
                    txtNombre.ReadOnly     = false;
                    txtReferencia.ReadOnly = false;
                    upload.Enabled         = true;
                    upload.CssClass        = "";
                }
                portrait.Attributes.Remove("class");
                SQLTrans.Restaurantes restaurants;
                try
                {
                    restaurants = client.GetRestaurante(id)[0];
                }
                catch
                {
                    output.Text = MSGNODISH;
                    return;
                }
                if (!IsPostBack)
                {
                    if (restaurants.URL == null || restaurants.URL == "")
                    {
                        img.ImageUrl = "/images/sin-imagen.gif";
                    }
                    else
                    {
                        img.ImageUrl = restaurants.URL;
                    }
                    txtNombre.Text     = restaurants.NOMBRE;
                    txtReferencia.Text = restaurants.REFERENCIA;
                }
            }
            else
            {
                userlist.Attributes.Remove("class");
                string locales = "";
                foreach (SQLTrans.Restaurantes r in client.GetRestaurantes())
                {
                    locales += string.Concat("<tr><td><img src='", (r.URL == null || r.URL == string.Empty) ? "/images/sin-imagen.gif" : r.URL, "' height='200px' width='200px' /></td><td>", r.NOMBRE, "</td><td>", r.REFERENCIA, "</td><td>", r.RATE == "" ?"Sin Datos" : Math.Round(double.Parse(r.RATE), 2).ToString(), "</td><td><a href=Locales.aspx?id=", r.ID, ">Ver</a>&emsp;");
                    if (ldata != null)
                    {
                        if (ldata.isAdmin)
                        {
                            locales += string.Concat("<a href=Locales.aspx?id=", r.ID, "&action=edit>Editar</a>&emsp;<a href=Locales.aspx?id=", r.ID, "&action=delete onclick=\"if ( ! UserDeleteConfirmation()) return false;\">Eliminar</a></td></tr>\n");
                        }
                    }
                }
                tbody.InnerHtml = locales;
            }
        }